hexsha
stringlengths 40
40
| size
int64 7
1.05M
| ext
stringclasses 13
values | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 4
269
| max_stars_repo_name
stringlengths 5
109
| max_stars_repo_head_hexsha
stringlengths 40
40
| max_stars_repo_licenses
listlengths 1
9
| max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 4
269
| max_issues_repo_name
stringlengths 5
116
| max_issues_repo_head_hexsha
stringlengths 40
40
| max_issues_repo_licenses
listlengths 1
9
| max_issues_count
int64 1
48.5k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 4
269
| max_forks_repo_name
stringlengths 5
116
| max_forks_repo_head_hexsha
stringlengths 40
40
| max_forks_repo_licenses
listlengths 1
9
| max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 7
1.05M
| avg_line_length
float64 1.21
330k
| max_line_length
int64 6
990k
| alphanum_fraction
float64 0.01
0.99
| author_id
stringlengths 2
40
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2017699eeb176419aca9a82faff09c4c27796912
| 38,496 |
cpp
|
C++
|
build/linux-build/Sources/src/zpp_nape/util/ZNPList_ZPP_CutVert.cpp
|
HedgehogFog/TimeOfDeath
|
b78abacf940e1a88c8b987d99764ebb6876c5dc6
|
[
"MIT"
] | null | null | null |
build/linux-build/Sources/src/zpp_nape/util/ZNPList_ZPP_CutVert.cpp
|
HedgehogFog/TimeOfDeath
|
b78abacf940e1a88c8b987d99764ebb6876c5dc6
|
[
"MIT"
] | null | null | null |
build/linux-build/Sources/src/zpp_nape/util/ZNPList_ZPP_CutVert.cpp
|
HedgehogFog/TimeOfDeath
|
b78abacf940e1a88c8b987d99764ebb6876c5dc6
|
[
"MIT"
] | null | null | null |
// Generated by Haxe 4.0.0-preview.5
#include <hxcpp.h>
#ifndef INCLUDED_zpp_nape_geom_ZPP_CutVert
#include <hxinc/zpp_nape/geom/ZPP_CutVert.h>
#endif
#ifndef INCLUDED_zpp_nape_util_ZNPList_ZPP_CutVert
#include <hxinc/zpp_nape/util/ZNPList_ZPP_CutVert.h>
#endif
#ifndef INCLUDED_zpp_nape_util_ZNPNode_ZPP_CutVert
#include <hxinc/zpp_nape/util/ZNPNode_ZPP_CutVert.h>
#endif
HX_DEFINE_STACK_FRAME(_hx_pos_378a7638927e1295_6013_new,"zpp_nape.util.ZNPList_ZPP_CutVert","new",0x362d64b0,"zpp_nape.util.ZNPList_ZPP_CutVert.new","zpp_nape/util/Lists.hx",6013,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6019_begin,"zpp_nape.util.ZNPList_ZPP_CutVert","begin",0x3ef93279,"zpp_nape.util.ZNPList_ZPP_CutVert.begin","zpp_nape/util/Lists.hx",6019,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6026_setbegin,"zpp_nape.util.ZNPList_ZPP_CutVert","setbegin",0xf0d7acf7,"zpp_nape.util.ZNPList_ZPP_CutVert.setbegin","zpp_nape/util/Lists.hx",6026,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6032_add,"zpp_nape.util.ZNPList_ZPP_CutVert","add",0x36238671,"zpp_nape.util.ZNPList_ZPP_CutVert.add","zpp_nape/util/Lists.hx",6032,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6036_inlined_add,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_add",0xb52cb0dd,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_add","zpp_nape/util/Lists.hx",6036,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6082_addAll,"zpp_nape.util.ZNPList_ZPP_CutVert","addAll",0xdf370730,"zpp_nape.util.ZNPList_ZPP_CutVert.addAll","zpp_nape/util/Lists.hx",6082,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6092_insert,"zpp_nape.util.ZNPList_ZPP_CutVert","insert",0xde1940e9,"zpp_nape.util.ZNPList_ZPP_CutVert.insert","zpp_nape/util/Lists.hx",6092,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6096_inlined_insert,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_insert",0xb50961fd,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_insert","zpp_nape/util/Lists.hx",6096,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6140_pop,"zpp_nape.util.ZNPList_ZPP_CutVert","pop",0x362ef1e1,"zpp_nape.util.ZNPList_ZPP_CutVert.pop","zpp_nape/util/Lists.hx",6140,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6144_inlined_pop,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_pop",0xb5381c4d,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_pop","zpp_nape/util/Lists.hx",6144,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6178_pop_unsafe,"zpp_nape.util.ZNPList_ZPP_CutVert","pop_unsafe",0xa6f11204,"zpp_nape.util.ZNPList_ZPP_CutVert.pop_unsafe","zpp_nape/util/Lists.hx",6178,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6182_inlined_pop_unsafe,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_pop_unsafe",0x73094d18,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_pop_unsafe","zpp_nape/util/Lists.hx",6182,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6204_remove,"zpp_nape.util.ZNPList_ZPP_CutVert","remove",0x44c499f4,"zpp_nape.util.ZNPList_ZPP_CutVert.remove","zpp_nape/util/Lists.hx",6204,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6206_try_remove,"zpp_nape.util.ZNPList_ZPP_CutVert","try_remove",0xbe1b47b8,"zpp_nape.util.ZNPList_ZPP_CutVert.try_remove","zpp_nape/util/Lists.hx",6206,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6240_inlined_remove,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_remove",0x1bb4bb08,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_remove","zpp_nape/util/Lists.hx",6240,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6244_inlined_try_remove,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_try_remove",0x8a3382cc,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_try_remove","zpp_nape/util/Lists.hx",6244,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6268_erase,"zpp_nape.util.ZNPList_ZPP_CutVert","erase",0x01c03136,"zpp_nape.util.ZNPList_ZPP_CutVert.erase","zpp_nape/util/Lists.hx",6268,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6272_inlined_erase,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_erase",0x3539cea2,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_erase","zpp_nape/util/Lists.hx",6272,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6318_splice,"zpp_nape.util.ZNPList_ZPP_CutVert","splice",0xffda832c,"zpp_nape.util.ZNPList_ZPP_CutVert.splice","zpp_nape/util/Lists.hx",6318,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6323_clear,"zpp_nape.util.ZNPList_ZPP_CutVert","clear",0xd6feb9dd,"zpp_nape.util.ZNPList_ZPP_CutVert.clear","zpp_nape/util/Lists.hx",6323,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6328_inlined_clear,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_clear",0x0a785749,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_clear","zpp_nape/util/Lists.hx",6328,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6333_reverse,"zpp_nape.util.ZNPList_ZPP_CutVert","reverse",0x0f3e3572,"zpp_nape.util.ZNPList_ZPP_CutVert.reverse","zpp_nape/util/Lists.hx",6333,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6349_empty,"zpp_nape.util.ZNPList_ZPP_CutVert","empty",0xfe7d82dd,"zpp_nape.util.ZNPList_ZPP_CutVert.empty","zpp_nape/util/Lists.hx",6349,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6354_size,"zpp_nape.util.ZNPList_ZPP_CutVert","size",0x34dbd271,"zpp_nape.util.ZNPList_ZPP_CutVert.size","zpp_nape/util/Lists.hx",6354,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6357_has,"zpp_nape.util.ZNPList_ZPP_CutVert","has",0x3628d3aa,"zpp_nape.util.ZNPList_ZPP_CutVert.has","zpp_nape/util/Lists.hx",6357,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6361_inlined_has,"zpp_nape.util.ZNPList_ZPP_CutVert","inlined_has",0xb531fe16,"zpp_nape.util.ZNPList_ZPP_CutVert.inlined_has","zpp_nape/util/Lists.hx",6361,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6392_front,"zpp_nape.util.ZNPList_ZPP_CutVert","front",0x953160f9,"zpp_nape.util.ZNPList_ZPP_CutVert.front","zpp_nape/util/Lists.hx",6392,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6394_back,"zpp_nape.util.ZNPList_ZPP_CutVert","back",0x29990bd7,"zpp_nape.util.ZNPList_ZPP_CutVert.back","zpp_nape/util/Lists.hx",6394,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6403_iterator_at,"zpp_nape.util.ZNPList_ZPP_CutVert","iterator_at",0xb9d0ee34,"zpp_nape.util.ZNPList_ZPP_CutVert.iterator_at","zpp_nape/util/Lists.hx",6403,0x9f4e6754)
HX_LOCAL_STACK_FRAME(_hx_pos_378a7638927e1295_6416_at,"zpp_nape.util.ZNPList_ZPP_CutVert","at",0xb59fbaa3,"zpp_nape.util.ZNPList_ZPP_CutVert.at","zpp_nape/util/Lists.hx",6416,0x9f4e6754)
namespace zpp_nape{
namespace util{
void ZNPList_ZPP_CutVert_obj::__construct(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6013_new)
HXLINE(6023) this->length = 0;
HXLINE(6022) this->pushmod = false;
HXLINE(6021) this->modified = false;
HXLINE(6014) this->head = null();
}
Dynamic ZNPList_ZPP_CutVert_obj::__CreateEmpty() { return new ZNPList_ZPP_CutVert_obj; }
void *ZNPList_ZPP_CutVert_obj::_hx_vtable = 0;
Dynamic ZNPList_ZPP_CutVert_obj::__Create(hx::DynamicArray inArgs)
{
hx::ObjectPtr< ZNPList_ZPP_CutVert_obj > _hx_result = new ZNPList_ZPP_CutVert_obj();
_hx_result->__construct();
return _hx_result;
}
bool ZNPList_ZPP_CutVert_obj::_hx_isInstanceOf(int inClassId) {
return inClassId==(int)0x00000001 || inClassId==(int)0x1d171732;
}
::zpp_nape::util::ZNPNode_ZPP_CutVert ZNPList_ZPP_CutVert_obj::begin(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6019_begin)
HXDLIN(6019) return this->head;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,begin,return )
void ZNPList_ZPP_CutVert_obj::setbegin( ::zpp_nape::util::ZNPNode_ZPP_CutVert i){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6026_setbegin)
HXLINE(6027) this->head = i;
HXLINE(6028) this->modified = true;
HXLINE(6029) this->pushmod = true;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,setbegin,(void))
::zpp_nape::geom::ZPP_CutVert ZNPList_ZPP_CutVert_obj::add( ::zpp_nape::geom::ZPP_CutVert o){
HX_GC_STACKFRAME(&_hx_pos_378a7638927e1295_6032_add)
HXDLIN(6032) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret;
HXDLIN(6032) if (hx::IsNull( ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool )) {
HXDLIN(6032) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::__alloc( HX_CTX );
}
else {
HXDLIN(6032) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6032) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = ret->next;
HXDLIN(6032) ret->next = null();
}
HXDLIN(6032) ret->elt = o;
HXDLIN(6032) ::zpp_nape::util::ZNPNode_ZPP_CutVert temp = ret;
HXDLIN(6032) temp->next = this->head;
HXDLIN(6032) this->head = temp;
HXDLIN(6032) this->modified = true;
HXDLIN(6032) this->length++;
HXDLIN(6032) return o;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,add,return )
::zpp_nape::geom::ZPP_CutVert ZNPList_ZPP_CutVert_obj::inlined_add( ::zpp_nape::geom::ZPP_CutVert o){
HX_GC_STACKFRAME(&_hx_pos_378a7638927e1295_6036_inlined_add)
HXLINE(6046) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret;
HXLINE(6048) if (hx::IsNull( ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool )) {
HXLINE(6049) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::__alloc( HX_CTX );
}
else {
HXLINE(6055) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXLINE(6056) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = ret->next;
HXLINE(6057) ret->next = null();
}
HXLINE(6064) ret->elt = o;
HXLINE(6045) ::zpp_nape::util::ZNPNode_ZPP_CutVert temp = ret;
HXLINE(6067) temp->next = this->head;
HXLINE(6068) this->head = temp;
HXLINE(6069) this->modified = true;
HXLINE(6070) this->length++;
HXLINE(6071) return o;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,inlined_add,return )
void ZNPList_ZPP_CutVert_obj::addAll( ::zpp_nape::util::ZNPList_ZPP_CutVert x){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6082_addAll)
HXLINE(6083) ::zpp_nape::util::ZNPNode_ZPP_CutVert cx_ite = x->head;
HXLINE(6084) while(hx::IsNotNull( cx_ite )){
HXLINE(6085) ::zpp_nape::geom::ZPP_CutVert i = cx_ite->elt;
HXLINE(6086) this->add(i);
HXLINE(6087) cx_ite = cx_ite->next;
}
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,addAll,(void))
::zpp_nape::util::ZNPNode_ZPP_CutVert ZNPList_ZPP_CutVert_obj::insert( ::zpp_nape::util::ZNPNode_ZPP_CutVert cur, ::zpp_nape::geom::ZPP_CutVert o){
HX_GC_STACKFRAME(&_hx_pos_378a7638927e1295_6092_insert)
HXDLIN(6092) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret;
HXDLIN(6092) if (hx::IsNull( ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool )) {
HXDLIN(6092) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::__alloc( HX_CTX );
}
else {
HXDLIN(6092) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6092) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = ret->next;
HXDLIN(6092) ret->next = null();
}
HXDLIN(6092) ret->elt = o;
HXDLIN(6092) ::zpp_nape::util::ZNPNode_ZPP_CutVert temp = ret;
HXDLIN(6092) if (hx::IsNull( cur )) {
HXDLIN(6092) temp->next = this->head;
HXDLIN(6092) this->head = temp;
}
else {
HXDLIN(6092) temp->next = cur->next;
HXDLIN(6092) cur->next = temp;
}
HXDLIN(6092) this->pushmod = (this->modified = true);
HXDLIN(6092) this->length++;
HXDLIN(6092) return temp;
}
HX_DEFINE_DYNAMIC_FUNC2(ZNPList_ZPP_CutVert_obj,insert,return )
::zpp_nape::util::ZNPNode_ZPP_CutVert ZNPList_ZPP_CutVert_obj::inlined_insert( ::zpp_nape::util::ZNPNode_ZPP_CutVert cur, ::zpp_nape::geom::ZPP_CutVert o){
HX_GC_STACKFRAME(&_hx_pos_378a7638927e1295_6096_inlined_insert)
HXLINE(6106) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret;
HXLINE(6108) if (hx::IsNull( ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool )) {
HXLINE(6109) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::__alloc( HX_CTX );
}
else {
HXLINE(6115) ret = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXLINE(6116) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = ret->next;
HXLINE(6117) ret->next = null();
}
HXLINE(6124) ret->elt = o;
HXLINE(6105) ::zpp_nape::util::ZNPNode_ZPP_CutVert temp = ret;
HXLINE(6127) if (hx::IsNull( cur )) {
HXLINE(6128) temp->next = this->head;
HXLINE(6129) this->head = temp;
}
else {
HXLINE(6132) temp->next = cur->next;
HXLINE(6133) cur->next = temp;
}
HXLINE(6135) this->pushmod = (this->modified = true);
HXLINE(6136) this->length++;
HXLINE(6137) return temp;
}
HX_DEFINE_DYNAMIC_FUNC2(ZNPList_ZPP_CutVert_obj,inlined_insert,return )
void ZNPList_ZPP_CutVert_obj::pop(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6140_pop)
HXDLIN(6140) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret = this->head;
HXDLIN(6140) this->head = ret->next;
HXDLIN(6140) {
HXDLIN(6140) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = ret;
HXDLIN(6140) o->elt = null();
HXDLIN(6140) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6140) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXDLIN(6140) if (hx::IsNull( this->head )) {
HXDLIN(6140) this->pushmod = true;
}
HXDLIN(6140) this->modified = true;
HXDLIN(6140) this->length--;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,pop,(void))
void ZNPList_ZPP_CutVert_obj::inlined_pop(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6144_inlined_pop)
HXLINE(6153) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret = this->head;
HXLINE(6154) this->head = ret->next;
HXLINE(6156) {
HXLINE(6157) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = ret;
HXLINE(6166) o->elt = null();
HXLINE(6167) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXLINE(6168) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXLINE(6173) if (hx::IsNull( this->head )) {
HXLINE(6173) this->pushmod = true;
}
HXLINE(6174) this->modified = true;
HXLINE(6175) this->length--;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,inlined_pop,(void))
::zpp_nape::geom::ZPP_CutVert ZNPList_ZPP_CutVert_obj::pop_unsafe(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6178_pop_unsafe)
HXDLIN(6178) ::zpp_nape::geom::ZPP_CutVert ret = this->head->elt;
HXDLIN(6178) this->pop();
HXDLIN(6178) return ret;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,pop_unsafe,return )
::zpp_nape::geom::ZPP_CutVert ZNPList_ZPP_CutVert_obj::inlined_pop_unsafe(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6182_inlined_pop_unsafe)
HXLINE(6191) ::zpp_nape::geom::ZPP_CutVert ret = this->head->elt;
HXLINE(6192) this->pop();
HXLINE(6193) return ret;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,inlined_pop_unsafe,return )
void ZNPList_ZPP_CutVert_obj::remove( ::zpp_nape::geom::ZPP_CutVert obj){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6204_remove)
HXDLIN(6204) ::zpp_nape::util::ZNPNode_ZPP_CutVert pre = null();
HXDLIN(6204) ::zpp_nape::util::ZNPNode_ZPP_CutVert cur = this->head;
HXDLIN(6204) bool ret = false;
HXDLIN(6204) while(hx::IsNotNull( cur )){
HXDLIN(6204) if (hx::IsEq( cur->elt,obj )) {
HXDLIN(6204) {
HXDLIN(6204) ::zpp_nape::util::ZNPNode_ZPP_CutVert old;
HXDLIN(6204) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret1;
HXDLIN(6204) if (hx::IsNull( pre )) {
HXDLIN(6204) old = this->head;
HXDLIN(6204) ret1 = old->next;
HXDLIN(6204) this->head = ret1;
HXDLIN(6204) if (hx::IsNull( this->head )) {
HXDLIN(6204) this->pushmod = true;
}
}
else {
HXDLIN(6204) old = pre->next;
HXDLIN(6204) ret1 = old->next;
HXDLIN(6204) pre->next = ret1;
HXDLIN(6204) if (hx::IsNull( ret1 )) {
HXDLIN(6204) this->pushmod = true;
}
}
HXDLIN(6204) {
HXDLIN(6204) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = old;
HXDLIN(6204) o->elt = null();
HXDLIN(6204) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6204) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXDLIN(6204) this->modified = true;
HXDLIN(6204) this->length--;
HXDLIN(6204) this->pushmod = true;
}
HXDLIN(6204) ret = true;
HXDLIN(6204) goto _hx_goto_13;
}
HXDLIN(6204) pre = cur;
HXDLIN(6204) cur = cur->next;
}
_hx_goto_13:;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,remove,(void))
bool ZNPList_ZPP_CutVert_obj::try_remove( ::zpp_nape::geom::ZPP_CutVert obj){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6206_try_remove)
HXLINE(6215) ::zpp_nape::util::ZNPNode_ZPP_CutVert pre = null();
HXLINE(6216) ::zpp_nape::util::ZNPNode_ZPP_CutVert cur = this->head;
HXLINE(6217) bool ret = false;
HXLINE(6218) while(hx::IsNotNull( cur )){
HXLINE(6219) if (hx::IsEq( cur->elt,obj )) {
HXLINE(6220) this->erase(pre);
HXLINE(6221) ret = true;
HXLINE(6222) goto _hx_goto_15;
}
HXLINE(6224) pre = cur;
HXLINE(6225) cur = cur->next;
}
_hx_goto_15:;
HXLINE(6227) return ret;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,try_remove,return )
void ZNPList_ZPP_CutVert_obj::inlined_remove( ::zpp_nape::geom::ZPP_CutVert obj){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6240_inlined_remove)
HXDLIN(6240) ::zpp_nape::util::ZNPNode_ZPP_CutVert pre = null();
HXDLIN(6240) ::zpp_nape::util::ZNPNode_ZPP_CutVert cur = this->head;
HXDLIN(6240) bool ret = false;
HXDLIN(6240) while(hx::IsNotNull( cur )){
HXDLIN(6240) if (hx::IsEq( cur->elt,obj )) {
HXDLIN(6240) {
HXDLIN(6240) ::zpp_nape::util::ZNPNode_ZPP_CutVert old;
HXDLIN(6240) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret1;
HXDLIN(6240) if (hx::IsNull( pre )) {
HXDLIN(6240) old = this->head;
HXDLIN(6240) ret1 = old->next;
HXDLIN(6240) this->head = ret1;
HXDLIN(6240) if (hx::IsNull( this->head )) {
HXDLIN(6240) this->pushmod = true;
}
}
else {
HXDLIN(6240) old = pre->next;
HXDLIN(6240) ret1 = old->next;
HXDLIN(6240) pre->next = ret1;
HXDLIN(6240) if (hx::IsNull( ret1 )) {
HXDLIN(6240) this->pushmod = true;
}
}
HXDLIN(6240) {
HXDLIN(6240) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = old;
HXDLIN(6240) o->elt = null();
HXDLIN(6240) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6240) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXDLIN(6240) this->modified = true;
HXDLIN(6240) this->length--;
HXDLIN(6240) this->pushmod = true;
}
HXDLIN(6240) ret = true;
HXDLIN(6240) goto _hx_goto_17;
}
HXDLIN(6240) pre = cur;
HXDLIN(6240) cur = cur->next;
}
_hx_goto_17:;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,inlined_remove,(void))
bool ZNPList_ZPP_CutVert_obj::inlined_try_remove( ::zpp_nape::geom::ZPP_CutVert obj){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6244_inlined_try_remove)
HXLINE(6253) ::zpp_nape::util::ZNPNode_ZPP_CutVert pre = null();
HXLINE(6254) ::zpp_nape::util::ZNPNode_ZPP_CutVert cur = this->head;
HXLINE(6255) bool ret = false;
HXLINE(6256) while(hx::IsNotNull( cur )){
HXLINE(6257) if (hx::IsEq( cur->elt,obj )) {
HXLINE(6258) {
HXLINE(6258) ::zpp_nape::util::ZNPNode_ZPP_CutVert old;
HXDLIN(6258) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret1;
HXDLIN(6258) if (hx::IsNull( pre )) {
HXLINE(6258) old = this->head;
HXDLIN(6258) ret1 = old->next;
HXDLIN(6258) this->head = ret1;
HXDLIN(6258) if (hx::IsNull( this->head )) {
HXLINE(6258) this->pushmod = true;
}
}
else {
HXLINE(6258) old = pre->next;
HXDLIN(6258) ret1 = old->next;
HXDLIN(6258) pre->next = ret1;
HXDLIN(6258) if (hx::IsNull( ret1 )) {
HXLINE(6258) this->pushmod = true;
}
}
HXDLIN(6258) {
HXLINE(6258) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = old;
HXDLIN(6258) o->elt = null();
HXDLIN(6258) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6258) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXDLIN(6258) this->modified = true;
HXDLIN(6258) this->length--;
HXDLIN(6258) this->pushmod = true;
}
HXLINE(6259) ret = true;
HXLINE(6260) goto _hx_goto_19;
}
HXLINE(6262) pre = cur;
HXLINE(6263) cur = cur->next;
}
_hx_goto_19:;
HXLINE(6265) return ret;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,inlined_try_remove,return )
::zpp_nape::util::ZNPNode_ZPP_CutVert ZNPList_ZPP_CutVert_obj::erase( ::zpp_nape::util::ZNPNode_ZPP_CutVert pre){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6268_erase)
HXDLIN(6268) ::zpp_nape::util::ZNPNode_ZPP_CutVert old;
HXDLIN(6268) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret;
HXDLIN(6268) if (hx::IsNull( pre )) {
HXDLIN(6268) old = this->head;
HXDLIN(6268) ret = old->next;
HXDLIN(6268) this->head = ret;
HXDLIN(6268) if (hx::IsNull( this->head )) {
HXDLIN(6268) this->pushmod = true;
}
}
else {
HXDLIN(6268) old = pre->next;
HXDLIN(6268) ret = old->next;
HXDLIN(6268) pre->next = ret;
HXDLIN(6268) if (hx::IsNull( ret )) {
HXDLIN(6268) this->pushmod = true;
}
}
HXDLIN(6268) {
HXDLIN(6268) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = old;
HXDLIN(6268) o->elt = null();
HXDLIN(6268) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6268) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXDLIN(6268) this->modified = true;
HXDLIN(6268) this->length--;
HXDLIN(6268) this->pushmod = true;
HXDLIN(6268) return ret;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,erase,return )
::zpp_nape::util::ZNPNode_ZPP_CutVert ZNPList_ZPP_CutVert_obj::inlined_erase( ::zpp_nape::util::ZNPNode_ZPP_CutVert pre){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6272_inlined_erase)
HXLINE(6281) ::zpp_nape::util::ZNPNode_ZPP_CutVert old;
HXLINE(6282) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret;
HXLINE(6283) if (hx::IsNull( pre )) {
HXLINE(6284) old = this->head;
HXLINE(6285) ret = old->next;
HXLINE(6286) this->head = ret;
HXLINE(6287) if (hx::IsNull( this->head )) {
HXLINE(6287) this->pushmod = true;
}
}
else {
HXLINE(6290) old = pre->next;
HXLINE(6291) ret = old->next;
HXLINE(6292) pre->next = ret;
HXLINE(6293) if (hx::IsNull( ret )) {
HXLINE(6293) this->pushmod = true;
}
}
HXLINE(6296) {
HXLINE(6297) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = old;
HXLINE(6306) o->elt = null();
HXLINE(6307) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXLINE(6308) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXLINE(6313) this->modified = true;
HXLINE(6314) this->length--;
HXLINE(6315) this->pushmod = true;
HXLINE(6316) return ret;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,inlined_erase,return )
::zpp_nape::util::ZNPNode_ZPP_CutVert ZNPList_ZPP_CutVert_obj::splice( ::zpp_nape::util::ZNPNode_ZPP_CutVert pre,int n){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6318_splice)
HXLINE(6319) while(true){
HXLINE(6319) bool _hx_tmp;
HXDLIN(6319) n = (n - 1);
HXDLIN(6319) if (((n + 1) > 0)) {
HXLINE(6319) _hx_tmp = hx::IsNotNull( pre->next );
}
else {
HXLINE(6319) _hx_tmp = false;
}
HXDLIN(6319) if (!(_hx_tmp)) {
HXLINE(6319) goto _hx_goto_23;
}
HXDLIN(6319) this->erase(pre);
}
_hx_goto_23:;
HXLINE(6320) return pre->next;
}
HX_DEFINE_DYNAMIC_FUNC2(ZNPList_ZPP_CutVert_obj,splice,return )
void ZNPList_ZPP_CutVert_obj::clear(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6323_clear)
HXDLIN(6323) while(hx::IsNotNull( this->head )){
HXDLIN(6323) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret = this->head;
HXDLIN(6323) this->head = ret->next;
HXDLIN(6323) {
HXDLIN(6323) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = ret;
HXDLIN(6323) o->elt = null();
HXDLIN(6323) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6323) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXDLIN(6323) if (hx::IsNull( this->head )) {
HXDLIN(6323) this->pushmod = true;
}
HXDLIN(6323) this->modified = true;
HXDLIN(6323) this->length--;
}
HXDLIN(6323) this->pushmod = true;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,clear,(void))
void ZNPList_ZPP_CutVert_obj::inlined_clear(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6328_inlined_clear)
HXLINE(6329) while(hx::IsNotNull( this->head )){
HXLINE(6329) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret = this->head;
HXDLIN(6329) this->head = ret->next;
HXDLIN(6329) {
HXLINE(6329) ::zpp_nape::util::ZNPNode_ZPP_CutVert o = ret;
HXDLIN(6329) o->elt = null();
HXDLIN(6329) o->next = ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool;
HXDLIN(6329) ::zpp_nape::util::ZNPNode_ZPP_CutVert_obj::zpp_pool = o;
}
HXDLIN(6329) if (hx::IsNull( this->head )) {
HXLINE(6329) this->pushmod = true;
}
HXDLIN(6329) this->modified = true;
HXDLIN(6329) this->length--;
}
HXLINE(6330) this->pushmod = true;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,inlined_clear,(void))
void ZNPList_ZPP_CutVert_obj::reverse(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6333_reverse)
HXLINE(6334) ::zpp_nape::util::ZNPNode_ZPP_CutVert cur = this->head;
HXLINE(6335) ::zpp_nape::util::ZNPNode_ZPP_CutVert pre = null();
HXLINE(6336) while(hx::IsNotNull( cur )){
HXLINE(6337) ::zpp_nape::util::ZNPNode_ZPP_CutVert nx = cur->next;
HXLINE(6338) cur->next = pre;
HXLINE(6339) this->head = cur;
HXLINE(6340) pre = cur;
HXLINE(6341) cur = nx;
}
HXLINE(6343) this->modified = true;
HXLINE(6344) this->pushmod = true;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,reverse,(void))
bool ZNPList_ZPP_CutVert_obj::empty(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6349_empty)
HXDLIN(6349) return hx::IsNull( this->head );
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,empty,return )
int ZNPList_ZPP_CutVert_obj::size(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6354_size)
HXDLIN(6354) return this->length;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,size,return )
bool ZNPList_ZPP_CutVert_obj::has( ::zpp_nape::geom::ZPP_CutVert obj){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6357_has)
HXDLIN(6357) bool ret;
HXDLIN(6357) {
HXDLIN(6357) ret = false;
HXDLIN(6357) {
HXDLIN(6357) ::zpp_nape::util::ZNPNode_ZPP_CutVert cx_ite = this->head;
HXDLIN(6357) while(hx::IsNotNull( cx_ite )){
HXDLIN(6357) ::zpp_nape::geom::ZPP_CutVert npite = cx_ite->elt;
HXDLIN(6357) if (hx::IsEq( npite,obj )) {
HXDLIN(6357) ret = true;
HXDLIN(6357) goto _hx_goto_33;
}
HXDLIN(6357) cx_ite = cx_ite->next;
}
_hx_goto_33:;
}
}
HXDLIN(6357) return ret;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,has,return )
bool ZNPList_ZPP_CutVert_obj::inlined_has( ::zpp_nape::geom::ZPP_CutVert obj){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6361_inlined_has)
HXLINE(6370) bool ret;
HXLINE(6371) {
HXLINE(6372) ret = false;
HXLINE(6373) {
HXLINE(6374) ::zpp_nape::util::ZNPNode_ZPP_CutVert cx_ite = this->head;
HXLINE(6375) while(hx::IsNotNull( cx_ite )){
HXLINE(6376) ::zpp_nape::geom::ZPP_CutVert npite = cx_ite->elt;
HXLINE(6378) if (hx::IsEq( npite,obj )) {
HXLINE(6379) ret = true;
HXLINE(6380) goto _hx_goto_35;
}
HXLINE(6383) cx_ite = cx_ite->next;
}
_hx_goto_35:;
}
}
HXLINE(6387) return ret;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,inlined_has,return )
::zpp_nape::geom::ZPP_CutVert ZNPList_ZPP_CutVert_obj::front(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6392_front)
HXDLIN(6392) return this->head->elt;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,front,return )
::zpp_nape::geom::ZPP_CutVert ZNPList_ZPP_CutVert_obj::back(){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6394_back)
HXLINE(6395) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret = this->head;
HXLINE(6396) ::zpp_nape::util::ZNPNode_ZPP_CutVert cur = ret;
HXLINE(6397) while(hx::IsNotNull( cur )){
HXLINE(6398) ret = cur;
HXLINE(6399) cur = cur->next;
}
HXLINE(6401) return ret->elt;
}
HX_DEFINE_DYNAMIC_FUNC0(ZNPList_ZPP_CutVert_obj,back,return )
::zpp_nape::util::ZNPNode_ZPP_CutVert ZNPList_ZPP_CutVert_obj::iterator_at(int ind){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6403_iterator_at)
HXLINE(6412) ::zpp_nape::util::ZNPNode_ZPP_CutVert ret = this->head;
HXLINE(6413) while(true){
HXLINE(6413) bool _hx_tmp;
HXDLIN(6413) ind = (ind - 1);
HXDLIN(6413) if (((ind + 1) > 0)) {
HXLINE(6413) _hx_tmp = hx::IsNotNull( ret );
}
else {
HXLINE(6413) _hx_tmp = false;
}
HXDLIN(6413) if (!(_hx_tmp)) {
HXLINE(6413) goto _hx_goto_40;
}
HXDLIN(6413) ret = ret->next;
}
_hx_goto_40:;
HXLINE(6414) return ret;
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,iterator_at,return )
::zpp_nape::geom::ZPP_CutVert ZNPList_ZPP_CutVert_obj::at(int ind){
HX_STACKFRAME(&_hx_pos_378a7638927e1295_6416_at)
HXLINE(6425) ::zpp_nape::util::ZNPNode_ZPP_CutVert it = this->iterator_at(ind);
HXLINE(6426) if (hx::IsNotNull( it )) {
HXLINE(6426) return it->elt;
}
else {
HXLINE(6426) return null();
}
HXDLIN(6426) return null();
}
HX_DEFINE_DYNAMIC_FUNC1(ZNPList_ZPP_CutVert_obj,at,return )
hx::ObjectPtr< ZNPList_ZPP_CutVert_obj > ZNPList_ZPP_CutVert_obj::__new() {
hx::ObjectPtr< ZNPList_ZPP_CutVert_obj > __this = new ZNPList_ZPP_CutVert_obj();
__this->__construct();
return __this;
}
hx::ObjectPtr< ZNPList_ZPP_CutVert_obj > ZNPList_ZPP_CutVert_obj::__alloc(hx::Ctx *_hx_ctx) {
ZNPList_ZPP_CutVert_obj *__this = (ZNPList_ZPP_CutVert_obj*)(hx::Ctx::alloc(_hx_ctx, sizeof(ZNPList_ZPP_CutVert_obj), true, "zpp_nape.util.ZNPList_ZPP_CutVert"));
*(void **)__this = ZNPList_ZPP_CutVert_obj::_hx_vtable;
__this->__construct();
return __this;
}
ZNPList_ZPP_CutVert_obj::ZNPList_ZPP_CutVert_obj()
{
}
void ZNPList_ZPP_CutVert_obj::__Mark(HX_MARK_PARAMS)
{
HX_MARK_BEGIN_CLASS(ZNPList_ZPP_CutVert);
HX_MARK_MEMBER_NAME(head,"head");
HX_MARK_MEMBER_NAME(modified,"modified");
HX_MARK_MEMBER_NAME(pushmod,"pushmod");
HX_MARK_MEMBER_NAME(length,"length");
HX_MARK_END_CLASS();
}
void ZNPList_ZPP_CutVert_obj::__Visit(HX_VISIT_PARAMS)
{
HX_VISIT_MEMBER_NAME(head,"head");
HX_VISIT_MEMBER_NAME(modified,"modified");
HX_VISIT_MEMBER_NAME(pushmod,"pushmod");
HX_VISIT_MEMBER_NAME(length,"length");
}
hx::Val ZNPList_ZPP_CutVert_obj::__Field(const ::String &inName,hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 2:
if (HX_FIELD_EQ(inName,"at") ) { return hx::Val( at_dyn() ); }
break;
case 3:
if (HX_FIELD_EQ(inName,"add") ) { return hx::Val( add_dyn() ); }
if (HX_FIELD_EQ(inName,"pop") ) { return hx::Val( pop_dyn() ); }
if (HX_FIELD_EQ(inName,"has") ) { return hx::Val( has_dyn() ); }
break;
case 4:
if (HX_FIELD_EQ(inName,"head") ) { return hx::Val( head ); }
if (HX_FIELD_EQ(inName,"size") ) { return hx::Val( size_dyn() ); }
if (HX_FIELD_EQ(inName,"back") ) { return hx::Val( back_dyn() ); }
break;
case 5:
if (HX_FIELD_EQ(inName,"begin") ) { return hx::Val( begin_dyn() ); }
if (HX_FIELD_EQ(inName,"erase") ) { return hx::Val( erase_dyn() ); }
if (HX_FIELD_EQ(inName,"clear") ) { return hx::Val( clear_dyn() ); }
if (HX_FIELD_EQ(inName,"empty") ) { return hx::Val( empty_dyn() ); }
if (HX_FIELD_EQ(inName,"front") ) { return hx::Val( front_dyn() ); }
break;
case 6:
if (HX_FIELD_EQ(inName,"length") ) { return hx::Val( length ); }
if (HX_FIELD_EQ(inName,"addAll") ) { return hx::Val( addAll_dyn() ); }
if (HX_FIELD_EQ(inName,"insert") ) { return hx::Val( insert_dyn() ); }
if (HX_FIELD_EQ(inName,"remove") ) { return hx::Val( remove_dyn() ); }
if (HX_FIELD_EQ(inName,"splice") ) { return hx::Val( splice_dyn() ); }
break;
case 7:
if (HX_FIELD_EQ(inName,"pushmod") ) { return hx::Val( pushmod ); }
if (HX_FIELD_EQ(inName,"reverse") ) { return hx::Val( reverse_dyn() ); }
break;
case 8:
if (HX_FIELD_EQ(inName,"modified") ) { return hx::Val( modified ); }
if (HX_FIELD_EQ(inName,"setbegin") ) { return hx::Val( setbegin_dyn() ); }
break;
case 10:
if (HX_FIELD_EQ(inName,"pop_unsafe") ) { return hx::Val( pop_unsafe_dyn() ); }
if (HX_FIELD_EQ(inName,"try_remove") ) { return hx::Val( try_remove_dyn() ); }
break;
case 11:
if (HX_FIELD_EQ(inName,"inlined_add") ) { return hx::Val( inlined_add_dyn() ); }
if (HX_FIELD_EQ(inName,"inlined_pop") ) { return hx::Val( inlined_pop_dyn() ); }
if (HX_FIELD_EQ(inName,"inlined_has") ) { return hx::Val( inlined_has_dyn() ); }
if (HX_FIELD_EQ(inName,"iterator_at") ) { return hx::Val( iterator_at_dyn() ); }
break;
case 13:
if (HX_FIELD_EQ(inName,"inlined_erase") ) { return hx::Val( inlined_erase_dyn() ); }
if (HX_FIELD_EQ(inName,"inlined_clear") ) { return hx::Val( inlined_clear_dyn() ); }
break;
case 14:
if (HX_FIELD_EQ(inName,"inlined_insert") ) { return hx::Val( inlined_insert_dyn() ); }
if (HX_FIELD_EQ(inName,"inlined_remove") ) { return hx::Val( inlined_remove_dyn() ); }
break;
case 18:
if (HX_FIELD_EQ(inName,"inlined_pop_unsafe") ) { return hx::Val( inlined_pop_unsafe_dyn() ); }
if (HX_FIELD_EQ(inName,"inlined_try_remove") ) { return hx::Val( inlined_try_remove_dyn() ); }
}
return super::__Field(inName,inCallProp);
}
hx::Val ZNPList_ZPP_CutVert_obj::__SetField(const ::String &inName,const hx::Val &inValue,hx::PropertyAccess inCallProp)
{
switch(inName.length) {
case 4:
if (HX_FIELD_EQ(inName,"head") ) { head=inValue.Cast< ::zpp_nape::util::ZNPNode_ZPP_CutVert >(); return inValue; }
break;
case 6:
if (HX_FIELD_EQ(inName,"length") ) { length=inValue.Cast< int >(); return inValue; }
break;
case 7:
if (HX_FIELD_EQ(inName,"pushmod") ) { pushmod=inValue.Cast< bool >(); return inValue; }
break;
case 8:
if (HX_FIELD_EQ(inName,"modified") ) { modified=inValue.Cast< bool >(); return inValue; }
}
return super::__SetField(inName,inValue,inCallProp);
}
void ZNPList_ZPP_CutVert_obj::__GetFields(Array< ::String> &outFields)
{
outFields->push(HX_("head",20,29,0b,45));
outFields->push(HX_("modified",49,db,c7,16));
outFields->push(HX_("pushmod",28,29,4b,75));
outFields->push(HX_("length",e6,94,07,9f));
super::__GetFields(outFields);
};
#ifdef HXCPP_SCRIPTABLE
static hx::StorageInfo ZNPList_ZPP_CutVert_obj_sMemberStorageInfo[] = {
{hx::fsObject /* ::zpp_nape::util::ZNPNode_ZPP_CutVert */ ,(int)offsetof(ZNPList_ZPP_CutVert_obj,head),HX_("head",20,29,0b,45)},
{hx::fsBool,(int)offsetof(ZNPList_ZPP_CutVert_obj,modified),HX_("modified",49,db,c7,16)},
{hx::fsBool,(int)offsetof(ZNPList_ZPP_CutVert_obj,pushmod),HX_("pushmod",28,29,4b,75)},
{hx::fsInt,(int)offsetof(ZNPList_ZPP_CutVert_obj,length),HX_("length",e6,94,07,9f)},
{ hx::fsUnknown, 0, null()}
};
static hx::StaticInfo *ZNPList_ZPP_CutVert_obj_sStaticStorageInfo = 0;
#endif
static ::String ZNPList_ZPP_CutVert_obj_sMemberFields[] = {
HX_("head",20,29,0b,45),
HX_("begin",29,ea,55,b0),
HX_("modified",49,db,c7,16),
HX_("pushmod",28,29,4b,75),
HX_("length",e6,94,07,9f),
HX_("setbegin",47,e3,5c,2b),
HX_("add",21,f2,49,00),
HX_("inlined_add",8d,4c,2e,02),
HX_("addAll",80,09,fb,9e),
HX_("insert",39,43,dd,9d),
HX_("inlined_insert",4d,34,10,a7),
HX_("pop",91,5d,55,00),
HX_("inlined_pop",fd,b7,39,02),
HX_("pop_unsafe",54,7c,ec,75),
HX_("inlined_pop_unsafe",68,87,ef,15),
HX_("remove",44,9c,88,04),
HX_("try_remove",08,b2,16,8d),
HX_("inlined_remove",58,8d,bb,0d),
HX_("inlined_try_remove",1c,bd,19,2d),
HX_("erase",e6,e8,1c,73),
HX_("inlined_erase",52,b6,9d,fa),
HX_("splice",7c,85,9e,bf),
HX_("clear",8d,71,5b,48),
HX_("inlined_clear",f9,3e,dc,cf),
HX_("reverse",22,39,fc,1a),
HX_("empty",8d,3a,da,6f),
HX_("size",c1,a0,53,4c),
HX_("has",5a,3f,4f,00),
HX_("inlined_has",c6,99,33,02),
HX_("front",a9,18,8e,06),
HX_("back",27,da,10,41),
HX_("iterator_at",e4,89,d2,06),
HX_("at",f3,54,00,00),
::String(null()) };
hx::Class ZNPList_ZPP_CutVert_obj::__mClass;
void ZNPList_ZPP_CutVert_obj::__register()
{
ZNPList_ZPP_CutVert_obj _hx_dummy;
ZNPList_ZPP_CutVert_obj::_hx_vtable = *(void **)&_hx_dummy;
hx::Static(__mClass) = new hx::Class_obj();
__mClass->mName = HX_("zpp_nape.util.ZNPList_ZPP_CutVert",be,8c,99,57);
__mClass->mSuper = &super::__SGetClass();
__mClass->mConstructEmpty = &__CreateEmpty;
__mClass->mConstructArgs = &__Create;
__mClass->mGetStaticField = &hx::Class_obj::GetNoStaticField;
__mClass->mSetStaticField = &hx::Class_obj::SetNoStaticField;
__mClass->mStatics = hx::Class_obj::dupFunctions(0 /* sStaticFields */);
__mClass->mMembers = hx::Class_obj::dupFunctions(ZNPList_ZPP_CutVert_obj_sMemberFields);
__mClass->mCanCast = hx::TCanCast< ZNPList_ZPP_CutVert_obj >;
#ifdef HXCPP_SCRIPTABLE
__mClass->mMemberStorageInfo = ZNPList_ZPP_CutVert_obj_sMemberStorageInfo;
#endif
#ifdef HXCPP_SCRIPTABLE
__mClass->mStaticStorageInfo = ZNPList_ZPP_CutVert_obj_sStaticStorageInfo;
#endif
hx::_hx_RegisterClass(__mClass->mName, __mClass);
}
} // end namespace zpp_nape
} // end namespace util
| 42.164294 | 234 | 0.699891 |
HedgehogFog
|
2017a1208d51761c56fe70dcbfeb96ec5d0085d4
| 7,961 |
hpp
|
C++
|
src/utilities/OStream/multiOStream.hpp
|
lhb8125/unstructure_frame_home_0218
|
e543850413879f120ce68d2c786002b166a62fe5
|
[
"Apache-2.0"
] | null | null | null |
src/utilities/OStream/multiOStream.hpp
|
lhb8125/unstructure_frame_home_0218
|
e543850413879f120ce68d2c786002b166a62fe5
|
[
"Apache-2.0"
] | 1 |
2020-09-10T01:17:13.000Z
|
2020-09-10T01:17:13.000Z
|
src/utilities/OStream/multiOStream.hpp
|
lhb8125/unstructure_frame_home_0218
|
e543850413879f120ce68d2c786002b166a62fe5
|
[
"Apache-2.0"
] | 2 |
2019-11-29T08:00:29.000Z
|
2019-11-29T08:26:13.000Z
|
/* Copyright (C)
* 2019 - Hu Ren, [email protected]
* 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; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
*/
/**
* @file MultiOStream.hpp
* @brief class MultiOStream will linked with multiple files, and output
* contents to those files simutaneously.
*
* @author Hu Ren, [email protected]
* @version v0.1
* @date 2019-08-13
*/
#include "OStream.hpp"
#include <stdlib.h>
#ifndef HSF_MULTIOSTREAM_HPP
#define HSF_MULTIOSTREAM_HPP
namespace HSF
{
class MultiOStream :
public OStream
{
// core file stream
vector<ostream*> files_;
// if it is redirected
vector<bool> redirected_;
// original stream buffer holder in case redirected
vector<StrBuf*> buffers_;
public:
//--------------------------------------------------------------
// construct & deconstruct
//--------------------------------------------------------------
// construct empty
MultiOStream()
:
files_(0),redirected_(0), buffers_(0)
{}
// construct from file name
MultiOStream(const string* filename, int num = 1)
:
files_(num, NULL), redirected_(num, false), buffers_(num, NULL)
{
for(int i = 0; i < num; i++)
files_[i] = new ofstream(filename[i].c_str());
}
// construct from file buffer
MultiOStream(StrBuf** rbuf, int num = 1)
:
files_(num, NULL), redirected_(num, true), buffers_(num, NULL)
{
for(int i = 0; i < num ; i++)
{
files_[i] = new ofstream();
buffers_[i] = files_[i]->rdbuf();
files_[i]->ostream::rdbuf(rbuf[i]);
}
}
// No clone or operator= (before C++11) for ostream
/*
// copy constructor
MultiOStream( const MultiOStream& ref )
:
OStream(ref), files_(0), redirected_(0), buffers_(0)
{
// copy data
size_t size = ref.getFileNum();
for(size_t i = 0; i < size; i++)
{
this->files_.push_back(ref.getRawStream(i)->clone() );
this->redirected_.push_back(ref.redirected(i) );
this->buffers_.push_back(ref.getStrBuf(i)->clone() );
}
}
// clone
virtual MultiOStream* clone() { return new MultiOStream(*this) };
// assign operator
void operator = ( const MultiOStream& ref )
{
// deconstruct the older first to close file
for(int i = 0; i < files_.size(); i++)
{
if( redirected_[i] ) files_[i]->ostream::rdbuf(buffers_[i]);
if( files_[i]->rdbuf() != cout.rdbuf() && files_[i]->rdbuf() != NULL )
((ofstream*) files_[i] )->close();
delete files_[i];
}
// clear containers
files_.resize(0);
redirected_.resize(0);
buffers_.resize(0);
// copy data
size_t size = ref.getFileNum();
for(size_t i = 0; i < size; i++)
{
this->files_.push_back(ref.getRawStream(i)->clone() );
this->redirected_.push_back(ref.redirected(i) );
this->buffers_.push_back(ref.getStrBuf(i)->clone() );
}
}
*/
// deconstruct
virtual ~MultiOStream()
{
for(int i = 0; i < files_.size(); i++)
{
if( redirected_[i] ) files_[i]->ostream::rdbuf(buffers_[i]);
if( files_[i]->rdbuf() != cout.rdbuf() && files_[i]->rdbuf() != NULL )
((ofstream*) files_[i] )->close();
delete files_[i];
}
}
//--------------------------------------------------------------
// redirecting & access
//--------------------------------------------------------------
virtual int redirect(StrBuf* rbuf, int pos = 0)
{
if(pos >= files_.size())
{
cerr<<__FILE__<<" + "<<__LINE__<<": "<<endl
<<__FUNCTION__<<": "<<endl
<<"Error: manipulation on an undefined object!"<<endl;
exit( -1 );
}
if(redirected_[pos]) files_[pos]->ostream::rdbuf(rbuf);
else
{
redirected_[pos] = true;
buffers_[pos] = files_[pos]->rdbuf();
files_[pos]->ostream::rdbuf(rbuf);
}
}
virtual int reset(int pos = 0)
{
if(pos >= files_.size())
{
cerr<<__FILE__<<" + "<<__LINE__<<": "<<endl
<<__FUNCTION__<<": "<<endl
<<"Error: manipulation on an undefined object!"<<endl;
exit( -1 );
}
if(redirected_[pos])
{
files_[pos]->ostream::rdbuf(buffers_[pos]);
redirected_[pos] = false;
}
}
virtual const ostream* getRawStream(int pos = 0) { return files_[pos]; }
virtual StrBuf* getStrBuf(int pos = 0) { return files_[pos]->rdbuf(); }
virtual bool redirected(int pos = 0) { return redirected_[pos]; }
virtual size_t getFileNum() { return files_.size(); }
// add new file
virtual int addFile(const string& filename)
{
files_.push_back(NULL);
*(files_.end() - 1 )= new ofstream(filename.c_str());
redirected_.push_back(false);
buffers_.push_back(NULL);
}
// add new buffer
virtual int addBuffer(StrBuf* buf)
{
files_.push_back(NULL);
files_[files_.size() - 1 ] = new ofstream();
redirected_.push_back(true);
buffers_.push_back(files_[files_.size() - 1 ]->rdbuf() );
files_[files_.size() - 1 ]->ostream::rdbuf(buf);
}
// erase last file
virtual int closeLast()
{
if(files_.size() > 0 )
{
int pos = files_.size() - 1;
if( redirected_[pos] ) files_[pos]->ostream::rdbuf(buffers_[pos]);
if( files_[pos]->rdbuf() != cout.rdbuf() &&
files_[pos]->rdbuf() != NULL )
((ofstream*) files_[pos] )->close();
delete files_[pos];
files_.pop_back();
buffers_.pop_back();
redirected_.pop_back();
}
else return 0;
}
//--------------------------------------------------------------
// streaming operator
//--------------------------------------------------------------
virtual MultiOStream & operator<<(char chrt)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<chrt;
return (MultiOStream &) *this;
}
virtual MultiOStream & operator<<(string str)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<str;
return (MultiOStream &) *this;
}
virtual MultiOStream & operator<<(int64_t val)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<val;
return (MultiOStream &) *this;
}
virtual MultiOStream & operator<<(int32_t val)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<val;
return (MultiOStream &) *this;
}
virtual MultiOStream & operator<<(unsigned long val)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<val;
return (MultiOStream &) *this;
}
virtual MultiOStream & operator<<(unsigned int val)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<val;
return (MultiOStream &) *this;
}
virtual MultiOStream & operator<<(double val)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<val;
return (MultiOStream &) *this;
}
virtual MultiOStream & operator<<(float val)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<val;
return (MultiOStream &) *this;
}
/**
* @brief operator<<, interface accept OsOp type parameters
* @param[in] opt, represent parameter like "ENDL" and "FLUSH".
* @return
*/
virtual MultiOStream & operator<<(OsOp opt)
{
for(int i = 0; i < files_.size(); i++ )
*(this->files_[i])<<opt;
return (MultiOStream &) *this;
}
};
}// namespace HSF
#endif // HSF_MULTIOSTREAM_HPP
| 26.273927 | 78 | 0.570908 |
lhb8125
|
201c495ed49f29a8dad3964eeaa9fbbbb834c07f
| 417 |
cpp
|
C++
|
projects/engine/src/rendering/viewport.cpp
|
zCubed3/Silica
|
c4aa6d8e204b96320ad092e324930b3ef0e26aaa
|
[
"BSD-3-Clause"
] | null | null | null |
projects/engine/src/rendering/viewport.cpp
|
zCubed3/Silica
|
c4aa6d8e204b96320ad092e324930b3ef0e26aaa
|
[
"BSD-3-Clause"
] | null | null | null |
projects/engine/src/rendering/viewport.cpp
|
zCubed3/Silica
|
c4aa6d8e204b96320ad092e324930b3ef0e26aaa
|
[
"BSD-3-Clause"
] | null | null | null |
#include "viewport.hpp"
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtx/quaternion.hpp>
#include "render_target.hpp"
namespace Manta::Rendering {
void Viewport::UpdateViewport() {
float aspect = (float)rect.width / (float)rect.height;
perspective = glm::perspective(glm::radians(fov), aspect, z_near, z_far);
eye = perspective * view;
}
}
| 26.0625 | 81 | 0.685851 |
zCubed3
|
201dce607c0f5c17539aa648b73aa59c1be9f0d9
| 270 |
hpp
|
C++
|
src/android/jni/Cube.hpp
|
ZKing1000/cordova-plugin-coventina-native
|
d704e5cfe4c4427a53b245eeb397a8c694235dfe
|
[
"Apache-2.0"
] | 1 |
2019-06-20T16:57:43.000Z
|
2019-06-20T16:57:43.000Z
|
src/android/jni/Cube.hpp
|
ZKing1000/cordova-plugin-coventina-native
|
d704e5cfe4c4427a53b245eeb397a8c694235dfe
|
[
"Apache-2.0"
] | null | null | null |
src/android/jni/Cube.hpp
|
ZKing1000/cordova-plugin-coventina-native
|
d704e5cfe4c4427a53b245eeb397a8c694235dfe
|
[
"Apache-2.0"
] | null | null | null |
// vim: sw=4 expandtab
#ifndef CUBE_HPP_
#define CUBE_HPP_
#include "MeshItem.hpp"
#include <glm/vec3.hpp>
#include <cstdint>
namespace game
{
class Cube : public MeshItem
{
public:
static void genGraphics();
void draw();
};
}
#endif
| 12.857143 | 34 | 0.62963 |
ZKing1000
|
2021c46c575e7a0155786e48ce2decf3cc4ad868
| 12,855 |
hpp
|
C++
|
SDK/ARKSurvivalEvolved_Deinonychus_AnimBP_parameters.hpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 10 |
2020-02-17T19:08:46.000Z
|
2021-07-31T11:07:19.000Z
|
SDK/ARKSurvivalEvolved_Deinonychus_AnimBP_parameters.hpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 9 |
2020-02-17T18:15:41.000Z
|
2021-06-06T19:17:34.000Z
|
SDK/ARKSurvivalEvolved_Deinonychus_AnimBP_parameters.hpp
|
2bite/ARK-SDK
|
c38ca9925309516b2093ad8c3a70ed9489e1d573
|
[
"MIT"
] | 3 |
2020-07-22T17:42:07.000Z
|
2021-06-19T17:16:13.000Z
|
#pragma once
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_Deinonychus_AnimBP_classes.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.BlueprintPlayAnimationEvent
struct UDeinonychus_AnimBP_C_BlueprintPlayAnimationEvent_Params
{
class UAnimMontage** AnimationMontage; // (Parm, ZeroConstructor, IsPlainOldData)
float* PlayRate; // (Parm, ZeroConstructor, IsPlainOldData)
float playedAnimLength; // (Parm, OutParm, ZeroConstructor, IsPlainOldData)
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7418
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7418_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5892
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5892_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7417
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7417_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ModifyBone_1048
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ModifyBone_1048_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5891
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5891_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5890
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5890_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5889
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5889_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5888
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5888_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7416
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7416_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7415
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7415_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5887
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5887_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5886
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5886_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7412
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7412_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7411
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7411_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5885
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5885_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5884
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5884_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7410
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7410_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7409
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7409_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5883
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5883_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5882
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5882_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5881
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5881_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ModifyBone_1047
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ModifyBone_1047_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5880
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5880_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5879
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5879_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5878
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5878_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_GroundBones_334
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_GroundBones_334_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_GroundBones_333
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_GroundBones_333_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ApplyAdditive_578
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ApplyAdditive_578_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5877
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5877_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_RotationOffsetBlendSpace_362
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_RotationOffsetBlendSpace_362_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_TwoWayBlend_114
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_TwoWayBlend_114_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7404
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7404_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_TwoWayBlend_113
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_TwoWayBlend_113_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7403
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7403_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5876
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5876_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7402
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7402_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5875
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_BlendListByBool_5875_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7401
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_SequencePlayer_7401_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ApplyAdditive_577
struct UDeinonychus_AnimBP_C_EvaluateGraphExposedInputs_ExecuteUbergraph_Deinonychus_AnimBP_AnimGraphNode_ApplyAdditive_577_Params
{
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.BlueprintUpdateAnimation
struct UDeinonychus_AnimBP_C_BlueprintUpdateAnimation_Params
{
float* DeltaTimeX; // (Parm, ZeroConstructor, IsPlainOldData)
};
// Function Deinonychus_AnimBP.Deinonychus_AnimBP_C.ExecuteUbergraph_Deinonychus_AnimBP
struct UDeinonychus_AnimBP_C_ExecuteUbergraph_Deinonychus_AnimBP_Params
{
int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 54.240506 | 161 | 0.894982 |
2bite
|
202204da367db1c8429deed9c79627e93bc34540
| 6,663 |
cpp
|
C++
|
Development-Delivery/Motor2D/j1Scene.cpp
|
MarcArizaAlborni/Development_Plataformas
|
44815d8581738977d20cb1be2b0481adef53c8d1
|
[
"Unlicense"
] | null | null | null |
Development-Delivery/Motor2D/j1Scene.cpp
|
MarcArizaAlborni/Development_Plataformas
|
44815d8581738977d20cb1be2b0481adef53c8d1
|
[
"Unlicense"
] | null | null | null |
Development-Delivery/Motor2D/j1Scene.cpp
|
MarcArizaAlborni/Development_Plataformas
|
44815d8581738977d20cb1be2b0481adef53c8d1
|
[
"Unlicense"
] | null | null | null |
#include "p2Defs.h"
#include "p2Log.h"
#include "j1App.h"
#include "j1Input.h"
#include "j1Textures.h"
#include "j1Audio.h"
#include "j1Render.h"
#include "j1Window.h"
#include "j1Map.h"
#include "j1Scene.h"
#include "j1FadeToBlack.h"
#include "j1Pathfinding.h"
#include "j1EntityManager.h"
#include "j1Player.h"
#include "j1Skeleton.h"
#include "j1SceneUI.h"
#include "Brofiler/Brofiler.h"
j1Scene::j1Scene() : j1Module()
{
name.create("scene");
debug_path = false;
}
// Destructor
j1Scene::~j1Scene()
{}
// Called before render is available
bool j1Scene::Awake(pugi::xml_node& config)
{
LOG("Loading Scene");
bool ret = true;
pugi::xml_node spawn = config.child("spawn");
Skeleton1.x = spawn.child("Skeleton1").attribute("x").as_int();
Skeleton1.y = spawn.child("Skeleton1").attribute("y").as_int();
Skeleton2.x = spawn.child("Skeleton2").attribute("x").as_int();
Skeleton2.y = spawn.child("Skeleton2").attribute("y").as_int();
Skeleton3.x = spawn.child("Skeleton3").attribute("x").as_int();
Skeleton3.y = spawn.child("Skeleton3").attribute("y").as_int();
Skull1.x = spawn.child("Skull1").attribute("x").as_int();
Skull1.y = spawn.child("Skull1").attribute("y").as_int();
Bee1.x = spawn.child("Bee1").attribute("x").as_int();
Bee1.y = spawn.child("Bee1").attribute("y").as_int();
MapItem1.x = spawn.child("Map1").attribute("x").as_int();
MapItem1.y = spawn.child("Map1").attribute("y").as_int();
MapItem2.x = spawn.child("Map2").attribute("x").as_int();
MapItem2.y = spawn.child("Map2").attribute("y").as_int();
MapItem3.x = spawn.child("Map3").attribute("x").as_int();
MapItem3.y = spawn.child("Map3").attribute("y").as_int();
MapItem4.x = spawn.child("Map4").attribute("x").as_int();
MapItem4.y = spawn.child("Map4").attribute("y").as_int();
IngameMenuOFFb = false;
IngameMenuONb = false;
return ret;
}
// Called before the first frame
bool j1Scene::Start()
{
BROFILER_CATEGORY("Scene Start();", Profiler::Color::SkyBlue)
if (App->map->Load("SimpleLevel1.tmx") == true)
{
StartMap1();
//CREEM UN BOO, QUE DETECTI QUIN NIVELL S'HA CARREGAT I DESPRES CREI ELS OBJECTES QUE SIGUIN D'AQUELL MAPA
}
debug_tex = App->tex->Load("maps/rosa.png");
App->audio->PlayMusic(App->map->data.MusicAudio_Files.GetString());
/*if (App->map->Load("SimpleLevel2.tmx") == true) {
StartMap2();
}*/
return true;
}
// Called each loop iteration
bool j1Scene::PreUpdate()
{
BROFILER_CATEGORY("Scene PreUpdate();", Profiler::Color::Brown)
return true;
}
// Called each loop iteration
bool j1Scene::Update(float dt)
{
//OPEN CLOSE INGAME MENU
if (App->input->GetKey(SDL_SCANCODE_ESCAPE) == KEY_DOWN && App->scene_ui->OnMainMenu!=true && App->scene_ui->OnSettingsMenu!=true && App->scene_ui->OnCreditsMenu!=true) {
if (App->scene_ui->OnIngameMenu == false) {
App->scene_ui->IngameMenuON();
App->scene_ui->OnIngameMenu = true;
if (App->scene_ui->bMuteIngameOFF == true) {
App->scene_ui->MuteIngameOFF();
App->scene_ui->UnMuteIngameON();
}
else {
App->scene_ui->MuteIngameON();
App->scene_ui->UnMuteIngameOFF();
}
}
else {
App->scene_ui->IngameMenuOFF();
App->scene_ui->OnIngameMenu = false;
App->scene_ui->MuteIngameOFF();
App->scene_ui->UnMuteIngameOFF();
}
}
if (App->input->GetKey(SDL_SCANCODE_GRAVE) == KEY_DOWN) {
LOG("CONSOLE OPENED");
if (App->scene_ui->OnConsole == false) {
App->scene_ui->ConsoleON();
App->scene_ui->OnConsole = true;
}
else {
LOG("CONSOLE CLOSED");
App->scene_ui->ConsoleOFF();
App->scene_ui->OnConsole = false;
}
}
/*if (App->input->GetKey(SDL_SCANCODE_Y) == KEY_DOWN) {
App->scene_ui->MainMenuON();
}*/
/*if ((App->input->GetKey(SDL_SCANCODE_L) == KEY_DOWN)) {
if (App->scene_ui->OnSettingsMenu == false) {
App->scene_ui->SettingsMenuON();
App->scene_ui->OnSettingsMenu = true;
LOG("SETTINGS MENU WITH L ON");
}
else {
App->scene_ui->SettingsMenuOFF();
App->scene_ui->OnSettingsMenu = false;
LOG("SETTINGS MENU WITH L OFF");
}
}*/
BROFILER_CATEGORY("Scene Update();", Profiler::Color::Thistle)
if (App->input->GetKey(SDL_SCANCODE_F6) == KEY_DOWN)
App->LoadGame();
if (App->input->GetKey(SDL_SCANCODE_F5) == KEY_DOWN)
App->SaveGame("save_game.xml");
//App->SaveGame();
/*if (App->input->GetKey(SDL_SCANCODE_F1) == KEY_DOWN) {
App->fade->FadeToBlack("SimpleLevel1.tmx");
StartMap1();
}
if (App->input->GetKey(SDL_SCANCODE_F2) == KEY_DOWN) {
App->fade->FadeToBlack("SimpleLevel2.tmx");
StartMap2();
}*/
App->map->Draw();
if (App->input->keyboard[SDL_SCANCODE_F9] == KEY_DOWN) {
if (debug_path) {
debug_path = false;
}
else
{
debug_path = true;
}
}
if (debug_path == false)
return true;
int x, y;
App->input->GetMousePosition(x, y);
return true;
}
// Called each loop iteration
bool j1Scene::PostUpdate()
{
BROFILER_CATEGORY("Scene PostUpdate();", Profiler::Color::DarkBlue)
//VOLUMEN
/*if (App->input->GetKey(SDL_SCANCODE_KP_PLUS) == KEY_DOWN)
{
App->audio->general_volume += 5;
App->audio->SetVolumeMusic();
}
if (App->input->GetKey(SDL_SCANCODE_KP_MINUS) == KEY_DOWN)
{
App->audio->general_volume -= 5;
App->audio->SetVolumeMusic();
}*/
bool ret = true;
/*if (App->input->GetKey(SDL_SCANCODE_ESCAPE) == KEY_DOWN)
ret = false;*/
return ret;
}
// Called before quitting
bool j1Scene::CleanUp()
{
BROFILER_CATEGORY("Scene Start();", Profiler::Color::PeachPuff)
LOG("Freeing scene");
return true;
}
bool j1Scene::Save(pugi::xml_node& data)const {
pugi::xml_node mapname = data.append_child("");
return true;
}
void j1Scene::StartMap1()
{
Map1Loaded = true;
int w, h;
uchar* data = NULL;
if (App->map->CreateWalkabilityMap(w, h, &data))
App->pathfinding->SetMap(w, h, data);
RELEASE_ARRAY(data);
// ENEMY SPAWNS LEVEL 1
App->entityManager->AddEnemies(Skeleton1, SKELETON);
App->entityManager->AddEnemies(Bee1, BEE);
App->entityManager->AddEnemies(Skeleton2, SKELETON);
App->entityManager->AddEnemies(Skull1, SKULL);
App->entityManager->AddEnemies(Skeleton3, SKELETON);
App->entityManager->CreateEntity(PLAYER);
//MAP ITEM ENTITY SPAWN
App->entityManager->AddEnemies(MapItem1, MAP);
App->entityManager->AddEnemies(MapItem2, MAP);
App->entityManager->AddEnemies(MapItem3, MAP);
App->entityManager->AddEnemies(MapItem4, MAP);
}
void j1Scene::StartMap2()
{
App->entityManager->AddEnemies(MapItem1, MAP);
App->entityManager->AddEnemies(MapItem2, MAP);
App->entityManager->AddEnemies(MapItem3, MAP);
App->entityManager->AddEnemies(MapItem4, MAP);
App->entityManager->CreateEntity(PLAYER);
}
void j1Scene::RestartLevelEntitiesL1()
{
}
| 22.818493 | 171 | 0.679124 |
MarcArizaAlborni
|
2024c3d98a97d73df5bdaebbde964bdd00b622e3
| 612 |
hpp
|
C++
|
external/keko_ctab/ctab/shared/cTab_markerMenu_macros.hpp
|
kellerkompanie/kellerkompanie-mods
|
f15704710f77ba6c018c486d95cac4f7749d33b8
|
[
"MIT"
] | 6 |
2018-05-05T22:28:57.000Z
|
2019-07-06T08:46:51.000Z
|
external/keko_ctab/ctab/shared/cTab_markerMenu_macros.hpp
|
Schwaggot/kellerkompanie-mods
|
7a389e49e3675866dbde1b317a44892926976e9d
|
[
"MIT"
] | 107 |
2018-04-11T19:42:27.000Z
|
2019-09-13T19:05:31.000Z
|
external/keko_ctab/ctab/shared/cTab_markerMenu_macros.hpp
|
kellerkompanie/kellerkompanie-mods
|
f15704710f77ba6c018c486d95cac4f7749d33b8
|
[
"MIT"
] | 3 |
2018-10-03T11:54:46.000Z
|
2019-02-28T13:30:16.000Z
|
/*
Required defines:
MENU_sizeEx - Menu text size (height)
*/
// place the menu outside of the visible area
#define MENU_X safeZoneXAbs + safeZoneWAbs
#define MENU_Y safeZoneY + safeZoneH
#define MENU_maxChars 12 // used to determine the necessary width of the menu
#define MENU_wPerChar MENU_sizeEx * 3/4 * 0.5 // assume characters 50% width relative to height
#define MENU_W (MENU_maxChars + 1.5) * MENU_wPerChar // add 1.5 characters for padding
#define MENU_elementH MENU_sizeEx / 0.8
#define MENU_elementY(item) MENU_elementH * (item - 1)
#define MENU_H(noOfElements) (noOfElements + 0.5) * MENU_elementH
| 38.25 | 95 | 0.76634 |
kellerkompanie
|
202a482a2227101c86d65a83181d73fe1ccaee9f
| 983 |
cpp
|
C++
|
Microsoft.Toolkit.Uwp.Input.GazeInteraction/GazeStats.cpp
|
paulcam206/WindowsCommunityToolkit
|
eb20ae30788f320127b2c809cad5c8bbfbd9e663
|
[
"MIT"
] | 3 |
2021-05-27T00:29:00.000Z
|
2021-05-27T13:10:00.000Z
|
Microsoft.Toolkit.Uwp.Input.GazeInteraction/GazeStats.cpp
|
DLozanoNavas/UWPCommunityToolkit
|
e58479b546cbc264d391de214f3a17557088e109
|
[
"MIT"
] | 9 |
2018-04-11T21:05:47.000Z
|
2018-05-04T03:02:07.000Z
|
Microsoft.Toolkit.Uwp.Input.GazeInteraction/GazeStats.cpp
|
DLozanoNavas/UWPCommunityToolkit
|
e58479b546cbc264d391de214f3a17557088e109
|
[
"MIT"
] | 1 |
2020-07-31T11:15:48.000Z
|
2020-07-31T11:15:48.000Z
|
//Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license.
//See LICENSE in the project root for license information.
#include "pch.h"
#include "GazeStats.h"
using namespace Platform::Collections;
BEGIN_NAMESPACE_GAZE_INPUT
GazeStats::GazeStats(int maxHistoryLen)
{
_maxHistoryLen = maxHistoryLen;
_history = ref new Vector<Point>();
}
void GazeStats::Reset()
{
_sumX = 0;
_sumY = 0;
_sumSquaredX = 0;
_sumSquaredY = 0;
_history->Clear();
}
void GazeStats::Update(float x, float y)
{
Point pt(x, y);
_history->Append(pt);
if (_history->Size > _maxHistoryLen)
{
auto oldest = _history->GetAt(0);
_history->RemoveAt(0);
_sumX -= oldest.X;
_sumY -= oldest.Y;
_sumSquaredX -= oldest.X * oldest.X;
_sumSquaredY -= oldest.Y * oldest.Y;
}
_sumX += x;
_sumY += y;
_sumSquaredX += x * x;
_sumSquaredY += y * y;
}
END_NAMESPACE_GAZE_INPUT
| 20.479167 | 79 | 0.626653 |
paulcam206
|
202bb71b0d6fadd105929e02716275e4755984d7
| 833 |
cpp
|
C++
|
ZeldaClone/src/main.cpp
|
dwjclark11/ZeldaClone_NES
|
5d91cad0e071b45dfb10a6b86ac11a26642ad037
|
[
"MIT"
] | 7 |
2021-08-23T09:56:00.000Z
|
2022-03-21T15:29:15.000Z
|
ZeldaClone/src/main.cpp
|
dwjclark11/ZeldaClone_NES
|
5d91cad0e071b45dfb10a6b86ac11a26642ad037
|
[
"MIT"
] | null | null | null |
ZeldaClone/src/main.cpp
|
dwjclark11/ZeldaClone_NES
|
5d91cad0e071b45dfb10a6b86ac11a26642ad037
|
[
"MIT"
] | null | null | null |
#include "Game/Game.h"
#include "Systems/CameraMovementSystem.h"
#include "Systems/NameSystems/NameSelectKeyboardControlSystem.h"
int main()
{
if (!Registry::Instance()->HasSystem<SoundFXSystem>())
Registry::Instance()->AddSystem<SoundFXSystem>();
if (!Registry::Instance()->HasSystem<MusicPlayerSystem>())
Registry::Instance()->AddSystem<MusicPlayerSystem>();
if (!Registry::Instance()->HasSystem<CameraMovementSystem>())
Registry::Instance()->AddSystem<CameraMovementSystem>();
// Is this needed here?
if (!Registry::Instance()->HasSystem<NameSelectKeyboardControlSystem>())
Registry::Instance()->AddSystem<NameSelectKeyboardControlSystem>();
// Turn music volume down
Mix_VolumeMusic(10);
// Run the game Instance--> There is a loop inside this
Game::Instance()->Run();
Game::Instance()->Shutdown();
}
| 33.32 | 73 | 0.734694 |
dwjclark11
|
202c2c9366707524fef063fbd7870343aa657e4f
| 725 |
hpp
|
C++
|
src/cmd/definition.hpp
|
moralismercatus/kmap
|
6887780c2fbe795f07a81808ef31f11dad4f5043
|
[
"MIT"
] | 1 |
2021-06-28T00:31:08.000Z
|
2021-06-28T00:31:08.000Z
|
src/cmd/definition.hpp
|
moralismercatus/kmap
|
6887780c2fbe795f07a81808ef31f11dad4f5043
|
[
"MIT"
] | null | null | null |
src/cmd/definition.hpp
|
moralismercatus/kmap
|
6887780c2fbe795f07a81808ef31f11dad4f5043
|
[
"MIT"
] | null | null | null |
/******************************************************************************
* Author(s): Christopher J. Havlicek
*
* See LICENSE and CONTACTS.
******************************************************************************/
#pragma once
#ifndef KMAP_CMD_DEFINITION_HPP
#define KMAP_CMD_DEFINITION_HPP
#include "../cli.hpp"
#include <functional>
namespace kmap {
class Kmap;
}
namespace kmap::cmd {
auto create_definition( Kmap& kmap )
-> std::function< Result< std::string >( CliCommand::Args const& args ) >;
auto add_definition( Kmap& kmap )
-> std::function< Result< std::string >( CliCommand::Args const& args ) >;
} // namespace kmap::cmd
#endif // KMAP_CMD_DEFINITION_HPP
| 26.851852 | 81 | 0.525517 |
moralismercatus
|
45cc65e0fcf35ac3154d9cf252f9279adb6c6dfe
| 672 |
hpp
|
C++
|
shared_model/backend/protobuf/util.hpp
|
akshatkarani/iroha
|
5acef9dd74720c6185360d951e9b11be4ef73260
|
[
"Apache-2.0"
] | 1,467 |
2016-10-25T12:27:19.000Z
|
2022-03-28T04:32:05.000Z
|
shared_model/backend/protobuf/util.hpp
|
akshatkarani/iroha
|
5acef9dd74720c6185360d951e9b11be4ef73260
|
[
"Apache-2.0"
] | 2,366 |
2016-10-25T10:07:57.000Z
|
2022-03-31T22:03:24.000Z
|
shared_model/backend/protobuf/util.hpp
|
akshatkarani/iroha
|
5acef9dd74720c6185360d951e9b11be4ef73260
|
[
"Apache-2.0"
] | 662 |
2016-10-26T04:41:22.000Z
|
2022-03-31T04:15:02.000Z
|
/**
* Copyright Soramitsu Co., Ltd. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef IROHA_SHARED_MODEL_PROTO_UTIL_HPP
#define IROHA_SHARED_MODEL_PROTO_UTIL_HPP
#include <google/protobuf/message.h>
#include <vector>
#include "cryptography/blob.hpp"
namespace shared_model {
namespace proto {
template <typename T>
crypto::Blob makeBlob(T &&message) {
crypto::Blob::Bytes data;
data.resize(message.ByteSizeLong());
message.SerializeToArray(data.data(), data.size());
return crypto::Blob(std::move(data));
}
} // namespace proto
} // namespace shared_model
#endif // IROHA_SHARED_MODEL_PROTO_UTIL_HPP
| 24 | 57 | 0.714286 |
akshatkarani
|
45d1dbb8b6e694baaa42ed82da757e23199ab54b
| 2,765 |
cpp
|
C++
|
ball.cpp
|
aczapi/PingPong
|
5f0df3c5453d73181fffc7d96c813c3eb296ddfd
|
[
"Unlicense"
] | null | null | null |
ball.cpp
|
aczapi/PingPong
|
5f0df3c5453d73181fffc7d96c813c3eb296ddfd
|
[
"Unlicense"
] | null | null | null |
ball.cpp
|
aczapi/PingPong
|
5f0df3c5453d73181fffc7d96c813c3eb296ddfd
|
[
"Unlicense"
] | null | null | null |
#include "ball.hpp"
#include <SFML/Audio.hpp>
#include <SFML/Window.hpp>
#include "gameStates.hpp"
#include "headers.hpp"
#include "mainMenu.hpp"
Ball::Ball(std::shared_ptr<Paddle> player1, std::shared_ptr<Paddle> player2, std::shared_ptr<Score> scorePlayer1, std::shared_ptr<Score> scorePlayer2) {
this->player1_ = player1;
this->player2_ = player2;
this->scorePlayer1_ = scorePlayer1;
this->scorePlayer2_ = scorePlayer2;
this->load("../assets/graphics/ball2.png");
this->buffer_ = new sf::SoundBuffer();
this->buffer_->loadFromFile("../assets/sounds/bounce.wav");
this->sound_ = new sf::Sound(*this->buffer_);
this->scoreBuffer_ = new sf::SoundBuffer();
this->scoreBuffer_->loadFromFile("../assets/sounds/glass.wav");
this->scoreSound_ = new sf::Sound(*this->scoreBuffer_);
this->scoreSound_->setVolume(50);
}
void Ball::addVelocity(std::shared_ptr<Paddle> paddle) {
if (this->velocity_.y > 0) {
if (paddle->velocity_.y > 0) {
this->velocity_.y *= 1.30f;
} else if (paddle->velocity_.y < 0 && this->velocity_.y != 5.5f) {
this->velocity_.y = 5.5f;
}
} else if (this->velocity_.y < 0) {
if (paddle->velocity_.y < 0) {
this->velocity_.y *= 1.30f;
} else if (paddle->velocity_.y > 0 && this->velocity_.y != -5.5f) {
this->velocity_.y = -5.5f;
}
}
}
void Ball::update(sf::RenderWindow* window) {
if (this->checkCollision(this->player1_)) {
this->velocity_.x *= -1;
addVelocity(player1_);
this->sound_->play();
}
if (this->checkCollision(this->player2_)) {
this->velocity_.x *= -1;
addVelocity(player2_);
this->sound_->play();
}
if (this->getPosition().y < 0 || this->getPosition().y + this->getGlobalBounds().height > window->getSize().y) {
this->velocity_.y *= -1;
this->sound_->play();
}
if (this->getPosition().x < this->player1_->getGlobalBounds().width - 5) {
this->scoreSound_->play();
this->scorePlayer2_->incrementScore();
this->reset(window);
}
if (this->getPosition().x > window->getSize().x - this->player2_->getGlobalBounds().width + 5) {
this->scoreSound_->play();
this->scorePlayer1_->incrementScore();
this->reset(window);
}
Entity::update();
}
void Ball::reset(sf::RenderWindow* window) {
this->velocity_.x = ((rand() % 2) == 0) ? 6.5f : -6.5f;
this->velocity_.y = ((rand() % 2) == 0) ? 6.5f : -6.5f;
this->setPosition(window->getSize().x / 2 - 14, window->getSize().y / 2 - 10);
}
Ball::~Ball() {
delete (this->scoreSound_);
delete (this->scoreBuffer_);
delete (this->buffer_);
delete (this->sound_);
}
| 34.135802 | 152 | 0.595298 |
aczapi
|
45dc62b034f9da99c95d3406fc9c14a09226c20a
| 2,407 |
cpp
|
C++
|
UOJ/62.cpp
|
sshockwave/Online-Judge-Solutions
|
9d0bc7fd68c3d1f661622929c1cb3752601881d3
|
[
"MIT"
] | 6 |
2019-09-30T16:11:00.000Z
|
2021-11-01T11:42:33.000Z
|
UOJ/62.cpp
|
sshockwave/Online-Judge-Solutions
|
9d0bc7fd68c3d1f661622929c1cb3752601881d3
|
[
"MIT"
] | 4 |
2017-11-21T08:17:42.000Z
|
2020-07-28T12:09:52.000Z
|
EZOJ/Contests/1425/C.cpp
|
sshockwave/Online-Judge-Solutions
|
9d0bc7fd68c3d1f661622929c1cb3752601881d3
|
[
"MIT"
] | 4 |
2017-07-26T05:54:06.000Z
|
2020-09-30T13:35:38.000Z
|
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
T i=0;char c;
while(!isdigit(c=getchar())&&c!='-');
bool neg=c=='-';
neg?c=getchar():0;
while(i=i*10-'0'+c,isdigit(c=getchar()));
return neg?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
template<class T>inline void mset(T a,int v,int n){memset(a,v,n*sizeof(a[0]));}
const int N=100010,O=998244353;
inline int fpow(int x,int n){
int a=1;
for(;n;n>>=1,x=(lint)x*x%O){
if(n&1){
a=(lint)a*x%O;
}
}
return a;
}
inline int mod_inv(int x){
return fpow(x,O-2);
}
namespace sieve{
int n;
int pri[N],ps=0;
bool np[N];
int mu[N];
inline void main(int _n){
n=_n;
mu[1]=1;
for(int i=2;i<=n;i++){
if(!np[i]){
pri[ps++]=i;
mu[i]=-1;
}
for(int j=0,p,t;j<ps&&(p=pri[j],t=i*p,t<=n);j++){
np[t]=true;
if(i%p){
mu[t]=-mu[i];
}else{
mu[t]=0;
break;
}
}
}
}
inline void gpw(int pw[],int e){
e=(e%(O-1)+O-1)%(O-1);
pw[1]=1;
for(int i=2;i<=n;i++){
if(!np[i]){
pw[i]=fpow(i,e);
}
for(int j=0,p,t;j<ps&&(p=pri[j],t=i*p,t<=n);j++){
pw[t]=(lint)pw[i]*pw[p]%O;
if(i%p==0)break;
}
}
}
}
using sieve::mu;
int g[N];
int invpwd[N],pwe[N];
lint b[N];
inline void Main(int n){
mset(b+1,0,n);
for(int i=1;i<=n;i++){
int a=next_num<lint>()*invpwd[i]%O;
for(int j=1,k=i;k<=n;j++,k+=i){
if(mu[j]){
b[k]+=a*mu[j];
}
}
}
for(int i=1;i<=n;i++){
b[i]%=O;
if(b[i]<0){
b[i]+=O;
}
if(b[i]!=0&&g[i]==0){
puts("-1");
return;
}
b[i]=(lint)b[i]*g[i]%O;
}
for(int i=1;i<=n;i++){
lint x=0;
for(int j=1,k=i;k<=n;j++,k+=i){
if(mu[j]){
x+=b[k]*mu[j];
}
}
x=((lint)x%O*invpwd[i]%O+O)%O;
printf("%lld ",x);
}
putchar('\n');
}
int main(){
#ifndef ONLINE_JUDGE
freopen("round.in","r",stdin);
freopen("round.out","w",stdout);
#endif
int n=ni,c=ni,d=ni;
sieve::main(n);
sieve::gpw(pwe,c-d);
sieve::gpw(invpwd,-d);
{//g
mset(g+1,0,n);
for(int i=1;i<=n;i++){
for(int j=1,k=i;k<=n;j++,k+=i){
if(mu[j]){
g[k]=((lint)g[k]+O+pwe[i]*mu[j])%O;
}
}
g[i]=mod_inv(g[i]);
}
}
for(int tot=ni;tot--;Main(n));
return 0;
}
| 18.234848 | 79 | 0.522227 |
sshockwave
|
45de1a5eb2b9ca60d7094a034aa0b05e639de2f0
| 2,630 |
cpp
|
C++
|
libs/input/impl/src/input/impl/multi_system.cpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | 2 |
2016-01-27T13:18:14.000Z
|
2018-05-11T01:11:32.000Z
|
libs/input/impl/src/input/impl/multi_system.cpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | null | null | null |
libs/input/impl/src/input/impl/multi_system.cpp
|
cpreh/spacegameengine
|
313a1c34160b42a5135f8223ffaa3a31bc075a01
|
[
"BSL-1.0"
] | 3 |
2018-05-11T01:11:34.000Z
|
2021-04-24T19:47:45.000Z
|
// Copyright Carl Philipp Reh 2006 - 2019.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <sge/input/capabilities_field.hpp>
#include <sge/input/processor.hpp>
#include <sge/input/processor_unique_ptr.hpp>
#include <sge/input/system.hpp>
#include <sge/input/system_unique_ptr.hpp>
#include <sge/input/impl/log_name.hpp>
#include <sge/input/impl/multi_processor.hpp>
#include <sge/input/impl/multi_system.hpp>
#include <sge/input/impl/system_ptr_vector.hpp>
#include <sge/input/plugin/collection.hpp>
#include <sge/input/plugin/context.hpp>
#include <sge/input/plugin/iterator.hpp>
#include <sge/input/plugin/object.hpp>
#include <sge/input/plugin/traits.hpp>
#include <sge/log/default_parameters.hpp>
#include <sge/log/location.hpp>
#include <sge/window/object_ref.hpp>
#include <fcppt/make_unique_ptr.hpp>
#include <fcppt/unique_ptr_to_base.hpp>
#include <fcppt/algorithm/fold.hpp>
#include <fcppt/algorithm/map.hpp>
#include <fcppt/container/bitfield/operators.hpp>
#include <fcppt/log/context_reference.hpp>
sge::input::impl::multi_system::multi_system(
fcppt::log::context_reference const _log_context,
sge::input::plugin::collection const &_collection)
: sge::input::system(),
log_{
_log_context,
sge::log::location(),
sge::log::default_parameters(sge::input::impl::log_name())},
plugins_(fcppt::algorithm::map<sge::input::impl::multi_system::plugin_vector>(
_collection,
[](sge::input::plugin::context const &_context) { return _context.load(); })),
systems_(fcppt::algorithm::map<sge::input::impl::system_ptr_vector>(
plugins_,
[&_log_context](sge::input::plugin::object const &_plugin)
{ return _plugin.get()(_log_context); })),
capabilities_(fcppt::algorithm::fold(
systems_,
sge::input::capabilities_field::null(),
[](sge::input::system_unique_ptr const &_system,
sge::input::capabilities_field const &_state)
{ return _state | _system->capabilities(); }))
{
}
sge::input::impl::multi_system::~multi_system() = default;
sge::input::processor_unique_ptr
sge::input::impl::multi_system::create_processor(sge::window::object_ref const _window)
{
return fcppt::unique_ptr_to_base<sge::input::processor>(
fcppt::make_unique_ptr<sge::input::impl::multi_processor>(log_, _window, systems_));
}
sge::input::capabilities_field sge::input::impl::multi_system::capabilities() const
{
return capabilities_;
}
| 39.253731 | 90 | 0.709506 |
cpreh
|
45e42a1025c8adc217a96c371d3bb00ac639fb17
| 1,112 |
cpp
|
C++
|
LuoguCodes/P1968.cpp
|
Anguei/OI-Codes
|
0ef271e9af0619d4c236e314cd6d8708d356536a
|
[
"MIT"
] | null | null | null |
LuoguCodes/P1968.cpp
|
Anguei/OI-Codes
|
0ef271e9af0619d4c236e314cd6d8708d356536a
|
[
"MIT"
] | null | null | null |
LuoguCodes/P1968.cpp
|
Anguei/OI-Codes
|
0ef271e9af0619d4c236e314cd6d8708d356536a
|
[
"MIT"
] | null | null | null |
//【P1968】美元汇率 - 洛谷 - 10
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
struct Income {
double dollar, mark;
Income() {}
} *f;
int n, *a;
void input() {
std::cin >> n;
a = new int[n + 1];
for (int i = 1; i <= n; ++i) {
std::cin >> a[i];
}
}
int main() {
input();
f = new Income[n + 1];
f[1].dollar = 100.0, f[1].mark = a[1];
for (int i = 2; i <= n; ++i) {
f[i].dollar = std::max(f[i - 1].dollar, f[i - 1].mark / a[i] * 100.0);
f[i].mark = std::max(f[i - 1].mark, f[i - 1].dollar * a[i] / 100.0);
}
printf("%.2f", (f[n].dollar > f[n].mark ? f[n].dollar : f[n].mark / a[n] * 100.0));
/*
double now_my = 100.0, now_mk = 0.0, max_hl = 0.0, min_hl = 2147483647.0;
for (int i = 0; i < n; ++i) {
if (i + 1 == n) {
now_my += now_mk * 100.0 / a[i];
now_mk = 0.0;
}
else if (a[i] > max_hl) {
now_mk += a[i] / 100.0 * now_my;
now_my = 0.0;
}
else if (a[i] < min_hl) {
now_my += now_mk * 100.0 / a[i];
now_mk = 0.0;
}
max_hl = std::max(max_hl, double(a[i]));
min_hl = std::min(min_hl, double(a[i]));
}
printf("%.2f", now_my);
*/
}
| 21.803922 | 84 | 0.502698 |
Anguei
|
45e610bb53c08e45b75bd5842dd978d69f9c3ce6
| 2,158 |
cpp
|
C++
|
Shared/Io/Timer.cpp
|
Joon-Jung/HoloLensForCV
|
fad1818ff1e6afd8bae3a91b710c23a653cbd722
|
[
"MIT"
] | 250 |
2017-07-26T20:54:22.000Z
|
2019-05-03T09:21:12.000Z
|
Shared/Io/Timer.cpp
|
Joon-Jung/HoloLensForCV
|
fad1818ff1e6afd8bae3a91b710c23a653cbd722
|
[
"MIT"
] | 79 |
2017-08-08T20:08:02.000Z
|
2019-05-06T14:32:45.000Z
|
Shared/Io/Timer.cpp
|
Joon-Jung/HoloLensForCV
|
fad1818ff1e6afd8bae3a91b710c23a653cbd722
|
[
"MIT"
] | 88 |
2017-07-28T09:11:51.000Z
|
2019-05-04T03:48:44.000Z
|
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
namespace Io
{
namespace Internal
{
// Gets the current number of ticks from QueryPerformanceCounter. Throws an
// exception if the call to QueryPerformanceCounter fails.
int64_t GetPerformanceCounter()
{
LARGE_INTEGER counter;
ASSERT(QueryPerformanceCounter(
&counter));
return counter.QuadPart;
}
}
Timer::Timer()
{
_qpcTotalStartTime =
Internal::GetPerformanceCounter();
_qpcElapsedStartTime =
_qpcTotalStartTime;
}
HundredsOfNanoseconds Timer::GetElapsedTime() const
{
const int64_t qpcCurrentTime =
Internal::GetPerformanceCounter();
const int64_t qpcElapsedTime =
qpcCurrentTime - _qpcElapsedStartTime;
return _timeConverter.QpcToRelativeTicks(
qpcCurrentTime - _qpcElapsedStartTime);
}
double Timer::GetElapsedSeconds() const
{
return std::chrono::duration_cast<std::chrono::duration<double>>(
GetElapsedTime()).count();
}
HundredsOfNanoseconds Timer::GetTotalTime() const
{
const int64_t qpcCurrentTime =
Internal::GetPerformanceCounter();
return _timeConverter.QpcToRelativeTicks(
qpcCurrentTime);
}
double Timer::GetTotalSeconds() const
{
return std::chrono::duration_cast<std::chrono::duration<double>>(
GetTotalTime()).count();
}
void Timer::ResetElapsedTime()
{
_qpcElapsedStartTime =
Internal::GetPerformanceCounter();
}
}
| 27.316456 | 84 | 0.57507 |
Joon-Jung
|
45e648661e82340b235cd566b3b0fa122864856d
| 425 |
cpp
|
C++
|
GFX/Vulkan/API_without_Secrets/Tutorial01/main.cpp
|
longlongwaytogo/Learning.test
|
ded9a25ba789c153d69b2d216599eda962ef83e9
|
[
"MIT"
] | null | null | null |
GFX/Vulkan/API_without_Secrets/Tutorial01/main.cpp
|
longlongwaytogo/Learning.test
|
ded9a25ba789c153d69b2d216599eda962ef83e9
|
[
"MIT"
] | null | null | null |
GFX/Vulkan/API_without_Secrets/Tutorial01/main.cpp
|
longlongwaytogo/Learning.test
|
ded9a25ba789c153d69b2d216599eda962ef83e9
|
[
"MIT"
] | null | null | null |
#include "Tutorial01.h"
int main( int argc, char ** argv ) {
ApiWithoutSecrets::OS::Window window;
ApiWithoutSecrets::Tutorial01 tutorial01;
// window creation
if(! window.Create("01-The Beginning") ) {
return -1;
}
// Vulkan preparations and initialization
if( !tutorial01.PrepareVulkan() ) {
return -1;
}
// Rendering Loop
if(!window.RenderingLoop(tutorial01) ) {
return -1;
}
return 0;
}
| 14.655172 | 43 | 0.663529 |
longlongwaytogo
|
45e94b3dfd7697ee37a539956a2ef6eade97b84f
| 1,583 |
hpp
|
C++
|
core/utilities/string.hpp
|
fritzio/libstl
|
0709e54e4b13576edf84e393db211fb77efd7f72
|
[
"MIT"
] | null | null | null |
core/utilities/string.hpp
|
fritzio/libstl
|
0709e54e4b13576edf84e393db211fb77efd7f72
|
[
"MIT"
] | null | null | null |
core/utilities/string.hpp
|
fritzio/libstl
|
0709e54e4b13576edf84e393db211fb77efd7f72
|
[
"MIT"
] | null | null | null |
#ifndef LIBSTL_UTLITIES_STRING_HPP
#define LIBSTL_UTLITIES_STRING_HPP
#include <array>
#include <string>
#include <vector>
namespace libstl {
namespace utilities {
namespace string {
std::string erase(const std::string& string, const std::string& substring) {
std::string s = string;
return s.erase(string.find(substring), substring.length());
}
std::string trim_leading_whitespace(const std::string& string, const std::string whitespace = " ") {
return string.substr(string.find_first_not_of(whitespace));
}
std::string trim_trailing_whitespace(const std::string& string, const std::string whitespace = " ") {
return string.substr(0, string.find_last_not_of(whitespace) + 1);
}
std::vector<std::string> split(const std::string& string, const std::string delimiter = " ") {
std::vector<std::string> splitted_string;
std::string s = string;
std::size_t pos = 0;
while ((pos = s.find(delimiter)) != std::string::npos) {
std::string token = s.substr(0, pos);
splitted_string.push_back(token);
s.erase(0, pos + delimiter.length());
}
splitted_string.push_back(s);
return splitted_string;
}
std::vector<std::string> trim_and_split(const std::string& string, const std::string delimiter = " ",
const std::string whitespace = " ") {
return split(trim_trailing_whitespace(trim_leading_whitespace(string, whitespace), whitespace), delimiter);
}
} // namespace string
} // namespace utilities
} // namespace libstl
#endif // LIBSTL_UTLITIES_STRING_HPP
| 26.830508 | 111 | 0.684776 |
fritzio
|
45e9bbade0ee125116c9f34aaa3263b5f7990dd2
| 2,148 |
cpp
|
C++
|
src/jet/live/LiveDelegate.cpp
|
cpei-avalara/jet-live
|
27593e29606456e822aee49384aafce97d914acd
|
[
"MIT"
] | null | null | null |
src/jet/live/LiveDelegate.cpp
|
cpei-avalara/jet-live
|
27593e29606456e822aee49384aafce97d914acd
|
[
"MIT"
] | null | null | null |
src/jet/live/LiveDelegate.cpp
|
cpei-avalara/jet-live
|
27593e29606456e822aee49384aafce97d914acd
|
[
"MIT"
] | null | null | null |
#include "LiveDelegate.hpp"
#include "jet/live/CompileCommandsCompilationUnitsParser.hpp"
#include "jet/live/DefaultProgramInfoLoader.hpp"
#include "jet/live/DepfileDependenciesHandler.hpp"
#include "jet/live/Utility.hpp"
namespace jet
{
void LiveDelegate::onLog(LogSeverity, const std::string&) {}
void LiveDelegate::onCodePreLoad() {}
void LiveDelegate::onCodePostLoad() {}
size_t LiveDelegate::getWorkerThreadsCount() { return 4; }
std::vector<std::string> LiveDelegate::getDirectoriesToMonitor() { return {}; }
bool LiveDelegate::shouldReloadMachoSymbol(const MachoContext& context, const MachoSymbol& symbol)
{
return (symbol.external && symbol.type == MachoSymbolType::kSection
&& symbol.sectionIndex == context.textSectionIndex && !symbol.weakDef);
}
bool LiveDelegate::shouldReloadElfSymbol(const ElfContext& context, const ElfSymbol& symbol)
{
static const std::string textSectionName = ".text";
return (symbol.type == ElfSymbolType::kFunction && symbol.size != 0
&& symbol.sectionIndex < context.sectionNames.size() // Some sections has reserved indices
&& context.sectionNames[symbol.sectionIndex] == textSectionName);
}
bool LiveDelegate::shouldTransferMachoSymbol(const MachoContext&, const MachoSymbol&) { return false; }
bool LiveDelegate::shouldTransferElfSymbol(const ElfContext& context, const ElfSymbol& symbol)
{
static const std::string bssSectionName = ".bss";
return (symbol.type == ElfSymbolType::kObject && context.sectionNames[symbol.sectionIndex] == bssSectionName);
}
std::unique_ptr<ICompilationUnitsParser> LiveDelegate::createCompilationUnitsParser()
{
return jet::make_unique<CompileCommandsCompilationUnitsParser>();
}
std::unique_ptr<IDependenciesHandler> LiveDelegate::createDependenciesHandler()
{
return jet::make_unique<DepfileDependenciesHandler>();
}
std::unique_ptr<IProgramInfoLoader> LiveDelegate::createProgramInfoLoader()
{
return jet::make_unique<DefaultProgramInfoLoader>();
}
}
| 37.684211 | 118 | 0.715549 |
cpei-avalara
|
45ec4eec8930c64c8fcb1910df45d16cbfbef69c
| 938 |
cpp
|
C++
|
backup/2/interviewbit/c++/majority-element.cpp
|
yangyanzhan/code-camp
|
4272564e916fc230a4a488f92ae32c07d355dee0
|
[
"Apache-2.0"
] | 21 |
2019-11-16T19:08:35.000Z
|
2021-11-12T12:26:01.000Z
|
backup/2/interviewbit/c++/majority-element.cpp
|
yangyanzhan/code-camp
|
4272564e916fc230a4a488f92ae32c07d355dee0
|
[
"Apache-2.0"
] | 1 |
2022-02-04T16:02:53.000Z
|
2022-02-04T16:02:53.000Z
|
backup/2/interviewbit/c++/majority-element.cpp
|
yangyanzhan/code-camp
|
4272564e916fc230a4a488f92ae32c07d355dee0
|
[
"Apache-2.0"
] | 4 |
2020-05-15T19:39:41.000Z
|
2021-10-30T06:40:31.000Z
|
// Hi, I'm Yanzhan. For more algothmic problems, visit my Youtube Channel (Yanzhan Yang's Youtube Channel) : https://www.youtube.com/channel/UCDkz-__gl3frqLexukpG0DA?view_as=subscriber or my Twitter Account (Yanzhan Yang's Twitter) : https://twitter.com/YangYanzhan or my GitHub HomePage (Yanzhan Yang's GitHub HomePage) : https://yanzhan.site .
// For this specific algothmic problem, visit my Youtube Video : .
// It's fascinating to solve algothmic problems, follow Yanzhan to learn more!
// Blog URL for this problem: https://yanzhan.site/interviewbit/majority-element.html .
int Solution::majorityElement(const vector<int> &A) {
int major = A[0], count = 1;
for (int i = 1; i < A.size(); i++) {
int num = A[i];
if (count == 0) {
major = num;
count = 1;
} else if (major == num) {
count++;
} else {
count--;
}
}
return major;
}
| 44.666667 | 345 | 0.630064 |
yangyanzhan
|
45f884f94ce01ba6ede76e1851e83ac115c28edf
| 281 |
hpp
|
C++
|
include/generic/geometry/range_space.hpp
|
shikanle/gfx
|
772db3ddd66c294beaf17319f6b3803abe3ce0df
|
[
"Apache-2.0"
] | 4 |
2022-01-06T14:06:03.000Z
|
2022-01-07T01:13:58.000Z
|
include/generic/geometry/range_space.hpp
|
shikanle/gfx
|
772db3ddd66c294beaf17319f6b3803abe3ce0df
|
[
"Apache-2.0"
] | null | null | null |
include/generic/geometry/range_space.hpp
|
shikanle/gfx
|
772db3ddd66c294beaf17319f6b3803abe3ce0df
|
[
"Apache-2.0"
] | null | null | null |
#pragma once
namespace gfx {
namespace generic {
template <typename float_system>
class range_space : public object {
public:
typedef float_system float_system_t;
typedef typename float_system_t::float_t float_t;
public:
dynamic_reflectible(range_space, {});
};
}
}
| 16.529412 | 53 | 0.754448 |
shikanle
|
45fc2c960ca416349005f51c9a48b3b7ebc6b602
| 864 |
cpp
|
C++
|
zoo_test.cpp
|
keychera/VirtualZOOP
|
893bbca25da0770504dc67c98adb526aee980237
|
[
"MIT"
] | null | null | null |
zoo_test.cpp
|
keychera/VirtualZOOP
|
893bbca25da0770504dc67c98adb526aee980237
|
[
"MIT"
] | null | null | null |
zoo_test.cpp
|
keychera/VirtualZOOP
|
893bbca25da0770504dc67c98adb526aee980237
|
[
"MIT"
] | null | null | null |
#include "zoo.h"
#include <gtest/gtest.h>
#include <iostream>
using namespace std;
class ZooTest : public ::testing::Test {
protected:
ZooTest(){}
};
TEST(ZooTest, Test1) {
string filename="map.txt";
Zoo Z;
Z.ReadZoo(filename.c_str());
ASSERT_EQ(21,Z.GetWidth());
ASSERT_EQ(21,Z.GetLength());
cout<<"width: "<<Z.GetWidth()<<endl;
cout<<"length: "<<Z.GetLength()<<endl;
for(int i=0;i<Z.GetWidth();i++)
{
for(int j=0;j<Z.GetLength();j++)
{
//cout<<i<<j<<(i*Z.GetLength()+j);
//cout<<Z.GetCells()[i*Z.GetLength()+j]->GetX()<<Z.GetCells()[i*Z.GetLength()+j]->GetY()<<endl;
ASSERT_EQ((i),Z.GetCells()[i*Z.GetLength()+j]->GetX());
ASSERT_EQ((j),Z.GetCells()[i*Z.GetLength()+j]->GetY());
}
//cout<<endl;
}
Z.MakeCage();
ASSERT_EQ(17,Z.GetNCages());
}
| 26.181818 | 97 | 0.552083 |
keychera
|
3400b7fe0e4d35c15ef8c18b5b35a8a4fb0a140f
| 1,819 |
cc
|
C++
|
onnxruntime/core/providers/cuda/generator/constant_of_shape.cc
|
csteegz/onnxruntime
|
a36810471b346ec862ac6e4de7f877653f49525e
|
[
"MIT"
] | 1 |
2020-07-12T15:23:49.000Z
|
2020-07-12T15:23:49.000Z
|
onnxruntime/core/providers/cuda/generator/constant_of_shape.cc
|
ajinkya933/onnxruntime
|
0e799a03f2a99da6a1b87a2cd37facb420c482aa
|
[
"MIT"
] | null | null | null |
onnxruntime/core/providers/cuda/generator/constant_of_shape.cc
|
ajinkya933/onnxruntime
|
0e799a03f2a99da6a1b87a2cd37facb420c482aa
|
[
"MIT"
] | 1 |
2020-09-09T06:55:51.000Z
|
2020-09-09T06:55:51.000Z
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "constant_of_shape.h"
#include "core/providers/common.h"
#include "gsl/gsl"
using namespace ::onnxruntime::common;
using namespace ONNX_NAMESPACE;
namespace onnxruntime {
namespace cuda {
ONNX_OPERATOR_KERNEL_EX(
ConstantOfShape,
kOnnxDomain,
9,
kCudaExecutionProvider,
KernelDefBuilder()
.InputMemoryType<OrtMemTypeCPUInput>(0)
.TypeConstraint("T1", DataTypeImpl::GetTensorType<int64_t>())
.TypeConstraint("T2", DataTypeImpl::AllFixedSizeTensorTypes()),
ConstantOfShape);
Status ConstantOfShape::Compute(OpKernelContext* ctx) const {
Tensor* output_tensor = nullptr;
ORT_RETURN_IF_ERROR(PrepareCompute(ctx, &output_tensor));
auto output_data = output_tensor->MutableDataRaw();
const auto size = output_tensor->Shape().Size();
const void* value_ptr = GetValuePtr();
const auto element_size = output_tensor->DataType()->Size();
switch (element_size) {
case sizeof(int8_t):
cuda::Fill(reinterpret_cast<int8_t*>(output_data), *(reinterpret_cast<const int8_t*>(value_ptr)), size);
break;
case sizeof(int16_t):
cuda::Fill(reinterpret_cast<int16_t*>(output_data), *(reinterpret_cast<const int16_t*>(value_ptr)), size);
break;
case sizeof(int32_t):
cuda::Fill(reinterpret_cast<int32_t*>(output_data), *(reinterpret_cast<const int32_t*>(value_ptr)), size);
break;
case sizeof(int64_t):
cuda::Fill(reinterpret_cast<int64_t*>(output_data), *(reinterpret_cast<const int64_t*>(value_ptr)), size);
break;
default:
ORT_THROW("Unsupported value attribute datatype with sizeof=: ", element_size);
break;
}
return Status::OK();
}
} // namespace cuda
} // namespace onnxruntime
| 33.685185 | 112 | 0.715778 |
csteegz
|
3413fcae1164f05e6869430c9c549bdc3b7a6e7c
| 6,668 |
hpp
|
C++
|
cpp/include/rapids_triton/model/model.hpp
|
divyegala/rapids-triton
|
8ff2a8dbad029e9379d9e7808d868924c4b60590
|
[
"Apache-2.0"
] | 1 |
2022-02-23T23:38:40.000Z
|
2022-02-23T23:38:40.000Z
|
cpp/include/rapids_triton/model/model.hpp
|
divyegala/rapids-triton
|
8ff2a8dbad029e9379d9e7808d868924c4b60590
|
[
"Apache-2.0"
] | 12 |
2021-09-20T21:23:27.000Z
|
2022-03-31T22:53:30.000Z
|
cpp/include/rapids_triton/model/model.hpp
|
divyegala/rapids-triton
|
8ff2a8dbad029e9379d9e7808d868924c4b60590
|
[
"Apache-2.0"
] | 2 |
2022-01-27T20:58:07.000Z
|
2022-02-09T23:07:41.000Z
|
/*
* Copyright (c) 2021, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifdef TRITON_ENABLE_GPU
#include <cuda_runtime_api.h>
#else
#include <rapids_triton/cpu_only/cuda_runtime_replacement.hpp>
#endif
#include <cstddef>
#include <rapids_triton/batch/batch.hpp>
#include <rapids_triton/memory/resource.hpp>
#include <rapids_triton/model/shared_state.hpp>
#include <rapids_triton/tensor/tensor.hpp>
#include <rapids_triton/triton/deployment.hpp>
#include <rapids_triton/triton/device.hpp>
#include <rapids_triton/utils/narrow.hpp>
#include <string>
#include <vector>
namespace triton {
namespace backend {
namespace rapids {
template <typename SharedState = SharedModelState>
struct Model {
virtual void predict(Batch& batch) const = 0;
virtual void load() {}
virtual void unload() {}
/**
* @brief Return the preferred memory type in which to store data for this
* batch or std::nullopt to accept whatever Triton returns
*
* The base implementation of this method will require data on-host if the
* model itself is deployed on the host OR if this backend has not been
* compiled with GPU support. Otherwise, models deployed on device will
* receive memory on device. Overriding this method will allow derived
* model classes to select a preferred memory location based on properties
* of the batch or to simply return std::nullopt if device memory or host
* memory will do equally well.
*/
virtual std::optional<MemoryType> preferred_mem_type(Batch& batch) const
{
return (IS_GPU_BUILD && deployment_type_ == GPUDeployment) ? DeviceMemory : HostMemory;
}
virtual std::optional<MemoryType> preferred_mem_type_in(Batch& batch) const
{
return preferred_mem_type(batch);
}
virtual std::optional<MemoryType> preferred_mem_type_out(Batch& batch) const
{
return preferred_mem_type(batch);
}
/**
* @brief Retrieve a stream used to set up batches for this model
*
* The base implementation of this method simply returns the default stream
* provided by Triton for use with this model. Child classes may choose to
* override this in order to provide different streams for use with
* successive incoming batches. For instance, one might cycle through
* several streams in order to distribute batches across them, but care
* should be taken to ensure proper synchronization in this case.
*/
virtual cudaStream_t get_stream() const { return default_stream_; }
/**
* @brief Get input tensor of a particular named input for an entire batch
*/
template <typename T>
auto get_input(Batch& batch,
std::string const& name,
std::optional<MemoryType> const& mem_type,
cudaStream_t stream) const
{
return batch.get_input<T const>(name, mem_type, device_id_, stream);
}
template <typename T>
auto get_input(Batch& batch,
std::string const& name,
std::optional<MemoryType> const& mem_type) const
{
return get_input<T>(batch, name, mem_type, default_stream_);
}
template <typename T>
auto get_input(Batch& batch, std::string const& name) const
{
return get_input<T>(batch, name, preferred_mem_type(batch), default_stream_);
}
/**
* @brief Get output tensor of a particular named output for an entire batch
*/
template <typename T>
auto get_output(Batch& batch,
std::string const& name,
std::optional<MemoryType> const& mem_type,
device_id_t device_id,
cudaStream_t stream) const
{
return batch.get_output<T>(name, mem_type, device_id, stream);
}
template <typename T>
auto get_output(Batch& batch,
std::string const& name,
std::optional<MemoryType> const& mem_type,
cudaStream_t stream) const
{
return get_output<T>(batch, name, mem_type, device_id_, stream);
}
template <typename T>
auto get_output(Batch& batch,
std::string const& name,
std::optional<MemoryType> const& mem_type) const
{
return get_output<T>(batch, name, mem_type, device_id_, default_stream_);
}
template <typename T>
auto get_output(Batch& batch, std::string const& name) const
{
return get_output<T>(batch, name, preferred_mem_type(batch), device_id_, default_stream_);
}
/**
* @brief Retrieve value of configuration parameter
*/
template <typename T>
auto get_config_param(std::string const& name) const
{
return shared_state_->template get_config_param<T>(name);
}
template <typename T>
auto get_config_param(std::string const& name, T default_value) const
{
return shared_state_->template get_config_param<T>(name, default_value);
}
template <typename T>
auto get_config_param(char const* name) const
{
return get_config_param<T>(std::string(name));
}
template <typename T>
auto get_config_param(char const* name, T default_value) const
{
return get_config_param<T>(std::string(name), default_value);
}
Model(std::shared_ptr<SharedState> shared_state,
device_id_t device_id,
cudaStream_t default_stream,
DeploymentType deployment_type,
std::string const& filepath)
: shared_state_{shared_state},
device_id_{device_id},
default_stream_{default_stream},
deployment_type_{deployment_type},
filepath_{filepath}
{
if constexpr (IS_GPU_BUILD) { setup_memory_resource(device_id_); }
}
auto get_device_id() const { return device_id_; }
auto get_deployment_type() const { return deployment_type_; }
auto const& get_filepath() const { return filepath_; }
auto get_output_shape(std::string const& name) const
{
return shared_state_->get_output_shape(name);
}
protected:
auto get_shared_state() const { return shared_state_; }
private:
std::shared_ptr<SharedState> shared_state_;
device_id_t device_id_;
cudaStream_t default_stream_;
DeploymentType deployment_type_;
std::string filepath_;
};
} // namespace rapids
} // namespace backend
} // namespace triton
| 33.676768 | 94 | 0.707858 |
divyegala
|
3415954e216bb53928018e5951bfdded31f93395
| 9,872 |
cpp
|
C++
|
Engine/src/Core/IO/icFileWin.cpp
|
binofet/ice
|
dee91da76df8b4f46ed4727d901819d8d20aefe3
|
[
"MIT"
] | null | null | null |
Engine/src/Core/IO/icFileWin.cpp
|
binofet/ice
|
dee91da76df8b4f46ed4727d901819d8d20aefe3
|
[
"MIT"
] | null | null | null |
Engine/src/Core/IO/icFileWin.cpp
|
binofet/ice
|
dee91da76df8b4f46ed4727d901819d8d20aefe3
|
[
"MIT"
] | null | null | null |
#ifdef WIN32
#include "Core/IO/icFile.h"
/*! Function converts ICE file modes to Microsoft flags
*
* @param u8Mode 8-bit mask of ICFILEMODE flags
* @param[out] pAccess Pointer for access rights
* @param[out] pCreateD Pointer for creation disposition
* @param[out] pFandA Pointer for flags and attributes
**/
void _GetFileParams(uchar u8Mode, DWORD* pAccess, DWORD* pCreateD,
DWORD* pFandA)
{
*pAccess=0; *pFandA = 0;
if (u8Mode&ICFM_READ) *pAccess |= GENERIC_READ;
if (u8Mode&ICFM_WRITE) *pAccess |= GENERIC_WRITE;
if (u8Mode&ICFM_CREATE_ALWAYS) *pCreateD = CREATE_ALWAYS;
if (u8Mode&ICFM_CREATE_NEW) *pCreateD = CREATE_NEW;
if (u8Mode&ICFM_OPEN_ALWAYS) *pCreateD = OPEN_ALWAYS;
if (u8Mode&ICFM_OPEN_EXISTING) *pCreateD = OPEN_EXISTING;
if (u8Mode&ICFM_ASYNC) *pFandA |= FILE_FLAG_OVERLAPPED|FILE_FLAG_NO_BUFFERING;
}// END FUNCTION _GetFileParams(uchar u8Mode, DWORD* pAccess, DWORD* pCreateD)
/*! Asynchronous operation callback
*
*
* @param dwErrorCode Error flags
* @param dwBytesMoved The number of bytes transferred
* @param lpOverlapped The overlapped structure for async op
**/
VOID CALLBACK icFile::AsyncCB(__in DWORD dwErrorCode,
__in DWORD dwBytesMoved,
__in LPOVERLAPPED lpOverlapped)
{
if (lpOverlapped)
{
icFile* pFile = static_cast<icFile*>(lpOverlapped);
// check for errors
if (dwErrorCode)
{
// should probably take a look at better way to handle this
icWarning("There was an error returned from Async Operation");
}
pFile->m_u64FilePos += dwBytesMoved;
pFile->m_bStreaming = false;
// call user callback function with their pointer
if (pFile->m_pVoidCallback)
(*pFile->m_pVoidCallback)(pFile->m_ptrUser, (size_t)dwBytesMoved);
}
else
{
// this should likely never happen
icError("Undefined behavior in Asynchronous callback");
}
}
/*! c'tor
**/
icFile::icFile(void)
{
ZeroMemory(this,sizeof(icFile));
m_pFile = NULL;
m_ptrUser = NULL;
m_pVoidCallback = NULL;
m_u64FilePos = 0;
m_bStreaming = false;
}// END FUNCTION icFile(void)
/*! d'tor
**/
icFile::~icFile(void)
{
if (m_pFile)
{
StopAsync();
if (hEvent)
CloseHandle(hEvent);
CloseHandle(m_pFile);
}
}// END FUNCTION ~icFile(void)
/*! Opens a file
*
* @param szFile Name of file to open
* @param u8Mode File mode (read/write/etc)
* @returns ICRESULT Status after open
**/
ICRESULT icFile::Open(const char *szFile, uchar u8Mode)
{
Close();
DWORD dwAccess=0;
DWORD dwShareMode=FILE_SHARE_READ; //! should this be exposed?
DWORD dwCreateDisp=0;
DWORD dwFandA=0;
m_FileMode = u8Mode;
_GetFileParams(u8Mode, &dwAccess, &dwCreateDisp, &dwFandA);
m_pFile = CreateFileA(szFile, // LPCSTR
dwAccess, // Desired Access
dwShareMode, // Share Mode
NULL, // lpSecurityAttributes
dwCreateDisp, // Creation Disposition
dwFandA, // Flags and attributes
NULL); // HANDLE to template file
if (m_pFile && m_pFile != INVALID_HANDLE_VALUE)
return IC_OK;
return IC_FAIL_GEN;
}// END FUNCTION Open(const char* szFile, u
/*! Closes the file
*
* This will stall in the event there is an asynchronous operation
* still in progress.
*
* @returns ICRESULT Status after closing the file
**/
ICRESULT icFile::Close(void)
{
m_FileMode = 0;
m_ptrUser = NULL;
m_pVoidCallback = NULL;
m_u64FilePos = 0;
if (m_pFile)
{
// WAIT FOR ANY PENDING ASYNCHRONOUS CALLS
while (m_bStreaming)
SleepEx(50, TRUE);
if (hEvent)
{
CloseHandle(hEvent);
hEvent = NULL;
}
if (CloseHandle(m_pFile))
{
m_pFile = NULL;
return IC_OK;
}
m_pFile = NULL;
return IC_FAIL_GEN;
}
m_bStreaming = false;
return IC_OK;
}// END FUNCTION Close(void)
/*! Reads data from file
*
* Note: This should not be called by ASYNC File objects
*
* @param pDest Destination buffer
* @param size Size in bytes to read
* @param sizeread Pointer to store size actually read
* @returns ICRESULT Status after file read
**/
ICRESULT icFile::Read(void* pDest, size_t size, size_t* sizeread)
{
if (m_pFile && !(m_FileMode&ICFM_ASYNC))
{
if (ReadFile(m_pFile, pDest, size, (LPDWORD)sizeread, NULL))
{
m_u64FilePos += *sizeread;
return IC_OK;
}
}
return IC_WARN_GEN;
}// END FUNCTION Read(void* pDest, size_t size, size_t* sizeread)
/*! Asynchronous Read
*
*
*
* @param pDest Destination buffer
* @param size Size in bytes to read
* @param userPtr Pointer user can use as needed
* @param callback Function to call when read is finished
* @returns ICRESULT Status after starting the async-read
**/
ICRESULT icFile::ReadAsync(void* pDest, size_t size,
void* userPtr, void (*callback)(void*,size_t))
{
if (m_pFile && !m_bStreaming)
{
m_pVoidCallback = callback;
m_ptrUser = userPtr;
m_bStreaming = true;
hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
if (ReadFileEx(m_pFile, pDest, size,
(LPOVERLAPPED)this, AsyncCB))
return IC_OK;
m_bStreaming = false;
}
return IC_WARN_GEN;
}// END FUNCTION ReadAsync(void* pDest, size_t size, void (*callback)(void))
/*! Stops all Asynchronous operations
*
* @returns ICRESULT Status after stopping asynchronous ops
**/
ICRESULT icFile::StopAsync(void)
{
if (m_pFile && m_bStreaming)
{
if (CancelIo(m_pFile))
//if (CancelIoEx(m_pFile, this))
{
m_bStreaming = false;
return IC_OK;
}
}
return IC_WARN_GEN;
}// END FUNCTION StopRead(void)
/*! Writes data to a file
*
* @param pSource Pointer to data to be written to file
* @param size Size of data (in bytes) to write
* @param[out] sizewritten Size of data actually written to the file
* @returns ICRESULT Status after the file write
**/
ICRESULT icFile::Write(void* pSource, size_t size, size_t* sizewritten)
{
if (m_pFile && !(m_FileMode&ICFM_ASYNC))
{
if (WriteFile(m_pFile, pSource, (DWORD)size,
(LPDWORD)sizewritten, NULL))
{
m_u64FilePos += *sizewritten;
return IC_OK;
}
}
return IC_FAIL_GEN;
}// END FUNCTION Write(void* pSource, size_t size, size_t* sizewritten)
/*! Writes to a file asynchronously
*
* @param pSource Pointer to data to be written to file
* @param size Size of data (in bytes) to write
* @param userPtr Pointer for user to use in callback
* @param callback Function pointer for user callback
* @returns ICRESULT Status after the file write
**/
ICRESULT icFile::WriteAsync(void* pSource, size_t size,
void* userPtr, void (*callback)(void*,size_t))
{
if (m_pFile && !m_bStreaming)
{
m_pVoidCallback = callback;
m_ptrUser = userPtr;
m_bStreaming = true;
hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
if (WriteFileEx(m_pFile, pSource, (DWORD)size, (LPOVERLAPPED)this, AsyncCB))
{
FlushFileBuffers(m_pFile);
return IC_OK;
}
else
{
m_bStreaming = false;
DWORD err = GetLastError();
icWarningf("icFile::WriteAsync failed with error: %i",err);
}
}
return IC_FAIL_GEN;
}// END FUNCTION WriteAsync(void* pSource, size_t size,
// void* userPtr, void (*callback)(void*,size_t))
/*! Get File Size in bytes
*
* @param size Pointer to store file size
* @returns ICRESULT Status after getting size
**/
ICRESULT icFile::GetSize(uint64* size)
{
if (m_pFile)
{
DWORD high=0;
DWORD low = GetFileSize(m_pFile, &high);
// check fail condition
if (low != INVALID_FILE_SIZE)
{
*size = (uint64)low | (uint64)high<<32;
return IC_OK;
}
}
return IC_FAIL_GEN;
}// END FUNCTION GetSize(size_t* size)
/*! Get the current file position
*
*
* @param pos Pointer to store file position
* @returns ICRESULT Status after getting file position
**/
ICRESULT icFile::GetPos(uint64* pos)
{
if (m_pFile)
{
*pos = m_u64FilePos;
return IC_OK;
}
return IC_FAIL_GEN;
}// END FUNCTION GetPos(size_t* pos)
/*! Sets the file pointer
*
* @param pos Desired file position
* @returns ICRESULT Status after changing file position
**/
ICRESULT icFile::SetPos(const uint64 pos)
{
if (m_pFile)
{
#if 1
LARGE_INTEGER liPos;
liPos.QuadPart = pos;
if (SetFilePointerEx(m_pFile, liPos,
(PLARGE_INTEGER)&m_u64FilePos, FILE_BEGIN))
#else
long liPos = (long)pos;
if (SetFilePointer(m_pFile, liPos,
0, FILE_BEGIN))
#endif
return IC_OK;
}
::MessageBoxA(NULL, "Failed to set file position", "Shit Ballz", 0);
return IC_FAIL_GEN;
}// END FUNCTION SetPos(const uint64 pos)
#endif// ifdef WIN32
| 26.972678 | 84 | 0.588533 |
binofet
|
341f5f51dd2e5f71923d964fb9924d9f9a11bc08
| 18,473 |
cpp
|
C++
|
src/BCRext/BwtIndex.cpp
|
ndaniel/BEETL
|
4f35e2f6a18be624c1159f3ffe042eb8490f94bf
|
[
"BSD-2-Clause"
] | 53 |
2015-02-05T02:26:15.000Z
|
2022-01-13T05:37:06.000Z
|
src/BCRext/BwtIndex.cpp
|
ndaniel/BEETL
|
4f35e2f6a18be624c1159f3ffe042eb8490f94bf
|
[
"BSD-2-Clause"
] | 9 |
2015-09-03T23:42:14.000Z
|
2021-10-15T15:25:49.000Z
|
src/BCRext/BwtIndex.cpp
|
ndaniel/BEETL
|
4f35e2f6a18be624c1159f3ffe042eb8490f94bf
|
[
"BSD-2-Clause"
] | 23 |
2015-01-08T13:43:07.000Z
|
2021-05-19T17:35:42.000Z
|
/**
** Copyright (c) 2011-2014 Illumina, Inc.
**
** This file is part of the BEETL software package,
** covered by the "BSD 2-Clause License" (see accompanying LICENSE file)
**
** Citation: Markus J. Bauer, Anthony J. Cox and Giovanna Rosone
** Lightweight BWT Construction for Very Large String Collections.
** Proceedings of CPM 2011, pp.219-231
**
**/
#include "BwtIndex.hh"
#include "BwtReader.hh"
#include "libzoo/util/Logger.hh"
#include <algorithm>
#include <unistd.h>
#include <sys/types.h>
#ifndef DONT_USE_MMAP
# include <fcntl.h>
# include <sys/mman.h>
# include <sys/stat.h>
# include <sys/types.h>
#endif
using namespace std;
template< class T >
BwtReaderIndex<T>::BwtReaderIndex( const string &filename, const string &optionalSharedMemoryPath ):
T( filename ),
indexFilename_( filename + ".idx" ),
// isNextIndex_( false ),
pIndexFile_( NULL )
{
// current_.clear();
initIndex( optionalSharedMemoryPath );
}
template< class T >
void BwtReaderIndex<T>::rewindFile( void )
{
// rewind file and set all vars as per constructor
// current_.clear();
indexNext_ = 0;
// initIndex();
T::rewindFile();
} // ~rewindFile
template< class T >
LetterNumber BwtReaderIndex<T>::readAndCount( LetterCount &c, const LetterNumber numChars )
{
#ifdef DEBUG_RAC
std::cout << "BR RLI readAndCount " << numChars << " chars " << endl;
std::cout << "Before: " << currentPos_ << " " << ftell( T::pFile_ ) << " ";
std::cout << c << endl;;
#endif
LetterNumber charsLeft( numChars );
uint32_t indexLast;
#ifdef DEBUG_RAC
if ( indexNext_ != indexSize_ )
assert( currentPos_ <= indexPosBwt_[indexNext_] );
#endif
// gotcha: numChars can be set to maxLetterNumber so no expressions should
// add to it - wraparound issues!
// if indexLast==indexPosBwtSize we know we have gone past last index point
// or that none are present at all
if ( ( indexNext_ != indexSize_ )
&& ( numChars > ( indexPosBwt_[indexNext_] - T::currentPos_ ) ) )
{
// count interval spans at least one index point
// how many index points does the count interval span?
indexLast = indexNext_;
while ( ( indexLast != indexSize_ )
&& ( numChars > ( indexPosBwt_[indexLast] - T::currentPos_ ) ) )
{
indexLast++;
}
indexLast--;
if ( indexNext_ <= indexLast )
{
// more than one index point in count interval - can use index
if ( ! ( T::currentPos_ == 0 && charsLeft >= indexPosBwt_[indexNext_] ) )
charsLeft -= T::readAndCount( c, indexPosBwt_[indexNext_] - T::currentPos_ );
else
{
charsLeft -= indexPosBwt_[0];
c += indexCount_[0];
if ( indexNext_ == indexLast )
T::seek( indexPosFile_[0], indexPosBwt_[0] );
}
// assert(T::currentPos_==indexNext_);
if ( indexNext_ != indexLast )
{
charsLeft -= ( indexPosBwt_[indexLast] - indexPosBwt_[indexNext_] );
// update counts and also indexNext_
while ( ++indexNext_ <= indexLast )
{
c += indexCount_[indexNext_];
#ifdef DEBUG_RAC_VERBOSE
std::cout << indexNext_ << " " << indexPosBwt_[indexNext_] << " " << indexPosFile_[indexNext_] << " " << indexCount_[indexNext_] << endl;
#endif
} //
// skip to last index point and reset buffers
T::seek( indexPosFile_[indexLast], indexPosBwt_[indexLast] );
}
else
{
assert( T::currentPos_ == indexPosBwt_[indexLast] );
++indexNext_;
}
/*
T::runLength_ = 0;
T::pBuf_ = T::buf_ + ReadBufferSize;
T::pBufMax_ = T::buf_ + ReadBufferSize;
*/
} // if more than one index point
// if we're in this clause we've gone past at least one index
indexLast++;
assert( indexLast <= indexSize_ );
}
#ifdef DEBUG_RAC
std::cout << "After (RLI) skip: " << T::currentPos_ << " " << ftell( T::pFile_ ) << " " << c << endl;
#endif
// now read as normal until done
charsLeft -= T::readAndCount( c, charsLeft );
// assert(T::currentPos_==desiredPos);
#ifdef DEBUG_RAC
std::cout << "After (RLI) final read: " << T::currentPos_ << " " << ftell( T::pFile_ ) << " " << c << endl;
#endif
return ( numChars - charsLeft );
}
template< class T >
void BwtReaderIndex<T>::initIndex( const string &optionalSharedMemoryPath )
{
indexNext_ = 0;
bool useSharedMemory = !optionalSharedMemoryPath.empty();
string shmFilename1, shmFilename2, shmFilename3;
if ( useSharedMemory )
{
string filenameWithoutSlash = T::filename_;
std::replace( filenameWithoutSlash.begin(), filenameWithoutSlash.end(), '/', '_' );
shmFilename1 = optionalSharedMemoryPath + "/BeetlIndexPosFile_" + filenameWithoutSlash;
shmFilename2 = optionalSharedMemoryPath + "/BeetlIndexCount_" + filenameWithoutSlash;
shmFilename3 = optionalSharedMemoryPath + "/BeetlIndexPosBwt_" + filenameWithoutSlash;
if ( readWriteCheck( shmFilename1.c_str(), false, false ) )
{
// Load vectors from shared memory
{
cerr << "Info: Using mmap'ed index " << shmFilename1 << endl;
int fd = open( shmFilename1.c_str(), O_RDONLY );
assert( fd >= 0 );
off_t fileSize = lseek( fd, 0, SEEK_END );
lseek( fd, 0, SEEK_SET );
char *mmappedFile = ( char * )mmap( NULL, fileSize, PROT_READ, MAP_SHARED /*| MAP_LOCKED | MAP_POPULATE*/, fd, 0 );
if ( mmappedFile == ( void * ) - 1 )
{
perror( "Error: Map failed" );
assert( false );
}
indexSize_ = *reinterpret_cast<uint32_t *>( mmappedFile );
indexPosFile_ = reinterpret_cast<LetterNumber *>( mmappedFile + sizeof( indexSize_ ) );
close( fd );
}
{
int fd = open( shmFilename2.c_str(), O_RDONLY );
assert( fd >= 0 );
off_t fileSize = lseek( fd, 0, SEEK_END );
lseek( fd, 0, SEEK_SET );
char *mmappedFile = ( char * )mmap( NULL, fileSize, PROT_READ, MAP_SHARED /*| MAP_LOCKED | MAP_POPULATE*/, fd, 0 );
if ( mmappedFile == ( void * ) - 1 )
{
perror( "Error: Map failed" );
assert( false );
}
assert( indexSize_ == *reinterpret_cast<uint32_t *>( mmappedFile ) );
indexCount_ = reinterpret_cast<LETTER_COUNT_CLASS *>( mmappedFile + sizeof( indexSize_ ) );
close( fd );
}
{
int fd = open( shmFilename3.c_str(), O_RDONLY );
assert( fd >= 0 );
off_t fileSize = lseek( fd, 0, SEEK_END );
lseek( fd, 0, SEEK_SET );
char *mmappedFile = ( char * )mmap( NULL, fileSize, PROT_READ, MAP_SHARED /*| MAP_LOCKED | MAP_POPULATE*/, fd, 0 );
if ( mmappedFile == ( void * ) - 1 )
{
perror( "Error: Map failed" );
assert( false );
}
assert( indexSize_ == *reinterpret_cast<uint32_t *>( mmappedFile ) );
indexPosBwt_ = reinterpret_cast<LetterNumber *>( mmappedFile + sizeof( indexSize_ ) );
close( fd );
}
return;
}
}
LetterNumber currentPosBwt( 0 );
uint8_t unusedAlphabetEntries( 0 );
if ( pIndexFile_ != NULL ) fclose( pIndexFile_ );
pIndexFile_ = fopen( indexFilename_.c_str(), "r" );
if ( pIndexFile_ == NULL )
{
// Logger::error() << "Error opening index file " << indexFilename_;
// exit( -1 );
}
else
{
// read file header
bool isIndexV2 = false;
uint8_t sizeOfAlphabet = 0;
uint8_t sizeOfLetterNumber = 0;
uint16_t sizeOfLetterCountCompact = 0;
vector<char> buf( indexV1Header.size() );
fread( buf.data(), indexV1Header.size(), 1, pIndexFile_ );
if ( equal( buf.begin(), buf.end(), indexV1Header.begin() ) )
{
// index v1 detected
fread( &sizeOfAlphabet, sizeof( uint8_t ), 1, pIndexFile_ );
fread( &sizeOfLetterNumber, sizeof( uint8_t ), 1, pIndexFile_ );
fread( &sizeOfLetterCountCompact, sizeof( uint16_t ), 1, pIndexFile_ );
}
else if ( equal( buf.begin(), buf.end(), indexV2Header.begin() ) )
{
// index v2 detected
isIndexV2 = true;
fread( &sizeOfAlphabet, sizeof( uint8_t ), 1, pIndexFile_ );
fread( &sizeOfLetterNumber, sizeof( uint8_t ), 1, pIndexFile_ );
sizeOfLetterCountCompact = sizeof( LetterCountCompact ); // unused in index v2
}
else
{
// default value from previous header-less format
sizeOfAlphabet = 7;
sizeOfLetterNumber = 8;
sizeOfLetterCountCompact = 4*sizeOfAlphabet;
rewind( pIndexFile_ );
}
if ( sizeOfAlphabet > alphabetSize )
{
Logger::error() << "WARNING: Index file " << indexFilename_ << " was built with alphabetSize == " << (int)sizeOfAlphabet << " whereas the current tools are using alphabetSize == " << alphabetSize << ".\n => You should rebuild the index files with beetl-index (or rebuild the tools using the same data widths (specified in Types.hh))." << endl;
unusedAlphabetEntries = sizeOfAlphabet - alphabetSize;
}
else if ( sizeOfAlphabet < alphabetSize )
{
Logger::error() << "ERROR: Index file " << indexFilename_ << " was built with alphabetSize == " << (int)sizeOfAlphabet << " whereas the current tools are using alphabetSize == " << alphabetSize << ".\n => You should rebuild the index files with beetl-index (or rebuild the tools using the same data widths (specified in Types.hh))." << endl;
exit( -1 );
}
if ( sizeOfLetterNumber != sizeof( LetterNumber ) )
{
Logger::error() << "ERROR: Index file " << indexFilename_ << " was built with sizeof(LetterNumber) == " << (int)sizeOfLetterNumber << " whereas the current tools are using sizeof(LetterNumber) == " << sizeof( LetterNumber ) << ".\n => You should rebuild the index files with beetl-index (or rebuild the tools using the same data widths (specified in Types.hh))." << endl;
exit( -1 );
}
if ( sizeOfLetterCountCompact != sizeof( LetterCountCompact ) + 4 * unusedAlphabetEntries ) // allow 32 bits per unused entry to be automatically ignored
{
Logger::error() << "ERROR: Index file " << indexFilename_ << " was built with sizeof(LetterCountCompact) == " << sizeOfLetterCountCompact << " whereas the current tools are using sizeof(LetterCountCompact) == " << sizeof( LetterCountCompact ) << " + " << unusedAlphabetEntries << "unused alphabet entries.\n => You should rebuild the index files with beetl-index (or rebuild the tools using the same data widths (specified in Types.hh))." << endl;
exit( -1 );
}
indexPosFile0_.push_back( 0 );
while ( fread( &indexPosFile0_.back(), sizeof( LetterNumber ), 1, pIndexFile_ ) == 1 )
{
indexCount0_.push_back( LETTER_COUNT_CLASS() );
if (!isIndexV2)
{
// In Index v1, counts were always stored using compact 32 bits values, which now need to be scaled to LETTER_COUNT_CLASS
for (int i=0; i<alphabetSize; ++i)
{
assert ( fread( &indexCount0_.back().count_[i], sizeof( uint32_t ), 1, pIndexFile_ ) == 1 );
}
uint32_t unusedEntry;
for (int i=0; i<unusedAlphabetEntries; ++i)
{
assert ( fread( &unusedEntry, sizeof( uint32_t ), 1, pIndexFile_ ) == 1 );
}
}
else
{
for (int i=0; i<alphabetSize; ++i)
{
int byteCount;
assert ( fread( &byteCount, 1, 1, pIndexFile_ ) == 1 );
if (byteCount)
{
#ifdef USE_COMPACT_STRUCTURES
if ( byteCount > sizeof(LetterNumberCompact) )
{
Logger::error() << "ERROR: Index file " << indexFilename_ << " contains large values. BEETL needs to be built without USE_COMPACT_STRUCTURES in BwtIndex.hh." << endl;
exit( -1 );
}
#endif
assert ( fread( &indexCount0_.back().count_[i], byteCount, 1, pIndexFile_ ) == 1 );
}
}
}
for ( int i( 0 ); i < alphabetSize; i++ )
currentPosBwt += indexCount0_.back().count_[i];
indexPosBwt0_.push_back( currentPosBwt );
#ifdef DEBUG_RAC_VERBOSE
cout << indexPosBwt0_.back() << " " << indexPosFile0_.back() << " " << indexCount0_.back() << endl;
#endif
// skip unused alphabet entries, and check that they were indeed useless
for (int i=0; i<unusedAlphabetEntries; ++i)
{
uint32_t unusedEntry;
assert( fread( &unusedEntry, sizeof( uint32_t ), 1, pIndexFile_ ) == 1 );
assert( unusedEntry == 0 && "Error: Trying to ignore an index entry, which contains a non-zero value" );
}
indexPosFile0_.push_back( 0 );
} // ~while
indexPosFile0_.pop_back();
fclose( pIndexFile_ );
pIndexFile_ = NULL;
} // ~if
indexSize_ = indexPosBwt0_.size();
assert( indexSize_ == indexPosFile0_.size() );
assert( indexSize_ == indexCount0_.size() );
// rewindFile();
indexPosBwt_ = indexPosBwt0_.data();
indexPosFile_ = indexPosFile0_.data();
indexCount_ = indexCount0_.data();
// Save vectors to shared memory
if ( useSharedMemory && !indexPosBwt0_.empty() )
{
{
ofstream os( shmFilename1 );
if ( !os.good() )
{
cerr << "Error creating " << shmFilename1 << endl;
exit( -1 );
}
os.write( reinterpret_cast<const char *>( &indexSize_ ), sizeof( indexSize_ ) );
os.write( reinterpret_cast<const char *>( indexPosFile0_.data() ), indexSize_ * sizeof( indexPosFile0_[0] ) );
}
{
ofstream os( shmFilename2 );
os.write( reinterpret_cast<const char *>( &indexSize_ ), sizeof( indexSize_ ) );
os.write( reinterpret_cast<const char *>( indexCount0_.data() ), indexSize_ * sizeof( indexCount0_[0] ) );
}
{
ofstream os( shmFilename3 );
os.write( reinterpret_cast<const char *>( &indexSize_ ), sizeof( indexSize_ ) );
os.write( reinterpret_cast<const char *>( indexPosBwt0_.data() ), indexSize_ * sizeof( indexPosBwt0_[0] ) );
}
}
} // ~initIndex
// Index creation
void buildIndex( BwtReaderBase *reader0, FILE *pIndexFile, const int indexBinSize )
{
BwtReaderRunLengthBase *reader = dynamic_cast< BwtReaderRunLengthBase* >( reader0 );
const int runsPerChunk( indexBinSize );
int runsThisChunk( 0 );
LetterCount countsThisChunk;
LetterNumber runsSoFar( 0 ), chunksSoFar( 0 );
bool lastRun = false;
if (reader == NULL)
{
Logger::out() << "Warning: cannot index file " << reader0->filename_ << endl;
return;
}
reader->currentPos_ = 0;
// Write file header
assert( fwrite( indexV2Header.data(), indexV2Header.size(), 1, pIndexFile ) == 1 );
uint8_t sizeOfAlphabet = alphabetSize;
uint8_t sizeOfLetterNumber = sizeof( LetterNumber );
fwrite( &sizeOfAlphabet, sizeof( uint8_t ), 1, pIndexFile );
fwrite( &sizeOfLetterNumber, sizeof( uint8_t ), 1, pIndexFile );
while ( !lastRun )
{
lastRun = !reader->getRun();
if (!lastRun)
{
runsSoFar++;
runsThisChunk++;
countsThisChunk.count_[whichPile[reader->lastChar_]] += reader->runLength_;
assert( countsThisChunk.count_[whichPile[reader->lastChar_]] >= reader->runLength_ && "Error: Overflow in buildIndex" );
reader->currentPos_ += reader->runLength_;
}
if ( runsThisChunk == runsPerChunk || lastRun )
{
#ifdef DEBUG_RAC
cout << reader->currentPos_ << " " << runsSoFar << " " << countsThisChunk << endl;
#endif
// don't bother writing this as can deduce by summing countsThisChunk
// assert
// ( fwrite( &reader->currentPos_, sizeof( LetterNumber ), 1, pIndexFile ) == 1 );
LetterNumber posInFile = reader->tellg();
assert
( fwrite( &posInFile, sizeof( LetterNumber ), 1, pIndexFile ) == 1 );
// In index format v2, we write each LetterCount independently, encoding the number of bytes as first byte
for (int i=0; i<alphabetSize; ++i)
{
LetterNumber val = countsThisChunk.count_[i];
int bytesNeeded = 0;
while (val >> (8*bytesNeeded))
++bytesNeeded;
assert( fwrite( &bytesNeeded, 1, 1, pIndexFile ) == 1 );
if (bytesNeeded)
assert( fwrite( &val, bytesNeeded, 1, pIndexFile ) == 1 );
}
chunksSoFar++;
runsThisChunk = 0;
countsThisChunk.clear();
}
}
cout << "buildIndex: read " << reader->currentPos_ << " bases compressed into " << runsSoFar << " runs" << " over " << reader->tellg() << " bytes." << endl;
cout << "buildIndex: generated " << chunksSoFar << " index points." << endl;
} // ~buildIndex
// Explicit template instantiations
template class BwtReaderIndex<BwtReaderRunLength>;
template class BwtReaderIndex<BwtReaderRunLengthV3>;
| 40.158696 | 459 | 0.560494 |
ndaniel
|
3422fef3339e415cb49949b7f4aaa1d4da2b9efd
| 253 |
cpp
|
C++
|
Chapter7/Image/QtImageViewer/qtimageViewer.cpp
|
valeriyvan/LinuxProgrammingWithRaspberryPi
|
7c57afcf2cbfc8e0486c78aa75b361fd712a136f
|
[
"MIT"
] | 4 |
2020-03-11T13:38:25.000Z
|
2021-12-25T00:48:53.000Z
|
Chapter7/Image/QtImageViewer/qtimageViewer.cpp
|
valeriyvan/LinuxProgrammingWithRaspberryPi
|
7c57afcf2cbfc8e0486c78aa75b361fd712a136f
|
[
"MIT"
] | null | null | null |
Chapter7/Image/QtImageViewer/qtimageViewer.cpp
|
valeriyvan/LinuxProgrammingWithRaspberryPi
|
7c57afcf2cbfc8e0486c78aa75b361fd712a136f
|
[
"MIT"
] | 8 |
2020-07-10T22:02:05.000Z
|
2021-12-15T02:11:44.000Z
|
#include <QApplication>
#include <QLabel>
#include <QPixmap>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QLabel* lb = new QLabel("", 0);
lb->setPixmap(QPixmap("mandrill.jpg"));
lb->show();
return app.exec();
}
| 16.866667 | 43 | 0.620553 |
valeriyvan
|
34279a67e3c5d16a5ea26423c28bc022e6bc97f0
| 2,575 |
cpp
|
C++
|
src/Timer.cpp
|
JuanDiegoMontoya/g
|
57a4f44ddea0299e6c6f056592e0b126a67ed8ec
|
[
"MIT"
] | 2 |
2022-02-04T10:14:49.000Z
|
2022-03-01T23:45:22.000Z
|
src/Timer.cpp
|
JuanDiegoMontoya/g
|
57a4f44ddea0299e6c6f056592e0b126a67ed8ec
|
[
"MIT"
] | null | null | null |
src/Timer.cpp
|
JuanDiegoMontoya/g
|
57a4f44ddea0299e6c6f056592e0b126a67ed8ec
|
[
"MIT"
] | null | null | null |
#include <fwog/Common.h>
#include <fwog/Timer.h>
#include <numeric>
namespace Fwog
{
TimerQuery::TimerQuery()
{
glGenQueries(2, queries);
glQueryCounter(queries[0], GL_TIMESTAMP);
}
TimerQuery::~TimerQuery()
{
glDeleteQueries(2, queries);
}
uint64_t TimerQuery::GetTimestamp()
{
int complete = 0;
glQueryCounter(queries[1], GL_TIMESTAMP);
while (!complete) glGetQueryObjectiv(queries[1], GL_QUERY_RESULT_AVAILABLE, &complete);
uint64_t startTime, endTime;
glGetQueryObjectui64v(queries[0], GL_QUERY_RESULT, &startTime);
glGetQueryObjectui64v(queries[1], GL_QUERY_RESULT, &endTime);
std::swap(queries[0], queries[1]);
return endTime - startTime;
}
TimerQueryAsync::TimerQueryAsync(uint32_t N)
: capacity_(N)
{
FWOG_ASSERT(capacity_ > 0);
queries = new uint32_t[capacity_ * 2];
glGenQueries(capacity_ * 2, queries);
}
TimerQueryAsync::~TimerQueryAsync()
{
glDeleteQueries(capacity_ * 2, queries);
delete[] queries;
}
void TimerQueryAsync::BeginZone()
{
// begin a query if there is at least one inactive
if (count_ < capacity_)
{
glQueryCounter(queries[start_], GL_TIMESTAMP);
}
}
void TimerQueryAsync::EndZone()
{
// end a query if there is at least one inactive
if (count_ < capacity_)
{
glQueryCounter(queries[start_ + capacity_], GL_TIMESTAMP);
start_ = (start_ + 1) % capacity_; // wrap
count_++;
}
}
std::optional<uint64_t> TimerQueryAsync::PopTimestamp()
{
// return nothing if there is no active query
if (count_ == 0)
{
return std::nullopt;
}
// get the index of the oldest query
uint32_t index = (start_ + capacity_ - count_) % capacity_;
// getting the start result is a sanity check
GLint startResultAvailable{};
GLint endResultAvailable{};
glGetQueryObjectiv(queries[index], GL_QUERY_RESULT_AVAILABLE, &startResultAvailable);
glGetQueryObjectiv(queries[index + capacity_], GL_QUERY_RESULT_AVAILABLE, &endResultAvailable);
// the oldest query's result is not available, abandon ship!
if (startResultAvailable == GL_FALSE || endResultAvailable == GL_FALSE)
{
return std::nullopt;
}
// pop oldest timing and retrieve result
count_--;
uint64_t startTimestamp{};
uint64_t endTimestamp{};
glGetQueryObjectui64v(queries[index], GL_QUERY_RESULT, &startTimestamp);
glGetQueryObjectui64v(queries[index + capacity_], GL_QUERY_RESULT, &endTimestamp);
return endTimestamp - startTimestamp;
}
}
| 27.105263 | 99 | 0.683495 |
JuanDiegoMontoya
|
342bcc038a2ca98c01e7e47922a5267283c40560
| 1,295 |
hpp
|
C++
|
Includes/Rosetta/PlayMode/Logs/PlayHistory.hpp
|
Hearthstonepp/Hearthstonepp
|
ee17ae6de1ee0078dab29d75c0fbe727a14e850e
|
[
"MIT"
] | 62 |
2017-08-21T14:11:00.000Z
|
2018-04-23T16:09:02.000Z
|
Includes/Rosetta/PlayMode/Logs/PlayHistory.hpp
|
Hearthstonepp/Hearthstonepp
|
ee17ae6de1ee0078dab29d75c0fbe727a14e850e
|
[
"MIT"
] | 37 |
2017-08-21T11:13:07.000Z
|
2018-04-30T08:58:41.000Z
|
Includes/Rosetta/PlayMode/Logs/PlayHistory.hpp
|
Hearthstonepp/Hearthstonepp
|
ee17ae6de1ee0078dab29d75c0fbe727a14e850e
|
[
"MIT"
] | 10 |
2017-08-21T03:44:12.000Z
|
2018-01-10T22:29:10.000Z
|
// This code is based on Sabberstone project.
// Copyright (c) 2017-2019 SabberStone Team, darkfriend77 & rnilva
// RosettaStone is hearthstone simulator using C++ with reinforcement learning.
// Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon
#ifndef ROSETTASTONE_PLAYMODE_PLAY_HISTORY_HPP
#define ROSETTASTONE_PLAYMODE_PLAY_HISTORY_HPP
#include <Rosetta/PlayMode/Models/Playable.hpp>
namespace RosettaStone::PlayMode
{
//!
//! \brief PlayHistory struct.
//!
//! This struct holds all values for played card.
//!
struct PlayHistory
{
explicit PlayHistory(const Playable* source, const Playable* target,
int _turn, int _chooseOne)
{
sourcePlayer = source->player;
sourceCard = source->card;
sourceID = source->GetGameTag(GameTag::ENTITY_ID);
if (target)
{
targetPlayer = target->player;
targetCard = target->card;
}
turn = _turn;
chooseOne = _chooseOne;
}
Player* sourcePlayer = nullptr;
Player* targetPlayer = nullptr;
Card* sourceCard = nullptr;
Card* targetCard = nullptr;
int sourceID = -1;
int turn = -1;
int chooseOne = -1;
};
} // namespace RosettaStone::PlayMode
#endif // ROSETTASTONE_PLAYMODE_PLAY_HISTORY_HPP
| 26.979167 | 79 | 0.671815 |
Hearthstonepp
|
342bf1d0c337848387f546dbefaadabf6a466b8f
| 293 |
cpp
|
C++
|
BotPantela/Ball.cpp
|
djcvijic/BotPantela
|
174287e2b10cdd30d3217dd9c2ff766fcc93530d
|
[
"MIT"
] | null | null | null |
BotPantela/Ball.cpp
|
djcvijic/BotPantela
|
174287e2b10cdd30d3217dd9c2ff766fcc93530d
|
[
"MIT"
] | null | null | null |
BotPantela/Ball.cpp
|
djcvijic/BotPantela
|
174287e2b10cdd30d3217dd9c2ff766fcc93530d
|
[
"MIT"
] | null | null | null |
#include "Ball.h"
using namespace std;
void Ball::inputPos ()
{
double xPos;
double yPos;
cin >> xPos;
cin >> yPos;
setXPos(xPos);
setYPos(yPos);
}
void Ball::inputVel ()
{
double xVel;
double yVel;
cin >> xVel;
cin >> yVel;
setXVel(xVel);
setYVel(yVel);
}
| 12.73913 | 23 | 0.590444 |
djcvijic
|
3438f017a59ebe1f52a4e23ee50c1de8ea272471
| 3,224 |
hpp
|
C++
|
src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessHelicopter.hpp
|
uavosky/uavosky-px4
|
5793a7264a1400914521a077a7009dd227f9c766
|
[
"BSD-3-Clause"
] | 4,224 |
2015-01-02T11:51:02.000Z
|
2020-10-27T23:42:28.000Z
|
src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessHelicopter.hpp
|
uavosky/uavosky-px4
|
5793a7264a1400914521a077a7009dd227f9c766
|
[
"BSD-3-Clause"
] | 11,736 |
2015-01-01T11:59:16.000Z
|
2020-10-28T17:13:38.000Z
|
src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessHelicopter.hpp
|
uavosky/uavosky-px4
|
5793a7264a1400914521a077a7009dd227f9c766
|
[
"BSD-3-Clause"
] | 11,850 |
2015-01-02T14:54:47.000Z
|
2020-10-28T16:42:47.000Z
|
/****************************************************************************
*
* Copyright (c) 2022 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
#pragma once
#include "ActuatorEffectiveness.hpp"
#include <px4_platform_common/module_params.h>
class ActuatorEffectivenessHelicopter : public ModuleParams, public ActuatorEffectiveness
{
public:
static constexpr int NUM_SWASH_PLATE_SERVOS_MAX = 4;
static constexpr int NUM_CURVE_POINTS = 5;
struct SwashPlateGeometry {
float angle;
float arm_length;
};
struct Geometry {
SwashPlateGeometry swash_plate_servos[NUM_SWASH_PLATE_SERVOS_MAX];
int num_swash_plate_servos{0};
float throttle_curve[NUM_CURVE_POINTS];
float pitch_curve[NUM_CURVE_POINTS];
};
ActuatorEffectivenessHelicopter(ModuleParams *parent);
virtual ~ActuatorEffectivenessHelicopter() = default;
bool getEffectivenessMatrix(Configuration &configuration, EffectivenessUpdateReason external_update) override;
const char *name() const override { return "Helicopter"; }
const Geometry &geometry() const { return _geometry; }
void updateSetpoint(const matrix::Vector<float, NUM_AXES> &control_sp, int matrix_index,
ActuatorVector &actuator_sp) override;
private:
void updateParams() override;
struct ParamHandlesSwashPlate {
param_t angle;
param_t arm_length;
};
struct ParamHandles {
ParamHandlesSwashPlate swash_plate_servos[NUM_SWASH_PLATE_SERVOS_MAX];
param_t num_swash_plate_servos;
param_t throttle_curve[NUM_CURVE_POINTS];
param_t pitch_curve[NUM_CURVE_POINTS];
};
ParamHandles _param_handles{};
Geometry _geometry{};
int _first_swash_plate_servo_index{};
};
| 35.822222 | 111 | 0.743797 |
uavosky
|
343973ee233f02e5296e9d3f81ba60df5cdf46c0
| 2,604 |
cpp
|
C++
|
src/RawlogHelper.cpp
|
dzunigan/extrinsic_calib
|
aec3747aeb6baecc7bc6202fc0832a113a1bc528
|
[
"BSD-3-Clause"
] | 5 |
2018-10-24T02:14:54.000Z
|
2019-05-11T12:36:01.000Z
|
src/RawlogHelper.cpp
|
dzunigan/extrinsic_calib
|
aec3747aeb6baecc7bc6202fc0832a113a1bc528
|
[
"BSD-3-Clause"
] | null | null | null |
src/RawlogHelper.cpp
|
dzunigan/extrinsic_calib
|
aec3747aeb6baecc7bc6202fc0832a113a1bc528
|
[
"BSD-3-Clause"
] | 1 |
2021-06-30T01:12:49.000Z
|
2021-06-30T01:12:49.000Z
|
#include "RawlogHelper.hpp"
//MRPT redefinition so they work without using mrpt namepase (more general)
#ifndef CLASS_ID_
#define CLASS_ID_(class_name, space_name) static_cast<const mrpt::utils::TRuntimeClassId*>(&space_name::class_name::class##class_name)
#endif
#ifndef IS_CLASS_
#define IS_CLASS_( ptrObj, class_name, space_name ) ((ptrObj)->GetRuntimeClass()==CLASS_ID_(class_name, space_name))
#endif
//STL
#include <cmath>
//MRPT
#include <mrpt/system/datetime.h>
//Debug
#include <iostream>
RawlogHelper::RawlogHelper(const ParametersPtr ¶ms)
: n(0), m(0), last_obs() //last_obs is a null pointer (default constructor)
{
max_time_diff = params->max_time_diff;
verbose = params->verbose;
rawlog.loadFromRawLogFile(params->rawlog_file);
}
bool RawlogHelper::getNextObservation(mrpt::obs::CObservation3DRangeScanPtr &obs)
{
mrpt::obs::CObservationPtr observation;
while (!this->hasFinished())
{
//1. Get observation from rawlog
observation = rawlog.getAsObservation(n);
n++;
if (verbose)
std::cout << "RawlogHelper: entry " << n << " (" << rawlog.size()+1 << ")" << std::endl;
if(!observation || !IS_CLASS_(observation, CObservation3DRangeScan, mrpt::obs))
{
if (verbose)
std::cout << "Skipping rawlog entry " << (n-1) << "... (not valid CObservation3DRangeScan)" << std::endl;
continue;
}
obs = (mrpt::obs::CObservation3DRangeScanPtr) observation;
last_obs = obs;
return true;
}
return false;
}
bool RawlogHelper::getNextPair(ObservationPair &obs2)
{
//Handle first call
if (!last_obs)
if (!this->getNextObservation(last_obs)) return false;
do
{
obs2.first = last_obs;
if (!this->getNextObservation(obs2.second)) return false;
if (verbose)
{
std::cout << obs2.first->sensorLabel << ": " << obs2.first->timestamp << std::endl;
std::cout << obs2.second->sensorLabel << ": " << obs2.second->timestamp << std::endl;
}
if (obs2.first->sensorLabel.compare(obs2.second->sensorLabel) != 0)
m++;
} while ((obs2.first->sensorLabel.compare(obs2.second->sensorLabel) == 0) ||
(std::abs(mrpt::system::timeDifference(obs2.first->timestamp, obs2.second->timestamp))) > max_time_diff);
//abs shouldn't be needed, but it also doesn't harm...
if (verbose) std::cout << "Synch" << std::endl;
return true;
}
bool RawlogHelper::hasFinished()
{
return (n >= rawlog.size());
}
| 28 | 138 | 0.630184 |
dzunigan
|
34407b0deadf3a5daf2ecf83f8962faca98e3f7c
| 828 |
hpp
|
C++
|
01_src/compontents/components.hpp
|
gledr/SMT_MacroPlacer
|
b5b25f0ce9094553167ffd4985721f86414ceddc
|
[
"MIT"
] | 3 |
2020-06-05T15:33:30.000Z
|
2021-05-03T07:34:15.000Z
|
01_src/compontents/components.hpp
|
gledr/SMT_MacroPlacer
|
b5b25f0ce9094553167ffd4985721f86414ceddc
|
[
"MIT"
] | null | null | null |
01_src/compontents/components.hpp
|
gledr/SMT_MacroPlacer
|
b5b25f0ce9094553167ffd4985721f86414ceddc
|
[
"MIT"
] | 1 |
2021-05-03T07:34:17.000Z
|
2021-05-03T07:34:17.000Z
|
//==================================================================
// Author : Pointner Sebastian
// Company : Johannes Kepler University
// Name : SMT Macro Placer
// Workfile : components.hpp
//
// Date : 19. May 2020
// Compiler : gcc version 9.3.0 (GCC)
// Copyright : Johannes Kepler University
// Description : Include Header for all Components
//==================================================================
#ifndef COMPONENTS_HPP
#define COMPONENTS_HPP
#include <cell.hpp>
#include <component.hpp>
#include <macro.hpp>
#include <macro_definition.hpp>
#include <partition.hpp>
#include <pin.hpp>
#include <pin_definition.hpp>
#include <supplementmacro.hpp>
#include <supplementpin.hpp>
#include <terminal.hpp>
#include <terminal_definition.hpp>
#endif /* COMPONENTS_HPP */
| 29.571429 | 68 | 0.588164 |
gledr
|
451ec556f9b2d36764908afcb2fcad82f82ed0d8
| 4,619 |
cpp
|
C++
|
windows/cpp/samples/hw_enc_avc_intel_file/hw_enc_avc_intel_file.cpp
|
avblocks/avblocks-samples
|
7388111a27c8110a9f7222e86e912fe38f444543
|
[
"MIT"
] | 1 |
2022-02-28T04:12:09.000Z
|
2022-02-28T04:12:09.000Z
|
windows/cpp/samples/hw_enc_avc_intel_file/hw_enc_avc_intel_file.cpp
|
avblocks/avblocks-samples
|
7388111a27c8110a9f7222e86e912fe38f444543
|
[
"MIT"
] | null | null | null |
windows/cpp/samples/hw_enc_avc_intel_file/hw_enc_avc_intel_file.cpp
|
avblocks/avblocks-samples
|
7388111a27c8110a9f7222e86e912fe38f444543
|
[
"MIT"
] | 1 |
2022-02-28T02:43:24.000Z
|
2022-02-28T02:43:24.000Z
|
/*
* Copyright (c) 2016 Primo Software. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
*/
#include "stdafx.h"
#include "util.h"
#include "options.h"
using namespace primo::codecs;
using namespace primo::avblocks;
using namespace std;
class stdout_utf16
{
public:
stdout_utf16()
{
// change stdout to Unicode. Cyrillic and Ideographic characters will appear in the console (console font is unicode).
_setmode(_fileno(stdout), _O_U16TEXT);
}
~stdout_utf16()
{
// restore ANSI mode
_setmode(_fileno(stdout), _O_TEXT);
}
};
void printStatus(const wchar_t* action, const primo::error::ErrorInfo* e)
{
if (action)
{
wcout << action << L": ";
}
if (primo::error::ErrorFacility::Success == e->facility())
{
wcout << L"Success" << endl;
return;
}
if (e->message())
{
wcout << e->message() << L", ";
}
wcout << L"facility:" << e->facility() << L", error:" << e->code() << endl;
}
bool isHardwareEncoderAvailable(primo::codecs::HwVendor::Enum vendor, primo::codecs::HwCodecType::Enum type)
{
primo::ref<Hardware> hw(Library::createHardware());
hw->refresh();
for (int i = 0; i < hw->devices()->count(); ++i)
{
HwDevice* device = hw->devices()->at(i);
if (device->vendor() == vendor)
{
for (int j = 0; j < device->codecs()->count(); ++j)
{
if (device->codecs()->at(j)->type() == type)
return true;
}
}
}
return false;
}
primo::ref<MediaSocket> createInputSocket(Options& opt)
{
auto socket = primo::make_ref(Library::createMediaSocket());
socket->setStreamType(StreamType::UncompressedVideo);
socket->setFile(opt.yuv_file.c_str());
auto pin = primo::make_ref(Library::createMediaPin());
socket->pins()->add(pin.get());
auto vsi = primo::make_ref(Library::createVideoStreamInfo());
pin->setStreamInfo(vsi.get());
vsi->setStreamType(StreamType::UncompressedVideo);
vsi->setFrameWidth(opt.frame_size.width_);
vsi->setFrameHeight(opt.frame_size.height_);
vsi->setColorFormat(opt.yuv_color.Id);
vsi->setFrameRate(opt.fps);
vsi->setScanType(ScanType::Progressive);
return socket;
}
primo::ref<MediaSocket> createOutputSocket(Options& opt)
{
auto socket = primo::make_ref(Library::createMediaSocket());
socket->setFile(opt.h264_file.c_str());
socket->setStreamType(StreamType::H264);
socket->setStreamSubType(StreamSubType::AVC_Annex_B);
auto pin = primo::make_ref(Library::createMediaPin());
socket->pins()->add(pin.get());
auto vsi = primo::make_ref(Library::createVideoStreamInfo());
pin->setStreamInfo(vsi.get());
pin->params()->addInt(Param::HardwareEncoder, HardwareEncoder::Intel);
vsi->setStreamType(StreamType::H264);
vsi->setStreamSubType(StreamSubType::AVC_Annex_B);
return socket;
}
bool encode(Options& opt)
{
auto inSocket = createInputSocket(opt);
// create output socket
auto outSocket = createOutputSocket(opt);
// create transcoder
auto transcoder = primo::make_ref(Library::createTranscoder());
transcoder->setAllowDemoMode(TRUE);
transcoder->inputs()->add(inSocket.get());
transcoder->outputs()->add(outSocket.get());
// transcoder will fail if output exists (by design)
deleteFile(opt.h264_file.c_str());
bool_t res = transcoder->open();
printStatus(L"Transcoder open:", transcoder->error());
if(!res)
return false;
res = transcoder->run();
printStatus(L"Transcoder run:", transcoder->error());
if(!res)
return false;
transcoder->close();
printStatus(L"Transcoder close:", transcoder->error());
return true;
}
int wmain(int argc, wchar_t* argv[])
{
Options opt;
switch(prepareOptions( opt, argc, argv))
{
case Command: return 0;
case Error: return 1;
}
Library::initialize();
if (!isHardwareEncoderAvailable(primo::codecs::HwVendor::Intel, primo::codecs::HwCodecType::H264Encoder))
{
wcout << "Intel H.264 hardware encoder is not available on your system" << endl;
return 0;
}
bool result = encode(opt);
Library::shutdown();
return result ? 0 : 1;
}
| 26.394286 | 127 | 0.606841 |
avblocks
|
452178ec8ad3cabe4e642fbe06772ac6f04cd837
| 6,590 |
cpp
|
C++
|
sg/importer/Importer.cpp
|
ospray/ospray_studio
|
1549ac72c7c561b4aafdea976189bbe95bd32ff2
|
[
"Apache-2.0"
] | 52 |
2018-10-09T23:56:32.000Z
|
2022-03-25T09:27:40.000Z
|
sg/importer/Importer.cpp
|
ospray/ospray_studio
|
1549ac72c7c561b4aafdea976189bbe95bd32ff2
|
[
"Apache-2.0"
] | 11 |
2018-11-19T18:51:47.000Z
|
2022-03-28T14:03:57.000Z
|
sg/importer/Importer.cpp
|
ospray/ospray_studio
|
1549ac72c7c561b4aafdea976189bbe95bd32ff2
|
[
"Apache-2.0"
] | 8 |
2019-02-10T00:16:24.000Z
|
2022-02-17T19:50:15.000Z
|
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include "Importer.h"
#include "sg/visitors/PrintNodes.h"
#include "../JSONDefs.h"
namespace ospray {
namespace sg {
OSPSG_INTERFACE std::map<std::string, std::string> importerMap = {
{"obj", "importer_obj"},
{"gltf", "importer_gltf"},
{"glb", "importer_gltf"},
{"raw", "importer_raw"},
{"structured", "importer_raw"},
{"spherical", "importer_raw"},
{"vdb", "importer_vdb"},
{"pcd", "importer_pcd"},
{"pvol", "importer_pvol"}};
Importer::Importer() {}
NodeType Importer::type() const
{
return NodeType::IMPORTER;
}
void Importer::importScene() {
}
OSPSG_INTERFACE void importScene(
std::shared_ptr<StudioContext> context, rkcommon::FileName &sceneFileName)
{
std::cout << "Importing a scene" << std::endl;
context->filesToImport.clear();
std::ifstream sgFile(sceneFileName.str());
if (!sgFile) {
std::cerr << "Could not open " << sceneFileName << " for reading"
<< std::endl;
return;
}
JSON j;
sgFile >> j;
std::map<std::string, JSON> jImporters;
sg::NodePtr lights;
// If the sceneFile contains a world (importers and lights), parse it here
// (must happen before refreshScene)
if (j.contains("world")) {
auto &jWorld = j["world"];
for (auto &jChild : jWorld["children"]) {
// Import either the old-type enum directly, or the new-type enum STRING
NodeType nodeType = jChild["type"].is_string()
? NodeTypeFromString[jChild["type"]]
: jChild["type"].get<NodeType>();
switch (nodeType) {
case NodeType::IMPORTER: {
FileName fileName = std::string(jChild["filename"]);
// Try a couple different paths to find the file before giving up
std::vector<std::string> possibleFileNames = {fileName, // as imported
sceneFileName.path() + fileName.base(), // in scenefile directory
fileName.base(), // in local directory
""};
for (auto tryFile : possibleFileNames) {
if (tryFile != "") {
std::ifstream f(tryFile);
if (f.good()) {
context->filesToImport.push_back(tryFile);
jImporters[jChild["name"]] = jChild;
break;
}
} else
std::cerr << "Unable to find " << fileName << std::endl;
}
} break;
case NodeType::LIGHTS:
// Handle lights in either the (world) or the lightsManager
lights = createNodeFromJSON(jChild);
break;
default:
break;
}
}
}
// refreshScene imports all filesToImport
if (!context->filesToImport.empty())
context->refreshScene(true);
// Any lights in the scenefile World are added here
if (lights) {
for (auto &light : lights->children())
context->lightsManager->addLight(light.second);
}
// If the sceneFile contains a lightsManager, add those lights here
if (j.contains("lightsManager")) {
auto &jLights = j["lightsManager"];
for (auto &jLight : jLights["children"])
context->lightsManager->addLight(createNodeFromJSON(jLight));
}
// If the sceneFile contains materials, parse them here, after the model has
// loaded. These parameters will overwrite materials in the model file.
if (j.contains("materialRegistry")) {
sg::NodePtr materials = createNodeFromJSON(j["materialRegistry"]);
for (auto &mat : materials->children()) {
// XXX temporary workaround. Just set params on existing materials.
// Prevents loss of texture data. Will be fixed when textures can reload.
// Modify existing material or create new material
// (account for change of material type)
if (context->baseMaterialRegistry->hasChild(mat.first)
&& context->baseMaterialRegistry->child(mat.first).subType()
== mat.second->subType()) {
auto &bMat = context->baseMaterialRegistry->child(mat.first);
for (auto ¶m : mat.second->children()) {
auto &p = *param.second;
// This is a generated node value and can't be imported
if (param.first == "handles")
continue;
// Modify existing param or create new params
if (bMat.hasChild(param.first))
bMat[param.first] = p.value();
else
bMat.createChild(
param.first, p.subType(), p.description(), p.value());
}
} else
context->baseMaterialRegistry->add(mat.second);
}
// refreshScene imports all filesToImport and updates materials
context->refreshScene(true);
}
// If the sceneFile contains a camera location
// (must happen after refreshScene)
if (j.contains("camera")) {
CameraState cs = j["camera"];
context->setCameraState(cs);
context->updateCamera();
}
// after import, correctly apply transform import nodes
// (must happen after refreshScene)
auto world = context->frame->childNodeAs<sg::Node>("world");
for (auto &jImport : jImporters) {
// lamdba, find node by name
std::function<sg::NodePtr(const sg::NodePtr, const std::string &)>
findFirstChild = [&findFirstChild](const sg::NodePtr root,
const std::string &name) -> sg::NodePtr {
sg::NodePtr found = nullptr;
// Quick shallow top-level search first
for (auto child : root->children())
if (child.first == name)
return child.second;
// Next level, deeper search if not found
for (auto child : root->children()) {
found = findFirstChild(child.second, name);
if (found)
return found;
}
return found;
};
auto importNode = findFirstChild(world, jImport.first);
if (importNode) {
// should be associated xfm node
auto childName = jImport.second["children"][0]["name"];
Node &xfmNode = importNode->child(childName);
// XXX parse JSON to get RST transforms saved to sg file. This is
// temporary. We will want RST to be a first-class citizen node that gets
// handled correctly without this kind of hardcoded workaround
auto child = createNodeFromJSON(jImport.second["children"][0]);
if (child) {
xfmNode = child->value(); // assigns base affine3f value
xfmNode.add(child->child("rotation"));
xfmNode.add(child->child("translation"));
xfmNode.add(child->child("scale"));
}
}
}
}
// global assets catalogue
AssetsCatalogue cat;
} // namespace sg
} // namespace ospray
| 31.5311 | 80 | 0.619272 |
ospray
|
452da6fe4e6d905249e89e7673f85c4a1a11cda2
| 774 |
cpp
|
C++
|
Miscellaneous/InterviewBit/Array/RotateImage.cpp
|
chirag-singhal/-Data-Structures-and-Algorithms
|
9f01b5cc0f382ed59bcd74444a0be1c3aa6cd1a3
|
[
"MIT"
] | 24 |
2021-02-09T17:59:54.000Z
|
2022-03-11T07:30:38.000Z
|
Miscellaneous/InterviewBit/Array/RotateImage.cpp
|
chirag-singhal/-Data-Structures-and-Algorithms
|
9f01b5cc0f382ed59bcd74444a0be1c3aa6cd1a3
|
[
"MIT"
] | null | null | null |
Miscellaneous/InterviewBit/Array/RotateImage.cpp
|
chirag-singhal/-Data-Structures-and-Algorithms
|
9f01b5cc0f382ed59bcd74444a0be1c3aa6cd1a3
|
[
"MIT"
] | 3 |
2021-06-22T03:09:49.000Z
|
2022-03-09T18:25:14.000Z
|
#include <bits/stdc++.h>
void rotate(std::vector<std::vector<int> > &A) {
// Do not write main() function.
// Do not read input, instead use the arguments to the function.
// Do not print the output, instead return values as specified
// Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details
for(int i = 0; i < A.size() / 2; i++) {
for(int j = i; j < A.size() - i - 1; j++) {
int temp = A[i][j];
A[i][j] = A[A.size() - 1 - j][i];
A[A.size() - j - 1][i] = A[A.size() - 1 - i][A.size() - j - 1];
A[A.size() - 1 - i][A.size() - j - 1] = A[j][A.size() - i - 1];
A[j][A.size() - i - 1] = temp;
}
}
}
| 35.181818 | 93 | 0.459948 |
chirag-singhal
|
452ee43e21aafb068418cfb57dfdab51a06eee65
| 2,784 |
cpp
|
C++
|
benchmark/demo_benchmark.cpp
|
Algorithms-and-Data-Structures-2021/semester-work-median
|
a3592c0af93f562ea8f60e2301e5f21d1edbda0e
|
[
"MIT"
] | null | null | null |
benchmark/demo_benchmark.cpp
|
Algorithms-and-Data-Structures-2021/semester-work-median
|
a3592c0af93f562ea8f60e2301e5f21d1edbda0e
|
[
"MIT"
] | null | null | null |
benchmark/demo_benchmark.cpp
|
Algorithms-and-Data-Structures-2021/semester-work-median
|
a3592c0af93f562ea8f60e2301e5f21d1edbda0e
|
[
"MIT"
] | null | null | null |
#include <fstream> // ifstream
#include <iostream> // cout
#include <string> // string, stoi
#include <string_view> // string_view
#include <chrono> // high_resolution_clock, duration_cast, nanoseconds
#include <sstream> // stringstream
#include <vector>
// подключаем алгоритм
#include "algorithm.hpp"
using namespace std;
// абсолютный путь до набора данных и папки проекта
static constexpr auto kDatasetPath = string_view{PROJECT_DATASET_DIR};
static constexpr auto kProjectPath = string_view{PROJECT_SOURCE_DIR};
//Путь к папке с наборами данных для заполнения
const string setsPath = "C:/Users/Admin/Desktop/sets";
// Сгенирировать наборы даннх : https://github.com/rthoor/generation.git
//укажите названия папок с наборами данных, если они есть
string folders[5] = {"/01/","/02/","/03/","/04/","/05/"};
//если их нет
//string folders[1] = {"/"};
//укажите названия файлов с наборами данных (без .csv)
string files[8] = {"11", "51", "101", "501", "1001", "5001", "10001", "50001"};
//Путь к папке, куда нужно выгрузить результаты
const string outputPath = "C:/Users/Admin/Desktop/results/";
// Ознакомтесь с директорией "results-path-example/results"
// в папке выгруза результатов нужно будет реализовать похожую структуру,
// опираясь на названия файлов в массиве files
// -----------------------------------
// запускать main() (в самом низу) |
// -----------------------------------
//Вывод результатов
void writeResults(string file, long time) {
// вывод результата
// не забудьте подготовить директорию
std::ofstream out(outputPath + file + "/results.txt", std::ios::app);
if (out.is_open()) {
out << time << std::endl;
}
out.close();
}
void goTest() {
for (auto file : files) {
for (auto folder : folders) {
for (int i = 0; i < 10; i++) { // i = сколько раз прогоняем один и тот же csv файл
auto input_file = ifstream(setsPath + folder + file + ".csv");
string line;
// Создание структуры
vector<int> array;
// добавление
while (getline(input_file, line, ',')) {
array.push_back(stoi(line));
}
auto time_point_before = chrono::steady_clock::now();
itis::quickselect(array);
auto time_point_after = chrono::steady_clock::now();
auto time_diff_insert = time_point_after - time_point_before;
long time = chrono::duration_cast<chrono::nanoseconds>(time_diff_insert).count();
array.clear();
// запись результатов
writeResults(file, time);
}
}
}
}
int main() {
goTest();
return 0;
}
| 32 | 97 | 0.600575 |
Algorithms-and-Data-Structures-2021
|
45310c3ba8f1aa569b5c663e734e95570828b415
| 2,128 |
cpp
|
C++
|
Shared Classes/Stats.cpp
|
Mertank/ToneArm
|
40c62b0de89ac506bea6674e43578bf4e2631f93
|
[
"Zlib",
"BSD-2-Clause"
] | null | null | null |
Shared Classes/Stats.cpp
|
Mertank/ToneArm
|
40c62b0de89ac506bea6674e43578bf4e2631f93
|
[
"Zlib",
"BSD-2-Clause"
] | null | null | null |
Shared Classes/Stats.cpp
|
Mertank/ToneArm
|
40c62b0de89ac506bea6674e43578bf4e2631f93
|
[
"Zlib",
"BSD-2-Clause"
] | null | null | null |
/*
------------------------------------------------------------------------------------------
Copyright (c) 2014 Vinyl Games Studio
Author: Mikhail Kutuzov
Date: 10/7/2014 5:45:48 PM
------------------------------------------------------------------------------------------
*/
#include "Stats.h"
#include "Effect.h"
using namespace merrymen;
//
// handles application of the effect
//
void Stats::ApplyEffect(const Effect& effect, vgs::GameObject* const author) {
Effect* appliedEffect = new Effect(effect);
// add the effect to the list of applied effects
AppliedEffects.insert(std::pair<Effect*, vgs::GameObject*>(appliedEffect, author));
}
//
// cancels one of the applied effects
//
void Stats::UnapplyEffect(Effect* const effect, vgs::GameObject* const author) {
// remove the effect from the list of applied effects
AppliedEffects.erase(effect);
delete effect;
}
//
// returns all of the effects applied to the stats which match the passed type
//
std::vector<Effect*> Stats::GetAppliedEffectsOfType(const SpecificEffectType& type) {
std::vector<Effect*> result;
for (auto effect : AppliedEffects) {
SpecificEffectType effectType = SpecificEffectType(effect.first->Type, effect.first->Reason);
if (effectType == type) {
result.push_back(effect.first);
}
}
return result;
}
//
// returns all of the effects of the same type as the passed effect, which are applied to the stats
//
std::vector<Effect*> Stats::GetSimilarAppliedEffects(const Effect& effect) {
std::vector<Effect*> result;
SpecificEffectType effectType = SpecificEffectType(effect.Type, effect.Reason);
for (auto appliedEffect : AppliedEffects) {
SpecificEffectType appliedEfectType = SpecificEffectType(appliedEffect.first->Type, appliedEffect.first->Reason);
if (effectType == appliedEfectType) {
result.push_back(appliedEffect.first);
}
}
return result;
}
//
// cound the number of effects of the same type as the passed effect, which are applied to the stats
//
int Stats::CountSimilarAppliedEffects(const Effect& effect) {
return GetSimilarAppliedEffects(effect).size();
}
| 25.035294 | 115 | 0.670583 |
Mertank
|
4536e307f42d425866f3d9ad9020706f0477068b
| 3,190 |
cpp
|
C++
|
vec3f.cpp
|
ei14/qecvec
|
e097d0a205889ec65362992c4171ae535bc113a5
|
[
"MIT"
] | null | null | null |
vec3f.cpp
|
ei14/qecvec
|
e097d0a205889ec65362992c4171ae535bc113a5
|
[
"MIT"
] | null | null | null |
vec3f.cpp
|
ei14/qecvec
|
e097d0a205889ec65362992c4171ae535bc113a5
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2021 Thomas Kaldahl
#include "qecvec.hpp"
// Constructors
Vec3f::Vec3f(
float x,
float y,
float z
) {
this->x = x;
this->y = y;
this->z = z;
}
Vec3f::Vec3f(float val) : Vec3f(val, val, val) {}
Vec3f::Vec3f() : Vec3f(0) {}
Vec3f::Vec3f(Vec2f v, float z) : Vec3f(v.x, v.y, z) {}
Vec3f::Vec3f(float x, Vec2f v) : Vec3f(x, v.x, v.y) {}
// Statics
Vec3f Vec3f::zero() {return Vec3f();}
Vec3f Vec3f::up() {return Vec3f( 0, 1, 0 );}
Vec3f Vec3f::down() {return Vec3f( 0, -1, 0 );}
Vec3f Vec3f::left() {return Vec3f( -1, 0, 0 );}
Vec3f Vec3f::right() {return Vec3f( 1, 0, 0 );}
Vec3f Vec3f::forward() {return Vec3f( 0, 0, 1 );}
Vec3f Vec3f::backward() {return Vec3f( 0, 0, -1 );}
//vec2f.cpp: Vec2f Vec2f::up() {return Vec2f( 0, 1 );}
//vec2f.cpp: Vec2f Vec2f::down() {return Vec2f( 0, -1 );}
//vec2f.cpp: Vec2f Vec2f::left() {return Vec2f( -1, 0 );}
//vec2f.cpp: Vec2f Vec2f::right() {return Vec2f( 1, 0 );}
//vec2f.cpp: Vec2f Vec2f::polar(float r, float theta) {
//vec2f.cpp: return Vec2f(r * cos(theta), r * sin(theta));
//vec2f.cpp: }
Vec3f Vec3f::randomUniform(float min, float max) {
float x = (max - min) * rand() / (float)RAND_MAX + min;
float y = (max - min) * rand() / (float)RAND_MAX + min;
float z = (max - min) * rand() / (float)RAND_MAX + min;
return Vec3f(x, y, z);
}
// Accessors
char *Vec3f::string() const {
char *res = (char*)malloc(64);
snprintf(res, 64, "< %0.3f, %0.3f, %0.3f >", x, y, z);
return res;
}
Vec2f Vec3f::xy() const {return Vec2f(x, y);}
Vec2f Vec3f::xz() const {return Vec2f(x, z);}
Vec2f Vec3f::yz() const {return Vec2f(y, z);}
// Technical methods
Vec3f Vec3f::copy() const {
return Vec3f(x, y, z);
}
// In-place operations
Vec3f Vec3f::operator*=(float scalar) {
x *= scalar;
y *= scalar;
z *= scalar;
return *this;
}
Vec3f Vec3f::operator/=(float divisor) {
x /= divisor;
y /= divisor;
z /= divisor;
return *this;
}
Vec3f Vec3f::operator+=(Vec3f addend) {
x += addend.x;
y += addend.y;
z += addend.z;
return *this;
}
Vec3f Vec3f::operator-=(Vec3f subtrahend) {
x -= subtrahend.x;
y -= subtrahend.y;
z -= subtrahend.z;
return *this;
}
Vec3f Vec3f::operator&=(Vec3f multiplier) {
x *= multiplier.x;
y *= multiplier.y;
z *= multiplier.z;
return *this;
}
Vec3f Vec3f::normalize() {
x /= norm();
y /= norm();
z /= norm();
return *this;
}
// Binary operations
Vec3f Vec3f::operator*(float scalar) const {return copy() *= scalar;}
Vec3f Vec3f::operator/(float divisor) const {return copy() /= divisor;}
float Vec3f::operator^(float exponent) const {return pow(norm(), exponent);}
Vec3f operator*(float scalar, Vec3f vector) {return vector * scalar;}
Vec3f Vec3f::operator+(Vec3f addend) const {return copy() += addend;}
Vec3f Vec3f::operator-(Vec3f subtrahend) const {return copy() -= subtrahend;}
Vec3f Vec3f::operator&(Vec3f multiplier) const {return copy() &= multiplier;}
float Vec3f::operator*(Vec3f multiplier) const {
return x * multiplier.x
+ y * multiplier.y
+ z * multiplier.z;
}
// Unary operations
Vec3f Vec3f::operator-() const {return -1 * *this;}
float Vec3f::norm() const {return sqrt(x*x + y*y + z*z);}
Vec3f Vec3f::normal() const {return *this / norm();}
| 25.52 | 77 | 0.630408 |
ei14
|
45382cb1d1d0ba807d163bc1cb1d314da6852610
| 3,806 |
cpp
|
C++
|
Source/10.0.18362.0/ucrt/mbstring/mbsdec.cpp
|
825126369/UCRT
|
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
|
[
"MIT"
] | 2 |
2021-01-27T10:19:30.000Z
|
2021-02-09T06:24:30.000Z
|
Source/10.0.18362.0/ucrt/mbstring/mbsdec.cpp
|
825126369/UCRT
|
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
|
[
"MIT"
] | null | null | null |
Source/10.0.18362.0/ucrt/mbstring/mbsdec.cpp
|
825126369/UCRT
|
8853304fdc2a5c216658d08b6dbbe716aa2a7b1f
|
[
"MIT"
] | 1 |
2021-01-27T10:19:36.000Z
|
2021-01-27T10:19:36.000Z
|
/***
*mbsdec.c - Move MBCS string pointer backward one charcter.
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
*Purpose:
* Move MBCS string pointer backward one character.
*
*******************************************************************************/
#ifndef _MBCS
#error This file should only be compiled with _MBCS defined
#endif
#include <corecrt_internal.h>
#include <corecrt_internal_mbstring.h>
#include <locale.h>
#include <stddef.h>
/***
*_mbsdec - Move MBCS string pointer backward one charcter.
*
*Purpose:
* Move the supplied string pointer backwards by one
* character. MBCS characters are handled correctly.
*
*Entry:
* const unsigned char *string = pointer to beginning of string
* const unsigned char *current = current char pointer (legal MBCS boundary)
*
*Exit:
* Returns pointer after moving it.
* Returns nullptr if string >= current.
*
*Exceptions:
* Input parameters are validated. Refer to the validation section of the function.
*
*******************************************************************************/
extern "C" unsigned char * __cdecl _mbsdec_l(
const unsigned char *string,
const unsigned char *current,
_locale_t plocinfo
)
{
const unsigned char *temp;
/* validation section */
_VALIDATE_RETURN(string != nullptr, EINVAL, nullptr);
_VALIDATE_RETURN(current != nullptr, EINVAL, nullptr);
if (string >= current)
return(nullptr);
_LocaleUpdate _loc_update(plocinfo);
if (_loc_update.GetLocaleT()->mbcinfo->ismbcodepage == 0)
return (unsigned char *)--current;
temp = current - 1;
/* There used to be an optimisation here:
*
* If (current-1) returns true from _ismbblead, it is a trail byte, because
* current is a known character start point, and so current-1 would have to be a
* legal single byte MBCS character, which a lead byte is not. Therefore, if so,
* return (current-2) because it must be the trailbyte's lead.
*
* if ( _ismbblead(*temp) )
* return (unsigned char *)(temp - 1);
*
* But this is not a valid optimisation if you want to cope correctly with an
* MBCS string which is terminated by a leadbyte and a 0 byte, when you are passed
* an initial position pointing to the \0 at the end of the string.
*
* This optimisation is also invalid if you are passed a pointer to half-way
* through an MBCS pair.
*
* Neither of these are truly valid input conditions, but to ensure predictably
* correct behaviour in the presence of these conditions, we have removed
* the optimisation.
*/
/*
* It is unknown whether (current - 1) is a single byte character or a
* trail. Now decrement temp until
* a) The beginning of the string is reached, or
* b) A non-lead byte (either single or trail) is found.
* The difference between (current-1) and temp is the number of non-single
* byte characters preceding (current-1). There are two cases for this:
* a) (current - temp) is odd, and
* b) (current - temp) is even.
* If odd, then there are an odd number of "lead bytes" preceding the
* single/trail byte (current - 1), indicating that it is a trail byte.
* If even, then there are an even number of "lead bytes" preceding the
* single/trail byte (current - 1), indicating a single byte character.
*/
while ( (string <= --temp) && (_ismbblead_l(*temp, _loc_update.GetLocaleT())) )
;
return (unsigned char *)(current - 1 - ((current - temp) & 0x01) );
}
extern "C" unsigned char * (__cdecl _mbsdec)(
const unsigned char *string,
const unsigned char *current
)
{
return _mbsdec_l(string, current, nullptr);
}
| 34.6 | 88 | 0.64083 |
825126369
|
4539f7f1d006ae249eb8f841b2f0a897d401f16e
| 1,678 |
cpp
|
C++
|
Heap.cpp
|
Aman-Chopra/DataStructure-Algorithms
|
fc5ed6ebe97032200b93c1ade783d4a5ed2fdd25
|
[
"MIT"
] | null | null | null |
Heap.cpp
|
Aman-Chopra/DataStructure-Algorithms
|
fc5ed6ebe97032200b93c1ade783d4a5ed2fdd25
|
[
"MIT"
] | 3 |
2016-06-09T07:46:15.000Z
|
2017-05-06T07:56:18.000Z
|
Heap.cpp
|
Aman-Chopra/DataStructure-Algorithms
|
fc5ed6ebe97032200b93c1ade783d4a5ed2fdd25
|
[
"MIT"
] | 4 |
2016-06-09T07:14:37.000Z
|
2021-05-21T22:07:20.000Z
|
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int smallest = 0;
int largest = 0;
void max_heapify(vector<int> &v, int i, int *n)
{
int left = 2*i;
int right = 2*i+1;
if(left <= *n && v[left] > v[i])
largest = left;
else
largest = i;
if(right <= *n && v[right] > v[largest])
largest = right;
if(largest != i)
{
swap(v[i],v[largest]);
max_heapify(v,largest,n);
}
}
void min_heapify(vector<int> &v, int i, int *n)
{
int left = 2*i;
int right = 2*i+1;
if(left <= *n && v[left] < v[i])
smallest = left;
else
smallest = i;
if(right <= *n && v[right] < v[smallest])
smallest = right;
if(smallest != i)
{
swap(v[i],v[smallest]);
min_heapify(v,smallest,n);
}
}
void build_minheap(vector<int> &v, int *size)
{
for(int i=(*size)/2;i>=1;i--)
{
min_heapify(v,i,size);
}
}
void build_maxheap(vector<int> &v, int *size)
{
for(int i = (*size)/2;i>=1;i--)
{
max_heapify(v,i,size);
}
}
void heap_sort(vector<int> &v, int *size)
{
int n = *size;
build_maxheap(v,size);
for(int i=n;i>=2;i--)
{
swap(v[1],v[i]);
n--;
max_heapify(v,1,&n);
}
}
int main()
{
cout<<"Enter the number of elements to store in the heap"<<endl;
int size;
cin>>size;
vector<int> heap(size+1);
for(int i=1;i<=size;i++)
{
cin>>heap[i];
}
cout<<"Heap Sort:"<<endl;
heap_sort(heap,&size);
for(int i=1;i<=size;i++)
{
cout<<heap[i]<<" ";
}
cout<<endl;
cout<<"Max Heap:"<<endl;
build_maxheap(heap, &size);
for(int i=1;i<=size;i++)
{
cout<<heap[i]<<" ";
}
cout<<endl;
cout<<"Min Heap:"<<endl;
build_minheap(heap, &size);
for(int i=1;i<=size;i++)
{
cout<<heap[i]<<" ";
}
cout<<endl;
return 0;
}
| 15.537037 | 65 | 0.573897 |
Aman-Chopra
|
453a1e6a515d4a67d7d37444149865b65fb7a952
| 4,785 |
cpp
|
C++
|
idlib-math/tests/idlib/tests/math/constants.cpp
|
egoboo/idlib
|
b27b9d3fe7357ecfe5f9dc71afe283a3d16b1ba8
|
[
"MIT"
] | 1 |
2021-07-30T14:02:43.000Z
|
2021-07-30T14:02:43.000Z
|
idlib-math/tests/idlib/tests/math/constants.cpp
|
egoboo/idlib
|
b27b9d3fe7357ecfe5f9dc71afe283a3d16b1ba8
|
[
"MIT"
] | null | null | null |
idlib-math/tests/idlib/tests/math/constants.cpp
|
egoboo/idlib
|
b27b9d3fe7357ecfe5f9dc71afe283a3d16b1ba8
|
[
"MIT"
] | 2 |
2017-01-27T16:53:08.000Z
|
2017-08-27T07:28:43.000Z
|
///////////////////////////////////////////////////////////////////////////////////////////////////
//
// Idlib: A C++ utility library
// Copyright (C) 2017-2018 Michael Heilmann
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
///////////////////////////////////////////////////////////////////////////////////////////////////
#include "gtest/gtest.h"
#include "idlib/math.hpp"
namespace idlib::tests {
TEST(constants, pi_s)
{
auto x = idlib::pi<single>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 3.1415926535897932384626433832795f);
}
TEST(constants, two_pi_s)
{
auto x = idlib::two_pi<single>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 2.0f * 3.1415926535897932384626433832795f);
}
TEST(constants, inv_pi_s)
{
auto x = idlib::inv_pi<single>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 1.0f / 3.1415926535897932384626433832795f); // GoogleTest tolerance is four ULP, ours was two ULP.
}
TEST(constants, inv_two_pi_s)
{
auto x = idlib::inv_two_pi<single>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 1.0f / (2.0f * 3.1415926535897932384626433832795f));
}
TEST(constants, pi_over_two_s)
{
auto x = idlib::pi_over<single, 2>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 3.1415926535897932384626433832795f / 2.0f);
}
TEST(constants, pi_over_four_s)
{
auto x = idlib::pi_over<single, 4>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 3.1415926535897932384626433832795f / 4.0f);
}
TEST(constants, pi_d)
{
auto x = idlib::pi<double>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 3.1415926535897932384626433832795);
}
TEST(constants, two_pi_d)
{
auto x = idlib::two_pi<double>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 2.0 * 3.1415926535897932384626433832795);
}
TEST(constants, inv_pi_d)
{
auto x = idlib::inv_pi<double>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 1.0 / 3.1415926535897932384626433832795);
}
TEST(constants, inv_two_pi_d)
{
auto x = idlib::inv_two_pi<double>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 1.0 / (2.0 * 3.1415926535897932384626433832795));
}
TEST(constants, pi_over_two_d)
{
auto x = idlib::pi_over<double, 2>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 3.1415926535897932384626433832795 / 2.0);
}
TEST(constants, pi_over_four_d)
{
auto x = idlib::pi_over<double, 4>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, 3.1415926535897932384626433832795 / 4.0);
}
TEST(constants, sqrt_two_s)
{
auto x = idlib::sqrt_two<single>();
ASSERT_TRUE(!std::isnan(x));
ASSERT_TRUE(!std::isinf(x));
ASSERT_FLOAT_EQ(x, std::sqrt(2.0f));
}
TEST(constants, inv_sqrt_two_s)
{
auto x = idlib::inv_sqrt_two<single>();
auto y = 1.0f / std::sqrt(2.0f);
ASSERT_TRUE(!std::isnan(x) && !std::isnan(y));
ASSERT_TRUE(!std::isinf(x) && !std::isinf(y));
ASSERT_TRUE(0.0 < x && 0.0 < y);
ASSERT_FLOAT_EQ(x, y);
}
TEST(constants, sqrt_two_d)
{
auto x = idlib::sqrt_two<double>();
auto y = std::sqrt(2.0);
ASSERT_TRUE(!std::isnan(x) && !std::isnan(y));
ASSERT_TRUE(!std::isinf(x) && !std::isinf(y));
ASSERT_TRUE(0.0 < x && 0.0 < y);
ASSERT_FLOAT_EQ(x, y);
}
TEST(constants, inv_sqrt_two_d)
{
double x = idlib::inv_sqrt_two<double>();
double y = 1.0 / std::sqrt(2.0);
ASSERT_TRUE(!std::isnan(x) && !std::isnan(y));
ASSERT_TRUE(!std::isinf(x) && !std::isinf(y));
ASSERT_TRUE(0.0 < x && 0.0 < y);
ASSERT_FLOAT_EQ(x, y);
}
} // namespace idlib::tests
| 29 | 121 | 0.63908 |
egoboo
|
453a2e4418602f71031fee4718f9682dd556d6c0
| 446 |
hpp
|
C++
|
include/lua_object.hpp
|
GhostInABottle/octopus_engine
|
50429e889493527bdc0e78b307937002e0f2c510
|
[
"BSD-2-Clause"
] | 3 |
2017-10-02T03:18:59.000Z
|
2020-11-01T09:21:28.000Z
|
include/lua_object.hpp
|
GhostInABottle/octopus_engine
|
50429e889493527bdc0e78b307937002e0f2c510
|
[
"BSD-2-Clause"
] | 2 |
2019-04-06T21:48:08.000Z
|
2020-05-22T23:38:54.000Z
|
include/lua_object.hpp
|
GhostInABottle/octopus_engine
|
50429e889493527bdc0e78b307937002e0f2c510
|
[
"BSD-2-Clause"
] | 1 |
2017-07-17T20:58:26.000Z
|
2017-07-17T20:58:26.000Z
|
#ifndef HPP_LUA_OBJECT
#define HPP_LUA_OBJECT
#include <string>
#include <memory>
#include "xd/vendor/sol/forward.hpp"
class Lua_Object {
public:
Lua_Object();
virtual ~Lua_Object();
void set_lua_property(const std::string& name, sol::stack_object value);
sol::main_object get_lua_property(const std::string& name);
private:
struct Impl;
friend struct Impl;
std::unique_ptr<Impl> pimpl;
};
#endif
| 22.3 | 77 | 0.690583 |
GhostInABottle
|
453a31f903a11270acdc2a5ad22af96280f0cdc3
| 838 |
cpp
|
C++
|
UVA/UVA11340.cpp
|
avillega/CompetitiveProgramming
|
f12c1a07417f8fc154ac5297889ca756b49f0f35
|
[
"Apache-2.0"
] | null | null | null |
UVA/UVA11340.cpp
|
avillega/CompetitiveProgramming
|
f12c1a07417f8fc154ac5297889ca756b49f0f35
|
[
"Apache-2.0"
] | null | null | null |
UVA/UVA11340.cpp
|
avillega/CompetitiveProgramming
|
f12c1a07417f8fc154ac5297889ca756b49f0f35
|
[
"Apache-2.0"
] | null | null | null |
#include <cstdio>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
int main(){
map<char, int> charPrice;
char artLine[10100];
int T; scanf("%d\n", &T);
int N;
ll totalCents;
while(T--){
totalCents=0;
charPrice.clear();
scanf("%d\n", &N);
char c;
int val;
while(N--){
scanf("%c %d\n", &c, &val);
charPrice[c]=val;
}
scanf("%d\n", &N);
while(N--){
gets(artLine);
string line(artLine);
for(char c: line){
totalCents+=charPrice[c];
}
}
printf("%.2f$\n", totalCents/100.0 );
}
return 0;
}
| 23.942857 | 52 | 0.387828 |
avillega
|
453d0e2d0c29f82be0ecfb636cb3150dbe88e579
| 1,000 |
cpp
|
C++
|
tools/EncoderTemplate/Encoder.cpp
|
EmilianC/Jewel3D
|
ce11aa686ab35d4989f018c948b26abed6637d77
|
[
"MIT"
] | 30 |
2017-02-02T01:57:13.000Z
|
2020-07-04T04:38:20.000Z
|
tools/EncoderTemplate/Encoder.cpp
|
EmilianC/Jewel3D
|
ce11aa686ab35d4989f018c948b26abed6637d77
|
[
"MIT"
] | null | null | null |
tools/EncoderTemplate/Encoder.cpp
|
EmilianC/Jewel3D
|
ce11aa686ab35d4989f018c948b26abed6637d77
|
[
"MIT"
] | 10 |
2017-07-10T01:31:54.000Z
|
2020-01-13T20:38:57.000Z
|
#include "Encoder.h"
#define CURRENT_VERSION 1
Encoder::Encoder()
: gem::Encoder(CURRENT_VERSION)
{
}
gem::ConfigTable Encoder::GetDefault() const
{
gem::ConfigTable defaultConfig;
defaultConfig.SetValue("version", CURRENT_VERSION);
// Any default values for a new asset can be added to metadata here.
return defaultConfig;
}
bool Encoder::Validate(const gem::ConfigTable& metadata, unsigned loadedVersion) const
{
switch (loadedVersion)
{
case 1:
// Check the presence of your metadata fields here.
// Also ensure that they have correct values.
//...
if (metadata.GetSize() != 1)
{
gem::Error("Incorrect number of value entries.");
return false;
}
}
return true;
}
bool Encoder::Convert(std::string_view source, std::string_view destination, const gem::ConfigTable& metadata) const
{
// Load the source file and output the built data to the destination folder.
// The conversion should be done using the properties inside the metadata.
//...
return true;
}
| 21.276596 | 116 | 0.725 |
EmilianC
|
45423747d3b937f5418714dac6ac022f087f6b9e
| 3,742 |
cpp
|
C++
|
src/FEM/FEM1DApp.cpp
|
Jerry-Shen0527/Numerical
|
0bd6b630ac450caa0642029792ab348867d2390d
|
[
"MIT"
] | null | null | null |
src/FEM/FEM1DApp.cpp
|
Jerry-Shen0527/Numerical
|
0bd6b630ac450caa0642029792ab348867d2390d
|
[
"MIT"
] | null | null | null |
src/FEM/FEM1DApp.cpp
|
Jerry-Shen0527/Numerical
|
0bd6b630ac450caa0642029792ab348867d2390d
|
[
"MIT"
] | null | null | null |
#include <FEM/FEM1DApp.hpp>
Float StaticFEM1DApp::GradientSelfInnerProduct(int i, int j)
{
std::vector<int> i_id, j_id;
auto i_mesh = IdxToMesh(i, i_id);
auto j_mesh = IdxToMesh(j, j_id);
Float ret = 0;
for (int a = 0; a < i_mesh.size(); ++a)
{
for (int b = 0; b < j_mesh.size(); ++b)
{
if (i_mesh[a] == j_mesh[b])
{
auto sub_interval = interval.SubInterval(i_mesh[a]);
ret += WeightedL2InnerProduct(sub_interval.remap(ShapeFunctions[i_id[a]]),
sub_interval.remap(ShapeFunctionGradients[j_id[b]],
1.0 / sub_interval.length()), b_func, sub_interval);
}
}
}
return ret;
}
Float StaticFEM1DApp::GradientInnerProduct(int i, int j)
{
std::vector<int> i_id, j_id;
auto i_mesh = IdxToMesh(i, i_id);
auto j_mesh = IdxToMesh(j, j_id);
Float ret = 0;
for (int a = 0; a < i_mesh.size(); ++a)
{
for (int b = 0; b < j_mesh.size(); ++b)
{
if (i_mesh[a] == j_mesh[b])
{
auto sub_interval = interval.SubInterval(i_mesh[a]);
ret += WeightedL2InnerProduct(
sub_interval.remap(ShapeFunctionGradients[i_id[a]], 1.0 / sub_interval.length()),
sub_interval.remap(ShapeFunctionGradients[j_id[b]], 1.0 / sub_interval.length()), d_func,
sub_interval);
}
}
}
return ret;
}
Float StaticFEM1DApp::SelfInnerProduct(int i, int j)
{
std::vector<int> i_id, j_id;
auto i_mesh = IdxToMesh(i, i_id);
auto j_mesh = IdxToMesh(j, j_id);
Float ret = 0;
for (int a = 0; a < i_mesh.size(); ++a)
{
for (int b = 0; b < j_mesh.size(); ++b)
{
if (i_mesh[a] == j_mesh[b])
{
auto sub_interval = interval.SubInterval(i_mesh[a]);
ret += WeightedL2InnerProduct(sub_interval.remap(ShapeFunctions[i_id[a]]),
sub_interval.remap(ShapeFunctions[j_id[b]]), c_func, sub_interval);
}
}
}
return ret;
}
Float StaticFEM1DApp::RHSInnerProduct(int i)
{
std::vector<int> func_id;
auto i_mesh = IdxToMesh(i, func_id);
Float ret = 0;
for (int a = 0; a < func_id.size(); ++a)
{
auto sub_interval = interval.SubInterval(i_mesh[a]);
ret += L2InnerProduct(sub_interval.remap(ShapeFunctions[func_id[a]]), RHS_func, sub_interval);
}
return ret;
}
std::vector<int> StaticFEM1DApp::RelatedFuncIdx(int idx)
{
std::vector<int> ret;
std::vector<int> foo_id;
auto MeshIds = IdxToMesh(idx, foo_id);
std::set<int> set_ret;
for (auto mesh_id : MeshIds)
{
for (int i = 0; i < ShapeFunctions.size(); ++i)
{
int idx;
if (MeshToIdx(mesh_id, i, idx))
{
set_ret.emplace(idx);
}
}
}
ret.assign(set_ret.begin(), set_ret.end());
return ret;
}
Float StaticFEM1DApp::Value(Float x)
{
if (mat_size == 0)
{
return 0;
}
Float ret = 0;
for (int i = 0; i < interval.GetPartitionCount(); ++i)
{
auto sub_interval = interval.SubInterval(i);
if (sub_interval.Inside(x))
{
for (int j = 0; j < ShapeFunctions.size(); ++j)
{
int idx;
if (MeshToIdx(i, j, idx))
{
ret += sub_interval.remap(ShapeFunctions[j])(x) * rst(idx);
}
}
}
}
return ret;
}
std::function<Float(Float)> LagrangianBase(int N, int i)
{
std::vector<Point2d> points(N + 1);
Float h = 1.0 / N;
for (int i = 0; i <= N; ++i)
{
points[i] = Point2d(i * h, 0);
}
points[i] = Point2d(i * h, 1.0);
return LagrangianPolynomial(points);
}
std::function<Float(Float)> LagrangianBaseDerivative(int N, int i)
{
return [=](Float x)
{
Float ret = 0;
for (int missing = 0; missing <= N; ++missing)
{
if (missing != i)
{
std::vector<Point2d> points;
Float h = 1.0 / N;
for (int j = 0; j <= N; ++j)
if (j != missing)
if (j == i)
points.emplace_back(j * h, 1.0);
else
points.emplace_back(j * h, 0.0);
ret += LagrangianPolynomial(points)(x) / (h * (i - missing));
}
}
return ret;
};
}
| 21.022472 | 96 | 0.617584 |
Jerry-Shen0527
|
45462edbf1008c8ccc83843d664762d8e82e0909
| 2,396 |
cpp
|
C++
|
node_modules/lzz-gyp/lzz-source/smtc_PrintNsFuncDefn.cpp
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | 3 |
2019-09-18T16:44:33.000Z
|
2021-03-29T13:45:27.000Z
|
node_modules/lzz-gyp/lzz-source/smtc_PrintNsFuncDefn.cpp
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | null | null | null |
node_modules/lzz-gyp/lzz-source/smtc_PrintNsFuncDefn.cpp
|
SuperDizor/dizornator
|
9f57dbb3f6af80283b4d977612c95190a3d47900
|
[
"ISC"
] | 2 |
2019-03-29T01:06:38.000Z
|
2019-09-18T16:44:34.000Z
|
// smtc_PrintNsFuncDefn.cpp
//
#include "smtc_PrintNsFuncDefn.h"
// semantic
#include "smtc_FuncDefn.h"
#include "smtc_IsNameQual.h"
#include "smtc_IsNsEnclUnmd.h"
#include "smtc_Output.h"
#include "smtc_PrintFuncDefn.h"
// config
#include "conf_Config.h"
#define LZZ_INLINE inline
namespace
{
using namespace smtc;
}
namespace
{
struct Printer
{
FuncDefnPtr const & func_defn;
NsPtr const & ns;
bool is_decl;
void printDecl (FilePtr const & file);
void printDefn (FilePtr const & file, SectionKind skind = BODY_SECTION);
public:
explicit Printer (FuncDefnPtr const & func_defn, NsPtr const & ns);
~ Printer ();
};
}
namespace
{
void Printer::printDecl (FilePtr const & file)
{
PrintFuncDecl printer;
printer.is_decl = is_decl;
printer.not_inline = true;
printer.print (file, DECLARATION_SECTION, func_defn, ns);
is_decl = false;
}
}
namespace
{
void Printer::printDefn (FilePtr const & file, SectionKind skind)
{
PrintFuncDefn printer;
printer.is_decl = is_decl;
printer.print (file, skind, func_defn, ns);
}
}
namespace
{
LZZ_INLINE Printer::Printer (FuncDefnPtr const & func_defn, NsPtr const & ns)
: func_defn (func_defn), ns (ns), is_decl (true)
{}
}
namespace
{
Printer::~ Printer ()
{}
}
namespace smtc
{
void printNsFuncDefn (Output & out, FuncDefnPtr const & func_defn, NsPtr const & ns)
{
Printer printer (func_defn, ns);
bool is_qual = isNameQual (func_defn->getName ());
if (func_defn->isStatic () || isNsEnclUnmd (ns))
{
if (! is_qual)
{
printer.printDecl (out.getSrcFile ());
}
printer.printDefn (out.getSrcFile ());
}
else
{
if (! is_qual)
{
printer.printDecl (out.getHdrFile ());
}
if (func_defn->isInline ())
{
if (conf::getOptionValue (conf::opt_inl_inl))
{
printer.printDefn (out.getHdrFile (), INLINE_BODY_SECTION);
printer.printDefn (out.getSrcFile (), INLINE_BODY_SECTION);
}
else if (conf::getOptionValue (conf::opt_inl))
{
printer.printDefn (out.getInlFile ());
}
else
{
printer.printDefn (out.getHdrFile ());
}
}
else
{
printer.printDefn (out.getSrcFile ());
}
}
}
}
#undef LZZ_INLINE
| 22.185185 | 86 | 0.613523 |
SuperDizor
|
454d3b48038a9b52fc0dc94df440bdb4ea5d76e7
| 8,056 |
cpp
|
C++
|
src/Nodes/Default_Nodes/Generators/chaoticOscillator.cpp
|
PlaymodesStudio/ofxOceanode
|
400df6d49c4b29bc6916e4a045145e935beff4e0
|
[
"MIT"
] | 31 |
2018-04-20T13:47:38.000Z
|
2021-12-26T04:32:24.000Z
|
src/Nodes/Default_Nodes/Generators/chaoticOscillator.cpp
|
PlaymodesStudio/ofxOceanode
|
400df6d49c4b29bc6916e4a045145e935beff4e0
|
[
"MIT"
] | 25 |
2018-02-19T17:15:32.000Z
|
2020-01-05T01:51:00.000Z
|
src/Nodes/Default_Nodes/Generators/chaoticOscillator.cpp
|
PlaymodesStudio/ofxOceanode
|
400df6d49c4b29bc6916e4a045145e935beff4e0
|
[
"MIT"
] | 5 |
2018-09-25T18:37:23.000Z
|
2021-01-21T16:26:16.000Z
|
//
// chaoticOscillator.cpp
// example-basic
//
// Created by Eduard Frigola Bagué on 02/03/2020.
//
#include "chaoticOscillator.h"
void chaoticOscillator::setup(){
color = ofColor(0, 200, 255);
oldPhasor = vector<float>(1, 0);
seedChanged = vector<bool>(true);
baseChOsc.resize(1);
result.resize(1);
listeners.push(phaseOffset_Param.newListener([this](vector<float> &val){
if(val.size() != baseChOsc.size() && index_Param->size() == 1 && phasorIn->size() == 1){
resize(val.size());
}
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].phaseOffset_Param = getValueForPosition(val, i);
}
}));
listeners.push(randomAdd_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].randomAdd_Param = getValueForPosition(val, i);
}
}));
listeners.push(scale_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].scale_Param = getValueForPosition(val, i);
}
}));
listeners.push(offset_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].offset_Param = getValueForPosition(val, i);
}
}));
listeners.push(pow_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].pow_Param = getValueForPosition(val, i);
baseChOsc[i].modulateNewRandom();
}
}));
listeners.push(biPow_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].biPow_Param = getValueForPosition(val, i);
baseChOsc[i].modulateNewRandom();
}
}));
listeners.push(quant_Param.newListener([this](vector<int> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].quant_Param = getValueForPosition(val, i);
baseChOsc[i].modulateNewRandom();
}
}));
listeners.push(pulseWidth_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].pulseWidth_Param = getValueForPosition(val, i);
}
}));
listeners.push(skew_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].skew_Param = getValueForPosition(val, i);
}
}));
listeners.push(amplitude_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].amplitude_Param = getValueForPosition(val, i);
}
}));
listeners.push(invert_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].invert_Param = getValueForPosition(val, i);
}
}));
listeners.push(roundness_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].roundness_Param = getValueForPosition(val, i);
}
}));
listeners.push(index_Param.newListener([this](vector<float> &val){
if(val.size() != baseChOsc.size()){
resize(val.size());
}
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].setIndexNormalized(getValueForPosition(val, i));
}
seedChanged = vector<bool>(baseChOsc.size(), true);
}));
listeners.push(customDiscreteDistribution_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].customDiscreteDistribution = val;
}
}));
listeners.push(seed.newListener([this](vector<int> &val){
seedChanged = vector<bool>(baseChOsc.size(), true);
}));
listeners.push(length_Param.newListener([this](vector<float> &val){
for(int i = 0; i < baseChOsc.size(); i++){
baseChOsc[i].length_Param = getValueForPosition(val, i);
}
seedChanged = vector<bool>(baseChOsc.size(), true);
}));
addParameter(phasorIn.set("Phase", {0}, {0}, {1}));
addParameter(index_Param.set("Index", {0}, {0}, {1}));
addParameter(length_Param.set("Length", {1}, {0}, {100}));
addParameter(phaseOffset_Param.set("Ph.Off", {0}, {0}, {1}));
addParameter(roundness_Param.set("Round", {0.5}, {0}, {1}));
addParameter(pulseWidth_Param.set("PulseW", {.5}, {0}, {1}));
addParameter(skew_Param.set("Skew", {0}, {-1}, {1}));
addParameter(pow_Param.set("Pow", {0}, {-1}, {1}));
addParameter(biPow_Param.set("BiPow", {0}, {-1}, {1}));
addParameter(quant_Param.set("Quant", {255}, {2}, {255}));
addParameter(customDiscreteDistribution_Param.set("Dist" , {-1}, {0}, {1}));
addParameter(seed.set("Seed", {-1}, {(INT_MIN+1)/2}, {(INT_MAX-1)/2}));
addParameter(randomAdd_Param.set("Rnd Add", {0}, {-.5}, {.5}));
addParameter(scale_Param.set("Scale", {1}, {0}, {2}));
addParameter(offset_Param.set("Offset", {0}, {-1}, {1}));
addParameter(amplitude_Param.set("Fader", {1}, {0}, {1}));
addParameter(invert_Param.set("Invert", {0}, {0}, {1}));
addOutputParameter(output.set("Output", {0}, {0}, {1}));
listeners.push(phasorIn.newListener(this, &chaoticOscillator::phasorInListener));
desiredLength = 1;
}
void chaoticOscillator::resize(int newSize){
baseChOsc.resize(newSize);
result.resize(newSize);
phaseOffset_Param = phaseOffset_Param;
roundness_Param = roundness_Param;
pulseWidth_Param = pulseWidth_Param;
skew_Param = skew_Param;
randomAdd_Param = randomAdd_Param;
scale_Param = scale_Param;
offset_Param = offset_Param;
pow_Param = pow_Param;
biPow_Param = biPow_Param;
quant_Param = quant_Param;
amplitude_Param = amplitude_Param;
invert_Param = invert_Param;
customDiscreteDistribution_Param = customDiscreteDistribution_Param;
seed = seed;
seedChanged = vector<bool>(baseChOsc.size(), true);
length_Param.setMax({static_cast<float>(newSize)});
string name = length_Param.getName();
parameterChangedMinMax.notify(name);
if(length_Param->size() == 1){
if(desiredLength != -1 && desiredLength <= newSize){
length_Param = vector<float>(1, desiredLength);
desiredLength = -1;
}
else{
if(length_Param->at(0) > length_Param.getMax()[0]){
desiredLength = length_Param->at(0);
length_Param = vector<float>(1, length_Param.getMax()[0]);
}
length_Param = length_Param;
}
}
};
void chaoticOscillator::presetRecallBeforeSettingParameters(ofJson &json){
if(json.count("Length") == 1){
desiredLength = (json["Length"]);
}
}
void chaoticOscillator::phasorInListener(vector<float> &phasor){
if(phasor.size() != baseChOsc.size() && phasor.size() != 1 && index_Param->size() == 1){
resize(phasor.size());
}
if(accumulate(seedChanged.begin(), seedChanged.end(), 0) != 0){
for(int i = 0; i < baseChOsc.size(); i++){
if(seedChanged[i] && getValueForPosition(phasor, i) < getValueForPosition(oldPhasor, i)){
if(getValueForPosition(seed.get(), i) == 0){
baseChOsc[i].deactivateSeed();
}else{
if(seed->size() == 1 && seed->at(0) < 0){
baseChOsc[i].setSeed(seed->at(0) - (10*getValueForPosition(index_Param.get(), i)*baseChOsc.size()));
}else{
baseChOsc[i].setSeed(getValueForPosition(seed.get(), i));
baseChOsc[i].computeFunc(0);
}
}
seedChanged[i] = false;
}
}
}
for(int i = 0; i < baseChOsc.size(); i++){
result[i] = baseChOsc[i].computeFunc(getValueForPosition(phasor, i));
}
oldPhasor = phasor;
output = result;
}
| 39.881188 | 124 | 0.585775 |
PlaymodesStudio
|
45523fb4a50faa6e4e59570ed6c5b2e26dfd7279
| 3,757 |
hpp
|
C++
|
src/riscv_devices.hpp
|
msyksphinz/swimmer_riscv
|
065cf3e0dcdcd00cd9bd976285a307d371253ba9
|
[
"BSD-3-Clause"
] | 33 |
2015-08-23T02:45:07.000Z
|
2019-11-06T23:34:51.000Z
|
src/riscv_devices.hpp
|
msyksphinz-self/swimmer_riscv
|
065cf3e0dcdcd00cd9bd976285a307d371253ba9
|
[
"BSD-3-Clause"
] | 11 |
2015-10-11T15:52:42.000Z
|
2019-09-20T14:30:35.000Z
|
src/riscv_devices.hpp
|
msyksphinz/swimmer_riscv
|
065cf3e0dcdcd00cd9bd976285a307d371253ba9
|
[
"BSD-3-Clause"
] | 5 |
2015-02-14T10:07:44.000Z
|
2019-09-20T06:37:38.000Z
|
/*
* Copyright (c) 2015, msyksphinz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <vector>
#include "mem_body.hpp"
#include "riscv_pe_thread.hpp"
// static uint8_t DEVICE (uint64_t command) { return command >> 56; }
// static uint8_t COMMAND(uint64_t command) { return command >> 48; }
// static uint64_t PAYLOAD(uint64_t command) { return command << 16 >> 16; }
#define DEVICE(cmd) ((cmd >> 56) & 0xff)
#define COMMAND(cmd) ((cmd >> 48) & 0xff)
#define PAYLOAD(cmd) (cmd & 0xffffffffffffULL)
#define MAKE_COMMAND(dev, cmd, payload) (static_cast<uint64_t>(dev) << 56 | static_cast<uint64_t>(cmd) << 48 | static_cast<uint64_t>(payload) & 0x0ffff)
class RiscvDevice_t
{
uint32_t m_dev_id;
RiscvPeThread *m_pe_thread;
public:
virtual void HandleCommand (UDWord_t cmd) = 0;
virtual void Tick() = 0;
RiscvPeThread *GetPeThread() { return m_pe_thread; }
RiscvDevice_t (uint32_t dev_id, RiscvPeThread *pe_thread) :
m_dev_id(dev_id), m_pe_thread(pe_thread) {}
virtual ~RiscvDevice_t () {}
inline uint32_t GetDevId() { return m_dev_id; }
};
class RiscvMMDevice_t
{
private:
Addr_t m_base_addr;
Addr_t m_size;
public:
RiscvPeThread *m_pe_thread;
virtual MemResult Load (Addr_t addr, size_t len, Byte_t *data) = 0;
virtual MemResult Store (Addr_t addr, size_t size, Byte_t *data) = 0;
Addr_t GetBaseAddr () { return m_base_addr; }
Addr_t GetSize () { return m_size; }
RiscvMMDevice_t (RiscvPeThread *pe_thread, Addr_t base_addr, Addr_t size) {
m_pe_thread = pe_thread;
m_base_addr = base_addr;
m_size = size;
}
virtual ~RiscvMMDevice_t () {}
};
class RiscvDeviceList_t
{
private:
std::vector<RiscvDevice_t*> m_devices;
public:
void RegisterDevice (RiscvDevice_t* dev) {
m_devices.push_back(dev);
}
void HandleCommand (UDWord_t cmd) {
if (DEVICE(cmd) >= m_devices.size()) {
fprintf (stderr, "<Info: HandleCommand not found %ld>\n", DEVICE(cmd));
return;
}
m_devices[DEVICE(cmd)]->HandleCommand(cmd);
}
void Tick () {
for (RiscvDevice_t *device : m_devices) {
device->Tick();
}
}
~RiscvDeviceList_t ()
{
for (RiscvDevice_t *device : m_devices) {
delete device;
}
}
};
| 31.571429 | 152 | 0.711206 |
msyksphinz
|
4555a728416e55f68c46303cbf1c1a6c81eb918c
| 593 |
cpp
|
C++
|
SET & MAP/basic problem/Count-of-pairs-between-two-arrays-such-that-the-sums-are-distinct.cpp
|
Shiv-sharma-111/jubilant-sniffle
|
4cd1ce6fe08f8749f16e569b3a78f3b5576ebe17
|
[
"MIT"
] | null | null | null |
SET & MAP/basic problem/Count-of-pairs-between-two-arrays-such-that-the-sums-are-distinct.cpp
|
Shiv-sharma-111/jubilant-sniffle
|
4cd1ce6fe08f8749f16e569b3a78f3b5576ebe17
|
[
"MIT"
] | null | null | null |
SET & MAP/basic problem/Count-of-pairs-between-two-arrays-such-that-the-sums-are-distinct.cpp
|
Shiv-sharma-111/jubilant-sniffle
|
4cd1ce6fe08f8749f16e569b3a78f3b5576ebe17
|
[
"MIT"
] | null | null | null |
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int T;
cin>>T;
while(T--)
{
int n1,n2;
cin>>n1>>n2;
int arr1[n1],arr2[n2];
for(int i=0;i<n1;i++)
{
cin>>arr1[i];
}
for(int i=0;i<n2;i++)
{
cin>>arr2[i];
}
int count=0,sum;
unordered_set<int> mp;
for(int i=0;i<n1;i++)
{
for(int j=0;j<n2;j++)
{
sum = arr1[i]+arr2[j];
mp.insert(sum);
}
}
//int k = mp.size();
cout<<mp.size()<<"\n";
}
return 0;
}
| 16.027027 | 35 | 0.468803 |
Shiv-sharma-111
|
455680b9155630f3e6d96be1a8de3c27928d49c0
| 517 |
hpp
|
C++
|
src/Exceptions/Exception.hpp
|
pokorj54/Command-line-calendar
|
de2c8a89917bd4cb69547427a6ec1bced218c5ad
|
[
"MIT"
] | null | null | null |
src/Exceptions/Exception.hpp
|
pokorj54/Command-line-calendar
|
de2c8a89917bd4cb69547427a6ec1bced218c5ad
|
[
"MIT"
] | null | null | null |
src/Exceptions/Exception.hpp
|
pokorj54/Command-line-calendar
|
de2c8a89917bd4cb69547427a6ec1bced218c5ad
|
[
"MIT"
] | null | null | null |
#ifndef Exception_785a62ec3213411cb4e442ee734c00cb
#define Exception_785a62ec3213411cb4e442ee734c00cb
#include <iostream>
/**
* @brief Abstract class providing genereal interface to exceptions
*
*/
class Exception: public std::exception
{
public:
/**
* @brief Message that can be printed to the end user
*
* @param[out] o here it will be printed
*/
virtual void Message(std::ostream & o) const = 0;
};
#endif //Exception_785a62ec3213411cb4e442ee734c00cb
| 24.619048 | 67 | 0.686654 |
pokorj54
|
455878b48a2ef154a4e5242dc0e51a7aee92a867
| 898 |
cpp
|
C++
|
src/util/TexShare.cpp
|
pharpend/Oscilloscope
|
e2598c559302bd91747b73a251d614eeb4dea663
|
[
"MIT"
] | 460 |
2015-03-18T18:59:49.000Z
|
2022-03-19T19:11:09.000Z
|
src/util/TexShare.cpp
|
pharpend/Oscilloscope
|
e2598c559302bd91747b73a251d614eeb4dea663
|
[
"MIT"
] | 78 |
2015-05-10T07:23:55.000Z
|
2022-03-09T13:58:51.000Z
|
src/util/TexShare.cpp
|
pharpend/Oscilloscope
|
e2598c559302bd91747b73a251d614eeb4dea663
|
[
"MIT"
] | 64 |
2015-06-13T01:45:54.000Z
|
2022-01-14T17:38:19.000Z
|
//
// SharedTex.cpp
// Oscilloscope
//
// Created by Hansi on 27/06/19.
//
//
#include "TexShare.h"
#include "ofMain.h"
#ifdef TARGET_OSX
#include "ofxSyphon.h"
class TexShareImpl{
public:
ofxSyphonServer server;
void setup(string name){
server.setName(name);
}
void update(ofTexture &tex){
server.publishTexture(&tex);
}
};
#elif defined TARGET_WIN32
#include "ofxSpout.h"
class TexShareImpl{
public:
ofxSpout::Sender spoutSender;
void setup(string name){
spoutSender.init(name);
}
void update(ofTexture &tex){
spoutSender.send(tex);
}
};
#else
class TexShareImpl{
public:
void setup(string name){}
void update(ofTexture & tex){};
};
#endif
TexShare::TexShare(){
impl = make_unique<TexShareImpl>();
}
TexShare::~TexShare() = default;
void TexShare::setup(string name){
impl->setup(name);
}
void TexShare::update(ofTexture &tex){
impl->update(tex);
}
| 14.483871 | 38 | 0.690423 |
pharpend
|
456ce2aad5fd617a5ed86fc8916b091e371316e3
| 423 |
cpp
|
C++
|
cph/modbus/mbqueue.cpp
|
Loggi-pro/cph-lib
|
4109dd1d3cc780c9f76aa54c2322bbdcbfdfea67
|
[
"MIT"
] | null | null | null |
cph/modbus/mbqueue.cpp
|
Loggi-pro/cph-lib
|
4109dd1d3cc780c9f76aa54c2322bbdcbfdfea67
|
[
"MIT"
] | null | null | null |
cph/modbus/mbqueue.cpp
|
Loggi-pro/cph-lib
|
4109dd1d3cc780c9f76aa54c2322bbdcbfdfea67
|
[
"MIT"
] | null | null | null |
#include "mbqueue.h"
void ModbusEventQueue::init() {
_isEventInQueue = false;
}
bool ModbusEventQueue::postEvent(MBEventType eEvent) {
_isEventInQueue = true;
_queuedEvent = eEvent;
return true;
}
bool ModbusEventQueue::getEvent(MBEventType* eEvent) {
bool isEventHappened = false;
if (_isEventInQueue) {
*eEvent = _queuedEvent;
_isEventInQueue = false;
isEventHappened = true;
}
return isEventHappened;
}
| 19.227273 | 54 | 0.747045 |
Loggi-pro
|
456cee28cc1d1ab23a90b671f5ab734025642346
| 1,778 |
cpp
|
C++
|
examples/HelloWorld/HelloWorld.cpp
|
SteveDeFacto/ovgl
|
879899f63f0dc399e2823dd84bb715fda3aafb78
|
[
"Apache-2.0"
] | 3 |
2019-02-24T23:17:49.000Z
|
2020-05-03T09:05:49.000Z
|
examples/HelloWorld/HelloWorld.cpp
|
SteveDeFacto/ovgl
|
879899f63f0dc399e2823dd84bb715fda3aafb78
|
[
"Apache-2.0"
] | null | null | null |
examples/HelloWorld/HelloWorld.cpp
|
SteveDeFacto/ovgl
|
879899f63f0dc399e2823dd84bb715fda3aafb78
|
[
"Apache-2.0"
] | null | null | null |
/**
* @file HelloWorld.cpp
* Copyright 2011 Steven Batchelor
*
* 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.
* @brief None.
*/
#include <Ovgl.h>
Ovgl::Context* context;
Ovgl::RenderTarget* render_target;
Ovgl::Window* window;
Ovgl::ResourceManager* resources;
Ovgl::Texture* texture1;
Ovgl::Interface* interface1;
Ovgl::Font* font1;
int main()
{
// Create Main Context
context = new Ovgl::Context( 0 );
// Create Window
window = new Ovgl::Window( context, "Hello World!", 320, 240);
// Create Render Target
render_target = new Ovgl::RenderTarget( context, window, Ovgl::URect( 0.0f, 0.0f, 1.0f, 1.0f ), 0 );
// Create Resource Manager
resources = new Ovgl::ResourceManager(context, "");
// Create an interface
interface1 = new Ovgl::Interface( render_target, Ovgl::URect( 0.0f, 0.0f, 1.0f, 1.0f ) );
// Load a font
font1 = new Ovgl::Font(resources, "../../media/fonts/ArchitectsDaughter.ttf", 48);
// Set interface font
interface1->font = font1;
// Set the interface text
interface1->setText("Hello World!");
// Start main loop
context->start();
// Release all
delete context;
// No errors happend so return zero
return 0;
}
| 27.78125 | 105 | 0.663105 |
SteveDeFacto
|
456d9b8f021d8459aaea5b9c07ffd93e2d8a506f
| 738 |
hpp
|
C++
|
src/cpp/iir-filter-node.hpp
|
node-3d/waa-raub
|
e458d76f290b1e12ef2a0adc063b521816337f04
|
[
"MIT"
] | 17 |
2018-10-03T00:44:33.000Z
|
2022-03-17T06:40:15.000Z
|
src/cpp/iir-filter-node.hpp
|
raub/node-waa
|
e458d76f290b1e12ef2a0adc063b521816337f04
|
[
"MIT"
] | 7 |
2019-07-16T08:22:31.000Z
|
2021-11-29T21:45:06.000Z
|
src/cpp/iir-filter-node.hpp
|
raub/node-waa
|
e458d76f290b1e12ef2a0adc063b521816337f04
|
[
"MIT"
] | 2 |
2019-08-05T20:00:42.000Z
|
2020-03-15T13:25:41.000Z
|
#ifndef _IIR_FILTER_NODE_HPP_
#define _IIR_FILTER_NODE_HPP_
#include "common.hpp"
class IIRFilterNode : public CommonNode {
DECLARE_ES5_CLASS(IIRFilterNode, IIRFilterNode);
public:
~IIRFilterNode();
explicit IIRFilterNode(const Napi::CallbackInfo &info);
static void init(Napi::Env env, Napi::Object exports);
static bool isIIRFilterNode(Napi::Object obj);
// Destroy an instance from C++ land
void _destroy();
protected:
IIRFilterNode();
static Napi::FunctionReference _constructor;
bool _isDestroyed;
private:
JS_DECLARE_METHOD(IIRFilterNode, destroy);
JS_DECLARE_GETTER(IIRFilterNode, isDestroyed);
JS_DECLARE_METHOD(IIRFilterNode, getFrequencyResponse);
};
#endif // _IIR_FILTER_NODE_HPP_
| 17.571429 | 56 | 0.768293 |
node-3d
|
456fba303c64e745bee06e191b15a89f770516b4
| 15,915 |
cpp
|
C++
|
Lambda-Lib-C++/LambdaCalc_SampleExec.cpp
|
jrandleman/Lambda-Calc-Compilation
|
488c6d1fbc92d00429aa7eb772df3fd6e0dd92c5
|
[
"MIT"
] | 1 |
2020-09-14T19:47:13.000Z
|
2020-09-14T19:47:13.000Z
|
Lambda-Lib-C++/LambdaCalc_SampleExec.cpp
|
jrandleman/Lambda-Calc-Compiler
|
488c6d1fbc92d00429aa7eb772df3fd6e0dd92c5
|
[
"MIT"
] | null | null | null |
Lambda-Lib-C++/LambdaCalc_SampleExec.cpp
|
jrandleman/Lambda-Calc-Compiler
|
488c6d1fbc92d00429aa7eb772df3fd6e0dd92c5
|
[
"MIT"
] | null | null | null |
// Author: Jordan Randleman -- LambdaCalc_SampleExec.cpp
// => Demo File to Illustrate LambdaCalc.hpp's Capabilities
#include <iostream>
#include "LambdaCalc.hpp"
/**
* -:- NAMESPACE LambdaCalc LAMBDAS -:-
* => ALL DATA IS IMMUTABLE (CONST)
* => ALL LAMBDAS ARE CURRIED ( IE Add(ox1, ox2) => Add(ox1)(ox2) )
* => CAPTURE SCOPE BY _VALUE_ (using [=]) FOR INNER - CURRIED! - LAMBDAS
*
* !!!!! GENERATE A LIST OF ARBITRARY LENGTH W/O MEMORY ALLOCATION (Push) !!!!!
*
* NOTATION:
* => let N = Church Numeral, B = Fcnal Bool, F1 = Unary Fcn, F2 = Binary Fcn,
* F = arbitrary fcn, X = arbitrary data,
* L = Fcnal List Data Structure (See More Below)
*
* ----------------------------------------------------------------------------
* - VISUALIZATION:
* ----------------------------------------------------------------------------
*
* show(X) => print arbitrary data x to screen + newline
* print(X) => print arbitrary data x to screen
*
* bshow(B) => print fcnal boolean as boolean boolean + newline
* bprint(B) => print fcnal boolean as boolean boolean
*
* nshow(N) => print church numeral as unsigned long long + newline
* nprint(N) => print church numeral as unsigned long long
*
* ----------------------------------------------------------------------------
* - FCNAL BOOLEANS:
* ----------------------------------------------------------------------------
*
* EXPLANATION:
* Fcnal Booleans are Binary Fcns, acting like C++'s Ternary '?:' operator:
* => Fcnal 'True' chooses arg1, 'False' chooses arg2
*
* BOOLEANS:
* => True
* => False
*
* BOOLEAN OPERATIONS:
* => Not (B)
* => And (B1)(B2)
* => Or (B1)(B2)
* => Xor (B1)(B2)
* => Beq (B1)(B2) => 'B'oolean 'eq'uality, ie xnor
*
* ----------------------------------------------------------------------------
* - CHURCH-NUMERAL NUMERIC FCNS:
* ----------------------------------------------------------------------------
*
* EXPLANATION:
* N-Fold Compositions of a Fcn (!!! ALL >= Zero Integers !!!):
* => IE Zero = a, Once = f(a), Twice = f(f(a)), Thrice = f(f(f(a))), etc
*
* NUMERALS:
* => Zero, Once, Twice, Thrice, Fourfold, Fivefold
* => ox0,ox1,ox2,ox3,ox4,ox5,ox6,ox7,ox8,ox9,oxa,oxb,oxc,oxd,oxe,oxf
*
* COMPARATIVE BOOLEANS:
* => Is0 (N) => Equal to 'Zero'
*
* => Eq (N1)(N2) => Equal-to
* => Lt (N1)(N2) => Less Than
* => Gt (N1)(N2) => Greater Than
* => Leq (N1)(N2) => Less Than Or Equal-to
* => Geq (N1)(N2) => Greater Than Or Equal-to
*
* => IsFactor (N1)(N2) => N1 is a factor of N2
* => Evenp (N) => N is even
* => Oddp (N) => N is odd
*
* ARITHMETIC:
* => Add (N1)(N2) => N1 + N2
* => Sub (N1)(N2) => N1 - N2
* => Mult (N1)(N2) => N1 * N2
* => Pow (N1)(N2) => N1 ** N2
* => Div (N1)(N2) => N1 / N2
* => Log (N1)(N2) => log N1 (N2)
*
* => Succ (N) => Succesor of N, N+1
* => Pred (N) => Predecessor of N, N-1
*
* => Factorial (N) => N! (w/o Loops, Recursion, or Mutability!!!)
* => NumericSum (N) => Sum (0,N)
* => NumericSumRange (N1)(N2) => Sum (N1,N2)
*
* ----------------------------------------------------------------------------
* - PURELY-FCNAL LIST DATA-STRUCTURE FCNS:
* ----------------------------------------------------------------------------
*
* CONSTRUCTION (Given List Size):
* => ListN(N) (N1) (N2) (N3) (NN) => Returns List size N of the trailing elts
*
* BASIC ANALYSIS:
* => Length (L) => Returns length of L
* => Nullp (L) => "Null" 'p'redicate: List is EMPTY
* => Pairp (L) => "Pair" 'p'redicate: List is __NOT__ EMPTY
*
* GETTERS:
* => Head (L) => Return L's 1st cell value
* => Last (L) => Return L's last cell value
* => Nth (N)(L) => Returns L's 'N'th elt (starting from 'ox1')
*
* SETTERS:
* => Insert (N)(X)(L) => Returns List w/ X inserted in L AFTER nth position
* => Erase (N)(L) => Returns List w/ L's nth value erased
* => Push (X)(L) => Returns List w/ X in front of L
* => Pop (L) => Returns List w/o L's Head
* => NOTE: "_back" versions may be self-implemented via "Backward" fcn (More Below)
*
* FILTER/MAP/VOIDMAP:
* => Filter (F1)(L) => Returns List having filtered out elts from L __NOT__ passing F1
* => Map (F1)(L) => Returns List having mapped F1 across all of L's elts
* => VoidMap (F1)(L) => Returns Void & F1 Must be void => Applie Fcn to each elt in L
* (useful for passing a "printer" fcn (ie nshow) to print each elt)
*
* REVERSED LIST & FCN APPLICATION:
* => Reverse (L) => Returns List of L in reverse
* => FlipArgs (F2) => Flips args for a Binary Fcn
* => Backward (F1)(L) => Returns List having applied F on Reverse(L)
* => BackwardAtomic (F1)(L) => Returns Atom (ie Non-List Fcn, such as a
* Church Numeral) having applied F on Reverse(L)
* ACCUMULATORS:
* => Foldl (F2)(X)(L) => Applies F2 on L from 'l'eft to right,
* starting w/ 'X' & Head(L)
* => Foldr (F2)(X)(L) => Applies F2 on L from 'r'ight to left,
* starting w/ 'X' & Last(L)
* MAX/MIN:
* => Max (L) => Returns Greatest value in List
* => Min (L) => Returns Smallest value in List
*
* LISP-STYLE ACCESS:
* => car (L) => Returns Current Cell Value ( IE Head(L) )
* => cdr (L) => Returns Next Cell ( IE Pop(L) )
* => cadr (L) => Head(Pop(L))
* => caddr (L) => Head(Pop(Pop(L)))
* => cadddr (L) => Head(Pop(Pop(Pop(L))))
* => ANY combo of 1-4 'a's & 'd's btwn 'c' & 'r' for nested list access!
*
* ----------------------------------------------------------------------------
* - IF YOU'VE GOTTEN THIS FAR ...
* ----------------------------------------------------------------------------
*
* You may genuinely enjoy the 2 JS Lambda Calculus videos below, found at:
* => Part 1: https://www.youtube.com/watch?v=3VQ382QG-y4&feature=youtu.be
* => Part 2: https://www.youtube.com/watch?v=pAnLQ9jwN-E
*
* In Summary:
* => Identity/Once, Idiot: I := \a.a
* => First/True/Const, Kestrel: K := \ab.a
* => Flip/LogicalNot, Cardinal: C := \fab.fba
* => Unary Compose, Bluebird: B := \fga.f(ga)
*
* => Self-Replication, Mockingbird M := \f.f(f) => IMPOSSIBLE IN HASKELL (Infinite Data Struct)
*
* => Second/False/Zero, Kite: KI := \ab.b = K I = C K
* => Binary Compose, Blackbird: B1 := \fgab.f(gab) = B B B
* => Hold An Arg, Thrush: Th := \af.fa = C I
* => Hold Arg Pair, Vireo: V := \abf.fab = B C Th = B C (C I)
*/
/******************************************************************************
* CURRIED FUNCTIONS & LAMBDA CALCULUS EXECUTION C++
******************************************************************************/
int main() {
using namespace LambdaCalc;
show("\nUsing Fcnal Booleans:");
print(" => Not(True): ");
bshow(Not(True));
print(" => Not(False): ");
bshow(Not(False));
print(" => And(True)(False): ");
bshow(And(True)(False));
print(" => And(True)(True): ");
bshow(And(True)(True));
print(" => And(False)(False): ");
bshow(And(False)(False));
print(" => Or(True)(False): ");
bshow(Or(True)(False));
print(" => Or(False)(False): ");
bshow(Or(False)(False));
print(" => Or(True)(True): ");
bshow(Or(True)(True));
print(" => Xor(False)(True): ");
bshow(Xor(False)(True));
print(" => Xor(True)(True): ");
bshow(Xor(True)(True));
print(" => Xor(False)(False): ");
bshow(Xor(False)(False));
print(" => Beq(True)(False): ");
bshow(Beq(True)(False));
print(" => Beq(True)(True): ");
bshow(Beq(True)(True));
print(" => Beq(False)(False): ");
bshow(Beq(False)(False));
show("\n\n\nUsing Church Numerals (0-15 shown as Hex w/ 'o' prefix):");
print(" => Is0(ox5): ");
bshow(Is0(ox5));
print(" => Is0(ox0): ");
bshow(Is0(ox0));
show("");
print(" => Eq(ox2)(ox8): ");
bshow(Eq(ox2)(ox8));
print(" => Eq(ox2)(ox2): ");
bshow(Eq(ox2)(ox2));
print(" => Lt(ox2)(ox8): ");
bshow(Lt(ox2)(ox8));
print(" => Lt(ox8)(ox2): ");
bshow(Lt(ox8)(ox2));
print(" => Lt(ox8)(ox8): ");
bshow(Lt(ox8)(ox8));
print(" => Gt(ox2)(ox8): ");
bshow(Gt(ox2)(ox8));
print(" => Gt(ox8)(ox2): ");
bshow(Gt(ox8)(ox2));
print(" => Gt(ox8)(ox8): ");
bshow(Gt(ox8)(ox8));
print(" => Leq(ox2)(ox8): ");
bshow(Leq(ox2)(ox8));
print(" => Leq(ox8)(ox2): ");
bshow(Leq(ox8)(ox2));
print(" => Leq(ox8)(ox8): ");
bshow(Leq(ox8)(ox8));
print(" => Geq(ox2)(ox8): ");
bshow(Geq(ox2)(ox8));
print(" => Geq(ox8)(ox2): ");
bshow(Geq(ox8)(ox2));
print(" => Geq(ox8)(ox8): ");
bshow(Geq(ox8)(ox8));
show("");
print(" => IsFactor(ox3)(oxc): ");
bshow(IsFactor(ox2)(ox4));
print(" => IsFactor(ox3)(oxd): ");
bshow(IsFactor(ox2)(ox7));
print(" => Evenp(ox6): ");
bshow(Evenp(ox6));
print(" => Evenp(ox9): ");
bshow(Evenp(ox9));
print(" => Oddp(ox6): ");
bshow(Oddp(ox6));
print(" => Oddp(ox9): ");
bshow(Oddp(ox9));
show("");
print(" => Add(oxf)(oxa): ");
nshow(Add(oxf)(oxa));
print(" => Sub(oxb)(ox6): ");
nshow(Sub(oxb)(ox6));
print(" => Mult(ox3)(ox7): ");
nshow(Mult(ox3)(ox7));
print(" => Pow(ox2)(ox5): ");
nshow(Pow(ox2)(ox5));
print(" => Div(Mult(ox2)(oxa))(ox4): ");
nshow(Div(Mult(ox2)(oxa))(ox4));
print(" => Log(ox2)(ox8): ");
nshow(Log(ox2)(ox8));
show("");
print(" => Succ(ox8): ");
nshow(Succ(ox8));
print(" => Pred(ox8): ");
nshow(Pred(ox8));
show("");
print(" => Factorial(ox5): ");
nshow(Factorial(ox5));
print(" => NumericSum(oxa): ");
nshow(NumericSum(oxa));
print(" => NumericSumRange(ox5)(oxa): ");
nshow(NumericSumRange(ox5)(oxa));
show("\n\n\nUsing The Purely-Fcnal \"ListN\" Data Structure:");
show(" => We have defined 2 lists:");
show(" (1) List of 5 Church Numerals:");
show(" List1 = ListN(ox5) (ox9) (ox4) (ox7) (ox3) (oxa);");
const auto List1 = ListN(ox5) (ox9) (ox4) (ox7) (ox3) (oxa);
show(" (2) Empty List:");
show(" List2 = ListN(ox0);");
const auto List2 = ListN(ox0);
show("\nBASIC ANALYSIS:");
print(" => Length(List1): ");
nshow(Length(List1));
print(" => Length(List2): ");
nshow(Length(List2));
show(" => Whether list IS or IS NOT empty:");
print(" - Nullp(List1): ");
bshow(Nullp(List1));
print(" - Nullp(List2): ");
bshow(Nullp(List2));
print(" - Pairp(List1): ");
bshow(Pairp(List1));
print(" - Pairp(List2): ");
bshow(Pairp(List2));
show("\nGETTERS:");
print(" => Head(List1): ");
nshow(Head(List1));
print(" => Last(List1): ");
nshow(Last(List1));
print(" => Nth(ox1)(List1): ");
nshow(Nth(ox1)(List1));
print(" => Nth(ox2)(List1): ");
nshow(Nth(ox2)(List1));
print(" => Nth(ox3)(List1): ");
nshow(Nth(ox3)(List1));
print(" => Nth(ox4)(List1): ");
nshow(Nth(ox4)(List1));
print(" => Nth(ox5)(List1): ");
nshow(Nth(ox5)(List1));
show("\nSETTERS:");
print(" => Length(Push(oxd)(List1)): ");
nshow(Length(Push(oxd)(List1)));
print(" => Head(Push(oxd)(List1)): ");
nshow(Head(Push(oxd)(List1)));
print(" => Length(Pop(List1)): ");
nshow(Length(Pop(List1)));
print(" => Head(Pop(List1)): ");
nshow(Head(Pop(List1)));
print(" => Length(Push(oxf)(List2)): ");
nshow(Length(Push(oxf)(List2)));
print(" => Head(Push(oxf)(List2)): ");
nshow(Head(Push(oxf)(List2)));
print(" => Length(Pop(Push(oxf)(List2))): ");
nshow(Length(Pop(Push(oxf)(List2))));
print(" => Erase(ox3)(List1) = ");
VoidMap(nprint)(Erase(ox3)(List1));
print("\n => Insert(ox3)(oxc)(List1) = ");
VoidMap(nprint)(Insert(ox3)(oxc)(List1));
show("");
show("\nFILTER/MAP/VOIDMAP:");
show(" => We have defined more 2 lists:");
show(" (1) List of odd Church Numerals from List1:");
show(" OnlyOdds = Filter(Oddp)(List1);");
const auto OnlyOdds = Filter(Oddp)(List1);
show(" (2) List of 2 raised to each value in List1:");
show(" PowersOf2 = Map(Pow(ox2))(List1);\n");
const auto PowersOf2 = Map(Pow(ox2))(List1);
show(" => Using \"VoidMap\" to map a Void printer fcn across these Lists:");
show(" (*) NOTE: \"nprint()\" = void lambda to print Church Numerals as ints!");
print(" (1) VoidMap(nprint)(OnlyOdds) = ");
VoidMap(nprint)(OnlyOdds);
show("");
print(" (2) VoidMap(nprint)(PowersOf2) = ");
VoidMap(nprint)(PowersOf2);
show("\n\nREVERSED LIST & REVERSED FCN APPLICATION:");
print(" => List1 = ");
VoidMap(nprint)(List1);
print("\n => Reverse(List1) = ");
VoidMap(nprint)(Reverse(List1));
print("\n => Pow(ox2)(ox3) = ");
nshow(Pow(ox2)(ox3));
print(" => FlipArgs(Pow)(ox2)(ox3) = ");
nshow(FlipArgs(Pow)(ox2)(ox3));
print(" => Push(oxf)(List1) = ");
VoidMap(nprint)(Push(oxf)(List1));
print("\n => Backward(Push(oxf))(List1) = ");
VoidMap(nprint)(Backward(Push(oxf))(List1));
show("\n => We have defined 1 more List: List3 = ListN(ox2) (ox2)(ox3);");
const auto List3 = ListN(ox2) (ox2)(ox3);
print(" -> Foldl(Pow)(ox1)(List3) = ");
nprint(Foldl(Pow)(ox1)(List3));
print("\n -> BackwardAtomic(Foldl(Pow)(ox1))(List3) = ");
nshow(BackwardAtomic(Foldl(Pow)(ox1))(List3));
show("\nACCUMULATORS:");
show(" => Both Accumulators have already been shown, 1 more subtly so:");
print(" -> Foldl(Pow)(ox1)(List3) = ");
nshow(Foldl(Pow)(ox1)(List3));
print(" -> Foldr(Pow)(ox1)(List3) = ");
nprint(Foldr(Pow)(ox1)(List3));
show(" // \"Foldr\" = \"BackwardAtomic\" . \"Foldl\"!");
show("\nMAX/MIN:");
print(" => Max(List1) = ");
nshow(Max(List1));
print(" => Min(List1) = ");
nshow(Min(List1));
show("\nLISP-STYLE ACCESS:");
print(" => List1 = ");
VoidMap(nprint)(List1);
print("\n => car(List1) = ");
nshow(car(List1));
print(" => cdr(List1) = ");
VoidMap(nprint)(cdr(List1));
print("\n => cadr(List1) = ");
nshow(cadr(List1));
print(" => caddr(List1) = ");
nshow(caddr(List1));
print(" => cadddr(List1) = ");
nshow(cadddr(List1));
show("\nLISTS OF LISTS:");
const auto SuperList1 = ListN(ox3) (ListN(ox2) (ox4) (ox5)) (ListN(ox3) (oxa) (ox2) (ox3)) (ListN(ox1) (ox8));
show(" => We have defined a list of 3 lists:");
show(" (*) // SuperList1 = [ [4, 5], [10, 2, 3], [8] ]");
show(" (0) SuperList1 = ListN(ox3) (ListN(ox2) (ox4) (ox5)) (ListN(ox3) (oxa) (ox2) (ox3)) (ListN(ox1) (ox8));\n");
print(" => Head(Head(SuperList1)) = ");
nshow(Head(Head(SuperList1)));
print(" => Last(Last(SuperList1)) = ");
nshow(Last(Last(SuperList1)));
print(" => Nth(ox1)(Nth(ox2)(SuperList1)) = ");
nshow(Nth(ox1)(Nth(ox2)(SuperList1)));
show(" => Using LISP Notation:");
print(" -> caar(SuperList1) = ");
nshow(caar(SuperList1));
print(" -> caaddr(SuperList1) = ");
nshow(caaddr(SuperList1));
print(" -> caadr(SuperList1) = ");
nshow(caadr(SuperList1));
show("\nLIST OF MULTIPLE-TYPED ELTS:");
show(" => We have defined a list w/ a float, String, & Church Numeral:");
show(" (0) multi_type_list = ListN(ox3) (3.14159) (\"Talk about dynamic!\") (oxd);");
const auto multi_type_list = ListN(ox3) (3.14159) ("Talk about dynamic!") (oxd);
print("\n => car(multi_type_list) = ");
show(car(multi_type_list));
print(" => cadr(multi_type_list) = ");
show(cadr(multi_type_list));
print(" => caddr(multi_type_list) = ");
nshow(caddr(multi_type_list));
show("\nBye!\n");
return 0;
}
| 35.13245 | 121 | 0.507823 |
jrandleman
|
45774a243eba9339b1d84de55198c4399b64d3f2
| 954 |
hpp
|
C++
|
main/inou_rand_api.hpp
|
tamim-asif/lgraph-private
|
733bbcd9e14a9850580b51c011e33785ab758b9d
|
[
"BSD-3-Clause"
] | null | null | null |
main/inou_rand_api.hpp
|
tamim-asif/lgraph-private
|
733bbcd9e14a9850580b51c011e33785ab758b9d
|
[
"BSD-3-Clause"
] | null | null | null |
main/inou_rand_api.hpp
|
tamim-asif/lgraph-private
|
733bbcd9e14a9850580b51c011e33785ab758b9d
|
[
"BSD-3-Clause"
] | null | null | null |
#include "inou_rand.hpp"
#include "main_api.hpp"
class Inou_rand_api {
protected:
static void tolg(Eprp_var &var) {
Inou_rand rand;
for(const auto &l:var.dict) {
rand.set(l.first,l.second);
}
std::vector<LGraph *> lgs = rand.tolg();
if (lgs.empty()) {
Main_api::warn(fmt::format("inou.rand could not create a random {} lgraph in {} path", var.get("name"), var.get("path")));
}else{
assert(lgs.size()==1); // rand only generated one graph at a time
var.add(lgs[0]);
}
}
public:
static void setup(Eprp &eprp) {
Eprp_method m1("inou.rand", "generate a random lgraph", &Inou_rand_api::tolg);
m1.add_label_optional("path","lgraph path");
m1.add_label_required("name","lgraph name");
m1.add_label_optional("seed","random seed");
m1.add_label_optional("size","lgraph size");
m1.add_label_optional("eratio","edge ratio for random");
eprp.register_method(m1);
}
};
| 24.461538 | 128 | 0.638365 |
tamim-asif
|
457799f6c60e7d7a5d1685b8781ec801a174ca43
| 3,127 |
hpp
|
C++
|
GameEngine/Systems/ButtonSystem.hpp
|
Epitech-Tek2/superBonobros2
|
525ab414215f5b67829bf200797c2055141cb7b9
|
[
"MIT"
] | null | null | null |
GameEngine/Systems/ButtonSystem.hpp
|
Epitech-Tek2/superBonobros2
|
525ab414215f5b67829bf200797c2055141cb7b9
|
[
"MIT"
] | null | null | null |
GameEngine/Systems/ButtonSystem.hpp
|
Epitech-Tek2/superBonobros2
|
525ab414215f5b67829bf200797c2055141cb7b9
|
[
"MIT"
] | null | null | null |
/*
** EPITECH PROJECT, 2020
** B-CPP-501-STG-5-1-rtype-romuald1.soultan
** File description:
** ButtonSystem
*/
#ifndef BUTTONSYSTEM_HPP_
#define BUTTONSYSTEM_HPP_
#include "ASystem.hpp"
#include "ECS.hpp"
#include "AScene.hpp"
#include "AGame.hpp"
#include "ASystem.hpp"
#include "ClickableComponent.hpp"
#include "ShapeComponent.hpp"
#include "Transform2DComponent.hpp"
#include "BaseColorComponent.hpp"
#include "TextureComponent.hpp"
#include "ButtonActionComponent.hpp"
namespace gameEngine {
class ButtonSystem : public gameEngine::ASystem {
public:
ButtonSystem(gameEngine::ECS *ecs) : gameEngine::ASystem(ecs) {}
void init(gameEngine::ECS *ecs)
{
ecs->systemAddDependances<gameEngine::ClickableComponent>(this);
ecs->systemAddDependances<gameEngine::TextureComponent>(this);
ecs->systemAddDependances<gameEngine::ShapeComponent>(this);
ecs->systemAddDependances<gameEngine::Transform2DComponent>(this);
ecs->systemAddDependances<gameEngine::BaseColorComponent>(this);
ecs->systemAddDependances<gameEngine::ButtonActionComponent>(this);
}
~ButtonSystem(void) = default;
private:
void action(std::shared_ptr<gameEngine::AEntity> entity, float)
{
Color const &baseColor = _ecs->getEntityComponent<gameEngine::BaseColorComponent>(entity)._color;
Color &color = _ecs->getEntityComponent<gameEngine::TextureComponent>(entity)._color;
ClickableComponent::MouseState const state = _ecs->getEntityComponent<gameEngine::ClickableComponent>(entity).state;
ButtonActionComponent &action = _ecs->getEntityComponent<gameEngine::ButtonActionComponent>(entity);
short red = 0;
short green = 0;
short blue = 0;
switch (state) {
case ClickableComponent::MouseState::OnButton:
red = baseColor.red - 30;
green = baseColor.green - 30;
blue = baseColor.blue - 30;
color.red = (red < 0 ? 0:red);
color.green = (green < 0 ? 0:green);
color.blue = (blue < 0 ? 0:blue);
break;
case ClickableComponent::MouseState::HoldClick:
red = baseColor.red - 60;
green = baseColor.green - 60;
blue = baseColor.blue - 60;
color.red = (red < 0 ? 0:red);
color.green = (green < 0 ? 0:green);
color.blue = (blue < 0 ? 0:blue);
break;
case ClickableComponent::MouseState::Released:
action._action();
break;
default:
color = baseColor;
break;
}
}
};
}
#endif /* !BUTTONSYSTEM_HPP_ */
| 39.582278 | 132 | 0.549089 |
Epitech-Tek2
|
4577c52083767b5b1ed8420cedc7326e012220ed
| 875 |
cpp
|
C++
|
coast/modules/Renderer/SubStringRenderer.cpp
|
zer0infinity/CuteForCoast
|
37d933c5fe2e0ce9a801f51b2aa27c7a18098511
|
[
"BSD-3-Clause"
] | null | null | null |
coast/modules/Renderer/SubStringRenderer.cpp
|
zer0infinity/CuteForCoast
|
37d933c5fe2e0ce9a801f51b2aa27c7a18098511
|
[
"BSD-3-Clause"
] | null | null | null |
coast/modules/Renderer/SubStringRenderer.cpp
|
zer0infinity/CuteForCoast
|
37d933c5fe2e0ce9a801f51b2aa27c7a18098511
|
[
"BSD-3-Clause"
] | null | null | null |
/*
* Copyright (c) 2005, Peter Sommerlad and IFS Institute for Software at HSR Rapperswil, Switzerland
* All rights reserved.
*
* This library/application is free software; you can redistribute and/or modify it under the terms of
* the license that is included with this library/application in the file license.txt.
*/
#include "SubStringRenderer.h"
RegisterRenderer(SubStringRenderer);
void SubStringRenderer::RenderAll(std::ostream &reply, Context &ctx, const ROAnything &config) {
StartTrace(SubStringRenderer.RenderAll);
String str;
Renderer::RenderOnString(str, ctx, config["String"]);
if (str.Length()) {
long start = RenderToString(ctx, config["Start"]).AsLong(0L);
long len = RenderToString(ctx, config["Length"]).AsLong(-1L);
String ret(str.SubString(start, len));
Trace("SubString(" << start << "," << len << ")-->" << ret);
reply << ret;
}
}
| 38.043478 | 102 | 0.718857 |
zer0infinity
|
4578b38a6b3f01fa80365cd43053e30c3d4c7513
| 65 |
cpp
|
C++
|
cpp_data_structure_and_algorithm/day9/IndexMaxHeap.cpp
|
xcyi2017/Agorithm
|
bae9918b0758624ecd1f94a3ca1692050c193a29
|
[
"Apache-2.0"
] | 1 |
2020-11-15T09:40:47.000Z
|
2020-11-15T09:40:47.000Z
|
cpp_data_structure_and_algorithm/day9/IndexMaxHeap.cpp
|
xcyi2017/Agorithm
|
bae9918b0758624ecd1f94a3ca1692050c193a29
|
[
"Apache-2.0"
] | null | null | null |
cpp_data_structure_and_algorithm/day9/IndexMaxHeap.cpp
|
xcyi2017/Agorithm
|
bae9918b0758624ecd1f94a3ca1692050c193a29
|
[
"Apache-2.0"
] | null | null | null |
//
// Created by xcy on 2020/10/5.
//
#include "IndexMaxHeap.h"
| 10.833333 | 31 | 0.630769 |
xcyi2017
|
457bc8521fdebe0808d93f1cd867ad9f31f5b80e
| 835 |
cpp
|
C++
|
CameraShake/MyCameraShake.cpp
|
H4DC0R3/unrealcpp
|
b0f5667cb20711d740a6fb0cb5064efc6873c948
|
[
"MIT"
] | 765 |
2018-01-03T14:58:37.000Z
|
2022-03-29T16:03:13.000Z
|
CameraShake/MyCameraShake.cpp
|
shyaZhou/unrealcpp
|
e998d89ce6c8d5484c084f395d2eca5e247b88bf
|
[
"MIT"
] | 1 |
2019-09-26T09:33:50.000Z
|
2020-12-11T05:17:13.000Z
|
CameraShake/MyCameraShake.cpp
|
shyaZhou/unrealcpp
|
e998d89ce6c8d5484c084f395d2eca5e247b88bf
|
[
"MIT"
] | 166 |
2018-02-20T07:36:12.000Z
|
2022-03-25T07:49:03.000Z
|
// Harrison McGuire
// UE4 Version 4.20.2
// https://github.com/Harrison1/unrealcpp
// https://severallevels.io
// https://harrisonmcguire.com
#include "MyCameraShake.h"
// Helpful Links
// http://api.unrealengine.com/INT/API/Runtime/Engine/Camera/UCameraShake/index.html
//
// Great explanation of camera shake values
// https://www.youtube.com/watch?v=Oice8gdpX6s
#include "MyCameraShake.h"
// Sets default values
UMyCameraShake::UMyCameraShake()
{
OscillationDuration = 0.25f;
OscillationBlendInTime = 0.05f;
OscillationBlendOutTime = 0.05f;
RotOscillation.Pitch.Amplitude = FMath::RandRange(5.0f, 10.0f);
RotOscillation.Pitch.Frequency = FMath::RandRange(25.0f, 35.0f);
RotOscillation.Yaw.Amplitude = FMath::RandRange(5.0f, 10.0f);
RotOscillation.Yaw.Frequency = FMath::RandRange(25.0f, 35.0f);
}
| 27.833333 | 84 | 0.731737 |
H4DC0R3
|
4584d9705bc128ecf32ee9da4ab82849fdd83607
| 2,241 |
hpp
|
C++
|
falcon/mpl/placeholders.hpp
|
jonathanpoelen/falcon
|
5b60a39787eedf15b801d83384193a05efd41a89
|
[
"MIT"
] | 2 |
2018-02-02T14:19:59.000Z
|
2018-05-13T02:48:24.000Z
|
falcon/mpl/placeholders.hpp
|
jonathanpoelen/falcon
|
5b60a39787eedf15b801d83384193a05efd41a89
|
[
"MIT"
] | null | null | null |
falcon/mpl/placeholders.hpp
|
jonathanpoelen/falcon
|
5b60a39787eedf15b801d83384193a05efd41a89
|
[
"MIT"
] | null | null | null |
#ifndef FALCON_MPL_PLACEHOLDERS_HPP
#define FALCON_MPL_PLACEHOLDERS_HPP
#include <falcon/mpl/arg.hpp>
namespace falcon {
namespace mpl {
namespace placeholders {
using _1 = arg<1>;
using _2 = arg<2>;
using _3 = arg<3>;
using _4 = arg<4>;
using _5 = arg<5>;
using _6 = arg<6>;
using _7 = arg<7>;
using _8 = arg<8>;
using _9 = arg<9>;
using _10 = arg<10>;
using _11 = arg<11>;
using _12 = arg<12>;
using _13 = arg<13>;
using _14 = arg<14>;
using _15 = arg<15>;
using _16 = arg<16>;
using _17 = arg<17>;
using _18 = arg<18>;
using _19 = arg<19>;
using _20 = arg<20>;
using _21 = arg<21>;
using _22 = arg<22>;
using _23 = arg<23>;
using _24 = arg<24>;
using _25 = arg<25>;
using _26 = arg<26>;
using _27 = arg<27>;
using _28 = arg<28>;
using _29 = arg<29>;
using _30 = arg<30>;
using _31 = arg<31>;
using _32 = arg<32>;
using _33 = arg<33>;
using _34 = arg<34>;
using _35 = arg<35>;
using _36 = arg<36>;
using _37 = arg<37>;
using _38 = arg<38>;
using _39 = arg<39>;
using _40 = arg<40>;
using _41 = arg<41>;
using _42 = arg<42>;
using _43 = arg<43>;
using _44 = arg<44>;
using _45 = arg<45>;
using _46 = arg<46>;
using _47 = arg<47>;
using _48 = arg<48>;
using _49 = arg<49>;
using _50 = arg<50>;
using _51 = arg<51>;
using _52 = arg<52>;
using _53 = arg<53>;
using _54 = arg<54>;
using _55 = arg<55>;
using _56 = arg<56>;
using _57 = arg<57>;
using _58 = arg<58>;
using _59 = arg<59>;
using _60 = arg<60>;
using _61 = arg<61>;
using _62 = arg<62>;
using _63 = arg<63>;
using _64 = arg<64>;
using _65 = arg<65>;
using _66 = arg<66>;
using _67 = arg<67>;
using _68 = arg<68>;
using _69 = arg<69>;
using _70 = arg<70>;
using _71 = arg<71>;
using _72 = arg<72>;
using _73 = arg<73>;
using _74 = arg<74>;
using _75 = arg<75>;
using _76 = arg<76>;
using _77 = arg<77>;
using _78 = arg<78>;
using _79 = arg<79>;
using _80 = arg<80>;
using _81 = arg<81>;
using _82 = arg<82>;
using _83 = arg<83>;
using _84 = arg<84>;
using _85 = arg<85>;
using _86 = arg<86>;
using _87 = arg<87>;
using _88 = arg<88>;
using _89 = arg<89>;
using _90 = arg<90>;
using _91 = arg<91>;
using _92 = arg<92>;
using _93 = arg<93>;
using _94 = arg<94>;
using _95 = arg<95>;
using _96 = arg<96>;
using _97 = arg<97>;
using _98 = arg<98>;
using _99 = arg<99>;
}
}
}
#endif
| 19.486957 | 35 | 0.629183 |
jonathanpoelen
|
4586a2f0f7b631495373c018c934fe3720aeba6d
| 2,998 |
cc
|
C++
|
sieve2015/src/presieved_primes.cc
|
mhdeleglise/Gh
|
21a0b9bd53ae9de17f8b99040cac95cd6e1897e4
|
[
"MIT"
] | null | null | null |
sieve2015/src/presieved_primes.cc
|
mhdeleglise/Gh
|
21a0b9bd53ae9de17f8b99040cac95cd6e1897e4
|
[
"MIT"
] | null | null | null |
sieve2015/src/presieved_primes.cc
|
mhdeleglise/Gh
|
21a0b9bd53ae9de17f8b99040cac95cd6e1897e4
|
[
"MIT"
] | null | null | null |
#include<mylib.h>
namespace presieved_primes{
long32 presieve_base;
long32 number_of_presieve_primes;
long32 sum_of_presieve_primes;
long32 small_primes[5] = {2, 3, 5, 7, 11};
int primes_initialized = 0;
long* Sp;
void init_presieve(int nbps) {
switch (nbps) {
case 2:
presieve_base = 6;
number_of_presieve_primes = 2;
sum_of_presieve_primes = 5;
number_of_presieve_primes = 2;
break;
case 3:
presieve_base = 30;
number_of_presieve_primes = 3;
sum_of_presieve_primes = 10;
number_of_presieve_primes = 3;
break;
case 4:
presieve_base = 210;
number_of_presieve_primes = 4;
sum_of_presieve_primes = 17;
number_of_presieve_primes = 4;
break;
case 5:
presieve_base = 2310;
number_of_presieve_primes = 5;
sum_of_presieve_primes = 28;
number_of_presieve_primes = 5;
break;
}
}
prime_table<sieve_by_slice<bit_table_cnte, long> > T;
long32
prime(long32 i) { return T.prime(i);}
long32
piB(long32 i) { return T.piB(i); }
long32
number_of_primes() { return T.get_number_of_primes(); }
long32
max_prime() {return prime(T.get_number_of_primes());}
long32
index_of_first_prime_bigger_than(long32 x)
{
return T.index_of_first_prime_bigger_than(x);
}
void
init_prime_table(long32 upto, int nbps)
{
if (nbps > 5) {
cout << "init_prime_table error called with upto = " << upto << " and nbps = " << nbps << endl\
<< "nbps, the number_of_presieved primes must be less or equal to 5\n";
error();
}
init_presieve(nbps);
//cout << "init_prime_table : presieve_base set to " << presieved_primes::presieve_base << endl;
T.create(upto, presieved_primes::presieve_base);
primes_initialized = 1;
#ifdef DEBUG_PRIMES
cout << "\nprime_table::is_created first non presieved prime = " << presieved_primes::prime(1) << endl;;
cout << "presieved_primes::number_of_primes() = " << presieved_primes::number_of_primes() << endl;
cout << "presieved_primes::max_prime() = " << presieved_primes::max_prime() << endl << endl;
#endif
}
void display() {
cout << "\nPrime_table created\n";
cout << " number of presieved primes = " << presieved_primes::number_of_presieve_primes << endl;
cout << " first non presieved prime = " << presieved_primes::prime(1) << endl;;
cout << " presieved_primes::number_of_primes() = " << presieved_primes::number_of_primes() << endl;
cout << " presieved_primes::max_prime() = " << presieved_primes::max_prime() << endl << endl;
}
void
display_prime_table() { T.display();}
void init_sum_primes() {
Sp= new long[1+number_of_primes()];
long sum=0;
for (int i=1; i <= number_of_primes(); i++) {
sum+=T.prime(i);
Sp[i]=sum;
}
}
}
| 29.106796 | 110 | 0.616077 |
mhdeleglise
|
4586e007716ddb33e39503120febcfcd9f469dcd
| 2,706 |
cpp
|
C++
|
checks/rng.cpp
|
vster/OpenCL
|
fb29aead4e6345e23f3f7ba5fb038fa1fd217e10
|
[
"BSD-2-Clause"
] | 46 |
2015-12-04T17:12:58.000Z
|
2022-03-11T04:30:49.000Z
|
checks/rng.cpp
|
vster/OpenCL
|
fb29aead4e6345e23f3f7ba5fb038fa1fd217e10
|
[
"BSD-2-Clause"
] | null | null | null |
checks/rng.cpp
|
vster/OpenCL
|
fb29aead4e6345e23f3f7ba5fb038fa1fd217e10
|
[
"BSD-2-Clause"
] | 23 |
2016-10-24T09:18:14.000Z
|
2022-02-25T02:11:35.000Z
|
/* This file is in the public domain */
#include <string>
#include <opencl/filters.h>
#include <opencl/square.h>
#include <opencl/randpool.h>
#include <opencl/x917.h>
#if defined(OPENCL_EXT_ENTROPY_SRC_DEVRANDOM)
#include <opencl/devrand.h>
#endif
#if defined(OPENCL_EXT_ENTROPY_SRC_PTHREAD)
#include <opencl/pthr_ent.h>
#endif
using namespace OpenCL;
/*************************************************/
/*
This is the global RNG used in various spots. Seems to make most sense to
declare it here.
*/
OpenCL::X917<OpenCL::Square> local_rng;
OpenCL::RandomNumberGenerator& rng = local_rng;
/*************************************************/
/* Not too useful generally; just dumps random bits */
template<typename R>
class RNG_Filter : public Filter
{
public:
void write(const byte[], u32bit);
private:
static const u32bit BUFFERSIZE = OpenCL::DEFAULT_BUFFERSIZE;
R rng;
SecureBuffer<byte, BUFFERSIZE> buffer;
u32bit position;
};
template<typename B>
void RNG_Filter<B>::write(const byte input[], u32bit length)
{
buffer.copy(position, input, length);
if(position + length >= BUFFERSIZE)
{
rng.randomize(buffer, BUFFERSIZE);
send(buffer, BUFFERSIZE);
input += (BUFFERSIZE - position);
length -= (BUFFERSIZE - position);
while(length >= BUFFERSIZE)
{
/* This actually totally ignores the input, but it doesn't matter,
because this is only for benchmark purposes and we just want to
test speed. Anyway, if the RNG is good you can't tell the diff */
rng.randomize(buffer, BUFFERSIZE);
send(buffer, BUFFERSIZE);
input += BUFFERSIZE;
length -= BUFFERSIZE;
}
buffer.copy(input, length);
position = 0;
}
position += length;
}
/* A wrappr class to convert an EntropySource into a psudoe-RNG */
template<typename E>
class ES_TO_RNG
{
public:
void randomize(byte buf[], u32bit size)
{
u32bit need = size;
while(need) need -= es.slow_poll(buf + size - need, need);
}
private:
E es;
};
Filter* lookup_rng(const std::string& algname)
{
if(algname == "X917<Square>")
return new RNG_Filter< X917<Square> >;
else if(algname == "Randpool")
return new RNG_Filter<Randpool>;
#if defined(OPENCL_EXT_ENTROPY_SRC_DEVRANDOM)
else if(algname == "EntropySrc_DevRandom")
return new RNG_Filter< ES_TO_RNG<DevRandom_EntropySource> >;
#endif
#if defined(OPENCL_EXT_ENTROPY_SRC_PTHREAD)
else if(algname == "EntropySrc_Pthread")
return new RNG_Filter< ES_TO_RNG<Pthread_EntropySource> >;
#endif
else return 0;
}
| 26.271845 | 77 | 0.636364 |
vster
|
4588b724efd0ce0f13cef267f2da3c49f709e55c
| 8,657 |
cpp
|
C++
|
intro/messageworld/messageworld.cpp
|
return/BeOSSampleCode
|
ca5a319fecf425a69e944f3c928a85011563a932
|
[
"BSD-3-Clause"
] | 5 |
2018-09-09T21:01:57.000Z
|
2022-03-27T10:01:27.000Z
|
intro/messageworld/messageworld.cpp
|
return/BeOSSampleCode
|
ca5a319fecf425a69e944f3c928a85011563a932
|
[
"BSD-3-Clause"
] | null | null | null |
intro/messageworld/messageworld.cpp
|
return/BeOSSampleCode
|
ca5a319fecf425a69e944f3c928a85011563a932
|
[
"BSD-3-Clause"
] | 5 |
2018-04-03T01:45:23.000Z
|
2021-05-14T08:23:01.000Z
|
//
// Menu World
//
// A sample program demonstrating the basics of using
// the BMessage and BMessenger classes.
//
// Written by: Eric Shepherd
//
/*
Copyright 1999, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License.
*/
#include <Application.h>
#include <Messenger.h>
#include <Message.h>
#include <Roster.h>
#include <Window.h>
#include <View.h>
#include <MenuBar.h>
#include <Menu.h>
#include <MenuItem.h>
#include <string.h>
#include <stdio.h>
// Application's signature
const char *APP_SIGNATURE = "application/x-vnd.Be-MessageWorld";
// Messages for window registry with application
const uint32 WINDOW_REGISTRY_ADD = 'WRad';
const uint32 WINDOW_REGISTRY_SUB = 'WRsb';
const uint32 WINDOW_REGISTRY_ADDED = 'WRdd';
// Messages for menu commands
const uint32 MENU_FILE_NEW = 'MFnw';
const uint32 MENU_FILE_OPEN = 'MFop';
const uint32 MENU_FILE_CLOSE = 'MFcl';
const uint32 MENU_FILE_SAVE = 'MFsv';
const uint32 MENU_FILE_SAVEAS = 'MFsa';
const uint32 MENU_FILE_PAGESETUP = 'MFps';
const uint32 MENU_FILE_PRINT = 'MFpr';
const uint32 MENU_FILE_QUIT = 'MFqu';
const uint32 MENU_OPT_HELLO = 'MOhl';
const char *STRING_HELLO = "Hello World!";
const char *STRING_GOODBYE = "Goodbye World!";
//
// HelloView class
//
// This class defines the view in which the "Hello World"
// message will be drawn.
//
class HelloView : public BView {
public:
HelloView(BRect frame);
virtual void Draw(BRect updateRect);
void SetString(const char *s);
private:
char message[128];
};
//
// HelloView::HelloView
//
// Constructs the view we'll be drawing in.
// As you see, it doesn't do much.
//
HelloView::HelloView(BRect frame)
: BView(frame, "HelloView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) {
SetString(STRING_HELLO);
}
//
// HelloView::SetString
//
// Sets the message to draw in the view.
//
void HelloView::SetString(const char *s) {
if (strlen(s) < 127) {
strcpy(message, s);
}
}
//
// HelloView::Draw
//
// This function is called whenever our view
// needs to be redrawn. This happens only because
// we specified B_WILL_DRAW for the flags when
// we created the view (see the constructor).
//
// The updateRect is the rectangle that needs to be
// redrawn. We're ignoring it, but you can use it to
// speed up your refreshes for more complex programs.
//
void HelloView::Draw(BRect updateRect) {
MovePenTo(BPoint(20,75)); // Move pen
DrawString(message);
}
//
// HelloWindow class
//
// This class defines the hello world window.
//
class HelloWindow : public BWindow {
public:
HelloWindow(BRect frame);
~HelloWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
private:
void Register(bool need_id);
void Unregister(void);
BMenuBar *menubar;
HelloView *helloview;
};
//
// HelloWindow::HelloWindow
//
// Constructs the window we'll be drawing into.
//
HelloWindow::HelloWindow(BRect frame)
: BWindow(frame, "Untitled ", B_TITLED_WINDOW,
B_NOT_RESIZABLE|B_NOT_ZOOMABLE) {
BRect r;
BMenu *menu;
BMenuItem *item;
// Add the menu bar
r = Bounds();
menubar = new BMenuBar(r, "menu_bar");
AddChild(menubar);
// Add File menu to menu bar
menu = new BMenu("File");
menu->AddItem(new BMenuItem("New", new BMessage(MENU_FILE_NEW), 'N'));
menu->AddItem(new BMenuItem("Open" B_UTF8_ELLIPSIS,
new BMessage(MENU_FILE_OPEN), 'O'));
menu->AddItem(new BMenuItem("Close", new BMessage(MENU_FILE_CLOSE), 'W'));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Save", new BMessage(MENU_FILE_SAVE), 'S'));
menu->AddItem(new BMenuItem("Save as" B_UTF8_ELLIPSIS,
new BMessage(MENU_FILE_SAVEAS)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Page Setup" B_UTF8_ELLIPSIS,
new BMessage(MENU_FILE_PAGESETUP)));
menu->AddItem(new BMenuItem("Print" B_UTF8_ELLIPSIS,
new BMessage(MENU_FILE_PRINT), 'P'));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Quit", new BMessage(MENU_FILE_QUIT), 'Q'));
menubar->AddItem(menu);
// Add Options menu to menu bar
menu = new BMenu("Options");
item=new BMenuItem("Say Hello", new BMessage(MENU_OPT_HELLO));
item->SetMarked(true);
menu->AddItem(item);
menubar->AddItem(menu);
// Add the drawing view
r.top = menubar->Bounds().bottom+1;
AddChild(helloview = new HelloView(r));
// Tell the application that there's one more window
// and get the number for this untitled window.
Register(true);
Show();
}
//
// HelloWindow::~HelloWindow
//
// Destruct the window. This calls Unregister().
//
HelloWindow::~HelloWindow() {
Unregister();
}
//
// HelloWindow::MessageReceived
//
// Called when a message is received by our
// application.
//
void HelloWindow::MessageReceived(BMessage *message) {
switch(message->what) {
case WINDOW_REGISTRY_ADDED:
{
char s[22];
int32 id = 0;
if (message->FindInt32("new_window_number", &id) == B_OK) {
sprintf(s, "Untitled %ld", id);
SetTitle(s);
}
}
break;
case MENU_FILE_NEW:
{
BRect r;
r = Frame();
r.OffsetBy(20,20);
new HelloWindow(r);
}
break;
case MENU_FILE_CLOSE:
Quit();
break;
case MENU_FILE_QUIT:
be_app->PostMessage(B_QUIT_REQUESTED);
break;
case MENU_OPT_HELLO:
{
BMenuItem *item;
const char *s;
bool mark;
message->FindPointer("source", (void **) &item);
if (item->IsMarked()) {
s = STRING_GOODBYE;
mark = false;
}
else {
s = STRING_HELLO;
mark = true;
}
helloview->SetString(s);
item->SetMarked(mark);
helloview->Invalidate();
}
break;
default:
BWindow::MessageReceived(message);
break;
}
}
//
// HelloWindow::Register
//
// Since MessageWorld can have multiple windows and
// we need to know when there aren't any left so the
// application can be shut down, this function is used
// to tell the application that a new window has been
// opened.
//
// If the need_id argument is true, we'll specify true
// for the "need_id" field in the message we send; this
// will cause the application to send back a
// WINDOW_REGISTRY_ADDED message containing the window's
// unique ID number. If this argument is false, we won't
// request an ID.
//
void HelloWindow::Register(bool need_id) {
BMessenger messenger(APP_SIGNATURE);
BMessage message(WINDOW_REGISTRY_ADD);
message.AddBool("need_id", need_id);
messenger.SendMessage(&message, this);
}
//
// HelloWindow::Unregister
//
// Unregisters a window. This tells the application that
// one fewer windows are open. The application will
// automatically quit if the count goes to zero because
// of this call.
//
void HelloWindow::Unregister(void) {
BMessenger messenger(APP_SIGNATURE);
messenger.SendMessage(new BMessage(WINDOW_REGISTRY_SUB));
}
//
// HelloWindow::QuitRequested
//
// Here we just give permission to close the window.
//
bool HelloWindow::QuitRequested() {
return true;
}
//
// HelloApp class
//
// This class, derived from BApplication, defines the
// Hello World application itself.
//
class HelloApp : public BApplication {
public:
HelloApp();
virtual void MessageReceived(BMessage *message);
private:
int32 window_count;
int32 next_untitled_number;
};
//
// HelloApp::HelloApp
//
// The constructor for the HelloApp class. This
// will create our window.
//
HelloApp::HelloApp()
: BApplication(APP_SIGNATURE) {
BRect windowRect;
windowRect.Set(50,50,349,399);
window_count = 0; // No windows yet
next_untitled_number = 1; // Next window is "Untitled 1"
new HelloWindow(windowRect);
}
//
// HelloApp::MessageReceived
//
// Handle incoming messages. In particular, handle the
// WINDOW_REGISTRY_ADD and WINDOW_REGISTRY_SUB messages.
//
void HelloApp::MessageReceived(BMessage *message) {
switch(message->what) {
case WINDOW_REGISTRY_ADD:
{
bool need_id = false;
if (message->FindBool("need_id", &need_id) == B_OK) {
if (need_id) {
BMessage reply(WINDOW_REGISTRY_ADDED);
reply.AddInt32("new_window_number", next_untitled_number);
message->SendReply(&reply);
next_untitled_number++;
}
window_count++;
}
break;
}
case WINDOW_REGISTRY_SUB:
window_count--;
if (!window_count) {
Quit();
}
break;
default:
BApplication::MessageReceived(message);
break;
}
}
//
// main
//
// The main() function's only real job in a basic BeOS
// application is to create the BApplication object
// and run it.
//
int main(void) {
HelloApp theApp; // The application object
theApp.Run();
return 0;
}
| 21.696742 | 75 | 0.688922 |
return
|
458bf6d617a44dfd03bbc2a44d0c4749251feb4d
| 801 |
cpp
|
C++
|
DEngine/Physics/cdCollisionWorld.cpp
|
norrischiu/DEngine
|
acea553f110b8d10fc7386ff0941b84f6d7ebce7
|
[
"MIT",
"Unlicense"
] | 8 |
2016-05-23T03:08:08.000Z
|
2020-03-02T06:15:16.000Z
|
DEngine/Physics/cdCollisionWorld.cpp
|
norrischiu/DEngine
|
acea553f110b8d10fc7386ff0941b84f6d7ebce7
|
[
"MIT",
"Unlicense"
] | 8 |
2016-06-01T17:00:58.000Z
|
2021-07-21T13:53:41.000Z
|
DEngine/Physics/cdCollisionWorld.cpp
|
norrischiu/DEngine
|
acea553f110b8d10fc7386ff0941b84f6d7ebce7
|
[
"MIT",
"Unlicense"
] | 1 |
2017-09-25T03:39:34.000Z
|
2017-09-25T03:39:34.000Z
|
#include "cdCollisionWorld.h"
/**
void CollisionWorld::addObject(const CollidableObject & object)
{
m_pObjects.push_back(object);
}
void CollisionWorld::addCollide(const Collide & collide)
{
m_pCollide.push_back(collide);
}
void CollisionWorld::computeCollision()
{
bool value = false;
Collide collide;
for (int i = 0; i < m_pObjects.size(); i++)
{
for (int j = i + 1; j < m_pObjects.size(); j++)
{
collide.collision(&m_pObjects[i], &m_pObjects[j]);
// collide.getCollide() returns a boolean value, true means collide, false means not collide
if (collide.getCollide())
addCollide(collide);
//value = true;
}
}
//return value;
}
*/
CollisionWorld * CollisionWorld::GetInstance()
{
if (!m_pInstance)
{
m_pInstance = new CollisionWorld();
}
return m_pInstance;
}
| 19.536585 | 95 | 0.68789 |
norrischiu
|
458c004d2710be6d40ca18beea5ef17f8842f0f1
| 8,708 |
cxx
|
C++
|
MITK/Plugins/uk.ac.ucl.cmic.igiultrasoundoverlayeditor/src/internal/niftkIGIUltrasoundOverlayEditorPreferencePage.cxx
|
NifTK/NifTK
|
2358b333c89ff1bba1c232eecbbcdc8003305dfe
|
[
"BSD-3-Clause"
] | 13 |
2018-07-28T13:36:38.000Z
|
2021-11-01T19:17:39.000Z
|
MITK/Plugins/uk.ac.ucl.cmic.igiultrasoundoverlayeditor/src/internal/niftkIGIUltrasoundOverlayEditorPreferencePage.cxx
|
NifTK/NifTK
|
2358b333c89ff1bba1c232eecbbcdc8003305dfe
|
[
"BSD-3-Clause"
] | null | null | null |
MITK/Plugins/uk.ac.ucl.cmic.igiultrasoundoverlayeditor/src/internal/niftkIGIUltrasoundOverlayEditorPreferencePage.cxx
|
NifTK/NifTK
|
2358b333c89ff1bba1c232eecbbcdc8003305dfe
|
[
"BSD-3-Clause"
] | 10 |
2018-08-20T07:06:00.000Z
|
2021-07-07T07:55:27.000Z
|
/*=============================================================================
NifTK: A software platform for medical image computing.
Copyright (c) University College London (UCL). All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
See LICENSE.txt in the top level directory for details.
=============================================================================*/
#include "niftkIGIUltrasoundOverlayEditorPreferencePage.h"
#include "niftkIGIUltrasoundOverlayEditor.h"
#include <QLabel>
#include <QPushButton>
#include <QFormLayout>
#include <QRadioButton>
#include <QColorDialog>
#include <QCheckBox>
#include <ctkPathLineEdit.h>
#include <berryIPreferencesService.h>
#include <berryPlatform.h>
namespace niftk
{
const QString IGIUltrasoundOverlayEditorPreferencePage::FIRST_BACKGROUND_STYLE_SHEET("first background color style sheet");
const QString IGIUltrasoundOverlayEditorPreferencePage::SECOND_BACKGROUND_STYLE_SHEET("second background color style sheet");
const QString IGIUltrasoundOverlayEditorPreferencePage::FIRST_BACKGROUND_COLOUR("first background color");
const QString IGIUltrasoundOverlayEditorPreferencePage::SECOND_BACKGROUND_COLOUR("second background color");
const QString IGIUltrasoundOverlayEditorPreferencePage::CLIP_TO_IMAGE_PLANE("clip to imae plane");
//-----------------------------------------------------------------------------
IGIUltrasoundOverlayEditorPreferencePage::IGIUltrasoundOverlayEditorPreferencePage()
: m_MainControl(0)
, m_ColorButton1(NULL)
, m_ColorButton2(NULL)
, m_ClipToImagePlane(NULL)
{
}
//-----------------------------------------------------------------------------
void IGIUltrasoundOverlayEditorPreferencePage::Init(berry::IWorkbench::Pointer )
{
}
//-----------------------------------------------------------------------------
void IGIUltrasoundOverlayEditorPreferencePage::CreateQtControl(QWidget* parent)
{
berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
m_IGIUltrasoundOverlayEditorPreferencesNode = prefService->GetSystemPreferences()->Node(IGIUltrasoundOverlayEditor::EDITOR_ID);
m_MainControl = new QWidget(parent);
QFormLayout *formLayout = new QFormLayout;
m_ClipToImagePlane = new QCheckBox();
formLayout->addRow("clipping planes", m_ClipToImagePlane);
// gradient background
QLabel* gBName = new QLabel;
gBName->setText("gradient background");
formLayout->addRow(gBName);
// color
m_ColorButton1 = new QPushButton;
m_ColorButton1->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
m_ColorButton2 = new QPushButton;
m_ColorButton2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
QPushButton* resetButton = new QPushButton;
resetButton->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);
resetButton->setText("reset");
QLabel* colorLabel1 = new QLabel("first color : ");
colorLabel1->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
QLabel* colorLabel2 = new QLabel("second color: ");
colorLabel2->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
QHBoxLayout* colorWidgetLayout = new QHBoxLayout;
colorWidgetLayout->setContentsMargins(4,4,4,4);
colorWidgetLayout->addWidget(colorLabel1);
colorWidgetLayout->addWidget(m_ColorButton1);
colorWidgetLayout->addWidget(colorLabel2);
colorWidgetLayout->addWidget(m_ColorButton2);
colorWidgetLayout->addWidget(resetButton);
QWidget* colorWidget = new QWidget;
colorWidget->setLayout(colorWidgetLayout);
// spacer
QSpacerItem *spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
QVBoxLayout* vBoxLayout = new QVBoxLayout;
vBoxLayout->addLayout(formLayout);
vBoxLayout->addWidget(colorWidget);
vBoxLayout->addSpacerItem(spacer);
m_MainControl->setLayout(vBoxLayout);
QObject::connect( m_ColorButton1, SIGNAL( clicked() )
, this, SLOT( FirstColorChanged() ) );
QObject::connect( m_ColorButton2, SIGNAL( clicked() )
, this, SLOT( SecondColorChanged() ) );
QObject::connect( resetButton, SIGNAL( clicked() )
, this, SLOT( ResetColors() ) );
this->Update();
}
//-----------------------------------------------------------------------------
QWidget* IGIUltrasoundOverlayEditorPreferencePage::GetQtControl() const
{
return m_MainControl;
}
//-----------------------------------------------------------------------------
bool IGIUltrasoundOverlayEditorPreferencePage::PerformOk()
{
m_IGIUltrasoundOverlayEditorPreferencesNode->Put(IGIUltrasoundOverlayEditorPreferencePage::FIRST_BACKGROUND_STYLE_SHEET, m_FirstColorStyleSheet);
m_IGIUltrasoundOverlayEditorPreferencesNode->Put(IGIUltrasoundOverlayEditorPreferencePage::SECOND_BACKGROUND_STYLE_SHEET, m_SecondColorStyleSheet);
m_IGIUltrasoundOverlayEditorPreferencesNode->Put(IGIUltrasoundOverlayEditorPreferencePage::FIRST_BACKGROUND_COLOUR, m_FirstColor);
m_IGIUltrasoundOverlayEditorPreferencesNode->Put(IGIUltrasoundOverlayEditorPreferencePage::SECOND_BACKGROUND_COLOUR, m_SecondColor);
m_IGIUltrasoundOverlayEditorPreferencesNode->PutBool(IGIUltrasoundOverlayEditorPreferencePage::CLIP_TO_IMAGE_PLANE, m_ClipToImagePlane->isChecked());
return true;
}
//-----------------------------------------------------------------------------
void IGIUltrasoundOverlayEditorPreferencePage::PerformCancel()
{
}
//-----------------------------------------------------------------------------
void IGIUltrasoundOverlayEditorPreferencePage::Update()
{
m_FirstColorStyleSheet = m_IGIUltrasoundOverlayEditorPreferencesNode->Get(IGIUltrasoundOverlayEditorPreferencePage::FIRST_BACKGROUND_STYLE_SHEET, "");
m_SecondColorStyleSheet = m_IGIUltrasoundOverlayEditorPreferencesNode->Get(IGIUltrasoundOverlayEditorPreferencePage::SECOND_BACKGROUND_STYLE_SHEET, "");
m_FirstColor = m_IGIUltrasoundOverlayEditorPreferencesNode->Get(IGIUltrasoundOverlayEditorPreferencePage::FIRST_BACKGROUND_COLOUR, "");
m_SecondColor = m_IGIUltrasoundOverlayEditorPreferencesNode->Get(IGIUltrasoundOverlayEditorPreferencePage::SECOND_BACKGROUND_COLOUR, "");
if (m_FirstColorStyleSheet=="")
{
m_FirstColorStyleSheet = "background-color:rgb(0,0,0)";
}
if (m_SecondColorStyleSheet=="")
{
m_SecondColorStyleSheet = "background-color:rgb(0,0,0)";
}
if (m_FirstColor=="")
{
m_FirstColor = "#000000";
}
if (m_SecondColor=="")
{
m_SecondColor = "#000000";
}
m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet);
m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet);
m_ClipToImagePlane->setChecked(m_IGIUltrasoundOverlayEditorPreferencesNode->GetBool(IGIUltrasoundOverlayEditorPreferencePage::CLIP_TO_IMAGE_PLANE, true));
}
//-----------------------------------------------------------------------------
void IGIUltrasoundOverlayEditorPreferencePage::FirstColorChanged()
{
QColor color = QColorDialog::getColor();
m_ColorButton1->setAutoFillBackground(true);
QString styleSheet = "background-color:rgb(";
styleSheet.append(QString::number(color.red()));
styleSheet.append(",");
styleSheet.append(QString::number(color.green()));
styleSheet.append(",");
styleSheet.append(QString::number(color.blue()));
styleSheet.append(")");
m_ColorButton1->setStyleSheet(styleSheet);
m_FirstColorStyleSheet = styleSheet;
QStringList firstColor;
firstColor << color.name();
m_FirstColor = firstColor.replaceInStrings(";","\\;").join(";");
}
//-----------------------------------------------------------------------------
void IGIUltrasoundOverlayEditorPreferencePage::SecondColorChanged()
{
QColor color = QColorDialog::getColor();
m_ColorButton2->setAutoFillBackground(true);
QString styleSheet = "background-color:rgb(";
styleSheet.append(QString::number(color.red()));
styleSheet.append(",");
styleSheet.append(QString::number(color.green()));
styleSheet.append(",");
styleSheet.append(QString::number(color.blue()));
styleSheet.append(")");
m_ColorButton2->setStyleSheet(styleSheet);
m_SecondColorStyleSheet = styleSheet;
QStringList secondColor;
secondColor << color.name();
m_SecondColor = secondColor.replaceInStrings(";","\\;").join(";");
}
//-----------------------------------------------------------------------------
void IGIUltrasoundOverlayEditorPreferencePage::ResetColors()
{
m_FirstColorStyleSheet = "background-color:rgb(0,0,0)";
m_SecondColorStyleSheet = "background-color:rgb(0,0,0)";
m_FirstColor = "#000000";
m_SecondColor = "#000000";
m_ColorButton1->setStyleSheet(m_FirstColorStyleSheet);
m_ColorButton2->setStyleSheet(m_SecondColorStyleSheet);
}
} // end namespace
| 37.373391 | 156 | 0.706821 |
NifTK
|
4593f57d4d81656f516d9deaca99f02bef8d2f98
| 1,610 |
cpp
|
C++
|
codechef/aug17/6.cpp
|
AadityaJ/Spoj
|
61664c1925ef5bb072a3fe78fb3dac4fb68d77a1
|
[
"MIT"
] | null | null | null |
codechef/aug17/6.cpp
|
AadityaJ/Spoj
|
61664c1925ef5bb072a3fe78fb3dac4fb68d77a1
|
[
"MIT"
] | null | null | null |
codechef/aug17/6.cpp
|
AadityaJ/Spoj
|
61664c1925ef5bb072a3fe78fb3dac4fb68d77a1
|
[
"MIT"
] | null | null | null |
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
void printArr(vector<string> &v){
for(int i=0;i<v.size();i++){
cout<<v[i]<<endl;
}
}
long long int f(vector<string> &v,string str){
for(int i=0;i<str.length();i++){
bool is=0;
char c=str[i];
for(int j=0;j<v.size();j++){
if(v[j][i]==c){is=1;break;}
}
if(!is){v.push_back(str);return str.length()-i;}
}
return 0;
}
string con2bits(int c,int n){
string str="";
for(int i=0;i<(n-c-1);i++) str.push_back('0');
str.push_back('1');
for(int i=0;i<c;i++) str.push_back('0');
return str;
}
string add(string a,string b){
int ca=0;
string c="";
for(int i=a.length()-1;i>=0;i--){
int ax=a[i]-'0';
int bx=b[i]-'0';
int cx=(ax+bx+ca)%2;
ca=(ax+bx+ca)/2;
c.push_back(cx+'0');
}
reverse(c.begin(),c.end());
return c;
}
int main(int argc, char const *argv[]) {
int t;
cin>>t;
while(t--){
int n,q;
cin>>n>>q;
long long int ans=0;
string x="";
for(int i=0;i<n;i++) x.push_back('0');
vector<string> v;
for(int i=0;i<q;i++){
char ch;
cin>>ch;
if(ch=='?'){cout<<ans<<endl;}
else{
int c;
cin>>c;
string str=con2bits(c,n);
x=add(x,str);
ans+=f(v,x);
cout<<i<<" :: "<<x<<endl;
printArr(v);
cout<<endl;
}
}
}
return 0;
}
| 22.676056 | 56 | 0.445342 |
AadityaJ
|
459410b8db4d34750797b8d22906e62fa7952018
| 72,861 |
cpp
|
C++
|
src/zgemmtune.cpp
|
codedivine/raijinclv2
|
e4c50b757e3fe6d1fa5d09c135f1156b31c08fab
|
[
"Apache-2.0"
] | null | null | null |
src/zgemmtune.cpp
|
codedivine/raijinclv2
|
e4c50b757e3fe6d1fa5d09c135f1156b31c08fab
|
[
"Apache-2.0"
] | null | null | null |
src/zgemmtune.cpp
|
codedivine/raijinclv2
|
e4c50b757e3fe6d1fa5d09c135f1156b31c08fab
|
[
"Apache-2.0"
] | null | null | null |
/**Copyright 2012, Rahul Garg and McGill University
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include <iostream>
#include <string>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include "raijin_complex.hpp"
#include "rtimer.hpp"
#include <CL/cl.h>
using namespace std;
using namespace RaijinCL;
struct GemmCsingle{
typedef cl_float2 ctype;
typedef cl_float basetype;
static bool isDouble(){return false;}
static string gemmName(){return "cgemm";}
static string name(){return "float";}
};
struct GemmCdouble{
typedef cl_double2 ctype;
typedef cl_double basetype;
static bool isDouble(){return true;}
static string gemmName(){return "zgemm";}
static string name(){return "double";}
};
static bool genCkernelTNOff(int lsizex,
int lsizey,
int htile,
int wtile,
int ktile,
string dtype,
int simdwidth,
bool storea,
bool storeb,
int maxLocalMemElems,
int padding,
string& kernel,
bool useImageA = false,
bool useImageB = false){
//cout<<"StoreA "<<storea<<" "<<"StoreB "<<storeb<<" "<<htile<<" "<<wtile<<" "<<" "<<ktile<<" "<<simdwidth<<" "<<lsizex<<" "<<lsizey<<" "<<unroll;
//cout<<" "<<maxLocalMemElems<<" "<<endl;
bool isDouble = (dtype.compare("double")==0) ? true:false;
if(isDouble && simdwidth>1 && (useImageA || useImageB)) return false;
if(!isDouble && simdwidth>2 && (useImageA || useImageB)) return false;
//const int unroll = ktile;
if(storea){
/*Number of rows of A per workgroup = ktile. Has to be divisble by lsizey. */
if(ktile%lsizex!=0) return false;
/*Number of columns of A per workgroup = htile*lsizex*/
if((htile*lsizex)%(simdwidth*lsizey)!=0) return false;
}else{
if(htile%simdwidth!=0) return false;
}
if(storeb){
/*Number of columns of B per workgroup = wtile*lsizey. Has to be divisble by lsizex*simdwidth */
if(ktile%lsizex!=0) return false;
if(((wtile*lsizey)%(lsizey*simdwidth))!=0) return false;
}else{
if(wtile%simdwidth!=0) return false;
}
//cout<<"Check 2 passed"<<endl;
if(wtile%simdwidth!=0 || htile%simdwidth!=0) return false;
int numLocalMemElems = 0;
if(storea) numLocalMemElems += ktile*(htile*lsizex+padding);
if(storeb) numLocalMemElems += ktile*(wtile*lsizey+padding);
if(numLocalMemElems>maxLocalMemElems) return false;
//cout<<"Check 3 passed"<<endl;
//if(ktile%unroll!=0) return false;
//cout<<"Check 4 passed"<<endl;
stringstream ss;
ss<<"(";
if(useImageA){
ss<<"__read_only image2d_t A,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict A,";
}
if(useImageB){
ss<<"__read_only image2d_t B,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict B,";
}
ss<<"__global "<<dtype<<"2 *restrict C,unsigned int lda,unsigned int ldb,unsigned int ldc,unsigned int K,"<<dtype<<"2 alpha,"<<dtype<<"2 beta){"<<endl;
ss<<"const int htile ="<<htile<<";\n";
ss<<"const int wtile ="<<wtile<<";\n";
ss<<"const int ktile ="<<ktile<<";\n";
ss<<"const int simdwidth="<<simdwidth<<";\n";
ss<<"const int lx = "<<lsizex<<";\n";
ss<<"const int ly = "<<lsizey<<";\n";
ss<<"const int i = get_global_id(1);"<<endl;
ss<<"const int j = get_global_id(0);"<<endl;
//ss<<"const int unroll = "<<unroll<<";\n";
//ss<<"const int unsigned flat = get_local_id(0)+get_local_id(1)*ly;"<<endl;
ss<<"const unsigned int lidx = get_local_id(1);"<<endl;
ss<<"const unsigned int lidy = get_local_id(0);"<<endl;
/*ss<<"const unsigned int lidx = flat%lx;"<<endl;
ss<<"const unsigned int lidy = (get_local_id(0)+get_local_id(1))%ly;"<<endl;*/
ss<<"int k;"<<endl;
if(storea){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsA["<<(ktile)<<"]["<<((htile/simdwidth)*lsizex+padding)<<"];"<<endl;
}
if(storeb){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsB["<<(ktile)<<"]["<<((wtile/simdwidth)*lsizey+padding)<<"];"<<endl;
}
for(int x=0;x<htile;x++){
for(int y=0;y<wtile/simdwidth;y++){
ss<<dtype<<(simdwidth*2)<<" sum"<<x<<"_"<<y<<" = ("<<dtype<<(simdwidth*2)<<")(0);\n";
}
}
ss<<"for(k=0;k<K;k+=ktile){"<<endl;
if(storea){
ss<<"const int gstartxA = get_group_id(1)*(htile/simdwidth)*lx;\n";
for(int y=0;y<(ktile/lsizex);y++){
for(int x=0;x<((htile*lsizex)/(simdwidth*lsizey));x++){
ss<<" ldsA["<<y<<"*lx + lidx]["<<x<<"*ly + lidy] = ";
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(lidy+"<<x<<"*ly+gstartxA,k+"<<y<<"*lx + lidx )))";
}else{
ss<<"(myread_imagef(A,(int2)(lidy+"<<x<<"*ly+gstartxA,k+"<<y<<"*lx + lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(k+"<<y<<"*lx+lidx)*(lda/simdwidth)+ gstartxA + lidy + "<<x<<"*ly];\n";
}
}
}
}
if(storeb){
ss<<"const int gstartxB = get_group_id(0)*(wtile/simdwidth)*ly;\n";
for(int y=0;y<(ktile/lsizex);y++){
for(int x=0;x<((wtile*lsizey)/(simdwidth*lsizey));x++){
ss<<" ldsB["<<y<<"*lx + lidx]["<<x<<"*ly + lidy] = ";
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(lidy + "<<x<<"*ly+gstartxB,k+"<<y<<"*lx +lidx)))";
}else{
ss<<"(myread_imagef(B,(int2)(lidy + "<<x<<"*ly+gstartxB,k+"<<y<<"*lx +lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(k+"<<y<<"*lx+lidx)*(ldb/simdwidth)+ gstartxB + lidy + "<<x<<"*ly];\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
//ss<<" for(kk=0;kk<ktile;kk+=unroll){\n";
ss<<"const int kk = 0;\n";
for (int y = 0; y < ktile; y++) {
for (int x = 0; x < wtile/simdwidth; x++) {
ss << " const " << dtype << (simdwidth*2) << " b" << x << "_" << y << " = ";
if(storeb){
ss << "ldsB[kk+"<<y<<"][ly*"<<x<<"+lidy];\n";
}else{
if(useImageB){
if(isDouble){
ss<<"as_double2( read_imagei(B,sampler,(int2)((get_group_id(0)*(wtile/simdwidth)+"<<x<<")*ly + lidy,k+kk+"<<y<<")))";
}else{
ss<<"( myread_imagef(B,(int2)((get_group_id(0)*(wtile/simdwidth)+"<<x<<")*ly + lidy,k+kk+"<<y<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss << "B[(k+kk+"<<y<<")*(ldb/simdwidth)+ (get_group_id(0)*(wtile/simdwidth)+"<<x<<")*ly + lidy];\n";
}
}
}
}
for (int y = 0; y < ktile; y++){
for (int x = 0; x < htile/simdwidth; x++) {
ss << " const " << dtype << (simdwidth*2) << " a" << x << "_" << y << " = ";
if(storea){
ss << "ldsA[kk+"<<y<<"][lx*"<<x<<"+lidx];\n";
}else{
if(useImageA){
if(isDouble) {
ss<<"as_double2(read_imagei(A,sampler,(int2)((get_group_id(1)*(htile/simdwidth)+"<<x<<")*lx + lidx,k+kk+"<<y<<")))";
}else{
ss<<"(myread_imagef(A,(int2)((get_group_id(1)*(htile/simdwidth)+"<<x<<")*lx + lidx,k+kk+"<<y<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss << "A[(k+kk+"<<y<<")*(lda/simdwidth)+ (get_group_id(1)*(htile/simdwidth)+"<<x<<")*lx + lidx];"<<endl;
}
}
//for(int x=0;x<htile/simdwidth;x++){
for(int xoff=0;xoff<simdwidth;xoff++){
int row = x*simdwidth + xoff;
for(int w=0;w<wtile/simdwidth; w++){
ss<<" sum"<<row<<"_"<<w;
ss<<" = fmaComplex"<<simdwidth;
ss<<"(a"<<x<<"_"<<y<<".s";
for(int m=0;m<simdwidth;m++){
ss<<(2*xoff);
ss<<(2*xoff+1);
}
ss<<",b"<<w<<"_"<<y<<",";
ss<<" sum"<<row<<"_"<<w;
ss<<");\n";
}
}
}
}
//ss<<" }\n";
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
ss<<"}"<<endl;
for (int i = 0; i < htile/simdwidth; i++) {
for(int ii=0;ii<simdwidth;ii++){
for (int j = 0; j < wtile/simdwidth; j++) {
for(int jj=0;jj<simdwidth;jj++){
ss << "C[( (get_group_id(1)*htile+"<<i<<"*simdwidth)*lx + lidx*simdwidth+ "<<ii<<")*ldc + (get_group_id(0)*wtile + " << j << "*simdwidth)*ly + lidy*simdwidth+" << jj << "]";
ss << "= mulComplex1(alpha,sum"<<(i*simdwidth+ii)<<"_"<<j;
if(simdwidth>1){
ss<<".s"<<(2*jj)<<(2*jj+1);
}
ss<<") + mulComplex1(beta,";
ss << "C[( (get_group_id(1)*htile+"<<i<<"*simdwidth)*lx + lidx*simdwidth+ "<<ii<<")*ldc + (get_group_id(0)*wtile + " << j << "*simdwidth)*ly + lidy*simdwidth+" << jj << "]";
//ss << "C[(i*" << htile << "+ " << i << ")*ldc + (get_group_id(0)*wtile + " << j << "*simdwidth)*ly + lidy*simdwidth+" << jj << "]";
ss << ");" << endl;
}
}
}
}
ss<<"}"<<endl;
kernel = ss.str();
return true;
}
static bool genCkernelNTCons(int lsizex, int lsizey, int htile, int wtile, int ktile, string dtype,int simdwidth, bool storea, bool storeb, int maxLocalMemElems,
int padding,string& kernel, bool useImageA,bool useImageB){
//cout<<"StoreA "<<storea<<" "<<"StoreB "<<storeb<<" "<<htile<<" "<<wtile<<" "<<" "<<ktile<<" "<<simdwidth<<" "<<lsizex<<" "<<lsizey<<" "<<unroll;
//cout<<" "<<maxLocalMemElems<<" "<<endl;
if(storea){
/*Number of rows of A per workgroup = htile*lsizex. Has to be divisble by lsizex. Trivially satisfied */
/*Number of columns of A per workgroup = ktile. Has to be divisble by lsizey*simdwidth */
if(ktile%(simdwidth*lsizey)!=0) return false;
}
if(storeb){
/*Number of columns of B per workgroup = ktile. Has to be divisble by lsizey*simdwidth */
if(ktile%(lsizey*simdwidth)!=0) return false;
/*Number of rows of B per workgroup = wtile*lsizey. Has to be divisble by lsizex*/
if((wtile*lsizey)%lsizex!=0) return false;
}
//cout<<"Check 2 passed"<<endl;
bool isDouble = (dtype.compare("double")==0);
if(ktile%simdwidth!=0) return false;
int numLocalMemElems = 0;
if(storea) numLocalMemElems += htile*lsizex*(ktile+padding);
if(storeb) numLocalMemElems += wtile*lsizey*(ktile+padding);
if(numLocalMemElems>maxLocalMemElems) return false;
//cout<<"Check 3 passed"<<endl;
//cout<<"Check 4 passed"<<endl;
stringstream ss;
ss<<"(";
if(useImageA){
ss<<"__read_only image2d_t A,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict A,";
}
if(useImageB){
ss<<"__read_only image2d_t B,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict B,";
}
ss<<"__global "<<dtype<<"2 *restrict C,unsigned int lda,unsigned int ldb,unsigned int ldc,unsigned int K,"<<dtype<<"2 alpha,"<<dtype<<"2 beta){"<<endl;
ss<<"const int htile ="<<htile<<";\n";
ss<<"const int wtile ="<<wtile<<";\n";
ss<<"const int ktile ="<<ktile<<";\n";
ss<<"const int simdwidth="<<simdwidth<<";\n";
ss<<"const int lx = "<<lsizex<<";\n";
ss<<"const int ly = "<<lsizey<<";\n";
ss<<"const int i = get_global_id(1);\n";
ss<<"const int j = get_global_id(0);\n";
ss<<"const unsigned int lidx = get_local_id(1);"<<endl;
ss<<"const unsigned int lidy = get_local_id(0);"<<endl;
ss<<"unsigned int k;"<<endl;
if(storea){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsA["<<(htile*lsizex)<<"]["<<((ktile/simdwidth)+padding)<<"];"<<endl;
}
if(storeb){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsB["<<(wtile*lsizey)<<"]["<<((ktile/simdwidth)+padding)<<"];"<<endl;
}
for(int x=0;x<htile;x++){
for(int y=0;y<wtile;y++){
ss<<dtype<<(simdwidth*2)<<" sum"<<x<<"_"<<y<<" = ("<<dtype<<(simdwidth*2)<<")(0);\n";
}
}
ss<<"const unsigned int ldbs = ldb/simdwidth;\n";
ss<<"const unsigned int ldas = lda/simdwidth;\n";
ss<<"for(k=0;k<K/simdwidth;k+=(ktile/simdwidth)){"<<endl;
if(storea){
ss<<"const int gstartxA = get_group_id(1)*htile*lx;\n";
for(int rowA=0;rowA<htile;rowA++){
for(int colA=0;colA<(ktile/(lsizey*simdwidth));colA++){
ss<<" ldsA["<<rowA<<"*lx + lidx]["<<colA<<"*ly + lidy] = ";
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k+"<<colA<<"*ly+lidy,gstartxA+"<<rowA<<"*lx+lidx)))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k+"<<colA<<"*ly+lidy,gstartxA+"<<rowA<<"*lx+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(gstartxA+"<<rowA<<"*lx + lidx)*(lda/simdwidth) + k + "<<colA<<"*ly + lidy];\n";
}
}
}
}
if(storeb){
ss<<"const int gstartxB = get_group_id(0)*wtile*ly;\n";
for(int rowB=0;rowB<(wtile*lsizey)/lsizex;rowB++){
for(int colB=0;colB<(ktile/(lsizey*simdwidth));colB++){
ss<<" ldsB["<<rowB<<"*lx + lidx]["<<colB<<"*ly + lidy] = ";
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(k+"<<colB<<"*ly+lidy,gstartxB+"<<rowB<<"*lx+lidx)))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(k+"<<colB<<"*ly+lidy,gstartxB+"<<rowB<<"*lx+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(gstartxB+"<<rowB<<"*lx + lidx)*(ldb/simdwidth) + k + "<<colB<<"*ly + lidy];\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
for(int rowB =0;rowB<wtile;rowB++){
for(int colB = 0;colB<ktile/simdwidth;colB++){
ss<<" const "<<dtype<<(simdwidth*2)<<" b"<<rowB<<"_"<<colB<<" = ";
if(storeb){
ss<<"ldsB["<<rowB<<"+lidy*wtile]["<<colB<<"];\n";
}else{
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(k+"<<colB<<",j*wtile+"<<rowB<<")))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(k+"<<colB<<",j*wtile+"<<rowB<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(j*wtile+"<<rowB<<")*ldbs + k + "<<colB<<"];\n";
}
}
}
}
for(int rowA=0;rowA<htile;rowA++){
for(int colA =0;colA<ktile/simdwidth;colA++){
ss<<" const "<<dtype<<(simdwidth*2)<<" a"<<rowA<<"_"<<colA<<" = ";
if(storea){
ss<<"ldsA["<<rowA<<"+lidx*htile]["<<colA<<"];\n";
}else{
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k+"<<colA<<",i*htile+"<<rowA<<")))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k+"<<colA<<",i*htile+"<<rowA<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(i*htile+"<<rowA<<")*ldas +k + "<<colA<<"];\n";
}
}
}
for(int colA =0;colA<ktile/simdwidth;colA++){
const int colB = colA;
for(int rowB=0;rowB<wtile;rowB++){
ss<<" sum"<<rowA<<"_"<<rowB;
ss<<" = fmaComplex"<<simdwidth<<"(a"<<rowA<<"_"<<colA<<",b"<<rowB<<"_"<<colB<<",";
ss<<" sum"<<rowA<<"_"<<rowB;
ss<<");\n";
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
ss<<"}"<<endl;
for (int i = 0; i < htile; i++) {
for (int j = 0; j < wtile; j++) {
ss << "C[(i*" << htile << "+ " << i << ")*ldc + j*" << wtile << "+" << j << "]";
ss << "= mulComplex1(alpha,(";
for(int s=0;s<simdwidth;s++){
ss<<"sum"<<i<<"_"<<j<<".s";
ss<<(2*s)<<(2*s+1);
if(s<(simdwidth-1)) ss<<"+";
}
ss<<"))+ mulComplex1(beta,";
ss << "C[(i*" << htile << "+ " << i << ")*ldc + j*" << wtile << "+" << j << "]";
ss<<");\n";
}
}
//ss<<"}"<<endl;
ss<<"}"<<endl;
kernel = ss.str();
return true;
}
static bool genCkernelTNCons(int lsizex,
int lsizey,
int htile,
int wtile,
int ktile,
string dtype,
int simdwidth,
bool storea,
bool storeb,
int maxLocalMemElems,
int padding,
string& kernel,
bool useImageA = false,
bool useImageB = false){
//cout<<"StoreA "<<storea<<" "<<"StoreB "<<storeb<<" "<<htile<<" "<<wtile<<" "<<" "<<ktile<<" "<<simdwidth<<" "<<lsizex<<" "<<lsizey<<" "<<unroll;
//cout<<" "<<maxLocalMemElems<<" "<<endl;
bool isDouble = (dtype.compare("double")==0) ? true:false;
if(isDouble && simdwidth!=2 && (useImageA || useImageB)) return false;
if(!isDouble && simdwidth!=4 && (useImageA || useImageB)) return false;
//const int unroll = ktile;
if(storea){
/*Number of rows of A per workgroup = ktile. Has to be divisble by lsizey. */
if(ktile%lsizex!=0) return false;
/*Number of columns of A per workgroup = htile*lsizex*/
if((htile*lsizex)%(simdwidth*lsizey)!=0) return false;
}else{
if(htile%simdwidth!=0) return false;
}
if(storeb){
/*Number of columns of B per workgroup = wtile*lsizey. Has to be divisble by lsizex*simdwidth */
if(ktile%lsizex!=0) return false;
if(((wtile*lsizey)%(lsizey*simdwidth))!=0) return false;
}else{
if(wtile%simdwidth!=0) return false;
}
//cout<<"Check 2 passed"<<endl;
if(wtile%simdwidth!=0 || htile%simdwidth!=0) return false;
int numLocalMemElems = 0;
if(storea) numLocalMemElems += ktile*(htile*lsizex+padding);
if(storeb) numLocalMemElems += ktile*(wtile*lsizey+padding);
if(numLocalMemElems>maxLocalMemElems) return false;
//cout<<"Check 3 passed"<<endl;
//if(ktile%unroll!=0) return false;
//cout<<"Check 4 passed"<<endl;
stringstream ss;
ss<<"(";
if(useImageA){
ss<<"__read_only image2d_t A,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict A,";
}
if(useImageB){
ss<<"__read_only image2d_t B,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict B,";
}
ss<<"__global "<<dtype<<"2 *restrict C,unsigned int lda,unsigned int ldb,unsigned int ldc,unsigned int K,"<<dtype<<"2 alpha,"<<dtype<<"2 beta){"<<endl;
ss<<"const int htile ="<<htile<<";\n";
ss<<"const int wtile ="<<wtile<<";\n";
ss<<"const int ktile ="<<ktile<<";\n";
ss<<"const int simdwidth="<<simdwidth<<";\n";
ss<<"const int lx = "<<lsizex<<";\n";
ss<<"const int ly = "<<lsizey<<";\n";
ss<<"const int i = get_global_id(1);"<<endl;
ss<<"const int j = get_global_id(0);"<<endl;
//ss<<"const int unroll = "<<unroll<<";\n";
ss<<"const unsigned int lidx = get_local_id(1);"<<endl;
ss<<"const unsigned int lidy = get_local_id(0);"<<endl;
ss<<"int k;"<<endl;
if(storea){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsA["<<(ktile)<<"]["<<((htile/simdwidth)*lsizex+padding)<<"];"<<endl;
}
if(storeb){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsB["<<(ktile)<<"]["<<((wtile/simdwidth)*lsizey+padding)<<"];"<<endl;
}
for(int x=0;x<htile;x++){
for(int y=0;y<wtile/simdwidth;y++){
ss<<dtype<<(simdwidth*2)<<" sum"<<x<<"_"<<y<<" = ("<<dtype<<(simdwidth*2)<<")(0);\n";
}
}
ss<<"for(k=0;k<K;k+=ktile){"<<endl;
if(storea){
ss<<"const int gstartxA = get_group_id(1)*(htile/simdwidth)*lx;\n";
for(int y=0;y<(ktile/lsizex);y++){
for(int x=0;x<((htile*lsizex)/(simdwidth*lsizey));x++){
ss<<" ldsA["<<y<<"*lx + lidx]["<<x<<"*ly + lidy] = ";
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(lidy+"<<x<<"*ly+gstartxA,k+"<<y<<"*lx + lidx )))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(lidy+"<<x<<"*ly+gstartxA,k+"<<y<<"*lx + lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(k+"<<y<<"*lx+lidx)*(lda/simdwidth)+ gstartxA + lidy + "<<x<<"*ly];\n";
}
}
}
}
if(storeb){
ss<<"const int gstartxB = get_group_id(0)*(wtile/simdwidth)*ly;\n";
for(int y=0;y<(ktile/lsizex);y++){
for(int x=0;x<((wtile*lsizey)/(simdwidth*lsizey));x++){
ss<<" ldsB["<<y<<"*lx + lidx]["<<x<<"*ly + lidy] = ";
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(lidy + "<<x<<"*ly+gstartxB,k+"<<y<<"*lx +lidx)))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(lidy + "<<x<<"*ly+gstartxB,k+"<<y<<"*lx +lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(k+"<<y<<"*lx+lidx)*(ldb/simdwidth)+ gstartxB + lidy + "<<x<<"*ly];\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
//ss<<" for(kk=0;kk<ktile;kk+=unroll){\n";
ss<<"const int kk = 0;\n";
for(int y =0; y < ktile; y++){
for (int x = 0; x < wtile/simdwidth; x++) {
ss << " const " << dtype << (simdwidth*2) << " b" << x << "_" << y << " = ";
if(storeb){
ss << "ldsB[kk+"<<y<<"][lidy*(wtile/simdwidth)+"<<x<<"];\n";
}else{
if(useImageB){
if(isDouble){
ss<<"as_double2( read_imagei(B,sampler,(int2)(j*(wtile/simdwidth)+"<<x<<",k+kk+"<<y<<")))";
}else{
ss<<"( read_imagef(B,sampler,(int2)(j*(wtile/simdwidth)+"<<x<<",k+kk+"<<y<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth;s++) ss<<s;
ss<<";\n";
}else{
ss << "B[(k+kk+"<<y<<")*(ldb/simdwidth)+j*(wtile/simdwidth)+"<<x<<"];\n";
}
}
}
for (int x = 0; x < htile/simdwidth; x++) {
ss << " const " << dtype << (simdwidth*2) << " a" << x << "_" << y << " = ";
if(storea){
ss << "ldsA[kk+"<<y<<"]["<<"lidx*(htile/simdwidth)+"<<x<<"];\n";
}else{
if(useImageA){
if(isDouble) {
ss<<"as_double2(read_imagei(A,sampler,(int2)(i*(htile/simdwidth)+"<<x<<",k+kk+"<<y<<")))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(i*(htile/simdwidth)+"<<x<<",k+kk+"<<y<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth;s++) ss<<s;
ss<<";\n";
}else{
ss << "A[(k+kk+"<<y<<")*(lda/simdwidth)+i*(htile/simdwidth)+"<<x<<"];"<<endl;
}
}
for(int xoff=0;xoff<simdwidth;xoff++){
int row = x*simdwidth + xoff;
for(int w=0;w<wtile/simdwidth; w++){
ss<<" sum"<<row<<"_"<<w;
ss<<" = fmaComplex"<<simdwidth<<"(a"<<x<<"_"<<y;
if(simdwidth>1){
ss<<".s";
for(int m=0;m<simdwidth;m++) {
ss<<(2*xoff)<<(2*xoff+1);
}
}
ss<<",b"<<w<<"_"<<y<<",";
ss<<" sum"<<row<<"_"<<w<<");\n";
}
}
}
}
//ss<<" }\n";
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
ss<<"}"<<endl;
for (int i = 0; i < htile; i++) {
for (int j = 0; j < wtile; j++) {
ss << "C[(i*" << htile << "+ " << i << ")*ldc + j*" << wtile << "+" << j << "]";
ss << "= mulComplex1(alpha,sum"<<i<<"_"<<(j/simdwidth);
if(simdwidth>1) ss<<".s"<<(2*(j%simdwidth))<<(2*(j%simdwidth)+1);
ss<<") + ";
ss << "mulComplex1(beta,C[(i*" << htile << "+ " << i << ")*ldc + j*" << wtile << "+" << j << "]";
//ss<<"C[(i*"<<htile<<"+ i)*N + j*"<<wtile<<"+"<<offset<<"]";
ss << ");" << endl;
}
}
ss<<"}"<<endl;
kernel = ss.str();
return true;
}
static bool genCkernelNTOff(int lsizex, int lsizey, int htile, int wtile, int ktile, string dtype,int simdwidth, bool storea, bool storeb, int maxLocalMemElems,
int padding,string& kernel, bool useImageA,bool useImageB){
//cout<<"StoreA "<<storea<<" "<<"StoreB "<<storeb<<" "<<htile<<" "<<wtile<<" "<<" "<<ktile<<" "<<simdwidth<<" "<<lsizex<<" "<<lsizey<<" "<<unroll;
//cout<<" "<<maxLocalMemElems<<" "<<endl;
if(storea){
/*Number of rows of A per workgroup = htile*lsizex. Has to be divisble by lsizex. Trivially satisfied */
/*Number of columns of A per workgroup = ktile. Has to be divisble by lsizey*simdwidth */
if(ktile%(simdwidth*lsizey)!=0) return false;
}
if(storeb){
/*Number of columns of B per workgroup = ktile. Has to be divisble by lsizey*simdwidth */
if(ktile%(lsizey*simdwidth)!=0) return false;
/*Number of rows of B per workgroup = wtile*lsizey. Has to be divisble by lsizex*/
if((wtile*lsizey)%lsizex!=0) return false;
}
//cout<<"Check 2 passed"<<endl;
bool isDouble = (dtype.compare("double")==0);
if(ktile%simdwidth!=0) return false;
int numLocalMemElems = 0;
if(storea) numLocalMemElems += htile*lsizex*(ktile+padding);
if(storeb) numLocalMemElems += wtile*lsizey*(ktile+padding);
if(numLocalMemElems>maxLocalMemElems) return false;
//cout<<"Check 3 passed"<<endl;
//cout<<"Check 4 passed"<<endl;
stringstream ss;
ss<<"(";
if(useImageA){
ss<<"__read_only image2d_t A,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict A,";
}
if(useImageB){
ss<<"__read_only image2d_t B,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict B,";
}
ss<<"__global "<<dtype<<"2 *restrict C,unsigned int lda,unsigned int ldb,unsigned int ldc,unsigned int K,"<<dtype<<"2 alpha,"<<dtype<<"2 beta){"<<endl;
ss<<"const int htile ="<<htile<<";\n";
ss<<"const int wtile ="<<wtile<<";\n";
ss<<"const int ktile ="<<ktile<<";\n";
ss<<"const int simdwidth="<<simdwidth<<";\n";
ss<<"const int lx = "<<lsizex<<";\n";
ss<<"const int ly = "<<lsizey<<";\n";
ss<<"const int i = get_global_id(1);\n";
ss<<"const int j = get_global_id(0);\n";
ss<<"const unsigned int lidx = get_local_id(1);"<<endl;
ss<<"const unsigned int lidy = get_local_id(0);"<<endl;
ss<<"unsigned int k;"<<endl;
if(storea){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsA["<<(htile*lsizex)<<"]["<<((ktile/simdwidth)+padding)<<"];"<<endl;
}
if(storeb){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsB["<<(wtile*lsizey)<<"]["<<((ktile/simdwidth)+padding)<<"];"<<endl;
}
for(int x=0;x<htile;x++){
for(int y=0;y<wtile;y++){
ss<<dtype<<(simdwidth*2)<<" sum"<<x<<"_"<<y<<" = ("<<dtype<<(simdwidth*2)<<")(0);\n";
}
}
ss<<"const unsigned int ldbs = ldb/simdwidth;\n";
ss<<"const unsigned int ldas = lda/simdwidth;\n";
ss<<"for(k=0;k<K/simdwidth;k+=(ktile/simdwidth)){"<<endl;
if(storea){
ss<<"const int gstartxA = get_group_id(1)*htile*lx;\n";
for(int rowA=0;rowA<htile;rowA++){
for(int colA=0;colA<(ktile/(lsizey*simdwidth));colA++){
ss<<" ldsA["<<rowA<<"*lx + lidx]["<<colA<<"*ly + lidy] = ";
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k+"<<colA<<"*ly+lidy,gstartxA+"<<rowA<<"*lx+lidx)))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k+"<<colA<<"*ly+lidy,gstartxA+"<<rowA<<"*lx+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(gstartxA+"<<rowA<<"*lx + lidx)*(lda/simdwidth) + k + "<<colA<<"*ly + lidy];\n";
}
}
}
}
if(storeb){
ss<<"const int gstartxB = get_group_id(0)*wtile*ly;\n";
for(int rowB=0;rowB<(wtile*lsizey)/lsizex;rowB++){
for(int colB=0;colB<(ktile/(lsizey*simdwidth));colB++){
ss<<" ldsB["<<rowB<<"*lx + lidx]["<<colB<<"*ly + lidy] = ";
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(k+"<<colB<<"*ly+lidy,gstartxB+"<<rowB<<"*lx+lidx)))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(k+"<<colB<<"*ly+lidy,gstartxB+"<<rowB<<"*lx+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(gstartxB+"<<rowB<<"*lx + lidx)*(ldb/simdwidth) + k + "<<colB<<"*ly + lidy];\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
for(int rowB =0;rowB<wtile;rowB++){
for(int colB = 0;colB<ktile/simdwidth;colB++){
ss<<" const "<<dtype<<(simdwidth*2)<<" b"<<rowB<<"_"<<colB<<" = ";
if(storeb){
ss<<"ldsB["<<rowB<<"*ly+lidy]["<<colB<<"];\n";
}else{
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(k+"<<colB<<",get_group_id(0)*wtile*ly+"<<rowB<<"*ly+lidy)))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(k+"<<colB<<",get_group_id(0)*wtile*ly+"<<rowB<<"*ly+lidy)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(get_group_id(0)*wtile*ly + "<<rowB<<"*ly + lidy)*ldbs + k + "<<colB<<"];\n";
}
}
}
}
for(int rowA=0;rowA<htile;rowA++){
for(int colA =0;colA<ktile/simdwidth;colA++){
ss<<" const "<<dtype<<(simdwidth*2)<<" a"<<rowA<<"_"<<colA<<" = ";
if(storea){
ss<<"ldsA["<<rowA<<"*lx+lidx]["<<colA<<"];\n";
}else{
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k+"<<colA<<",get_group_id(1)*htile*lx+"<<rowA<<"*lx+lidx)))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k+"<<colA<<",get_group_id(1)*htile*lx+"<<rowA<<"*lx+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(get_group_id(1)*htile*lx+ "<<rowA<<"*lx+lidx )*ldas +k + "<<colA<<"];\n";
}
}
const int colB = colA;
for(int rowB=0;rowB<wtile;rowB++){
ss<<" sum"<<rowA<<"_"<<rowB;
ss<<" = fmaComplex"<<simdwidth<<"(a"<<rowA<<"_"<<colA<<",b"<<rowB<<"_"<<colB<<",";
ss<<" sum"<<rowA<<"_"<<rowB;
ss<<");\n";
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
ss<<"}"<<endl;
ss<<"const unsigned int Cx = get_group_id(1)*htile*lx;"<<endl;
ss<<"const unsigned int Cy = get_group_id(0)*wtile*ly;"<<endl;
for (int i = 0; i < htile; i++) {
for (int j = 0; j < wtile; j++) {
ss << "C[(Cx + " << i<< "*lx + lidx)*ldc + Cy + " << j << "*ly + lidy]";
ss << "= mulComplex1(alpha,(";
for(int s=0;s<simdwidth;s++){
ss<<"sum"<<i<<"_"<<j;
ss<<".s"<<(2*s)<<(2*s+1);
if(s<(simdwidth-1)) ss<<"+";
}
ss<<"))+ mulComplex1(beta,(";
ss << "C[(Cx + " << i<< "*lx + lidx)*ldc + Cy + " << j << "*ly + lidy]";
ss<<"));\n";
}
}
//ss<<"}"<<endl;
ss<<"}"<<endl;
kernel = ss.str();
return true;
}
static bool genCkernelNNCons(int lsizex,
int lsizey,
int htile,
int wtile,
int ktile,
string dtype,
int simdwidth,
bool storea,
bool storeb,
int maxLocalMemElems,
int padding,
string& kernel,bool useImageA,bool useImageB){
bool isDouble = (dtype.compare("double")==0);
//cout<<"StoreA "<<storea<<" "<<"StoreB "<<storeb<<" "<<htile<<" "<<wtile<<" "<<" "<<ktile<<" "<<simdwidth<<" "<<lsizex<<" "<<lsizey<<" "<<unroll;
//cout<<" "<<maxLocalMemElems<<" "<<endl;
if(storea){
/*Number of rows of A per workgroup = htile*lsizex. Has to be divisble by lsizex. Trivially satisfied */
/*Number of columns of A per workgroup = ktile. Has to be divisble by lsizey*simdwidth */
if(ktile%(simdwidth*lsizey)!=0) return false;
}
if(storeb){
/*Number of columns of B per workgroup = wtile*lsizey. Has to be divisble by lsizey*simdwidth */
if(ktile%lsizex!=0) return false;
if(((wtile*lsizey)%(lsizey*simdwidth))!=0) return false;
}
//cout<<"Check 2 passed"<<endl;
if(wtile%simdwidth!=0 || ktile%simdwidth!=0) return false;
if(!storea && !storeb && ktile>simdwidth) return false;
int numLocalMemElems = 0;
if(storea) numLocalMemElems += htile*lsizex*(ktile+padding);
if(storeb) numLocalMemElems += ktile*(wtile*lsizey+padding);
if(numLocalMemElems>maxLocalMemElems) return false;
//cout<<"Check 3 passed"<<endl;
//cout<<"Check 4 passed"<<endl;
stringstream ss;
ss<<"(";
if(useImageA){
ss<<"__read_only image2d_t A,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict A,";
}
if(useImageB){
ss<<"__read_only image2d_t B,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict B,";
}
ss<<"__global "<<dtype<<"2 *restrict C,unsigned int lda,unsigned int ldb,unsigned int ldc,unsigned int K,"<<dtype<<"2 alpha,"<<dtype<<"2 beta){"<<endl;
ss<<"const int htile ="<<htile<<";\n";
ss<<"const int wtile ="<<wtile<<";\n";
ss<<"const int ktile ="<<ktile<<";\n";
ss<<"const int simdwidth="<<simdwidth<<";\n";
ss<<"const int lx = "<<lsizex<<";\n";
ss<<"const int ly = "<<lsizey<<";\n";
ss<<"const int i = get_global_id(1);"<<endl;
ss<<"const int j = get_global_id(0);"<<endl;
ss<<"const unsigned int lidx = get_local_id(1);"<<endl;
ss<<"const unsigned int lidy = get_local_id(0);"<<endl;
ss<<"int k;"<<endl;
if(storea){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsA["<<(htile*lsizex)<<"]["<<((ktile/simdwidth)+padding)<<"];"<<endl;
}
if(storeb){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsB["<<(ktile)<<"]["<<((wtile/simdwidth)*lsizey+padding)<<"];"<<endl;
}
for(int x=0;x<htile;x++){
for(int y=0;y<wtile/simdwidth;y++){
ss<<dtype<<(simdwidth*2)<<" sum"<<x<<"_"<<y<<" = ("<<dtype<<(simdwidth*2)<<")(0);\n";
}
}
ss<<"for(k=0;k<K;k+=ktile){"<<endl;
if(storea){
ss<<"const int gstartxA = get_group_id(1)*htile*lx;\n";
for(int x=0;x<htile;x++){
for(int y=0;y<(ktile/(lsizey*simdwidth));y++){
ss<<" ldsA["<<x<<"*lx + lidx]["<<y<<"*ly + lidy] = ";
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k/simdwidth +"<<y<<"*ly+lidy,gstartxA+"<<x<<"*lx+lidx)))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k/simdwidth+"<<y<<"*ly+lidy,gstartxA+"<<x<<"*lx+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(gstartxA+"<<x<<"*lx + lidx)*(lda/simdwidth) + k/simdwidth + "<<y<<"*ly + lidy];\n";
}
}
}
}
if(storeb){
ss<<"const int gstartxB = get_group_id(0)*(wtile/simdwidth)*ly;\n";
for(int x=0;x<(wtile/simdwidth);x++){
for(int y=0;y<(ktile/lsizex);y++){
ss<<" ldsB["<<y<<"*lx + lidx]["<<x<<"*ly + lidy] = ";
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(gstartxB + lidy + "<<x<<"*ly,k+"<<y<<"*lx +lidx)))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(gstartxB + lidy + "<<x<<"*ly,k+"<<y<<"*lx +lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(k+"<<y<<"*lx+lidx)*(ldb/simdwidth)+ gstartxB + lidy + "<<x<<"*ly];\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
/*for (int x = 0; x < wtile/simdwidth; x++) {
for (int y = 0; y < ktile; y++) {
ss << " const " << dtype << simdwidth << " b" << x << "_" << y << " = ";
if(storeb){
ss << "ldsB["<<y<<"][lidy*(wtile/simdwidth)+"<<x<<"];\n";
}else{
ss << "B[(k+"<<y<<")*(ldb/simdwidth)+j*(wtile/simdwidth)+"<<x<<"];\n";
}
}
}*/
for (int k = 0; k < ktile/simdwidth; k++) {
for (int koff = 0; koff < simdwidth; koff++) {
for (int x = 0; x < wtile/simdwidth; x++) {
int rowB = k*simdwidth+koff;
ss << " const " << dtype << (simdwidth*2) << " b" << x << "_" << rowB << " = ";
if(storeb){
ss << "ldsB["<<rowB<<"][lidy*(wtile/simdwidth)+"<<x<<"];\n";
}else{
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(j*(wtile/simdwidth) + "<<x<<",k+"<<rowB<<")))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(j*(wtile/simdwidth) + "<<x<<",k+"<<rowB<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss << "B[(k+"<<rowB<<")*(ldb/simdwidth)+j*(wtile/simdwidth)+"<<x<<"];\n";
}
}
}
}
for(int y =0; y < htile; y++){
ss << " const " << dtype << (simdwidth*2) << " a" << k << "_" << y << " = ";
if(storea){
ss << "ldsA["<<y<<"+lidx*htile]["<<k<<"];\n";
}else{
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k/simdwidth +"<<k<<",i*htile+"<<y<<")))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k/simdwidth+"<<k<<",i*htile + "<<y<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss << "A[(i*htile + "<<y<<")*(lda/simdwidth) + k/simdwidth+"<<k<<"];"<<endl;
}
}
for(int koff=0;koff<simdwidth;koff++){
int rowB = (k*simdwidth+koff);
for(int x = 0;x<(wtile/simdwidth);x++){
ss<<"sum"<<y<<"_"<<x<<" = fmaComplex"<<simdwidth<<"(a"<<k<<"_"<<y;
ss<<".s";
for(int t=0;t<simdwidth;t++) ss<<(2*koff)<<(2*koff+1);
ss<<",b"<<x<<"_"<<rowB<<",";
ss<<"sum"<<y<<"_"<<x<<");\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
ss<<"}"<<endl;
for (int i = 0; i < htile; i++) {
for (int j = 0; j < wtile; j++) {
ss << "C[(i*" << htile << "+ " << i << ")*ldc + j*" << wtile << "+" << j << "]";
ss << "= mulComplex1(alpha,sum"<<i<<"_"<<(j/simdwidth);
ss<<".s"<<2*(j%simdwidth)<<(2*(j%simdwidth)+1);
ss<<") + mulComplex1(beta,";
ss << "C[(i*" << htile << "+ " << i << ")*ldc + j*" << wtile << "+" << j << "])";
ss << ";" << endl;
}
}
ss<<"}"<<endl;
kernel = ss.str();
return true;
}
static bool genCkernelNNOff(int lsizex,
int lsizey,
int htile,
int wtile,
int ktile,
string dtype,
int simdwidth,
bool storea,
bool storeb,
int maxLocalMemElems,
int padding,
string& kernel,bool useImageA,bool useImageB){
bool isDouble = (dtype.compare("double")==0);
//cout<<"StoreA "<<storea<<" "<<"StoreB "<<storeb<<" "<<htile<<" "<<wtile<<" "<<" "<<ktile<<" "<<simdwidth<<" "<<lsizex<<" "<<lsizey<<" "<<unroll;
//cout<<" "<<maxLocalMemElems<<" "<<endl;
if(storea){
/*Number of rows of A per workgroup = htile*lsizex. Has to be divisble by lsizex. Trivially satisfied */
/*Number of columns of A per workgroup = ktile. Has to be divisble by lsizey*simdwidth */
if(ktile%(simdwidth*lsizey)!=0) return false;
}
if(storeb){
/*Number of columns of B per workgroup = wtile*lsizey. Has to be divisble by lsizey*simdwidth */
if(ktile%lsizex!=0) return false;
if(((wtile*lsizey)%(lsizey*simdwidth))!=0) return false;
}
//cout<<"Check 2 passed"<<endl;
if(wtile%simdwidth!=0 || ktile%simdwidth!=0) return false;
if(!storea && !storeb && ktile>simdwidth) return false;
int numLocalMemElems = 0;
if(storea) numLocalMemElems += htile*lsizex*(ktile+padding);
if(storeb) numLocalMemElems += ktile*(wtile*lsizey+padding);
if(numLocalMemElems>maxLocalMemElems) return false;
//cout<<"Check 3 passed"<<endl;
//cout<<"Check 4 passed"<<endl;
stringstream ss;
ss<<"(";
if(useImageA){
ss<<"__read_only image2d_t A,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict A,";
}
if(useImageB){
ss<<"__read_only image2d_t B,";
}else{
ss<<"const __global "<<dtype<<(simdwidth*2)<<" *restrict B,";
}
ss<<"__global "<<dtype<<"2 *restrict C,unsigned int lda,unsigned int ldb,unsigned int ldc,unsigned int K,"<<dtype<<"2 alpha,"<<dtype<<"2 beta){"<<endl;
ss<<"const int htile ="<<htile<<";\n";
ss<<"const int wtile ="<<wtile<<";\n";
ss<<"const int ktile ="<<ktile<<";\n";
ss<<"const int simdwidth="<<simdwidth<<";\n";
ss<<"const int lx = "<<lsizex<<";\n";
ss<<"const int ly = "<<lsizey<<";\n";
ss<<"const int i = get_global_id(1);"<<endl;
ss<<"const int j = get_global_id(0);"<<endl;
ss<<"const unsigned int lidx = get_local_id(1);"<<endl;
ss<<"const unsigned int lidy = get_local_id(0);"<<endl;
ss<<"int k;"<<endl;
if(storea){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsA["<<(htile*lsizex)<<"]["<<((ktile/simdwidth)+padding)<<"];"<<endl;
}
if(storeb){
ss<<"__local "<<dtype<<(simdwidth*2)<<" ldsB["<<(ktile)<<"]["<<((wtile/simdwidth)*lsizey+padding)<<"];"<<endl;
}
for(int x=0;x<htile;x++){
for(int y=0;y<wtile/simdwidth;y++){
ss<<dtype<<(simdwidth*2)<<" sum"<<x<<"_"<<y<<" = ("<<dtype<<(simdwidth*2)<<")(0);\n";
}
}
ss<<"for(k=0;k<K;k+=ktile){"<<endl;
if(storea){
ss<<"const int gstartxA = get_group_id(1)*htile*lx;\n";
for(int x=0;x<htile;x++){
for(int y=0;y<(ktile/(lsizey*simdwidth));y++){
ss<<" ldsA["<<x<<"*lx + lidx]["<<y<<"*ly + lidy] = ";
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k/simdwidth +"<<y<<"*ly+lidy,gstartxA+"<<x<<"*lx+lidx)))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k/simdwidth+"<<y<<"*ly+lidy,gstartxA+"<<x<<"*lx+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"A[(gstartxA+"<<x<<"*lx + lidx)*(lda/simdwidth) + k/simdwidth + "<<y<<"*ly + lidy];\n";
}
}
}
}
if(storeb){
ss<<"const int gstartxB = get_group_id(0)*(wtile/simdwidth)*ly;\n";
for(int x=0;x<(wtile/simdwidth);x++){
for(int y=0;y<(ktile/lsizex);y++){
ss<<" ldsB["<<y<<"*lx + lidx]["<<x<<"*ly + lidy] = ";
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(gstartxB + lidy + "<<x<<"*ly,k+"<<y<<"*lx +lidx)))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(gstartxB + lidy + "<<x<<"*ly,k+"<<y<<"*lx +lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss<<"B[(k+"<<y<<"*lx+lidx)*(ldb/simdwidth)+ gstartxB + lidy + "<<x<<"*ly];\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
/*for (int x = 0; x < wtile/simdwidth; x++) {
for (int y = 0; y < ktile; y++) {
ss << " const " << dtype << simdwidth << " b" << x << "_" << y << " = ";
if(storeb){
ss << "ldsB["<<y<<"][lidy*(wtile/simdwidth)+"<<x<<"];\n";
}else{
ss << "B[(k+"<<y<<")*(ldb/simdwidth)+j*(wtile/simdwidth)+"<<x<<"];\n";
}
}
}*/
for (int k = 0; k < ktile/simdwidth; k++) {
for (int koff = 0; koff < simdwidth; koff++) {
for (int x = 0; x < wtile/simdwidth; x++) {
int rowB = k*simdwidth+koff;
ss << " const " << dtype << (simdwidth*2) << " b" << x << "_" << rowB << " = ";
if(storeb){
ss << "ldsB["<<rowB<<"][lidy+ly*"<<x<<"];\n";
}else{
if(useImageB){
if(isDouble){
ss<<"as_double2(read_imagei(B,sampler,(int2)(get_group_id(0)*(wtile/simdwidth)*ly + lidy+"<<x<<"*ly,k+"<<rowB<<")))";
}else{
ss<<"(read_imagef(B,sampler,(int2)(get_group_id(0)*(wtile/simdwidth)*ly + lidy+"<<x<<"*ly,k+"<<rowB<<")))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss << "B[(k+"<<rowB<<")*(ldb/simdwidth)+get_group_id(0)*(wtile/simdwidth)*ly + lidy+"<<x<<"*ly];\n";
}
}
}
}
for(int y =0; y < htile; y++){
ss << " const " << dtype << (simdwidth*2) << " a" << k << "_" << y << " = ";
if(storea){
ss << "ldsA["<<y<<"*lx+lidx]["<<k<<"];\n";
}else{
if(useImageA){
if(isDouble){
ss<<"as_double2(read_imagei(A,sampler,(int2)(k/simdwidth+"<<k<<",get_group_id(1)*htile*lx + lx*"<<y<<"+lidx)))";
}else{
ss<<"(read_imagef(A,sampler,(int2)(k/simdwidth+"<<k<<",get_group_id(1)*htile*lx + lx*"<<y<<"+lidx)))";
}
ss<<".s";
for(int s=0;s<simdwidth*2;s++) ss<<s;
ss<<";\n";
}else{
ss << "A[(get_group_id(1)*htile*lx + lx*"<<y<<"+lidx)*(lda/simdwidth) + k/simdwidth+"<<k<<"];"<<endl;
}
}
for(int koff=0;koff<simdwidth;koff++){
int rowB = (k*simdwidth+koff);
for(int x = 0;x<(wtile/simdwidth);x++){
ss<<"sum"<<y<<"_"<<x<<" = fmaComplex"<<simdwidth<<"(a"<<k<<"_"<<y;
ss<<".s";
for(int t=0;t<simdwidth;t++) ss<<(2*koff)<<(2*koff+1);
ss<<",b"<<x<<"_"<<rowB<<",";
ss<<"sum"<<y<<"_"<<x<<");\n";
}
}
}
}
if(storea || storeb) ss<<" barrier(CLK_LOCAL_MEM_FENCE);"<<endl;
ss<<"}"<<endl;
ss<<"const unsigned int Cx = get_group_id(1)*htile*lx;"<<endl;
ss<<"const unsigned int Cy = get_group_id(0)*wtile*ly;"<<endl;
for (int i = 0; i < htile; i++) {
for (int j = 0; j < wtile; j++) {
ss << "C[( Cx+ lidx+lx*"<< i << ")*ldc + Cy + simdwidth*lidy + simdwidth*ly*" << j/simdwidth << "+"<<(j%simdwidth)<<"]";
ss << "= mulComplex1(alpha,sum"<<i<<"_"<<(j/simdwidth);
const int off = j%simdwidth;
ss<<".s"<<(2*off)<<(2*off+1);
ss<<") + mulComplex1(beta,";
ss << "C[( Cx+ lidx+lx*"<< i << ")*ldc + Cy + simdwidth*lidy + simdwidth*ly*" << j/simdwidth << "+"<<(j%simdwidth)<<"])";
//ss<<"C[(i*"<<htile<<"+ i)*N + j*"<<wtile<<"+"<<offset<<"]";
ss << ";" << endl;
}
}
ss<<"}"<<endl;
kernel = ss.str();
return true;
}
template <typename T>
static double testGemmComplex(unsigned int N,cl_device_id dvc,cl_context ctx,cl_kernel krnl, RaijinGemmOptKernel& optkernel, RaijinTranspose *transObj,
RaijinCopy *copyObj,
RaijinScale *scaleObj,bool verify=true){
typedef typename T::ctype ctype;
typedef typename T::basetype basetype;
size_t size = sizeof(ctype) * N * N;
cl_mem bufA, bufB, bufC;
ctype *ptrA = new ctype[N * N];
ctype *ptrB = new ctype[N * N];
ctype *ptrC = new ctype[N * N];
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if(optkernel.transA){
ptrA[i * N + j].s[0] = 0.002 * j;
ptrA[i*N +j].s[1] = 1;
}else{
ptrA[i*N + j].s[0] = 0.002*i;
ptrA[i*N+j].s[1] = 1;
}
if(optkernel.transB){
ptrB[i * N + j].s[0] = 0.002 * i;
ptrB[i*N+j].s[1] = 1;
}else{
ptrB[i*N + j].s[0] = 0.002*j;
ptrB[i*N+j].s[1] = 1;
}
ptrC[i * N + j].s[0] = 0;
ptrC[i*N+j].s[1] = 0;
}
}
cl_command_queue q = clCreateCommandQueue(ctx,dvc,0,NULL);
cl_int errcode;
bufA = clCreateBuffer(ctx, CL_MEM_READ_ONLY, size, NULL, &errcode);
bufB = clCreateBuffer(ctx, CL_MEM_READ_ONLY, size, NULL, &errcode);
bufC = clCreateBuffer(ctx, CL_MEM_READ_WRITE, size, NULL, &errcode);
clEnqueueWriteBuffer(q, bufA, CL_TRUE, 0, size, ptrA, 0, NULL, NULL);
clEnqueueWriteBuffer(q, bufB, CL_TRUE, 0, size, ptrB, 0, NULL, NULL);
clEnqueueWriteBuffer(q, bufC, CL_TRUE, 0, size, ptrC, 0, NULL, NULL);
clFlush( q);
const int niters = 3;
double tdiff = 0;
for(int i=0;i<niters;i++){
RTimer rt;
rt.start();
ctype alpha;
alpha.s[0] = 1;
alpha.s[1] = 0;
ctype beta;
beta.s[0] = 0;
beta.s[1] = 0;
RaijinCleaner *cleaner = new RaijinCleaner;
cl_event evt = raijinApplyOpt<ctype>(q,cleaner,krnl,optkernel,ctx,dvc,RaijinCL::RaijinRowMajor,optkernel.transA,optkernel.transB,N,N,N,
alpha,bufA,N,bufB,N,beta,bufC,N,transObj,copyObj,scaleObj);
clFinish(q);
delete cleaner;
rt.stop();
if(i>0){
tdiff += rt.getDiff();
cout<<rt.getDiff()<<endl;
}
}
tdiff /= (niters-1);
if(verify){
clEnqueueReadBuffer(q, bufC, CL_TRUE, 0, size, ptrC, 0, NULL, NULL);
double totalerror = 0.0;
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
basetype calc = ptrC[i*N+j].s[0];
basetype expected = N*((0.002*i)*(0.002*j)-1);
double val = calc - expected;
if(val<0) val = -val;
//if(val>1) cout<<"Real: "<<i<<" "<<j<<" "<<calc<<" "<<expected<<endl;
//if(val>1) exit(-1);
basetype calcimg = ptrC[i*N+j].s[1];
basetype expimg = N*(0.002*i+0.002*j);
double valimg = calcimg - expimg;
if(valimg<0) valimg *= -1;
totalerror += (val+valimg);
}
}
double avgerror = (totalerror)/(N*N);
cout<<"Avg absolute error "<<(totalerror/(N*N))<<endl;
//if(avgerror>1.0) exit(-1);
}
clReleaseMemObject(bufA);
clReleaseMemObject(bufB);
clReleaseMemObject(bufC);
delete[] ptrA;
delete[] ptrB;
delete[] ptrC;
clReleaseCommandQueue(q);
return 8.0e-9*N*(1.0*N)*(1.0*N)/tdiff;
}
string genCmulFuncs(bool isDouble){
string dtype = (isDouble)? "double":"float";
stringstream ss;
//mulComplex1
if(isDouble){
ss<<"#ifdef cl_khr_fp64\n"<<endl;
ss<<"#pragma OPENCL EXTENSION cl_khr_fp64 : enable"<<endl;
ss<<"#else"<<endl;
ss<<"#pragma OPENCL EXTENSION cl_amd_fp64 : enable"<<endl;
ss<<"#endif"<<endl;
}
ss<<dtype<<"2 mulComplex1("<<dtype<<"2 a,"<<dtype<<"2 b){"<<endl;
ss<<dtype<<"2 c;"<<endl;
//if(isDouble) ss<<"#ifndef FP_FAST_FMAF"<<endl;
//ss<<"c.x = a.x*b.x - a.y*b.y;"<<endl;
//if(isDouble){
//ss<<"#else"<<endl;
ss<<dtype<<" temp = -a.y*b.y;"<<endl;
ss<<"c.x = fma(a.x,b.x,temp);"<<endl;
//ss<<"#endif"<<endl;
//}
//if(isDouble) ss<<"#ifndef FP_FAST_FMAF"<<endl;
//ss<<"c.y = a.x*b.y + a.y*b.x;"<<endl;
//if(isDouble){
//ss<<"#else"<<endl;
ss<<dtype<<" temp2 = a.y*b.x;"<<endl;
ss<<"c.y = fma(a.x,b.y,temp2);"<<endl;
//ss<<"#endif"<<endl;
//}
ss<<"return c;\n}"<<endl;
//mulComplex2
ss<<dtype<<"4 mulComplex2("<<dtype<<"4 a,"<<dtype<<"4 b){"<<endl;
ss<<dtype<<"4 c;"<<endl;
ss<<"c.s01 = mulComplex1(a.s01,b.s01); c.s23 = mulComplex1(a.s23,b.s23);"<<endl;
ss<<"return c;\n}"<<endl;
//fmaComplex1
ss<<dtype<<"2 fmaComplex1("<<dtype<<"2 a,"<<dtype<<"2 b,"<<dtype<<"2 c){"<<endl;
ss<<" "<<dtype<<"2 res;"<<endl;
if(isDouble) ss<<"#ifndef FP_FAST_FMAF"<<endl;
ss<<" res.x = a.x*b.x + c.x;"<<endl;
ss<<" res.y = a.x*b.y + c.y;"<<endl;
ss<<" res.x = -a.y*b.y + res.x;"<<endl;
ss<<" res.y = a.y*b.x + res.y;"<<endl;
if(isDouble){
ss<<"#else"<<endl;
ss<<" res.x = fma(-a.y,b.y,c.x);"<<endl;
ss<<" res.y = fma(a.y,b.x,c.y);"<<endl;
ss<<" res.x = fma(a.x,b.x,res.x);"<<endl;
ss<<" res.y = fma(a.x,b.y,res.y);"<<endl;
ss<<"#endif"<<endl;
}
ss<<" return res;"<<endl;
ss<<"}"<<endl;
//fmaComplex2
ss<<dtype<<"4 fmaComplex2("<<dtype<<"4 a,"<<dtype<<"4 b,"<<dtype<<"4 c){"<<endl;
ss<<dtype<<"4 res;"<<endl;
ss<<"res.s01 = fmaComplex1(a.s01,b.s01,c.s01); res.s23 = fmaComplex1(a.s23,b.s23,c.s23);"<<endl;
ss<<"return res;\n}"<<endl;
/*ss<<dtype<<"2 are = a.s02,aim =a.s13;\n";
ss<<dtype<<"2 bre = b.s02,bim= b.s13;\n";
ss<<dtype<<"2 cre = c.s02,cim =c.s13;\n";
ss<<dtype<<"2 rre = are*bre+cre; rre = -aim*bim+rre;\n";
ss<<dtype<<"2 rim = are*bim+cim; rim = bre*aim+rim;\n";
ss<<"rre = -aim*bim + rre;\n"<<endl;
ss<<"rim = bre*aim + rim;\n";
ss<<dtype<<"4 res; res.s02 = rre; res.s13 = rim;\n";
ss<<"return res;\n}";*/
return ss.str();
}
template <typename T>
static void tuneGemmComplex(cl_context ctx, cl_device_id dvc,RaijinGemmOptKernel *optparams,unsigned int N,double *gflopbest){
cout<<"Inside tuneGemmCache"<<endl;
cout<<"Tuning "<<T::gemmName()<<endl;
cl_int errcode;
cl_command_queue q = clCreateCommandQueue(ctx,dvc,0,&errcode);
if(errcode!=CL_SUCCESS) cout<<"Error creating queue"<<endl;
typedef typename T::ctype ctype;
size_t size = sizeof(ctype)*N*N;
int htiles[] = {2,4,4,8,4};
int wtiles[] = {4,2,4,4,8};
int ktiles[] = {1,2,4,8,16,32};
int simdwidths[] = {1,2,4,8};
int lsizesX[] = {4,8,8,4,16,16};
int lsizesY[] = {8,4,8,16,4,16};
int unrolls[] = {1,2,4,8};
bool storeA[] = {true, false};
bool storeB[] = {true, false};
bool useImageA[] = {true,false};
bool useImageB[] = {true,false};
bool initialized = false;
//double tbest = 0.0;
string prgmbest;
*gflopbest = 0.0;
cl_device_type dvctype;
cl_ulong lmemSize;
cl_device_local_mem_type ltype;
clGetDeviceInfo(dvc,CL_DEVICE_TYPE,sizeof(dvctype),&dvctype,NULL);
clGetDeviceInfo(dvc,CL_DEVICE_LOCAL_MEM_SIZE,sizeof(lmemSize),&lmemSize,NULL);
clGetDeviceInfo(dvc,CL_DEVICE_LOCAL_MEM_TYPE,sizeof(ltype),<ype,NULL);
RaijinTranspose transObj(dvc,ctx);
RaijinCopy copyObj(ctx,dvc);
RaijinScale scaleObj(ctx,dvc);
cl_uint vecWidth;
if(T::isDouble()) clGetDeviceInfo(dvc,CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE,sizeof(cl_uint),&vecWidth,NULL);
else clGetDeviceInfo(dvc,CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT,sizeof(cl_uint),&vecWidth,NULL);
bool imgA[] = {true,false};
bool imgB[] = {true,false};
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
for (int simdidx = 0; simdidx < 2;simdidx++) {
for (int ktileidx = 0; ktileidx < 5; ktileidx++) {
for(int sa = 0 ; sa<1; sa++){
for(int sb = 0; sb <1 ; sb++){
for(int imgAidx=0;imgAidx<2;imgAidx++){
for(int imgBidx=0;imgBidx<2;imgBidx++){
//if(T::isDouble() && simdidx>0) continue;
int ktile = ktiles[ktileidx];
const int unr = ktile;
//cout<<s<<" "<<bfidx<<" "<<splits[s]<<" "<<bfirsts[bfidx]<<endl;
bool isAggregate = false;
bool storec = false;
int htile = htiles[i];
int wtile = wtiles[i];
bool useImageA = imgA[imgAidx];
bool useImageB = imgB[imgBidx];
bool transA = true;
bool transB = false;
if(dvctype!=CL_DEVICE_TYPE_GPU && (useImageA || useImageB)) continue;
if(ltype!=CL_LOCAL && (storeA[sa] || storeB[sb])) continue;
string body;
const int simd = simdwidths[simdidx];
//if(dvctype==CL_DEVICE_TYPE_CPU && simd!=vecWidth) continue;
if(dvctype==CL_DEVICE_TYPE_GPU){
if(T::isDouble() && simd>2) continue;
else if(!(T::isDouble()) && simd>4) continue;
}
int regest = 2*(htile * wtile + htile * simd + wtile * simd);
if(regest>128) continue;
string dtype = T::name();
int lx, ly;
lx = lsizesX[j];
ly = lsizesY[j];
unsigned int nVecRegs = htile*wtile;
nVecRegs += (htile>wtile) ? (wtile/simd) : (htile/simd);
//if(dvctype==CL_DEVICE_TYPE_CPU && nVecRegs>16) continue;
bool kernSuc = genCkernelTNOff(lx,ly,htile, wtile, ktile,dtype, simd, storeA[sa],storeB[sb],lmemSize/(sizeof(ctype))
,1,body,useImageA,useImageB);
/*unsigned int nVecRegs = htile*wtile/simd;
nVecRegs += (htile>wtile) ? (wtile/simd) : (htile/simd);
if(dvctype==CL_DEVICE_TYPE_CPU && nVecRegs>16) continue;
bool kernSuc = genKernelTNCons(lx,ly,htile, wtile, ktile,dtype, simd, storeA[sa],storeB[sb],lmemSize/(sizeof(realtype))
,1,body,useImageA,useImageB);*/
if(!kernSuc) continue;
//cout<<body<<endl;
stringstream kernelstream;
stringstream namestream;
namestream << T::gemmName() << i << "_" << j << "_" << simdidx << "_" << ktileidx << "_" << sa << "_" <<sb<<"_"<<imgAidx<<"_"<<imgBidx;
string kname = namestream.str();
kernelstream<<genCmulFuncs(T::isDouble())<<endl;
if(useImageA || useImageB){
kernelstream<<"__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;"<<endl;
kernelstream<<"float4 myread_imagef(__read_only image2d_t img,int2 pos){ return read_imagef(img,sampler,pos);\n}"<<endl;
}
kernelstream<<"__kernel ";
if(isAggregate){
kernelstream<<"__attribute__((reqd_work_group_size(1,1,1))) "<<endl;
}else{
kernelstream<<"__attribute__((reqd_work_group_size("<<ly<<","<<lx<<",1))) "<<endl;
}
kernelstream <<"void " << kname;
kernelstream << body;
string kernelsrc = kernelstream.str();
string klogname = kname +".cl";
ofstream klog(klogname.c_str());
klog<<kernelsrc<<endl;
klog.close();
const size_t len = kernelsrc.length();
cl_int errcode1, errcode2;
RTimer rt1, rt2, rt3;
rt1.start();
const char *srcbuf = kernelsrc.c_str();
cl_program prg = clCreateProgramWithSource(ctx, 1, &srcbuf, (const size_t*) &len, &errcode1);
cl_int bldcode = clBuildProgram(prg, 1, &dvc, "", NULL, NULL);
cl_kernel krnl = clCreateKernel(prg, kname.c_str(), &errcode2);
rt1.stop();
cout<<"Compile time "<<rt1.getDiff()<<endl;
if (errcode1 != CL_SUCCESS || errcode2 != CL_SUCCESS || bldcode != CL_SUCCESS) {
/*cl::Program prgmcpp(prg);
const cl::Device dvccpp(dvc);
string buildlog = prgmcpp.getBuildInfo<CL_PROGRAM_BUILD_LOG>(dvccpp);
cout<<buildlog<<endl;*/
size_t retbytes;
cout << "Error creating program from source " << errcode1 << " " << errcode2 << " " << bldcode << endl;
clGetProgramBuildInfo(prg, dvc, CL_PROGRAM_BUILD_LOG, 0, NULL, &retbytes);
char *buildlog = new char[retbytes+1];
clGetProgramBuildInfo(prg,dvc,CL_PROGRAM_BUILD_LOG,retbytes,buildlog,NULL);
cout << "Buildlog " << retbytes<<" "<<buildlog << endl;
//cout << "Error creating program from source " << errcode1 << " " << errcode2 << " " << bldcode << endl;
cout << kernelsrc << endl;
exit(-1);
continue;
} else {
//string fname = kname+".cl";
//ofstream of(fname.c_str());
//of<<kernelsrc<<endl;
//of.close();
//cout<<"Time taken to compile "<<rt1.getDiff()<<endl;
RaijinGemmOptKernel candidate;
candidate.transA = transA;
candidate.transB = transB;
candidate.simdwidth = simd;
candidate.htile = htile;
candidate.wtile = wtile;
candidate.ktile = ktile;
candidate.lsizex = lx;
candidate.lsizey = ly;
candidate.kernel = kernelsrc;
candidate.kname = kname;
candidate.imageA = useImageA;
candidate.imageB = useImageB;
double gflops;
size_t tuneSize = 2048;
gflops = testGemmComplex<T>(tuneSize, dvc, ctx, krnl,candidate,&transObj,©Obj,&scaleObj,true);
clReleaseKernel(krnl);
clReleaseProgram(prg);
double bwidth = (htile+wtile)*gflops*sizeof(ctype)/(8*htile*wtile);
cout<<"htile "<<htile<<" wtile "<<wtile<<" ktile "<<(ktile);
cout<<" lx "<<lx<<" ly "<<ly<<" simd "<<simd<<" storeA? "<<storeA[sa]<<" storeB? "<<storeB[sb];
cout<<" ImageA? "<<useImageA<<" ImageB? "<<useImageB<<endl;
if (!initialized || (gflops > (*gflopbest)) && (gflops < 2500)) {
*optparams = candidate;
*gflopbest = gflops;
initialized = true;
}
cout << "Gflops " << gflops << " Bwidth "<< bwidth<<" Best So Far "<<(*gflopbest)<<" "<<kname<<endl;
}
}
}
}
}
}
}
}
}
clReleaseCommandQueue(q);
}
template <typename T>
bool tuneGemmComplex(cl_platform_id platform, cl_device_id dvc,RaijinGemmOptKernel *optkernel,unsigned int N=1024){
cout<<"Inside tuneGemm"<<endl;
cl_context_properties conprop[3];
conprop[0] = CL_CONTEXT_PLATFORM;
conprop[1] = (cl_context_properties)platform;
conprop[2] = (cl_context_properties)0;
cl_int errcode;
cl_context ctx = clCreateContext(conprop,1,&dvc,NULL,NULL,&errcode);
if(errcode==CL_SUCCESS){
double gflopbest=0.0;
tuneGemmComplex<T>(ctx,dvc,optkernel,N,&gflopbest);
}else{
cout<<"Could not successfully create context for this device"<<endl;
return false;
}
clReleaseContext(ctx);
return true;
}
void RaijinCL::raijinTuneZgemm(cl_device_id dvc){
RaijinGemmOptKernel zgemmParams;
cl_platform_id platform;
clGetDeviceInfo(dvc,CL_DEVICE_PLATFORM,sizeof(cl_platform_id),&platform,NULL);
string zpath = raijinGetProfileFileName(dvc,"zgemm");
ofstream zfile(zpath.c_str());
tuneGemmComplex<GemmCdouble>(platform,dvc,&zgemmParams);
zfile<<zgemmParams<<endl;
zfile.close();
}
void RaijinCL::raijinTuneCgemm(cl_device_id dvc){
RaijinGemmOptKernel cgemmParams;
cl_platform_id platform;
clGetDeviceInfo(dvc,CL_DEVICE_PLATFORM,sizeof(cl_platform_id),&platform,NULL);
string cpath = raijinGetProfileFileName(dvc,"cgemm");
ofstream cfile(cpath.c_str());
tuneGemmComplex<GemmCsingle>(platform,dvc,&cgemmParams);
cfile<<cgemmParams<<endl;
cfile.close();
}
| 44.319343 | 193 | 0.447427 |
codedivine
|
459c85c986e46de885a11a2a0a52ad2704918e44
| 1,840 |
cpp
|
C++
|
hyperplatform_log_parser/hyperplatform_log_parser.cpp
|
tandasat/hyperplatform_log_parser
|
7a7eba3c8c582fa43ba2a47372a363080796d2d4
|
[
"MIT"
] | 17 |
2016-04-08T10:59:03.000Z
|
2021-12-11T07:09:31.000Z
|
hyperplatform_log_parser/hyperplatform_log_parser.cpp
|
c3358/hyperplatform_log_parser
|
7a7eba3c8c582fa43ba2a47372a363080796d2d4
|
[
"MIT"
] | null | null | null |
hyperplatform_log_parser/hyperplatform_log_parser.cpp
|
c3358/hyperplatform_log_parser
|
7a7eba3c8c582fa43ba2a47372a363080796d2d4
|
[
"MIT"
] | 11 |
2016-07-02T15:23:57.000Z
|
2021-01-08T19:27:36.000Z
|
// Copyright (c) 2015-2016, tandasat. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
//
// This module implements an entry point of the driver.
//
#include "stdafx.h"
#include "log_parser.h"
#include "utility.h"
////////////////////////////////////////////////////////////////////////////////
//
// macro utilities
//
////////////////////////////////////////////////////////////////////////////////
//
// constants and macros
//
////////////////////////////////////////////////////////////////////////////////
//
// types
//
////////////////////////////////////////////////////////////////////////////////
//
// prototypes
//
bool AppMain(_In_ const std::vector<std::basic_string<TCHAR>> &args);
////////////////////////////////////////////////////////////////////////////////
//
// variables
//
////////////////////////////////////////////////////////////////////////////////
//
// implementations
//
//
int _tmain(int argc, TCHAR *argv[]) {
auto exit_code = EXIT_FAILURE;
try {
std::vector<std::basic_string<TCHAR>> args;
for (auto i = 0; i < argc; ++i) {
args.push_back(argv[i]);
}
if (AppMain(args)) {
exit_code = EXIT_SUCCESS;
}
} catch (std::exception &e) {
std::cout << e.what() << std::endl;
} catch (...) {
std::cout << "Unhandled exception occurred." << std::endl;
}
return exit_code;
}
// A main application loop
_Use_decl_annotations_ bool AppMain(
const std::vector<std::basic_string<TCHAR>> &args) {
if (args.size() == 1) {
std::cout << "Usage:\n"
<< " >this.exe <log_file_path>\n" << std::endl;
return false;
}
LogParser log_parser(args.at(1));
for (;;) {
std::this_thread::sleep_for(std::chrono::seconds(1));
log_parser.ParseFile();
}
}
| 23.291139 | 80 | 0.448913 |
tandasat
|
459d3fd808aba1dfd91a27a8763c89bd4d83aae4
| 61 |
hpp
|
C++
|
addons/interrogation/functions/script_component.hpp
|
kellerkompanie/kellerkompanie-mods
|
f15704710f77ba6c018c486d95cac4f7749d33b8
|
[
"MIT"
] | 6 |
2018-05-05T22:28:57.000Z
|
2019-07-06T08:46:51.000Z
|
addons/interrogation/functions/script_component.hpp
|
Schwaggot/kellerkompanie-mods
|
7a389e49e3675866dbde1b317a44892926976e9d
|
[
"MIT"
] | 107 |
2018-04-11T19:42:27.000Z
|
2019-09-13T19:05:31.000Z
|
addons/interrogation/functions/script_component.hpp
|
kellerkompanie/kellerkompanie-mods
|
f15704710f77ba6c018c486d95cac4f7749d33b8
|
[
"MIT"
] | 3 |
2018-10-03T11:54:46.000Z
|
2019-02-28T13:30:16.000Z
|
#include "\x\keko\addons\interrogation\script_component.hpp"
| 30.5 | 60 | 0.819672 |
kellerkompanie
|
45a0d5b4a59c688e301f8a5f78f412956f5d1494
| 1,603 |
cpp
|
C++
|
SystemResource/Source/Compression/ZLIB/ZLIBCompressionLevel.cpp
|
BitPaw/BitFireEngine
|
2c02a4eae19276bf60ac925e4393966cec605112
|
[
"MIT"
] | 5 |
2021-10-19T18:30:43.000Z
|
2022-03-19T22:02:02.000Z
|
SystemResource/Source/Compression/ZLIB/ZLIBCompressionLevel.cpp
|
BitPaw/BitFireEngine
|
2c02a4eae19276bf60ac925e4393966cec605112
|
[
"MIT"
] | 12 |
2022-03-09T13:40:21.000Z
|
2022-03-31T12:47:48.000Z
|
SystemResource/Source/Compression/ZLIB/ZLIBCompressionLevel.cpp
|
BitPaw/BitFireEngine
|
2c02a4eae19276bf60ac925e4393966cec605112
|
[
"MIT"
] | null | null | null |
#include "ZLIBCompressionLevel.h"
BF::ZLIBCompressionLevel BF::ConvertCompressionLevel(unsigned char compressionLevel)
{
switch (compressionLevel)
{
case 0u:
return BF::ZLIBCompressionLevel::Fastest;
case 1u:
return BF::ZLIBCompressionLevel::Fast;
case 2u:
return BF::ZLIBCompressionLevel::Default;
case 3u:
return BF::ZLIBCompressionLevel::Slowest;
default:
return BF::ZLIBCompressionLevel::InvalidCompressionLevel;
}
}
unsigned char BF::ConvertCompressionLevel(ZLIBCompressionLevel compressionLevel)
{
switch (compressionLevel)
{
default:
case BF::ZLIBCompressionLevel::InvalidCompressionLevel:
return -1;
case BF::ZLIBCompressionLevel::Default:
return 2u;
case BF::ZLIBCompressionLevel::Slowest:
return 3u;
case BF::ZLIBCompressionLevel::Fast:
return 1u;
case BF::ZLIBCompressionLevel::Fastest:
return 0u;
}
}
const char* BF::CompressionLevelToString(ZLIBCompressionLevel compressionLevel)
{
switch (compressionLevel)
{
default:
case BF::ZLIBCompressionLevel::InvalidCompressionLevel:
return "Invalid";
case BF::ZLIBCompressionLevel::Default:
return "Default";
case BF::ZLIBCompressionLevel::Slowest:
return "Slowest";
case BF::ZLIBCompressionLevel::Fast:
return "Fast";
case BF::ZLIBCompressionLevel::Fastest:
return "Fastest";
}
}
| 23.925373 | 84 | 0.625702 |
BitPaw
|
45a55d2ac83ad14f7d75e5bef293e0e05bf1b121
| 19 |
cpp
|
C++
|
src/Type.cpp
|
phiwen96/ph_image
|
282bdd835d721a561c4f3afcbb76af5f9bda87ba
|
[
"Apache-2.0"
] | 1 |
2021-09-05T08:38:39.000Z
|
2021-09-05T08:38:39.000Z
|
src/Type.cpp
|
phiwen96/ph_image
|
282bdd835d721a561c4f3afcbb76af5f9bda87ba
|
[
"Apache-2.0"
] | null | null | null |
src/Type.cpp
|
phiwen96/ph_image
|
282bdd835d721a561c4f3afcbb76af5f9bda87ba
|
[
"Apache-2.0"
] | 2 |
2021-12-04T14:39:52.000Z
|
2022-03-04T21:12:02.000Z
|
#include "Type.hpp"
| 19 | 19 | 0.736842 |
phiwen96
|
45b1eec24e6fbb6c79c985d3859420b22890719f
| 2,353 |
cpp
|
C++
|
Projects/Library/Source/Translator/Token.cpp
|
kalineh/KAI
|
43ab555bcbad1886715cd00b2cdac89e12d5cfe5
|
[
"MIT"
] | 1 |
2018-06-16T17:53:43.000Z
|
2018-06-16T17:53:43.000Z
|
Projects/Library/Source/Translator/Token.cpp
|
kalineh/KAI
|
43ab555bcbad1886715cd00b2cdac89e12d5cfe5
|
[
"MIT"
] | null | null | null |
Projects/Library/Source/Translator/Token.cpp
|
kalineh/KAI
|
43ab555bcbad1886715cd00b2cdac89e12d5cfe5
|
[
"MIT"
] | null | null | null |
#include "KAI/KAI.h"
#include "KAI/Translator/Token.h"
#include "KAI/Translator/Lexer.h"
KAI_BEGIN
Token::Token(Type type, const Lexer &lexer, int ln, Slice slice)
: type(type), lexer(&lexer), lineNumber(ln), slice(slice)
{
}
char Token::operator[](int n) const
{
return lexer->input[slice.Start + n];
}
std::string Token::Text() const
{
if (lexer == 0)
return "";
return std::move(lexer->lines[lineNumber].substr(slice.Start, slice.Length()));
}
const char * Token::ToString(Type t)
{
switch (t)
{
case None: return "None";
case Whitespace: return "";
case Semi: return "Semi";
case Int: return "Int";
case Float: return "Float";
case String: return "String";
case Ident: return "Ident";
case Dot: return "Dot";
case If: return "If";
case Else: return "Else";
case For: return "For";
case While: return "While";
case OpenParan: return "OpenParan";
case CloseParan: return "CloseParan";
case Plus: return "Plus";
case Minus: return "Minus";
case Mul: return "Mul";
case Divide: return "Divide";
case Assign: return "Assign";
case Less: return "Less";
case Equiv: return "Equiv";
case Greater: return "Greater";
case LessEquiv: return "LessEquiv";
case GreaterEquiv: return "GreaterEqiv";
case Return: return "Return";
case OpenBrace: return "OpenBrace";
case CloseBrace: return "CloseBrace";
case Not: return "Not";
case NotEquiv: return "NotEquiv";
case And: return "And";
case Or: return "Or";
case Comma: return "Comma";
case OpenSquareBracket: return "OpenSquareBracket";
case CloseSquareBracket: return "CloseSquareBracket";
case Increment: return "++";
case Decrement: return "--";
case Self: return "Self";
case Lookup: return "Lookup";
case Fun: return "Fun";
case Tab: return "Tab";
case NewLine: return "NewLine";
case Comment: return "Comment";
case PlusAssign: return "PlusAssign";
case MinusAssign: return "MinusAssign";
case MulAssign: return "MulAssign";
case DivAssign: return "DivAssign";
case Yield: return "Yield";
}
static char b[100];
_itoa_s(t, b, 100, 10);
return b;
}
std::ostream &operator<<(std::ostream &out, Token const &node)
{
if (node.type == Token::None)
return out;
out << Token::ToString(node.type);
switch (node.type)
{
case Token::Int:
case Token::String:
case Token::Ident:
out << "=" << node.Text();
}
return out;
}
KAI_END
| 23.29703 | 80 | 0.686783 |
kalineh
|
45b5656d99ec73a5687a9c57e0255033950efb59
| 863 |
hpp
|
C++
|
HexDumper.hpp
|
jancarlsson/snarkfront
|
7f90a4181721f758f114497382aa462185e71dae
|
[
"MIT"
] | 60 |
2015-01-02T12:28:40.000Z
|
2021-04-13T01:40:07.000Z
|
HexDumper.hpp
|
artree222/snarkfront
|
7f90a4181721f758f114497382aa462185e71dae
|
[
"MIT"
] | 8 |
2015-03-05T13:12:39.000Z
|
2018-07-03T07:17:45.000Z
|
HexDumper.hpp
|
artree222/snarkfront
|
7f90a4181721f758f114497382aa462185e71dae
|
[
"MIT"
] | 17 |
2015-01-22T03:10:49.000Z
|
2020-12-27T12:22:17.000Z
|
#ifndef _SNARKFRONT_HEX_DUMPER_HPP_
#define _SNARKFRONT_HEX_DUMPER_HPP_
#include <cstdint>
#include <istream>
#include <ostream>
#include <vector>
#include <cryptl/ASCII_Hex.hpp>
#include <cryptl/DataPusher.hpp>
namespace snarkfront {
////////////////////////////////////////////////////////////////////////////////
// print messages in hexdump format
//
class HexDumper
{
public:
HexDumper(std::ostream&);
void print(const std::vector<std::uint8_t>&);
void print(std::istream&);
private:
// print as text characters
class PrintText
{
public:
PrintText(std::ostream&);
void pushOctet(const std::uint8_t);
private:
std::ostream& m_os;
};
cryptl::DataPusher<cryptl::PrintHex<true>> m_hex;
cryptl::DataPusher<PrintText> m_text;
std::ostream& m_os;
};
} // namespace snarkfront
#endif
| 19.177778 | 80 | 0.618772 |
jancarlsson
|
45b6bb571b5dcd870ad59efbb29989e5fc5dfa59
| 1,278 |
hpp
|
C++
|
Siv3D/include/Siv3D/Base64.hpp
|
Fuyutsubaki/OpenSiv3D
|
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
|
[
"MIT"
] | 1 |
2018-05-23T10:57:32.000Z
|
2018-05-23T10:57:32.000Z
|
Siv3D/include/Siv3D/Base64.hpp
|
Fuyutsubaki/OpenSiv3D
|
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
|
[
"MIT"
] | null | null | null |
Siv3D/include/Siv3D/Base64.hpp
|
Fuyutsubaki/OpenSiv3D
|
4370f6ebe28addd39bfdd75915c5a18e3e5e9273
|
[
"MIT"
] | 1 |
2019-10-06T17:09:26.000Z
|
2019-10-06T17:09:26.000Z
|
//-----------------------------------------------
//
// This file is part of the Siv3D Engine.
//
// Copyright (c) 2008-2018 Ryo Suzuki
// Copyright (c) 2016-2018 OpenSiv3D Project
//
// Licensed under the MIT License.
//
//-----------------------------------------------
# pragma once
# include "Fwd.hpp"
namespace s3d
{
/// <summary>
/// Base64
/// </summary>
/// <remarks>
/// Base64 エンコード/デコードの機能を提供します。
/// </remarks>
namespace Base64
{
/// <summary>
/// データを Base64 エンコードします。
/// </summary>
/// <param name="data">
/// エンコードするデータの先頭ポインタ
/// </param>
/// <param name="size">
/// エンコードするデータのサイズ(バイト)
/// </param>
/// <returns>
/// エンコードされたテキストデータ、エンコードに失敗した場合空の文字列
/// </returns>
[[nodiscard]] String Encode(const void* data, size_t size);
/// <summary>
/// データを Base64 エンコードします。
/// </summary>
/// <param name="view">
/// エンコードするデータ
/// </param>
/// <returns>
/// エンコードされたテキストデータ、エンコードに失敗した場合空の文字列
/// </returns>
[[nodiscard]] String Encode(ByteArrayView view);
/// <summary>
/// テキストを Base64 でデコードします。
/// </summary>
/// <param name="view">
/// デコードするテキスト
/// </param>
/// <returns>
/// デコードされたバイナリデータ、デコードに失敗した場合空のバイナリデータ
/// </returns>
[[nodiscard]] ByteArray Decode(StringView view);
};
}
| 20.612903 | 61 | 0.553991 |
Fuyutsubaki
|
45c1f7f43093cf219183eba6c6043dbd56ca7db3
| 1,532 |
cpp
|
C++
|
CWin/CWin/events/event_trigger_condition.cpp
|
benbraide/CWin
|
0441b48a71fef0dbddabf61033d7286669772c1e
|
[
"MIT"
] | null | null | null |
CWin/CWin/events/event_trigger_condition.cpp
|
benbraide/CWin
|
0441b48a71fef0dbddabf61033d7286669772c1e
|
[
"MIT"
] | null | null | null |
CWin/CWin/events/event_trigger_condition.cpp
|
benbraide/CWin
|
0441b48a71fef0dbddabf61033d7286669772c1e
|
[
"MIT"
] | null | null | null |
#include "event_trigger_condition.h"
cwin::events::trigger_condition::~trigger_condition() = default;
cwin::events::trigger_condition::operator m_callback_type() const{
return get();
}
cwin::events::trigger_condition::m_callback_type cwin::events::trigger_condition::get() const{
return nullptr;
}
cwin::events::external_trigger_condition::external_trigger_condition(const m_callback_type &value)
: value_(value){}
cwin::events::external_trigger_condition::~external_trigger_condition() = default;
cwin::events::trigger_condition::m_callback_type cwin::events::external_trigger_condition::get() const{
return value_;
}
cwin::events::odd_count_trigger_condition::~odd_count_trigger_condition() = default;
cwin::events::trigger_condition::m_callback_type cwin::events::odd_count_trigger_condition::get() const{
return [](std::size_t count){
return ((count % 2u) == 1u);
};
}
cwin::events::even_count_trigger_condition::~even_count_trigger_condition() = default;
cwin::events::trigger_condition::m_callback_type cwin::events::even_count_trigger_condition::get() const{
return [](std::size_t count){
return ((count % 2u) == 0u);
};
}
cwin::events::max_count_trigger_condition::max_count_trigger_condition(std::size_t value)
: value_(value){}
cwin::events::max_count_trigger_condition::~max_count_trigger_condition() = default;
cwin::events::trigger_condition::m_callback_type cwin::events::max_count_trigger_condition::get() const{
return [value = value_](std::size_t count){
return (count <= value);
};
}
| 31.916667 | 105 | 0.772846 |
benbraide
|
45c4ff283f1bd510f5089c454c2a348f353c0a08
| 3,347 |
cpp
|
C++
|
12_TIM1_PWM_input/main.cpp
|
AVilezhaninov/STM32F429VG
|
cb77fb53235ffd4cdf000749e4857108bc96c2cb
|
[
"MIT"
] | null | null | null |
12_TIM1_PWM_input/main.cpp
|
AVilezhaninov/STM32F429VG
|
cb77fb53235ffd4cdf000749e4857108bc96c2cb
|
[
"MIT"
] | null | null | null |
12_TIM1_PWM_input/main.cpp
|
AVilezhaninov/STM32F429VG
|
cb77fb53235ffd4cdf000749e4857108bc96c2cb
|
[
"MIT"
] | null | null | null |
/* CMSIS */
#include "CMSIS\Device\stm32f4xx.h"
/* User */
#include "user\RCC.h"
/******************************************************************************/
/* Private definitions ********************************************************/
/******************************************************************************/
#define TIM1_PSC 0u /* TIM1 clock: (180 MHz / 1) = 180 MHz */
#define TIM1_ARR 65535u /* TIM1 maximum clock value */
#define TIM1_IRQ_PRIORITY 5u
/******************************************************************************/
/* Private function prototypes ************************************************/
/******************************************************************************/
static void InitTim1();
/******************************************************************************/
/* Interrupts *****************************************************************/
/******************************************************************************/
extern "C" {
/**
* TIM1 capture compare interrupt handler
*/
void TIM1_CC_IRQHandler() {
uint16_t period;
uint16_t width;
if ((TIM1->SR & TIM_SR_CC2IF) == TIM_SR_CC2IF) {
period = TIM1->CCR2; /* Get pulse period */
width = TIM1->CCR1; /* Get pulse width */
}
TIM1->SR &= ~TIM_SR_CC1OF; /* Clear overcapture 1 flag */
TIM1->SR &= ~TIM_SR_CC2OF; /* Clear overcapture 2 flag */
}
} /* extern "C" */
/******************************************************************************/
/* Main ***********************************************************************/
/******************************************************************************/
int main(void) {
InitSystemClock();
InitTim1();
while (1) {
;
}
}
/******************************************************************************/
/* Private functions **********************************************************/
/******************************************************************************/
void InitTim1() {
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN; /* Enable PORTE clock */
GPIOE->MODER |= GPIO_MODER_MODER11_1; /* PE11 alternate mode */
GPIOE->AFR[1u] |= (1u << 12u); /* PE11 in AF1 */
RCC->APB2ENR |= RCC_APB2ENR_TIM1EN; /* Enable TIM1 clock */
TIM1->PSC = TIM1_PSC; /* Set TIM1 prescaler */
TIM1->ARR = TIM1_ARR; /* Set TIM1 auto reload value */
TIM1->CCMR1 |= TIM_CCMR1_CC1S_1; /* IC1 mapped on TI2 */
TIM1->CCER |= TIM_CCER_CC1P; /* Falling edge on TI1 */
TIM1->CCMR1 |= TIM_CCMR1_CC2S_0; /* IC2 mapped on TI1 */
TIM1->SMCR |= TIM_SMCR_TS_2 | TIM_SMCR_TS_1; /* Filtered timer input 2 */
TIM1->SMCR |= TIM_SMCR_SMS_2; /* "Reset" slave mode */
TIM1->DIER |= TIM_DIER_CC2IE; /* Capture 2 interrupt enable */
TIM1->CCER |= TIM_CCER_CC2E; /* Caputre 2 output enbale */
TIM1->CCER |= TIM_CCER_CC1E; /* Caputre 1 output enbale */
NVIC_SetPriority(TIM1_CC_IRQn, TIM1_IRQ_PRIORITY); /* Set TIM1 interrupt
* priority */
NVIC_EnableIRQ(TIM1_CC_IRQn); /* Enable TIM1 capture interrupt */
TIM1->CR1 |= TIM_CR1_CEN; /* Enable TIM1 timer */
}
| 42.367089 | 80 | 0.380042 |
AVilezhaninov
|
45c88d8e96e32d7e9ca06903b231e840b90406f2
| 836 |
cxx
|
C++
|
src/engine/ivp/ivp_collision/ivp_clustering_lrange_hash.cxx
|
cstom4994/SourceEngineRebuild
|
edfd7f8ce8af13e9d23586318350319a2e193c08
|
[
"MIT"
] | 6 |
2022-01-23T09:40:33.000Z
|
2022-03-20T20:53:25.000Z
|
src/engine/ivp/ivp_collision/ivp_clustering_lrange_hash.cxx
|
cstom4994/SourceEngineRebuild
|
edfd7f8ce8af13e9d23586318350319a2e193c08
|
[
"MIT"
] | null | null | null |
src/engine/ivp/ivp_collision/ivp_clustering_lrange_hash.cxx
|
cstom4994/SourceEngineRebuild
|
edfd7f8ce8af13e9d23586318350319a2e193c08
|
[
"MIT"
] | 1 |
2022-02-06T21:05:23.000Z
|
2022-02-06T21:05:23.000Z
|
// Copyright (C) Ipion Software GmbH 1999-2000. All rights reserved.
#include <ivp_physics.hxx>
#include <ivu_vhash.hxx>
#include <ivp_clustering_longrange.hxx>
#include <ivp_clustering_lrange_hash.hxx>
IVP_ov_tree_hash::~IVP_ov_tree_hash() { ; }
int IVP_ov_tree_hash::node_to_index(IVP_OV_Node *node) {
return hash_index((char *) &node->data, sizeof(node->data));
}
IVP_BOOL IVP_ov_tree_hash::compare(void *elem0, void *elem1) const {
IVP_OV_Node *node0 = (IVP_OV_Node *) elem0;
IVP_OV_Node *node1 = (IVP_OV_Node *) elem1;
if (node0->data.rasterlevel != node1->data.rasterlevel) return (IVP_FALSE);
if (node0->data.x != node1->data.x) return (IVP_FALSE);
if (node0->data.y != node1->data.y) return (IVP_FALSE);
if (node0->data.z != node1->data.z) return (IVP_FALSE);
return (IVP_TRUE);
}
| 24.588235 | 79 | 0.697368 |
cstom4994
|
68f869732418d1de819ccec3d477502ec2a8e751
| 2,715 |
cpp
|
C++
|
vkconfig/widget_preset.cpp
|
johnzupin/VulkanTools
|
4a4d824b43984d29902f7c8246aab99f0909151d
|
[
"Apache-2.0"
] | null | null | null |
vkconfig/widget_preset.cpp
|
johnzupin/VulkanTools
|
4a4d824b43984d29902f7c8246aab99f0909151d
|
[
"Apache-2.0"
] | null | null | null |
vkconfig/widget_preset.cpp
|
johnzupin/VulkanTools
|
4a4d824b43984d29902f7c8246aab99f0909151d
|
[
"Apache-2.0"
] | null | null | null |
/*
* Copyright (c) 2020 Valve Corporation
* Copyright (c) 2020 LunarG, Inc.
*
* 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.
*
* Authors:
* - Christophe Riccio <[email protected]>
*/
#include "widget_preset.h"
#include <cassert>
PresetWidget::PresetWidget(QTreeWidgetItem* item, const Layer& layer, Parameter& parameter) : layer(layer), parameter(parameter) {
assert(item);
assert(&layer);
assert(¶meter);
this->blockSignals(true);
this->addItem("User Defined Settings");
preset_indexes.push_back(Layer::NO_PRESET);
for (std::size_t i = 0, n = layer.presets.size(); i < n; ++i) {
const LayerPreset& layer_preset = layer.presets[i];
if (!(layer_preset.platform_flags & (1 << VKC_PLATFORM))) {
continue;
}
this->addItem((layer_preset.label + " Preset").c_str());
preset_indexes.push_back(layer_preset.preset_index);
}
this->blockSignals(false);
this->UpdateCurrentIndex();
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(OnPresetChanged(int)));
}
void PresetWidget::UpdateCurrentIndex() {
int preset_index = layer.FindPresetIndex(parameter.settings);
this->blockSignals(true);
this->setCurrentIndex(GetComboBoxIndex(preset_index));
this->blockSignals(false);
if (preset_index == Layer::NO_PRESET) return;
const LayerPreset* preset = GetPreset(layer.presets, preset_index);
assert(preset != nullptr);
this->setToolTip(preset->description.c_str());
}
int PresetWidget::GetComboBoxIndex(const int preset_index) const {
for (std::size_t i = 0, n = preset_indexes.size(); i < n; ++i) {
if (preset_indexes[i] == preset_index) return static_cast<int>(i);
}
assert(0);
return -1;
}
void PresetWidget::OnPresetChanged(int combox_preset_index) {
assert(combox_preset_index >= 0 && static_cast<std::size_t>(combox_preset_index) < preset_indexes.size());
const int preset_index = preset_indexes[combox_preset_index];
if (preset_index == Layer::NO_PRESET) return;
const LayerPreset* preset = GetPreset(layer.presets, preset_index);
assert(preset != nullptr);
parameter.ApplyPresetSettings(*preset);
}
| 31.569767 | 130 | 0.698343 |
johnzupin
|
68ff22d8df3673d6303576f88fc3fa40888fd4de
| 1,947 |
cpp
|
C++
|
network/src/network/loopPrivate.cpp
|
yandaomin/network
|
fd88844116d77639c7a76ec61fb352f2710f47a8
|
[
"Apache-2.0"
] | null | null | null |
network/src/network/loopPrivate.cpp
|
yandaomin/network
|
fd88844116d77639c7a76ec61fb352f2710f47a8
|
[
"Apache-2.0"
] | null | null | null |
network/src/network/loopPrivate.cpp
|
yandaomin/network
|
fd88844116d77639c7a76ec61fb352f2710f47a8
|
[
"Apache-2.0"
] | null | null | null |
#include "loopPrivate.h"
#include "async.h"
#include "loop.h"
// LoopPrivate::LoopPrivate()
// : LoopPrivate(false)
// {
// isRunning_ = false;
// }
LoopPrivate::LoopPrivate(bool isDefault) {
isRunning_ = false;
if (isDefault) {
loop_ = uv_default_loop();
}
else {
loop_ = new uv_loop_t();
::uv_loop_init(loop_);
}
}
LoopPrivate::~LoopPrivate() {
if (!isDefaultLoop()) {
uv_loop_close(loop_);
delete async_;
delete loop_;
}
}
// LoopPrivate* LoopPrivate::defaultLoop() {
// static LoopPrivate defaultLoop(true);
// return &defaultLoop;
// }
uv_loop_t* LoopPrivate::handle() {
return loop_;
}
bool LoopPrivate::isDefaultLoop() {
return (loop_ == uv_default_loop());
}
void LoopPrivate::init()
{
async_ = new Async((Loop*)parent_);
}
int LoopPrivate::run() {
if (!isRunning_) {
async_->init();
threadId_ = std::this_thread::get_id();
isRunning_ = true;
auto rlt = ::uv_run(loop_, UV_RUN_DEFAULT);
isRunning_ = false;
return rlt;
}
return -1;
}
int LoopPrivate::runNoWait(){
if (!isRunning_) {
async_->init();
threadId_ = std::this_thread::get_id();
isRunning_ = true;
auto rst = ::uv_run(loop_, UV_RUN_NOWAIT);
isRunning_ = false;
return rst;
}
return -1;
}
int LoopPrivate::stop() {
if (isRunning_){
async_->close([](Async* ptr)
{
::uv_stop((uv_loop_t*)(ptr->loop()->handle()));
});
return 0;
}
return -1;
}
bool LoopPrivate::isRunning() {
return isRunning_;
}
bool LoopPrivate::isSameThread() {
return std::this_thread::get_id() == threadId_;
}
void LoopPrivate::runInLoop(const ActionCallback func) {
if (nullptr == func)
return;
if (isSameThread() || !isRunning()) {
func();
return;
}
async_->run(func);
}
std::string LoopPrivate::getErrorMessage(int status) {
if (WriteResult::result_disconnected == status)
return "the connection is closed";
const char* msg = uv_strerror(status);
std::string errMsg(msg);
//delete[] msg;
return errMsg;
}
| 17.7 | 56 | 0.662044 |
yandaomin
|
ec087b40fc0aeb9bb7862421ed3d0a0427b72406
| 170 |
hpp
|
C++
|
dfg/dataAnalysisAll.hpp
|
tc3t/dfglib
|
7157973e952234a010da8e9fbd551a912c146368
|
[
"MIT",
"BSL-1.0",
"BSD-3-Clause"
] | 1 |
2017-08-01T04:42:29.000Z
|
2017-08-01T04:42:29.000Z
|
dfg/dataAnalysisAll.hpp
|
tc3t/dfglib
|
7157973e952234a010da8e9fbd551a912c146368
|
[
"MIT",
"BSL-1.0",
"BSD-3-Clause"
] | 128 |
2018-04-06T23:01:51.000Z
|
2022-03-31T20:19:38.000Z
|
dfg/dataAnalysisAll.hpp
|
tc3t/dfglib
|
7157973e952234a010da8e9fbd551a912c146368
|
[
"MIT",
"BSL-1.0",
"BSD-3-Clause"
] | 3 |
2018-03-21T01:11:05.000Z
|
2021-04-05T19:20:31.000Z
|
#pragma once
#include "dataAnalysis/correlation.hpp"
#include "dataAnalysis/smoothWithNeighbourAverages.hpp"
#include "dataAnalysis/smoothWithNeighbourMedians.hpp"
| 28.333333 | 56 | 0.823529 |
tc3t
|
ec0eef56d74c1c6cc4dae12c44f81b1e0cf72c91
| 689 |
cpp
|
C++
|
benchmarks/clean_shared_memory.cpp
|
MaximilienNaveau/shared_memory
|
1440454759cdd19e0d898753d86b8714c1aefa84
|
[
"BSD-3-Clause"
] | 2 |
2020-09-08T04:01:02.000Z
|
2021-01-28T15:02:11.000Z
|
benchmarks/clean_shared_memory.cpp
|
MaximilienNaveau/shared_memory
|
1440454759cdd19e0d898753d86b8714c1aefa84
|
[
"BSD-3-Clause"
] | 13 |
2019-09-24T17:21:49.000Z
|
2021-03-02T10:09:03.000Z
|
benchmarks/clean_shared_memory.cpp
|
MaximilienNaveau/shared_memory
|
1440454759cdd19e0d898753d86b8714c1aefa84
|
[
"BSD-3-Clause"
] | 2 |
2019-05-06T08:25:35.000Z
|
2020-04-14T11:49:02.000Z
|
/**
* @file clean_shared_memory.cpp
* @author Vincent Berenz
* @license License BSD-3-Clause
* @copyright Copyright (c) 2019, New York University and Max Planck
* Gesellschaft.
* @date 2019-05-22
*
* @brief Clean the shared memory of the benchmark, the unnittests, ...
*/
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
#include "shared_memory/benchmarks/benchmark_common.hh"
int main()
{
boost::interprocess::named_mutex::remove(SHM_NAME.c_str());
boost::interprocess::shared_memory_object::remove(SHM_OBJECT_NAME.c_str());
boost::interprocess::shared_memory_object::remove("main_memory");
return 0;
}
| 29.956522 | 79 | 0.744557 |
MaximilienNaveau
|
ec1f214e9a1c35cd7ee04a0109985f1a428a2937
| 2,473 |
hpp
|
C++
|
third-party/Empirical/include/emp/io/ascii_utils.hpp
|
koellingh/empirical-p53-simulator
|
aa6232f661e8fc65852ab6d3e809339557af521b
|
[
"MIT"
] | null | null | null |
third-party/Empirical/include/emp/io/ascii_utils.hpp
|
koellingh/empirical-p53-simulator
|
aa6232f661e8fc65852ab6d3e809339557af521b
|
[
"MIT"
] | null | null | null |
third-party/Empirical/include/emp/io/ascii_utils.hpp
|
koellingh/empirical-p53-simulator
|
aa6232f661e8fc65852ab6d3e809339557af521b
|
[
"MIT"
] | null | null | null |
/**
* @note This file is part of Empirical, https://github.com/devosoft/Empirical
* @copyright Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
* @date 2020
*
* @file ascii_utils.hpp
* @brief Tools for working with ascii output.
* @note Status: ALPHA
*
*/
#ifndef EMP_ASCII_UTILS_H
#define EMP_ASCII_UTILS_H
#include <iostream>
#include <ostream>
#include "../base/assert.hpp"
#include "../base/vector.hpp"
#include "../datastructs/vector_utils.hpp"
namespace emp {
/// The following function prints an ascii bar graph on to the screen (or provided stream).
template <typename T>
void AsciiBarGraph( emp::vector<T> data,
size_t max_width=80, ///< What's the widest bars allowed?
bool show_scale=true, ///< Should we show the scale at bottom.
bool max_scale_1=true, ///< Should we limit scaling to 1:1?
std::ostream & os=std::cout) ///< Where to output the bar graph?
{
T min_size = emp::FindMin(data);
T max_size = emp::FindMax(data);
double scale = ((double) max_width) / ((double) max_size);
if (max_scale_1 && scale > 1.0) scale = 1.0;
for (T datum : data) {
double bar_width = datum * scale;
while (bar_width >= 1.0) { os << '='; bar_width -= 1.0; }
if (bar_width > 0.0) os << '~';
os << " (" << datum << ")\n";
}
if (show_scale) {
os << "SCALE: = -> " << (1.0 / scale) << std::endl;
}
}
/// Take the input data, break it into bins, and print it as a bar graph.
template <typename T>
void AsciiHistogram(emp::vector<T> data,
size_t num_bins=40, ///< How many bins in histogram?
size_t max_width=80, ///< What's the widest bars allowed?
bool show_scale=true, ///< Should we show the scale at bottom?
std::ostream & os=std::cout) ///< Where to output the bar graph?
{
T min_val = emp::FindMin(data);
T max_val = emp::FindMax(data);
T val_range = max_val - min_val;
T bin_width = val_range / (T) num_bins;
emp::vector<size_t> bins(num_bins, 0);
for (T d : data) {
size_t bin_id = (size_t) ( (d - min_val) / bin_width );
if (bin_id == num_bins) bin_id--;
bins[bin_id]++;
}
AsciiBarGraph<size_t>(bins, max_width, show_scale, true, os);
}
}
#endif
| 33.418919 | 96 | 0.57501 |
koellingh
|
ec29a544d9100b3387e11d9bc03102fb43674314
| 329 |
hh
|
C++
|
src/UsageEnvironment/include/UsageEnvironment_version.hh
|
RayanWang/Live555
|
3a8b2998e5872326e4edb96e6e7dc46dc1d16af4
|
[
"MIT"
] | 5 |
2018-04-09T02:03:33.000Z
|
2022-03-26T16:17:52.000Z
|
src/UsageEnvironment/include/UsageEnvironment_version.hh
|
RayanWang/Live555
|
3a8b2998e5872326e4edb96e6e7dc46dc1d16af4
|
[
"MIT"
] | null | null | null |
src/UsageEnvironment/include/UsageEnvironment_version.hh
|
RayanWang/Live555
|
3a8b2998e5872326e4edb96e6e7dc46dc1d16af4
|
[
"MIT"
] | null | null | null |
// Version information for the "UsageEnvironment" library
// Copyright (c) 1996-2014 Live Networks, Inc. All rights reserved.
#ifndef _USAGEENVIRONMENT_VERSION_HH
#define _USAGEENVIRONMENT_VERSION_HH
#define USAGEENVIRONMENT_LIBRARY_VERSION_STRING "2014.12.17"
#define USAGEENVIRONMENT_LIBRARY_VERSION_INT 1418774400
#endif
| 29.909091 | 68 | 0.835866 |
RayanWang
|
ec2bc096ac8d02bf32f1e3d46ed2a7005d6d0383
| 3,663 |
cpp
|
C++
|
Builds/vs2013/Task2/unittest1.cpp
|
AJ-Moore/AIStates
|
b2bc31d7d3cbec25b4efacbe9ae6c9940e8e68e4
|
[
"MIT"
] | null | null | null |
Builds/vs2013/Task2/unittest1.cpp
|
AJ-Moore/AIStates
|
b2bc31d7d3cbec25b4efacbe9ae6c9940e8e68e4
|
[
"MIT"
] | null | null | null |
Builds/vs2013/Task2/unittest1.cpp
|
AJ-Moore/AIStates
|
b2bc31d7d3cbec25b4efacbe9ae6c9940e8e68e4
|
[
"MIT"
] | null | null | null |
#include "stdafx.h"
#include "CppUnitTest.h"
#include <AI.h>
#include <FSM.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace Task2
{
TEST_CLASS(UnitTest1)
{
public:
//Test that the AI Starting State is Idle
TEST_METHOD(StartState)
{
AI ai(false, 0, 0);
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Idle);
}
//Check Idle to Observe Transition.
TEST_METHOD(IdleToObserve)
{
//create the AI -> Sets Can See Player to true
AI ai(true, 0, 0);
//check that the current state is in idle
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Idle);
//check after the update that the state has changed to Observe
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Observe);
}
//Checks the transition between the Observe and Idle states.
TEST_METHOD(ObserveToIdle)
{
AI ai(true, 0, 0);
ai.update();
ai.canSeePlayer = false;
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Idle);
}
//Observe to Combat Test
TEST_METHOD(ObserveToCombat){
AI ai(true, 70, 0);
ai.update();//state should now be observe.
ai.update();//state should still be observe.
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Observe);
//change health to 71 and ammo to 1
ai.health = 71;
ai.ammunition = 1;
ai.update();//state should now be combat
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Combat);
}
//Combat to Retreat Test.
TEST_METHOD(CombatToRetreat){
AI ai(true, 71, 1);
ai.update();//state should now be observe.
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Observe);
ai.update();//state should now be combat
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Combat);
ai.ammunition = 0;
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Retreat);
}
//Combat to Retreat Test.
TEST_METHOD(CombatToDead){
AI ai(true, 71, 1);
ai.update();//state should now be observe.
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Observe);
ai.update();//state should now be combat
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Combat);
ai.health = 0;
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Dead);
}
//Combat to Retreat Test.
TEST_METHOD(RetreatToDead){
AI ai(true, 71, 1);
ai.update();//state should now be observe.
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Observe);
ai.update();//state should now be combat
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Combat);
ai.ammunition = 0;
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Retreat);
ai.health = 0;
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Dead);
}
TEST_METHOD(RetreatToIdle){
AI ai(true, 71, 1);
ai.update();//state should now be observe.
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Observe);
ai.update();//state should now be combat
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Combat);
ai.ammunition = 0;
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Retreat);
ai.canSeePlayer = false;
ai.update();
Assert::AreEqual((int)ai.fsm->getCurrentState()->state, (int)AIStates::Idle);
}
};
}
| 31.577586 | 83 | 0.670762 |
AJ-Moore
|
ec2c9e529ef42d3a903fcae5273beb2dec55545d
| 276 |
cpp
|
C++
|
Char.cpp
|
RafelNunes/ifsc-programacao
|
40622fb1a5496e09f4800220e293385468fef323
|
[
"MIT"
] | null | null | null |
Char.cpp
|
RafelNunes/ifsc-programacao
|
40622fb1a5496e09f4800220e293385468fef323
|
[
"MIT"
] | null | null | null |
Char.cpp
|
RafelNunes/ifsc-programacao
|
40622fb1a5496e09f4800220e293385468fef323
|
[
"MIT"
] | null | null | null |
#include<stdio.h>
#include<stdlib.h>
int main(void){
char letra1, letra2;
printf("Digite um caracter: ");
scanf("%c", &letra1);
while(letra1 != 'X')
{printf("Digite um caracter: ");
scanf(" %c", &letra1);
}
printf("Letra1: %c Letra2: %c\n", letra1, letra2);
}
| 16.235294 | 51 | 0.605072 |
RafelNunes
|
ec2ec73f474fa18945883ea8e2f68b90c16505c2
| 1,645 |
hpp
|
C++
|
libcaf_net/caf/net/http/v1.hpp
|
seewpx/actor-framework
|
65ecf35317b81d7a211848d59e734f43483fe410
|
[
"BSD-3-Clause"
] | null | null | null |
libcaf_net/caf/net/http/v1.hpp
|
seewpx/actor-framework
|
65ecf35317b81d7a211848d59e734f43483fe410
|
[
"BSD-3-Clause"
] | null | null | null |
libcaf_net/caf/net/http/v1.hpp
|
seewpx/actor-framework
|
65ecf35317b81d7a211848d59e734f43483fe410
|
[
"BSD-3-Clause"
] | null | null | null |
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/byte_span.hpp"
#include "caf/detail/net_export.hpp"
#include "caf/net/http/header_fields_map.hpp"
#include "caf/net/http/status.hpp"
#include <string_view>
#include <utility>
namespace caf::net::http::v1 {
/// Tries splitting the given byte span into an HTTP header (`first`) and a
/// remainder (`second`). Returns an empty `string_view` as `first` for
/// incomplete HTTP headers.
CAF_NET_EXPORT std::pair<std::string_view, byte_span>
split_header(byte_span bytes);
/// Writes an HTTP header to the buffer.
CAF_NET_EXPORT void write_header(status code, const header_fields_map& fields,
byte_buffer& buf);
/// Writes a complete HTTP response to the buffer. Automatically sets
/// Content-Type and Content-Length header fields.
CAF_NET_EXPORT void write_response(status code, std::string_view content_type,
std::string_view content, byte_buffer& buf);
/// Writes a complete HTTP response to the buffer. Automatically sets
/// Content-Type and Content-Length header fields followed by the user-defined
/// @p fields.
CAF_NET_EXPORT void write_response(status code, std::string_view content_type,
std::string_view content,
const header_fields_map& fields,
byte_buffer& buf);
} // namespace caf::net::http::v1
| 40.121951 | 79 | 0.68997 |
seewpx
|
ec349105626f6ef1b4acc73abbf21be54516c61e
| 4,545 |
cpp
|
C++
|
LaalMathEngine/src/Shape/SvgShape.cpp
|
vijayshankarkumar/LME
|
6483d893a8902cec4959936220656fcab2b72d4f
|
[
"MIT"
] | 1 |
2022-02-18T10:38:42.000Z
|
2022-02-18T10:38:42.000Z
|
LaalMathEngine/src/Shape/SvgShape.cpp
|
vijayshankarkumar/LME
|
6483d893a8902cec4959936220656fcab2b72d4f
|
[
"MIT"
] | 1 |
2021-09-03T21:20:38.000Z
|
2021-09-03T21:20:38.000Z
|
LaalMathEngine/src/Shape/SvgShape.cpp
|
vijayshankarkumar/LME
|
6483d893a8902cec4959936220656fcab2b72d4f
|
[
"MIT"
] | null | null | null |
#include "Shape/SvgShape.h"
namespace laal
{
SvgShape::SvgShape()
{
}
SvgShape::SvgShape(const std::string& fileName)
{
InitChildShapes(fileName);
}
SvgShape::~SvgShape()
{
for (Shape* shape : m_ChildShapes)
{
delete shape;
}
}
void SvgShape::InitChildShapes(const std::string& fileName)
{
NSVGimage* image;
image = nsvgParseFromFile(fileName.c_str(), "px", 96);
//std::cout << "after the image init..." << std::endl;
for (NSVGshape* shape = image->shapes; shape != NULL; shape = shape->next) {
//std::cout << "In ther loop..." << std::endl;
Shape* childShape = new Shape();
SetFillStyle(shape, childShape);
SetStrokeStyle(shape, childShape);
SetPath(shape, childShape);
Add(childShape);
}
nsvgDelete(image);
}
void SvgShape::SetFillStyle(NSVGshape* fromShape, Shape* toShape)
{
Style fillStyle;
switch (fromShape->fill.type)
{
case NSVG_PAINT_NONE:
fillStyle.StyleType(STYLE_NONE);
break;
case NSVG_PAINT_COLOR:
{
unsigned int color = fromShape->fill.color;
double r = (double)(color & 255) / 255.0;
color >>= 8;
double g = (double)(color & 255) / 255.0;
color >>= 8;
double b = (double)(color & 255) / 255.0;
color >>= 8;
double a = (double)(color) / 255.0;
fillStyle.SetColor(Color(r, g, b, a));
//std::cout << "fill color => " << r << " " << g << " " << b << " " << a << std::endl;
break;
}
case NSVG_PAINT_LINEAR_GRADIENT:
break;
case NSVG_PAINT_RADIAL_GRADIENT:
break;
default:
break;
}
switch (fromShape->fillRule)
{
case NSVG_FILLRULE_EVENODD:
fillStyle.FillRule(FILL_RULE_EVENODD);
break;
case NSVG_FILLRULE_NONZERO:
fillStyle.FillRule(FILL_RULE_NONEZERO);
break;
default:
break;
}
fillStyle.Opacity(fromShape->opacity);
toShape->SetFillStyle(fillStyle);
}
void SvgShape::SetStrokeStyle(NSVGshape* fromShape, Shape* toShape)
{
/*switch (fromShape->stroke.type)
{
case NSVG_PAINT_NONE:
toShape->FillType(FILL_NONE);
break;
case NSVG_PAINT_COLOR:
toShape->StrokeColor(fromShape->fill.color);
break;
case NSVG_PAINT_LINEAR_GRADIENT:
break;
case NSVG_PAINT_RADIAL_GRADIENT:
break;
default:
break;
}
switch (fromShape->fillRule)
{
case NSVG_FILLRULE_EVENODD:
toShape->FillRule(FILL_RULE_EVENODD);
break;
case NSVG_FILLRULE_NONZERO:
toShape->FillRule(FILL_RULE_NONEZERO);
break;
default:
break;
}*/
if (fromShape->fill.type == NSVG_PAINT_COLOR)
{
unsigned int color = fromShape->fill.color;
double r = (double)(color & 255) / 255.0;
color >>= 8;
double g = (double)(color & 255) / 255.0;
color >>= 8;
double b = (double)(color & 255) / 255.0;
color >>= 8;
double a = (double)(color) / 255.0;
toShape->StrokeColor(Color(r, g, b, a));
//std::cout << "stroke color => " << r << " " << g << " " << b << " " << a << std::endl;
}
toShape->StrokeOpacity(fromShape->opacity);
toShape->StrokeWidth(fromShape->strokeWidth);
//std::cout << "stroke type => " << fromShape->stroke.type << std::endl;
//std::cout << "stroke width => " << fromShape->strokeWidth << std::endl;
}
void SvgShape::SetPath(NSVGshape* fromShape, Shape* toShape)
{
for (NSVGpath* path = fromShape->paths; path != NULL; path = path->next) {
toShape->StartNewPath(Point(path->pts[0], path->pts[1], 0.0));
for (int i = 0; i < path->npts - 1; i += 3) {
float* p = &path->pts[i * 2];
toShape->LastPath()->AddPoint(Point(p[2], p[3], 0.0));
toShape->LastPath()->AddPoint(Point(p[4], p[5], 0.0));
toShape->LastPath()->AddPoint(Point(p[6], p[7], 0.0));
}
toShape->LastPath()->MiterLimit(fromShape->miterLimit);
switch (fromShape->strokeLineJoin)
{
case NSVG_JOIN_BEVEL:
toShape->LastPath()->LineJoin(JOIN_BAVEL);
break;
case NSVG_JOIN_MITER:
toShape->LastPath()->LineJoin(JOIN_MITER);
break;
case NSVG_JOIN_ROUND:
toShape->LastPath()->LineJoin(JOIN_ROUND);
break;
default:
break;
}
switch (fromShape->strokeLineCap)
{
case NSVG_CAP_BUTT:
toShape->LastPath()->LineCap(CAP_BUTT);
break;
case NSVG_CAP_ROUND:
toShape->LastPath()->LineCap(CAP_ROUND);
break;
case NSVG_CAP_SQUARE:
toShape->LastPath()->LineCap(CAP_SQUARE);
break;
default:
break;
}
//std::cout << "path closed flag => " << (int)path->closed << std::endl;
if ((int)path->closed == 0) {
toShape->LastPath()->Close();
//std::cout << "path is closed...." << std::endl;
}
}
}
}
| 22.5 | 91 | 0.626843 |
vijayshankarkumar
|
ec3f65192e715686735d0cc87c5ef7837a149342
| 6,837 |
cpp
|
C++
|
SimSpark/rcssserver3d/plugin/soccer/gamestateaspect/gamestateitem.cpp
|
IllyasvielEin/Robocup3dInstaller
|
12e91d9372dd08a92feebf98e916c98bc2242ff4
|
[
"MIT"
] | null | null | null |
SimSpark/rcssserver3d/plugin/soccer/gamestateaspect/gamestateitem.cpp
|
IllyasvielEin/Robocup3dInstaller
|
12e91d9372dd08a92feebf98e916c98bc2242ff4
|
[
"MIT"
] | null | null | null |
SimSpark/rcssserver3d/plugin/soccer/gamestateaspect/gamestateitem.cpp
|
IllyasvielEin/Robocup3dInstaller
|
12e91d9372dd08a92feebf98e916c98bc2242ff4
|
[
"MIT"
] | null | null | null |
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
this file is part of rcssserver3D
Fri May 9 2003
Copyright (C) 2002,2003 Koblenz University
Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
$Id$
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "gamestateitem.h"
#include "gamestateaspect.h"
#include <soccerbase/soccerbase.h>
using namespace oxygen;
using namespace std;
GameStateItem::GameStateItem() : MonitorItem()
{
ResetSentFlags();
}
GameStateItem::~GameStateItem()
{
}
void GameStateItem::ResetSentFlags()
{
mSentLeftTeamname = false;
mSentRightTeamname = false;
mLastHalf = GH_NONE;
mLastLeftScore = -1;
mLastRightScore = -1;
mLastPlayMode = PM_NONE;
mSentFlags = false;
}
void GameStateItem::PutFloatParam(const string& name, PredicateList& pList)
{
float value;
if (! SoccerBase::GetSoccerVar(*this,name,value))
{
return;
}
Predicate& pred = pList.AddPredicate();
pred.name = name;
pred.parameter.AddValue(value);
}
void GameStateItem::GetInitialPredicates(PredicateList& pList)
{
ResetSentFlags();
// field geometry parameter
PutFloatParam("FieldLength",pList);
PutFloatParam("FieldWidth",pList);
PutFloatParam("FieldHeight",pList);
PutFloatParam("GoalWidth",pList);
PutFloatParam("GoalDepth",pList);
PutFloatParam("GoalHeight",pList);
PutFloatParam("BorderSize",pList);
PutFloatParam("FreeKickDistance",pList);
PutFloatParam("WaitBeforeKickOff",pList);
// agent parameter
// PutFloatParam("AgentMass",pList);
PutFloatParam("AgentRadius",pList);
// PutFloatParam("AgentMaxSpeed",pList);
// ball parameter
PutFloatParam("BallRadius",pList);
PutFloatParam("BallMass",pList);
// soccer rule parameters
PutFloatParam("RuleGoalPauseTime",pList);
PutFloatParam("RuleKickInPauseTime",pList);
PutFloatParam("RuleHalfTime",pList);
PutFloatParam("PassModeMinOppBallDist",pList);
PutFloatParam("PassModeDuration",pList);
// play modes
Predicate& pred = pList.AddPredicate();
pred.name = "play_modes";
for (int i=0; i<PM_NONE; ++i)
{
pred.parameter.AddValue
(SoccerBase::PlayMode2Str(static_cast<TPlayMode>(i)));
}
GetPredicates(pList);
}
void GameStateItem::GetPredicates(PredicateList& pList)
{
if (mGameState.get() == 0)
{
return;
}
Predicate& timePred = pList.AddPredicate();
timePred.name = "time";
timePred.parameter.AddValue(mGameState->GetTime());
if (! mSentLeftTeamname)
{
// team names
string name = mGameState->GetTeamName(TI_LEFT);
if (! name.empty())
{
Predicate& teamPredLeft = pList.AddPredicate();
teamPredLeft.name = "team_left";
teamPredLeft.parameter.AddValue(name);
mSentLeftTeamname = true;
}
}
if (! mSentRightTeamname)
{
// team names
string name = mGameState->GetTeamName(TI_RIGHT);
if (! name.empty())
{
Predicate& teamPredRight = pList.AddPredicate();
teamPredRight.name = "team_right";
teamPredRight.parameter.AddValue(name);
mSentRightTeamname = true;
}
}
// game half
TGameHalf half = mGameState->GetGameHalf();
if (half != mLastHalf)
{
mLastHalf = half;
Predicate& halfPred = pList.AddPredicate();
halfPred.name = "half";
halfPred.parameter.AddValue(static_cast<int>(half));
}
// scores
int left_score = mGameState->GetScore(TI_LEFT);
if (left_score != mLastLeftScore)
{
mLastLeftScore = left_score;
Predicate& scoreLeftPred = pList.AddPredicate();
scoreLeftPred.name = "score_left";
scoreLeftPred.parameter.AddValue(left_score);
}
int right_score = mGameState->GetScore(TI_RIGHT);
if (right_score != mLastRightScore)
{
mLastRightScore = right_score;
Predicate& scoreRightPred = pList.AddPredicate();
scoreRightPred.name = "score_right";
scoreRightPred.parameter.AddValue(right_score);
}
// gamestate
TPlayMode play_mode = mGameState->GetPlayMode();
if (play_mode != mLastPlayMode)
{
mLastPlayMode = play_mode;
Predicate& modePred = pList.AddPredicate();
modePred.name = "play_mode";
modePred.parameter.AddValue(static_cast<int>(play_mode));
}
//pass mode score wait time left team
if (mGameState->GetPlayMode() == PM_PlayOn
&& mGameState->GetTime()-mGameState->GetLastTimeInPassMode(TI_LEFT) < mPassModeScoreWaitTime
&& !mGameState->GetPassModeClearedToScore(TI_LEFT))
{
float wait_time = mPassModeScoreWaitTime - (mGameState->GetTime()-mGameState->GetLastTimeInPassMode(TI_LEFT));
Predicate& passModeScoreWaitLeftPred = pList.AddPredicate();
passModeScoreWaitLeftPred.name = "pass_mode_score_wait_left";
passModeScoreWaitLeftPred.parameter.AddValue(wait_time);
}
//pass mode score wait time right team
if (mGameState->GetPlayMode() == PM_PlayOn
&& mGameState->GetTime()-mGameState->GetLastTimeInPassMode(TI_RIGHT) < mPassModeScoreWaitTime
&& !mGameState->GetPassModeClearedToScore(TI_RIGHT))
{
float wait_time = mPassModeScoreWaitTime - (mGameState->GetTime()-mGameState->GetLastTimeInPassMode(TI_RIGHT));
Predicate& passModeScoreWaitRightPred = pList.AddPredicate();
passModeScoreWaitRightPred.name = "pass_mode_score_wait_right";
passModeScoreWaitRightPred.parameter.AddValue(wait_time);
}
}
void GameStateItem::OnLink()
{
SoccerBase::GetGameState(*this,mGameState);
mPassModeScoreWaitTime = 10.0;
SoccerBase::GetSoccerVar(*this,"PassModeScoreWaitTime",mPassModeScoreWaitTime);
}
void GameStateItem::OnUnlink()
{
mGameState.reset();
}
| 31.506912 | 124 | 0.64853 |
IllyasvielEin
|
ec411e41e5e7f00fd5988a99752d7abb2b69a426
| 4,490 |
cpp
|
C++
|
3DShootingGame/Framework/Physics/Rigidbody.cpp
|
ydeagames/3DShootingGame
|
f93e15179452810bd55fbfcedb6c162698296ec4
|
[
"MIT"
] | 2 |
2020-03-30T05:11:51.000Z
|
2022-01-30T09:04:40.000Z
|
3DShootingGame/Framework/Physics/Rigidbody.cpp
|
ydeagames/3DShootingGame
|
f93e15179452810bd55fbfcedb6c162698296ec4
|
[
"MIT"
] | null | null | null |
3DShootingGame/Framework/Physics/Rigidbody.cpp
|
ydeagames/3DShootingGame
|
f93e15179452810bd55fbfcedb6c162698296ec4
|
[
"MIT"
] | 2 |
2020-03-30T05:11:52.000Z
|
2020-10-28T02:06:35.000Z
|
// Copyright (c) 2019-2020 ydeagames
// Released under the MIT license
// https://github.com/ydeagames/3DShootingGame/blob/master/LICENSE
//
// Author: ${ydeagames}
// Created: 2019-07-22 06:12:28 +0900
// Modified: 2020-01-17 11:44:41 +0900
#include "pch.h"
#include "Rigidbody.h"
#include "Collidable.h"
#include <Framework/ECS/GameContext.h>
#include <Framework/ECS/GameObject.h>
#include <Framework/ECS/Scene.h>
#include <Framework/Context/SceneManager.h>
#include <Framework/PhysX/PhysXManager.h>
#include <Framework/PhysX/PhysXScene.h>
#include <Framework/Tags/Tags.h>
void Rigidbody::Start()
{
gameObject.FindGameObjectWithTag<Tag::PhysXSceneTag>().ifPresent([&](GameObject& obj)
{
if (obj.HasComponent<PhysXScene>())
{
auto& manager = GameContext::Get<PhysXManager>();
auto trans = physx::PxTransform(physx::toPhysX(gameObject.GetComponent<Transform>().position), physx::toPhysX(gameObject.GetComponent<Transform>().rotation));
if (gameObject.GetComponent<Transform>().isStatic)
rigid = manager.GetPhysics()->createRigidStatic(trans);
else
{
auto dynamic = manager.GetPhysics()->createRigidDynamic(trans);
dynamic->setRigidBodyFlags(lockFlags);
rigid = dynamic;
}
auto& reg = *gameObject.registry;
auto& e = gameObject.entity;
std::vector<entt::entity> src;
auto rec0 = [&](auto& e, auto& rec) mutable -> void {
src.push_back(e);
reg.view<Transform>().each([&](auto entity, Transform& component) {
if (component.parent == e)
rec(entity, rec);
});
};
rec0(e, rec0);
Collidable::AddCollider(reg, src, std::forward<physx::PxRigidActor>(*rigid));
obj.GetComponent<PhysXScene>().CreateObject(*rigid);
if (rigid && rigid->is<physx::PxRigidBody>())
{
auto dynamic = rigid->is<physx::PxRigidBody>();
dynamic->setLinearVelocity(preVelocity);
dynamic->addForce(preForce);
}
}
});
}
void Rigidbody::Update()
{
if (rigid)
{
auto trans = rigid->getGlobalPose();
gameObject.GetComponent<Transform>().position = physx::fromPhysX(trans.p);
gameObject.GetComponent<Transform>().rotation = physx::fromPhysX(trans.q);
}
}
void Rigidbody::OnDestroy()
{
if (rigid)
{
auto scene = rigid->getScene();
if (scene)
scene->removeActor(*rigid);
px_release(rigid);
}
}
void Rigidbody::AddForce(const DirectX::SimpleMath::Vector3& force)
{
preForce = physx::toPhysX(force);
if (rigid && rigid->is<physx::PxRigidBody>())
rigid->is<physx::PxRigidBody>()->addForce(physx::toPhysX(force));
}
void Rigidbody::SetVelocity(const DirectX::SimpleMath::Vector3& velocity)
{
preVelocity = physx::toPhysX(velocity);
if (rigid && rigid->is<physx::PxRigidBody>())
rigid->is<physx::PxRigidBody>()->setLinearVelocity(physx::toPhysX(velocity));
}
DirectX::SimpleMath::Vector3 Rigidbody::GetVelocity() const
{
if (rigid && rigid->is<physx::PxRigidBody>())
return physx::fromPhysX(rigid->is<physx::PxRigidBody>()->getLinearVelocity());
return DirectX::SimpleMath::Vector3();
}
Transform& Rigidbody::Fetch()
{
auto& t = gameObject.GetComponent<Transform>();
if (rigid)
{
auto trans = rigid->getGlobalPose();
t.position = physx::fromPhysX(trans.p);
t.rotation = physx::fromPhysX(trans.q);
}
return t;
}
void Rigidbody::Apply()
{
if (rigid)
{
auto& t = gameObject.GetComponent<Transform>();
physx::PxTransform trans;
trans.p = physx::toPhysX(t.position);
trans.q = physx::toPhysX(t.rotation);
rigid->setGlobalPose(trans);
}
}
void Rigidbody::EditorGui()
{
{
uint32_t flags = lockFlags;
ImGui::CheckboxFlags("Kinematic", &flags, physx::PxRigidBodyFlag::eKINEMATIC);
ImGui::CheckboxFlags("Use Kinematic Target for Scene Queries", &flags, physx::PxRigidBodyFlag::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES);
ImGui::CheckboxFlags("Enable CCD", &flags, physx::PxRigidBodyFlag::eENABLE_CCD);
ImGui::CheckboxFlags("Enable CCD Friction", &flags, physx::PxRigidBodyFlag::eENABLE_CCD_FRICTION);
ImGui::CheckboxFlags("Enable Pose Integration Preview", &flags, physx::PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW);
ImGui::CheckboxFlags("Enable Speculative CCD", &flags, physx::PxRigidBodyFlag::eENABLE_SPECULATIVE_CCD);
ImGui::CheckboxFlags("Enable CCD Max Contact Impulse", &flags, physx::PxRigidBodyFlag::eENABLE_CCD_MAX_CONTACT_IMPULSE);
ImGui::CheckboxFlags("Return Accelerations", &flags, physx::PxRigidBodyFlag::eRETAIN_ACCELERATIONS);
lockFlags = physx::PxRigidBodyFlags(physx::PxU8(flags));
}
}
| 30.753425 | 162 | 0.710022 |
ydeagames
|
ec41db944c5ccf4371e9f02f77f4024f1882087c
| 754 |
cpp
|
C++
|
source/native-backend/parsing/TextProcessor.cpp
|
batburger/Native-Backend
|
aaed26851e09f9e110061025fb2140aed1b4f9b5
|
[
"Apache-2.0"
] | null | null | null |
source/native-backend/parsing/TextProcessor.cpp
|
batburger/Native-Backend
|
aaed26851e09f9e110061025fb2140aed1b4f9b5
|
[
"Apache-2.0"
] | null | null | null |
source/native-backend/parsing/TextProcessor.cpp
|
batburger/Native-Backend
|
aaed26851e09f9e110061025fb2140aed1b4f9b5
|
[
"Apache-2.0"
] | null | null | null |
//
// Created by albert on 3/17/18.
//
#include "native-backend/parsing/TextProcessor.h"
/*!\brief Finds the value specified as key in \c replacement_map in the \c input_string and replaces it with the value for the key.*/
void
nvb::TextProcessor::process(std::string *input_string, std::unordered_map<std::string, std::string> &replacement_map) {
for(auto replacement_pair : replacement_map){
while(input_string->find(replacement_pair.first, 0) != input_string->npos){
size_t position = input_string->find(replacement_pair.first, 0);
*input_string = input_string->erase(position, replacement_pair.first.size());
*input_string = input_string->insert(position, replacement_pair.second);
}
}
}
| 41.888889 | 133 | 0.706897 |
batburger
|
ec452340961e1d815ad437430988dbeaa16cbb3d
| 1,234 |
cpp
|
C++
|
daolib/CommonQueries.cpp
|
mfranceschi/SQLiteDao
|
447da25d15f6332e454f151fb71aa232665d8506
|
[
"MIT"
] | null | null | null |
daolib/CommonQueries.cpp
|
mfranceschi/SQLiteDao
|
447da25d15f6332e454f151fb71aa232665d8506
|
[
"MIT"
] | null | null | null |
daolib/CommonQueries.cpp
|
mfranceschi/SQLiteDao
|
447da25d15f6332e454f151fb71aa232665d8506
|
[
"MIT"
] | null | null | null |
#include "CommonQueries.hpp"
#include <algorithm>
#include "magic_enum.hpp"
#include <fmt/core.h>
#include <fmt/format.h>
std::string enquote(const std::string &text) {
return fmt::format("`{}`", text);
};
namespace CommonQueries {
std::string dropTableIfExists(const std::string &tableName) {
return fmt::format("DROP TABLE IF EXISTS {}; ", enquote(tableName));
}
std::string createTable(const std::string &tableName,
const ColumnList_t &columnList) {
std::vector<std::string> columnDeclarations(columnList.size());
std::transform(columnList.cbegin(), columnList.cend(),
columnDeclarations.begin(), [](const ColumnData &columnData) {
return fmt::format("{} {}", columnData.name,
magic_enum::enum_name(columnData.type));
});
return fmt::format("CREATE TABLE {} ({}); ", tableName,
fmt::join(columnDeclarations, ", "));
}
std::string selectAll(const std::string &tableName) {
return fmt::format("SELECT * FROM {}; ", enquote(tableName));
}
std::string listTables() {
return "SELECT name FROM sqlite_schema WHERE type = 'table' ORDER BY NAME; ";
}
} // namespace CommonQueries
| 30.85 | 79 | 0.628849 |
mfranceschi
|
ec4c7360f6ec7ae840e22bc6ba95fe901cc59e4a
| 186 |
cpp
|
C++
|
test/test-bits.cpp
|
mbeutel/slowmath
|
d09967d168433814896e83af2fbc92bc36e6c4fb
|
[
"BSL-1.0"
] | 1 |
2021-09-02T07:03:53.000Z
|
2021-09-02T07:03:53.000Z
|
test/test-bits.cpp
|
mbeutel/slowmath
|
d09967d168433814896e83af2fbc92bc36e6c4fb
|
[
"BSL-1.0"
] | 8 |
2019-12-03T21:11:07.000Z
|
2020-02-05T18:44:31.000Z
|
test/test-bits.cpp
|
mbeutel/slowmath
|
d09967d168433814896e83af2fbc92bc36e6c4fb
|
[
"BSL-1.0"
] | null | null | null |
#include <tuple>
#include <catch2/catch.hpp>
#include <slowmath/arithmetic.hpp>
// TODO: add comprehensive tests for shift_left()
// TODO: add comprehensive tests for shift_right()
| 16.909091 | 50 | 0.741935 |
mbeutel
|
ec4de22693fbd85ce1682b86960c25b1d8fde467
| 1,614 |
cpp
|
C++
|
HW06/src/utils.cpp
|
petegerhat/cuda
|
671c244276828baeeb66e2c4e0e2f9881b666716
|
[
"Apache-2.0"
] | null | null | null |
HW06/src/utils.cpp
|
petegerhat/cuda
|
671c244276828baeeb66e2c4e0e2f9881b666716
|
[
"Apache-2.0"
] | null | null | null |
HW06/src/utils.cpp
|
petegerhat/cuda
|
671c244276828baeeb66e2c4e0e2f9881b666716
|
[
"Apache-2.0"
] | null | null | null |
/*
* File: main.cpp
* Author: peter
*
* Created on March 25, 2012, 1:36 AM
*/
#ifndef UTILS_H
#define UTILS_H
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
DT& getDistance(DT* distances, int n, int i, int j) {
#ifdef DIS1
return distances[i * n + j];
#else
throw "Missing DIS";
#endif
}
DT *genEmptyMatrix(const int n) {
DT *ptr;
//cudaMallocHost(&ptr, n * sizeof (DT));
ptr = new DT[n];
return ptr;
}
unsigned int *genEmptyColMatrix(const int n) {
unsigned int *ptr;
//cudaMallocHost(&ptr, n * sizeof (DT));
ptr = new unsigned int[n];
return ptr;
}
DT *genMatrix(const int n) {
DT *ptr;
ptr = genEmptyMatrix(n);
for (int i = 0; i < n; i++) {
ptr[i] = ((DT) rand()) / RAND_MAX;
}
return ptr;
}
DT **genMatrix(const int n, const int m) {
DT **ptr;
//ptr = (DT**)malloc(n*sizeof(DT*));
//cudaMallocHost((void**)&ptr, n*sizeof(DT*));
ptr = new DT*[n];
for (int i = 0; i < n; i++) {
ptr[i] = genEmptyMatrix(m);
for (int j = 0; j < m; j++) {
ptr[i][j] = ((DT) rand()) / RAND_MAX;
}
}
return ptr;
}
void cudaRelease(int n, DT** array) {
for (int i = 0; i < n; i++) {
cudaFree(array[i]);
}
cudaFree(array);
}
void cudaRelease(DT* array) {
cudaFree(array);
}
void cudaRelease(unsigned int* array) {
cudaFree(array);
}
void release(int n, DT** array) {
for (int i = 0; i < n; i++) {
free(array[i]);
}
free(array);
}
void release(DT* array) {
free(array);
}
#endif
| 17.543478 | 53 | 0.545229 |
petegerhat
|
ec62ea93f7707080935e94c530290dd834411df5
| 23,401 |
cxx
|
C++
|
SimModel_Python_API/simmodel_swig/SimModel_Dll_lib/framework/SimFlowEnergyTransfer_HeatExEarthToWater_Surface.cxx
|
EnEff-BIM/EnEffBIM-Framework
|
6328d39b498dc4065a60b5cc9370b8c2a9a1cddf
|
[
"MIT"
] | 3 |
2016-05-30T15:12:16.000Z
|
2022-03-22T08:11:13.000Z
|
SimModel_Python_API/simmodel_swig/SimModel_Dll_lib/framework/SimFlowEnergyTransfer_HeatExEarthToWater_Surface.cxx
|
EnEff-BIM/EnEffBIM-Framework
|
6328d39b498dc4065a60b5cc9370b8c2a9a1cddf
|
[
"MIT"
] | 21 |
2016-06-13T11:33:45.000Z
|
2017-05-23T09:46:52.000Z
|
SimModel_Python_API/simmodel_swig/SimModel_Dll_lib/framework/SimFlowEnergyTransfer_HeatExEarthToWater_Surface.cxx
|
EnEff-BIM/EnEffBIM-Framework
|
6328d39b498dc4065a60b5cc9370b8c2a9a1cddf
|
[
"MIT"
] | null | null | null |
// Copyright (c) 2005-2014 Code Synthesis Tools CC
//
// This program was generated by CodeSynthesis XSD, an XML Schema to
// C++ data binding compiler.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
// In addition, as a special exception, Code Synthesis Tools CC gives
// permission to link this program with the Xerces-C++ library (or with
// modified versions of Xerces-C++ that use the same license as Xerces-C++),
// and distribute linked combinations including the two. You must obey
// the GNU General Public License version 2 in all respects for all of
// the code used other than Xerces-C++. If you modify this copy of the
// program, you may extend this exception to your version of the program,
// but you are not obligated to do so. If you do not wish to do so, delete
// this exception statement from your version.
//
// Furthermore, Code Synthesis Tools CC makes a special exception for
// the Free/Libre and Open Source Software (FLOSS) which is described
// in the accompanying FLOSSE file.
//
// Begin prologue.
//
//
// End prologue.
#include <xsd/cxx/pre.hxx>
#include "SimFlowEnergyTransfer_HeatExEarthToWater_Surface.hxx"
namespace schema
{
namespace simxml
{
namespace MepModel
{
// SimFlowEnergyTransfer_HeatExEarthToWater_Surface
//
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_HydronicTubingsideDiam_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubingsideDiam () const
{
return this->SimFlowEnergyTrans_HydronicTubingsideDiam_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_HydronicTubingsideDiam_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubingsideDiam ()
{
return this->SimFlowEnergyTrans_HydronicTubingsideDiam_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubingsideDiam (const SimFlowEnergyTrans_HydronicTubingsideDiam_type& x)
{
this->SimFlowEnergyTrans_HydronicTubingsideDiam_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubingsideDiam (const SimFlowEnergyTrans_HydronicTubingsideDiam_optional& x)
{
this->SimFlowEnergyTrans_HydronicTubingsideDiam_ = x;
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_FluidInletNodeName_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidInletNodeName () const
{
return this->SimFlowEnergyTrans_FluidInletNodeName_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_FluidInletNodeName_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidInletNodeName ()
{
return this->SimFlowEnergyTrans_FluidInletNodeName_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidInletNodeName (const SimFlowEnergyTrans_FluidInletNodeName_type& x)
{
this->SimFlowEnergyTrans_FluidInletNodeName_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidInletNodeName (const SimFlowEnergyTrans_FluidInletNodeName_optional& x)
{
this->SimFlowEnergyTrans_FluidInletNodeName_ = x;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidInletNodeName (::std::auto_ptr< SimFlowEnergyTrans_FluidInletNodeName_type > x)
{
this->SimFlowEnergyTrans_FluidInletNodeName_.set (x);
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_FluidOutletNodeName_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidOutletNodeName () const
{
return this->SimFlowEnergyTrans_FluidOutletNodeName_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_FluidOutletNodeName_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidOutletNodeName ()
{
return this->SimFlowEnergyTrans_FluidOutletNodeName_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidOutletNodeName (const SimFlowEnergyTrans_FluidOutletNodeName_type& x)
{
this->SimFlowEnergyTrans_FluidOutletNodeName_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidOutletNodeName (const SimFlowEnergyTrans_FluidOutletNodeName_optional& x)
{
this->SimFlowEnergyTrans_FluidOutletNodeName_ = x;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_FluidOutletNodeName (::std::auto_ptr< SimFlowEnergyTrans_FluidOutletNodeName_type > x)
{
this->SimFlowEnergyTrans_FluidOutletNodeName_.set (x);
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_NumTubingCircuits_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_NumTubingCircuits () const
{
return this->SimFlowEnergyTrans_NumTubingCircuits_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_NumTubingCircuits_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_NumTubingCircuits ()
{
return this->SimFlowEnergyTrans_NumTubingCircuits_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_NumTubingCircuits (const SimFlowEnergyTrans_NumTubingCircuits_type& x)
{
this->SimFlowEnergyTrans_NumTubingCircuits_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_NumTubingCircuits (const SimFlowEnergyTrans_NumTubingCircuits_optional& x)
{
this->SimFlowEnergyTrans_NumTubingCircuits_ = x;
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_ConstructionName_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_ConstructionName () const
{
return this->SimFlowEnergyTrans_ConstructionName_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_ConstructionName_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_ConstructionName ()
{
return this->SimFlowEnergyTrans_ConstructionName_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_ConstructionName (const SimFlowEnergyTrans_ConstructionName_type& x)
{
this->SimFlowEnergyTrans_ConstructionName_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_ConstructionName (const SimFlowEnergyTrans_ConstructionName_optional& x)
{
this->SimFlowEnergyTrans_ConstructionName_ = x;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_ConstructionName (::std::auto_ptr< SimFlowEnergyTrans_ConstructionName_type > x)
{
this->SimFlowEnergyTrans_ConstructionName_.set (x);
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_HydronicTubeSpacing_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubeSpacing () const
{
return this->SimFlowEnergyTrans_HydronicTubeSpacing_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_HydronicTubeSpacing_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubeSpacing ()
{
return this->SimFlowEnergyTrans_HydronicTubeSpacing_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubeSpacing (const SimFlowEnergyTrans_HydronicTubeSpacing_type& x)
{
this->SimFlowEnergyTrans_HydronicTubeSpacing_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_HydronicTubeSpacing (const SimFlowEnergyTrans_HydronicTubeSpacing_optional& x)
{
this->SimFlowEnergyTrans_HydronicTubeSpacing_ = x;
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_SurfLength_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfLength () const
{
return this->SimFlowEnergyTrans_SurfLength_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_SurfLength_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfLength ()
{
return this->SimFlowEnergyTrans_SurfLength_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfLength (const SimFlowEnergyTrans_SurfLength_type& x)
{
this->SimFlowEnergyTrans_SurfLength_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfLength (const SimFlowEnergyTrans_SurfLength_optional& x)
{
this->SimFlowEnergyTrans_SurfLength_ = x;
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_SurfWidth_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfWidth () const
{
return this->SimFlowEnergyTrans_SurfWidth_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_SurfWidth_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfWidth ()
{
return this->SimFlowEnergyTrans_SurfWidth_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfWidth (const SimFlowEnergyTrans_SurfWidth_type& x)
{
this->SimFlowEnergyTrans_SurfWidth_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_SurfWidth (const SimFlowEnergyTrans_SurfWidth_optional& x)
{
this->SimFlowEnergyTrans_SurfWidth_ = x;
}
const SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_LowSurfEnvironment_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_LowSurfEnvironment () const
{
return this->SimFlowEnergyTrans_LowSurfEnvironment_;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::SimFlowEnergyTrans_LowSurfEnvironment_optional& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_LowSurfEnvironment ()
{
return this->SimFlowEnergyTrans_LowSurfEnvironment_;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_LowSurfEnvironment (const SimFlowEnergyTrans_LowSurfEnvironment_type& x)
{
this->SimFlowEnergyTrans_LowSurfEnvironment_.set (x);
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_LowSurfEnvironment (const SimFlowEnergyTrans_LowSurfEnvironment_optional& x)
{
this->SimFlowEnergyTrans_LowSurfEnvironment_ = x;
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTrans_LowSurfEnvironment (::std::auto_ptr< SimFlowEnergyTrans_LowSurfEnvironment_type > x)
{
this->SimFlowEnergyTrans_LowSurfEnvironment_.set (x);
}
}
}
}
#include <xsd/cxx/xml/dom/parsing-source.hxx>
#include <xsd/cxx/tree/type-factory-map.hxx>
namespace _xsd
{
static
const ::xsd::cxx::tree::type_factory_plate< 0, char >
type_factory_plate_init;
}
namespace schema
{
namespace simxml
{
namespace MepModel
{
// SimFlowEnergyTransfer_HeatExEarthToWater_Surface
//
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTransfer_HeatExEarthToWater_Surface ()
: ::schema::simxml::MepModel::SimFlowEnergyTransfer_HeatExEarthToWater (),
SimFlowEnergyTrans_HydronicTubingsideDiam_ (this),
SimFlowEnergyTrans_FluidInletNodeName_ (this),
SimFlowEnergyTrans_FluidOutletNodeName_ (this),
SimFlowEnergyTrans_NumTubingCircuits_ (this),
SimFlowEnergyTrans_ConstructionName_ (this),
SimFlowEnergyTrans_HydronicTubeSpacing_ (this),
SimFlowEnergyTrans_SurfLength_ (this),
SimFlowEnergyTrans_SurfWidth_ (this),
SimFlowEnergyTrans_LowSurfEnvironment_ (this)
{
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTransfer_HeatExEarthToWater_Surface (const RefId_type& RefId)
: ::schema::simxml::MepModel::SimFlowEnergyTransfer_HeatExEarthToWater (RefId),
SimFlowEnergyTrans_HydronicTubingsideDiam_ (this),
SimFlowEnergyTrans_FluidInletNodeName_ (this),
SimFlowEnergyTrans_FluidOutletNodeName_ (this),
SimFlowEnergyTrans_NumTubingCircuits_ (this),
SimFlowEnergyTrans_ConstructionName_ (this),
SimFlowEnergyTrans_HydronicTubeSpacing_ (this),
SimFlowEnergyTrans_SurfLength_ (this),
SimFlowEnergyTrans_SurfWidth_ (this),
SimFlowEnergyTrans_LowSurfEnvironment_ (this)
{
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTransfer_HeatExEarthToWater_Surface (const SimFlowEnergyTransfer_HeatExEarthToWater_Surface& x,
::xml_schema::flags f,
::xml_schema::container* c)
: ::schema::simxml::MepModel::SimFlowEnergyTransfer_HeatExEarthToWater (x, f, c),
SimFlowEnergyTrans_HydronicTubingsideDiam_ (x.SimFlowEnergyTrans_HydronicTubingsideDiam_, f, this),
SimFlowEnergyTrans_FluidInletNodeName_ (x.SimFlowEnergyTrans_FluidInletNodeName_, f, this),
SimFlowEnergyTrans_FluidOutletNodeName_ (x.SimFlowEnergyTrans_FluidOutletNodeName_, f, this),
SimFlowEnergyTrans_NumTubingCircuits_ (x.SimFlowEnergyTrans_NumTubingCircuits_, f, this),
SimFlowEnergyTrans_ConstructionName_ (x.SimFlowEnergyTrans_ConstructionName_, f, this),
SimFlowEnergyTrans_HydronicTubeSpacing_ (x.SimFlowEnergyTrans_HydronicTubeSpacing_, f, this),
SimFlowEnergyTrans_SurfLength_ (x.SimFlowEnergyTrans_SurfLength_, f, this),
SimFlowEnergyTrans_SurfWidth_ (x.SimFlowEnergyTrans_SurfWidth_, f, this),
SimFlowEnergyTrans_LowSurfEnvironment_ (x.SimFlowEnergyTrans_LowSurfEnvironment_, f, this)
{
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
SimFlowEnergyTransfer_HeatExEarthToWater_Surface (const ::xercesc::DOMElement& e,
::xml_schema::flags f,
::xml_schema::container* c)
: ::schema::simxml::MepModel::SimFlowEnergyTransfer_HeatExEarthToWater (e, f | ::xml_schema::flags::base, c),
SimFlowEnergyTrans_HydronicTubingsideDiam_ (this),
SimFlowEnergyTrans_FluidInletNodeName_ (this),
SimFlowEnergyTrans_FluidOutletNodeName_ (this),
SimFlowEnergyTrans_NumTubingCircuits_ (this),
SimFlowEnergyTrans_ConstructionName_ (this),
SimFlowEnergyTrans_HydronicTubeSpacing_ (this),
SimFlowEnergyTrans_SurfLength_ (this),
SimFlowEnergyTrans_SurfWidth_ (this),
SimFlowEnergyTrans_LowSurfEnvironment_ (this)
{
if ((f & ::xml_schema::flags::base) == 0)
{
::xsd::cxx::xml::dom::parser< char > p (e, true, false, true);
this->parse (p, f);
}
}
void SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
parse (::xsd::cxx::xml::dom::parser< char >& p,
::xml_schema::flags f)
{
this->::schema::simxml::MepModel::SimFlowEnergyTransfer_HeatExEarthToWater::parse (p, f);
for (; p.more_content (); p.next_content (false))
{
const ::xercesc::DOMElement& i (p.cur_element ());
const ::xsd::cxx::xml::qualified_name< char > n (
::xsd::cxx::xml::dom::name< char > (i));
// SimFlowEnergyTrans_HydronicTubingsideDiam
//
if (n.name () == "SimFlowEnergyTrans_HydronicTubingsideDiam" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
if (!this->SimFlowEnergyTrans_HydronicTubingsideDiam_)
{
this->SimFlowEnergyTrans_HydronicTubingsideDiam_.set (SimFlowEnergyTrans_HydronicTubingsideDiam_traits::create (i, f, this));
continue;
}
}
// SimFlowEnergyTrans_FluidInletNodeName
//
if (n.name () == "SimFlowEnergyTrans_FluidInletNodeName" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
::std::auto_ptr< SimFlowEnergyTrans_FluidInletNodeName_type > r (
SimFlowEnergyTrans_FluidInletNodeName_traits::create (i, f, this));
if (!this->SimFlowEnergyTrans_FluidInletNodeName_)
{
this->SimFlowEnergyTrans_FluidInletNodeName_.set (r);
continue;
}
}
// SimFlowEnergyTrans_FluidOutletNodeName
//
if (n.name () == "SimFlowEnergyTrans_FluidOutletNodeName" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
::std::auto_ptr< SimFlowEnergyTrans_FluidOutletNodeName_type > r (
SimFlowEnergyTrans_FluidOutletNodeName_traits::create (i, f, this));
if (!this->SimFlowEnergyTrans_FluidOutletNodeName_)
{
this->SimFlowEnergyTrans_FluidOutletNodeName_.set (r);
continue;
}
}
// SimFlowEnergyTrans_NumTubingCircuits
//
if (n.name () == "SimFlowEnergyTrans_NumTubingCircuits" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
if (!this->SimFlowEnergyTrans_NumTubingCircuits_)
{
this->SimFlowEnergyTrans_NumTubingCircuits_.set (SimFlowEnergyTrans_NumTubingCircuits_traits::create (i, f, this));
continue;
}
}
// SimFlowEnergyTrans_ConstructionName
//
if (n.name () == "SimFlowEnergyTrans_ConstructionName" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
::std::auto_ptr< SimFlowEnergyTrans_ConstructionName_type > r (
SimFlowEnergyTrans_ConstructionName_traits::create (i, f, this));
if (!this->SimFlowEnergyTrans_ConstructionName_)
{
this->SimFlowEnergyTrans_ConstructionName_.set (r);
continue;
}
}
// SimFlowEnergyTrans_HydronicTubeSpacing
//
if (n.name () == "SimFlowEnergyTrans_HydronicTubeSpacing" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
if (!this->SimFlowEnergyTrans_HydronicTubeSpacing_)
{
this->SimFlowEnergyTrans_HydronicTubeSpacing_.set (SimFlowEnergyTrans_HydronicTubeSpacing_traits::create (i, f, this));
continue;
}
}
// SimFlowEnergyTrans_SurfLength
//
if (n.name () == "SimFlowEnergyTrans_SurfLength" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
if (!this->SimFlowEnergyTrans_SurfLength_)
{
this->SimFlowEnergyTrans_SurfLength_.set (SimFlowEnergyTrans_SurfLength_traits::create (i, f, this));
continue;
}
}
// SimFlowEnergyTrans_SurfWidth
//
if (n.name () == "SimFlowEnergyTrans_SurfWidth" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
if (!this->SimFlowEnergyTrans_SurfWidth_)
{
this->SimFlowEnergyTrans_SurfWidth_.set (SimFlowEnergyTrans_SurfWidth_traits::create (i, f, this));
continue;
}
}
// SimFlowEnergyTrans_LowSurfEnvironment
//
if (n.name () == "SimFlowEnergyTrans_LowSurfEnvironment" && n.namespace_ () == "http://d-alchemy.com/schema/simxml/MepModel")
{
::std::auto_ptr< SimFlowEnergyTrans_LowSurfEnvironment_type > r (
SimFlowEnergyTrans_LowSurfEnvironment_traits::create (i, f, this));
if (!this->SimFlowEnergyTrans_LowSurfEnvironment_)
{
this->SimFlowEnergyTrans_LowSurfEnvironment_.set (r);
continue;
}
}
break;
}
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface* SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
_clone (::xml_schema::flags f,
::xml_schema::container* c) const
{
return new class SimFlowEnergyTransfer_HeatExEarthToWater_Surface (*this, f, c);
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface& SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
operator= (const SimFlowEnergyTransfer_HeatExEarthToWater_Surface& x)
{
if (this != &x)
{
static_cast< ::schema::simxml::MepModel::SimFlowEnergyTransfer_HeatExEarthToWater& > (*this) = x;
this->SimFlowEnergyTrans_HydronicTubingsideDiam_ = x.SimFlowEnergyTrans_HydronicTubingsideDiam_;
this->SimFlowEnergyTrans_FluidInletNodeName_ = x.SimFlowEnergyTrans_FluidInletNodeName_;
this->SimFlowEnergyTrans_FluidOutletNodeName_ = x.SimFlowEnergyTrans_FluidOutletNodeName_;
this->SimFlowEnergyTrans_NumTubingCircuits_ = x.SimFlowEnergyTrans_NumTubingCircuits_;
this->SimFlowEnergyTrans_ConstructionName_ = x.SimFlowEnergyTrans_ConstructionName_;
this->SimFlowEnergyTrans_HydronicTubeSpacing_ = x.SimFlowEnergyTrans_HydronicTubeSpacing_;
this->SimFlowEnergyTrans_SurfLength_ = x.SimFlowEnergyTrans_SurfLength_;
this->SimFlowEnergyTrans_SurfWidth_ = x.SimFlowEnergyTrans_SurfWidth_;
this->SimFlowEnergyTrans_LowSurfEnvironment_ = x.SimFlowEnergyTrans_LowSurfEnvironment_;
}
return *this;
}
SimFlowEnergyTransfer_HeatExEarthToWater_Surface::
~SimFlowEnergyTransfer_HeatExEarthToWater_Surface ()
{
}
}
}
}
#include <istream>
#include <xsd/cxx/xml/sax/std-input-source.hxx>
#include <xsd/cxx/tree/error-handler.hxx>
namespace schema
{
namespace simxml
{
namespace MepModel
{
}
}
}
#include <xsd/cxx/post.hxx>
// Begin epilogue.
//
//
// End epilogue.
| 41.271605 | 164 | 0.718345 |
EnEff-BIM
|
ec6550f7f9b7351b4b82ef1fc9ffef8244d19ad7
| 5,809 |
hpp
|
C++
|
my_vulkan/command_buffer.hpp
|
pixelwise/my_vulkan
|
f1c139ed8f95380186905d77cb8e81008f48bc95
|
[
"CC0-1.0"
] | null | null | null |
my_vulkan/command_buffer.hpp
|
pixelwise/my_vulkan
|
f1c139ed8f95380186905d77cb8e81008f48bc95
|
[
"CC0-1.0"
] | 3 |
2019-02-25T10:13:57.000Z
|
2020-11-11T14:46:14.000Z
|
my_vulkan/command_buffer.hpp
|
pixelwise/my_vulkan
|
f1c139ed8f95380186905d77cb8e81008f48bc95
|
[
"CC0-1.0"
] | null | null | null |
#pragma once
#include <vulkan/vulkan.h>
#include <vector>
#include "utils.hpp"
namespace my_vulkan
{
struct command_buffer_t
{
struct scope_t
{
scope_t(
VkCommandBuffer command_buffer,
VkCommandBufferUsageFlags flags
);
scope_t(const scope_t&) = delete;
scope_t(scope_t&& other) noexcept;
scope_t& operator=(const scope_t&) = delete;
scope_t& operator=(scope_t&& other) noexcept;
struct buffer_binding_t
{
VkBuffer buffer;
VkDeviceSize offset;
};
void begin_render_pass(
VkRenderPass renderPass,
VkFramebuffer framebuffer,
VkRect2D render_area,
std::vector<VkClearValue> clear_values = {},
VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE
);
void next_subpass(
VkSubpassContents contents = VK_SUBPASS_CONTENTS_INLINE
);
void set_viewport(
std::vector<VkViewport> viewports,
uint32_t first = 0
);
void set_scissor(
std::vector<VkRect2D> scissors,
uint32_t first = 0
);
void clear(
std::vector<VkClearAttachment> attachements,
std::vector<VkClearRect> rects
);
void bind_pipeline(
VkPipelineBindPoint bind_point,
VkPipeline pipeline,
std::optional<VkRect2D> target_rect = std::nullopt
);
void bind_vertex_buffers(
std::vector<buffer_binding_t> bindings,
uint32_t offset = 0
);
void bind_index_buffer(
VkBuffer buffer,
VkIndexType type,
size_t offset = 0
);
void bind_descriptor_set(
VkPipelineBindPoint bind_point,
VkPipelineLayout layout,
std::vector<VkDescriptorSet> descriptors,
uint32_t offset = 0,
std::vector<uint32_t> dynamic_offset = {}
);
void draw_indexed(
index_range_t index_range,
uint32_t vertex_offset = 0,
index_range_t instance_range = {0, 1}
);
void draw(
index_range_t index_range,
index_range_t instance_range = {0, 1}
);
void end_render_pass();
void pipeline_barrier(
VkPipelineStageFlags src_stage_mask,
VkPipelineStageFlags dst_stage_mask,
std::vector<VkMemoryBarrier> barriers,
VkDependencyFlags dependency_flags = 0
);
void pipeline_barrier(
VkPipelineStageFlags src_stage_mask,
VkPipelineStageFlags dst_stage_mask,
std::vector<VkBufferMemoryBarrier> barriers,
VkDependencyFlags dependency_flags = 0
);
void pipeline_barrier(
VkPipelineStageFlags src_stage_mask,
VkPipelineStageFlags dst_stage_mask,
std::vector<VkImageMemoryBarrier> barriers,
VkDependencyFlags dependency_flags = 0
);
void pipeline_barrier(
VkPipelineStageFlags src_stage_mask,
VkPipelineStageFlags dst_stage_mask,
std::vector<VkMemoryBarrier> memory_barriers,
std::vector<VkBufferMemoryBarrier> buffer_barriers,
std::vector<VkImageMemoryBarrier> image_barriers,
VkDependencyFlags dependency_flags = 0
);
void copy(
VkBuffer src,
VkBuffer dst,
std::vector<VkBufferCopy> operations
);
void copy(
VkBuffer src,
VkImage dst,
VkImageLayout dst_layout,
std::vector<VkBufferImageCopy> operations
);
void copy(
VkImage src,
VkBuffer dst,
VkImageLayout src_layout,
std::vector<VkBufferImageCopy> operations
);
void copy(
VkImage src,
VkImageLayout src_layout,
VkImage dst,
VkImageLayout dst_layout,
std::vector<VkImageCopy> operations
);
void blit(
VkImage src,
VkImageLayout src_layout,
VkImage dst,
VkImageLayout dst_layout,
std::vector<VkImageBlit> operations,
VkFilter filter = VK_FILTER_NEAREST
);
VkCommandBuffer end();
~scope_t();
private:
VkCommandBuffer _command_buffer{0};
};
command_buffer_t(
VkDevice device,
VkCommandPool command_pool,
VkCommandBufferLevel level = VK_COMMAND_BUFFER_LEVEL_PRIMARY
);
command_buffer_t(const command_buffer_t&) = delete;
command_buffer_t(command_buffer_t&& other) noexcept;
command_buffer_t& operator=(const command_buffer_t&) = delete;
command_buffer_t& operator=(command_buffer_t&& other) noexcept;
~command_buffer_t();
VkCommandBuffer get();
VkDevice device();
scope_t begin(VkCommandBufferUsageFlags flags);
void reset();
private:
void cleanup();
VkDevice _device;
VkCommandPool _command_pool;
VkCommandBuffer _command_buffer;
};
}
| 33.773256 | 72 | 0.531589 |
pixelwise
|
ec669e2811f8c3832ac24e4ccb6ea55c1716d7e3
| 2,325 |
cpp
|
C++
|
leetcode/stack and queue/Implement Stack using Queues225/Implement Stack using Queues/Implement Stack using Queues/main.cpp
|
mingyuefly/leetcode
|
b1af0b715ac6ef15a1321057bbd9e6f8bddbbcf8
|
[
"MIT"
] | null | null | null |
leetcode/stack and queue/Implement Stack using Queues225/Implement Stack using Queues/Implement Stack using Queues/main.cpp
|
mingyuefly/leetcode
|
b1af0b715ac6ef15a1321057bbd9e6f8bddbbcf8
|
[
"MIT"
] | null | null | null |
leetcode/stack and queue/Implement Stack using Queues225/Implement Stack using Queues/Implement Stack using Queues/main.cpp
|
mingyuefly/leetcode
|
b1af0b715ac6ef15a1321057bbd9e6f8bddbbcf8
|
[
"MIT"
] | null | null | null |
//
// main.cpp
// Implement Stack using Queues
//
/**
Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.
pop() -- Removes the element on top of the stack.
top() -- Get the top element.
empty() -- Return whether the stack is empty.
Example:
MyStack stack = new MyStack();
stack.push(1);
stack.push(2);
stack.top(); // returns 2
stack.pop(); // returns 2
stack.empty(); // returns false
Notes:
You must use only standard operations of a queue -- which means only push to back, peek/pop from front, size, and is empty operations are valid.
Depending on your language, queue may not be supported natively. You may simulate a queue by using a list or deque (double-ended queue), as long as you use only standard operations of a queue.
You may assume that all operations are valid (for example, no pop or top operations will be called on an empty stack).
*/
// Created by mingyue on 2020/8/8.
// Copyright © 2020 Gmingyue. All rights reserved.
//
#include <iostream>
#include <queue>
using namespace std;
class MyStack {
public:
/** Initialize your data structure here. */
queue<int> queueOne;
queue<int> queueTwo;
//queue<int> queueThree;
MyStack() {
}
/** Push element x onto stack. */
void push(int x) {
queueOne.push(x);
}
/** Removes the element on top of the stack and returns that element. */
int pop() {
int result = queueOne.back();
while (queueOne.size() != 1) {
queueTwo.push(queueOne.front());
queueOne.pop();
}
queueOne.pop();
swap(queueOne, queueTwo);
return result;
}
/** Get the top element. */
int top() {
return queueOne.back();;
}
/** Returns whether the stack is empty. */
bool empty() {
return queueOne.empty();
}
};
int main(int argc, const char * argv[]) {
MyStack stack = MyStack();
stack.push(1);
stack.push(2);
int top = stack.top(); // returns 2
cout << top << endl;
int pop = stack.pop(); // returns 2
cout << pop << endl;
bool empty = stack.empty(); // returns false
if (empty) {
cout << "empty" << endl;
} else {
cout << "not empty" << endl;
}
return 0;
}
| 25.833333 | 193 | 0.603011 |
mingyuefly
|
ec69358fa56dcbd1b4a63769bb58639a33809df3
| 762 |
hpp
|
C++
|
matlab/src/bits/nnsimpooling.hpp
|
taigw/matconvnet-dermoscopy
|
14429a9f66a116cabafaae252f23bd88f0b910a5
|
[
"BSD-2-Clause"
] | 39 |
2017-06-15T19:34:26.000Z
|
2021-12-10T23:25:13.000Z
|
matlab/src/bits/nnsimpooling.hpp
|
taigw/matconvnet-dermoscopy
|
14429a9f66a116cabafaae252f23bd88f0b910a5
|
[
"BSD-2-Clause"
] | 2 |
2018-06-05T20:34:50.000Z
|
2019-02-10T19:35:21.000Z
|
matlab/src/bits/nnsimpooling.hpp
|
igondia/matconvnet-dermoscopy
|
038cc2f023d464520517ca6a5fedf95bc09a9edc
|
[
"BSD-2-Clause"
] | 21 |
2017-06-02T13:00:12.000Z
|
2021-01-02T11:14:42.000Z
|
// @file nnpooling.hpp
// @brief Pooling block
// @author Andrea Vedaldi
/*
Copyright (C) 2014-16 Andrea Vedaldi and Karel Lenc.
All rights reserved.
This file is part of the VLFeat library and is made available under
the terms of the BSD license (see the COPYING file).
*/
#ifndef __vl__nnsimpooling__
#define __vl__nnsimpooling__
#include "data.hpp"
#include <stdio.h>
namespace vl {
vl::ErrorCode
nnsimpooling_forward(vl::Context& context,
vl::Tensor output,
vl::Tensor data) ;
vl::ErrorCode
nnsimpooling_backward(vl::Context& context,
vl::Tensor derData,
vl::Tensor data,
vl::Tensor derOutput) ;
}
#endif /* defined(__vl__nnpooling__) */
| 21.771429 | 67 | 0.641732 |
taigw
|
ec6dac3adc0af9a1ab1733e9ef7655065611ac44
| 6,494 |
cpp
|
C++
|
utils/TauReflectionGenerator/src/reflection/attribs/GetAttribute.cpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | 1 |
2020-04-22T04:07:01.000Z
|
2020-04-22T04:07:01.000Z
|
utils/TauReflectionGenerator/src/reflection/attribs/GetAttribute.cpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | null | null | null |
utils/TauReflectionGenerator/src/reflection/attribs/GetAttribute.cpp
|
hyfloac/TauEngine
|
1559b2a6e6d1887b8ee02932fe0aa6e5b9d5652c
|
[
"MIT"
] | null | null | null |
#include <llvm/Support/raw_ostream.h>
#include "reflection/attribs/GetAttribute.hpp"
#include "reflection/Class.hpp"
namespace tau { namespace reflection { namespace attribs {
AttributeData GetPropertyAttribute::parseAttribute(const DynString& attribName, const ::clang::MacroArgs*, const ::clang::Token*& currentToken) const noexcept
{
currentToken = getNextToken(currentToken);
return AttributeData(this, nullptr, attribName);
}
void GetPropertyAttribute::generateBaseTauClass(::llvm::raw_fd_ostream& base) const noexcept
{
base <<
"public:\n"
" template<typename _T>\n"
" [[nodiscard]] const _T* getProperty(const void* const object, const char* const propName) const noexcept\n"
" { return reinterpret_cast<const _T*>(_getProperty(object, propName)); }\n"
"\n"
" template<typename _T>\n"
" [[nodiscard]] const _T* getProperty(const void* const object, const int propIndex) const noexcept\n"
" { return reinterpret_cast<const _T*>(_getProperty(object, propIndex)); }\n"
"protected:\n"
" [[nodiscard]] virtual const void* _getProperty(const void* object, const char* propName) const noexcept = 0;\n"
" [[nodiscard]] virtual const void* _getProperty(const void* object, unsigned propIndex) const noexcept = 0;\n";
}
void GetPropertyAttribute::generateImplTauClass(::llvm::raw_fd_ostream& base, const Ref<Class>& clazz) const noexcept
{
base <<
" public: \\\n"
" template<typename _T> \\\n"
" [[nodiscard]] const _T* getProperty(const " << clazz->name() << "* const object, const char* const propName) const noexcept \\\n"
" { return reinterpret_cast<const _T*>(getPropertyImpl(object, propName)); } \\\n"
" \\\n"
" template<typename _T> \\\n"
" [[nodiscard]] const _T* getProperty(const " << clazz->name() << "* const object, const unsigned propIndex) const noexcept \\\n"
" { return reinterpret_cast<const _T*>(getPropertyImpl(object, propIndex)); } \\\n"
" protected: \\\n"
" [[nodiscard]] const void* _getProperty(const void* const object, const char* const propName) const noexcept override \\\n"
" { return getPropertyImpl(reinterpret_cast<const " << clazz->name() << "*>(object), propName); } \\\n"
" \\\n"
" [[nodiscard]] const void* _getProperty(const void* const object, const unsigned propIndex) const noexcept override \\\n"
" { return getPropertyImpl(reinterpret_cast<const " << clazz->name() << "*>(object), propIndex); } \\\n"
" \\\n"
" [[nodiscard]] const void* getPropertyImpl(const " << clazz->name() << "* const object, const char* const propName) const noexcept \\\n"
" { \\\n";
for(uSys i = 0; i < clazz->properties().size(); ++i)
{
if(!clazz->properties()[i]->declaration()->hasAttribute("get"))
{ continue; }
base <<
" if(::std::strcmp(propName, \"" << clazz->properties()[i]->name() << "\") == 0) \\\n"
" { return &object->" << clazz->properties()[i]->name() << "; } \\\n";
}
base <<
" return nullptr; \\\n"
" } \\\n"
" \\\n"
" [[nodiscard]] const void* getPropertyImpl(const " << clazz->name() << "* const object, const unsigned propIndex) const noexcept \\\n"
" { \\\n"
" switch(propIndex) \\\n"
" { \\\n";
for(uSys i = 0; i < clazz->properties().size(); ++i)
{
if(!clazz->properties()[i]->declaration()->hasAttribute("get"))
{ continue; }
base <<
" case " << i << ": return &object->" << clazz->properties()[i]->name() << "; \\\n";
}
base <<
" default: return nullptr; \\\n"
" } \\\n"
" } \\\n";
}
} } }
| 74.643678 | 158 | 0.345088 |
hyfloac
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.