blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 3
264
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
85
| license_type
stringclasses 2
values | repo_name
stringlengths 5
140
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 941
values | visit_date
timestamp[us]date 2015-08-09 11:21:18
2023-09-06 10:45:07
| revision_date
timestamp[us]date 1977-08-08 00:00:00
2023-09-17 19:19:19
| committer_date
timestamp[us]date 1977-08-08 00:00:00
2023-09-06 06:22:19
| github_id
int64 3.89k
681M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us]date 2012-06-07 00:51:45
2023-09-14 21:58:39
⌀ | gha_created_at
timestamp[us]date 2008-03-27 23:40:48
2023-08-21 23:17:38
⌀ | gha_language
stringclasses 142
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
10.4M
| extension
stringclasses 120
values | content
stringlengths 3
10.4M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
158
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c7914b7b26041b88df4a6ae27df10a64ecb777fc | 3a0da4368b6874c297328025b381cb7c7e5233ee | /source/game/field.cpp | 9cb440b17a1cfbdd0b22ae7448aa179401b02566 | [] | no_license | Unlogicaly/MIPT_task2_memo | 7bc173a544c13ead8d4d36af82874251194b944f | 330f15ccff5e2dea8a547f49ff8fa801cf204e9a | refs/heads/master | 2020-09-08T16:46:14.004445 | 2019-12-09T17:20:49 | 2019-12-09T17:20:49 | 221,187,355 | 0 | 0 | null | 2019-11-23T09:01:46 | 2019-11-12T10:09:23 | null | UTF-8 | C++ | false | false | 3,612 | cpp | #include "field.h"
#include <algorithm>
#include <chrono>
#include <random>
// Generate shuffled range from 0 to max
std::vector<int> rand_range(int max, long long seed = 0)
{
if (seed == 0)
seed = std::chrono::system_clock::now().time_since_epoch().count();
std::vector<int> res(max);
for (decltype(res.size()) i = 0; i < res.size(); ++i)
{
res[i] = static_cast<int>(i);
}
std::shuffle(res.begin(), res.end(), std::default_random_engine{seed});
return res;
}
Card *Field::get_card(int x, int y)
{
return cards[(x - get_side_gap()) / (get_size() + get_shift())][(y - get_up_gap()) / (get_size() + get_shift())];
}
Field::Field(bool &_end, int x_resol, int y_resol) : myWin(_end, x_resol, y_resol), opened{nullptr, nullptr}
{
long long seed = std::chrono::system_clock::now().time_since_epoch().count();
myWin::color(Graph_lib::Color::white);
std::vector<std::string> pictures;
get_names(pictures);
std::shuffle(pictures.begin(), pictures.end(), std::default_random_engine{seed});
std::vector<int> pairs = rand_range(get_height() * get_width(), seed);
for (auto i = 0; i < get_width(); ++i)
{
cards.emplace_back();
for (auto j = 0; j < get_height(); ++j)
cards[i].push_back(nullptr);
}
for (auto i = 0; i < get_height() * get_width(); i += 2)
{
int i1 = pairs[i] / get_width(), j1 = pairs[i] % get_width();
cards[j1][i1] =
new Card(get_point(j1, i1), get_size(), get_pic(pictures[i / 2], get_size(), get_size()), cb_show);
attach(*cards[j1][i1]);
attach(*cards[j1][i1]->show);
int i2 = pairs[i + 1] / get_width(), j2 = pairs[i + 1] % get_width();
cards[j2][i2] =
new Card(get_point(j2, i2), get_size(), get_pic(pictures[i / 2], get_size(), get_size()), cb_show);
attach(*cards[j2][i2]);
attach(*cards[j2][i2]->show);
}
}
void Field::treat_last(Card *last)
{
for (auto &lines : cards)
{
for (auto *card : lines)
{
if (!card->is_found and card != last)
{
card->is_found = true;
last->is_found = true;
card->show->hide();
last->show->hide();
card->click();
started = false;
return;
}
}
}
}
void Field::flip(Graph_lib::Address pwin)
{
Fl_Widget &w = Graph_lib::reference_to<Fl_Widget>(pwin);
auto c = get_card(w.x(), w.y());
if (!opened.first)
opened.first = c;
else if (!opened.second)
{
if (opened.first == c)
return;
opened.second = c;
}
else
{
if (opened.first->get_name() == opened.second->get_name())
{
opened.first->show->hide();
opened.second->show->hide();
opened.first->is_found = true;
opened.second->is_found = true;
ready++;
if (c == opened.first or c == opened.second)
{
opened.first = nullptr;
opened.second = nullptr;
return;
}
}
else
{
opened.first->click();
opened.second->click();
}
opened.first = c;
opened.second = nullptr;
}
c->click();
if (ready == get_height() * get_width() / 2 - 1)
{
treat_last(c);
asc();
}
Fl::redraw();
}
Field::~Field()
{
for (auto &line : cards)
for (auto *card : line)
delete card;
}
| [
"[email protected]"
] | |
547d777962fb28b2c7f4e4c8ef43132d3e6a009a | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_5/WWC+poonceonce+ctrlonceonce+Release.c.cbmc.cpp | bab1de600e14ef3935676eed5dae25374028b0c9 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 35,227 | cpp | // Global variabls:
// 3:atom_2_X0_1:1
// 0:vars:2
// 2:atom_1_X0_2:1
// Local global variabls:
// 0:thr0:1
// 1:thr1:1
// 2:thr2:1
#define ADDRSIZE 4
#define LOCALADDRSIZE 3
#define NTHREAD 4
#define NCONTEXT 5
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// Declare arrays for intial value version in contexts
int local_mem[LOCALADDRSIZE];
// Dumping initializations
local_mem[0+0] = 0;
local_mem[1+0] = 0;
local_mem[2+0] = 0;
int cstart[NTHREAD];
int creturn[NTHREAD];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NTHREAD*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NTHREAD*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NTHREAD*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NTHREAD*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NTHREAD*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NTHREAD*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NTHREAD*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NTHREAD*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NTHREAD*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NTHREAD];
int cdy[NTHREAD];
int cds[NTHREAD];
int cdl[NTHREAD];
int cisb[NTHREAD];
int caddr[NTHREAD];
int cctrl[NTHREAD];
__LOCALS__
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
buff(3,0) = 0;
pw(3,0) = 0;
cr(3,0) = 0;
iw(3,0) = 0;
cw(3,0) = 0;
cx(3,0) = 0;
is(3,0) = 0;
cs(3,0) = 0;
crmax(3,0) = 0;
buff(3,1) = 0;
pw(3,1) = 0;
cr(3,1) = 0;
iw(3,1) = 0;
cw(3,1) = 0;
cx(3,1) = 0;
is(3,1) = 0;
cs(3,1) = 0;
crmax(3,1) = 0;
buff(3,2) = 0;
pw(3,2) = 0;
cr(3,2) = 0;
iw(3,2) = 0;
cw(3,2) = 0;
cx(3,2) = 0;
is(3,2) = 0;
cs(3,2) = 0;
crmax(3,2) = 0;
buff(3,3) = 0;
pw(3,3) = 0;
cr(3,3) = 0;
iw(3,3) = 0;
cw(3,3) = 0;
cx(3,3) = 0;
is(3,3) = 0;
cs(3,3) = 0;
crmax(3,3) = 0;
cl[3] = 0;
cdy[3] = 0;
cds[3] = 0;
cdl[3] = 0;
cisb[3] = 0;
caddr[3] = 0;
cctrl[3] = 0;
cstart[3] = get_rng(0,NCONTEXT-1);
creturn[3] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(3+0,0) = 0;
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(2+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
mem(0,1) = meminit(0,1);
co(0,1) = coinit(0,1);
delta(0,1) = deltainit(0,1);
mem(0,2) = meminit(0,2);
co(0,2) = coinit(0,2);
delta(0,2) = deltainit(0,2);
mem(0,3) = meminit(0,3);
co(0,3) = coinit(0,3);
delta(0,3) = deltainit(0,3);
mem(0,4) = meminit(0,4);
co(0,4) = coinit(0,4);
delta(0,4) = deltainit(0,4);
co(1,0) = 0;
delta(1,0) = -1;
mem(1,1) = meminit(1,1);
co(1,1) = coinit(1,1);
delta(1,1) = deltainit(1,1);
mem(1,2) = meminit(1,2);
co(1,2) = coinit(1,2);
delta(1,2) = deltainit(1,2);
mem(1,3) = meminit(1,3);
co(1,3) = coinit(1,3);
delta(1,3) = deltainit(1,3);
mem(1,4) = meminit(1,4);
co(1,4) = coinit(1,4);
delta(1,4) = deltainit(1,4);
co(2,0) = 0;
delta(2,0) = -1;
mem(2,1) = meminit(2,1);
co(2,1) = coinit(2,1);
delta(2,1) = deltainit(2,1);
mem(2,2) = meminit(2,2);
co(2,2) = coinit(2,2);
delta(2,2) = deltainit(2,2);
mem(2,3) = meminit(2,3);
co(2,3) = coinit(2,3);
delta(2,3) = deltainit(2,3);
mem(2,4) = meminit(2,4);
co(2,4) = coinit(2,4);
delta(2,4) = deltainit(2,4);
co(3,0) = 0;
delta(3,0) = -1;
mem(3,1) = meminit(3,1);
co(3,1) = coinit(3,1);
delta(3,1) = deltainit(3,1);
mem(3,2) = meminit(3,2);
co(3,2) = coinit(3,2);
delta(3,2) = deltainit(3,2);
mem(3,3) = meminit(3,3);
co(3,3) = coinit(3,3);
delta(3,3) = deltainit(3,3);
mem(3,4) = meminit(3,4);
co(3,4) = coinit(3,4);
delta(3,4) = deltainit(3,4);
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !36, metadata !DIExpression()), !dbg !42
// br label %label_1, !dbg !43
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !41), !dbg !44
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !37, metadata !DIExpression()), !dbg !45
// call void @llvm.dbg.value(metadata i64 2, metadata !40, metadata !DIExpression()), !dbg !45
// store atomic i64 2, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !46
// ST: Guess
// : Release
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l20_c3
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l20_c3
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
ASSUME(cw(1,0) >= cr(1,3+0));
ASSUME(cw(1,0) >= cr(1,0+0));
ASSUME(cw(1,0) >= cr(1,0+1));
ASSUME(cw(1,0) >= cr(1,2+0));
ASSUME(cw(1,0) >= cw(1,3+0));
ASSUME(cw(1,0) >= cw(1,0+0));
ASSUME(cw(1,0) >= cw(1,0+1));
ASSUME(cw(1,0) >= cw(1,2+0));
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 2;
mem(0,cw(1,0)) = 2;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
is(1,0) = iw(1,0);
cs(1,0) = cw(1,0);
ASSUME(creturn[1] >= cw(1,0));
// ret i8* null, !dbg !47
ret_thread_1 = (- 1);
goto T1BLOCK_END;
T1BLOCK_END:
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !50, metadata !DIExpression()), !dbg !60
// br label %label_2, !dbg !48
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !59), !dbg !62
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !52, metadata !DIExpression()), !dbg !63
// %0 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !51
// LD: Guess
old_cr = cr(2,0);
cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l26_c15
// Check
ASSUME(active[cr(2,0)] == 2);
ASSUME(cr(2,0) >= iw(2,0));
ASSUME(cr(2,0) >= 0);
ASSUME(cr(2,0) >= cdy[2]);
ASSUME(cr(2,0) >= cisb[2]);
ASSUME(cr(2,0) >= cdl[2]);
ASSUME(cr(2,0) >= cl[2]);
// Update
creg_r0 = cr(2,0);
crmax(2,0) = max(crmax(2,0),cr(2,0));
caddr[2] = max(caddr[2],0);
if(cr(2,0) < cw(2,0)) {
r0 = buff(2,0);
ASSUME((!(( (cw(2,0) < 1) && (1 < crmax(2,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(2,0) < 2) && (2 < crmax(2,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(2,0) < 3) && (3 < crmax(2,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(2,0) < 4) && (4 < crmax(2,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(2,0) != co(0,cr(2,0))) {
ASSUME(cr(2,0) >= old_cr);
}
pw(2,0) = co(0,cr(2,0));
r0 = mem(0,cr(2,0));
}
ASSUME(creturn[2] >= cr(2,0));
// call void @llvm.dbg.value(metadata i64 %0, metadata !54, metadata !DIExpression()), !dbg !63
// %conv = trunc i64 %0 to i32, !dbg !52
// call void @llvm.dbg.value(metadata i32 %conv, metadata !51, metadata !DIExpression()), !dbg !60
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !55, metadata !DIExpression()), !dbg !66
// call void @llvm.dbg.value(metadata i64 1, metadata !57, metadata !DIExpression()), !dbg !66
// store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !54
// ST: Guess
iw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l27_c3
old_cw = cw(2,0+1*1);
cw(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l27_c3
// Check
ASSUME(active[iw(2,0+1*1)] == 2);
ASSUME(active[cw(2,0+1*1)] == 2);
ASSUME(sforbid(0+1*1,cw(2,0+1*1))== 0);
ASSUME(iw(2,0+1*1) >= 0);
ASSUME(iw(2,0+1*1) >= 0);
ASSUME(cw(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cw(2,0+1*1) >= old_cw);
ASSUME(cw(2,0+1*1) >= cr(2,0+1*1));
ASSUME(cw(2,0+1*1) >= cl[2]);
ASSUME(cw(2,0+1*1) >= cisb[2]);
ASSUME(cw(2,0+1*1) >= cdy[2]);
ASSUME(cw(2,0+1*1) >= cdl[2]);
ASSUME(cw(2,0+1*1) >= cds[2]);
ASSUME(cw(2,0+1*1) >= cctrl[2]);
ASSUME(cw(2,0+1*1) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,0+1*1) = 1;
mem(0+1*1,cw(2,0+1*1)) = 1;
co(0+1*1,cw(2,0+1*1))+=1;
delta(0+1*1,cw(2,0+1*1)) = -1;
ASSUME(creturn[2] >= cw(2,0+1*1));
// %cmp = icmp eq i32 %conv, 2, !dbg !55
creg__r0__2_ = max(0,creg_r0);
// %conv1 = zext i1 %cmp to i32, !dbg !55
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !58, metadata !DIExpression()), !dbg !60
// store i32 %conv1, i32* @atom_1_X0_2, align 4, !dbg !56, !tbaa !57
// ST: Guess
iw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l29_c15
old_cw = cw(2,2);
cw(2,2) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l29_c15
// Check
ASSUME(active[iw(2,2)] == 2);
ASSUME(active[cw(2,2)] == 2);
ASSUME(sforbid(2,cw(2,2))== 0);
ASSUME(iw(2,2) >= creg__r0__2_);
ASSUME(iw(2,2) >= 0);
ASSUME(cw(2,2) >= iw(2,2));
ASSUME(cw(2,2) >= old_cw);
ASSUME(cw(2,2) >= cr(2,2));
ASSUME(cw(2,2) >= cl[2]);
ASSUME(cw(2,2) >= cisb[2]);
ASSUME(cw(2,2) >= cdy[2]);
ASSUME(cw(2,2) >= cdl[2]);
ASSUME(cw(2,2) >= cds[2]);
ASSUME(cw(2,2) >= cctrl[2]);
ASSUME(cw(2,2) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,2) = (r0==2);
mem(2,cw(2,2)) = (r0==2);
co(2,cw(2,2))+=1;
delta(2,cw(2,2)) = -1;
ASSUME(creturn[2] >= cw(2,2));
// ret i8* null, !dbg !61
ret_thread_2 = (- 1);
goto T2BLOCK_END;
T2BLOCK_END:
// Dumping thread 3
int ret_thread_3 = 0;
cdy[3] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[3] >= cstart[3]);
T3BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !77, metadata !DIExpression()), !dbg !89
// br label %label_3, !dbg !50
goto T3BLOCK1;
T3BLOCK1:
// call void @llvm.dbg.label(metadata !87), !dbg !91
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !79, metadata !DIExpression()), !dbg !92
// %0 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !53
// LD: Guess
old_cr = cr(3,0+1*1);
cr(3,0+1*1) = get_rng(0,NCONTEXT-1);// 3 ASSIGN LDCOM _l35_c15
// Check
ASSUME(active[cr(3,0+1*1)] == 3);
ASSUME(cr(3,0+1*1) >= iw(3,0+1*1));
ASSUME(cr(3,0+1*1) >= 0);
ASSUME(cr(3,0+1*1) >= cdy[3]);
ASSUME(cr(3,0+1*1) >= cisb[3]);
ASSUME(cr(3,0+1*1) >= cdl[3]);
ASSUME(cr(3,0+1*1) >= cl[3]);
// Update
creg_r1 = cr(3,0+1*1);
crmax(3,0+1*1) = max(crmax(3,0+1*1),cr(3,0+1*1));
caddr[3] = max(caddr[3],0);
if(cr(3,0+1*1) < cw(3,0+1*1)) {
r1 = buff(3,0+1*1);
ASSUME((!(( (cw(3,0+1*1) < 1) && (1 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(3,0+1*1) < 2) && (2 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(3,0+1*1) < 3) && (3 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(3,0+1*1) < 4) && (4 < crmax(3,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(3,0+1*1) != co(0+1*1,cr(3,0+1*1))) {
ASSUME(cr(3,0+1*1) >= old_cr);
}
pw(3,0+1*1) = co(0+1*1,cr(3,0+1*1));
r1 = mem(0+1*1,cr(3,0+1*1));
}
ASSUME(creturn[3] >= cr(3,0+1*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !81, metadata !DIExpression()), !dbg !92
// %conv = trunc i64 %0 to i32, !dbg !54
// call void @llvm.dbg.value(metadata i32 %conv, metadata !78, metadata !DIExpression()), !dbg !89
// %cmp = icmp eq i32 %conv, 0, !dbg !55
creg__r1__0_ = max(0,creg_r1);
// %conv1 = zext i1 %cmp to i32, !dbg !55
// call void @llvm.dbg.value(metadata i32 %conv1, metadata !82, metadata !DIExpression()), !dbg !89
// %tobool = icmp ne i32 %conv1, 0, !dbg !56
creg___r1__0___0_ = max(0,creg__r1__0_);
// br i1 %tobool, label %if.then, label %if.else, !dbg !58
old_cctrl = cctrl[3];
cctrl[3] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[3] >= old_cctrl);
ASSUME(cctrl[3] >= creg___r1__0___0_);
if(((r1==0)!=0)) {
goto T3BLOCK2;
} else {
goto T3BLOCK3;
}
T3BLOCK2:
// br label %lbl_label195, !dbg !59
goto T3BLOCK4;
T3BLOCK3:
// br label %lbl_label195, !dbg !60
goto T3BLOCK4;
T3BLOCK4:
// call void @llvm.dbg.label(metadata !88), !dbg !101
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !83, metadata !DIExpression()), !dbg !102
// call void @llvm.dbg.value(metadata i64 1, metadata !85, metadata !DIExpression()), !dbg !102
// store atomic i64 1, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !63
// ST: Guess
iw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l39_c3
old_cw = cw(3,0);
cw(3,0) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l39_c3
// Check
ASSUME(active[iw(3,0)] == 3);
ASSUME(active[cw(3,0)] == 3);
ASSUME(sforbid(0,cw(3,0))== 0);
ASSUME(iw(3,0) >= 0);
ASSUME(iw(3,0) >= 0);
ASSUME(cw(3,0) >= iw(3,0));
ASSUME(cw(3,0) >= old_cw);
ASSUME(cw(3,0) >= cr(3,0));
ASSUME(cw(3,0) >= cl[3]);
ASSUME(cw(3,0) >= cisb[3]);
ASSUME(cw(3,0) >= cdy[3]);
ASSUME(cw(3,0) >= cdl[3]);
ASSUME(cw(3,0) >= cds[3]);
ASSUME(cw(3,0) >= cctrl[3]);
ASSUME(cw(3,0) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,0) = 1;
mem(0,cw(3,0)) = 1;
co(0,cw(3,0))+=1;
delta(0,cw(3,0)) = -1;
ASSUME(creturn[3] >= cw(3,0));
// %cmp2 = icmp eq i32 %conv, 1, !dbg !64
creg__r1__1_ = max(0,creg_r1);
// %conv3 = zext i1 %cmp2 to i32, !dbg !64
// call void @llvm.dbg.value(metadata i32 %conv3, metadata !86, metadata !DIExpression()), !dbg !89
// store i32 %conv3, i32* @atom_2_X0_1, align 4, !dbg !65, !tbaa !66
// ST: Guess
iw(3,3) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STIW _l41_c15
old_cw = cw(3,3);
cw(3,3) = get_rng(0,NCONTEXT-1);// 3 ASSIGN STCOM _l41_c15
// Check
ASSUME(active[iw(3,3)] == 3);
ASSUME(active[cw(3,3)] == 3);
ASSUME(sforbid(3,cw(3,3))== 0);
ASSUME(iw(3,3) >= creg__r1__1_);
ASSUME(iw(3,3) >= 0);
ASSUME(cw(3,3) >= iw(3,3));
ASSUME(cw(3,3) >= old_cw);
ASSUME(cw(3,3) >= cr(3,3));
ASSUME(cw(3,3) >= cl[3]);
ASSUME(cw(3,3) >= cisb[3]);
ASSUME(cw(3,3) >= cdy[3]);
ASSUME(cw(3,3) >= cdl[3]);
ASSUME(cw(3,3) >= cds[3]);
ASSUME(cw(3,3) >= cctrl[3]);
ASSUME(cw(3,3) >= caddr[3]);
// Update
caddr[3] = max(caddr[3],0);
buff(3,3) = (r1==1);
mem(3,cw(3,3)) = (r1==1);
co(3,cw(3,3))+=1;
delta(3,cw(3,3)) = -1;
ASSUME(creturn[3] >= cw(3,3));
// ret i8* null, !dbg !70
ret_thread_3 = (- 1);
goto T3BLOCK_END;
T3BLOCK_END:
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// %thr2 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !114, metadata !DIExpression()), !dbg !137
// call void @llvm.dbg.value(metadata i8** %argv, metadata !115, metadata !DIExpression()), !dbg !137
// %0 = bitcast i64* %thr0 to i8*, !dbg !64
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !64
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !116, metadata !DIExpression()), !dbg !139
// %1 = bitcast i64* %thr1 to i8*, !dbg !66
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !66
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !120, metadata !DIExpression()), !dbg !141
// %2 = bitcast i64* %thr2 to i8*, !dbg !68
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %2) #7, !dbg !68
// call void @llvm.dbg.declare(metadata i64* %thr2, metadata !121, metadata !DIExpression()), !dbg !143
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1), metadata !122, metadata !DIExpression()), !dbg !144
// call void @llvm.dbg.value(metadata i64 0, metadata !124, metadata !DIExpression()), !dbg !144
// store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !71
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l50_c3
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l50_c3
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !125, metadata !DIExpression()), !dbg !146
// call void @llvm.dbg.value(metadata i64 0, metadata !127, metadata !DIExpression()), !dbg !146
// store atomic i64 0, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !73
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l51_c3
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l51_c3
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// store i32 0, i32* @atom_1_X0_2, align 4, !dbg !74, !tbaa !75
// ST: Guess
iw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l52_c15
old_cw = cw(0,2);
cw(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l52_c15
// Check
ASSUME(active[iw(0,2)] == 0);
ASSUME(active[cw(0,2)] == 0);
ASSUME(sforbid(2,cw(0,2))== 0);
ASSUME(iw(0,2) >= 0);
ASSUME(iw(0,2) >= 0);
ASSUME(cw(0,2) >= iw(0,2));
ASSUME(cw(0,2) >= old_cw);
ASSUME(cw(0,2) >= cr(0,2));
ASSUME(cw(0,2) >= cl[0]);
ASSUME(cw(0,2) >= cisb[0]);
ASSUME(cw(0,2) >= cdy[0]);
ASSUME(cw(0,2) >= cdl[0]);
ASSUME(cw(0,2) >= cds[0]);
ASSUME(cw(0,2) >= cctrl[0]);
ASSUME(cw(0,2) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,2) = 0;
mem(2,cw(0,2)) = 0;
co(2,cw(0,2))+=1;
delta(2,cw(0,2)) = -1;
ASSUME(creturn[0] >= cw(0,2));
// store i32 0, i32* @atom_2_X0_1, align 4, !dbg !79, !tbaa !75
// ST: Guess
iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l53_c15
old_cw = cw(0,3);
cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l53_c15
// Check
ASSUME(active[iw(0,3)] == 0);
ASSUME(active[cw(0,3)] == 0);
ASSUME(sforbid(3,cw(0,3))== 0);
ASSUME(iw(0,3) >= 0);
ASSUME(iw(0,3) >= 0);
ASSUME(cw(0,3) >= iw(0,3));
ASSUME(cw(0,3) >= old_cw);
ASSUME(cw(0,3) >= cr(0,3));
ASSUME(cw(0,3) >= cl[0]);
ASSUME(cw(0,3) >= cisb[0]);
ASSUME(cw(0,3) >= cdy[0]);
ASSUME(cw(0,3) >= cdl[0]);
ASSUME(cw(0,3) >= cds[0]);
ASSUME(cw(0,3) >= cctrl[0]);
ASSUME(cw(0,3) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,3) = 0;
mem(3,cw(0,3)) = 0;
co(3,cw(0,3))+=1;
delta(3,cw(0,3)) = -1;
ASSUME(creturn[0] >= cw(0,3));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !80
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call3 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !81
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %call4 = call i32 @pthread_create(i64* noundef %thr2, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t2, i8* noundef null) #7, !dbg !82
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[3] >= cdy[0]);
// %3 = load i64, i64* %thr0, align 8, !dbg !83, !tbaa !84
r3 = local_mem[0];
// %call5 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !86
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %4 = load i64, i64* %thr1, align 8, !dbg !87, !tbaa !84
r4 = local_mem[1];
// %call6 = call i32 @pthread_join(i64 noundef %4, i8** noundef null), !dbg !88
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// %5 = load i64, i64* %thr2, align 8, !dbg !89, !tbaa !84
r5 = local_mem[2];
// %call7 = call i32 @pthread_join(i64 noundef %5, i8** noundef null), !dbg !90
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,3+0));
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,2+0));
ASSUME(cdy[0] >= cr(0,3+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,2+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[3]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0), metadata !129, metadata !DIExpression()), !dbg !161
// %6 = load atomic i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !92
// LD: Guess
old_cr = cr(0,0);
cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l63_c12
// Check
ASSUME(active[cr(0,0)] == 0);
ASSUME(cr(0,0) >= iw(0,0));
ASSUME(cr(0,0) >= 0);
ASSUME(cr(0,0) >= cdy[0]);
ASSUME(cr(0,0) >= cisb[0]);
ASSUME(cr(0,0) >= cdl[0]);
ASSUME(cr(0,0) >= cl[0]);
// Update
creg_r6 = cr(0,0);
crmax(0,0) = max(crmax(0,0),cr(0,0));
caddr[0] = max(caddr[0],0);
if(cr(0,0) < cw(0,0)) {
r6 = buff(0,0);
ASSUME((!(( (cw(0,0) < 1) && (1 < crmax(0,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(0,0) < 2) && (2 < crmax(0,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(0,0) < 3) && (3 < crmax(0,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(0,0) < 4) && (4 < crmax(0,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(0,0) != co(0,cr(0,0))) {
ASSUME(cr(0,0) >= old_cr);
}
pw(0,0) = co(0,cr(0,0));
r6 = mem(0,cr(0,0));
}
ASSUME(creturn[0] >= cr(0,0));
// call void @llvm.dbg.value(metadata i64 %6, metadata !131, metadata !DIExpression()), !dbg !161
// %conv = trunc i64 %6 to i32, !dbg !93
// call void @llvm.dbg.value(metadata i32 %conv, metadata !128, metadata !DIExpression()), !dbg !137
// %cmp = icmp eq i32 %conv, 2, !dbg !94
creg__r6__2_ = max(0,creg_r6);
// %conv8 = zext i1 %cmp to i32, !dbg !94
// call void @llvm.dbg.value(metadata i32 %conv8, metadata !132, metadata !DIExpression()), !dbg !137
// %7 = load i32, i32* @atom_1_X0_2, align 4, !dbg !95, !tbaa !75
// LD: Guess
old_cr = cr(0,2);
cr(0,2) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l65_c13
// Check
ASSUME(active[cr(0,2)] == 0);
ASSUME(cr(0,2) >= iw(0,2));
ASSUME(cr(0,2) >= 0);
ASSUME(cr(0,2) >= cdy[0]);
ASSUME(cr(0,2) >= cisb[0]);
ASSUME(cr(0,2) >= cdl[0]);
ASSUME(cr(0,2) >= cl[0]);
// Update
creg_r7 = cr(0,2);
crmax(0,2) = max(crmax(0,2),cr(0,2));
caddr[0] = max(caddr[0],0);
if(cr(0,2) < cw(0,2)) {
r7 = buff(0,2);
ASSUME((!(( (cw(0,2) < 1) && (1 < crmax(0,2)) )))||(sforbid(2,1)> 0));
ASSUME((!(( (cw(0,2) < 2) && (2 < crmax(0,2)) )))||(sforbid(2,2)> 0));
ASSUME((!(( (cw(0,2) < 3) && (3 < crmax(0,2)) )))||(sforbid(2,3)> 0));
ASSUME((!(( (cw(0,2) < 4) && (4 < crmax(0,2)) )))||(sforbid(2,4)> 0));
} else {
if(pw(0,2) != co(2,cr(0,2))) {
ASSUME(cr(0,2) >= old_cr);
}
pw(0,2) = co(2,cr(0,2));
r7 = mem(2,cr(0,2));
}
ASSUME(creturn[0] >= cr(0,2));
// call void @llvm.dbg.value(metadata i32 %7, metadata !133, metadata !DIExpression()), !dbg !137
// %8 = load i32, i32* @atom_2_X0_1, align 4, !dbg !96, !tbaa !75
// LD: Guess
old_cr = cr(0,3);
cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l66_c13
// Check
ASSUME(active[cr(0,3)] == 0);
ASSUME(cr(0,3) >= iw(0,3));
ASSUME(cr(0,3) >= 0);
ASSUME(cr(0,3) >= cdy[0]);
ASSUME(cr(0,3) >= cisb[0]);
ASSUME(cr(0,3) >= cdl[0]);
ASSUME(cr(0,3) >= cl[0]);
// Update
creg_r8 = cr(0,3);
crmax(0,3) = max(crmax(0,3),cr(0,3));
caddr[0] = max(caddr[0],0);
if(cr(0,3) < cw(0,3)) {
r8 = buff(0,3);
ASSUME((!(( (cw(0,3) < 1) && (1 < crmax(0,3)) )))||(sforbid(3,1)> 0));
ASSUME((!(( (cw(0,3) < 2) && (2 < crmax(0,3)) )))||(sforbid(3,2)> 0));
ASSUME((!(( (cw(0,3) < 3) && (3 < crmax(0,3)) )))||(sforbid(3,3)> 0));
ASSUME((!(( (cw(0,3) < 4) && (4 < crmax(0,3)) )))||(sforbid(3,4)> 0));
} else {
if(pw(0,3) != co(3,cr(0,3))) {
ASSUME(cr(0,3) >= old_cr);
}
pw(0,3) = co(3,cr(0,3));
r8 = mem(3,cr(0,3));
}
ASSUME(creturn[0] >= cr(0,3));
// call void @llvm.dbg.value(metadata i32 %8, metadata !134, metadata !DIExpression()), !dbg !137
// %and = and i32 %7, %8, !dbg !97
creg_r9 = max(creg_r7,creg_r8);
r9 = r7 & r8;
// call void @llvm.dbg.value(metadata i32 %and, metadata !135, metadata !DIExpression()), !dbg !137
// %and9 = and i32 %conv8, %and, !dbg !98
creg_r10 = max(creg__r6__2_,creg_r9);
r10 = (r6==2) & r9;
// call void @llvm.dbg.value(metadata i32 %and9, metadata !136, metadata !DIExpression()), !dbg !137
// %cmp10 = icmp eq i32 %and9, 1, !dbg !99
creg__r10__1_ = max(0,creg_r10);
// br i1 %cmp10, label %if.then, label %if.end, !dbg !101
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg__r10__1_);
if((r10==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([120 x i8], [120 x i8]* @.str.1, i64 0, i64 0), i32 noundef 69, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !102
// unreachable, !dbg !102
r11 = 1;
goto T0BLOCK_END;
T0BLOCK2:
// %9 = bitcast i64* %thr2 to i8*, !dbg !105
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %9) #7, !dbg !105
// %10 = bitcast i64* %thr1 to i8*, !dbg !105
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !105
// %11 = bitcast i64* %thr0 to i8*, !dbg !105
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !105
// ret i32 0, !dbg !106
ret_thread_0 = 0;
goto T0BLOCK_END;
T0BLOCK_END:
ASSUME(meminit(0,1) == mem(0,0));
ASSUME(coinit(0,1) == co(0,0));
ASSUME(deltainit(0,1) == delta(0,0));
ASSUME(meminit(0,2) == mem(0,1));
ASSUME(coinit(0,2) == co(0,1));
ASSUME(deltainit(0,2) == delta(0,1));
ASSUME(meminit(0,3) == mem(0,2));
ASSUME(coinit(0,3) == co(0,2));
ASSUME(deltainit(0,3) == delta(0,2));
ASSUME(meminit(0,4) == mem(0,3));
ASSUME(coinit(0,4) == co(0,3));
ASSUME(deltainit(0,4) == delta(0,3));
ASSUME(meminit(1,1) == mem(1,0));
ASSUME(coinit(1,1) == co(1,0));
ASSUME(deltainit(1,1) == delta(1,0));
ASSUME(meminit(1,2) == mem(1,1));
ASSUME(coinit(1,2) == co(1,1));
ASSUME(deltainit(1,2) == delta(1,1));
ASSUME(meminit(1,3) == mem(1,2));
ASSUME(coinit(1,3) == co(1,2));
ASSUME(deltainit(1,3) == delta(1,2));
ASSUME(meminit(1,4) == mem(1,3));
ASSUME(coinit(1,4) == co(1,3));
ASSUME(deltainit(1,4) == delta(1,3));
ASSUME(meminit(2,1) == mem(2,0));
ASSUME(coinit(2,1) == co(2,0));
ASSUME(deltainit(2,1) == delta(2,0));
ASSUME(meminit(2,2) == mem(2,1));
ASSUME(coinit(2,2) == co(2,1));
ASSUME(deltainit(2,2) == delta(2,1));
ASSUME(meminit(2,3) == mem(2,2));
ASSUME(coinit(2,3) == co(2,2));
ASSUME(deltainit(2,3) == delta(2,2));
ASSUME(meminit(2,4) == mem(2,3));
ASSUME(coinit(2,4) == co(2,3));
ASSUME(deltainit(2,4) == delta(2,3));
ASSUME(meminit(3,1) == mem(3,0));
ASSUME(coinit(3,1) == co(3,0));
ASSUME(deltainit(3,1) == delta(3,0));
ASSUME(meminit(3,2) == mem(3,1));
ASSUME(coinit(3,2) == co(3,1));
ASSUME(deltainit(3,2) == delta(3,1));
ASSUME(meminit(3,3) == mem(3,2));
ASSUME(coinit(3,3) == co(3,2));
ASSUME(deltainit(3,3) == delta(3,2));
ASSUME(meminit(3,4) == mem(3,3));
ASSUME(coinit(3,4) == co(3,3));
ASSUME(deltainit(3,4) == delta(3,3));
ASSERT(r11== 0);
}
| [
"[email protected]"
] | |
1bac8385ea203fe822b832a79335a9dddd6c7b47 | 944acde16ef16cb39caa55b8f93decd290407e7e | /main.cpp | 18acb18b2d2ef87fdb50de3a8ab36ca00ea5e7d9 | [] | no_license | mfg637/extended_numbers_x128 | 8c55832316faf15a99f6707ad8eb49b4a356fd0f | b562587d2493920ecdca3d12baed4ef845c2265f | refs/heads/master | 2020-07-26T19:49:42.665923 | 2019-12-22T21:01:13 | 2019-12-22T21:01:13 | 208,749,731 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,643 | cpp | #include <iostream>
#include <fstream>
#include <random>
#include "src/deserialisation.h"
#include "src/int/UInt128.h"
#include "src/int/Int128.h"
int main(int argc, char **argv)
{
std::ifstream test("test.bin");
if (test.is_open()){
ExtNumsArray a = deserialize(test);
std::cout << a.array_size << ' ';
//IExtNums& sum = *(new Int128(0, 0));
Int128 sum(0, 0);
Int128 incr(0, 1);
for (unsigned i = 0; i<a.array_size; i++){
IExtNums* current_elem = a.array[i];
IExtNums* prev_value = current_elem;
current_elem = &((*prev_value) + incr);
delete prev_value;
current_elem->text_out(std::cout);
sum = (Int128&)((IExtNums&)(sum) + *current_elem);
std::cout << ' ';
}
std::cout << std::endl << "sum of array elems: ";
sum.text_out(std::cout);
std::cout << std::endl;
test.close();
delete [] a.array;
}
std::cout << "Hello world!" << std::endl;
//overflow test
UInt128 a(0, 0xffffffffffffffff);
std::cout << "a = " << a << std::endl;
UInt128 b(0, 2);
std::cout << "b = " << b << std::endl;
UInt128 print_test(0xffffffffffffffff, 0xffffffffffffffff);
std::cout << "print_test = " << print_test << std::endl;
UInt128 result1 = a+b;
std::cout << "result1 = " << result1 << std::endl;
UInt128 result2 = result1 - b;
std::cout << "result2 = " << result2 << std::endl;
UInt128 result3 = a * b;
std::cout << "result3 = " << result3 << std::endl;
UInt128 c(0, 10);
std::cout << "c = " << c << std::endl;
UInt128 result4 = a * c;
std::cout << "result4 = " << result4 << std::endl;
UInt128 result5 = result4 / c;
std::cout << "result5 = " << result5 << std::endl;
Int128 d(0xffffffffffffffff, 0xffffffffffffffff);
std::cout << "d = " << d << std::endl;
Int128 e(0, 2);
std::cout << "e = " << e << std::endl;
Int128 result6 = d + e;
std::cout<< "result6 = " << result6 <<std::endl;
Int128 result7 = d - e;
std::cout << "result7 = " << result7 << std::endl;
Int128 result8 = d * e;
std::cout << "result8 = " << result8 << std::endl;
Int128 result9 = result8 / e;
std::cout << "result9 = " << result9 << std::endl;
Int128 result10 = d * e - e;
std::cout << "result10 = "<< result10 << std::endl;
UInt128 f(0, 0);
std::cout << "f = ";
std::cin >> f;
if (!std::cin.bad()){
std::cout << "f = " << f << std::endl;
}else{
std::cout << "incorrent 128bit unsigned number";
return 1;
}
Int128 g(0, 0);
std::cout << "g = ";
std::cin >> g;
if (!std::cin.bad()){
std::cout << "g = " << g << std::endl;
}else{
std::cout << "incorrent 128bit signed integer number";
return 1;
}
UInt128 h("150");
std::cout << "h = " << h << std::endl;
Int128 m("-150");
std::cout << "m = " << m << std::endl;
std::ofstream test_file("test.bin");
IExtNums** array = new IExtNums*[6];
std::default_random_engine generator;
std::uniform_int_distribution<long long int> signed_distribution(std::numeric_limits<long long int>::min(), std::numeric_limits<long long int>::max());
std::uniform_int_distribution<long long unsigned> unsigned_distribution;
std::uniform_int_distribution<char> bool_distribution(0, 1);
for (int i=0; i<6; i++){
bool isSigned = (bool)((bool_distribution(generator))>0);
long long int b = 0;
long long unsigned l = unsigned_distribution(generator);
if (isSigned){
bool isNegate = bool_distribution(generator);
if (isNegate){
b = -1;
l = (~l)+1;
}
array[i] = new Int128(b, l);
}else{
array[i] = new UInt128(0, l);
}
}
serialize(array, 6, test_file);
test_file.close();
delete[] array;
return 0;
}
| [
"[email protected]"
] | |
5edd2152d39d3a90650a8398593b0ddb571c9a56 | 8c953249a62367a8f0138eff488ce5d510e65620 | /cs109/lab4og/src/comply.cc | 5b61a7f4c7c67392bf0a348fddea0430171eed89 | [] | no_license | nahawtho/cs109copy | 5ce87799eb09ac22b38f63b8d77b3878f8b5b001 | 66e2b2be6adf54bf724a437f2a32090a1d834cba | refs/heads/master | 2020-04-05T06:50:35.063576 | 2018-11-08T05:10:56 | 2018-11-08T05:10:56 | 156,653,424 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,890 | cc | /*
* Copyright (C) 2018 David C. Harrison. All right reserved.
*
* You may not use, distribute, publish, or modify this code without
* the express written permission of the copyright holder.
*/
/****************** DO NOT MODIFY THIS FILE ****************************
*
* It is not included in the subission archive ceated by 'make submit' .
*
* If you modify it and your code relies on those modifications, your code
* will not compile in the automated test harness and will be unable to
* execute any tests.
*
* To put it another way, if you modify this file, you will get a big fat
* ZERO on this lab.
*
************************************************************************/
#include <iostream>
#include "circle.h"
#include "polygon.h"
#include "reuleaux.h"
#include "sphere.h"
static void twodim()
{
Point p1 = Point();
Point p2 = Point(0.0, 0.0);
Point p3 = Point(p2);
Circle circle = Circle(Point(0.0,0.0), 0.0);
double x = circle.center().x;
double r = circle.radius();
ConvexPolygon polygon = ConvexPolygon({Point(0,0), Point(0,0), Point(0,0)});
polygon.vertices().size();
RegularConvexPolygon regular = RegularConvexPolygon({Point(0,0), Point(0,0), Point(0,0)});
regular.vertices().size();
Point vertices[3] = {Point(0,0), Point(0,0), Point(0,0)};
ReuleauxTriangle reuleaux = ReuleauxTriangle(vertices);
reuleaux.vertices().size();
circle.containedBy(circle);
circle.containedBy(polygon);
circle.containedBy(regular);
circle.containedBy(reuleaux);
polygon.containedBy(circle);
polygon.containedBy(polygon);
polygon.containedBy(regular);
polygon.containedBy(reuleaux);
regular.containedBy(circle);
regular.containedBy(polygon);
regular.containedBy(regular);
regular.containedBy(reuleaux);
reuleaux.containedBy(circle);
reuleaux.containedBy(polygon);
reuleaux.containedBy(regular);
reuleaux.containedBy(reuleaux);
}
static void threedim()
{
Point3D p1 = Point3D();
Point3D p2 = Point3D(0.0, 0.0, 0.0);
Point3D p3 = Point3D(p2);
Sphere sphere = Sphere(Point3D(0.0,0.0,0.0), 0.0);
Point3D upper[4] = {Point3D(0,0,0), Point3D(0,0,0), Point3D(0,0,0), Point3D(0,0,0)};
Point3D lower[4] = {Point3D(0,0,0), Point3D(0,0,0), Point3D(0,0,0), Point3D(0,0,0)};
Cube cube = Cube(upper, lower);
Point3D vertices[4] = {Point3D(0,0,0), Point3D(0,0,0), Point3D(0,0,0), Point3D(0,0,0)};
ReuleauxTetrahedron reuleaux = ReuleauxTetrahedron(vertices);
cube.containedBy(cube);
cube.containedBy(sphere);
cube.containedBy(reuleaux);
sphere.containedBy(cube);
sphere.containedBy(sphere);
sphere.containedBy(reuleaux);
reuleaux.containedBy(cube);
reuleaux.containedBy(sphere);
reuleaux.containedBy(reuleaux);
}
int main(int argc, char *argv[])
{
twodim();
threedim();
}
| [
"[email protected]"
] | |
dc909a351ca0af697fe3deac85749d2fc944eaea | b7e66b2c0b9bb14dbf4ae5aa587335c63c5586d7 | /Chapter1/problem1.cpp | f83f5275663a018334fe28fc850e58573c6734cd | [] | no_license | howardwang15/Cracking-the-coding-interview | 232c80847deac1f69f51413615025f7b2a7742d8 | 895dd6d4b6e72e6527cf68e02b3ddc54398142dc | refs/heads/master | 2018-11-17T17:42:16.977785 | 2018-09-03T02:44:22 | 2018-09-03T02:44:22 | 116,181,757 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 251 | cpp | #include <iostream>
using namespace std;
bool isUnique(string s) {
int frequencies[256] = { 0 };
for (char c: s) {
int val = c;
if (frequencies[val] != 0) return false;
frequencies[val]++;
}
return true;
}
int main () {
} | [
"[email protected]"
] | |
1b3b335960fc82212b9b3f811794363057c1e2d9 | 753a70bc416e8dced2853f278b08ef60cdb3c768 | /include/tensorflow/lite/micro/kernels/mul.cc | 2e6464208bdbfe56bf2e6b1314b19ed9f513fb60 | [
"MIT"
] | permissive | finnickniu/tensorflow_object_detection_tflite | ef94158e5350613590641880cb3c1062f7dd0efb | a115d918f6894a69586174653172be0b5d1de952 | refs/heads/master | 2023-04-06T04:59:24.985923 | 2022-09-20T16:29:08 | 2022-09-20T16:29:08 | 230,891,552 | 60 | 19 | MIT | 2023-03-25T00:31:18 | 2019-12-30T09:58:41 | C++ | UTF-8 | C++ | false | false | 6,675 | cc | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/lite/kernels/internal/reference/mul.h"
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/kernels/internal/quantization_util.h"
#include "tensorflow/lite/kernels/internal/reference/integer_ops/mul.h"
#include "tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h"
#include "tensorflow/lite/kernels/internal/tensor_ctypes.h"
#include "tensorflow/lite/kernels/kernel_util.h"
namespace tflite {
namespace ops {
namespace micro {
namespace mul {
constexpr int kInput1Tensor = 0;
constexpr int kInput2Tensor = 1;
constexpr int kOutputTensor = 0;
struct OpData {
int32_t output_activation_min;
int32_t output_activation_max;
int32_t output_multiplier;
int output_shift;
};
TfLiteStatus CalculateOpData(TfLiteContext* context, TfLiteNode* node,
TfLiteMulParams* params, OpData* data) {
const TfLiteTensor* input1 = GetInput(context, node, kInput1Tensor);
const TfLiteTensor* input2 = GetInput(context, node, kInput2Tensor);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
TF_LITE_ENSURE_EQ(context, input1->type, input2->type);
if (output->type == kTfLiteUInt8) {
CalculateActivationRangeUint8(params->activation, output,
&data->output_activation_min,
&data->output_activation_max);
} else if (output->type == kTfLiteInt8) {
CalculateActivationRangeInt8(params->activation, output,
&data->output_activation_min,
&data->output_activation_max);
}
if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8) {
double real_multiplier =
input1->params.scale * input2->params.scale / output->params.scale;
QuantizeMultiplier(real_multiplier, &data->output_multiplier,
&data->output_shift);
}
return kTfLiteOk;
}
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}
void EvalQuantized(TfLiteContext* context, TfLiteNode* node,
TfLiteMulParams* params, OpData* data,
const TfLiteTensor* input1, const TfLiteTensor* input2,
TfLiteTensor* output) {
if (output->type == kTfLiteInt8 || output->type == kTfLiteUInt8) {
tflite::ArithmeticParams op_params;
SetActivationParams(data->output_activation_min,
data->output_activation_max, &op_params);
op_params.input1_offset = -input1->params.zero_point;
op_params.input2_offset = -input2->params.zero_point;
op_params.output_offset = output->params.zero_point;
op_params.output_multiplier = data->output_multiplier;
op_params.output_shift = data->output_shift;
bool need_broadcast = reference_ops::ProcessBroadcastShapes(
GetTensorShape(input1), GetTensorShape(input2), &op_params);
#define TF_LITE_MUL(type, opname, dtype) \
type::opname(op_params, GetTensorShape(input1), \
GetTensorData<dtype>(input1), GetTensorShape(input2), \
GetTensorData<dtype>(input2), GetTensorShape(output), \
GetTensorData<dtype>(output));
if (output->type == kTfLiteInt8) {
if (need_broadcast) {
TF_LITE_MUL(reference_integer_ops, BroadcastMul4DSlow, int8_t);
} else {
TF_LITE_MUL(reference_integer_ops, Mul, int8_t);
}
} else if (output->type == kTfLiteUInt8) {
if (need_broadcast) {
TF_LITE_MUL(reference_ops, BroadcastMul4DSlow, uint8_t);
} else {
TF_LITE_MUL(reference_ops, Mul, uint8_t);
}
}
#undef TF_LITE_MUL
}
}
void EvalFloat(TfLiteContext* context, TfLiteNode* node,
TfLiteMulParams* params, OpData* data,
const TfLiteTensor* input1, const TfLiteTensor* input2,
TfLiteTensor* output) {
float output_activation_min, output_activation_max;
CalculateActivationRange(params->activation, &output_activation_min,
&output_activation_max);
tflite::ArithmeticParams op_params;
SetActivationParams(output_activation_min, output_activation_max, &op_params);
bool need_broadcast = reference_ops::ProcessBroadcastShapes(
GetTensorShape(input1), GetTensorShape(input2), &op_params);
#define TF_LITE_MUL(opname) \
reference_ops::opname(op_params, GetTensorShape(input1), \
GetTensorData<float>(input1), GetTensorShape(input2), \
GetTensorData<float>(input2), GetTensorShape(output), \
GetTensorData<float>(output));
if (need_broadcast) {
TF_LITE_MUL(BroadcastMul4DSlow);
} else {
TF_LITE_MUL(Mul);
}
#undef TF_LITE_MUL
}
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
auto* params = reinterpret_cast<TfLiteMulParams*>(node->builtin_data);
OpData data;
const TfLiteTensor* input1 = GetInput(context, node, kInput1Tensor);
const TfLiteTensor* input2 = GetInput(context, node, kInput2Tensor);
TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
CalculateOpData(context, node, params, &data);
switch (input1->type) {
case kTfLiteUInt8:
case kTfLiteInt8:
EvalQuantized(context, node, params, &data, input1, input2, output);
break;
case kTfLiteFloat32:
EvalFloat(context, node, params, &data, input1, input2, output);
break;
default:
context->ReportError(context, "Type %d not currently supported.",
input1->type);
return kTfLiteError;
}
return kTfLiteOk;
}
} // namespace mul
TfLiteRegistration* Register_MUL() {
static TfLiteRegistration r = {nullptr, nullptr, mul::Prepare, mul::Eval};
return &r;
}
} // namespace micro
} // namespace ops
} // namespace tflite
| [
"[email protected]"
] | |
9bc30c12f83dfa8069cd310bb9c438256011d791 | 9f520bcbde8a70e14d5870fd9a88c0989a8fcd61 | /pitzDaily/389/uniform/functionObjects/functionObjectProperties | 15b5c580dadf831388e52cb2b659b89fef46566a | [] | no_license | asAmrita/adjoinShapOptimization | 6d47c89fb14d090941da706bd7c39004f515cfea | 079cbec87529be37f81cca3ea8b28c50b9ceb8c5 | refs/heads/master | 2020-08-06T21:32:45.429939 | 2019-10-06T09:58:20 | 2019-10-06T09:58:20 | 213,144,901 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 897 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "389/uniform/functionObjects";
object functionObjectProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //
| [
"[email protected]"
] | ||
6cdf6bdd52ff7a0d8f30d45dbc4bac4c28880324 | 63e3ec9a6849b10dc743b191a62649c954831d06 | /Tester/main.cpp | e0791ff35004ab5b558141ef4bc581cfd09d9451 | [
"Apache-2.0"
] | permissive | amj55/CPP | b89f1bfafd7595f47689c3c8502f2a3ae380c267 | 993fdfa8e1878c2033ad78070d55442f4c15393a | refs/heads/master | 2021-08-28T09:33:35.491890 | 2017-12-11T21:17:15 | 2017-12-11T21:17:15 | 114,029,061 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 409 | cpp | #include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> test;
test.push_back(5);
test.push_back(10);
test.push_back(100);
test.insert(test.begin(), 1);
cout << test.back() << " " << test.front() << " " << test[0] << endl;
return 0;
}
void disp(vector<con> items) {
for(int i = 0; i < items.size(); i++) {
cout << items[1] << " ";
}
}
| [
"[email protected]"
] | |
6dfd68acdbd618e2b2d723e5472cb499abcec932 | cae01d285dbd8bbebd7b48b95efa483ae6b4a2c5 | /Intermediate/Build/Win64/UE4Editor/Inc/VehicleTemplate/Checkpoints.generated.h | 12757ce519347866731717ca9fa903cab1ef5d18 | [] | no_license | AliHasl/UnrealVehicleProject | 24f148f487b56c8a40ce0313bcf1a12294a7834b | 592f743cb05977ce7265506f7348f6c35e57e63c | refs/heads/master | 2020-04-10T05:41:48.065440 | 2018-12-07T14:30:36 | 2018-12-07T14:30:36 | 160,834,796 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,149 | h | // Copyright 1998-2018 Epic Games, Inc. All Rights Reserved.
/*===========================================================================
Generated code exported from UnrealHeaderTool.
DO NOT modify this manually! Edit the corresponding .h files instead!
===========================================================================*/
#include "ObjectMacros.h"
#include "ScriptMacros.h"
PRAGMA_DISABLE_DEPRECATION_WARNINGS
#ifdef VEHICLETEMPLATE_Checkpoints_generated_h
#error "Checkpoints.generated.h already included, missing '#pragma once' in Checkpoints.h"
#endif
#define VEHICLETEMPLATE_Checkpoints_generated_h
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_RPC_WRAPPERS
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_RPC_WRAPPERS_NO_PURE_DECLS
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_INCLASS_NO_PURE_DECLS \
private: \
static void StaticRegisterNativesACheckpoints(); \
friend VEHICLETEMPLATE_API class UClass* Z_Construct_UClass_ACheckpoints(); \
public: \
DECLARE_CLASS(ACheckpoints, AActor, COMPILED_IN_FLAGS(0), 0, TEXT("/Script/VehicleTemplate"), NO_API) \
DECLARE_SERIALIZER(ACheckpoints) \
enum {IsIntrinsic=COMPILED_IN_INTRINSIC};
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_INCLASS \
private: \
static void StaticRegisterNativesACheckpoints(); \
friend VEHICLETEMPLATE_API class UClass* Z_Construct_UClass_ACheckpoints(); \
public: \
DECLARE_CLASS(ACheckpoints, AActor, COMPILED_IN_FLAGS(0), 0, TEXT("/Script/VehicleTemplate"), NO_API) \
DECLARE_SERIALIZER(ACheckpoints) \
enum {IsIntrinsic=COMPILED_IN_INTRINSIC};
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_STANDARD_CONSTRUCTORS \
/** Standard constructor, called after all reflected properties have been initialized */ \
NO_API ACheckpoints(const FObjectInitializer& ObjectInitializer); \
DEFINE_DEFAULT_OBJECT_INITIALIZER_CONSTRUCTOR_CALL(ACheckpoints) \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ACheckpoints); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(ACheckpoints); \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API ACheckpoints(ACheckpoints&&); \
NO_API ACheckpoints(const ACheckpoints&); \
public:
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_ENHANCED_CONSTRUCTORS \
private: \
/** Private move- and copy-constructors, should never be used */ \
NO_API ACheckpoints(ACheckpoints&&); \
NO_API ACheckpoints(const ACheckpoints&); \
public: \
DECLARE_VTABLE_PTR_HELPER_CTOR(NO_API, ACheckpoints); \
DEFINE_VTABLE_PTR_HELPER_CTOR_CALLER(ACheckpoints); \
DEFINE_DEFAULT_CONSTRUCTOR_CALL(ACheckpoints)
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_PRIVATE_PROPERTY_OFFSET
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_12_PROLOG
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_GENERATED_BODY_LEGACY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_PRIVATE_PROPERTY_OFFSET \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_RPC_WRAPPERS \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_INCLASS \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_STANDARD_CONSTRUCTORS \
public: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#define VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_GENERATED_BODY \
PRAGMA_DISABLE_DEPRECATION_WARNINGS \
public: \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_PRIVATE_PROPERTY_OFFSET \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_RPC_WRAPPERS_NO_PURE_DECLS \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_INCLASS_NO_PURE_DECLS \
VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h_15_ENHANCED_CONSTRUCTORS \
private: \
PRAGMA_ENABLE_DEPRECATION_WARNINGS
#undef CURRENT_FILE_ID
#define CURRENT_FILE_ID VehicleTemplate_04_12_2018_Source_VehicleTemplate_Checkpoints_h
PRAGMA_ENABLE_DEPRECATION_WARNINGS
| [
"[email protected]"
] | |
42f0b1c94b78719dc6a409d2c51f79d2d01764a5 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /crypto/ec_signature_creator_impl.cc | 2870310dd1c0d30880412a0a05bd87ac978da063 | [
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 2,343 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "crypto/ec_signature_creator_impl.h"
#include <openssl/bn.h>
#include <openssl/ec.h>
#include <openssl/ecdsa.h>
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <stddef.h>
#include <stdint.h>
#include "base/logging.h"
#include "crypto/ec_private_key.h"
#include "crypto/openssl_util.h"
namespace crypto {
ECSignatureCreatorImpl::ECSignatureCreatorImpl(ECPrivateKey* key)
: key_(key) {
EnsureOpenSSLInit();
}
ECSignatureCreatorImpl::~ECSignatureCreatorImpl() {}
bool ECSignatureCreatorImpl::Sign(const uint8_t* data,
int data_len,
std::vector<uint8_t>* signature) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
bssl::ScopedEVP_MD_CTX ctx;
size_t sig_len = 0;
if (!ctx.get() ||
!EVP_DigestSignInit(ctx.get(), nullptr, EVP_sha256(), nullptr,
key_->key()) ||
!EVP_DigestSignUpdate(ctx.get(), data, data_len) ||
!EVP_DigestSignFinal(ctx.get(), nullptr, &sig_len)) {
return false;
}
signature->resize(sig_len);
if (!EVP_DigestSignFinal(ctx.get(), &signature->front(), &sig_len))
return false;
// NOTE: A call to EVP_DigestSignFinal() with a nullptr second parameter
// returns a maximum allocation size, while the call without a nullptr
// returns the real one, which may be smaller.
signature->resize(sig_len);
return true;
}
bool ECSignatureCreatorImpl::DecodeSignature(
const std::vector<uint8_t>& der_sig,
std::vector<uint8_t>* out_raw_sig) {
OpenSSLErrStackTracer err_tracer(FROM_HERE);
// Create ECDSA_SIG object from DER-encoded data.
bssl::UniquePtr<ECDSA_SIG> ecdsa_sig(
ECDSA_SIG_from_bytes(der_sig.data(), der_sig.size()));
if (!ecdsa_sig.get())
return false;
// The result is made of two 32-byte vectors.
const size_t kMaxBytesPerBN = 32;
std::vector<uint8_t> result(2 * kMaxBytesPerBN);
if (!BN_bn2bin_padded(&result[0], kMaxBytesPerBN, ecdsa_sig->r) ||
!BN_bn2bin_padded(&result[kMaxBytesPerBN], kMaxBytesPerBN,
ecdsa_sig->s)) {
return false;
}
out_raw_sig->swap(result);
return true;
}
} // namespace crypto
| [
"[email protected]"
] | |
7440b24ea9e26820cf09a065a704bccd9e0110c4 | 959af614f695a948ae2c899f1e9a6c8163c80e00 | /samples/core/sample_core_benchmark_disk.cpp | abfd69eb7210700193f120cb835cc69b5763b33c | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Paul-Hi/saiga | cacf1d8537096df871fafa06e755b4e9908672f3 | 1b843bf7800f7113e7bd4d709fc965088078702d | refs/heads/master | 2023-06-19T22:18:24.752565 | 2021-06-29T15:06:25 | 2021-06-29T15:06:25 | 289,020,555 | 0 | 0 | MIT | 2020-08-20T13:58:07 | 2020-08-20T13:58:06 | null | UTF-8 | C++ | false | false | 1,195 | cpp | /**
* Copyright (c) 2017 Darius Rückert
* Licensed under the MIT License.
* See LICENSE file for more information.
*/
#include "saiga/core/Core.h"
#include "saiga/core/time/all.h"
#include "saiga/core/util/Thread/omp.h"
using namespace Saiga;
int sizeMB = 1000 * 1;
size_t blockSize = sizeMB * 1000UL * 1000UL;
double blockSizeGB = (blockSize / (1000.0 * 1000.0 * 1000.0));
void write(const std::string& file, const std::vector<char>& data)
{
FILE* dest = fopen(file.c_str(), "wb");
if (dest == 0)
{
return;
}
auto written = fwrite(0, 1, data.size(), dest);
SAIGA_ASSERT(written == data.size());
fclose(dest);
}
void write2(const std::string& file, const std::vector<char>& data)
{
std::ofstream is(file, std::ios::binary | std::ios::out);
if (!is.is_open())
{
std::cout << "File not found " << file << std::endl;
return;
}
is.write(data.data(), data.size());
is.close();
}
int main(int, char**)
{
catchSegFaults();
std::vector<char> data(blockSize);
{
SAIGA_BLOCK_TIMER();
write2("test.dat", data);
}
std::cout << "Done." << std::endl;
return 0;
}
| [
"[email protected]"
] | |
4e8213aa94d1e02c6254898794a4c0f7c40095fe | c022ac5523662a3022e220beef041268b11103f4 | /DS-malik-cpp/namespaceEg1.cpp | 2b4d6c7989ed8cac7189d88c0aa2ebf75f1cfb49 | [] | no_license | Otumian-empire/DS-malik-cpp | 780194091ddd013ed6f5286a79278cc3f0eeb9ed | aa2273b88dab69b267ffb1cab76e5c562fc28de7 | refs/heads/master | 2020-06-13T03:36:48.184918 | 2020-04-26T09:46:08 | 2020-04-26T09:46:08 | 194,520,519 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 440 | cpp |
namespace otu {
string author = "Otumian Empire";
string expertise = "Die hard programmer";
}
namespace globalType {
const int N = 10;
const double RATE = 7.50;
int count = 0;
void printResult();
}
#include <iostream>z
using namespace std;
// using namespace otu;
using namespace globalType;
int main() {
// cout << otu::author << endl << expertise << endl;
cout << N << endl;
cout << RATE << endl;
return 0;
} | [
"[email protected]"
] | |
a6e33853276bc2ae67f69b6915f7180c0f752eed | da0d71b758d95e532056bc705b186666837709b7 | /src/libfauxdcore/tuple-compiler.cc | 58202b7ed49edf1bc075a54703e9978abe12b6d0 | [
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | ZachBacon/fauxdacious | fc3f3aa5bf6cbf0f88b7e33a0e3fd4c8971a124a | a2bbdaed2fee91d8f5d84fd2c21b41cf9452620a | refs/heads/master | 2021-05-19T23:46:26.626551 | 2020-03-04T16:45:28 | 2020-03-04T16:45:28 | null | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 12,833 | cc | /*
* tuple_compiler.c
* Copyright (c) 2007 Matti 'ccr' Hämäläinen
* Copyright (c) 2011-2014 John Lindgren
*
* 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
* provided with the distribution.
*
* This software is provided "as is" and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising from
* the use of this software.
*/
#include <stdlib.h>
#include <string.h>
#include <new>
#include <glib.h>
#include "audstrings.h"
#include "runtime.h"
#include "tuple-compiler.h"
struct Variable
{
enum {
Invalid = 0,
Text,
Integer,
Field
} type;
String text;
int integer;
Tuple::Field field;
bool set (const char * name, bool literal);
bool exists (const Tuple & tuple) const;
Tuple::ValueType get (const Tuple & tuple, String & tmps, int & tmpi) const;
};
enum class Op {
Invalid = 0,
Var,
Exists,
Equal,
Unequal,
Greater,
GreaterEqual,
Less,
LessEqual,
Empty
};
struct TupleCompiler::Node {
Op op;
Variable var1, var2;
Index<Node> children;
};
typedef TupleCompiler::Node Node;
bool Variable::set (const char * name, bool literal)
{
if (g_ascii_isdigit (name[0]))
{
type = Integer;
integer = atoi (name);
}
else if (literal)
{
type = Text;
text = String (name);
}
else
{
type = Field;
field = Tuple::field_by_name (name);
if (field < 0)
{
AUDWARN ("Invalid variable '%s'.\n", name);
return false;
}
}
return true;
}
bool Variable::exists (const Tuple & tuple) const
{
g_return_val_if_fail (type == Field, false);
return tuple.get_value_type (field) != Tuple::Empty;
}
Tuple::ValueType Variable::get (const Tuple & tuple, String & tmps, int & tmpi) const
{
switch (type)
{
case Text:
tmps = text;
return Tuple::String;
case Integer:
tmpi = integer;
return Tuple::Int;
case Field:
switch (tuple.get_value_type (field))
{
case Tuple::String:
tmps = tuple.get_str (field);
return Tuple::String;
case Tuple::Int:
tmpi = tuple.get_int (field);
return Tuple::Int;
default:
return Tuple::Empty;
}
default:
g_return_val_if_reached (Tuple::Empty);
}
}
TupleCompiler::TupleCompiler () {}
TupleCompiler::~TupleCompiler () {}
static StringBuf get_item (const char * & str, char endch, bool & literal)
{
const char * s = str;
StringBuf buf (-1);
char * set = buf;
char * stop = buf + buf.len ();
if (* s == '"')
{
if (! literal)
{
buf = StringBuf (); // release space before AUDWARN
AUDWARN ("Unexpected string literal at '%s'.\n", s);
return StringBuf ();
}
s ++;
}
else
literal = false;
if (literal)
{
while (* s != '"')
{
if (* s == '\\')
s ++;
if (! * s)
{
buf = StringBuf (); // release space before AUDWARN
AUDWARN ("Unterminated string literal.\n");
return StringBuf ();
}
if (set == stop)
throw std::bad_alloc ();
* set ++ = * s ++;
}
s ++;
}
else
{
while (g_ascii_isalnum (* s) || * s == '-')
{
if (set == stop)
throw std::bad_alloc ();
* set ++ = * s ++;
}
}
if (* s != endch)
{
buf = StringBuf (); // release space before AUDWARN
AUDWARN ("Expected '%c' at '%s'.\n", endch, s);
return StringBuf ();
}
str = s + 1;
buf.resize (set - buf);
return buf;
}
static bool compile_expression (Index<Node> & nodes, const char * & expression);
static bool parse_construct (Node & node, const char * & c)
{
bool literal1 = true, literal2 = true;
StringBuf tmps1 = get_item (c, ',', literal1);
if (! tmps1)
return false;
StringBuf tmps2 = get_item (c, ':', literal2);
if (! tmps2)
return false;
if (! node.var1.set (tmps1, literal1))
return false;
if (! node.var2.set (tmps2, literal2))
return false;
return compile_expression (node.children, c);
}
/* Compile format expression into Node tree. */
static bool compile_expression (Index<Node> & nodes, const char * & expression)
{
const char * c = expression;
while (* c && * c != '}')
{
Node & node = nodes.append ();
if (* c == '$')
{
/* Expression? */
if (c[1] != '{')
{
AUDWARN ("Expected '${' at '%s'.\n", c);
return false;
}
c += 2;
switch (* c)
{
case '?':
case '(':
{
if (* c == '?')
{
node.op = Op::Exists;
c ++;
}
else
{
if (strncmp (c, "(empty)?", 8))
{
AUDWARN ("Expected '(empty)?' at '%s'.\n", c);
return false;
}
node.op = Op::Empty;
c += 8;
}
bool literal = false;
StringBuf tmps = get_item (c, ':', literal);
if (! tmps)
return false;
if (! node.var1.set (tmps, false))
return false;
if (! compile_expression (node.children, c))
return false;
break;
}
case '=':
case '!':
node.op = (* c == '=') ? Op::Equal : Op::Unequal;
if (c[1] != '=')
{
AUDWARN ("Expected '%c=' at '%s'.\n", c[0], c);
return false;
}
c += 2;
if (! parse_construct (node, c))
return false;
break;
case '<':
case '>':
if (c[1] == '=')
{
node.op = (* c == '<') ? Op::LessEqual : Op::GreaterEqual;
c += 2;
}
else
{
node.op = (* c == '<') ? Op::Less : Op::Greater;
c ++;
}
if (! parse_construct (node, c))
return false;
break;
default:
{
bool literal = false;
StringBuf tmps = get_item (c, '}', literal);
if (! tmps)
return false;
c --;
node.op = Op::Var;
if (! node.var1.set (tmps, false))
return false;
}
}
if (* c != '}')
{
AUDWARN ("Expected '}' at '%s'.\n", c);
return false;
}
c ++;
}
else if (* c == '{')
{
AUDWARN ("Unexpected '%c' at '%s'.\n", * c, c);
return false;
}
else
{
/* Parse raw/literal text */
StringBuf buf (-1);
char * set = buf;
char * stop = buf + buf.len ();
while (* c && * c != '$' && * c != '{' && * c != '}')
{
if (* c == '\\')
{
c ++;
if (! * c)
{
buf = StringBuf (); // release space before AUDWARN
AUDWARN ("Incomplete escaped character.\n");
return false;
}
}
if (set == stop)
throw std::bad_alloc ();
* set ++ = * c ++;
}
buf.resize (set - buf);
node.op = Op::Var;
node.var1.type = Variable::Text;
node.var1.text = String (buf);
}
}
expression = c;
return true;
}
bool TupleCompiler::compile (const char * expr)
{
const char * c = expr;
Index<Node> nodes;
if (! compile_expression (nodes, c))
return false;
if (* c)
{
AUDWARN ("Unexpected '%c' at '%s'.\n", * c, c);
return false;
}
root_nodes = std::move (nodes);
return true;
}
void TupleCompiler::reset ()
{
root_nodes.clear ();
}
/* Evaluate tuple in given TupleEval expression in given
* context and return resulting string. */
static void eval_expression (const Index<Node> & nodes, const Tuple & tuple, StringBuf & out)
{
for (const Node & node : nodes)
{
switch (node.op)
{
case Op::Var:
{
String tmps;
int tmpi;
switch (node.var1.get (tuple, tmps, tmpi))
{
case Tuple::String:
out.insert (-1, tmps);
break;
case Tuple::Int:
str_insert_int (out, -1, tmpi);
break;
default:
break;
}
break;
}
case Op::Equal:
case Op::Unequal:
case Op::Less:
case Op::LessEqual:
case Op::Greater:
case Op::GreaterEqual:
{
bool result = false;
String tmps1, tmps2;
int tmpi1 = 0, tmpi2 = 0;
Tuple::ValueType type1 = node.var1.get (tuple, tmps1, tmpi1);
Tuple::ValueType type2 = node.var2.get (tuple, tmps2, tmpi2);
if (type1 != Tuple::Empty && type2 != Tuple::Empty)
{
int resulti;
if (type1 == type2)
{
if (type1 == Tuple::String)
resulti = strcmp (tmps1, tmps2);
else
resulti = tmpi1 - tmpi2;
}
else
{
if (type1 == Tuple::Int)
resulti = tmpi1 - atoi (tmps2);
else
resulti = atoi (tmps1) - tmpi2;
}
switch (node.op)
{
case Op::Equal:
result = (resulti == 0);
break;
case Op::Unequal:
result = (resulti != 0);
break;
case Op::Less:
result = (resulti < 0);
break;
case Op::LessEqual:
result = (resulti <= 0);
break;
case Op::Greater:
result = (resulti > 0);
break;
case Op::GreaterEqual:
result = (resulti >= 0);
break;
default:
g_warn_if_reached ();
}
}
if (result)
eval_expression (node.children, tuple, out);
break;
}
case Op::Exists:
if (node.var1.exists (tuple))
eval_expression (node.children, tuple, out);
break;
case Op::Empty:
if (! node.var1.exists (tuple))
eval_expression (node.children, tuple, out);
break;
default:
g_warn_if_reached ();
}
}
}
void TupleCompiler::format (Tuple & tuple) const
{
tuple.unset (Tuple::FormattedTitle); // prevent recursion
StringBuf buf (0);
eval_expression (root_nodes, tuple, buf);
if (buf[0])
{
tuple.set_str (Tuple::FormattedTitle, buf);
return;
}
/* formatting failed, try fallbacks */
for (Tuple::Field fallback : {Tuple::Title, Tuple::Basename})
{
String title = tuple.get_str (fallback);
if (title)
{
tuple.set_str (Tuple::FormattedTitle, title);
return;
}
}
tuple.set_str (Tuple::FormattedTitle, "");
}
| [
"[email protected]"
] | |
f3499235c1299d4bc284deb36518a466f36274bf | a2206795a05877f83ac561e482e7b41772b22da8 | /Source/PV/build/Qt/Components/moc_pqStringVectorPropertyWidget.cxx | ec134e8372774ae2c8e9d04920dba9af3c476a00 | [] | no_license | supreethms1809/mpas-insitu | 5578d465602feb4d6b239a22912c33918c7bb1c3 | 701644bcdae771e6878736cb6f49ccd2eb38b36e | refs/heads/master | 2020-03-25T16:47:29.316814 | 2018-08-08T02:00:13 | 2018-08-08T02:00:13 | 143,947,446 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,679 | cxx | /****************************************************************************
** Meta object code from reading C++ file 'pqStringVectorPropertyWidget.h'
**
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.6)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../../ParaView/Qt/Components/pqStringVectorPropertyWidget.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'pqStringVectorPropertyWidget.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.6. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_pqStringVectorPropertyWidget[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
static const char qt_meta_stringdata_pqStringVectorPropertyWidget[] = {
"pqStringVectorPropertyWidget\0"
};
void pqStringVectorPropertyWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
const QMetaObjectExtraData pqStringVectorPropertyWidget::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject pqStringVectorPropertyWidget::staticMetaObject = {
{ &pqPropertyWidget::staticMetaObject, qt_meta_stringdata_pqStringVectorPropertyWidget,
qt_meta_data_pqStringVectorPropertyWidget, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &pqStringVectorPropertyWidget::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *pqStringVectorPropertyWidget::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *pqStringVectorPropertyWidget::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_pqStringVectorPropertyWidget))
return static_cast<void*>(const_cast< pqStringVectorPropertyWidget*>(this));
return pqPropertyWidget::qt_metacast(_clname);
}
int pqStringVectorPropertyWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = pqPropertyWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
| [
"[email protected]"
] | |
23bb7c0023ab0d19e14718cb92e52a5c74663292 | 7e2f4649977299d392d6fedd08156232d62bd216 | /src/controls/sdbrowserwidget.h | 366ea2b95faed6832f485ed90a07af9c5cdb32ab | [
"MIT"
] | permissive | AhmadPanogari/Phoenard-Toolkit | cadd1d26649f7877ff87fc2791d32e8c9d06fbe1 | 395ce79a3c56701073531cb2caad3637312d906c | refs/heads/master | 2021-06-04T17:47:43.102820 | 2016-07-11T14:42:53 | 2016-07-11T14:42:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,830 | h | #ifndef SDBROWSERWIDGET_H
#define SDBROWSERWIDGET_H
#include <QTreeWidget>
#include <QResizeEvent>
#include <QDragEnterEvent>
#include <QDragMoveEvent>
#include <QDragLeaveEvent>
#include <QDropEvent>
#include "mainmenutab.h"
#include "../imaging/phniconprovider.h"
class SDBrowserWidget : public QTreeWidget, public MainMenuTab
{
Q_OBJECT
public:
SDBrowserWidget(QWidget *parent = 0);
void refreshFiles();
void deleteFiles();
void saveFilesTo();
void importFiles();
void importFiles(QStringList filePaths);
void importFiles(QStringList filePaths, QString destFolder);
void createNew(QString fileName, bool isDirectory);
void keyPressEvent(QKeyEvent *ev);
bool hasSelection();
QTreeWidgetItem* getSelectedFolder();
QString volumeName();
protected:
void dragEnterEvent(QDragEnterEvent *event);
void dragMoveEvent(QDragMoveEvent *event);
void dragLeaveEvent(QDragLeaveEvent *event);
void dropEvent(QDropEvent *event);
void itemExpanded(QTreeWidgetItem *item);
void refreshItem(QTreeWidgetItem *item);
void refreshItem(QTreeWidgetItem *item, QList<DirectoryInfo> subFiles);
void setupItemName(QTreeWidgetItem *item, QString name);
void addExpandedListTasks(QTreeWidgetItem *item, QList<stk500Task*> *tasks);
QString getPath(QTreeWidgetItem *item);
QTreeWidgetItem *getItemAtPath(QString path);
bool itemHasSelectedParent(QTreeWidgetItem *item);
bool itemIsFolder(QTreeWidgetItem *item);
void updateItemIcon(QTreeWidgetItem *item);
private slots:
void on_itemExpanded(QTreeWidgetItem *item);
void on_itemChanged(QTreeWidgetItem *item, int column);
void on_itemDoubleClicked(QTreeWidgetItem *item, int column);
private:
bool _isRefreshing;
PHNIconProvider iconProvider;
};
#endif // SDBROWSERWIDGET_H
| [
"[email protected]"
] | |
697e691d13515b02d37cce2ac7290dba54adf47d | b1ee6b1a8b616c3e2692a426d4e59b8a508cd6c3 | /Robot/Robot.ip_user_files/bd/base/ip/base_constant_tkeep_tstrb_1/sim/base_constant_tkeep_tstrb_1.h | 59cc2887cf546a3587b23354959360c8139fe323 | [
"MIT"
] | permissive | junhongmit/PYNQ_Car | 5c9157bc42680c897c828ba6539800b066d6888f | c4600f270c56c819e6b3e3e357b44081ee5ddce5 | refs/heads/master | 2022-03-01T12:44:03.589295 | 2019-10-21T16:43:33 | 2019-10-21T16:43:33 | 165,031,312 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,689 | h | // (c) Copyright 1995-2014 Xilinx, Inc. All rights reserved.
//
// This file contains confidential and proprietary information
// of Xilinx, Inc. and is protected under U.S. and
// international copyright and other intellectual property
// laws.
//
// DISCLAIMER
// This disclaimer is not a license and does not grant any
// rights to the materials distributed herewith. Except as
// otherwise provided in a valid license issued to you by
// Xilinx, and to the maximum extent permitted by applicable
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
// (2) Xilinx shall not be liable (whether in contract or tort,
// including negligence, or under any other theory of
// liability) for any loss or damage of any kind or nature
// related to, arising under or in connection with these
// materials, including for any direct, or any indirect,
// special, incidental, or consequential loss or damage
// (including loss of data, profits, goodwill, or any type of
// loss or damage suffered as a result of any action brought
// by a third party) even if such damage or loss was
// reasonably foreseeable or Xilinx had been advised of the
// possibility of the same.
//
// CRITICAL APPLICATIONS
// Xilinx products are not designed or intended to be fail-
// safe, or for use in any application requiring fail-safe
// performance, such as life-support or safety devices or
// systems, Class III medical devices, nuclear facilities,
// applications related to the deployment of airbags, or any
// other applications that could lead to death, personal
// injury, or severe property or environmental damage
// (individually and collectively, "Critical
// Applications"). Customer assumes the sole risk and
// liability of any use of Xilinx products in Critical
// Applications, subject only to applicable laws and
// regulations governing limitations on product liability.
//
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
// PART OF THIS FILE AT ALL TIMES.
//
// DO NOT MODIFY THIS FILE.
// IP VLNV: xilinx.com:ip:xlconstant:1.1
// IP Revision: 1
#ifndef _base_constant_tkeep_tstrb_1_H_
#define _base_constant_tkeep_tstrb_1_H_
#include "xlconstant_v1_1.h"
#include "systemc.h"
class base_constant_tkeep_tstrb_1 : public sc_module {
public:
xlconstant_v1_1_5<4,15> mod;
sc_out< sc_bv<4> > dout;
base_constant_tkeep_tstrb_1 (sc_core::sc_module_name name) :sc_module(name), mod("mod") {
mod.dout(dout);
}
};
#endif
| [
"[email protected]"
] | |
70e88be0e6d971d7e5b7e635de9ca1e355ae7bc5 | cbd022378f8c657cef7f0d239707c0ac0b27118a | /src/npcclient/walkpoly.h | 086682f6eb262d1af23613db499207e0fd45b057 | [] | no_license | randomcoding/PlaneShift-PSAI | 57d3c1a2accdef11d494c523f3e2e99142d213af | 06c585452abf960e0fc964fe0b7502b9bd550d1f | refs/heads/master | 2016-09-10T01:58:01.360365 | 2011-09-07T23:13:48 | 2011-09-07T23:13:48 | 2,336,981 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,256 | h | /*
* walkpoly.h
*
* Copyright (C) 2005 Atomic Blue ([email protected], http://www.atomicblue.org)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation (version 2
* of the License).
* 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef ___WALKPOLY_HEADER___
#define ___WALKPOLY_HEADER___
#if USE_WALKPOLY
//=============================================================================
// Crystal Space Includes
//=============================================================================
#include <csgeom/vector3.h>
#include <csgeom/box.h>
#include <iutil/objreg.h>
#include <csutil/array.h>
#include <csutil/csstring.h>
#include <csutil/list.h>
//=============================================================================
// Local Includes
//=============================================================================
#include "pathfind.h"
class psNPCClient;
void Dump3(const char * name, const csVector3 & p);
void Dump(const char * name, const csBox3 & b);
void Dump(const char * name, const csVector3 & p);
float Calc2DDistance(const csVector3 & a, const csVector3 & b);
float AngleDiff(float a1, float a2);
/** Normal equation of a line in 2D space (the y coord is ignored) */
class ps2DLine
{
public:
float a, b, c;
void Dump();
void Calc(const csVector3 & p1, const csVector3 & p2);
void CalcPerp(const csVector3 & begin, const csVector3 & end);
float CalcDist(const csVector3 & point);
float CalcRel(const csVector3 & point);
void Copy(ps2DLine & dest);
};
class psWalkPoly;
class psMapWalker;
struct iSector;
class CelBase;
struct iDocumentNode;
struct iVFS;
/**************************************************************************
* psSpatialIndex is a tree-style data structure.
* Its purpose is fast search of the psWalkPoly that is under your feet
* or close to you.
* It recursively splits the space into pairs of rectangular subspaces.
*
* Each subspace corresponds to one node of the tree.
* Each node keeps list of psWalkPolys whose psWalkPoly::box
* collides with the subspace of the node.
***************************************************************************/
class psSpatialIndexNode
{
friend class psSpatialIndex;
public:
psSpatialIndexNode();
/** Finds terminal node containing given point
The point MUST be located in subtree of this node */
psSpatialIndexNode * FindNodeOfPoint(const csVector3 & p);
/** Adds polygon to the right terminal nodes from the subtree */
void Add(psWalkPoly* poly);
csBox3 & GetBBox() { return bbox; }
csList<psWalkPoly*> * GetPolys() { return &polys; };
protected:
/** Returns distance to root (root has 0) */
int GetTreeLevel();
/** Splits itself into two nodes */
void Split();
/** Chooses and sets appropriate splitAxis and splitValue */
void ChooseSplit();
psSpatialIndexNode * child1, * child2;
psSpatialIndexNode * parent;
csBox3 bbox; /** subspace of this node */
float splitValue; /** The border value of x or y or z which separates the subspaces
of child1 and child2 ... used only if node has children */
char splitAxis; /** 0=x, 1=y, 2=z ... used only if node has children */
csList<psWalkPoly*> polys; /** Polygons whose "box" collides with this subspace */
int numPolys; /** Length of the list because csList lacks that */
};
class psSpatialIndex
{
public:
psSpatialIndex();
/** Adds without balancing */
void Add(psWalkPoly* poly);
/** Rebuilds the index from scratch so that it is more balanced */
void Rebuild();
/** Finds terminal node containing given point.
'hint' is an optional index node that could be the right node */
psSpatialIndexNode * FindNodeOfPoint(const csVector3 & p, psSpatialIndexNode * hint=NULL);
//psSpatialIndexNode * FindNodeOfPoly(psWalkPoly * poly);
/** Finds psWalkPoly whose "box" contains given point
'hint' is an optional index node that could be the right node */
psWalkPoly * FindPolyOfPoint(const csVector3 & p, psSpatialIndexNode * hint=NULL);
psANode * FindNearbyANode(const csVector3 & pos);
protected:
psSpatialIndexNode root;
};
class psSeed
{
public:
psSeed();
psSeed(csVector3 pos, iSector * sector, float quality);
psSeed(csVector3 edgePos, csVector3 pos, iSector * sector, float quality);
void SaveToString(csString & str);
void LoadFromXML(iDocumentNode * node, csRef<iEngine> engine);
bool CheckValidity(psMapWalker * walker);
bool edgeSeed;
float quality;
csVector3 pos, edgePos;
iSector * sector;
};
class psSeedSet
{
public:
psSeedSet(iObjectRegistry * objReg);
psSeed PickUpBestSeed();
void AddSeed(const psSeed & seed);
bool IsEmpty() { return seeds.IsEmpty(); }
bool LoadFromString(const csString & str);
bool LoadFromFile(const csString & path);
void SaveToString(csString & str);
bool SaveToFile(const csString & path);
protected:
iObjectRegistry * objReg;
csList<psSeed> seeds;
};
/*****************************************************************
* The areas of map that are without major obstacles are denoted
* by set of polygons that cover these areas. This is used
* to precisely calculate very short paths. Other paths
* are calculated using A*, and later fine-tuned with this map.
******************************************************************/
/** This describes a contact of edge of one polygon with edge of another polygon */
class psWalkPolyCont
{
public:
csVector3 begin, end; ///< what part of the edge
psWalkPoly * poly; ///< the polygon that touches us
};
/** Vertex of psWalkPoly, also containing info about edge to the next vertex.
Contains list of contacts with neighbour psWalkPolys */
class psWalkPolyVert
{
public:
csVector3 pos;
ps2DLine line; ///< normal equation of edge from this vertex to the following one
csArray<psWalkPolyCont> conts;
csString info; ///< debug only
bool touching, stuck;
bool followingEdge;
float angle;
psWalkPolyVert();
psWalkPolyVert(const csVector3 & pos);
/** Finds neighbour polygon that contacts with this edge at given point.
Return NULL = there is no contact at this point */
psWalkPoly * FindCont(const csVector3 & point);
void CalcLineTo(const csVector3 & point);
};
/** This just keeps all polygons that we know and their index */
class psWalkPolyMap
{
friend class psWalkPoly;
public:
psWalkPolyMap(iObjectRegistry * objReg);
psWalkPolyMap();
void SetObjReg(iObjectRegistry * objReg) { this->objReg=objReg; }
/** Adds new polygon to map */
void AddPoly(psWalkPoly * );
/** Checks if you can go directly between two points without problems */
bool CheckDirectPath(csVector3 start, csVector3 goal);
void Generate(psNPCClient * npcclient, psSeedSet & seeds, iSector * sector);
void CalcConts();
csString DumpPolys();
void BuildBasicAMap(psAMap & AMap);
void LoadFromXML(iDocumentNode * node);
bool LoadFromString(const csString & str);
bool LoadFromFile(const csString & path);
void SaveToString(csString & str);
bool SaveToFile(const csString & path);
psANode * FindNearbyANode(const csVector3 & pos);
psWalkPoly * FindPoly(int id);
void PrunePolys();
void DeleteContsWith(psWalkPoly * poly);
protected:
csList<psWalkPoly*> polys;
psSpatialIndex index;
csHash<psWalkPoly*> polyByID;
iObjectRegistry * objReg;
csRef<iVFS> vfs;
};
/********************************************************************
* A convex polygon that denotes area without major obstacles .
* It is not necessarily a real polygon, because its vertices
* do not have to be on the same 3D plane (just "roughly").
* The walkable area within the polygon borders is rarely flat, too.
********************************************************************/
class psWalkPoly
{
friend class psWalkPolyMap;
public:
psWalkPoly();
~psWalkPoly();
/** Adds a new vertex to polygon
- vertices must be added CLOCKWISE ! */
void AddVert(const csVector3 & pos, int beforeIndex=-1);
size_t GetNumVerts() { return verts.GetSize(); }
void AddNode(psANode * node);
void DeleteNode(psANode * node);
void SetSector(iSector * sector);
/** Moves 'point' (which must be within our polygon) towards 'goal' until it reaches
another polygon or dead end.
Returns true, if it reached another polygon, false on dead end */
bool MoveToNextPoly(const csVector3 & goal, csVector3 & point, psWalkPoly * & nextPoly);
void AddSeeds(psMapWalker * walker, psSeedSet & seeds);
/** Checks if polygon is still convex after we moved vertex 'vertNum' */
bool CheckConvexity(int vertNum);
void Clear();
//ignores y
void Cut(const csVector3 & cut1, const csVector3 & cut2);
//ignores y
void Intersect(const psWalkPoly & other);
float EstimateY(const csVector3 & point);
void Dump(const char * name);
void DumpJS(const char * name);
void DumpPureJS();
void DumpPolyJS(const char * name);
int Stretch(psMapWalker & walker, psWalkPolyMap & map, float stepSize);
void GlueToNeighbours(psMapWalker & walker, psWalkPolyMap & map);
float GetBoxSize();
float GetArea();
float GetTriangleArea(int vertNum);
float GetLengthOfEdges();
void GetShape(float & min, float & max);
float GetNarrowness();
void PruneUnboundVerts(psMapWalker & walker);
void PruneInLineVerts();
bool IsNearWalls(psMapWalker & walker, int vertNum);
/** returns true if it moved at least a bit */
bool StretchVert(psMapWalker & walker, psWalkPolyMap & map, int vertNum, const csVector3 & newPos, float stepSize);
void SetMini(psMapWalker & walker, const csVector3 & pos, int numVerts);
/** Calculates box of polygon */
void CalcBox();
csBox3 & GetBox() { return box; }
bool IsInLine();
void ClearInfo();
bool CollidesWithPolys(psWalkPolyMap & map, csList<psWalkPoly*> * polys);
void SaveToString(csString & str);
void LoadFromXML(iDocumentNode * node, csRef<iEngine> engine);
/** Populates the 'conts' array */
void CalcConts(psWalkPolyMap & map);
void RecalcAllEdges();
void ConnectNodeToPoly(psANode * node, bool bidirectional);
bool TouchesPoly(psWalkPoly * poly);
bool NeighboursTouchEachOther();
psANode * GetFirstNode();
int GetID() { return id; }
iSector * GetSector() { return sector; }
bool PointIsIn(const csVector3 & p, float maxRel=0);
csVector3 GetClosestPoint(const csVector3 & point, float & angle);
int GetNumConts();
size_t GetNumNodes() { return nodes.GetSize(); }
bool ReachableFromNeighbours();
psWalkPoly* GetNearNeighbour(const csVector3 & pos, float maxDist);
void DeleteContsWith(psWalkPoly * poly);
bool NeighbourSupsMe(psWalkPoly* neighbour);
void MovePointInside(csVector3 & point, const csVector3 & goal);
protected:
void RecalcEdges(int vertNum);
int FindClosestEdge(const csVector3 pos);
/** Finds contact of this polygon with another polygon that is
at given point and edge */
psWalkPoly * FindCont(const csVector3 & point, int edgeNum);
/** Moves 'point' to the closest point in the direction of 'goal' that is within
our polygon (some point on polygon border).
'edgeNum' is number of the edge where the new point is */
bool MoveToBorder(const csVector3 & goal, csVector3 & point, int & edgeNum);
/** Populates the 'edges' array according to 'verts' */
void CalcEdges();
int GetNeighbourIndex(int vertNum, int offset) const;
bool HandleProblems(psMapWalker & walker, psWalkPolyMap & map, int vertNum, const csVector3 & oldPos);
csVector3 GetClosestCollisionPoint(csList<psWalkPoly*> & collisions, ps2DLine & line);
bool HandlePolyCollisions(psWalkPolyMap & map, int vertNum, const csVector3 & oldPos);
int id;
static int nextID;
bool supl;
csArray<psWalkPolyVert> verts; /** vertices of polygon */
iSector * sector;
csBox3 box; /** box around polygon - taller than the real poly */
csArray<psANode*> nodes;
};
#endif
#endif
| [
"whacko88@2752fbe2-5038-0410-9d0a-88578062bcef"
] | whacko88@2752fbe2-5038-0410-9d0a-88578062bcef |
c7ad667771f2737d87dc1bcbb1062bb791a32891 | 39e9e8c8d4ca4e97c87f35670e0774920a2abe45 | /Viscous/viscous_explicit.cpp | f68f3576d94040890d6259110772a44f661caa48 | [] | no_license | aditya12398/QKFVS_2D | a15de68d4759c36fe6e19c995004aa6b39fe64fa | 9d80d5f64f25f9235ab61d2c78333165473787e6 | refs/heads/master | 2020-06-14T13:46:01.679637 | 2019-08-09T02:38:01 | 2019-08-09T02:38:01 | 195,017,837 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,153 | cpp | /*
This code is a solver for 2D Euler equations for compressible domain.
It uses `Kinetic Flux Vector Splitting(KFVS)` to calculate fluxes across the edges of a cell and conserve them. The related equations can be found in the Reference: "J. C. Mandal, S. M. Deshpande - Kinetic Flux Vector Splitting For Euler Equations" at location ../References/Kinetic_Flux_Vector_Splitting
Strongly Recommended: Use Visual Studio Code(text editor) while understanding the code. The comments are coupled appropriately with the functions and variables for easier understanding.
*/
#include <fstream>
#include <iostream>
#include <cmath>
using namespace std;
int max_edges, max_cells, max_iters;
double Mach, aoa, cfl, limiter_const;
double gma = 1.4, R = 287, Prandtl_number = 0.72; //Flow and material parameters
double residue, max_res; //RMS Residue and maximum residue in the fluid domain
int max_res_cell; //Cell number with maximum residue
double pi = 4.0 * atan(1.0);
//Structure to store edge data
struct Edge
{
int lcell, rcell; //Holds cell numbers on either side of the edge. Prefix l stands for left and r for right.
double nx, ny, mx, my; //Hold point data. Prefix m stands for midpoint and n for edge normal.
double length; //Holds edge length data
char status; //Specifies whether the edge is Internal(f), Wall(w) or Outer Boundary(o).
};
//Structure to store cell data
struct Cell
{
int *edge, noe, nbhs, *conn; //Holds enclosing edges and neighbour cell data.
double area, cx, cy; //Area of the cell and cell centre coordinates
double rho, u1, u2, pr, tp; //Values of density, x - velocity, y - velocity, pressure and temperature of the cell
double u1x, u2x, u1y, u2y; //Velocity derivatives
double tpx, tpy; //Temperature derivatives
double flux[5]; //Kinetic Fluxes. Reference: See function `void KFVS_pos_flux(...)`
double Unew[5], Uold[5]; //Corresponds to void backward_sweep()
double q[5], qx[5], qy[5]; //Entropy Variables. Reference: See Boltzmann Equations
};
struct Edge *edge;
struct Cell *cell;
//--------------------------Main function starts--------------------------
int main(int arg, char *argv[])
{
void input_data();
void initial_conditions();
void q_variables();
void q_derivatives();
void f_derivatives();
void evaluate_flux();
void state_update();
void print_output();
ofstream outfile("./Output/Residue");
double res_old;
input_data();
int T = 2;
for (int t = 1; t <= max_iters; t++)
{
initial_conditions();
q_variables();
q_derivatives();
f_derivatives();
evaluate_flux();
state_update();
if (t == 1)
res_old = residue;
residue = log10(residue / res_old);
if ((max_res) < -12 && (residue) < -12)
{
cout << "Convergence criteria reached.\n";
break;
}
cout << t << "\t" << residue << "\t" << max_res << "\t" << max_res_cell << endl;
outfile << t << "\t" << residue << "\t" << max_res << "\t" << max_res_cell << endl;
if (t == T)
{
T = T + 2;
print_output();
}
}
print_output();
} //End of the main function
/*
This function reads flow and grid data from the files:
Grid data: ogrid_viscous_dim
Flow Parameters: fp_viscous
*/
void input_data()
{
ifstream infile("ogrid_viscous_dim");
ifstream infile2("fp_viscous");
//Input Flow Parameters
infile2 >> Mach >> aoa >> cfl >> max_iters >> limiter_const;
//Input Edge data
infile >> max_edges;
edge = new Edge[max_edges + 1];
for (int k = 1; k <= max_edges; k++)
{
infile >> edge[k].mx >> edge[k].my >> edge[k].lcell >> edge[k].rcell >> edge[k].status >> edge[k].nx >> edge[k].ny >> edge[k].length;
}
//Input Cell data
infile >> max_cells;
cell = new Cell[max_cells + 1];
for (int k = 1; k <= max_cells; k++)
{
infile >> cell[k].cx >> cell[k].cy >> cell[k].rho >> cell[k].u1 >> cell[k].u2 >> cell[k].pr >> cell[k].area >> cell[k].noe;
cell[k].tp = cell[k].pr / (R * cell[k].rho);
//Set enclosing edges
cell[k].edge = new int[cell[k].noe + 1];
for (int r = 1; r <= cell[k].noe; r++)
infile >> cell[k].edge[r];
//Set neighbours
infile >> cell[k].nbhs;
cell[k].conn = new int[cell[k].nbhs];
for (int r = 0; r < cell[k].nbhs; r++)
infile >> cell[k].conn[r];
}
infile.close();
infile2.close();
} //End of the function
double *gauss_elimination(double matrix[5][(6)])
{
int i, j, k;
double *solution = new double[5];
double swap;
//Pivot the matrix for diagonal dominance
for (i = 0; i < 5; i++)
{
solution[i] = 0;
double max = fabs(matrix[i][i]);
int pos = i;
for (j = i; j < 5; j++)
{
if (fabs(matrix[j][i]) > max)
{
pos = j;
max = fabs(matrix[j][i]);
}
}
//Swap the elements
for (k = 0; k <= 5; k++)
{
swap = matrix[i][k];
matrix[i][k] = matrix[pos][k];
matrix[pos][k] = swap;
}
}
//Convert the matrix to a lower triangle matrix
for (i = 4; i > 0; i--)
{
for (j = i - 1; j >= 0; j--)
{
double d = (matrix[j][i] / matrix[i][i]);
for (k = 5; k >= 0; k--)
{
matrix[j][k] -= d * matrix[i][k];
}
}
}
solution[0] = matrix[0][5] / matrix[0][0];
for (i = 1; i < 5; i++)
{
solution[i] = matrix[i][5];
for (j = i - 1; j >= 0; j--)
{
solution[i] -= (solution[j] * matrix[i][j]);
}
solution[i] = solution[i] / matrix[i][i];
}
return solution;
}
void construct_equation(int k, char var, double matrix[5][6])
{
double sig_dxdx, sig_dydy, sig_dxdy;
double sig_dxdxdx, sig_dydydy, sig_dxdxdy, sig_dxdydy;
double sig_dxdxdxdx, sig_dydydydy, sig_dxdxdxdy, sig_dxdxdydy, sig_dxdydydy;
double sig_dfdx, sig_dfdy, sig_dfdxdx, sig_dfdydy, sig_dfdxdy;
double dx, dy, df;
sig_dxdx = sig_dydy = sig_dxdy = sig_dxdxdx = sig_dydydy = sig_dxdxdy = sig_dxdydy = sig_dxdxdxdx = sig_dydydydy = sig_dxdxdxdy = sig_dxdxdydy = sig_dxdydydy = sig_dfdx = sig_dfdy = sig_dfdxdx = sig_dfdydy = sig_dfdxdy = 0;
for (int i = 0; i < cell[k].nbhs; i++)
{
int p = cell[k].conn[i];
dx = cell[p].cx - cell[k].cx;
dy = cell[p].cy - cell[k].cy;
double dist = sqrt(dx * dx + dy * dy); //Distance between cell and edge midpoint
double w = 1 / pow(dist, 2.0); //Least Squares weight
if (var == 'u')
df = cell[p].u1 - cell[k].u1;
else if (var == 'v')
df = cell[p].u2 - cell[k].u2;
else if (var == 't')
df = cell[p].tp - cell[k].tp;
sig_dfdx += w * df * dx;
sig_dfdy += w * df * dy;
sig_dfdxdx += w * df * dx * dx;
sig_dfdydy += w * df * dy * dy;
sig_dfdxdy += w * df * dx * dy;
sig_dxdx += w * dx * dx;
sig_dxdy += w * dx * dy;
sig_dydy += w * dy * dy;
sig_dxdxdx += w * dx * dx * dx;
sig_dxdxdy += w * dx * dx * dy;
sig_dxdydy += w * dx * dy * dy;
sig_dydydy += w * dy * dy * dy;
sig_dxdxdxdx += w * dx * dx * dx * dx;
sig_dxdxdxdy += w * dx * dx * dx * dy;
sig_dxdxdydy += w * dx * dx * dy * dy;
sig_dxdydydy += w * dx * dy * dy * dy;
sig_dydydydy += w * dy * dy * dy * dy;
}
matrix[0][5] = sig_dfdx;
matrix[1][5] = sig_dfdy;
matrix[2][5] = sig_dfdxdx / 2;
matrix[3][5] = sig_dfdydy / 2;
matrix[4][5] = sig_dfdxdy;
matrix[0][0] = sig_dxdx;
matrix[1][1] = sig_dydy;
matrix[2][2] = sig_dxdxdxdx / 4;
matrix[3][3] = sig_dydydydy / 4;
matrix[4][4] = sig_dxdxdydy;
matrix[0][1] = matrix[1][0] = sig_dxdy;
matrix[0][2] = matrix[2][0] = sig_dxdxdx / 2;
matrix[0][3] = matrix[3][0] = sig_dxdydy / 2;
matrix[0][4] = matrix[4][0] = sig_dxdxdy;
matrix[1][2] = matrix[2][1] = sig_dxdxdy / 2;
matrix[1][3] = matrix[3][1] = sig_dydydy / 2;
matrix[1][4] = matrix[4][1] = sig_dxdydy;
matrix[2][3] = matrix[3][2] = sig_dxdxdydy / 4;
matrix[2][4] = matrix[4][2] = sig_dxdxdxdy / 2;
matrix[3][4] = matrix[4][3] = sig_dxdydydy / 2;
}
void f_derivatives()
{
for (int k = 1; k <= max_cells; k++)
{
double matrix[5][6], *solution;
//Derivative of velocity
construct_equation(k, 'u', matrix);
solution = gauss_elimination(matrix);
cell[k].u1x = solution[0];
cell[k].u1y = solution[1];
delete[] solution;
construct_equation(k, 'v', matrix);
solution = gauss_elimination(matrix);
cell[k].u2x = solution[0];
cell[k].u2y = solution[1];
delete[] solution;
construct_equation(k, 't', matrix);
solution = gauss_elimination(matrix);
cell[k].tpx = solution[0];
cell[k].tpy = solution[1];
delete[] solution;
}
}
void viscous_flux(double *G, int e, double nx, double ny, int CELL, double rho_ref, double u1_ref, double u2_ref, double pr_ref)
{
double u_dash[5], tp_dash[3];
double tauxx, tauyy, tauxy, t_ref, mu, kappa;
t_ref = pr_ref / (R * rho_ref);
mu = 1.458E-6 * pow(t_ref, 1.5) / (t_ref + 110.4);
kappa = mu * (gma * R) / (Prandtl_number * (gma - 1));
u_dash[1] = (cell[CELL].u1x);
u_dash[2] = (cell[CELL].u1y);
u_dash[3] = (cell[CELL].u2x);
u_dash[4] = (cell[CELL].u2y);
tp_dash[1] = cell[CELL].tpx;
tp_dash[2] = cell[CELL].tpy;
tauxx = mu * (4 / 3 * u_dash[1] - 2 / 3 * u_dash[4]);
tauyy = mu * (4 / 3 * u_dash[4] - 2 / 3 * u_dash[1]);
tauxy = mu * (u_dash[2] + u_dash[3]);
//Storing viscous fluxes
if (edge[e].status == 'w')
{
tp_dash[1] = tp_dash[2] = 0;
}
G[1] = 0;
G[2] = -(tauxx * nx + tauxy * ny);
G[3] = -(tauxy * nx + tauyy * ny);
G[4] = -((u1_ref * tauxx + u2_ref * tauxy + kappa * tp_dash[1]) * nx) + ((u1_ref * tauxy + u2_ref * tauyy + kappa * tp_dash[2]) * ny);
}
//Fluxes are evaluated in this function
void evaluate_flux()
{
//Function Prototypes
void linear_reconstruction(double *, int, int);
void KFVS_pos_flux(double *, double, double, double, double, double, double);
void KFVS_neg_flux(double *, double, double, double, double, double, double);
void KFVS_wall_flux(double *, double, double, double, double, double, double);
void KFVS_outer_flux(double *, double, double, double, double, double, double);
double u_dash[5];
int lcell, rcell;
double nx, ny, s;
double Gp[5], Gn[5], Gd[5];
double Gwall[5], Gout[5];
double lprim[5], rprim[5];
char status;
double rhol, u1l, u2l, prl; //Left Cell Data
double rhor, u1r, u2r, prr; //Right Cell Data
for (int k = 1; k <= max_edges; k++)
{
lcell = edge[k].lcell;
rcell = edge[k].rcell;
nx = edge[k].nx;
ny = edge[k].ny;
s = edge[k].length;
status = edge[k].status;
if (status == 'f') //Flux across interior edges
{
linear_reconstruction(lprim, lcell, k);
linear_reconstruction(rprim, rcell, k);
rhol = lprim[1];
u1l = lprim[2];
u2l = lprim[3];
prl = lprim[4];
rhor = rprim[1];
u1r = rprim[2];
u2r = rprim[3];
prr = rprim[4];
KFVS_pos_flux(Gp, nx, ny, rhol, u1l, u2l, prl);
KFVS_neg_flux(Gn, nx, ny, rhor, u1r, u2r, prr);
viscous_flux(Gd, k, nx, ny, lcell, rhol, u1l, u2l, prl);
viscous_flux(Gd, k, nx, ny, rcell, rhor, u1r, u2r, prr);
for (int r = 1; r <= 4; r++)
{
cell[lcell].flux[r] = cell[lcell].flux[r] + s * (*(Gp + r) + *(Gn + r) + *(Gd + r));
cell[rcell].flux[r] = cell[rcell].flux[r] - s * (*(Gp + r) + *(Gn + r) + *(Gd + r));
}
}
if (status == 'w') //Flux across wall edge
{
if (lcell == 0)
{
nx = -nx;
ny = -ny;
lcell = rcell;
}
linear_reconstruction(lprim, lcell, k);
rhol = lprim[1];
u1l = lprim[2];
u2l = lprim[3];
prl = lprim[4];
KFVS_wall_flux(Gwall, nx, ny, rhol, u1l, u2l, prl);
viscous_flux(Gd, k, nx, ny, lcell, rhol, 0, 0, prl);
for (int r = 1; r <= 4; r++)
cell[lcell].flux[r] = cell[lcell].flux[r] + s * (*(Gwall + r) + *(Gd + r));
}
if (status == 'o') //Flux across outer boundary edge
{
if (lcell == 0)
{
nx = -nx;
ny = -ny;
lcell = rcell;
}
linear_reconstruction(lprim, lcell, k);
rhol = lprim[1];
u1l = lprim[2];
u2l = lprim[3];
prl = lprim[4];
KFVS_outer_flux(Gout, nx, ny, rhol, u1l, u2l, prl);
viscous_flux(Gd, k, nx, ny, lcell, rhol, u1l, u2l, prl);
for (int r = 1; r <= 4; r++)
cell[lcell].flux[r] = cell[lcell].flux[r] + s * (*(Gout + r) + *(Gd + r));
}
} //End of k loop
} //End of the flux function
//Expressions for the kfvs - fluxes
/*
Function to find the kfvs - positive flux
The following function uses the G Flux equations.
Reference: J. C. Mandal, S. M. Deshpande - Kinetic Flux Vector Splitting For Euler Equations; Page 7 of 32; Book Page Number 453
Reference Location: ../References/Kinetic_Flux_Vector_Splitting/
*/
void KFVS_pos_flux(double *G, double nx, double ny, double rho, double u1, double u2, double pr)
{
double tx, ty;
tx = ny;
ty = -nx;
double un = u1 * nx + u2 * ny;
double ut = u1 * tx + u2 * ty;
double beta = 0.5 * rho / pr;
double S = un * sqrt(beta);
double A = 0.5 * (1 + erf(S));
double B = 0.5 * exp(-S * S) / sqrt(pi * beta);
*(G + 1) = rho * (un * A + B);
double temp1 = (pr + rho * un * un) * A + rho * un * B;
double temp2 = rho * (un * ut * A + ut * B);
*(G + 2) = -ty * temp1 + ny * temp2;
*(G + 3) = tx * temp1 - nx * temp2;
temp1 = 0.5 * rho * (un * un + ut * ut);
*(G + 4) = ((gma / (gma - 1)) * pr + temp1) * un * A + (((gma + 1) / (2 * (gma - 1))) * pr + temp1) * B;
} //End of G-positive flux
/*
Function to find the kfvs - negative flux
The following function uses the G Flux equations.
Reference: J. C. Mandal, S. M. Deshpande - Kinetic Flux Vector Splitting For Euler Equations; Page 7 of 32; Book Page Number 453
Reference Location: ../References/Kinetic_Flux_Vector_Splitting/
*/
void KFVS_neg_flux(double *G, double nx, double ny, double rho, double u1, double u2, double pr)
{
double tx, ty;
tx = ny;
ty = -nx;
double un = u1 * nx + u2 * ny;
double ut = u1 * tx + u2 * ty;
double beta = 0.5 * rho / pr;
double S = un * sqrt(beta);
double A = 0.5 * (1 - erf(S));
double B = 0.5 * exp(-S * S) / sqrt(pi * beta);
*(G + 1) = rho * (un * A - B);
double temp1 = (pr + rho * un * un) * A - rho * un * B;
double temp2 = rho * (un * ut * A - ut * B);
*(G + 2) = -ty * temp1 + ny * temp2;
*(G + 3) = tx * temp1 - nx * temp2;
temp1 = 0.5 * rho * (un * un + ut * ut);
*(G + 4) = ((gma / (gma - 1)) * pr + temp1) * un * A - (((gma + 1) / (2 * (gma - 1))) * pr + temp1) * B;
} //End of G-negative flux
/*
Function to find the kfvs - wall boundary flux
The following function uses the G Flux equations.
Reference: J. C. Mandal, S. M. Deshpande - Kinetic Flux Vector Splitting For Euler Equations; Page 7 of 32; Book Page Number 453
Reference Location: ../References/Kinetic_Flux_Vector_Splitting/
*/
void KFVS_wall_flux(double *G, double nx, double ny, double rho, double u1, double u2, double pr)
{
double un, ut;
ut = 0.0; //No slip boundary condition
un = 0.0;
double beta = 0.5 * rho / pr;
double Sw = un * sqrt(beta);
double Aw = 0.5 * (1 + erf(Sw));
double Bw = 0.5 * exp(-Sw * Sw) / sqrt(pi * beta);
double temp = (pr + rho * un * un) * Aw + rho * un * Bw;
temp = 2.0 * temp;
*(G + 1) = 0.0;
*(G + 2) = nx * temp;
*(G + 3) = ny * temp;
*(G + 4) = 0.0;
} //End of the wall flux function
/*
Function to find the kfvs - outer boundary flux
The following function uses the G Flux equations.
Reference: J. C. Mandal, S. M. Deshpande - Kinetic Flux Vector Splitting For Euler Equations; Page 7 of 32; Book Page Number 453
Reference Location: ../References/Kinetic_Flux_Vector_Splitting/
*/
void KFVS_outer_flux(double *Gout, double nx, double ny, double rho, double u1, double u2, double pr)
{
void KFVS_pos_flux(double *, double, double, double, double, double, double);
void KFVS_neg_flux(double *, double, double, double, double, double, double);
double Gp[5];
double Gn_inf[5];
double rho_inf, u1_inf, u2_inf, pr_inf, u_ref;
u_ref = sqrt(gma * R * 288.20);
double theta = aoa * pi / 180;
rho_inf = 1.225;
u1_inf = u_ref * Mach * cos(theta);
u2_inf = u_ref * Mach * sin(theta);
pr_inf = 101325.0;
KFVS_pos_flux(Gp, nx, ny, rho, u1, u2, pr);
KFVS_neg_flux(Gn_inf, nx, ny, rho_inf, u1_inf, u2_inf, pr_inf);
for (int r = 1; r <= 4; r++)
*(Gout + r) = *(Gp + r) + *(Gn_inf + r);
} //End of the function
//Function to find the conserved vector from the given primitive vector
void prim_to_conserved(double *U, int k)
{
double rho, u1, u2, pr, e;
rho = cell[k].rho;
u1 = cell[k].u1;
u2 = cell[k].u2;
pr = cell[k].pr;
e = (1 / (gma - 1)) * pr / rho + 0.5 * (u1 * u1 + u2 * u2);
*(U + 1) = rho;
*(U + 2) = rho * u1;
*(U + 3) = rho * u2;
*(U + 4) = rho * e;
} //End of the function
//Function to get the primitive vector from the given conserved vector
void conserved_to_primitive(double *U, int k)
{
double U1 = *(U + 1);
double U2 = *(U + 2);
double U3 = *(U + 3);
double U4 = *(U + 4);
cell[k].rho = U1;
double temp = 1 / U1;
cell[k].u1 = U2 * temp;
cell[k].u2 = U3 * temp;
temp = U4 - (0.5 * temp) * (U2 * U2 + U3 * U3);
cell[k].pr = 0.4 * temp;
cell[k].tp = cell[k].pr / (R * cell[k].rho);
} //End of the function
//Function to find the delt (delta t) for each cell
double func_delt(int k)
{
double smallest_dist(int);
double rho, u1, u2, pr;
double area, temp1, smin;
int edges, e;
double nx, ny, delt_inv = 0.0, delt_visc = 0.0;
area = cell[k].area;
u1 = cell[k].u1;
u2 = cell[k].u2;
rho = cell[k].rho;
pr = cell[k].pr;
smin = smallest_dist(k);
edges = cell[k].noe;
temp1 = 3.0 * sqrt(pr / rho);
for (int r = 1; r <= edges; r++)
{
e = cell[k].edge[r];
double length = edge[e].length;
nx = edge[e].nx;
ny = edge[e].ny;
if (edge[e].rcell == k)
{
nx = -nx;
ny = -ny;
}
double un = u1 * nx + u2 * ny;
double temp2 = (fabs(un) + temp1);
temp2 = length * temp2;
delt_inv = delt_inv + temp2;
}
double mu = 1.458E-6 * pow(cell[k].tp, 1.5) / (cell[k].tp + 110.4);
delt_inv = 2.0 * area / delt_inv;
delt_visc = rho * Prandtl_number * smin * smin / (4 * mu * gma);
double delt = 1 / ((1 / delt_inv) + (1 / delt_visc));
return (cfl * delt);
} //End of the function
//Function to give the initial conditions
void initial_conditions()
{
double rho, u1, u2, pr, e, U[5];
for (int k = 1; k <= max_cells; k++)
{
rho = cell[k].rho;
u1 = cell[k].u1;
u2 = cell[k].u2;
pr = cell[k].pr;
e = (1 / (gma - 1)) * pr / rho + 0.5 * (u1 * u1 + u2 * u2);
U[1] = rho;
U[2] = rho * u1;
U[3] = rho * u2;
U[4] = rho * e;
for (int r = 1; r <= 4; r++)
{
cell[k].flux[r] = 0.0;
cell[k].Uold[r] = U[r];
cell[k].Unew[r] = U[r];
}
}
} //End of the function
void state_update()
{
void prim_to_conserved(double *, int);
void conserved_to_primitive(double *, int);
residue = 0.0;
max_res = 0.0;
double U[5];
for (int k = 1; k <= max_cells; k++)
{
prim_to_conserved(U, k);
double temp = U[1];
for (int r = 1; r <= 4; r++)
{
cell[k].Unew[r] = cell[k].Uold[r] - func_delt(k) * cell[k].flux[r] / cell[k].area;
U[r] = cell[k].Unew[r];
cell[k].Uold[r] = cell[k].Unew[r];
}
residue = residue + (temp - U[1]) * (temp - U[1]);
temp = fabs(temp - U[1]);
if (max_res < temp)
{
max_res = temp;
max_res_cell = k;
}
conserved_to_primitive(U, k);
}
residue = residue / max_cells;
residue = sqrt(residue);
} //End of the function
//Function writes the data in supported tecplot format
void write_tecplot()
{
static int count = 1;
string title =to_string(count++) + "_Solution_Tecplot_Explicit.dat";
ofstream tecplotfile("./Output/" + title);
tecplotfile << "TITLE: \"QKFVS Viscous Code - NAL\"\n";
tecplotfile << "VARIABLES= \"X\", \"Y\", \"Density\", \"Pressure\", \"x-velocity\", \"y-velocity\", \"Velocity Magnitude\", \"Temperature\"\n";
tecplotfile << "ZONE I= 298 J= 179, DATAPACKING=BLOCK\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << cell[k].cx << "\n";
}
}
tecplotfile << "\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << cell[k].cy << "\n";
}
}
tecplotfile << "\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << cell[k].rho << "\n";
}
}
tecplotfile << "\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << cell[k].pr << "\n";
}
}
tecplotfile << "\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << cell[k].u1 << "\n";
}
}
tecplotfile << "\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << cell[k].u2 << "\n";
}
}
tecplotfile << "\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << sqrt(pow(cell[k].u1, 2) + pow(cell[k].u2, 2)) << "\n";
}
}
tecplotfile << "\n";
for (int j = 1; j < 180; j++)
{
for (int i = 1; i <= 298; i++)
{
int k = (j - 1) * 298 + i;
tecplotfile << cell[k].tp << "\n";
}
}
tecplotfile << "\n";
tecplotfile.close();
}
//Function which prints the final primitive vector into the file "primitive-vector.dat"
void print_output()
{
ofstream outfile("./Output/Primitive-Vector.dat");
for (int k = 1; k <= max_cells; k++)
{
outfile << k << "\t" << cell[k].rho << "\t" << cell[k].u1 << "\t" << cell[k].u2 << "\t" << cell[k].pr << endl;
}
write_tecplot();
} //End of the function
/*
Second order part of the code starts from here
Second order accuracy is achieved via linear reconstruction with q-variables
*/
//Function to calculate the q-variables for all the nodes
void q_variables()
{
int i;
double rho, u1, u2, pr, beta;
for (i = 1; i <= max_cells; i++)
{
rho = cell[i].rho;
u1 = cell[i].u1;
u2 = cell[i].u2;
pr = cell[i].pr;
beta = 0.5 * rho / pr;
cell[i].q[1] = log(rho) + (log(beta) * (1 / (gma - 1))) - beta * (u1 * u1 + u2 * u2);
cell[i].q[2] = 2 * beta * u1;
cell[i].q[3] = 2 * beta * u2;
cell[i].q[4] = -2 * beta;
}
} //End of the function
//Function to convert q-varibales to primitive variables
void func_qtilde_to_prim_variables(double *prim, double *qtilde)
{
double q1, q2, q3, q4, beta, u1, u2;
q1 = *(qtilde + 1);
q2 = *(qtilde + 2);
q3 = *(qtilde + 3);
q4 = *(qtilde + 4);
beta = -q4 * 0.5;
double temp = 0.5 / beta;
*(prim + 2) = q2 * temp;
*(prim + 3) = q3 * temp;
u1 = *(prim + 2);
u2 = *(prim + 3);
double temp1 = q1 + beta * (u1 * u1 + u2 * u2);
//double temp2 = temp1 - (log(beta)/(gma-1));
temp1 = temp1 - (log(beta) * (1 / (gma - 1)));
*(prim + 1) = exp(temp1);
*(prim + 4) = *(prim + 1) * temp;
} //End of the function
//Function to find q-derivatives using the method of least squares
void q_derivatives()
{
//double power = 2.0;
for (int k = 1; k <= max_cells; k++)
{
//Initialise the sigma values
double sig_dxdx = 0.0;
double sig_dydy = 0.0;
double sig_dxdy = 0.0;
double sig_dxdq[5], sig_dydq[5];
for (int r = 1; r <= 4; r++)
{
sig_dxdq[r] = 0.0;
sig_dydq[r] = 0.0;
}
for (int j = 0; j < cell[k].nbhs; j++)
{
int p = cell[k].conn[j];
double delx = cell[p].cx - cell[k].cx;
double dely = cell[p].cy - cell[k].cy;
double dist = sqrt(delx * delx + dely * dely);
double w = 1 / pow(dist, 2.0);
sig_dxdx = sig_dxdx + w * delx * delx;
sig_dydy = sig_dydy + w * dely * dely;
sig_dxdy = sig_dxdy + w * delx * dely;
for (int r = 1; r <= 4; r++)
{
double delq = cell[p].q[r] - cell[k].q[r];
sig_dxdq[r] = sig_dxdq[r] + w * delx * delq;
sig_dydq[r] = sig_dydq[r] + w * dely * delq;
}
}
double det = sig_dxdx * sig_dydy - sig_dxdy * sig_dxdy;
for (int r = 1; r <= 4; r++)
{
double detx = sig_dydy * sig_dxdq[r] - sig_dxdy * sig_dydq[r];
double dety = sig_dxdx * sig_dydq[r] - sig_dxdy * sig_dxdq[r];
cell[k].qx[r] = detx / det;
cell[k].qy[r] = dety / det;
}
} //End of k loop
} //End of the function
//Function to find the linear reconstruction values of primitive variables at the mid point of a given edge
void linear_reconstruction(double *prim, int CELL, int edg)
{
void limiter(double *, double *, int);
void func_qtilde_to_prim_variables(double *, double *);
double delx, dely, phi[5], qtilde[5];
delx = edge[edg].mx - cell[CELL].cx;
dely = edge[edg].my - cell[CELL].cy;
for (int r = 1; r <= 4; r++)
qtilde[r] = cell[CELL].q[r] + delx * cell[CELL].qx[r] + dely * cell[CELL].qy[r];
//limiter(qtilde, phi, CELL);
/*for (int r = 1; r <= 4; r++)
qtilde[r] = cell[CELL].q[r] + phi[r] * (delx * cell[CELL].qx[r] + dely * cell[CELL].qy[r]);*/
func_qtilde_to_prim_variables(prim, qtilde);
} //End of the function
//Function to find the limiter
void limiter(double *qtilde, double *phi, int k)
{
double maximum(int, int);
double minimum(int, int);
double smallest_dist(int);
double max_q, min_q, temp;
double q, del_neg, del_pos;
for (int r = 1; r <= 4; r++)
{
q = cell[k].q[r];
del_neg = qtilde[r] - q;
if (fabs(del_neg) <= 10e-6)
phi[r] = 1.0;
else
{
if (del_neg > 0.0)
{
max_q = maximum(k, r);
del_pos = max_q - q;
}
else if (del_neg < 0.0)
{
min_q = minimum(k, r);
del_pos = min_q - q;
}
double num, den, ds;
ds = smallest_dist(k);
double epsi = limiter_const * ds;
epsi = pow(epsi, 3.0);
num = (del_pos * del_pos) + (epsi * epsi);
num = num * del_neg + 2.0 * del_neg * del_neg * del_pos;
den = del_pos * del_pos + 2.0 * del_neg * del_neg;
den = den + del_neg * del_pos + epsi * epsi;
den = den * del_neg;
temp = num / den;
if (temp < 1.0)
phi[r] = temp;
else
phi[r] = 1.0;
}
}
} //End of the function
double maximum(int k, int r)
{
double max = cell[k].q[r];
for (int j = 0; j < cell[k].nbhs; j++)
{
int p = cell[k].conn[j];
if (cell[p].q[r] > max)
max = cell[p].q[r];
}
return (max);
} //End of the function
double minimum(int k, int r)
{
double min = cell[k].q[r];
for (int j = 0; j < cell[k].nbhs; j++)
{
int p = cell[k].conn[j];
if (cell[p].q[r] < min)
min = cell[p].q[r];
}
return (min);
} //End of the function
//Finding the dels; the smallest distance measured over the neighbours of a given cell
double smallest_dist(int k)
{
int p;
double dx, dy, ds, min;
for (int j = 0; j < cell[k].nbhs; j++)
{
p = cell[k].conn[j];
dx = cell[p].cx - cell[k].cx;
dy = cell[p].cy - cell[k].cy;
ds = sqrt(dx * dx + dy * dy);
if (j == 0)
min = ds;
if (ds < min)
min = ds;
}
return (ds);
} //End of the function | [
"[email protected]"
] | |
dd17aea02e2bcc6fc9c62ed475cbe61630ff9bd4 | d017b807b3753800feef6b8077d084b460027e46 | /cpp/AlignParametric/ParticleSurface.cpp | fe23b164543c2453c78ca40248b79256e1172a1e | [] | no_license | awturner/awturner-phd | de64cc0c23e1195df59ea9ac6ebfa8e24ee55f88 | d8280b5602476565d97586854566c93fefe1d431 | refs/heads/master | 2016-09-06T04:47:14.802338 | 2011-06-02T22:33:27 | 2011-06-02T22:33:27 | 32,140,837 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,158 | cpp | /*
* ################################################################################
* ### MIT License
* ################################################################################
*
* Copyright (c) 2006-2011 Andy Turner
*
* 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 "AlignParametric/ParticleSurface.h"
#include "Mesh/TuplesImpl.h"
#include "Mesh/MeshFunctions.h"
#include "Mesh/TuplesFunctions.h"
#include "MeshSearching/FacesNearestPointSearch.h"
#include "Useful/Noise.h"
#include "Useful/ColouredConsole.h"
#include <vector>
#include <algorithm>
#include "vnl/vnl_matrix_fixed.h"
#include "Useful/ArrayVectorFunctions.h"
using namespace AWT;
using namespace AWT::AlignParametric;
AWT::AlignParametric::ParticleSurface::ParticleSurface(MeshType::P mesh, const TuplesType::P samples, const Idx _ntake)
{
// Keep a hold of the mesh
this->mesh = mesh;
calculateFaceNormals();
const Idx ntake = std::min<Idx>(_ntake, samples->getNumberOfPoints());
DEBUGMACRO("Only taking " << ntake);
// Take just the first 10 samples
this->samples = TuplesImpl<T>::getInstance(3, ntake);
for (Idx i = 0; i < ntake; ++i)
{
T vtx[3];
samples->getPoint(i, vtx);
this->samples->setPoint(i, vtx);
}
// Calculate the 5th-%ile triangle area, use this to avoid truncation error
std::vector<T> areas;
MESH_EACHFACE(mesh, f)
areas.push_back(MeshFunctions<T>::getFaceArea(mesh, f));
sort(areas.begin(), areas.end());
maxMove = sqrt(areas[ areas.size() * 5 / 100 ]) / 2;
PRINTVBL(maxMove);
}
void AWT::AlignParametric::ParticleSurface::initialize()
{
DEBUGLINE;
setPointLocationsInitial();
}
AWT::AlignParametric::ParticleSurface::~ParticleSurface()
{
}
// Get the number of parameter components describing each sample
Idx AWT::AlignParametric::ParticleSurface::getParameterDimensionality() const
{
return 3;
}
// Get the number of samples on the surface
Idx AWT::AlignParametric::ParticleSurface::getNumberOfSamples() const
{
return samples->getNumberOfPoints();
}
// Get the current sample locations
// NOTE: This should be in HOMOGENEOUS form, i.e. samples.rows() = Dims + 1
// The last row should be all ones, or weird things will happen...
void AWT::AlignParametric::ParticleSurface::getSamples(MatrixType& samples) const
{
if (samples.rows() != 4 || samples.cols() != getNumberOfSamples())
samples.set_size(4, getNumberOfSamples());
T vtx[4];
for (Idx i = 0, imax = getNumberOfSamples(); i < imax; ++i)
{
this->samples->getPoint(i, vtx);
vtx[3] = 1;
samples.set_column(i, vtx);
}
}
T AWT::AlignParametric::ParticleSurface::getMaxMove() const
{
return maxMove;
}
// Get the number of parameters which control this sampling
Idx AWT::AlignParametric::ParticleSurface::getNumberOfParameters() const
{
return samples->getNumberOfPoints();
}
// Get the current set of control values
void AWT::AlignParametric::ParticleSurface::getParameters(MatrixType& controls) const
{
if (controls.rows() != getNumberOfParameters() || controls.cols() != 3)
controls.set_size(getNumberOfParameters(), 3);
T vtx[3];
for (Idx i = 0, imax = getNumberOfParameters(); i < imax; ++i)
{
samples->getPoint(i,vtx);
controls.set_row(i, vtx);
}
}
void AWT::AlignParametric::ParticleSurface::jacobian(const Idx l, const Idx p, MatrixType& matrix) const
{
// Nice and easy Jacobian...
if (l == p)
{
matrix.set_identity();
return;
T nml[3];
faceNormals->getPoint(particleFace[l], nml);
for (Idx r = 0; r < 3; ++r)
for (Idx c = 0; c < 3; ++c)
matrix(r,c) -= nml[r]*nml[c];
}
else
{
matrix.fill(0);
}
}
void AWT::AlignParametric::ParticleSurface::splitParticle(const Idx p, const T* theShift)
{
ColouredConsole cons(ColouredConsole::COL_YELLOW);
FacesNearestPointSearch<T>::P searcher = FacesNearestPointSearch<T>::getInstance();
T vtx[4];
const T mults[] = { -0.5, 0.5 };
const Idx idxs[] = { p, samples->getNumberOfPoints() };
// Push back a face into the list (will be overwritten soon enough)
particleFace.push_back(INVALID_INDEX);
for (Idx i = 0; i < 2; ++i)
{
// Get the sample location
samples->getPoint(p, vtx);
FOREACHAXIS(ax)
vtx[ax] += mults[i]*theShift[ax];
vtx[3] = 1;
updatePointLocation(idxs[i], vtx, searcher);
samples->getPoint(idxs[i], vtx);
//PRINTVBL(idxs[i]);
//PRINTVEC(vtx, 4);
}
modified();
}
void AWT::AlignParametric::ParticleSurface::refine()
{
}
// Iterator functions - allows you to skip all the zero jacobians
// Takes the internal iterPtr back to the start
void AWT::AlignParametric::ParticleSurface::resetIterator()
{
iterPtr = 0;
}
// Advances to the next non-zero jacobian pair
bool AWT::AlignParametric::ParticleSurface::next(Idx& l, Idx& p)
{
bool ret = iterPtr < samples->getNumberOfPoints();
if (ret)
l = p = iterPtr++;
else
l = p = INVALID_INDEX;
return ret;
}
MeshType::P AWT::AlignParametric::ParticleSurface::getMesh()
{
return mesh;
}
TuplesType::P AWT::AlignParametric::ParticleSurface::getSamples()
{
return samples;
}
// Projects the point to the closest point on the mesh surface
int AWT::AlignParametric::ParticleSurface::updatePointLocation(const Idx i, const T* vtx, FacesNearestPointSearch<T>::P searcher)
{
searcher->reset();
searcher->setTestPoint(vtx);
mesh->searchFaces(searcher);
T vtxNearest[3];
int np = searcher->getNearestPoint(vtxNearest);
particleFace[i] = np;
samples->setPoint(i, vtxNearest);
return np;
}
void AWT::AlignParametric::ParticleSurface::calculateFaceNormals()
{
T vtx[3][3];
faceNormals = TuplesImpl<T>::getInstance(3, mesh->getNumberOfFaces());
MESH_EACHFACE(mesh, f)
{
mesh->getFace(f, vtx[0], vtx[1], vtx[2]);
FOREACHAXIS(ax)
{
vtx[2][ax] -= vtx[0][ax];
vtx[1][ax] -= vtx[0][ax];
}
cross<T>(vtx[1], vtx[2], vtx[0]);
normalize<T>(vtx[0], 3);
faceNormals->setPoint(f, vtx[0]);
}
}
void AWT::AlignParametric::ParticleSurface::setPointLocationsInitial()
{
FacesNearestPointSearch<T>::P searcher = FacesNearestPointSearch<T>::getInstance();
T vtx[4];
// Make sure that the list of particleFaces is allocated
particleFace.clear();
for (Idx i = 0, imax = samples->getNumberOfPoints(); i < imax; ++i)
{
// Get the sample location
samples->getPoint(i, vtx);
vtx[3] = 1;
// Push back a face into the list (will be overwritten soon enough)
particleFace.push_back(INVALID_INDEX);
updatePointLocation(i, vtx, searcher);
}
}
void AWT::AlignParametric::ParticleSurface::setParameters(MatrixType& controls)
{
FacesNearestPointSearch<T>::P searcher = FacesNearestPointSearch<T>::getInstance();
T vtx[3];
for (Idx i = 0, imax = samples->getNumberOfPoints(); i < imax; ++i)
{
vtx[0] = controls(i,0);
vtx[1] = controls(i,1);
vtx[2] = controls(i,2);
updatePointLocation(i, vtx, searcher);
}
} | [
"[email protected]@8ccf9804-531a-5bdb-f4a8-09d094668cd7"
] | [email protected]@8ccf9804-531a-5bdb-f4a8-09d094668cd7 |
Subsets and Splits