blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
2
247
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
4
111
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringlengths
4
58
visit_date
timestamp[ns]date
2015-07-25 18:16:41
2023-09-06 10:45:08
revision_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
committer_date
timestamp[ns]date
1970-01-14 14:03:36
2023-09-06 06:22:19
github_id
int64
3.89k
689M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
25 values
gha_event_created_at
timestamp[ns]date
2012-06-07 00:51:45
2023-09-14 21:58:52
gha_created_at
timestamp[ns]date
2008-03-27 23:40:48
2023-08-24 19:49:39
gha_language
stringclasses
159 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
7
10.5M
extension
stringclasses
111 values
filename
stringlengths
1
195
text
stringlengths
7
10.5M
69ae358a872c1f89524f12b33710e1ded23ffa05
efea68eccbac678f5ad78cc14f0b8cbac3109ee7
/Week2i/array/pdf/maximum reapting element.cpp
620cc44643134dc4b8bb5f68a700bb78b10174f5
[]
no_license
indraraj844/ipmp1921Week2
dc2795a6f8f4b6f8742f1a972f895149c2831aef
3003ff0cc6fa7f61601369b4ee6ca51f43cbc4ca
refs/heads/main
2023-04-21T11:02:35.613765
2021-04-20T03:24:46
2021-04-20T03:24:46
355,276,970
0
0
null
null
null
null
UTF-8
C++
false
false
443
cpp
maximum reapting element.cpp
#include<bits/stdc++.h> using namespace std; void find_majority(int arr[],int n) { int k=10000; for(int i=0;i<n;i++) { arr[arr[i]%k]+=k; } int max_index=0; for(int i=1;i<n;i++) { if(arr[i]>arr[max_index]) max_index=i; } cout<<arr[max_index]%k<<" is max reapeted element"; } int main() { int arr[7]={2,3,2,1,2,2,8,}; int n=7; find_majority(arr,n); }
9aeecf8aa67a2db55a3eff5c44393f7d4b134dc7
2e681135562c2b9148947526e3d16ed42815cee0
/Texto.h
1f1149adf7a41f1fa2f0765ea4d9184dccaa9351
[]
no_license
Hackables44/TareaProgramadaII
787aa5d5156f1efadae96b3dee6adc1abf0fb8c1
14634e54ae9afde942e1691b99ac2eb278c8c1f7
refs/heads/master
2020-03-19T08:37:38.459809
2018-06-10T16:13:24
2018-06-10T16:13:24
131,327,925
0
0
null
null
null
null
UTF-8
C++
false
false
1,356
h
Texto.h
//Texto.h Cabecera de la clase Texto #ifndef _TEXTO_H #define _TEXTO_H // clases que utilizará #include "Diccionario.h" //#include "Palabra.h" #include "string" #include <fstream> class Texto{ private: Diccionario * diccionarioPtr; // puntero al diccionario que utilizará int cantidadPalabras; // almacenará temporalmente la cantidad de palabras que forman un hashtag //ofstream salida("Hashtags.csv"); /** lo siguiente se usará para simular si alguna palabra está en diccionario */ string * vPalabras; int length; /** length del vector */ public: // constructor por omisión Texto(); // constructor con parámetro Texto(Diccionario * diccionarioPtr); // constructor por copia Texto(Texto & otro); // destructor ~Texto(); //Palabra & operator[](int i); // devuelve la palabra en la posición indicada int getTamanyo(); // devuelve la cantidad de palabras que forman al hashtag void splitHashtag(string hashtag/*, ofstream & salida*/); // pasa los parámetros al métod para dividir el hashtag void splitHashtagR(string hashtag, string divisionesH, string fragmentoH, int indice/*, ofstream & salida*/, int iteracion); // // divide el hashtag int operator[](string palabra); /** simulador de diccionario, busca en el vector de strings las palabras */ }; #endif
36f2dcbd0b4a7dfa686a43b0fdbc14978b29e5b9
7046d581da4fddbb931343dbeba74654b30ae15b
/include/tailor/certVerify.h
b0471cd903250415c33c7b8f6847f01cc2712201
[ "MIT" ]
permissive
Adennan/Tailor-tls
8ddb56c713e5c81eb1e2829eceaa31fd19e866dc
2d24cb016a26f13ffa9627a193bc8177489f1a7f
refs/heads/main
2023-03-23T12:34:02.878820
2021-03-22T10:27:55
2021-03-22T10:27:55
348,375,095
0
0
null
null
null
null
UTF-8
C++
false
false
667
h
certVerify.h
#ifndef CERT_VERIFY_H #define CERT_VERIFY_H #include "handshake.h" #include "types.h" #include <cstdint> #include <string> #include <iostream> #include <openssl/x509.h> namespace tailor { class CertVerify : public Handshake { private: x509::sign_algo _sign_algo; std::basic_string<uint8_t> sign; public: virtual HandshakeType type() const override { return handshakeCertificatedVerify; } virtual size_t serialize(std::basic_ostringstream<uint8_t>&) override; virtual void deserialize(std::basic_istringstream<uint8_t>&) override; virtual size_t size() const override; } } #endif // CERT_VERIFY_H
5748e88887c94a1dcf0cdd6a743a01a465249791
3c7c200fa7b0bcf50bd099b0081bd7e3332b638d
/src/UI.cpp
5c9f718631903c5e1b5f8623118c8933cffdcf25
[]
no_license
dushan42/thegrid
edd2d3568e16b4708b629247220f765922565aa2
cb17b142002763b2d9116f857d75a40a632f0db5
refs/heads/master
2022-07-01T00:34:52.665219
2013-02-14T20:56:39
2013-02-14T20:56:39
8,106,338
0
0
null
null
null
null
UTF-8
C++
false
false
8,884
cpp
UI.cpp
#include "UI.h" #include "OpenGL.h" #include "Font.h" #include "Texture.h" #include <SDL.h> static GLuint g_texture = 0; static int g_xMouse = 0; static int g_yMouse = 0; static int g_hotItem = 0; static int g_activeItem = 0; static int g_mouseButton[3] = { 0, 0, 0 }; static char g_charEvent = 0; static int g_keyEvent = 0; static int g_mousePressed[3] = { 0, 0, 0 }; /* Mouse was pressed since the last frame */ void UI_CharacterEvent(char c) { g_charEvent = c; } void UI_KeyEvent(int key) { g_keyEvent = key; } void UI_Begin(GLuint texture, int xSize, int ySize) { Uint8 buttons; int i; g_texture = texture; SDL_Surface* surface; surface = SDL_GetVideoSurface(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0.0f, xSize, ySize, 0.0f); buttons = SDL_GetMouseState(&g_xMouse, &g_yMouse); for (i = 0; i < 3; ++i) { int prev = g_mouseButton[i]; g_mouseButton[i] = buttons & SDL_BUTTON(i + 1); g_mousePressed[i] = !prev && g_mouseButton[i]; } g_xMouse = g_xMouse * xSize / surface->w; g_yMouse = g_yMouse * ySize / surface->h; g_hotItem = 0; } void UI_End() { glMatrixMode(GL_PROJECTION); glPopMatrix(); g_charEvent = 0; g_keyEvent = 0; } int UI_GetIsMouseInside(int x, int y, int xSize, int ySize) { return g_xMouse >= x && g_yMouse >= y && g_xMouse < x + xSize && g_yMouse < y + ySize; } void UI_DrawBox(int x, int y, int xSize, int ySize, int u, int v, int uSize, int vSize, int he, int ve) { /* +---+-------+---+ | 1 | 5 | 2 | +---+-------+---+ | | | | | 8 | 9 | 6 | | | | | +---+-------+---+ | 4 | 7 | 3 | +-----------+---+ */ const float xTexSize = 256.0; const float yTexSize = 256.0; float u1, v1, u2, v2; u1 = u / 256.0f; v1 = v / 256.0f; u2 = u1 + uSize / 256.0f; v2 = v1 + vSize / 256.0f; glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); /* Region 1 */ glTexCoord2f(u / xTexSize, v / xTexSize); glVertex2i(x, y); glTexCoord2f((u + he) / xTexSize, v / xTexSize); glVertex2i(x + he, y); glTexCoord2f((u + he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + he, y + ve); glTexCoord2f(u / xTexSize, (v + ve) / xTexSize); glVertex2i(x, y + ve); /* Region 2 */ glTexCoord2f((u + uSize - he) / xTexSize, v / xTexSize); glVertex2i(x + xSize - he, y); glTexCoord2f((u + uSize) / xTexSize, v / xTexSize); glVertex2i(x + xSize, y); glTexCoord2f((u + uSize) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + xSize, y + ve); glTexCoord2f((u + uSize - he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + xSize - he, y + ve); /* Region 3 */ glTexCoord2f((u + uSize - he) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + xSize - he, y + ySize - ve); glTexCoord2f((u + uSize) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + xSize, y + ySize - ve); glTexCoord2f((u + uSize) / xTexSize, (v + vSize) / xTexSize); glVertex2i(x + xSize, y + ySize); glTexCoord2f((u + uSize - he) / xTexSize, (v + vSize) / xTexSize); glVertex2i(x + xSize - he, y + ySize); /* Region 4 */ glTexCoord2f(u / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x, y + ySize - ve); glTexCoord2f((u + he) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + he, y + ySize - ve); glTexCoord2f((u + he) / xTexSize, (v + vSize) / xTexSize); glVertex2i(x + he, y + ySize); glTexCoord2f(u / xTexSize, (v + vSize) / xTexSize); glVertex2i(x, y + ySize); /* Region 5 */ glTexCoord2f((u + he) / xTexSize, v / xTexSize); glVertex2i(x + he, y); glTexCoord2f((u + uSize - he) / xTexSize, v / xTexSize); glVertex2i(x + xSize - he, y); glTexCoord2f((u + uSize - he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + xSize - he, y + ve); glTexCoord2f((u + he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + he, y + ve); /* Region 6 */ glTexCoord2f((u + uSize - he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + xSize - he, y + ve); glTexCoord2f((u + uSize) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + xSize, y + ve); glTexCoord2f((u + uSize) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + xSize, y + ySize - ve); glTexCoord2f((u + uSize - he) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + xSize - he, y + ySize - ve); /* Region 7 */ glTexCoord2f((u + he) / xTexSize, (v + vSize - he) / xTexSize); glVertex2i(x + he, y + ySize - ve); glTexCoord2f((u + uSize - he) / xTexSize, (v + vSize - he) / xTexSize); glVertex2i(x + xSize - he, y + ySize - ve); glTexCoord2f((u + uSize - he) / xTexSize, (v + vSize) / xTexSize); glVertex2i(x + xSize - he, y + ySize); glTexCoord2f((u + he) / xTexSize, (v + vSize) / xTexSize); glVertex2i(x + he, y + ySize); /* Region 8 */ glTexCoord2f(u / xTexSize, (v + ve) / xTexSize); glVertex2i(x, y + ve); glTexCoord2f((u + he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + he, y + ve); glTexCoord2f((u + he) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + he, y + ySize - ve); glTexCoord2f(u / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x, y + ySize - ve); /* Region 9 */ glTexCoord2f((u + he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + he, y + ve); glTexCoord2f((u + uSize - he) / xTexSize, (v + ve) / xTexSize); glVertex2i(x + xSize - he, y + ve); glTexCoord2f((u + uSize - he) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + xSize - he, y + ySize - ve); glTexCoord2f((u + he) / xTexSize, (v + vSize - ve) / xTexSize); glVertex2i(x + he, y + ySize - ve); glEnd(); } void UI_HandleFocus(int id, int x, int y, int xSize, int ySize) { if (UI_GetIsMouseInside(x, y, xSize, ySize)) { g_hotItem = id; if (g_mousePressed[0]) { g_activeItem = id; } } } int UI_Button(int id, const Font& font, int x, int y, int xSize, int ySize, const char* label) { int textWidth, textHeight; int textOffset; int v = 0; textWidth = Font_GetTextWidth(font, label); textHeight = Font_GetTextHeight(font); UI_HandleFocus(id, x, y, xSize, ySize); if (g_hotItem == id) { if (g_activeItem == id) { v = 32; } else { v = 16; } } else { v = 0; } glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, g_texture); UI_DrawBox(x, y, xSize, ySize, 0, v, 16, 16, 3, 3); Font_BeginDrawing(font); textOffset = g_activeItem == id ? 1 : 0; glColor3f(0.25f, 0.25f, 0.25f); Font_DrawText(label, x + (xSize - textWidth) / 2 + 1 + textOffset, y + (ySize - textHeight) / 2 + 1 + textOffset); glColor3f(1, 1, 1); Font_DrawText(label, x + (xSize - textWidth) / 2 + textOffset, y + (ySize - textHeight) / 2 + textOffset); Font_EndDrawing(); if (!g_mouseButton[0] && g_activeItem == id) { g_activeItem = 0; if (g_hotItem == id) { return 1; } } return 0; } void UI_TextBox(int id, const Font& font, int x, int y, int xSize, int ySize, char* text, size_t maxLength) { int textHeight; int cursorPos; size_t length; length = strlen(text); textHeight = Font_GetTextHeight(font); UI_HandleFocus(id, x, y, xSize, ySize); if (g_activeItem == id) { Uint8* keyState = SDL_GetKeyState(NULL); if (g_charEvent != 0 && length < maxLength) { text[length] = g_charEvent; text[length + 1] = 0; ++length; } else if (g_keyEvent == SDLK_BACKSPACE) { if (length > 0) { text[length - 1] = 0; --length; } } } glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, g_texture); UI_DrawBox(x, y, xSize, ySize, 0, 48, 16, 16, 3, 3); Font_BeginDrawing(font); glColor3f(1.0f, 1.0f, 1.0f); cursorPos = Font_DrawText(text, x + 5, y + (ySize - textHeight) / 2); if (g_activeItem == id) { if ((SDL_GetTicks() % 800) < 400) { Font_DrawText("_", cursorPos, y + (ySize - textHeight) / 2); } } Font_EndDrawing(); } void UI_Label(const Font& font, int x, int y, int xSize, int ySize, const char* text) { glColor3f(1.0f, 1.0f, 1.0f); Font_BeginDrawing(font); Font_DrawText(text, x, y); Font_EndDrawing(); }
142049a6b47484e0d4058a69130ef81ff4a7dbd4
ae92a9930a03e7283039c9ce0f7cd809a205f859
/Musume/SimplePortrait.h
0941a978fb2a6ba24ddf372d829f37ccbca41492
[]
no_license
Warhammer4000/OpenGLMusume
07f4d4659d60367e78fe0927a45969b7e1b5beeb
5c9550187a47e2707c019a9272d72ac6b99a4d35
refs/heads/master
2020-12-31T04:55:38.901585
2016-12-28T01:09:21
2016-12-28T01:09:21
76,187,669
0
0
null
null
null
null
UTF-8
C++
false
false
87
h
SimplePortrait.h
#pragma once class SimplePortrait { public: SimplePortrait(); ~SimplePortrait(); };
a7f23790b0a19db5c9ca467f3952a1414f39f9d9
f015d2b8264dfd2b45349a7a421dbec5375d462f
/test.cpp
0dc7165f6eb4a66d9a5e8460312bdccd53e1b82f
[]
no_license
Request2609/codeOfPractice
b8ab9f36a2e7ebd435645868f71ede0bd9875056
5226ff6616272f83423780209cb2dfe43c77527a
refs/heads/master
2021-07-12T17:25:28.637166
2020-09-20T14:44:20
2020-09-20T14:44:20
199,008,203
5
2
null
null
null
null
UTF-8
C++
false
false
1,264
cpp
test.cpp
#include <iostream> #include <vector> //评测题目: c++ , 给定一个数组和一个数组下标,请根据下标值把数组“对折”一下。 // 如 给定数组: 1,2,3,4,5,6,7,8,9 和下标3. 结果为:7,6,5,4,3,2,1,8,9 // 注意考虑边界条件 void swap(int&num1, int& num2) { int tmp = std::move(num1) ; num1 = std::move(num2) ; num2 = std::move(tmp) ; } void fun( std::vector<int>& array , int index){ int len = array.size(); if(len-1<index) { return ; } int left = index-1; int right = index+1; while(left>=0&&right<len) { swap(array[left], array[right]); left--; right++ ; } if(left<0) { return; } std::vector<int> tmp ; index = left ; for(int i=left+1; i<len; i++) { tmp.push_back(array[i]) ; } for(int i=0; i<=index; i++) { tmp.push_back(array[i]) ; } array = tmp ; } int main() { std::vector<int>ls ; while(1) { int a ; std::cin >>a ; if(a == -1) break ; ls.push_back(a) ; } int index ; std::cin >> index ; fun(ls, index) ; for(int i=0; i<(int)ls.size(); i++) { std::cout << ls[i] << " " ; } std::cout << std::endl ; return 0; }
9589cff07195aace5471684444e083c5a103e51d
4019d98ce38791a4e145c639d48aef5666a3fd5c
/conts/team/buaast19/6/g.cpp
a91dc7a4760818e5ad4011e938280fc4c808d227
[]
no_license
karin0/problems
c099ded507fabc08d5fe6a234d8938575e9628b7
b60ffaa685bbeb4a21cde518919cdd2749086846
refs/heads/master
2023-02-09T21:55:24.678019
2021-01-08T16:46:54
2021-01-08T16:46:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,354
cpp
g.cpp
sort(use,use+n,cmp); for(int i=0,j=1%n;i<n;++i){ while(j!=i and (use[i]^use[j])>=0) j=(j+1)%n; } struct node{ ll x,y; int xx; node(){} node(ll _x,ll _y){ x=_x,y=_y; if(y==0){ if(x>=0)xx=1; else xx=2; }else{ if(y>0)xx=1; else xx=2; } } node operator-(const node&p)const{ return node(x-p.x,y-p.y); } ll operator^(const node&p)const{ return x*p.y-y*p.x; } ll operator*(const node&p)const{ return x*p.x + y*p.y; } }; bool cmp(const node&le,const node&ri){ if(le.xx==ri.xx)return (le^ri)>0; else return le.xx<ri.xx; } #include <cstdio> #include <algorithm> #include <iostream> #include <set> #include <vector> #define rep(i_, s_, t_) for (int i_ = (s_); i_ <= (t_); ++i_) #define re(i_, s_, t_) for (int i_ = (s_); i_ < (t_); ++i_) typedef long long ll; #ifdef AKARI void cca() { std::cerr << "\033[39;0m" << std::endl; } template <typename T, typename... Args> void cca(T a, Args... args) { std::cerr << a << ", "; cca(args...); } #define ccc(args...) std::cerr << "\033[32;1m" << #args << " = ", cca(args) #define ccf(args...) fprintf(stderr, args) #define crep(i_, s_, t_) for (int i_ = (s_); i_ <= (t_); ++i_) #else #define ccc(...) 0 #define ccf(...) 0 #define crep(...) if (0) #endif cint N = 50002; struct Pt { double x, y; Pt() {} Pt(const double x, const double y) : x(x), y(y) {} void read() { int a, b; scanf("%d%d", &a, &b); x = a, y = b; } Pt operator - () const { return Pt(-x, -y); } Pt operator - (const Pt &rhs) const { return Pt(x - rhs.x, y - rhs.y); } Pt operator + (const Pt &rhs) const { return Pt(x + rhs.x, y + rhs.y); } Pt operator * (const double k) const { return Pt(x * k, y * k); } Pt &operator *= (const double k) { return *this = *this * k; } double operator * (const Pt rhs) const { return x * rhs.y - y * rhs.x; } double norm2() const { return x * x + y * y; } double norm() const { return sqrt(norm2()); } Pt normal() const { return Pt(y, -x); } } pts[N]; struct Func { double a, b, c; Func(const Pt &p, const Pt &q) : a(p.y - q.y), b(q.x - p.x), c(p * q) {} double operator () (const Pt &p) const { return fabs(a * p.x + b * p.y + c); } }; /* void say(double x, const char end) { if (x < 0) { io << '-'; x = -x; } int i = x, j = round((x - i) * 10000000); io << i << '.'; if (j) io << j; else io << "0000000"; io << end; } */ inline Pt intersect(const Pt &aa, const Pt &ab, const Pt &ba, const Pt &bb) { double s1 = (ba - aa) * (bb - aa), s2 = (bb - ab) * (ba - ab); return aa + (ab - aa) * (s1 / (s1 + s2)); } int main() { #ifndef AKARI freopen("flags.in", "r", stdin); #endif int T; scanf("%d", &T); rep (ks, 1, T) { printf("Case %d:\n", ks); int n, m; scanf("%d", &n); rep (i, 1, n) pts[i].read(); scanf("%d", &m); while (m--) { Pt p1, p2; p1.read(); p2.read(); double ans = DBL_MAX; Pt ans2; rep (i, 1, n) { const Pt &a = pts[i], &b = pts[i < n ? i + 1 : 1]; const Func f(a, b); double d = f(p1) / sqrt(f.a * f.a + f.b * f.b); const Pt t = a - b; Pt v = t.normal() * (d / t.norm()), v2 = -v; Pt o = p1 + v, o2 = p1 + v2; o = f(o) > f(o2) ? o2 + v2 : o + v; double dis = (o - p2).norm2(); if (dis < ans) { Pt u = intersect(p2, o, a, b); double x1, x2, y1, y2; std::tie(x1, x2) = std::minmax(a.x, b.x); std::tie(y1, y2) = std::minmax(a.y, b.y); if (x1 <= u.x && u.x <= x2 && y1 <= u.y && u.y <= y2) ans = dis, ans2 = u; } } printf("%.7f %.7f %.7f\n", sqrt(ans), ans2.x , ans2.y); } } return 0; }
3760af399ec7f26b3e574280becf37b0b57a5f02
fadd572fac56a74d326bf4b0e64c2d25a3543172
/Tcp_Server_Client/displayform.h
4d7dc46aadbec6ad4604f4e2046be1e7b6654ae5
[]
no_license
XueDee123/QT_Exercise_Tools
d36aec4d9439a34c2ceb55f6a43b0a081c2e7a28
1555e7c5dd699635a95af51acf0e1440b86a9365
refs/heads/master
2023-03-01T01:29:13.163193
2021-01-29T05:28:20
2021-01-29T05:28:20
331,553,207
0
0
null
null
null
null
UTF-8
C++
false
false
741
h
displayform.h
#ifndef DISPLAYFORM_H #define DISPLAYFORM_H #include <QWidget> #include "Parameter.h" namespace Ui { class DisplayForm; } class DisplayForm : public QWidget { Q_OBJECT public: explicit DisplayForm(bool connect=false,QWidget *parent = nullptr); explicit DisplayForm(SocketInfo info,bool connect=false,QWidget *parent = nullptr); ~DisplayForm(); void RecData(QByteArray &data,SocketInfo info); SocketInfo GetInfo(); signals: void sendData(const QByteArray & data,SocketInfo& i); private: Ui::DisplayForm *ui; private: void Init(bool p); private: SocketInfo info; QString recDispData; QString sendDispData; long long recDataNum; long long sendDataNum; }; #endif // DISPLAYFORM_H
250a1eb2ab59118abf5c84c67557e2312e8a77da
b42e741cc8934423c3b681447cd5d9a9c8e00ce7
/string v4.0/palidrom.cpp
38364240b0007c1e7a7d02bbb47fb964f179b8aa
[]
no_license
wildstrider/kalcul
8730514fe1eee5ae47e68369873499d325f0c323
dac62066d40c90793fff6ddd6c9b2895fe01df30
refs/heads/master
2023-04-12T14:54:33.928588
2021-04-11T14:49:39
2021-04-11T14:49:39
356,895,388
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
196
cpp
palidrom.cpp
#include <iostream> using namespace std; void text(char* t, int s); void main() { string text = "я иду с мечем судия"; int s = text.length(); } void text(char* t, int s) { }
38351a5ce9bfa3d55b66924825a5fb08fcc2fa91
5919d75bbf999847b12e5f0b4f401e3c8f756883
/bmpReader/MyFrameWnd.cpp
46496704cda0ea4c03dee523836a4bec5fcb9fcc
[]
no_license
popelenkow/MyBmpReader
2f46afdbd6dd3cc30c16865684b889d6d1777408
d2c59e191ec3d2fe35b1ea451242d639975f57be
refs/heads/master
2021-01-10T04:37:00.642194
2016-02-23T07:45:00
2016-02-23T07:45:00
51,840,728
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
783
cpp
MyFrameWnd.cpp
// MyFrameWnd.cpp: файл реализации // #include "stdafx.h" #include "bmpReader.h" #include "MyFrameWnd.h" // CMyFrameWnd IMPLEMENT_DYNAMIC(CMyFrameWnd, CWnd) BEGIN_MESSAGE_MAP(CMyFrameWnd, CWnd) ON_WM_PAINT() ON_WM_ERASEBKGND() END_MESSAGE_MAP() CMyFrameWnd::CMyFrameWnd() { } CMyFrameWnd::~CMyFrameWnd() { clean_image(); } // обработчики сообщений CMyFrameWnd void CMyFrameWnd::OnPaint() { CPaintDC dc(this); // контекст устройства для рисования if (image != nullptr) { BITMAPINFO info = image->get_bmp_info(); COLORREF* data = image->get_data(); data += info.bmiHeader.biWidth*pos.y + pos.x; ::SetDIBitsToDevice(dc, 0, 0, dimensions.x, dimensions.y, 0, 0, 0, dimensions.x, data, &info, 0); } }
69cbd3593268509ed82128c05e05d5d330089bba
fccf42a949aaf0f6d756120c70c7aace514c7011
/FreightSimulator/FreightSimulator/State.hpp
eee5c2b6435ee78653c5005679095c3d15117d64
[]
no_license
gcbh/ACO-platooning
f9126e4b233a1c7111320981b6eadf8a394d3c3b
b1dc618fb11696c2623ccacaa48a262e7c56471c
refs/heads/master
2020-03-09T03:52:42.701586
2018-04-07T23:09:41
2018-04-07T23:09:41
128,574,825
0
0
null
2018-04-07T23:09:42
2018-04-07T22:46:34
C++
UTF-8
C++
false
false
1,183
hpp
State.hpp
// // RenderState.hpp // FreightSimulator // // Created by Sean Amadio on 2017-07-05. // Copyright © 2017 FYDP. All rights reserved. // #ifndef RenderState_hpp #define RenderState_hpp #include "imgui.h" #include "imgui_impl_glfw_gl3.h" #include <stdio.h> #include <map> #include <GLFW/glfw3.h> #include "glm.hpp" enum class CityMode : int { None, Default }; enum class CityLabelMode : int { None, Name, ID, NameAndID }; enum class RoadMode : int { None, Default, StaticHeat, Distance }; enum class TruckType : int { Dijkstra, ACO }; struct InputState { GLFWwindow *window; double deltaTime; }; struct UpdateState { double deltaTime; float sim_time; float sim_time_scale; }; struct RenderState { // Rendering GLFWwindow *window; glm::mat4 mvp; ImVec2 screen_size; // Rendering Modes CityMode cityMode; CityLabelMode cityLabelMode; RoadMode roadMode; TruckType truckMode; std::map<int, float> *aco_static_heatmap; std::map<int, float> *dijkstra_static_heatmap; // Sim Info float sim_time; float sim_time_scale; }; #endif /* RenderState_hpp */
3e64f1343247d29262855a3ac9dde50042b73156
cab2a22409d1a98802ca4918fd9629563ed4d276
/dc/core/WallWindow.h
6dd241a22f0a2c566ee9532a43ec8bf6fa2c15ac
[ "BSD-2-Clause" ]
permissive
BlueBrain/DisplayCluster
4cff0a5b65cb89b2bfb1afe729ec544203ca6ecb
6daed7a1009b75048cf82591ff4c4323fe48f514
refs/heads/master
2021-01-17T22:04:07.060487
2016-04-07T11:34:04
2016-04-07T11:34:04
10,027,845
6
5
null
2016-04-15T12:50:50
2013-05-13T08:48:40
C++
UTF-8
C++
false
false
4,128
h
WallWindow.h
/*********************************************************************/ /* Copyright (c) 2015, EPFL/Blue Brain Project */ /* Raphael Dumusc <raphael.dumusc@epfl.ch> */ /* 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. */ /* */ /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ /* AUSTIN ``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 UNIVERSITY OF TEXAS AT */ /* AUSTIN 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. */ /* */ /* The views and conclusions contained in the software and */ /* documentation are those of the authors and should not be */ /* interpreted as representing official policies, either expressed */ /* or implied, of The University of Texas at Austin. */ /*********************************************************************/ #ifndef WALLWINDOW_H #define WALLWINDOW_H #include "types.h" #include "FpsRenderer.h" #include <QGraphicsView> class WallWindow : public QGraphicsView { Q_OBJECT public: /** * Constructor. * @param scene The scene to display. * @param sceneRect The portion of the scene to display in pixels. * The window is also sized accordingly. */ WallWindow( QGraphicsScene* scene, const QRect& sceneRect ); /** Set the test pattern. */ void setTestPattern( TestPatternPtr testPattern ); /** Get the test pattern */ TestPatternPtr getTestPattern(); /** Show or hide the fps counter. */ void setShowFps( bool value ); /** Block all the update() and repaint() calls. */ void setBlockDrawCalls( bool enable ); /** Disable VSync on this window for the next swapBuffer() call. */ void disableVSync(); /** Check if the window is exposed in the window system. */ bool isExposed() const; private: /** Reimplemented from QGraphicsView to draw the test pattern */ void drawForeground( QPainter* painter, const QRectF& rect ) override; /** Reimplemented from QGraphicsView to block unsolicited draw calls. */ void paintEvent( QPaintEvent* event ) override; TestPatternPtr testPattern_; FpsRenderer fpsRenderer_; bool blockUpdates_; bool isExposed_; }; #endif // WALLWINDOW_H
661fe44fe4132131e5115e3d163e2e5408138b36
05db8a70a2134afc5c830b7f2af779647f643202
/src/manager/EzyAppManager.h
49bf65588ebb65ba1a5c892c968fa5db11260693
[]
no_license
youngmonkeys/ezyfox-server-cpp-client
a97699cb6494380e75d86c86ee4493471f52f986
1d55695eaaf855b01464604cd205ae6861e1bbf2
refs/heads/master
2023-07-21T19:36:32.775174
2023-07-09T06:58:55
2023-07-09T06:58:55
112,422,375
6
6
null
2023-07-10T15:02:37
2017-11-29T03:36:27
C++
UTF-8
C++
false
false
793
h
EzyAppManager.h
#ifndef EzyAppManager_h #define EzyAppManager_h #include <map> #include <vector> #include <string> #include "../EzyMacro.h" EZY_NAMESPACE_START_WITH_ONLY(entity) class EzyApp; EZY_NAMESPACE_END_WITH EZY_NAMESPACE_START_WITH(manager) class EzyAppManager { protected: std::vector<entity::EzyApp*> mAppList; std::map<int, entity::EzyApp*> mAppByIds; std::map<std::string, entity::EzyApp*> mAppByNames; public: EzyAppManager(); ~EzyAppManager(); void clear(); void addApp(entity::EzyApp* app); entity::EzyApp* removeApp(int appId); entity::EzyApp* getApp(); std::vector<entity::EzyApp*> getApps(); entity::EzyApp* getAppById(int appId); entity::EzyApp* getAppByName(std::string appName); }; EZY_NAMESPACE_END_WITH #endif /* EzyAppManager_h */
2941782e2a016c56744a9d3249648844f2c37271
cec143902e7187dccb6219ab753864c87b7225ee
/src/graphics/primitives.h
ef7f463552b068c9b4394d7fdaa6f4fdce0e1b47
[]
no_license
higgipoker/gamelib
ad4f0b3ee1627dc5a94572439c46247f1f5383dd
5abae6a0be08e9a90a23330f37a32c0fc3fac255
refs/heads/master
2021-01-01T17:48:31.306907
2018-07-05T18:47:41
2018-07-05T18:47:41
98,159,773
0
0
null
null
null
null
UTF-8
C++
false
false
1,550
h
primitives.h
#pragma once #include "../math/shapes.h" #include "../math/vector3.h" #include "color.h" #include "window.h" namespace GameLib { // ************************************************************ // TODO: primitives do not take account of viewport for HUD elements!!! // ************************************************************ /** * @brief The Primitives class */ class Primitives { public: static void Circle(Window &target, unsigned int x, unsigned int y, unsigned int radius); static void Triangle(Window &target, unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, unsigned int x3, unsigned int y3); static void Rectangle(Window &target, unsigned int x, unsigned int y, unsigned int w, unsigned int h); static void Lines(Window &target, const std::vector<Line> &lines, unsigned int thickness = 1); static void DrawLine(Window &target, const Vector3 &point1, const Vector3 &point2, unsigned int thickness = 1); static void Arc(Window &target, float x, float y, float radius, float start, float end, unsigned int segments, unsigned int thickness); static void OutlineColor(const Color &c); static void FillColor(const Color &c); static void RestoreColors(); private: static Color outline_color; static Color fill_color; static Color last_outline_color; static Color last_fill_color; }; } // GameLib
5fe2861767ee163f78dc0ce69ac71bb5e13eab67
42c5f229c9e5d843730779e325f9df02ad119d24
/MouseController.h
02c2dc878590dec907645922f514ac2b4a5f4177
[]
no_license
keshoujing/MineSweeper
823b541cdc469a27ab496222a19e93e35e4beabc
73514c3f3deb21a963cffe5c9976ff9dd9f38ce1
refs/heads/main
2023-08-31T16:16:38.095613
2021-10-24T23:33:15
2021-10-24T23:33:15
null
0
0
null
null
null
null
UTF-8
C++
false
false
544
h
MouseController.h
#ifndef MAIN_CPP_MouseManager_H #define MAIN_CPP_MouseManager_H #include <iostream> #include <SFML/Graphics.hpp> #include "logicController.h" using namespace std; class MouseController { static sf::Vector2<float> position; public: static void leftClicked(sf::RenderWindow &window, sf::Mouse mouse); static void rightClicked(sf::RenderWindow &window, sf::Mouse mouse); //static void setPosition(sf::RenderWindow &window, sf::Mouse mouse); //static sf::Vector2<float> getPosition(); }; #endif
aafbb351a0585ab42bc3e3f76e22e0b0ab699bce
0b26358f214df46483ed4c95f36227bdc515dd5f
/cf/526/a.cpp
736e041b0f11605695b47e4d4c5bd3b333509716
[]
no_license
ghost1998/codes
884d282275ea555e6126588ba5587782df3be031
84c656072ba542e2d07a3d0808493032ee3cf1d3
refs/heads/master
2020-04-25T14:26:04.683766
2019-02-27T04:11:00
2019-02-27T04:11:00
172,841,246
0
0
null
null
null
null
UTF-8
C++
false
false
462
cpp
a.cpp
#include <bits/stdc++.h> using namespace std; int main() { long int n; cin>>n; long int ar[n+1]; for(int i = 0 ; i < n ; i ++) cin>>ar[i]; long int ans = 10000000000; long int temp = ans; long int sum = 0; for(int i = 0 ; i < n ; i++) { temp = 0 ; for(int j = 0 ; j < n ; j++) { if(j<=i) temp += ar[j]*(2*i); if(j>i) temp += ar[j] * (2*j); } ans = min(ans, temp); } std::cout << 2*ans << '\n'; return 0; }
9fb28eda92f3d881d4021b9712f59f3988d4a217
490f20c0e75357d1be5f789f362273f1cdc0cfcb
/RcEngine/RcEngine/Graphics/Material.cpp
f9fbca5c6550ebd5be02f0e37fad6a28a08f7efa
[]
no_license
cgkelei/cg-demos
105639b46caed39127579e61340d25cb29b72a8c
34048efae5dd0f3bf02bcd82881e5398b4fbf0e6
refs/heads/master
2021-01-10T13:34:31.184706
2014-07-25T03:06:01
2014-07-25T03:06:01
48,785,065
0
1
null
null
null
null
UTF-8
C++
false
false
10,029
cpp
Material.cpp
#include <Graphics/Material.h> #include <Graphics/RenderDevice.h> #include <Graphics/RenderFactory.h> #include <Graphics/FrameBuffer.h> #include <Graphics/Camera.h> #include <Graphics/Effect.h> #include <Graphics/GraphicsResource.h> #include <Graphics/TextureResource.h> #include <Graphics/RenderState.h> #include <Graphics/RenderQueue.h> #include <Core/Environment.h> #include <Core/Exception.h> #include <Core/XMLDom.h> #include <Core/Utility.h> #include <Core/Exception.h> #include <IO/FileSystem.h> #include <IO/PathUtil.h> #include <Resource/ResourceManager.h> #include <Graphics/GraphicsScriptLoader.h> namespace { using namespace RcEngine; uint32_t GetRenderQueueBucket(const String& str) { if (str == "Overlay") return RenderQueue::BucketOverlay; else if (str == "Background") return RenderQueue::BucketBackground; else if (str == "Opaque") return RenderQueue::BucketOpaque; else if (str == "Transparent") return RenderQueue::BucketTransparent; else if (str == "Translucent") return RenderQueue::BucketTranslucent; else if (str == "Opaque") return RenderQueue::BucketTransparent; else ENGINE_EXCEPT(Exception::ERR_INVALID_PARAMS, "Undefined Queue Bucket", "GetQueueBucket"); } } namespace RcEngine { Material::Material( ResourceManager* creator, ResourceHandle handle, const String& name, const String& group ) : Resource(RT_Material, creator, handle, name, group) { } Material::~Material(void) { } //shared_ptr<Resource> Material::Clone() //{ // printf("Clone material: %s\n", mMaterialName.c_str()); // // shared_ptr<Material> retVal = std::make_shared<Material>(mCreator, mResourceHandle, mResourceName, mGroup); // // retVal->mMaterialName = mMaterialName; // // retVal->mAmbient = mEmissive; // retVal->mDiffuse = mDiffuse; // retVal->mSpecular = mSpecular; // retVal->mEmissive = mEmissive; // retVal->mPower = mPower; // // retVal->mEffect = std::static_pointer_cast<Effect>(mEffect/*->Clone()*/); // retVal->mTextures = mTextures; // // /*for (MaterialParameter* param : mCachedEffectParams) // { // MaterialParameter* paramCloned = new MaterialParameter; // paramCloned->EffectParam = retVal->mEffect->GetParameterByName(param->Name); // paramCloned->Usage = param->Usage; // paramCloned->IsSemantic = param->IsSemantic; // paramCloned->Name = param->Name; // paramCloned->Type = param->Type; // retVal->mCachedEffectParams.push_back(paramCloned); // }*/ // // retVal->SetLoadState(Resource::Loaded); // // return retVal; //} void Material::SetTexture( const String& name, const shared_ptr<ShaderResourceView>& textureSRV ) { mTextureSRVs[name] = textureSRV; EffectParameter* effectParam = mEffect->GetParameterByName(name); if (effectParam == nullptr) { String errMsg = "Texture " + name + " not exit in Effect" + mEffect->GetResourceName(); ENGINE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, errMsg, "Material::SetTexture"); } effectParam->SetValue(textureSRV); } void Material::LoadImpl() { FileSystem& fileSystem = FileSystem::GetSingleton(); RenderFactory* factory = Environment::GetSingleton().GetRenderFactory(); ResourceManager& resMan = ResourceManager::GetSingleton(); shared_ptr<Stream> matStream = fileSystem.OpenStream(mResourceName, mGroup); Stream& source = *matStream; XMLDoc doc; XMLNodePtr root = doc.Parse(source); // material name mMaterialName = root->AttributeString("name", ""); mMaterialName = mResourceName; // effect first XMLNodePtr effectNode = root->FirstNode("Effect"); String effecFile = effectNode->AttributeString("name", ""); // file name String parentDir = PathUtil::GetPath(mResourceName); String effectResGroup; // Test if a effect exits in the same group as material if( fileSystem.Exits(parentDir + effecFile, mGroup) ) { effectResGroup = mGroup; effecFile = parentDir + effecFile; // Add material resource directory } else effectResGroup = "General"; /* Effect name is unique resource ID, but with the effect shader macro, we can define different effect * with the same file. So the full effect name is the effect file string + shader macro. By this way, * we can distinction effects. */ String effectName = effecFile; for (XMLNodePtr effectFlagNode = effectNode->FirstNode("Flag"); effectFlagNode; effectFlagNode = effectFlagNode->NextSibling("Flag")) { String flag = effectFlagNode->AttributeString("name", ""); effectName += " " + flag; } // load effect mEffect = std::static_pointer_cast<Effect>( resMan.GetResourceByName(RT_Effect, effectName, effectResGroup) ); for (XMLNodePtr paramNode = root->FirstNode("Parameter"); paramNode; paramNode = paramNode->NextSibling("Parameter")) { if (XMLAttributePtr sematicAttrib = paramNode->FirstAttribute("semantic")) { String semantic = sematicAttrib->ValueString(); EffectParameter* effectParam = mEffect->GetParameterByUsage(Internal::EffectParamsUsageDefs::GetInstance().GetUsageType(semantic)); if (effectParam == nullptr) continue; // texture type if (EPT_Texture1D <= effectParam->GetParameterType() && effectParam->GetParameterType() <= EPT_TextureCubeArray) { String texFile = paramNode->AttributeString("value", ""); if (!texFile.empty()) { String resGroup = mGroup; String texturePath = parentDir + texFile; if (fileSystem.Exits(texturePath, mGroup) == false) resGroup = "General"; shared_ptr<TextureResource> textureRes = resMan.GetResourceByName<TextureResource>(RT_Texture, texturePath, mGroup); mMaterialTextureCopys.push_back(textureRes->GetTexture()); SetTexture(effectParam->GetName(), textureRes->GetTexture()->GetShaderResourceView()); } } // Material Color switch (effectParam->GetParameterUsage()) { case EPU_Material_Ambient_Color: { String value = paramNode->AttributeString("value", ""); mAmbient = Internal::StringToFloat3(value); } break; case EPU_Material_Diffuse_Color: { String value = paramNode->AttributeString("value", ""); mDiffuse = Internal::StringToFloat3(value); } break; case EPU_Material_Specular_Color: { String value = paramNode->AttributeString("value", ""); mSpecular = Internal::StringToFloat3(value); } break; case EPU_Material_Emissive_Color: { String value = paramNode->AttributeString("value", ""); mEmissive = Internal::StringToFloat3(value); } break; case EPU_Material_Power: { String value = paramNode->AttributeString("value", ""); std::sscanf(value.c_str(), "%f", &mPower); } break; default: break; } } } // Capture all auto-binding shader parameter for (auto& kv : mEffect->GetParameters()) { EffectParameter* effectParam = kv.second; if (effectParam->GetParameterUsage() != EPU_Unknown) mAutoBindings.push_back(effectParam); } // Parse render queue bucket if (root->FirstNode("Queue")) { String bucket = root->FirstNode("Queue")->AttributeString("name", ""); mQueueBucket = GetRenderQueueBucket(bucket); } } void Material::UnloadImpl() { } shared_ptr<Resource> Material::FactoryFunc( ResourceManager* creator, ResourceHandle handle, const String& name, const String& group ) { return std::make_shared<Material>(creator, handle, name, group); } EffectTechnique* Material::GetCurrentTechnique() const { return mEffect->GetCurrentTechnique(); } void Material::SetCurrentTechnique( const String& techName ) { mEffect->SetCurrentTechnique(techName); } void Material::SetCurrentTechnique( uint32_t index ) { mEffect->SetCurrentTechnique(index); } void Material::ApplyMaterial( const float4x4& world ) { RenderDevice* renderDevice = Environment::GetSingleton().GetRenderDevice(); const shared_ptr<Camera> camera = renderDevice->GetCurrentFrameBuffer()->GetCamera(); for (auto effectParam : mAutoBindings) { switch (effectParam->GetParameterUsage()) { case EPU_WorldMatrix: { effectParam->SetValue(world); } break; case EPU_ViewMatrix: { effectParam->SetValue(camera->GetViewMatrix()); } break; case EPU_ProjectionMatrix: { effectParam->SetValue(camera->GetEngineProjMatrix()); } break; case EPU_WorldViewMatrix: { effectParam->SetValue(world * camera->GetViewMatrix()); } break; case EPU_ViewProjectionMatrix: { effectParam->SetValue(camera->GetEngineViewProjMatrix()); } break; case EPU_WorldViewProjection: { effectParam->SetValue(world * camera->GetEngineViewProjMatrix()); } break; case EPU_WorldInverseTranspose: { effectParam->SetValue(world.Inverse().Transpose()); } break; case EPU_WorldMatrixInverse: { effectParam->SetValue(world.Inverse()); } break; /*case EPU_ViewMatrixInverse: { effectParam->SetValue(camera->GetInvViewMatrix()); } break; case EPU_ProjectionMatrixInverse: { effectParam->SetValue(camera->GetInvProjMatrix()); } break;*/ case EPU_Material_Ambient_Color: { effectParam->SetValue(mAmbient); } break; case EPU_Material_Diffuse_Color: { effectParam->SetValue(mDiffuse); } break; case EPU_Material_Specular_Color: { effectParam->SetValue(mSpecular); } break; case EPU_Material_Power: { effectParam->SetValue(mPower); } break; case EPU_Material_DiffuseMap: case EPU_Material_SpecularMap: case EPU_Material_NormalMap: { effectParam->SetValue(mTextureSRVs[effectParam->GetName()]); } break; case EPU_Camera_Position: { effectParam->SetValue(camera->GetPosition()); } break; default: { } } } } } // Namespace RcEngine
03f2aed7dfb5a34b5ac6c30013b476ace7da3041
819f672546f411a29f655212c3b0d643bc09f309
/Token.cpp
d1d5b9ba68fba5bebbdfb10a3eb902f50f429b9c
[]
no_license
afaucher17/abstract-vm
53141964d88203819545da9ffed32c4daf97cbf5
63540781db6a589ef534bdde655956dfec35b3ee
refs/heads/master
2020-06-20T13:10:55.074506
2016-11-27T02:45:13
2016-11-27T02:45:13
74,862,625
0
0
null
null
null
null
UTF-8
C++
false
false
1,620
cpp
Token.cpp
#include <iostream> #include "Token.hpp" Token::Token( void ) : _value(""), _type(UNKNOWN), _line(0) { return ; } Token::Token( tokenType type , size_t line ) : _value(""), _type(type), _line(line) { return ; } Token::Token( std::string const & value, size_t line) : _value(value), _type(UNKNOWN), _line(line) { return ; } Token::Token( Token const & src ) { *this = src; return ; } Token::~Token( void ) { return ; } Token & Token::operator=(Token const & rhs) { this->_value = rhs._value; this->_type = rhs._type; this->_line = rhs._line; return *this; } std::string Token::getValue( void ) const { return this->_value; } tokenType Token::getType( void ) const { return this->_type; } std::string Token::toString( void ) const { std::stringstream ss; ss << ""; if (this->_type == END_OF_FILE) ss << "end of file"; else if (this->_value.compare("\n") == 0) ss << "end of line"; else if (this->_value.compare("") != 0) ss << this->_value; return ss.str(); } size_t Token::getLine( void ) const { return this->_line; } void Token::setType( tokenType type ) { this->_type = type ; return ; } std::ostream & operator<<(std::ostream & o, Token const & rhs) { o << "{" << rhs.getValue() << "}" << std::endl; o << "Line: " << rhs.getLine() << std::endl; o << Token::tokenTypeName[rhs.getType()]; return o; } const std::string Token::tokenTypeName[] = { "Unknown", "Left Parenthesis", "Right Parenthesis", "Operator", "Value Operator", "Int Precision", "Floating Precision", "Natural Value", "Floating Value", "Separator", "End of File", };
e62858b15d5437d41a27df1e97eb0e33c3537821
db2d4784dd26e7f5b09de5565238b2794a245520
/SPL_CKQ/DlgExtStaDevStatus.cpp
d75127659e195c21e6ce59cfe2d00862d82a54a3
[]
no_license
xsjames/SPLCKQ-11
16daa54c1156491a14221ea5cc7cc18a4d5c7755
6b635ad2a799a7126a4f508c8c0767c05bbb21cb
refs/heads/master
2021-01-02T16:58:54.850962
2018-02-08T09:59:54
2018-02-08T09:59:54
null
0
0
null
null
null
null
GB18030
C++
false
false
3,456
cpp
DlgExtStaDevStatus.cpp
// DlgExtStaStatus.cpp : implementation file // #include "stdafx.h" #include "SPL_CKQ.h" #include "DlgExtStaDevStatus.h" #include "afxdialogex.h" #include "AccessData.h" #include "Tools.h" #include "MainFrm.h" // DlgExtStaStatus dialog IMPLEMENT_DYNAMIC(DlgExtStaDevStatus, CDialogEx) DlgExtStaDevStatus::DlgExtStaDevStatus(CWnd* pParent /*=NULL*/) : CDialogEx(DlgExtStaDevStatus::IDD, pParent) { } DlgExtStaDevStatus::~DlgExtStaDevStatus() { } void DlgExtStaDevStatus::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_EDIT_FILE_1, FileName1); } BEGIN_MESSAGE_MAP(DlgExtStaDevStatus, CDialogEx) ON_BN_CLICKED(IDC_BUTTON_OPEN_1, &DlgExtStaDevStatus::OnBnClickedButtonOpen) ON_BN_CLICKED(IDCANCEL_1, &DlgExtStaDevStatus::OnBnClickedCancel) ON_BN_CLICKED(IDOK_1, &DlgExtStaDevStatus::OnBnClickedOk) END_MESSAGE_MAP() // DlgExtStaStatus message handlers void DlgExtStaDevStatus::OnBnClickedButtonOpen() { // TODO: 在此添加控件通知处理程序代码 UpdateData(); CString OpenFilePathName; CFileDialog dlg(TRUE, NULL, NULL, OFN_NOCHANGEDIR); int nOK = dlg.DoModal(); if (nOK == IDOK) { OpenFilePathName = dlg.GetPathName(); int len = WideCharToMultiByte(CP_ACP, 0, OpenFilePathName, OpenFilePathName.GetLength(), NULL, 0, NULL, NULL); char * pFileName = new char[len + 1]; WideCharToMultiByte(CP_ACP, 0, OpenFilePathName, OpenFilePathName.GetLength(), pFileName, len, NULL, NULL); pFileName[len + 1] = '\0'; FileName1.SetWindowText(OpenFilePathName); /* FILE* fp = NULL; fp = fopen(pFileName, "rb"); fseek(fp,0,SEEK_END); long nLen = ftell(fp); CString strlong; strlong.Format(_T("%d"),nLen);*/ delete[] pFileName; } } BOOL DlgExtStaDevStatus::OnInitDialog() { CMainFrame* pMain = (CMainFrame*)AfxGetApp()->GetMainWnd(); CDialogEx::OnInitDialog(); CAccessData access; CTools tools; int nHang = 0; CString stWhere = _T("ConfigName='STA的设备状态信息'"); CString strData; CString strlist[10]; int nNumb = 0; //if(access.SelectDataFromTable(_T(".\\配置文件\\13762Data.accdb"),_T("Config"),_T("MessageData"),stWhere,&strData,nHang)) if (access.SelectDataFromTable(pMain->m_PeiZhi_db, _T("Config"), _T("MessageData"), stWhere, &strData, nHang)) { tools.Split(strData, _T("☆"), strlist, nNumb); FileName1.SetWindowTextW(strlist[0]); } else { AfxMessageBox(_T("获取数据失败!")); } return TRUE; // return TRUE unless you set the focus to a control } void DlgExtStaDevStatus::OnBnClickedCancel() { // TODO: 在此添加控件通知处理程序代码 CDialogEx::OnCancel(); } void DlgExtStaDevStatus::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 CMainFrame* pMain = (CMainFrame*)AfxGetApp()->GetMainWnd(); if (FileName1.GetWindowTextLengthW() == 0) { AfxMessageBox(_T("请选择保存文件")); return; } CString strlistName[2] = { _T("ConfigName"), _T("MessageData") }; CString strFile; CAccessData access; FileName1.GetWindowTextW(strFile); CString strlistData = strFile + _T("☆"); CString strSet = _T("MessageData='") + strlistData + _T("'"); CString stWhere = _T("ConfigName='STA的设备状态信息'"); //if(!access.UpdataFromTable(_T(".\\配置文件\\13762Data.accdb"),_T("Config"),strSet , stWhere)) if (!access.UpdataFromTable(pMain->m_PeiZhi_db, _T("Config"), strSet, stWhere)) { AfxMessageBox(_T("数据保存失败!")); return; } CDialogEx::OnOK(); }
89d8ab1da7f8695057c553728fc67d72caeda4ae
e480eb092d704fd1b696011c04b47449ce8d386f
/code/judge/judge_test.cpp
2a10b16a00ae3210e22dbe097cc8978ad225f4dd
[]
no_license
weizengke/judge
cc28feca9c43d11599a63315810bb18da4a1c480
2eb8dc81cfa7cafe16d51d872d54ba40fbeff551
refs/heads/master
2022-05-13T03:37:53.647972
2022-05-02T07:57:17
2022-05-02T07:57:17
14,402,444
39
10
null
null
null
null
UTF-8
C++
false
false
4,975
cpp
judge_test.cpp
#include "judge/include/judge_inc.h" typedef struct tag_Judge_test_ST { char testId[128]; int problemId; int languageId; int verdictId; int time_used; int memory_used; char languageName[100]; char languageExt[10]; char languageExe[10]; char sourcePath[MAX_PATH]; char inputFile[MAX_PATH]; char outputFile[MAX_PATH]; char compileCmd[512]; char runCmd[MAX_PATH]; }JUDGE_TEST_S; /* 1: judge test xxx_id.json json: { "test_id: asas121dd2d2", "problem_id: 1000", "language_id", "1", "code": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "input": "sssss" }, result: { "test_id: asas121dd2d2", "problem_id: 1000", "language_id", "1", "input": "sssss", "output": "aasasa" } */ char g_jsonBuff[1000000] = {0}; int judge_test_init(JUDGE_TEST_S *test) { write_log(JUDGE_INFO, "testId=%s, languageId=%d", test->testId, test->languageId); sprintf(test->sourcePath, "%s\/%s\/data.in", g_judge_work_path, test->testId); sprintf(test->inputFile, "%s\/%s\/data.in", g_judge_work_path, test->testId); sprintf(test->outputFile, "%s\/%s\/data.out", g_judge_work_path, test->testId); config_json_get_array_item_string("languages", test->languageId, "language_name", "", test->languageName, sizeof(test->languageName)); config_json_get_array_item_string("languages", test->languageId, "LanguageExt", "", test->languageExt, sizeof(test->languageExt)); config_json_get_array_item_string("languages", test->languageId, "LanguageExe", "exe", test->languageExe, sizeof(test->languageExe)); config_json_get_array_item_string("languages", test->languageId, "CompileCmd", "NULL", test->compileCmd, sizeof(test->compileCmd)); config_json_get_array_item_string("languages", test->languageId, "RunCmd", "", test->runCmd, sizeof(test->runCmd)); write_log(JUDGE_INFO, "sourcePath=%s", test->sourcePath); write_log(JUDGE_INFO, "inputFile=%s", test->inputFile); write_log(JUDGE_INFO, "outputFile=%s", test->outputFile); write_log(JUDGE_INFO, "languageName=%s", test->languageName); write_log(JUDGE_INFO, "languageExt=%s", test->languageExt); write_log(JUDGE_INFO, "languageExe=%s", test->languageExe); write_log(JUDGE_INFO, "compileCmd=%s", test->compileCmd); write_log(JUDGE_INFO, "runCmd=%s", test->runCmd); return 0; } void judge_test_parse(char *jsonBuff) { JUDGE_TEST_S test = {0}; write_log(JUDGE_INFO, "%s", jsonBuff); cJSON *json = cJSON_Parse(jsonBuff); if (json == NULL) { write_log(JUDGE_INFO, "cJSON_Parse failed."); return ; } cJSON *json_test_id = cJSON_GetObjectItem(json, "test_id"); if(json_test_id != NULL && json_test_id->type == cJSON_String) { write_log(JUDGE_INFO, "test_id=%s\n", json_test_id->valuestring); strncpy(test.testId, json_test_id->valuestring, sizeof(test.testId) - 1); } cJSON *json_problem_id = cJSON_GetObjectItem(json, "problem_id"); if(json_problem_id != NULL && json_problem_id->type == cJSON_Number) { write_log(JUDGE_INFO, "problem_id=%d\n", json_problem_id->valueint); test.problemId = json_problem_id->valueint; } cJSON *json_language_id = cJSON_GetObjectItem(json, "language_id"); if(json_language_id != NULL && json_language_id->type == cJSON_Number) { write_log(JUDGE_INFO, "language_id=%d\n", json_language_id->valueint); test.languageId = json_language_id->valueint; } judge_test_init(&test); cJSON *json_code = cJSON_GetObjectItem(json, "code"); if(json_code != NULL && json_code->type == cJSON_String) { write_log(JUDGE_INFO, "code=%s\n", json_code->valuestring); FILE *fp = fopen(test.sourcePath, "w"); if (fp != NULL) { fprintf(fp, "%s", json_code->valuestring); fclose(fp); } } cJSON *json_input = cJSON_GetObjectItem(json, "input"); if(json_input != NULL && json_input->type == cJSON_String) { write_log(JUDGE_INFO, "code=%s\n", json_input->valuestring); FILE *fp = fopen(test.inputFile, "w"); if (fp != NULL) { fprintf(fp, "%s", json_input->valuestring); fclose(fp); } } } void judge_test_run(char *json_file) { if (json_file == NULL) { return; } if( (file_access(json_file, 0 )) == -1 ) { write_log(JUDGE_INFO, "json_file %s is not exist.", json_file); return; } char *jsonBuff = (char*)malloc(1000000); memset(jsonBuff, 0, sizeof(1000000)); (void)util_fread(json_file, jsonBuff, 1000000 - 1); int judge_sendto_remote_test(char *jsonMsg, int port, char *ip); judge_sendto_remote_test(jsonBuff, 5000, "127.0.0.1"); free(jsonBuff); //judge_test_parse(g_jsonBuff); } void judge_test() { judge_test_run("1.json"); }
ac879ddaa92e3d8722ace779e666f69e29043e92
ad10052619b7bc79d311940bd2419772c4bc8a53
/topcoder-master-2/Bonuses.cpp
8b8ec737143d556042affb5cfbf0337994fc5011
[]
no_license
bluepine/topcoder
3af066a5b1ac6c448c50942f98deb2aa382ba040
d300c8a349a8346dba4a5fe3b4f43b17207627a1
refs/heads/master
2021-01-19T08:15:06.539102
2014-04-02T21:10:58
2014-04-02T21:10:58
18,381,690
1
0
null
null
null
null
UTF-8
C++
false
false
2,786
cpp
Bonuses.cpp
#include <string> #include <vector> #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> using namespace std; class Bonuses { public: vector <int> getDivision(vector <int> points) { vector <int> ret(points.size()); unsigned int i, j, tmp; int totalPoint = 0; int restPoint = 100; int sort[points.size()]; for(i=0; i<points.size(); i++) { totalPoint += points[i]; sort[i] = i; } for(i=0; i<points.size(); i++) { ret[i] = (int)((double)points[i] / (double)totalPoint * 100.0); restPoint -= ret[i]; } for(i=1; i<points.size(); i++) for(j=i; j>0 && points[sort[j-1]] >= points[sort[j]]; j--) { tmp = sort[j]; sort[j] = sort[j-1]; sort[j-1] = tmp; } for(i=points.size()-1; restPoint > 0; i--, restPoint--) ret[sort[i]]++; return ret; } // BEGIN CUT HERE void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const vector <int> &Expected, const vector <int> &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: " << print_array(Expected) << endl; cerr << "\tReceived: " << print_array(Received) << endl; } } void test_case_0() { int Arr0[] = {1,2,3,4,5}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = { 6, 13, 20, 27, 34 }; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(0, Arg1, getDivision(Arg0)); } void test_case_1() { int Arr0[] = {5,5,5,5,5,5}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = { 17, 17, 17, 17, 16, 16 }; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(1, Arg1, getDivision(Arg0)); } void test_case_2() { int Arr0[] = {485, 324, 263, 143, 470, 292, 304, 188, 100, 254, 296, 255, 360, 231, 311, 275, 93, 463, 115, 366, 197, 470}; vector <int> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); int Arr1[] = { 8, 6, 4, 2, 8, 5, 5, 3, 1, 4, 5, 4, 6, 3, 5, 4, 1, 8, 1, 6, 3, 8 }; vector <int> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(2, Arg1, getDivision(Arg0)); } // END CUT HERE }; // BEGIN CUT HERE int main() { Bonuses ___test; ___test.run_test(-1); } // END CUT HERE
9be0d93c72b5b30fef761c257bf6deeecef9612b
74393dfca94417b6aa7fd4903b2912313fbd9bf7
/engine/src/wolf.system/w_window.cpp
1b635daa50c4eae3dd516952ce7df9edb5325c5c
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jstarpl/Wolf.Engine
2c558dc91e311091102a477541e06ee490df9f14
40f4f9933cab551ab3fafd0ed6675ccde249ef62
refs/heads/master
2021-01-09T06:17:33.157681
2017-01-31T15:41:21
2017-01-31T15:41:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,080
cpp
w_window.cpp
#include "w_system_pch.h" #include "w_window.h" #include <map> static std::map<std::wstring, std::function<HRESULT(HWND, UINT, WPARAM, LPARAM)>> sMsgsProcFunctions; w_window::w_window() : _full_screen(false), _screen_width(800), _screen_height(600), _screen_posX(-1), _screen_posY(-1), _close(false), _hInstance(NULL), _hwnd(NULL) { set_fixed_time_step(true); } w_window::~w_window() { release(); } static LRESULT CALLBACK MsgProc(HWND pHwnd, UINT pMessage, WPARAM pWParam, LPARAM pLParam) { TCHAR _class_name[MAX_PATH]; GetClassName(pHwnd, _class_name, MAX_PATH); std::wstring _w_class_name(_class_name); auto _message_proc_func = sMsgsProcFunctions.find(_w_class_name); if (_message_proc_func != sMsgsProcFunctions.end()) { if (_message_proc_func->second != nullptr && _message_proc_func->second(pHwnd, pMessage, pWParam, pLParam) == S_OK) return S_OK; } return DefWindowProc(pHwnd, pMessage, pWParam, pLParam); } void w_window::initialize(std::function<HRESULT(HWND, UINT, WPARAM, LPARAM)> pMsgProcFunction) { //Unregister all this->_hInstance = NULL; this->_hwnd = NULL; this->_hdc = NULL; if (this->_class_name.empty()) { this->_class_name = L"Wolf Engine"; } UnregisterClass(this->_class_name.c_str(), NULL); // Get the instance of this application. this->_hInstance = GetModuleHandle(NULL); sMsgsProcFunctions[this->_class_name] = pMsgProcFunction; // Setup the windows class with default settings. WNDCLASSEX wc; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; //CS_DBLCLKS for double click wc.lpfnWndProc = MsgProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = this->_hInstance; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); wc.hIconSm = wc.hIcon; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = this->_class_name.c_str(); wc.cbSize = sizeof(WNDCLASSEX); // Register the window class. RegisterClassEx(&wc); // Setup the screen DEVMODE dev_mode; if (this->_full_screen) { // Determine the resolution of the clients desktop screen and create full screen window std::memset(&dev_mode, 0, sizeof(dev_mode)); dev_mode.dmSize = sizeof(dev_mode); dev_mode.dmPelsWidth = static_cast<unsigned long>(GetSystemMetrics(SM_CXSCREEN)); dev_mode.dmPelsHeight = static_cast<unsigned long>(GetSystemMetrics(SM_CYSCREEN)); dev_mode.dmBitsPerPel = 32; dev_mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; //Setup full screen mode ChangeDisplaySettings(&dev_mode, CDS_FULLSCREEN); } else { //Middle screen if (this->_screen_posX == -1 || this->_screen_posY == -1) { this->_screen_posX = (GetSystemMetrics(SM_CXSCREEN) - this->_screen_width) / 2; this->_screen_posY = (GetSystemMetrics(SM_CYSCREEN) - this->_screen_height) / 2; } } // Create the window with the screen settings and get the handle to it. this->_hwnd = CreateWindowEx( WS_EX_APPWINDOW, this->_class_name.c_str(), this->_class_name.c_str(), WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP, this->_screen_posX, this->_screen_posY, this->_screen_width, this->_screen_height, NULL, NULL, this->_hInstance, NULL); if (!this->_hwnd) { V(S_FALSE, L"creating window handle", this->name, 3, true, false); return; } this->_hdc = GetDC(this->_hwnd); // Show window up on the screen ShowWindow(this->_hwnd, SW_SHOW); SetForegroundWindow(this->_hwnd); SetFocus(this->_hwnd); // Hide/Show the mouse cursor. ShowCursor(true); } void w_window::run(std::function<void(void)>& const pFunc) { MSG msg; std::memset(&msg, 0, sizeof(msg)); while (true) { if (this->_close) { break; } // Handle the windows messages. if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { switch (msg.message) { case WM_CLOSE: DestroyWindow(msg.hwnd); break; case WM_MOVE: { RECT _rect; GetClientRect(msg.hwnd, &_rect); MapWindowPoints(msg.hwnd, GetParent(msg.hwnd), (LPPOINT) &_rect, 2); //get width and height _rect.left -= 2; _rect.top -= 2; _rect.right += 2; _rect.bottom += 2; auto _width = _rect.right - _rect.left; auto _height = _rect.bottom - _rect.top; MoveWindow(msg.hwnd, msg.wParam, msg.lParam, _width, _height, TRUE); } break; case WM_SHOWWINDOW: { ShowWindow(msg.hwnd, msg.wParam); break; } case WM_ENABLE: { EnableWindow(msg.hwnd, msg.wParam); break; } } TranslateMessage(&msg); DispatchMessage(&msg); } else { pFunc(); } } } void w_window::close() { this->_close = true; } ULONG w_window::release() { if (is_released()) return 0; this->_hInstance = NULL; this->_hwnd = NULL; this->_hdc = NULL; UnregisterClass(this->_class_name.c_str(), NULL); this->_class_name.clear(); return w_object::release(); } #pragma region Setters void w_window::set_class_name(_In_ LPWSTR pValue) { this->_class_name = pValue; } void w_window::set_full_screen(bool pValue) { this->_full_screen = pValue; } void w_window::set_fixed_time_step(bool pValue) { this->_game_time.set_fixed_time_step(pValue); } void w_window::set_width(const int pValue) { this->_screen_width = pValue; } void w_window::set_height(const int pValue) { this->_screen_height = pValue; } void w_window::set_position(const int pX, const int pY) { this->_screen_posX = pX; this->_screen_posY = pY; } #pragma endregion #pragma region Getters LPCWSTR w_window::get_class_name() const { return this->_class_name.c_str(); } HDC w_window::get_HDC() const { return this->_hdc; } HINSTANCE w_window::get_HINSTANCE() const { return this->_hInstance; } HWND w_window::get_HWND() const { return this->_hwnd; } UINT w_window::get_width() const { return this->_screen_width; } UINT w_window::get_height() const { return this->_screen_height; } bool w_window::get_fixed_time_step() const { return this->_game_time.get_fixed_timeStep(); } bool w_window::get_full_screen() const { return this->_full_screen; } #pragma endregion
7731ac071a5d14a29b86af53e2a67801de65a348
39880004a4b884b90e7c58585f8efcfba1639d0d
/Steam/SteamCommon.cpp
1bf84f55a56569dee520fa26b103477730b12708
[]
no_license
sokie/hAPI
30971f0fa70e3c84cfc9a4cbe64085813b594d06
1400b256cff52baa4047b31f6bd90facb761260e
refs/heads/master
2021-01-21T23:54:21.465519
2014-01-05T05:40:38
2014-01-05T05:40:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,330
cpp
SteamCommon.cpp
#include <STDInc.h> bool ValueExists(char *Section, char *Key, char *File) { char Buffer[512]; if (GetPrivateProfileString(Section, Key, NULL, Buffer, 512, File) > 0) return true; return false; } void SteamCommon::Init() { // I Think this is one of the ugliest functions I've ever written.. HHSDBG(); steamID = new CSteamID(); char Buffer[512]; char Path[512]; GetCurrentDirectoryA(512, Path); sprintf(Path, "%s\\hAPI.ini", Path); if (GetPrivateProfileString("Authentication", "Username", "Unknown", Buffer, 512, Path) > 0) strcpy(&playerName[0], Buffer); if (ValueExists("Game", "SteamAppID", Path)) steamAppID = GetPrivateProfileIntA("Game", "SteamAppID", 0, Path); // Which version of the classes to use. // TODO: Find a better way.. if (ValueExists("Version", "SteamUser", Path)) { switch (GetPrivateProfileIntA("Version", "SteamUser", 0, Path)) { case 17: steamUser = (ISteamUser *)new SteamUser017(); break; default: MessageBoxA(0, "Steamuser version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamFriends", Path)) { int K = GetPrivateProfileIntA("Version", "SteamFriends", 0, Path); K += 10; switch (GetPrivateProfileIntA("Version", "SteamFriends", 0, Path)) { case 13: steamFriends = (ISteamFriends *) new SteamFriends013(); break; default: MessageBoxA(0, "SteamFriends version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamUtils", Path)) { switch (GetPrivateProfileIntA("Version", "SteamUtils", 0, Path)) { default: MessageBoxA(0, "SteamUtils version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamMatchMaking", Path)) { switch (GetPrivateProfileIntA("Version", "SteamMatchMaking", 0, Path)) { default: MessageBoxA(0, "SteamMatchMaking version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamMatchMakingServers", Path)) { switch (GetPrivateProfileIntA("Version", "SteamMatchMakingServers", 0, Path)) { default: MessageBoxA(0, "SteamMatchMakingServers version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamUserStats", Path)) { switch (GetPrivateProfileIntA("Version", "SteamUserStats", 0, Path)) { default: MessageBoxA(0, "SteamUserStats version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamApps", Path)) { switch (GetPrivateProfileIntA("Version", "SteamApps", 0, Path)) { case 001: steamApps = (ISteamApps *) new SteamApps001(); break; case 002: steamApps = (ISteamApps *) new SteamApps002(); break; case 003: steamApps = (ISteamApps *) new SteamApps003(); break; case 004: steamApps = (ISteamApps *) new SteamApps004(); break; case 005: steamApps = (ISteamApps *) new SteamApps005(); break; default: MessageBoxA(0, "SteamApps version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamNetworking", Path)) { switch (GetPrivateProfileIntA("Version", "SteamNetworking", 0, Path)) { default: MessageBoxA(0, "SteamNetworking version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamRemoteStorage", Path)) { switch (GetPrivateProfileIntA("Version", "SteamRemoteStorage", 0, Path)) { default: MessageBoxA(0, "SteamRemoteStorage version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamScreenshots", Path)) { switch (GetPrivateProfileIntA("Version", "SteamScreenshots", 0, Path)) { default: MessageBoxA(0, "SteamScreenshots version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamHTTP", Path)) { switch (GetPrivateProfileIntA("Version", "SteamHTTP", 0, Path)) { default: MessageBoxA(0, "SteamHTTP version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamUnifiedMessages", Path)) { switch (GetPrivateProfileIntA("Version", "SteamUnifiedMessages", 0, Path)) { default: MessageBoxA(0, "SteamUnifiedMessages version is not implemented.", 0, 0); break; } } if (ValueExists("Version", "SteamController", Path)) { switch (GetPrivateProfileIntA("Version", "SteamController", 0, Path)) { default: MessageBoxA(0, "SteamController version is not implemented.", 0, 0); break; } } } SteamAPICall_t SteamCommon::RequestEncryptedAppTicket(const void *pUserData, int cbUserData) { HHSDBG(); uint64 userID = GetSteamID()->ConvertToUint64(); memset(encryptedAppTicket, 0, sizeof(encryptedAppTicket)); memcpy(&encryptedAppTicket[32], pUserData, min(cbUserData, sizeof(encryptedAppTicket))); memcpy(&encryptedAppTicket[cbUserData + 32], &userID, sizeof(userID)); SteamAPICall_t callID = Callbacks::RegisterCall(); EncryptedAppTicketResponse_t *response = (EncryptedAppTicketResponse_t*)malloc(sizeof(EncryptedAppTicketResponse_t)); response->m_eResult = k_EResultOK; Callbacks::Return(response, EncryptedAppTicketResponse_t::k_iCallback, callID, sizeof(EncryptedAppTicketResponse_t)); return callID; } CSteamID *SteamCommon::GetSteamID() { HHSDBG(); return steamID; } AppId_t SteamCommon::GetSteamAppID() { return steamAppID; } char *SteamCommon::GetEncryptedAppTicket() { HHSDBG(); return encryptedAppTicket; } char *SteamCommon::GetPlayerName() { HHSDBG(); return playerName; } void SteamCommon::SetPlayerName(const char *newName) { HHSDBG(); strcpy(&playerName[0], newName); } ISteamApps *SteamCommon::GetSteamApps() { HHSDBG(); return steamApps; } ISteamFriends *SteamCommon::GetSteamFriends() { HHSDBG(); return steamFriends; } ISteamGameServer *SteamCommon::GetSteamGameServer() { HHSDBG(); return steamGameServer; } ISteamGameServerStats *SteamCommon::GetSteamGameServerStats() { HHSDBG(); return steamGameServerStats; } ISteamHTTP *SteamCommon::GetSteamHTTP() { HHSDBG(); return steamHTTP; } ISteamMatchmaking *SteamCommon::GetSteamMatchmaking() { HHSDBG(); return steamMatchmaking; } ISteamMatchmakingServers *SteamCommon::GetSteamMatchmakingServers() { HHSDBG(); return steamMatchmakingServers; } ISteamNetworking *SteamCommon::GetSteamNetworking() { HHSDBG(); return steamNetworking; } ISteamRemoteStorage *SteamCommon::GetSteamRemoteStorage() { HHSDBG(); return steamRemoteStorage; } ISteamUser *SteamCommon::GetSteamUser() { return steamUser; } ISteamUserStats *SteamCommon::GetSteamUserStats() { HHSDBG(); return steamUserStats; } ISteamUtils *SteamCommon::GetSteamUtils() { HHSDBG(); return steamUtils; } ISteamBilling *SteamCommon::GetSteamBilling() { HHSDBG(); return steamBilling; } ISteamContentServer *SteamCommon::GetSteamContentServer() { HHSDBG(); return steamContentServer; } ISteamMasterServerUpdater *SteamCommon::GetSteamMasterServerUpdater() { HHSDBG(); return steamMasterServerUpdater; } ISteamController *SteamCommon::GetSteamController() { HHSDBG(); return steamController; } ISteamScreenshots *SteamCommon::GetSteamScreenshots() { HHSDBG(); return steamScreenshots; } ISteamUnifiedMessages *SteamCommon::GetSteamUnifiedMessages() { HHSDBG(); return steamUnifiedMessages; } CSteamID *SteamCommon::steamID = NULL; AppId_t SteamCommon::steamAppID = NULL; ISteamApps *SteamCommon::steamApps = NULL; ISteamFriends *SteamCommon::steamFriends = NULL; ISteamGameServer *SteamCommon::steamGameServer = NULL; ISteamGameServerStats *SteamCommon::steamGameServerStats = NULL; ISteamHTTP *SteamCommon::steamHTTP = NULL; ISteamMatchmaking*SteamCommon::steamMatchmaking = NULL; ISteamMatchmakingServers *SteamCommon::steamMatchmakingServers = NULL; ISteamNetworking *SteamCommon::steamNetworking = NULL; ISteamRemoteStorage *SteamCommon::steamRemoteStorage = NULL; ISteamUser *SteamCommon::steamUser = NULL; ISteamUserStats *SteamCommon::steamUserStats = NULL; ISteamUtils *SteamCommon::steamUtils = NULL; ISteamBilling *SteamCommon::steamBilling = NULL; ISteamContentServer *SteamCommon::steamContentServer = NULL; ISteamMasterServerUpdater *SteamCommon::steamMasterServerUpdater = NULL; ISteamController *SteamCommon::steamController = NULL; ISteamScreenshots *SteamCommon::steamScreenshots = NULL; ISteamUnifiedMessages *SteamCommon::steamUnifiedMessages = NULL; char SteamCommon::encryptedAppTicket[128]; char SteamCommon::playerName[255];
c4dc47480beecda2434d4509f8f25b6f27c05c5e
cd5ea61819e208d56fc85c07e8200e7fc4dea75e
/Symmetric Tree/Solution.cpp
5d4f4a4ab3979fcb464533e4ccbc69028b8b93f3
[]
no_license
rogers140/leetcode-oj
b741fd42efb877ce10c196fc7d05744bc5e17a67
9b1b8729840d5e20c879c81d460e461465be34c4
refs/heads/master
2020-04-05T23:41:03.033613
2017-01-21T07:39:00
2017-01-21T07:39:00
16,267,782
0
0
null
null
null
null
UTF-8
C++
false
false
2,178
cpp
Solution.cpp
#include <stdio.h> #include <iostream> #include <vector> using namespace std; struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x): val(x), left(NULL), right(NULL) {} }; class Solution { public: bool isSymmetric(TreeNode *root) { if(root == NULL) { return true; } if(root->left != NULL) { if(root->right == NULL) { return false; } else { return isSymmetricTrees(root->left, root->right); } } else { if(root->right == NULL) { return true; } else { return false; } } } bool isSymmetricTrees(TreeNode *p, TreeNode *q) { vector<TreeNode *> stackP; vector<TreeNode *> stackQ; TreeNode *currentP = p; TreeNode *currentQ = q; while(currentP != NULL || stackP.size() != 0) { while(currentP != NULL) { stackP.push_back(currentP); if(currentQ == NULL) { return false; } stackQ.push_back(currentQ); currentP = currentP->left; currentQ = currentQ->right; } if(currentQ != NULL) { return false; } currentP = stackP.back(); if(stackQ.size() == 0) { return false; } currentQ = stackQ.back(); if(currentP->val != currentQ->val) { return false; } stackP.pop_back(); stackQ.pop_back(); currentP = currentP->right; currentQ = currentQ->left; } if(currentQ != NULL || stackQ.size() != 0) { return false; } return true; } }; int main(int argc, char const *argv[]) { Solution *s = new Solution(); TreeNode *node1 = new TreeNode(1); TreeNode *node21 = new TreeNode(2); TreeNode *node22 = new TreeNode(2); TreeNode *node31 = new TreeNode(3); TreeNode *node32 = new TreeNode(3); TreeNode *node41 = new TreeNode(4); node21->right = node31; node22->left = node32; node22->right = node41; node1->left = node21; node1->right = node22; cout<<s->isSymmetric(node1)<<endl; return 0; }
c28d718cf01dcd1cb282121f56fe5e1adc2f8bc3
fb62f45c6e3140ab11cd73e0b64be516247945b6
/common/common_internal.h
025987b6be6ff7f74c5f2aea1ffaacdbf4bfe56b
[]
no_license
shangdehao1/cleanup
80a7dab3fb48baa56d39b3b11cfaecd5bc2bd92f
2c5144c4cdb0280c6207ad9fb3a65e40cb2f7322
refs/heads/master
2021-04-25T03:37:25.324334
2018-02-04T16:07:56
2018-02-04T16:07:56
115,608,206
0
0
null
null
null
null
UTF-8
C++
false
false
3,502
h
common_internal.h
#ifndef COMMON_INTERNAL_H_ #define COMMON_INTERNAL_H_ #include <boost/bind.hpp> #include <boost/asio.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/function.hpp> #include <memory> #include "smart_ptr/networking_ptr.h" namespace hdcs { namespace networking { class ControllerImpl; typedef hdcs::networking::shared_ptr<ControllerImpl> ControllerImplPtr; typedef hdcs::networking::weak_ptr<ControllerImpl> ControllerImplWPtr; class ChannelImpl; typedef hdcs::networking::shared_ptr<ChannelImpl> ChannelImplPtr; class ClientImpl; typedef hdcs::networking::shared_ptr<ClientImpl> ClientImplPtr; class ServerImpl; typedef hdcs::networking::shared_ptr<ServerImpl> ServerImplPtr; typedef hdcs::networking::weak_ptr<ServerImpl> ServerImplWPtr; class ClientStream; typedef hdcs::networking::shared_ptr<ClientStream> ClientStreamPtr; typedef hdcs::networking::weak_ptr<ClientStream> ClientStreamWPtr; class ServerStream; typedef hdcs::networking::shared_ptr<ServerStream> ServerStreamPtr; typedef hdcs::networking::weak_ptr<ServerStream> ServerStreamWPtr; class Listener; typedef hdcs::networking::shared_ptr<Listener> ListenerPtr; class TimerWorker; typedef hdcs::networking::shared_ptr<TimerWorker> TimerWorkerPtr; class TimeoutManager; typedef hdcs::networking::shared_ptr<TimeoutManager> TimeoutManagerPtr; class ThreadGroup; typedef hdcs::networking::shared_ptr<ThreadGroup> ThreadGroupPtr; class ServicePool; typedef hdcs::networking::shared_ptr<ServicePool> ServicePoolPtr; typedef hdcs::networking::weak_ptr<ServicePool> ServicePoolWPtr; class FlowController; typedef hdcs::networking::shared_ptr<FlowController> FlowControllerPtr; class WaitEvent; typedef hdcs::networking::shared_ptr<WaitEvent> WaitEventPtr; /////////////////////////////////////////////////////////////////////// class IOServicePool; typedef hdcs::networking::shared_ptr<IOServicePool> IOServicePoolPtr; class WebService; typedef hdcs::networking::shared_ptr<WebService> WebServicePtr; typedef boost::asio::io_service IOService; typedef hdcs::networking::shared_ptr<IOService> IOServicePtr; typedef boost::asio::io_service::work IOServiceWork; typedef hdcs::networking::shared_ptr<IOServiceWork> IOServiceWorkPtr; typedef boost::asio::io_service::strand IOServiceStrand; typedef hdcs::networking::shared_ptr<IOServiceStrand> IOServiceStrandPtr; typedef boost::asio::deadline_timer IOServiceTimer; typedef hdcs::networking::shared_ptr<IOServiceTimer> IOServiceTimerPtr; typedef boost::posix_time::ptime PTime; /* #define SOFA_PBRPC_DECLARE_RESOURCE_COUNTER(name_) \ extern hdcs::networking::AtomicCounter g_hdcs_counter_##name_ #define SOFA_PBRPC_DEFINE_RESOURCE_COUNTER(name_) \ hdcs::networking::AtomicCounter g_hdcs_counter_##name_(0) #define SOFA_PBRPC_INC_RESOURCE_COUNTER(name_) \ ++g_hdcs_counter_##name_ #define SOFA_PBRPC_DEC_RESOURCE_COUNTER(name_) \ --g_hdcs_counter_##name_ #define SOFA_PBRPC_GET_RESOURCE_COUNTER(name_) \ static_cast<int>(g_hdcs_counter_##name_) //SOFA_PBRPC_DECLARE_RESOURCE_COUNTER(ByteStream); //SOFA_PBRPC_DECLARE_RESOURCE_COUNTER(Listener); // Use for affecting global/static variables' construct/destruct order. inline void touch_boost_error_category() { (void)boost::system::system_category(); (void)boost::system::generic_category(); (void)boost::asio::error::get_addrinfo_category(); (void)boost::asio::error::get_misc_category(); (void)boost::asio::error::get_netdb_category(); } */ } } #endif
a2dba728f76dd15c5abd2e3303acaeb7dcadabc9
5b95703178b1a20541941404e894de4c719b72b7
/main.cpp
9d8c3cf4047dd19c392263dfc5a246e6d9278528
[]
no_license
wolfsberger/HumiditySensor
9a2d16597f8d2028a35a83d528c4ff013d3b759a
8a823b32d114b7e9260d0fe09385b710a8ebbd5f
refs/heads/master
2021-01-10T01:54:51.688214
2016-02-25T12:30:10
2016-02-25T12:30:10
51,906,309
0
1
null
null
null
null
UTF-8
C++
false
false
3,114
cpp
main.cpp
#include "stdio.h" #include "mbed.h" #include "HygroClip2.h" #include "SPI_TFT_ILI9341.h" #include "Arial12x12.h" #include "Arial28x28.h" #include "GraphScale.h" #include "LineGraph.h" #include "CommandHandler.h" #include "Encoder.h" //Serial pc(SERIAL_TX, SERIAL_RX); HygroClip2 sensor(D8,D2); SPI_TFT_ILI9341 TFT(SPI_MOSI,SPI_MISO,SPI_SCK,SPI_CS,D9,D7); const int ColorTemperature = RGB(0xff,0x37,0x00); const int ColorHumidity = RGB(0x00,0xc8,0xff); const int ColorDewPoint = RGB(0x00,0xE8,0x59); const int ColorHumidityAbs = RGB(0xff,0x44,0xa5); const float GraphUpdateRateInSeconds = 5; LineGraph<200> graphTemperature (&TFT,1,200,200,100,0,100); LineGraph<200> graphHumidity (&TFT,1,200,200,100,0,100); LineGraph<200> graphDewPoint (&TFT,1,200,200,100,0,100); GraphScale scale (&TFT,1,200,200,100,0,100,20); //RotaryEncoder encoder(D3, D4); CommandHandler commandHandler; void drawChangingValues() { TFT.set_font((unsigned char*)Arial28x28); TFT.locate(10,25); TFT.foreground(ColorTemperature); TFT.printf("%.1f*C ",sensor.getTemperature()); // * will be displayed as ° TFT.locate(10,70); TFT.foreground(ColorHumidity); TFT.printf("%.1f%%rH ",sensor.getHumidity()); TFT.foreground(ColorHumidityAbs); TFT.locate(10,115); TFT.printf("%.3fg/m3 ",sensor.getAbsolutHumidity()); TFT.foreground(ColorDewPoint); TFT.locate(10,160); TFT.printf("%.1f*C ",sensor.getDewPoint()); // * will be displayed as ° } void drawGraphs() { graphTemperature.draw(ColorTemperature); graphHumidity.draw(ColorHumidity); graphDewPoint.draw(ColorDewPoint); } int main() { //TFT.claim(stdout); // send stdout to the TFT display TFT.background(Black); // set background to black TFT.foreground(White); // set chars to white TFT.cls(); // clear the screen TFT.set_font((unsigned char*) Arial12x12); // select the font TFT.set_orientation(2); TFT.locate(10,10); TFT.printf("Loading..."); while(!sensor.isDataValid()) { sensor.update(); wait(.5f); } TFT.locate(10,10); TFT.printf("Temperatur"); TFT.locate(10,55); TFT.printf("Luftfeuchtigkeit (relativ)"); TFT.locate(10,100); TFT.printf("Luftfeuchtigkeit (absolut)"); TFT.locate(10,145); TFT.printf("Taupunkt"); scale.draw(White); float seconds = 0; const float waitTime = 1.0f; printf("running..\n"); while(1) { sensor.update(); drawChangingValues(); if (seconds >= GraphUpdateRateInSeconds) { seconds = 0; graphTemperature.addItem(sensor.getTemperature()); graphHumidity.addItem(sensor.getHumidity()); graphDewPoint.addItem(sensor.getDewPoint()); drawGraphs(); } seconds += waitTime; wait(waitTime); // Encoder Tests /*TFT.locate(5,305); TFT.set_font((unsigned char*) Arial12x12); TFT.printf("Encoder: %d", encoder.position()); wait(0.05);*/ } }
7493fe618fce2d8d46917bdf98e6a9e5ca2cd0e9
6132c157618f09f8f4751061c282e1523a968f7b
/Hackerrank/DiagonalDifference.cpp
315c64962f7dd3b7b0e406fb0a7e13bfca2af535
[]
no_license
hryer/Algorithm-Playground
12926704ba20230c7d50b6cbdddad06c0597c71d
80d8edd0047116cfe174bcf2aabc9c910acfcb11
refs/heads/master
2022-12-15T13:07:35.678594
2020-09-12T11:27:42
2020-09-12T11:27:42
110,347,356
1
0
null
null
null
null
UTF-8
C++
false
false
662
cpp
DiagonalDifference.cpp
//https://www.hackerrank.com/challenges/diagonal-difference/problem #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main(){ int n; cin>>n; int a[n][n]; int x=0,y=0; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> a[i][j]; } } for(int j = 0 ; j < n ; j++){ x = x + a[j][j]; } int temp =0; for(int k = n-1 ; k >= 0; k--){ y = y + a[k][temp]; temp++; } if(x>y){ cout << x-y; }else{ cout << y-x; } return 0; }
98ddcc8eb209e45755514e9177488aef82f1a8ab
b209f657817b2252934dd5fba2601d3f8fb8ab04
/app/src/main/cpp/engine_3d/MusicPlayer.h
9b14e116f3eb78da4cd2cc265252c99471c31c8f
[]
no_license
raynor73/AndroidNDKOpenGLResearch
4faa8d7cd618e2194ab7396af28e83fb7fd84444
34d4292d1bcaaa72e7a4836d7e38568e31183e46
refs/heads/master
2023-01-31T12:54:35.325233
2020-12-10T09:37:55
2020-12-10T09:37:55
268,936,661
0
0
null
null
null
null
UTF-8
C++
false
false
460
h
MusicPlayer.h
// // Created by Igor Lapin on 31/08/2020. // #ifndef ENGINE_3D_MUSIC_PLAYER_H #define ENGINE_3D_MUSIC_PLAYER_H #include <string> class MusicPlayer { public: ~MusicPlayer() = default; virtual void play(const std::string& path) = 0; virtual void pause() = 0; virtual void resume() = 0; virtual void stop() = 0; virtual void setGain(float gain) = 0; virtual bool isPlaybackCompleted() = 0; }; #endif //ENGINE_3D_MUSIC_PLAYER_H
8904ce67c1565064bfdd2fa38886523cbe0fe456
d263e9ad5c18c95a44d26af8c9e1a06ed7ba660f
/OSSupport/ResolveProcessSpecifier.cpp
42cfb6d17307ceb424c5f04f84ed8443b81aea36
[ "BSL-1.0" ]
permissive
mlbrock/MlbDev
3783d148e7934ce84d26643c879d33a3aa1935a2
d499f66c7f672f8761d81a04f00f87a0808f9ff1
refs/heads/develop
2022-10-28T18:09:17.473659
2022-10-18T08:28:44
2022-10-18T08:28:44
15,541,112
2
2
null
2018-04-23T21:50:46
2013-12-31T02:18:56
C++
UTF-8
C++
false
false
5,014
cpp
ResolveProcessSpecifier.cpp
// //////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////// // MLB Operating System Support (OSSupport) Library Module File // //////////////////////////////////////////////////////////////////////////// /* File Name : %M% File Version : %I% Last Extracted : %D% %T% Last Updated : %E% %U% File Description : Given a string which represents a process identifier or a process name, resolves it. Revision History : 1998-04-08 --- Creation. Michael L. Brock Copyright Michael L. Brock 1998 - 2018. 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) */ // //////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////// // Required include files... // //////////////////////////////////////////////////////////////////////////// #include <OSSupport/OSSupport.hpp> #include <Utility/Utility_Exception.hpp> // //////////////////////////////////////////////////////////////////////////// namespace MLB { namespace OSSupport { // //////////////////////////////////////////////////////////////////////////// std::pair<MLB::Utility::ProcessId, std::string> ResolveProcessSpecifier(const char *process_specifier) { std::pair<MLB::Utility::ProcessId, std::string> return_value; try { if ((process_specifier == NULL) || (!(*process_specifier))) MLB::Utility::ThrowInvalidArgument("The process specifier passed to " "'ResolveProcess()' is " + std::string((process_specifier == NULL) ? "'NULL'" : "an empty string") + "."); const char *tmp_ptr = process_specifier; while (*tmp_ptr) { if (!isdigit(*tmp_ptr)) { return_value.first = ProcessNameToId(process_specifier); return_value.second = ProcessIdToName(return_value.first); return(return_value); } ++tmp_ptr; } return_value.second = ProcessIdToName( static_cast<MLB::Utility::ProcessId>(atoi(process_specifier))); return_value.first = ProcessNameToId(return_value.second); } catch (const std::exception &except) { MLB::Utility::Rethrow(except, "Attempt to resolve a process specifier " "failed: " + std::string(except.what())); } return(return_value); } // //////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////// std::pair<MLB::Utility::ProcessId, std::string> ResolveProcessSpecifier(const std::string &process_specifier) { return(ResolveProcessSpecifier(process_specifier.c_str())); } // //////////////////////////////////////////////////////////////////////////// } // namespace OSSupport } // namespace MLB #ifdef TEST_MAIN #include <Utility/ParseCmdLineArg.hpp> using namespace MLB::OSSupport; // //////////////////////////////////////////////////////////////////////////// int main(int argc, char **argv) { int return_code = EXIT_SUCCESS; // ////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// // Help may have been requested on the command line... // ////////////////////////////////////////////////////////////////////// if (MLB::Utility::ParseCmdLineArg::HasCmdLineHelp(argc, argv, 1)) { std::cout << "USAGE: " << std::endl << " " << argv[0] << " " << "[ { <process-name> | <process-id> } [ ... ] ]" << std::endl << std::endl; exit(EXIT_SUCCESS); } // ////////////////////////////////////////////////////////////////////// try { std::vector<std::string> process_list; if (argc == 1) process_list.push_back(argv[0]); else std::vector<std::string>(argv + 1, argv + argc).swap(process_list); std::cout << "Test ResolveProcessSpecifier():" << std::endl; std::vector<std::string>::const_iterator iter_b(process_list.begin()); std::vector<std::string>::const_iterator iter_e(process_list.end()); for ( ; iter_b != iter_e; ++iter_b) { std::pair<MLB::Utility::ProcessId, std::string> proc_spec; std::cout << " " << *iter_b << ": " << std::flush; try { proc_spec = ResolveProcessSpecifier(*iter_b); std::cout << " " << *iter_b << ": " << proc_spec.first << " = " << proc_spec.second << std::endl; } catch (const std::exception &except) { std::cout << "FAILED: " << except.what() << std::endl; return_code = EXIT_FAILURE; } } std::cout << std::endl; } catch (const std::exception &except) { std::cerr << "REGRESSION TEST FAILURE: " << "OSSupport/ResolveProcessSpecifier.cpp: " << except.what() << std::endl; return_code = EXIT_FAILURE; } return(return_code); } // //////////////////////////////////////////////////////////////////////////// #endif /* #ifdef TEST_MAIN */
380f44df38f55e02ceac79d5a782ef02efc24817
4ce262e598ef85ade7e76b89773e644f977a04d1
/tests/test_example.cpp
79371185215cfad96b8b25e3f65d763d5df77a6b
[]
no_license
nick-warfield/thread-safe-vector
fa744a400b647f56150efdb3c62c170731f88406
40800385ad9034cb93786b7bf2dcef1837529b48
refs/heads/main
2023-08-15T14:40:16.487301
2021-10-06T02:04:02
2021-10-06T02:04:02
413,586,879
0
0
null
null
null
null
UTF-8
C++
false
false
66
cpp
test_example.cpp
#include "catch.hpp" TEST_CASE("Example") { REQUIRE(1 == 1); }
d23efb1d8e215fae72b5891359a5e8438d9c8177
30dd9ff200f97b525b069577471d23387b23970b
/src/map/util/lanelet2_map_preprocessor/src/fix_lane_change_tags.cpp
aef6aeed1d8ea7bdb5694dd5279c4e6953a6c0a1
[]
permissive
ColleyLi/AutowareArchitectureProposal
cd544ef913e3c49852d385883c3e3ee5b518b1b8
80ac2a8823d342e5a1e34703dbde27e8e9b5cd98
refs/heads/master
2022-04-18T01:41:53.649137
2020-04-21T12:18:58
2020-04-21T12:18:58
257,659,506
2
0
Apache-2.0
2020-04-21T17:03:50
2020-04-21T17:03:49
null
UTF-8
C++
false
false
3,654
cpp
fix_lane_change_tags.cpp
/* * Copyright 2020 Tier IV, Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <ros/ros.h> #include <lanelet2_core/LaneletMap.h> #include <lanelet2_core/geometry/Lanelet.h> #include <lanelet2_core/primitives/LaneletSequence.h> #include <lanelet2_io/Io.h> #include <lanelet2_extension/io/autoware_osm_parser.h> #include <lanelet2_extension/projection/mgrs_projector.h> #include <lanelet2_extension/utility/message_conversion.h> #include <iostream> #include <unordered_set> #include <vector> void printUsage() { std::cerr << "Please set following private parameters:" << std::endl << "llt_map_path" << std::endl << "output_path" << std::endl; } using lanelet::utils::getId; using lanelet::utils::to2D; bool loadLaneletMap( const std::string & llt_map_path, lanelet::LaneletMapPtr & lanelet_map_ptr, lanelet::Projector & projector) { lanelet::LaneletMapPtr lanelet_map; lanelet::ErrorMessages errors; lanelet_map_ptr = lanelet::load(llt_map_path, "autoware_osm_handler", projector, &errors); for (const auto & error : errors) { ROS_ERROR_STREAM(error); } if (!errors.empty()) { return false; } std::cout << "Loaded Lanelet2 map" << std::endl; return true; } bool exists(std::unordered_set<lanelet::Id> & set, lanelet::Id element) { return std::find(set.begin(), set.end(), element) != set.end(); } lanelet::Lanelets convertToVector(lanelet::LaneletMapPtr & lanelet_map_ptr) { lanelet::Lanelets lanelets; for (lanelet::Lanelet lanelet : lanelet_map_ptr->laneletLayer) { lanelets.push_back(lanelet); } return lanelets; } void fixTags(lanelet::LaneletMapPtr & lanelet_map_ptr) { auto lanelets = convertToVector(lanelet_map_ptr); lanelet::traffic_rules::TrafficRulesPtr trafficRules = lanelet::traffic_rules::TrafficRulesFactory::create( lanelet::Locations::Germany, lanelet::Participants::Vehicle); lanelet::routing::RoutingGraphUPtr routingGraph = lanelet::routing::RoutingGraph::build(*lanelet_map_ptr, *trafficRules); for (auto & llt : lanelets) { if (!routingGraph->conflicting(llt).empty()) { continue; } llt.attributes().erase("turn_direction"); if (!!routingGraph->adjacentRight(llt)) { llt.rightBound().attributes()["lane_change"] = "yes"; } if (!!routingGraph->adjacentLeft(llt)) { llt.leftBound().attributes()["lane_change"] = "yes"; } } } int main(int argc, char * argv[]) { ros::init(argc, argv, "merge_lines"); ros::NodeHandle pnh("~"); if (!pnh.hasParam("llt_map_path")) { printUsage(); return EXIT_FAILURE; } if (!pnh.hasParam("output_path")) { printUsage(); return EXIT_FAILURE; } std::string llt_map_path, output_path; pnh.getParam("llt_map_path", llt_map_path); pnh.getParam("output_path", output_path); lanelet::LaneletMapPtr llt_map_ptr(new lanelet::LaneletMap); lanelet::projection::MGRSProjector projector; if (!loadLaneletMap(llt_map_path, llt_map_ptr, projector)) { return EXIT_FAILURE; } fixTags(llt_map_ptr); lanelet::write(output_path, *llt_map_ptr, projector); return 0; }
f8daeb8dac7df107ae068f91a1e27d7fe51953cc
9e4f8d9c7717d6bd20c0a6f724fc355e87d2f666
/include/PrimitiveRenderer.h
8a2826ea8cf539e250f35ecebed1fe977708c8aa
[ "MIT" ]
permissive
Sometrik/framework
071f7e12c9d58f15dad078788b6405ec5440f0a1
29d387251cd553aa75f8755adccf94494a9d7367
refs/heads/master
2023-02-05T11:31:12.545966
2023-02-01T15:07:08
2023-02-01T15:07:08
44,181,086
7
2
null
null
null
null
UTF-8
C++
false
false
3,569
h
PrimitiveRenderer.h
#ifndef _PRIMITIVERENDERER_H_ #define _PRIMITIVERENDERER_H_ #include <VBO.h> #include <shader_program.h> #include <glm/glm.hpp> #define COLOR_BUFFER_BIT 1 #define DEPTH_BUFFER_BIT 2 #define STENCIL_BUFFER_BIT 4 #define DEPTH_STENCIL_BUFFER_BIT 8 class Texture; class FWPlatform; class Sprite; class PrimitiveRenderer { public: enum CompositionMode { COPY = 0, NORMAL, MULTIPLY }; PrimitiveRenderer(float _display_scale) : display_scale(_display_scale) { }; virtual ~PrimitiveRenderer() { } virtual void renderTexturedWindow(VBO & vbo, const Texture & texture, const glm::mat4 & mat, float alpha = 1.0f) { } virtual void drawSprite(const Sprite & sprite, const glm::mat4 & projMat, const glm::mat4 & mvMat) { } virtual void initialize(FWPlatform & platform) { } const glm::ivec2 & getDisplaySize() const { return current_display_size; } void clear(int clear_bits); void invalidateFramebuffer(int bits); void setClearColor(float r, float g, float b); void colorMask(bool r, bool g, bool b, bool a); void viewport(unsigned int x, unsigned int y, unsigned int w, unsigned int h); unsigned int getMaxTextureSize() const { return max_texture_size; } bool hasETC1() const { return has_etc1; } bool hasDXT1() const { return has_dxt1; } bool hasRGTC() const { return has_rgtc; } bool hasRGB565() const { return has_rgb565; } bool hasInstancing() const { return has_instancing; } bool isModern() const { return is_modern; } float getDisplayScale() const { return display_scale; } void setDisplayScale(float f) { display_scale = f; } void setScreenSize(unsigned int _width, unsigned int _height, unsigned int _actual_width, unsigned int _actual_height) { screen_width = _width; screen_height = _height; actual_screen_width = _actual_width; actual_screen_height = _actual_height; } unsigned int getScreenWidth() const { return screen_width; } unsigned int getScreenHeight() const { return screen_height; } unsigned int getActualScreenWidth() const { return actual_screen_width; } unsigned int getActualScreenHeight() const { return actual_screen_height; } protected: void initializeBase(); void pushGroupMarker(const char * name); void popGroupMarker(); void blend(bool t); void stencilTest(bool t); void stencilMask(int m); void depthTest(bool t); void depthMask(bool m); void cullFace(bool t); void setLineWidth(float w); void setCompositionMode(CompositionMode mode); void bind(const Texture & texture); void bind(const VBO & vbo); void use(const shader_program & program); const char * getGLSLVersion() const; const char * getModernGLSLVersion() const; private: unsigned int max_texture_size = 0; bool has_etc1 = false, has_dxt1 = false, has_rgtc = false, has_rgb565 = false; bool blend_enabled = false; bool depth_test_enabled = false; bool current_depth_mask = true; bool stencil_test_enabled = false; int current_stencil_mask = 0xff; bool cull_face_enabled = false; float current_line_width = 1.0f; bool current_red_mask = true, current_green_mask = true, current_blue_mask = true, current_alpha_mask = true; CompositionMode current_composition_mode = COPY; glm::ivec2 current_display_size; float display_scale = 1.0f; int current_texture_2d = 0, current_vertex_array = 0, current_program = 0; bool is_modern = false, is_es3 = false, has_instancing = false; unsigned int screen_width = 0, screen_height = 0, actual_screen_width = 0, actual_screen_height = 0; glm::vec3 clear_color; }; #endif
b0e2280c5e4e18467a064bbff291f20ec0f85869
f14626611951a4f11a84cd71f5a2161cd144a53a
/Public/Setup/SkillList.h
cc301a6fa3da47782c4b534e4a0ca7dfc9a5bd8f
[]
no_license
Deadmanovi4/mmo-resourse
045616f9be76f3b9cd4a39605accd2afa8099297
1c310e15147ae775a59626aa5b5587c6895014de
refs/heads/master
2021-05-29T06:14:28.650762
2015-06-18T01:16:43
2015-06-18T01:16:43
null
0
0
null
null
null
null
GB18030
C++
false
false
2,005
h
SkillList.h
//====================================================================================== /** * @file SkillList.h * @data * @author */ //====================================================================================== #pragma once /** * @class CSkillList * * @brief 技能列表配置类 */ class CSkillList { public: /// 构造 CSkillList(void); /// 析构 ~CSkillList(void); public: /// 技能目标 enum eSkillDestType { SDT_SELF, // 自己 SDT_SHAPE, // 其他shape SDT_TILE, // 地图格子 }; /// 技能步骤 struct tagStep { WORD wCommandID; // 命令编号 uchar bStringParam; // 是否是字符串变量 union{ long lParam; // 整形参数 char *pstrParam; // 字符串参数 }; }; /// 技能等级 struct tagLevel { WORD wRange; // 释放范围 vector<tagStep> vectorSteps; // 步骤列表 }; /// 技能结构 struct tagSkill { DWORD dwIndex; // 技能编号 string strName; // 技能名称 string strDescribe; // 描述 eSkillDestType lDestType; // 目标类型 vector<tagLevel> vectorLevels; // 各个等级的详细资料 }; private: /// 原始Skill列表(dwIndex, tagSkill) static map<DWORD, tagSkill> m_mapSkillList; /// 步骤名称对应的ID static map<string, WORD> m_mapStepNameID; public: // 从文件加载原始技能列表 static BOOL LoadSkillList(const char* stepfilename, const char* dir_name); /// 编码 static bool AddToByteArray(vector<uchar>* pByteArray); /// 解码 static bool DecordFromByteArray(uchar* pByte, long& pos); public: /// 根据技能编号查询指定的Skill属性 static tagSkill* GetPropertiy(DWORD dwIndex); /// 根据技能名称查询指定的Skill属性 static tagSkill* GetPropertiyByName(const char* strName); private: /// 读取一个技能 static BOOL LoadOneSkill(const char* filename); /// 释放 static void Release(); };
23aaeac4e9539785e22f5b29bce832f02c94b500
827fb12621580fccea54f2f4a577cc6ee8a80692
/backend/web/client.hh
e55dcf3b3c88d335544781d73106323a40b4569b
[]
no_license
stanford-stagecast/equipment
f731a3dd0e364e7daf1f4247921e4184ac76cf05
d73196ab0d65a8c38176f2d91d8739e9de85bac6
refs/heads/main
2023-03-13T04:39:05.070470
2021-03-04T09:44:59
2021-03-04T09:44:59
300,461,829
0
1
null
2021-03-03T06:36:17
2020-10-02T00:40:20
C++
UTF-8
C++
false
false
799
hh
client.hh
#ifndef CLIENT_HH #define CLIENT_HH #include <string_view> #include <queue> #include "net.hh" #include "beast.hh" class Dispatcher; class Client : public std::enable_shared_from_this<Client> { private: websocket::stream<beast::tcp_stream> ws_; beast::flat_buffer buffer_; std::queue<std::string> queue_; std::shared_ptr<Dispatcher> dispatcher_; bool write_in_progress_; void fail(beast::error_code ec, std::string_view what); void on_accept(beast::error_code ec); void on_read(beast::error_code ec, std::size_t bytes); void on_write(beast::error_code ec, std::size_t bytes); void do_read(); void do_write(); public: Client(tcp::socket &&socket, std::shared_ptr<Dispatcher> dispatcher); ~Client(); void run(); void do_update(std::string_view update); }; #endif
488157c197664727ce94713baf8bd24a667699ad
15c48a209be92c84c17e80659621f35e46ee8922
/include/Clock.hpp
86e9cdb951ef8ba9d3570e94cbcb5efa43bf4154
[ "Unlicense" ]
permissive
Denmey/Terrain
fc96cfa3d977492d6b812079da2fc73dfba320a4
bf1dc5dfda018c9b3788524dc00a86e10d8f3b4d
refs/heads/master
2023-02-13T19:23:32.762045
2021-01-10T12:28:41
2021-01-10T12:28:41
258,827,988
0
0
null
null
null
null
UTF-8
C++
false
false
381
hpp
Clock.hpp
#pragma once #define GLFW_INCLUDE_NONE #include <GLFW/glfw3.h> namespace Trn { class Clock { public: Clock(); void update(); double currentTime() const; double previousTime() const; double deltaTime() const; private: private: double m_currentTime = 0.0; double m_previousTime = 0.0; double m_deltaTime = 0.0; }; } // namespace Trn
c0d7f59555a39277706ef728f70c1f05ceb45693
09e38c683fd8deee413c595146419a2b5064bb09
/src/vector.cc
c309c80d7d7c1acf08c943a3a7fa9a2c3e88d628
[ "MIT" ]
permissive
hiro-dot-exe/patient-observer
e4b6cb3e975ab2b25c11ef83d3d83e9dadda7db7
5a684248e0f4ddba7e96110b6be2c6e0fc0ea153
refs/heads/master
2022-08-13T01:37:00.787167
2020-05-18T16:15:44
2020-05-18T16:15:44
264,993,355
1
0
null
null
null
null
UTF-8
C++
false
false
1,681
cc
vector.cc
#include "vector.h" #define _USE_MATH_DEFINES // M_PI #include <math.h> // M_PI, sqrt(), pow(), acos() Vector::Vector(double initX, double initY, double initZ) : x(initX), y(initY), z(initZ) { } Vector::Vector() : x(0.0), y(0.0), z(0.0) { } Vector Vector::Add(const Vector &v) const { Vector answer; answer.x = x + v.x; answer.y = y + v.y; answer.z = z + v.z; return answer; } Vector Vector::Subtract(const Vector &v) const { Vector answer; answer.x = x - v.x; answer.y = y - v.y; answer.z = z - v.z; return answer; } Vector Vector::Cross(const Vector &v) const { Vector answer; answer.x = y * v.z - z * v.y; answer.y = z * v.x - x * v.z; answer.z = x * v.y - y * v.x; return answer; } double Vector::Dot(const Vector &v) const { return x * v.x + y * v.y + z * v.z; } double Vector::Length() const { return sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)); } Vector Vector::Normalize() const { Vector answer; double length = Length(); if (0 < length) { answer.x = x / length; answer.y = y / length; answer.z = z / length; } return answer; } double Vector::AngleRadian(const Vector &v) const { double angle = 0.0; if (0 < Length() && 0 < v.Length()) angle = acos(Dot(v) / Length() / v.Length()); return angle; } double Vector::AngleDegree(const Vector &v) const { return AngleRadian(v) * 180 / M_PI; } Vector Vector::Normal(const Vector &v1, const Vector &v2) const { Vector normal; normal.x = (y - v2.y) * (v1.z - z) - (z - v2.z) * (v1.y - y); normal.y = (z - v2.z) * (v1.x - x) - (x - v2.x) * (v1.z - z); normal.z = (x - v2.x) * (v1.y - y) - (y - v2.y) * (v1.x - x); return normal; }
14ab3a2e07485e42e85484567ac6d4c5ece82343
b59919a3d3bdf9876f17459427c4767b79687d17
/Src/Logic/Entity/Components/SunController.h
12222401fb531c95f71450e815452019047c230f
[]
no_license
yarpee/DamnedSunset
a7fd113f7406e9a331d00611948690ceaa3d13b3
2de62f680cf1ba11d8fc5848c337818a9d7a6ebe
refs/heads/master
2020-03-19T10:02:01.476681
2012-10-15T09:43:28
2012-10-15T09:43:28
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
4,189
h
SunController.h
/** @file SunController.h Contiene la declaración del componente que controla el movimiento del sol y el la luz ambiental. @see Logic::CSunController @see Logic::IComponent @author Daniel Flamenco @date Enero, 2012 */ #ifndef __Logic_SunController_H #define __Logic_SunController_H #include "Logic/Entity/Component.h" #include "BaseSubsystems/Math.h" //declaración de la clase namespace Logic { /** Este componente es el encargado de mover a una entidad animada. Tiene diferentes métodos que permiten avances o giros. El uso de este componente es un poco atípico ya que se puede registrar en otro controlador externo (i.e. GUI::CPlayerController) que sea el que de las órdenes que se deben llevar a cabo mediante llamadas a métodos públicos del componente. Puede no obstante ampliarse este componente para aceptar mensajes tradicionales con las órdenes, sin embargo de momento así es suficiente. @ingroup logicGroup @author Daniel Flamenco @date Enero, 2012 */ class CSunController : public IComponent { DEC_FACTORY(CSunController); public: /** Constructor por defecto; inicializa los atributos a su valor por defecto. */ CSunController() : IComponent(), _theta(Math::PI / 2), _phi(0), _speed(1.0f) {} /** Inicialización del componente, utilizando la información extraída de la entidad leída del mapa (Maps::CEntity). Toma del mapa el atributo speed que indica a la velocidad a la que se moverá el jugador. @param entity Entidad a la que pertenece el componente. @param map Mapa Lógico en el que se registrará el objeto. @param entityInfo Información de construcción del objeto leído del fichero de disco. @return Cierto si la inicialización ha sido satisfactoria. */ virtual bool spawn(CEntity* entity, CMap *map, const Map::CEntity *entityInfo); /** Método que activa el componente; invocado cuando se activa el mapa donde está la entidad a la que pertenece el componente. <p> Si el componente pertenece a la entidad del jugador, el componente se registra así mismo en el controlador del GUI para que las ordenes se reciban a partir de los eventos de teclado y ratón. @return true si todo ha ido correctamente. */ virtual bool activate(); /** Método que desactiva el componente; invocado cuando se desactiva el mapa donde está la entidad a la que pertenece el componente. Se invocará siempre, independientemente de si estamos activados o no. <p> Si el componente pertenece a la entidad del jugador, el componente se deregistra así mismo en el controlador del GUI para dejar de recibir las ordenes dadas a partir de los eventos de teclado y ratón. */ virtual void deactivate(); /** Método llamado en cada frame que actualiza el estado del componente. <p> Se encarga de mover la entidad en cada vuelta de ciclo cuando es necesario (cuando está andando o desplazándose lateralmente). @param msecs Milisegundos transcurridos desde el último tick. */ virtual void tick(unsigned int msecs); /** Método virtual que elige que mensajes son aceptados. Este componente no acepta ningún mensaje. @param message Mensaje a chequear. @return true si el mensaje es aceptado. */ virtual bool accept(IMessage *message); /** Método virtual que procesa un mensaje. @param message Mensaje a procesar. */ virtual void process(IMessage *message); protected: /** Atributo para saber la velocidad a la que avanza el sol. */ float _speed; /** Angulo al que se encuentra el sol sobre el horizonte. */ float _phi; /** Angulo que está girado el sol sobre la perpendicular al horizonte. */ float _theta; /** Distancia a la que se encuentra el sol desde el origen de coordenadas. */ float _sphereRad; /** Color actual de la iluminación ambiental. */ Vector3 _currentColor; unsigned int _lastColorChanged; }; // class CSunController REG_FACTORY(CSunController); } // namespace Logic #endif // __Logic_SunController_H
e65c31657a533e78646da26140e970d54f4e6eec
ec10d4320fdbad0bab61b5fa00c0bf27e50ce6f1
/code/engine/vieigen/sources/vieigendouble.cpp
667bfea686293ea14ba059b578efd41c114d4b55
[]
no_license
dualword/Visore
d9e97c5a53cdd0c812c41a52ce169bd7c04b765d
db402f0bb69b25fccbca7500f275fac8a629b1f9
refs/heads/master
2023-03-17T12:38:02.901936
2015-01-29T06:06:32
2015-01-29T06:06:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,621
cpp
vieigendouble.cpp
#include <vieigendouble.h> ViEigenMatrixDouble::ViEigenMatrixDouble() : EigenMatrixDouble() { } ViEigenMatrixDouble::ViEigenMatrixDouble(const int &size) : EigenMatrixDouble(size, size) { int i, j; for(i = 0; i < size; ++i) { for(j = 0; j < size; ++j) this->coeffRef(i, j) = 0; } } ViEigenMatrixDouble::ViEigenMatrixDouble(const int &rows, const int &columns) : EigenMatrixDouble(rows, columns) { int i, j; for(i = 0; i < rows; ++i) { for(j = 0; j < columns; ++j) this->coeffRef(i, j) = 0; } } void ViEigenMatrixDouble::get(double &result, const int &row, const int &column) { result = this->coeffRef(row, column); } void ViEigenMatrixDouble::get(double &result, const int &row, const int &column) const { result = this->coeffRef(row, column); } void ViEigenMatrixDouble::get(mpfr::mpreal &result, const int &row, const int &column) { result = this->coeffRef(row, column); } void ViEigenMatrixDouble::get(mpfr::mpreal &result, const int &row, const int &column) const { result = this->coeffRef(row, column); } void ViEigenMatrixDouble::set(const int &row, const int &column, const double &value) { this->coeffRef(row, column) = value; } void ViEigenMatrixDouble::set(const int &row, const int &column, const mpfr::mpreal &value) { this->coeffRef(row, column) = value.toDouble(); } void ViEigenMatrixDouble::setPower(const int &row, const int &column, const double &base, const int &exponent) { set(row, column, std::pow(base, exponent)); } void ViEigenMatrixDouble::setPowerMulti(const int &row, const int &column, const double &multi, const double &base, const int &exponent) { set(row, column, multi * std::pow(base, exponent)); } void ViEigenMatrixDouble::setSin(const int &row, const int &column, const double &value) { set(row, column, std::sin(value)); } void ViEigenMatrixDouble::setCos(const int &row, const int &column, const double &value) { set(row, column, std::cos(value)); } void ViEigenMatrixDouble::setSinMulti(const int &row, const int &column, const double &multi, const double &value) { set(row, column, multi * std::sin(value)); } void ViEigenMatrixDouble::setCosMulti(const int &row, const int &column, const double &multi, const double &value) { set(row, column, multi * std::cos(value)); } QString ViEigenMatrixDouble::toString(const int &precision) const { QString result = ""; for(int i = 0; i < this->rows(); ++i) { for(int j = 0; j < this->cols(); ++j) { result += eigenToString(this->coeff(i, j), precision) + " "; } result += "\n"; } return result; } ViEigenVectorDouble::ViEigenVectorDouble() : EigenVectorDouble() { } ViEigenVectorDouble::ViEigenVectorDouble(const int &rows) : EigenVectorDouble(rows) { for(int i = 0; i < rows; ++i) this->coeffRef(i) = 0; } ViEigenVectorDouble::ViEigenVectorDouble(const EigenVectorDouble &other) : EigenVectorDouble(other) { } void ViEigenVectorDouble::get(double &result, const int &row) { result = this->coeffRef(row); } void ViEigenVectorDouble::get(double &result, const int &row) const { result = this->coeffRef(row); } void ViEigenVectorDouble::get(mpfr::mpreal &result, const int &row) { result = this->coeffRef(row); } void ViEigenVectorDouble::get(mpfr::mpreal &result, const int &row) const { result = this->coeffRef(row); } void ViEigenVectorDouble::set(const int &row, const double &value) { this->coeffRef(row) = value; } void ViEigenVectorDouble::set(const int &row, const mpfr::mpreal &value) { this->coeffRef(row) = value.toDouble(); } QString ViEigenVectorDouble::toString(const int &precision) const { QString result = ""; for(int i = 0; i < this->rows(); ++i) { result += eigenToString(this->coeff(i), precision) + " "; } result += "\n"; return result; } void ViEigenDouble::intialize(mpfr::mpreal &value) { } ViEigenBaseMatrix* ViEigenDouble::createMatrix() { return new ViEigenMatrixDouble(); } ViEigenBaseMatrix* ViEigenDouble::createMatrix(const int &size) { return new ViEigenMatrixDouble(size); } ViEigenBaseMatrix* ViEigenDouble::createMatrix(const int &rows, const int &columns) { return new ViEigenMatrixDouble(rows, columns); } ViEigenBaseVector* ViEigenDouble::createVector() { return new ViEigenVectorDouble(); } ViEigenBaseVector* ViEigenDouble::createVector(const int &rows) { return new ViEigenVectorDouble(rows); } ViEigenBaseVector* ViEigenDouble::estimate(const ViEigenBaseMatrix *matrix, const ViEigenBaseVector *vector) { return cast(cast(matrix)->fullPivHouseholderQr().solve(*cast(vector))); } void ViEigenDouble::solve(const ViEigenBaseVector *coefficients, const ViEigenBaseMatrix *values, double *output, const int &outputSize, const int &offset) { const ViEigenVectorDouble *castCoefficients = cast(coefficients); const ViEigenMatrixDouble *castValues = cast(values); double result; int i, j; for(i = 0; i < outputSize; ++i) { result = 0; for(j = 0; j < castValues->cols(); ++j) { result += castCoefficients->coeffRef(j + offset) * castValues->coeffRef(i, j); } if(result < -1) result = -1; else if(result > 1) result = 1; output[i] = result; } } void ViEigenDouble::solve(const ViEigenBaseVector *coefficients, const ViEigenBaseMatrix *values, double *output, const int &outputSize, const int *offset) { const ViEigenVectorDouble *castCoefficients = cast(coefficients); const ViEigenMatrixDouble *castValues = cast(values); double result; int i, j; for(i = 0; i < outputSize; ++i) { result = 0; for(j = 0; j < castValues->cols(); ++j) { result += castCoefficients->coeffRef(offset[i] + j) * castValues->coeffRef(i, j); } if(result < -1) result = -1; else if(result > 1) result = 1; output[i] = result; } } void ViEigenDouble::clear(ViEigenBaseMatrix *matrix) { delete cast(matrix); // Cast first, otherwise there are memory leaks matrix = NULL; } void ViEigenDouble::clear(ViEigenBaseVector *vector) { delete cast(vector); // Cast first, otherwise there are memory leaks vector = NULL; } inline const ViEigenMatrixDouble* ViEigenDouble::cast(const ViEigenBaseMatrix *matrix) const { return (const ViEigenMatrixDouble*) matrix; } inline const ViEigenVectorDouble* ViEigenDouble::cast(const ViEigenBaseVector *vector) const { return (const ViEigenVectorDouble*) vector; } inline ViEigenMatrixDouble* ViEigenDouble::cast(ViEigenBaseMatrix *matrix) const { return (ViEigenMatrixDouble*) matrix; } inline ViEigenVectorDouble* ViEigenDouble::cast(ViEigenBaseVector *vector) const { return (ViEigenVectorDouble*) vector; } ViEigenVectorDouble* ViEigenDouble::cast(const EigenVectorDouble &vector) const { return new ViEigenVectorDouble(vector); }
02e012f7a90777a246a1bb83ed630b4cc3d185f4
b6cdff45c1e3e7052487f6fa819cfd3b5e5d2542
/LNQuang-bai2.cpp
a3775e793cb0a5b2b28b3afa73e987aa0734a28e
[]
no_license
QuangNLee/C-Final-Exam
4e075cb35c848476d6ab189d0d9c81b5338ffce1
3e9f6ef9b4d7ae09a839b39f28ea6ca66481f9bc
refs/heads/master
2020-08-31T19:39:30.315573
2019-10-31T13:10:25
2019-10-31T13:10:25
218,768,368
0
0
null
null
null
null
UTF-8
C++
false
false
491
cpp
LNQuang-bai2.cpp
#include<stdio.h> #include<math.h> int main(){ int n; float interest_rate,capital, interest; printf("Enter Capital Sum: \t"); scanf("%f",&capital); printf("\nEnter Rate of Interest: \t"); scanf("%f",&interest_rate); printf("\nEnter No of year: \t"); scanf("%d",&n); for(int i=1;i<=n;i++){ interest = capital*(interest_rate/100); capital+=interest; interest=capital; printf("Year \t Interest \t Sum \n%d \t %f \t %f\n",i,interest,capital); } return 0; }
343cb50a96062c2406105d83cd6576b97dc4028d
5faedde7e894769aad042015ce56f30c77d67fda
/Experiment6.0.cpp
9b8a387424f7621f89ebd6124d05722343a07ba6
[]
no_license
MaruAlgio/Experiment-2
587d37ebdc602415e3817346217af8d81ddc2f30
5d17c82b7702b4c54def81398fb824d8acde6432
refs/heads/master
2020-05-19T08:10:55.032070
2019-05-05T22:36:44
2019-05-05T22:36:44
184,914,742
0
0
null
null
null
null
UTF-8
C++
false
false
581
cpp
Experiment6.0.cpp
// PROBLEM 6 - Custom Calculator. /* The total terms here are 22 since it includes the first 0 and 1 and then the succeeding 20 terms. */ #include <iostream> #include <conio.h> using namespace std; int main () { int Maru; int x = 1; do { cout << "Enter a number: "; cin >> Maru; if (Maru >= 1) { int sum = 0; for ( x=1 ; x <= Maru ; x++) { sum += x; } cout << "The sum of all whole numbers from 1 to "<< Maru << " is " << sum << ".\n"; } else break; } while (x > 0); getch (); return 0; }
c0b8076ec17880939e6ff50e2c45afcc654a9ab6
1221f25393be9ee6d3375c22802d70b237236c7e
/code/init/views/SplashView.h
4defb06b9cdb818e1e82d696dc11612f2c064c73
[]
no_license
ajatprabha/CS223_Apr18_02
19625a7bf76f4fe5cfb8097eddca6f1250ff188e
f51c14397c91d6cce10adcd74bca0e7d2756f461
refs/heads/master
2021-04-03T01:35:19.393757
2018-04-24T18:25:23
2018-04-24T20:52:07
124,763,461
2
0
null
null
null
null
UTF-8
C++
false
false
538
h
SplashView.h
// // Created by ajatprabha on 12/3/18. // #ifndef CLASSROOMBOOKINGSYSTEM_SPLASHVIEW_H #define CLASSROOMBOOKINGSYSTEM_SPLASHVIEW_H #include <controller.h> #include <base/views/View.h> class SplashView : public View { public: SplashView() : View("Welcome to ClassRoomBooking system\nChoose from the options below\n", {"Login", "Exit"}, {Controller::getInstance().getView("login"), Controller::getInstance().getView("exit")}) {} void display() override; }; #endif //CLASSROOMBOOKINGSYSTEM_SPLASHVIEW_H
854d5e51b95f83cceb6b23fb9268a9ab9d95730a
78970aebaa5cc619fc4a69bd4ce8f158a070dc53
/md5.cpp
0e8834e3c9728df53ba6107191ff208a49ebc03b
[]
no_license
cachpachios/md5-optimisation
0116d9f5044d37d88d61134da81e3856d6ee777d
31fc4e985ca9efbed5810c665d415b19e089ebee
refs/heads/master
2023-08-19T15:28:55.635739
2021-10-20T04:35:36
2021-10-20T04:35:36
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,798
cpp
md5.cpp
#include <stdint.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <stdio.h> #include "md5-x86-asm.h" #include "md5-arm-asm.h" template<typename HT> void md5_init(MD5_STATE<HT>* state) { state->A = 0x67452301; state->B = 0xefcdab89; state->C = 0x98badcfe; state->D = 0x10325476; } #ifdef __AVX512VL__ #include <immintrin.h> template<> void md5_init<__m128i>(MD5_STATE<__m128i>* state) { state->A = _mm_cvtsi32_si128(0x67452301); state->B = _mm_cvtsi32_si128(0xefcdab89); state->C = _mm_cvtsi32_si128(0x98badcfe); state->D = _mm_cvtsi32_si128(0x10325476); } #endif template<typename HT, void(&fn)(MD5_STATE<HT>*, const void*)> void md5(MD5_STATE<HT>* state, const void* __restrict__ src, size_t len) { md5_init<HT>(state); char* __restrict__ _src = (char* __restrict__)src; uint64_t totalLen = len << 3; // length in bits for(; len >= 64; len -= 64) { fn(state, _src); _src += 64; } len &= 63; // finalize char block[64]; memcpy(block, _src, len); block[len++] = 0x80; // write this in a loop to avoid duplicating the force-inlined process_block function twice for(int iter = (len <= 64-8); iter < 2; iter++) { if(iter == 0) { memset(block + len, 0, 64-len); len = 0; } else { memset(block + len, 0, 64-8 - len); memcpy(block + 64-8, &totalLen, 8); } fn(state, block); } } bool do_tests(const char* expected, const void* __restrict__ src, size_t len) { MD5_STATE<uint32_t> hash; md5<uint32_t, md5_block_std>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; #ifdef PLATFORM_X86 md5<uint32_t, md5_block_gopt>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; md5<uint32_t, md5_block_ghopt>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; md5<uint32_t, md5_block_nolea>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; md5<uint32_t, md5_block_noleag>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; md5<uint32_t, md5_block_noleagh>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; #ifdef PLATFORM_AMD64 md5<uint32_t, md5_block_cache4>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; md5<uint32_t, md5_block_cache8>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; md5<uint32_t, md5_block_cache_gopt>(&hash, src, len); if(memcmp(&hash, expected, 16)) return true; #ifdef __AVX512VL__ MD5_STATE<__m128i> hashV; md5<__m128i, md5_block_avx512>(&hashV, src, len); hash.A = _mm_cvtsi128_si32(hashV.A); hash.B = _mm_cvtsi128_si32(hashV.B); hash.C = _mm_cvtsi128_si32(hashV.C); hash.D = _mm_cvtsi128_si32(hashV.D); if(memcmp(&hash, expected, 16)) return true; #endif #endif #endif return false; } #ifdef _WIN32 // because high-resolution timer in MinGW is questionable: https://github.com/msys2/MINGW-packages/issues/5086 # define WIN32_LEAN_AND_MEAN # include <windows.h> static uint64_t queryPerfFreq() { LARGE_INTEGER f; QueryPerformanceFrequency(&f); return f.QuadPart; } static uint64_t perfFreq = queryPerfFreq(); class Timer { uint64_t beg_; static uint64_t getTime() { LARGE_INTEGER t; QueryPerformanceCounter(&t); return t.QuadPart; } public: Timer() { reset(); } void reset() { beg_ = getTime(); } double elapsed() const { return (double)(getTime() - beg_) / perfFreq; } }; #else // from https://stackoverflow.com/a/19471595/459150 #include <chrono> class Timer { public: Timer() : beg_(clock_::now()) {} void reset() { beg_ = clock_::now(); } double elapsed() const { return std::chrono::duration_cast<second_> (clock_::now() - beg_).count(); } private: typedef std::chrono::high_resolution_clock clock_; typedef std::chrono::duration<double, std::ratio<1> > second_; std::chrono::time_point<clock_> beg_; }; #endif const size_t TEST_SIZE = 16384; // same as OpenSSL max const unsigned NUM_TRIALS = 5; const unsigned NUM_ROUNDS = 16384; void* benchData; #include <float.h> template<typename HT, void(&fn)(MD5_STATE<HT>*, const void*)> static void run_bench(const char* label) { std::cout << label; MD5_STATE<HT> hash; double result = DBL_MAX; int trial = NUM_TRIALS; while(trial--) { int rounds = NUM_ROUNDS; Timer t; while(rounds--) { md5<HT, fn>(&hash, benchData, TEST_SIZE); } //asm(""::"m"(hash):); // force hash to be written double secs = t.elapsed(); if(secs < result) result = secs; } printf("%8.1f MB/s\n", (double)(TEST_SIZE*NUM_ROUNDS/1048576) / result); } int main(void) { #define TEST_ERROR(s) std::cout << "TEST ERROR: " s << std::endl if(do_tests("\xd4\x1d\x8c\xd9\x8f\0\xb2\x04\xe9\x80\x09\x98\xec\xf8\x42\x7e", "", 0)) TEST_ERROR("Failed blank"); if(do_tests("\x0c\xc1\x75\xb9\xc0\xf1\xb6\xa8\x31\xc3\x99\xe2\x69\x77\x26\x61", "a", 1)) TEST_ERROR("Failed partial block"); if(do_tests("\x3d\x37\x3b\x8c\xd6\xfd\x06\x9d\x31\x3c\xdc\x3f\x38\xa1\x89\x63", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012", 55)) // everything fits in an MD5 block TEST_ERROR("Failed nearly full block"); if(do_tests("\xd4\x3e\x61\xe9\xb5\xf8\xc9\xd2\x2c\x4d\xc5\xdb\x6e\x6d\xf7\x75", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123", 56)) // just crosses one byte into second block TEST_ERROR("Failed nearly full block (2)"); if(do_tests("\xce\x3a\x13\xcb\x6c\x59\xe1\xda\xd8\xa1\x70\xec\xd5\x0f\x0c\xe8", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-", 63)) TEST_ERROR("Failed nearly full block (3)"); if(do_tests("\x2a\x37\x87\xf9\x92\x07\xe3\x6b\x2c\xb2\xc3\x40\x68\x92\xde\xf0", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_", 64)) TEST_ERROR("Failed full block"); if(do_tests("\x77\xf8\x6b\xd2\x20\x76\xca\x4e\x99\x0f\xc7\xba\x77\x78\x11\x13", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_=", 65)) TEST_ERROR("Failed full+partial block"); if(do_tests("\x9b\x27\x94\x27\xd4\x81\xc9\xc9\xc7\x1d\x9a\xcb\x4f\xc9\xe9\x9a", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_", 128)) TEST_ERROR("Failed two full blocks"); // run benchmark benchData = calloc(1, TEST_SIZE); run_bench<uint32_t, md5_block_std>( "Std : "); #ifdef PLATFORM_X86 run_bench<uint32_t, md5_block_gopt>("GOpt : "); run_bench<uint32_t, md5_block_ghopt>("GHOpt : "); run_bench<uint32_t, md5_block_nolea>("NoLEA : "); run_bench<uint32_t, md5_block_noleag>("NoL-G : "); run_bench<uint32_t, md5_block_noleagh>("NoL-GH: "); #ifdef PLATFORM_AMD64 run_bench<uint32_t, md5_block_cache4>("Cache4: "); run_bench<uint32_t, md5_block_cache8>("Cache8: "); run_bench<uint32_t, md5_block_cache_gopt>("Cach8G: "); #ifdef __AVX512VL__ run_bench<__m128i, md5_block_avx512>("AVX512: "); #endif #endif #endif return 0; }
96ab29b6f133d02c2a9b2ad9bc43b7c7178df75d
0e8f2bdbbb5e1433e2fa20742e36db918e1c0cfc
/Derivator.cpp
7ed672f54b97f20550f07a00bf8b6109f583e69e
[]
no_license
a-m-j-s/FC-ElectromangeticShowerSimulation
38abe099ed82616e8a7e8a2048f2f2bce0baeb71
c62a6e78b8220ba0005f54d54852d82f2d46e582
refs/heads/main
2023-07-09T14:10:31.376700
2021-08-11T19:50:40
2021-08-11T19:50:40
394,981,902
0
1
null
null
null
null
UTF-8
C++
false
false
3,076
cpp
Derivator.cpp
#include"Func1D.h" #include"Derivator.h" #include"Vec1.h" #include"FCmatrix.h" #include"FCmatrixFull.h" #include"EqSolver.h" #include"TF1.h" #include<stdio.h> #include<iostream> using namespace std; //#define DEBUG void Derivator::FDerivative(double x,double h,double &Derivative){ #if defined(DEBUG) printf("[%s]\n", __PRETTY_FUNCTION__); #endif if(h!=0){ Derivative=(1/(12*h))*((p->Eval(x-2*h)+8*p->Eval(x+h))-(8*p->Eval(x-h)+p->Eval(x+2*h))); } } void Derivator::SDerivative(double x,double h,double &Derivative){ #if defined(DEBUG) printf("[%s]\n", __PRETTY_FUNCTION__); #endif if(h!=0){ Derivative=(1/(12*h*h))*((16*p->Eval(x-h)+16*p->Eval(x+h))-(p->Eval(x-2*h)+30*p->Eval(x)+p->Eval(x+2*h)));} } void Derivator::FourthDerivative(double x,double h,double &Derivative){ #if defined(DEBUG) printf("[%s]\n", __PRETTY_FUNCTION__); #endif if(h!=0){ Derivative=((p->Eval(x+2*h)+6*p->Eval(x)+p->Eval(x-2*h))-(4*p->Eval(x+h)+4*p->Eval(x-h)))/(h*h*h*h); } } void Derivator::IDerivative(double fx, double &Derivative,double *x,double*y, int N){ #if defined(DEBUG) printf("[%s]\n", __PRETTY_FUNCTION__); #endif double **a=new double*[N-2]; for(int i=0;i<N-2;++i){ a[i]=new double[N-2]; for(int j=0;j<N-2;++j){ if(i==j){ a[i][j]=2*(x[i]-x[i+2]); } else if(i==j+1){ a[i][j]=(x[i]-x[i+1]); } else if(j==i+1){ a[i][j]=x[j]-x[j+1]; } else{ a[i][j]=0; } } } FCmatrixFull M(a,N-2,N-2); double *v=new double[N-2]; for(int i=0;i<N-2;++i){ v[i]=6*((y[i]-y[i+1])/(x[i]-x[i+1])-(y[i+1]-y[i+2])/(x[i+1]-x[i+2])); //cout<<v[i]<<endl; } Vec V(N-2,v); EqSolver E(M,V); Vec C=E.LUdecompositionSolver(); double *K=new double[N]; for(int i=1;i<N-1;++i){ K[i]=C[i-1]; //cout<<"K["<<i<<"]="<<K[i]<<endl; } K[0]=0; K[N-1]=0; int i; for(i=1;i<N;++i){ if((fx-x[i])<0.){break;} } Derivative=(K[i]/6)*(3*(fx-x[i+1])*(fx-x[i+1])/(x[i]-x[i+1])-(x[i]-x[i+1]))-(K[i+1]/6)*(3*(fx-x[i])*(fx-x[i])/(x[i]-x[i+1])-(x[i]-x[i+1]))+(y[i]-y[i+1])/(x[i]-x[i+1]); //segunda derivada=K[i]*(fx-x[i+1])/(x[i]-x[i+1])-K[i+1]*(fx-x[i])/(x[i]-x[i+1]); } double Derivator::fSDerivative(double *fx, double*par){ double d; SDerivative(fx[0],0.00001,d); return d; } double Derivator::fFDerivative(double *fx, double*par){ double d; FDerivative(fx[0],0.00001,d); return d; } double Derivator::fFourthDerivative(double *fx, double*par){ double d; FourthDerivative(fx[0],0.01,d); return d; } TF1* Derivator::GetfSDerivative(double x0, double x1){ TF1*Fd=new TF1("Fd",this, &Derivator::fSDerivative,x0,x1,0,"Derivator","SDerivative"); return Fd; } TF1* Derivator::GetfFDerivative(double x0,double x1){ TF1*Fd=new TF1("Fd",this, &Derivator::fFDerivative,x0,x1,0,"Derivator","SDerivative"); return Fd; } TF1* Derivator::GetfFourthDerivative(double x0, double x1){ TF1*Fd=new TF1("Fd",this, &Derivator::fFourthDerivative,x0,x1,0,"Derivator","SDerivative"); return Fd; }
653fa17529402621eefd077cf487dd44c696e2fc
48cb56db297506f3764efa2475c29082d49b669d
/simpleui/include/screenprinter.hpp
4b89b44453e07eaca11ad4f78ae1998e25ece433
[]
no_license
jbigot/Projet-GLCS-2020-2021
c3c3554111980ae513212d33af05656f6433f536
665cf5ff964bc26cc7cd31736b066c83a704f5f7
refs/heads/main
2023-02-10T21:51:05.791634
2021-01-08T10:16:37
2021-01-08T10:19:53
327,666,171
0
12
null
null
null
null
UTF-8
C++
false
false
454
hpp
screenprinter.hpp
#pragma once // library headers #include <simulationobserver.hpp> /** An implementation of SimulationObserver that prints the simulation data to * screen. * * \warning This class is inefficient, brittle and does not guarantee the correct * ordering of the values printed on screen. */ class ScreenPrinter : public SimulationObserver { public: // see overriden function void simulation_updated( const Distributed2DField& data ) override; };
6e1064afe0525797335b22e7d65d2f364b04fad8
7aa7aabfbf1218018f71a10f4d069d3dc0f602c0
/6.08/projects/ball_launcher/ex04_ball_starter/ex04_ball_starter.ino
273466eea4ade90927b2b0c131af38c51f7464da
[]
no_license
mtrejo0/SchoolWork
55f35b5223be1ce37fd071071037d3175bd41238
3b44d5cc9d7f6dc1f4be4e717d376f5ab1417f84
refs/heads/master
2020-06-19T22:47:05.146191
2019-07-15T01:40:51
2019-07-15T01:40:51
196,902,751
0
0
null
null
null
null
UTF-8
C++
false
false
4,041
ino
ex04_ball_starter.ino
#include <SPI.h> #include <TFT_eSPI.h> TFT_eSPI tft = TFT_eSPI(); // Set up the TFT object const int LOOP_SPEED = 25; unsigned long primary_timer; //main loop timer #define BACKGROUND TFT_BLACK #define BALL_COLOR TFT_WHITE const uint8_t BUTTON_PIN = 16; //CHANGE YOUR WIRING TO PIN 16!!! (FROM 19) class Ball { float x_pos = 64; //x position float y_pos = 80; //y position float x_vel; //x velocity float y_vel; //y velocity float x_accel; //x acceleration float y_accel; //y acceleration int BALL_CLR; int BKGND_CLR; float MASS; //for starters int RADIUS; //radius of ball float K_FRICTION; //friction coefficient float K_SPRING; //spring coefficient int LEFT_LIMIT; //left side of screen limit int RIGHT_LIMIT; //right side of screen limit int TOP_LIMIT; //top of screen limit int BOTTOM_LIMIT; //bottom of screen limit int DT; //timing for integration public: Ball(int rad = 4, float ms = 1, int ball_color = TFT_WHITE, int background_color = BACKGROUND) { x_pos = 64; //x position y_pos = 80; //y position x_vel = 0; //x velocity y_vel = 0; //y velocity x_accel = 0; //x acceleration y_accel = 0; //y acceleration BALL_CLR = ball_color; //ball color BKGND_CLR = background_color; MASS = ms; //for starters RADIUS = rad; //radius of ball K_FRICTION = 0.05; //friction coefficient K_SPRING = 0.9; //spring coefficient LEFT_LIMIT = RADIUS; //left side of screen limit RIGHT_LIMIT = 127 - RADIUS; //right side of screen limit TOP_LIMIT = RADIUS; //top of screen limit BOTTOM_LIMIT = 159 - RADIUS; //bottom of screen limit DT = LOOP_SPEED; //timing for integration } void step(float x_force = 0, float y_force = 0 ) { //update to your working ex02 implementation tft.drawCircle(x_pos, y_pos, RADIUS, BKGND_CLR); //update acceleration (from f=ma) x_force = x_force - x_vel * K_FRICTION; y_force = y_force - y_vel * K_FRICTION; x_accel = x_force / MASS; y_accel = y_force / MASS; //integrate to get velocity from current acceleration x_vel = x_vel + 0.001 * DT * x_accel; //integrate, 0.001 is conversion from milliseconds to seconds y_vel = y_vel + 0.001 * DT * y_accel; //integrate!! moveBall(); //you'll write this from scratch! tft.drawCircle(x_pos, y_pos, RADIUS, BALL_CLR); } void reset(int x = 64, int y = 32) { x_pos = x; y_pos = y; x_vel = 0; y_vel = 0; x_accel = 0; y_accel = 0; } private: void moveBall() { //Your code here! x_pos = x_pos + x_vel * DT / 1000; y_pos = y_pos + y_vel * DT / 1000; if (x_pos > RIGHT_LIMIT) { x_vel = -x_vel * K_SPRING; x_pos = x_pos - (x_pos - RIGHT_LIMIT) - (x_pos - RIGHT_LIMIT) * K_SPRING; } if (x_pos < LEFT_LIMIT) { x_vel = -x_vel * K_SPRING; x_pos = x_pos + (LEFT_LIMIT - x_pos) + (LEFT_LIMIT - x_pos) * K_SPRING; } if (y_pos > BOTTOM_LIMIT) { y_vel = -y_vel * K_SPRING; y_pos = y_pos - (y_pos - BOTTOM_LIMIT) - (y_pos - BOTTOM_LIMIT) * K_SPRING; } if (y_pos < TOP_LIMIT) { y_vel = -y_vel * K_SPRING; y_pos = y_pos + (TOP_LIMIT - y_pos) + (TOP_LIMIT - y_pos) * K_SPRING; } } }; Ball lots[20]; void setup() { Serial.begin(115200); //for debugging if needed. tft.init(); tft.setRotation(2); tft.setTextSize(1); tft.fillScreen(BACKGROUND); randomSeed(analogRead(0)); //initialize random numbers for (int i=0; i<20; i++) { lots[i].reset(); } delay(20); //wait 20 milliseconds for (int i=0; i<20; i++) { lots[i].step(random(-30000,30000),random(-30000,30000)); } primary_timer = millis(); } void loop() { for (int i=0; i<20; i++){ lots[i].step(); } while (millis()-primary_timer<LOOP_SPEED); //wait for primary timer to increment primary_timer = millis(); }
f2216b6b12c85c77f0685f03616e8eb2fb3ac715
1653acd0b8a476b55128b9af60c74366cc730568
/2018-2/support/utils.h
26a3cbf440c9707be1040aeb9681a16522bd46ba
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
sgtest/p4test
5c6ab62098e99413af8ee12b5911ad9cf7fc081e
0b065a1f4aad902f5860d03fa44d14e00ee980a4
refs/heads/master
2020-04-27T16:46:05.018649
2019-02-07T10:04:05
2019-02-07T10:04:05
174,492,667
1
0
null
null
null
null
UTF-8
C++
false
false
2,272
h
utils.h
/* * @file utils.h * * @brief miscellaneous utilties available to all * * Threading: none * * @invariants: * * Copyright (c) 2012 Perforce Software * Confidential. All Rights Reserved. * @author Wendy Heffner * * Creation Date: December 5, 2012 */ //////////////////////////////////////////////////////////////////////////// // RefCount - CLASS // //////////////////////////////////////////////////////////////////////////// class RefCount { public: RefCount() { count=0; } const int &Increment() { ++count; return count; } const int &Decrement() { --count; return count; } int Value() { return count; } private: int count; }; //////////////////////////////////////////////////////////////////////////// // SmartPointer - CLASS // //////////////////////////////////////////////////////////////////////////// /* * Reference counted smart pointer. If last smart pointer referencing the object * of type T leaves allocation scope then the destructor of smart pointer * will delete the referenced T object. */ template < typename T > class SmartPointer { public: SmartPointer() : pData(0), ref(0) { ref = new RefCount(); ref->Increment(); }; SmartPointer(T* t) : pData(t), ref(0) { ref = new RefCount(); ref->Increment(); }; SmartPointer(const SmartPointer<T>& ptr) : pData(ptr.pData), ref(ptr.ref) { ref->Increment(); }; ~SmartPointer() { if( ref->Decrement() == 0) { delete pData; delete ref; } }; T& operator* () { return *pData; }; T* operator-> () { return pData; }; SmartPointer<T>& operator = (const SmartPointer<T>& ptr) { // Am I on both rhs and lhs if so skip if (this != &ptr) { if( ref->Decrement() == 0) { delete pData; delete ref; } pData = ptr.pData; ref = ptr.ref; ref->Increment(); } return *this; }; private: T* pData; // data pointer RefCount* ref; // reference count }; // global utility funciton /** * ISHex * - return true if c is a valid character for a hex value, * - otherwise return false. */ bool IsHex( char c );
ac3e58c8e2771888c649f7d9cceb17a98f96edce
7c76919de4ccabb6e5f86c723f9e7771a3b5d95e
/src/ns_ui/UIRadioButton.h
1461cef04f3b082a1de77d9a96fd532a259f3b5f
[ "MIT" ]
permissive
shintaro4/cellophane
cdcbd09cb1b94207473ae6ea603437270b7834c9
6876c81886f75f74d1b61076b9298f277872db04
refs/heads/master
2021-06-30T23:51:35.116229
2016-11-03T07:32:02
2016-11-03T07:32:02
27,334,525
3
1
null
null
null
null
UTF-8
C++
false
false
1,496
h
UIRadioButton.h
// // UIRadioButton.h // #pragma once #include "UIButton.h" namespace cellophane { namespace ns_ui { class UIRadioButton : public BaseUI { public: //-------------------------------------------------------------- // interface //-------------------------------------------------------------- UIRadioButton(KU::Options option, float size, const std::vector<ofPoint>& anchors, const std::vector<std::string>& image_paths, int value); ~UIRadioButton(); virtual void draw(); virtual void touchDown(const ofTouchEventArgs& touch); virtual void touchUp(const ofTouchEventArgs& touch); virtual void setLayerAlpha(float layer_alpha); virtual bool inside(const ofTouchEventArgs& touch) const; int getValue() const; private: //-------------------------------------------------------------- // methods //-------------------------------------------------------------- UIRadioButton(const UIRadioButton&); UIRadioButton& operator=(const UIRadioButton&); void handleUIEvent(KU::UIEventArgs& args); void initButtons(float size, const std::vector<ofPoint>& anchors, const std::vector<std::string>& image_paths); //-------------------------------------------------------------- // members //-------------------------------------------------------------- int value_; std::vector<UIButton*> buttons_; }; } // namespace ns_ui } // namespace cellophane
d318e80f97effb6edf64bebeb16ad4800f2f88a6
0ce9e3d0643571994e5d95e1182e6a31ac9728c2
/data_acquisition/ptu/libs/digites/src/Console.cpp
ce77422ef27a4e88f99e4cc67d60ede073e23d55
[ "MIT" ]
permissive
HoliestCow/wind_daq
78fddb2407b857fdfb1d843b995b64cd13c837f8
6a8b30ba6b14b3162f2fa3144b52cdf7ed17ec3a
refs/heads/master
2021-01-19T19:16:49.840098
2020-01-06T18:02:17
2020-01-06T18:02:17
101,187,374
1
0
null
null
null
null
UTF-8
C++
false
false
9,089
cpp
Console.cpp
/****************************************************************************** * * CAEN SpA - Front End Division * Via Vetraia, 11 - 55049 - Viareggio ITALY * +390594388398 - www.caen.it * ***************************************************************************//** * \note TERMS OF USE: * 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. 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. The user relies on the * software, documentation and results solely at his own risk. ******************************************************************************/ #include "Console.h" #include <stdio.h> #include <stdarg.h> #ifdef linux #define CLEARSCR "clear" /*****************************************************************************/ static struct termios g_old_kbd_mode; static void cooked(void) { tcsetattr(0, TCSANOW, &g_old_kbd_mode); } static void raw(void) { static char init=0; struct termios new_kbd_mode; //if (init) return; /* put keyboard (stdin, actually) in raw, unbuffered mode */ tcgetattr(0, &g_old_kbd_mode); memcpy(&new_kbd_mode, &g_old_kbd_mode, sizeof(struct termios)); new_kbd_mode.c_lflag &= ~(ICANON | ECHO); new_kbd_mode.c_cc[VTIME] = 0; new_kbd_mode.c_cc[VMIN] = 1; tcsetattr(0, TCSANOW, &new_kbd_mode); /* when we exit, go back to normal, "cooked" mode */ atexit(cooked); init = 1; } // --------------------------------------------------------------------------------------------------------- // Init console window (terminal) // --------------------------------------------------------------------------------------------------------- int InitConsole() { raw(); return 0; } // --------------------------------------------------------------------------------------------------------- // GETCH // --------------------------------------------------------------------------------------------------------- int getch(void) { unsigned char temp; /* stdin = fd 0 */ if(read(0, &temp, 1) != 1) return 0; return temp; } // --------------------------------------------------------------------------------------------------------- // KBHIT // --------------------------------------------------------------------------------------------------------- int kbhit() { struct timeval timeout; fd_set read_handles; int status; /* check stdin (fd 0) for activity */ FD_ZERO(&read_handles); FD_SET(0, &read_handles); timeout.tv_sec = timeout.tv_usec = 0; status = select(0 + 1, &read_handles, NULL, NULL, &timeout); if(status < 0) { printf("select() failed in kbhit()\n"); exit(1); } return (status); } // --------------------------------------------------------------------------------------------------------- // SCANF (change termios settings, then execute scanf) // --------------------------------------------------------------------------------------------------------- int _scanf(char *fmt, ...) { int ret; cooked(); va_list args; va_start(args, fmt); ret = vscanf(fmt, args); va_end(args); raw(); return ret; } // --------------------------------------------------------------------------------------------------------- // Description: get time from the computer // Return: time in ms // --------------------------------------------------------------------------------------------------------- long get_time() { long time_ms; struct timeval t1; struct timezone tz; gettimeofday(&t1, &tz); time_ms = (t1.tv_sec) * 1000 + t1.tv_usec / 1000; return time_ms; } // --------------------------------------------------------------------------------------------------------- // Description: get write time of a file // Return: 0: OK, -1: error // --------------------------------------------------------------------------------------------------------- int GetFileUpdateTime(char *fname, uint64_t *ftime) { struct stat t_stat; *ftime = 0; stat(fname, &t_stat); //struct tm * timeinfo = localtime(&t_stat.st_mtime); *ftime = (uint64_t)t_stat.st_mtime; // last modification time return 0; } // --------------------------------------------------------------------------------------------------------- // Description: clear the console // --------------------------------------------------------------------------------------------------------- void ClearScreen() { // HACK : how to clear screen in Linux? } // --------------------------------------------------------------------------------------------------------- // Description: get a string from stdin (space are allowed) // Input: str: pointer to the string // MaxCount: max num of characters // Return: size of the string // --------------------------------------------------------------------------------------------------------- int GetString(char *str, int MaxCounts) { fflush(stdin); cooked(); fgets(str, MaxCounts, stdin); raw(); return(strlen(str)); } #else // Windows #include <windows.h> #include <tchar.h> #include <strsafe.h> // --------------------------------------------------------------------------------------------------------- // Init console window (terminal) // --------------------------------------------------------------------------------------------------------- int InitConsole() { // Set console window size system("mode con: cols=80 lines=60"); return 0; } // --------------------------------------------------------------------------------------------------------- // Description: clear the console // --------------------------------------------------------------------------------------------------------- void ClearScreen() { system("cls"); } // --------------------------------------------------------------------------------------------------------- // Description: get time from the computer // Return: time in ms // --------------------------------------------------------------------------------------------------------- long get_time() { long time_ms; struct _timeb timebuffer; _ftime( &timebuffer ); time_ms = (long)timebuffer.time * 1000 + (long)timebuffer.millitm; return time_ms; } // --------------------------------------------------------------------------------------------------------- // Description: get write time of a file // Return: 0: OK, -1: error // --------------------------------------------------------------------------------------------------------- int GetFileUpdateTime(char *fname, uint64_t *ftime) { FILETIME ftCreate, ftAccess, ftWrite; SYSTEMTIME stUTC, stLocal; HANDLE hFile; wchar_t wtext[200]; mbstowcs(wtext, fname, strlen(fname)+1);//Plus null LPWSTR ptr = wtext; *ftime = 0; hFile = CreateFile(ptr, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if(hFile == INVALID_HANDLE_VALUE) return -1; // Retrieve the file times for the file. if (!GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite)) return -1; // Convert the last-write time to local time. FileTimeToSystemTime(&ftWrite, &stUTC); SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); CloseHandle(hFile); //printf("Y=%d M=%d D=%d - H=%d, min=%d, sec=%d\n", stLocal.wYear, stLocal.wMonth, stLocal.wDay, stLocal.wHour, stLocal.wMinute, stLocal.wSecond); *ftime = 366*31*24*3600*(uint64_t)stLocal.wYear + 31*24*3600*(uint64_t)stLocal.wMonth + 24*3600*(uint64_t)stLocal.wDay + 3600*(uint64_t)stLocal.wHour + 60*(uint64_t)stLocal.wMinute + (uint64_t)stLocal.wSecond; return 0; } // --------------------------------------------------------------------------------------------------------- // Description: get a string from stdin (space are allowed) // Input: str: pointer to the string // MaxCount: max num of characters // Return: size of the string // --------------------------------------------------------------------------------------------------------- int GetString(char *str, int MaxCounts) { fflush(stdin); fgets(str, MaxCounts, stdin); return((int)strlen(str)); } #endif // --------------------------------------------------------------------------------------------------------- // Description: printf to screen and to log file // Return: 0: OK // --------------------------------------------------------------------------------------------------------- int msg_printf(FILE *MsgLog, char *fmt, ...) { va_list args; va_start(args, fmt); vfprintf(MsgLog, fmt, args); fflush(MsgLog); va_end(args); va_start(args, fmt); vprintf(fmt, args); va_end(args); return 0; }
58d268d00ec5e7d9cde6e6983bfeefba7399162c
4bec0306800897b05aac563161d3147d305c1c1a
/src/blogger/blog.cpp
b8388a72d7b7b329ac559eae25d1c2050730e1ba
[ "CC0-1.0", "BSD-3-Clause" ]
permissive
KDE/libkgapi
03d5d494406ff44ddb1797c2f3d6e8d9892454d8
4fbde0ea726bf3759a05298ecab9d8e40e72da8a
refs/heads/master
2023-08-24T12:26:21.881120
2023-08-08T01:52:54
2023-08-08T01:52:54
42,723,656
9
9
null
null
null
null
UTF-8
C++
false
false
3,832
cpp
blog.cpp
/* * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com> * * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL */ #include "blog.h" #include <QJsonDocument> using namespace KGAPI2::Blogger; class Q_DECL_HIDDEN Blog::Private { public: Private(); static BlogPtr fromJSON(const QVariant &json); QString id; QString name; QString description; QDateTime published; QDateTime updated; QUrl url; uint postsCount = 0; uint pagesCount = 0; QString language; QString languageVariant; QString country; QVariant customMetaData; }; Blog::Private::Private() { } Blog::Blog() : Object() , d(new Private) { } Blog::~Blog() { delete d; } QString Blog::id() const { return d->id; } QString Blog::name() const { return d->name; } QString Blog::description() const { return d->description; } QDateTime Blog::published() const { return d->published; } QDateTime Blog::updated() const { return d->updated; } QUrl Blog::url() const { return d->url; } uint Blog::postsCount() const { return d->postsCount; } uint Blog::pagesCount() const { return d->pagesCount; } QString Blog::language() const { return d->language; } QString Blog::country() const { return d->country; } QString Blog::languageVariant() const { return d->languageVariant; } QVariant Blog::customMetaData() const { return d->customMetaData; } BlogPtr Blog::Private::fromJSON(const QVariant &json) { BlogPtr blog(new Blog); const QVariantMap map = json.toMap(); blog->d->id = map[QStringLiteral("id")].toString(); blog->d->name = map[QStringLiteral("name")].toString(); blog->d->description = map[QStringLiteral("description")].toString(); blog->d->published = QDateTime::fromString(map[QStringLiteral("published")].toString(), Qt::ISODate); blog->d->updated = QDateTime::fromString(map[QStringLiteral("updated")].toString(), Qt::ISODate); blog->d->url = map[QStringLiteral("url")].toUrl(); blog->d->postsCount = map[QStringLiteral("posts")].toMap()[QStringLiteral("totalItems")].toUInt(); blog->d->pagesCount = map[QStringLiteral("pages")].toMap()[QStringLiteral("totalItems")].toUInt(); const QVariantMap locale = map[QStringLiteral("locale")].toMap(); blog->d->language = locale[QStringLiteral("language")].toString(); blog->d->country = locale[QStringLiteral("country")].toString(); blog->d->languageVariant = locale[QStringLiteral("variant")].toString(); const QString metadata = map[QStringLiteral("customMetaData")].toString(); QJsonDocument document = QJsonDocument::fromJson(metadata.toUtf8()); blog->d->customMetaData = document.toVariant(); return blog; } BlogPtr Blog::fromJSON(const QByteArray &rawData) { QJsonDocument document = QJsonDocument::fromJson(rawData); if (document.isNull()) { return BlogPtr(); } const QVariant json = document.toVariant(); const QVariantMap map = json.toMap(); if (map[QStringLiteral("kind")].toString() != QLatin1String("blogger#blog")) { return BlogPtr(); } return Private::fromJSON(map); } BlogsList Blog::fromJSONFeed(const QByteArray &rawData) { QJsonDocument document = QJsonDocument::fromJson(rawData); if (document.isNull()) { return BlogsList(); } const QVariant json = document.toVariant(); const QVariantMap map = json.toMap(); if (map[QStringLiteral("kind")].toString() != QLatin1String("blogger#blogList")) { return BlogsList(); } BlogsList items; const QVariantList blogs = map[QStringLiteral("items")].toList(); items.reserve(blogs.size()); for (const QVariant &blog : blogs) { items << Blog::Private::fromJSON(blog); } return items; }
64ec7e3e9c3bbeddfbfbe9887a6e5de7d7e30c82
cfd8eb4191254363cbac4384cfa334d52cb8e5fe
/sweetcher/sweetcher.ino
b2ecc785f5f3f978dff60421b3bc611168391278
[]
no_license
vlad-gheorghe/arduino
52c938058bda78da37287ba824c258bb167071d1
fccb2e70b83c6a2803f6294c7c975d8f2fa965b6
refs/heads/master
2020-03-14T17:24:50.946561
2016-10-29T14:00:38
2016-10-29T14:00:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,721
ino
sweetcher.ino
#include <EEPROM.h> int in = 3; int mode = 1; int a = 2; int b = 3; int c = 4; int d = 5; int e = 6; int f = 7; int g = 8; int signalOut = 11; int led = 13; boolean ledOn = false; int modeOut[] = {20, 73, 112, 152, 191, 250}; int digits[13][7][2] = { {{a, 0}, {b, 0}, {c, 0}, {d, 0}, {e, 0}, {f, 0}, {g, 1}},//0 {{a, 1}, {b, 0}, {c, 0}, {d, 1}, {e, 1}, {f, 1}, {g, 1}},//1 {{a, 0}, {b, 0}, {c, 1}, {d, 0}, {e, 0}, {f, 1}, {g, 0}},//2 {{a, 0}, {b, 0}, {c, 0}, {d, 0}, {e, 1}, {f, 1}, {g, 0}},//3 {{a, 1}, {b, 0}, {c, 0}, {d, 1}, {e, 1}, {f, 0}, {g, 0}},//4 {{a, 0}, {b, 1}, {c, 0}, {d, 0}, {e, 1}, {f, 0}, {g, 0}},//5 {{a, 0}, {b, 1}, {c, 0}, {d, 0}, {e, 0}, {f, 0}, {g, 0}},//6 {{a, 0}, {b, 0}, {c, 0}, {d, 1}, {e, 1}, {f, 1}, {g, 1}},//7 {{a, 0}, {b, 0}, {c, 0}, {d, 0}, {e, 0}, {f, 0}, {g, 0}},//8 {{a, 0}, {b, 0}, {c, 0}, {d, 0}, {e, 1}, {f, 0}, {g, 0}},//9 {{a, 1}, {b, 1}, {c, 1}, {d, 1}, {e, 1}, {f, 1}, {g, 1}},// blank {{a, 0}, {b, 1}, {c, 1}, {d, 1}, {e, 1}, {f, 1}, {g, 1}},// Highest Border {{a, 1}, {b, 1}, {c, 1}, {d, 0}, {e, 1}, {f, 1}, {g, 1}}// Lowest Border }; int blankScreen = 10; int highestBorder = 11; int lowestBorder = 12; void setup() { Serial.begin(9600); pinMode(in, INPUT); pinMode(a, OUTPUT); pinMode(b, OUTPUT); pinMode(c, OUTPUT); pinMode(d, OUTPUT); pinMode(e, OUTPUT); pinMode(f, OUTPUT); pinMode(g, OUTPUT); pinMode(led, OUTPUT); pinMode(signalOut, OUTPUT); loadDataFromEEPROM(); showNumber(1); } void showNumber(int num){ for(int i = 0; i < 7; i++) { digitalWrite(digits[num][i][0], digits[num][i][1]); } } void blink(){ ledOn = !ledOn; digitalWrite(led, ledOn); } void setMode(int mode) { //int val = map(mode, 1, 6, 20, 255); analogWrite(signalOut, modeOut[mode-1]); } int lookButtonCounter = 0; int readKeybordValue(){ int r = analogRead(in); if(r > 100) { delay(10); r = analogRead(in); } return r; } int getKeyNumber(int r){ int keyNum = 0; if(r < 500) { keyNum = 0; } else if(r < 705) { keyNum = 1;//680 } else if(r < 755) { keyNum = 2;//730 } else if(r < 820) { keyNum = 3;//785 } else if(r < 890) { keyNum = 6;//852 } else if(r < 975) { keyNum = 5;//930 } else { keyNum = 4; } return keyNum; } void loop() { blink(); int r = readKeybordValue(); int key = getKeyNumber(r); if(key > 0) { mode = key; if(key == 1) { lookButtonCounter++; if(lookButtonCounter > 10) { lookButtonCounter = 0; setupMode(); } } showNumber(mode); setMode(mode); Serial.print('mode='); Serial.println(mode, DEC); delay(100); } else { delay(50); lookButtonCounter = 0; } }
cf23d3ead0b658308ae176da22a94f972ecf5384
c84f4810ba016f271bfab0330f3d731793a685ba
/Lista 4/Gerenciamento_contas/Conta.h
459e2aee182c65444df60333c640c642a00ec387
[]
no_license
andersoncoutinho/Laboratorio-de-Linguagem-de-Programacao-I
0f017d658bdd3e79b9108cb4030ea6ba8c578899
acbd3467bd159241465c1fc571d40670de2d5fcb
refs/heads/main
2023-06-10T16:53:29.659514
2021-07-02T17:26:38
2021-07-02T17:26:38
349,862,663
1
0
null
null
null
null
UTF-8
C++
false
false
497
h
Conta.h
#ifndef CONTA_H #define CONTA_H #include <string> class Conta { public: Conta(); Conta(std::string nomeCliente, int numero); virtual void sacar(double); virtual void depositar(double); virtual double saldoTotalDisponivel(); virtual void getInfo(); void setNomeCliente(std::string); std::string getNomeCliente(); void setNumero(int); int getNumero(); void setSaldo(double); double getSaldo(); protected: std::string nomeCliente; int numero; double saldo; }; #endif
fef76985d98cb0f5297a77fe1c811dc00b0f0619
5a63bd6870346aa6593233b990303e743cdb8861
/SDK/ST_Team_structs.h
4f580926301b5cbdd100bff0a4551b1253cb3440
[]
no_license
zH4x-SDK/zBlazingSails-SDK
dc486c4893a8aa14f760bdeff51cea11ff1838b5
5e6d42df14ac57fb934ec0dabbca88d495db46dd
refs/heads/main
2023-07-10T12:34:06.824910
2021-08-27T13:42:23
2021-08-27T13:42:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,577
h
ST_Team_structs.h
#pragma once // Name: BS, Version: 1.536.0 #ifdef _MSC_VER #pragma pack(push, 0x8) #endif namespace SDK { //--------------------------------------------------------------------------- // Script Structs //--------------------------------------------------------------------------- // UserDefinedStruct ST_Team.ST_Team // 0x004C struct FST_Team { int TeamID_3_FFA23020468BBEDB9D8B689679B08025; // 0x0000(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) int TeamFirstNameRow_18_0285FB684A99ADA2FC6A22ABC25C4C18; // 0x0004(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) int EmblemRow_45_D509801E44B5CDF93EA797A6F1755BB9; // 0x0008(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) int EmblemIndex_46_B4430570403BD4FCD3D807A724391580; // 0x000C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) int TeamCOlorRow_25_B1C6B8954D3F3AEB713046A4DE9B1239; // 0x0010(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) bool Defeated_27_DAB622274CE24A0ECAF1F093646E09E6; // 0x0014(0x0001) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) unsigned char UnknownData00[0x3]; // 0x0015(0x0003) MISSED OFFSET int TeamRank_30_DCD44BB14FD517664032E8BAFD575142; // 0x0018(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) int GoldAmount_33_911CFEF542D478ABE8EABFAC26CEBD26; // 0x001C(0x0004) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) class ABP_Controller_C* LeaderController_38_F556E87F4DAA97B7C16BA4967B162B9F; // 0x0020(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnTemplate, IsPlainOldData) struct FText ShipName_41_0703C25848C7C25BDF4D67BF982DC174; // 0x0028(0x0018) (Edit, BlueprintVisible) struct FVector SpawnPoint_44_4C884FD6414FC3826C394C84FB7C92DF; // 0x0040(0x000C) (Edit, BlueprintVisible, ZeroConstructor, IsPlainOldData) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
24dc4c4e0bea6a5ab44bf0e8dc738624375ce54b
2f06ecd54b971cf789af33667f8f147aa965fe8c
/arrays/q7-arrays.cpp
4681f8699e7067fa74be2520fa66446084520e64
[]
no_license
umtince/C-introductory-exercises
9bfc3ba4b6667b833359fff4d8e3e72cc8717c68
dfe2e2956983a229b07d02a2317cf831d20051eb
refs/heads/master
2020-09-16T02:19:13.888563
2020-04-24T18:09:22
2020-04-24T18:09:22
223,620,600
0
1
null
null
null
null
UTF-8
C++
false
false
1,387
cpp
q7-arrays.cpp
#include <stdio.h> void ArraySortAndMerge(int a1[],int a2[],int elementB,int element1,int element2); int main() { int element1,element2,elementB; int i=0; printf("Input the number of elements to be stored in the first array:"); scanf("%d",&element1); int a1[element1]; printf("\nInput %d elements in the array:",element1); do { printf("\nelement-%d :",i); scanf("%d",&a1[i]); i++; }while(i<=element1-1); i=0; printf("Input the number of elements to be stored in the second array:"); scanf("%d",&element2); int a2[element2]; printf("\nInput %d elements in the array:",element2); do { printf("\nelement-%d :",i); scanf("%d",&a2[i]); i++; }while(i<=element2-1); elementB = element1 + element2; printf("The merged array in decending order is:\n"); ArraySortAndMerge(a1,a2,elementB,element1,element2); return 0; } void ArraySortAndMerge(int a1[],int a2[],int elementB,int element1,int element2) { int i,k,b[elementB],temporary; for(i=0; i<= element1-1; i++) { b[i] = a1[i]; } for(k=0; k<= element2-1; k++) { b[k+element1] = a2[k]; } for(int pass=0; pass< elementB; pass++) { for(int k=0; k<elementB-1; k++) { if(b[k]<=b[k+1]) { temporary = b[k]; b[k] = b[k+1]; b[k+1] = temporary; } } } for(int j=0; j< elementB; j++) { printf("%d ",b[j]); } }
be537e6c5b3e40a8871278077b3c2a206606690b
81e31a571f9263b317a60ab7e2fa6a62199aefa1
/icm-1.1/icm/Current.h
46c963e3b3efb5a6f51abdb8ad540a968d085e73
[]
no_license
qhjindev/icm
66910f1db5b9cf549b31817e3e2adeada4babd17
9e2a659dcf8c4cdadb71e129eedb667efc817517
refs/heads/master
2020-05-17T05:37:21.762348
2015-01-08T02:16:08
2015-01-08T02:16:08
28,762,156
3
1
null
null
null
null
UTF-8
C++
false
false
300
h
Current.h
#ifndef ICM_CURRENT_H #define ICM_CURRENT_H #include <string> #include "Object.h" #include "ObjectAdapter.h" #include "Connection.h" struct Current { ObjectAdapter* adapter; //Connection* con; Identity* id; std::string operation; Context ctx; }; #endif //ICM_CURRENT_H
db371c62ee9ff2465008d145f9398bd870822c5f
bfabf4e93e251cf03541749c732b384651fcc363
/stl/pair.cpp
8844da75896ffb5dd86f33937461746ca80ddcd3
[]
no_license
youndge/cpp
1d364a2bdaaea8fb90046518434d7d1a7c6d3115
530838d56fc0543c43c3c682ffce3c0f792abb8d
refs/heads/main
2023-07-27T18:41:24.504638
2021-09-09T15:42:53
2021-09-09T15:42:53
393,051,318
0
0
null
null
null
null
UTF-8
C++
false
false
2,052
cpp
pair.cpp
#include <utility> #include <iostream> #include <string> using namespace std; /** * 1.pair类构造函数 #1) 默认构造函数,即创建空的 pair 对象 pair(); #2) 直接使用 2 个元素初始化成 pair 对象 pair (const first_type& a, const second_type& b); #3) 拷贝(复制)构造函数,即借助另一个 pair 对象,创建新的 pair 对象 template<class U, class V> pair (const pair<U,V>& pr); #4) 移动构造函数 template<class U, class V> pair (pair<U,V>&& pr); #5) 使用右值引用参数,创建 pair 对象 template<class U, class V> pair (U&& a, V&& b); */ void pairConstructor(){ // 调用构造函数 1,也就是默认构造函数 pair <string, double> pair1; pair1.first = "hello"; pair1.second = 1.25; // 调用第 2 种构造函数 pair <string, string> pair2("STL教程","http://c.biancheng.net/stl/"); // 调用拷贝构造函数 pair <string, string> pair3(pair2); //调用移动构造函数 pair <string, string> pair4(make_pair("C++教程", "http://c.biancheng.net/cplus/")); // 调用第 5 种构造函数 pair <string, string> pair5(string("Python教程"), string("http://c.biancheng.net/python/")); cout << "pair1: " << pair1.first << " " << pair1.second << endl; cout << "pair2: "<< pair2.first << " " << pair2.second << endl; cout << "pair3: " << pair3.first << " " << pair3.second << endl; cout << "pair4: " << pair4.first << " " << pair4.second << endl; cout << "pair5: " << pair5.first << " " << pair5.second << endl; } /** * 2.pair比较 */ void pairCompare(){ pair <string, int> pair1("STL教程", 20); pair <string, int> pair2("C++教程", 20); pair <string, int> pair3("C++教程", 30); //pair1和pair2的key不同,value相同 if (pair1 != pair2) { cout << "pair != pair2" << endl; } //pair2和pair3的key相同,value不同 if (pair2 != pair3) { cout << "pair2 != pair3" << endl; } } int main(){ pairConstructor(); pairCompare(); return 0; }
9c168f84fdf811428c7c28fda79eb84266cf988c
d9a50abfe2b0a1adf655048ddba8ef302d750d53
/DERAS-Server/src/ieee_sep/gYear.cpp
5229497e7edbbee9a92c5d14b8a2aeb9e6d63398
[ "BSD-2-Clause" ]
permissive
psu-powerlab/DERAS-Server
f7ed520ee6885a77ac5d3b2f672d8a6502004c97
5b41f35148aa1ff45c1f6b3a96f94ce443a72d0f
refs/heads/master
2022-11-29T15:01:50.874535
2020-06-18T20:06:10
2020-06-18T20:06:10
261,805,865
0
0
BSD-2-Clause
2020-07-06T18:53:10
2020-05-06T15:44:56
C++
UTF-8
C++
false
false
279
cpp
gYear.cpp
/////////////////////////////////////////////////////////// // gYear.cpp // Implementation of the Class gYear // Created on: 13-Apr-2020 2:51:30 PM /////////////////////////////////////////////////////////// #include "gYear.h" gYear::gYear(){ } gYear::~gYear(){ }
bfec8ca1621813afaca0abd01cc5350970d789dd
413a1d85f164ab38ef876452ac3c363f9df058c4
/wiki_app/venv/lib/python3.5/site-packages/lucene-8.1.1-py3.5-linux-x86_64.egg/lucene/include/org/apache/lucene/analysis/standard/UAX29URLEmailAnalyzer.h
090296d4af3aeb22dd6f2fd7e065847a6e33be53
[]
no_license
prateek68/Wikipedia-Online-Content-Comparison
18d53e3456e2d7aa6eb67629c2ea1c79b7d8be4d
77d54b99881558b3195190740ba1be7f8328392b
refs/heads/master
2020-12-26T11:58:18.903011
2020-02-02T09:55:37
2020-02-02T09:55:37
237,495,848
1
2
null
null
null
null
UTF-8
C++
false
false
2,785
h
UAX29URLEmailAnalyzer.h
#ifndef org_apache_lucene_analysis_standard_UAX29URLEmailAnalyzer_H #define org_apache_lucene_analysis_standard_UAX29URLEmailAnalyzer_H #include "org/apache/lucene/analysis/StopwordAnalyzerBase.h" namespace java { namespace io { class Reader; class IOException; } namespace lang { class Class; } } namespace org { namespace apache { namespace lucene { namespace analysis { class CharArraySet; } } } } template<class T> class JArray; namespace org { namespace apache { namespace lucene { namespace analysis { namespace standard { class UAX29URLEmailAnalyzer : public ::org::apache::lucene::analysis::StopwordAnalyzerBase { public: enum { mid_init$_8e1955e8a9db094a, mid_init$_27bffdfab90e8f9d, mid_init$_4fd8e3a5e4256fa5, mid_getMaxTokenLength_ebe7ab370a509c13, mid_setMaxTokenLength_36df8fa8e39fb5cc, mid_createComponents_f24880e635cbdbf8, mid_normalize_0c7ab2510ceda208, max_mid }; static ::java::lang::Class *class$; static jmethodID *mids$; static bool live$; static jclass initializeClass(bool); explicit UAX29URLEmailAnalyzer(jobject obj) : ::org::apache::lucene::analysis::StopwordAnalyzerBase(obj) { if (obj != NULL && mids$ == NULL) env->getClass(initializeClass); } UAX29URLEmailAnalyzer(const UAX29URLEmailAnalyzer& obj) : ::org::apache::lucene::analysis::StopwordAnalyzerBase(obj) {} static jint DEFAULT_MAX_TOKEN_LENGTH; static ::org::apache::lucene::analysis::CharArraySet *STOP_WORDS_SET; UAX29URLEmailAnalyzer(); UAX29URLEmailAnalyzer(const ::org::apache::lucene::analysis::CharArraySet &); UAX29URLEmailAnalyzer(const ::java::io::Reader &); jint getMaxTokenLength() const; void setMaxTokenLength(jint) const; }; } } } } } #include <Python.h> namespace org { namespace apache { namespace lucene { namespace analysis { namespace standard { extern PyType_Def PY_TYPE_DEF(UAX29URLEmailAnalyzer); extern PyTypeObject *PY_TYPE(UAX29URLEmailAnalyzer); class t_UAX29URLEmailAnalyzer { public: PyObject_HEAD UAX29URLEmailAnalyzer object; static PyObject *wrap_Object(const UAX29URLEmailAnalyzer&); static PyObject *wrap_jobject(const jobject&); static void install(PyObject *module); static void initialize(PyObject *module); }; } } } } } #endif
c8972452792ba7b5d28a512c7ca4716efc609707
26135a1362f8cb9638cc9649ec9cc2a11e2cd66e
/src/Transform/ONNX/ShapeInferencePass.cpp
c7b0f31dda165f8beda53e650ec34a7c2db10f4f
[ "Apache-2.0", "LicenseRef-scancode-dco-1.1" ]
permissive
onnx/onnx-mlir
81003870714bf743aac7b08666563552aac34a5b
8919cf3198e8e98960d95b1fb163a58f43c52070
refs/heads/main
2023-08-28T13:18:14.750654
2023-08-28T09:57:10
2023-08-28T09:57:10
241,400,276
590
286
Apache-2.0
2023-09-14T18:46:19
2020-02-18T15:43:43
C++
UTF-8
C++
false
false
1,912
cpp
ShapeInferencePass.cpp
/* * SPDX-License-Identifier: Apache-2.0 */ //===------- ShapeInferencePass.cpp - Shape Inference ---------------------===// // // Copyright 2019-2023 The IBM Research Authors. // // ============================================================================= // // ShapeInferencePass infers shapes for all operations and propagates shapes // to their users and function signature return types. // //===----------------------------------------------------------------------===// #include "mlir/Dialect/Func/IR/FuncOps.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Interfaces/CallInterfaces.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "src/Pass/Passes.hpp" #include "src/Transform/ONNX/ShapeInference.hpp" using namespace mlir; namespace onnx_mlir { namespace { class ShapeInferencePass : public PassWrapper<ShapeInferencePass, OperationPass<func::FuncOp>> { public: MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(ShapeInferencePass) StringRef getArgument() const override { return "shape-inference"; } StringRef getDescription() const override { return "ONNX shape inference."; } LogicalResult initialize(MLIRContext *context) override { RewritePatternSet cumulativePatterns(context); getShapeInferencePatterns(cumulativePatterns); patterns = FrozenRewritePatternSet(std::move(cumulativePatterns)); return success(); } void runOnOperation() override { func::FuncOp f = getOperation(); GreedyRewriteConfig config; config.useTopDownTraversal = true; (void)applyPatternsAndFoldGreedily(f.getBody(), patterns, config); inferFunctionReturnShapes(f); } FrozenRewritePatternSet patterns; }; } // end anonymous namespace /*! * Create a Shape Inference pass. */ std::unique_ptr<Pass> createShapeInferencePass() { return std::make_unique<ShapeInferencePass>(); } } // namespace onnx_mlir
aa2c49b12ae5bc2dbeea9a8ef5c4bce825b45a70
e2bad7304a6a07271ec3b927b4a7ebc0da0d1e83
/Classwork/AFS_Archive/volume_user.mcresap/cse20311/lab11/fern.cpp
3a53493b34bf17d15125033f031ddb725a24aa40
[]
no_license
mcresap/ND
8fadf03aad4d50f9548ed52203466055e6e8bdba
c973ad1348747580ca638bab3f3f047bddf9d9d8
refs/heads/master
2022-11-16T00:05:47.618952
2020-07-07T01:31:07
2020-07-07T01:31:07
277,685,329
0
0
null
null
null
null
UTF-8
C++
false
false
2,117
cpp
fern.cpp
// Recursive function to generate the Sierpinski triangle fractal. // From main, you would call this function to draw the outer triangle. // The function will then recurse to draw all the inner triangles // (you will of course have to write a triangle drawing function). // NOTE: // you may only use this code if you fully understand how it works. #include "gfx.h" #include <stdlib.h> #include <cmath> #include <iostream> using namespace std; //void tree(int,int, int, int, int); void tree(int, int, int, float); int main() { int w=800; int h=800; char c=0; int marg=20; float pi=atan(1)*4; //calculate pi gfx_open(w, h, "tree"); gfx_color(255, 255, 255); while (c!='q'){ c=gfx_wait(); if (c==1) tree(w/2, h-marg, (2*h/3), -pi/2); //tree(w/2, h-marg, w/2, 3*h/5, (h-marg)-(3*h/5)); } return 0; } //void tree( int x1, int y1, int x2, int y2, int len) void tree(int x1, int y1, int len, float ang) { float pi=atan(1)*4; //calculate pi // Base case. if( abs(len) < 5 ) return; // Draw the triangle //mytriangledrawingfunction( x1, y1, x2, y2, x3, y3 ); gfx_line(x1, y1, x1+len*cos(ang), y1+len*sin(ang)); //len=pow((pow(y2-y1, 2)+pow((x2-x1), 2)), (1/2))/2; //cout << x1 << ' ' << x2; // gfx_line(x1, y1, x1+x1*cos(2*pi/5), y1+y1*sin(2*pi/5)); //gfx_line(x3, y3, x1, y1); // Recursive calls //tree(x2, y2, x2-x2*sin(2*pi/5), y2-y2*sin(2*pi/5), len); //tree(x2, y2, x2-x2*cos(4*pi/5), y2-y2*sin(4*pi/5), len); tree(x1+len*cos(ang)*.25, y1+len*sin(ang)*.25, len/3, ang+pi/6); tree(x1+len*cos(ang)*.25, y1+len*sin(ang)*.25, len/3, ang-pi/6); tree(x1+len*cos(ang)*.5, y1+len*sin(ang)*.5, len/3, ang-pi/6 ); tree(x1+len*cos(ang)*.5, y1+len*sin(ang)*.5, len/3, ang+pi/6); tree(x1+len*cos(ang)*.75, y1+len*sin(ang)*.75, len/3, ang+pi/6); tree(x1+len*cos(ang)*.75, y1+len*sin(ang)*.75, len/3, ang-pi/6); tree(x1+len*cos(ang), y1+len*sin(ang), len/3, ang+pi/6); tree(x1+len*cos(ang), y1+len*sin(ang), len/3, ang-pi/6); //tree(x1, y1, ); //tree(x1, y1, ); }
9f8fee6d5855508290222e38b9d075edde316234
2555cbc320199097f339b1de7ffc3b1fe197bc4e
/Source/AgeOfSurvival/CPPCharacterAI.cpp
c0a28cdceb5d05cee5b336775888992a62faeeb5
[ "BSD-2-Clause" ]
permissive
JensenJ/AgeOfSurvival
74c55c99ccd63905150848b5ed3ec861a9c98802
8329ad9f96e039818f0e731318435d06f56f3f2f
refs/heads/Distribution
2020-04-15T00:40:47.780523
2019-01-26T22:20:39
2019-01-26T22:20:39
164,248,766
0
0
BSD-2-Clause
2019-01-26T22:20:40
2019-01-05T20:29:14
C++
UTF-8
C++
false
false
109
cpp
CPPCharacterAI.cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "CPPCharacterAI.h"
8a0d12044ec1fee069d2dc4e5db4f44a4619afed
bfa78ed6d5b741902d17549e5c0e923f42dbf716
/sceneManager/patch.cpp
e071c04c49cc908a8526925655c864029ab8d819
[]
no_license
lucio81/3DGraph
8591a1ad1c8c372650a667cefb385e0a7c9979da
9fef6c9912d6fe9844063e5cd460e1980b5cf2c7
refs/heads/master
2020-06-01T16:18:26.268421
2012-02-14T10:44:52
2012-02-14T10:44:52
550,797
1
0
null
null
null
null
UTF-8
C++
false
false
4,240
cpp
patch.cpp
#include"sceneManager/patch.h" #include<QColor> void Geometry::loadArrays() const { glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); glNormalPointer(GL_FLOAT, 0, normals.constData()); } void Geometry::finalize() { // TODO: add vertex buffer uploading here // Finish smoothing normals by ensuring accumulated normals are returned // to length 1.0. for (int i = 0; i < normals.count(); ++i) normals[i].normalize(); } void Geometry::appendSmooth(const QVector3D &a, const QVector3D &n, int from) { // Smooth normals are acheived by averaging the normals for faces meeting // at a point. First find the point in geometry already generated // (working backwards, since most often the points shared are between faces // recently added). int v = vertices.count() - 1; for ( ; v >= from; --v) if (qFuzzyCompare(vertices[v], a)) break; if (v < from) { // The vert was not found so add it as a new one, and initialize // its corresponding normal v = vertices.count(); vertices.append(a); normals.append(n); } else { // Vert found, accumulate normals into corresponding normal slot. // Must call finalize once finished accumulating normals normals[v] += n; } // In both cases (found or not) reference the vert via its index faces.append(v); } void Geometry::appendFaceted(const QVector3D &a, const QVector3D &n) { // Faceted normals are achieved by duplicating the vert for every // normal, so that faces meeting at a vert get a sharp edge. int v = vertices.count(); vertices.append(a); normals.append(n); faces.append(v); } void Patch::qSetColor(float colorVec[], QColor c) { colorVec[0] = c.redF(); colorVec[1] = c.greenF(); colorVec[2] = c.blueF(); colorVec[3] = c.alphaF(); }; Patch::Patch(Geometry *g) : start(g->faces.count()) , count(0) , initv(g->vertices.count()) , sm(Patch::Smooth) , geom(g) { qSetColor(faceColor, QColor(Qt::darkGray)); } void Patch::rotate(qreal deg, QVector3D axis) { mat.rotate(deg, axis); } void Patch::translate(const QVector3D &t) { mat.translate(t); } static inline void qMultMatrix(const QMatrix4x4 &mat) { if (sizeof(qreal) == sizeof(GLfloat)) glMultMatrixf((GLfloat*)mat.constData()); #ifndef QT_OPENGL_ES else if (sizeof(qreal) == sizeof(GLdouble)) glMultMatrixd((GLdouble*)mat.constData()); #endif else { GLfloat fmat[16]; qreal const *r = mat.constData(); for (int i = 0; i < 16; ++i) fmat[i] = r[i]; glMultMatrixf(fmat); } } void Patch::draw() const { glPushMatrix(); qMultMatrix(mat); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, faceColor); const GLushort *indices = geom->faces.constData(); glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_SHORT, indices + start); glPopMatrix(); } void Patch::addTri(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &n) { QVector3D norm = n.isNull() ? QVector3D::normal(a, b, c) : n; if (sm == Smooth) { geom->appendSmooth(a, norm, initv); geom->appendSmooth(b, norm, initv); geom->appendSmooth(c, norm, initv); } else { geom->appendFaceted(a, norm); geom->appendFaceted(b, norm); geom->appendFaceted(c, norm); } count += 3; } void Patch::addQuad(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &d) { QVector3D norm = QVector3D::normal(a, b, c); if (sm == Smooth) { addTri(a, b, c, norm); addTri(a, c, d, norm); } else { // If faceted share the two common verts addTri(a, b, c, norm); int k = geom->vertices.count(); geom->appendSmooth(a, norm, k); geom->appendSmooth(c, norm, k); geom->appendFaceted(d, norm); count += 3; } } static inline QVector<QVector3D> extrude(const QVector<QVector3D> &verts, qreal depth) { QVector<QVector3D> extr = verts; for (int v = 0; v < extr.count(); ++v) extr[v].setZ(extr[v].z() - depth); return extr; }
8e7357877a34e83f8a32e989158e70717169239d
ef38f0e1a85f4f9f1444a76f5ebaf7c234a01835
/src/server/game/Battlegrounds/BattleGround.h
ed27958656faba84313cf4898bf7f0dd3d02000b
[]
no_license
Refuge89/sunstrider-core
189546853dfc896cbde75181e29d0f2ec6fcf2fb
6295c804be78ddafdccfc08cce0d9cf8fe7f50ca
refs/heads/master
2020-03-23T10:50:17.426306
2018-07-18T14:26:38
2018-07-18T14:26:44
141,465,214
2
0
null
2018-07-18T17:04:05
2018-07-18T17:04:04
null
UTF-8
C++
false
false
25,407
h
BattleGround.h
#ifndef __BATTLEGROUND_H #define __BATTLEGROUND_H #include "Opcodes.h" #include "ObjectMgr.h" #include "SharedDefines.h" #include "SpectatorAddon.h" #include "Position.h" struct PvPDifficultyEntry; enum BattlegroundSounds { SOUND_HORDE_WINS = 8454, SOUND_ALLIANCE_WINS = 8455, SOUND_BG_START = 3439, SOUND_BG_START_L70ETC = 11803, }; enum BattlegroundQuests { SPELL_WS_QUEST_REWARD = 43483, SPELL_AB_QUEST_REWARD = 43484, SPELL_AV_QUEST_REWARD = 43475, SPELL_AV_QUEST_KILLED_BOSS = 23658, SPELL_EY_QUEST_REWARD = 43477, SPELL_AB_QUEST_REWARD_4_BASES = 24061, SPELL_AB_QUEST_REWARD_5_BASES = 24064 }; enum BattlegroundMarks { ITEM_AV_MARK_OF_HONOR = 20560, ITEM_WS_MARK_OF_HONOR = 20558, ITEM_AB_MARK_OF_HONOR = 20559, ITEM_EY_MARK_OF_HONOR = 29024 }; enum BattlegroundMarksCount { ITEM_WINNER_COUNT = 3, ITEM_LOSER_COUNT = 1 }; enum BattlegroundSpells { SPELL_WAITING_FOR_RESURRECT = 2584, // Waiting to Resurrect SPELL_SPIRIT_HEAL_CHANNEL = 22011, // Spirit Heal Channel SPELL_SPIRIT_HEAL = 22012, // Spirit Heal SPELL_RESURRECTION_VISUAL = 24171, // Resurrection Impact Visual SPELL_ARENA_PREPARATION = 32727, // use this one, 32728 not correct SPELL_ALLIANCE_GOLD_FLAG = 32724, SPELL_ALLIANCE_GREEN_FLAG = 32725, SPELL_HORDE_GOLD_FLAG = 35774, SPELL_HORDE_GREEN_FLAG = 35775, SPELL_PREPARATION = 44521, // Preparation SPELL_SPIRIT_HEAL_MANA = 44535, // Spirit Heal SPELL_RECENTLY_DROPPED_FLAG = 42792, // Recently Dropped Flag SPELL_AURA_PLAYER_IDLE = 43680, // When reported idle by other players, removed by PvP Combat SPELL_AURA_PLAYER_INACTIVE = 43681 // After 1 min Idle }; enum BattlegroundTimeIntervals { CHECK_PLAYER_POSITION_INVERVAL = 1 * SECOND * IN_MILLISECONDS, // ms RESURRECTION_INTERVAL = 30 * SECOND * IN_MILLISECONDS, // ms //REMIND_INTERVAL = 30 * SECOND * IN_MILLISECONDS, INVITATION_REMIND_TIME = 20 * SECOND * IN_MILLISECONDS, // ms INVITE_ACCEPT_WAIT_TIME = 80 * SECOND * IN_MILLISECONDS, // ms TIME_TO_AUTOREMOVE = 2 * MINUTE * IN_MILLISECONDS, MAX_OFFLINE_TIME = 2 * MINUTE * SECOND, START_DELAY0 = 2 * MINUTE * IN_MILLISECONDS, START_DELAY1 = 1 * MINUTE * IN_MILLISECONDS, START_DELAY2 = 30 * SECOND * IN_MILLISECONDS, START_DELAY3 = 15 * SECOND * IN_MILLISECONDS, //used only in arena RESPAWN_ONE_DAY = DAY, // secs RESPAWN_IMMEDIATELY = 0, // secs BUFF_RESPAWN_TIME = 3 * MINUTE, // secs BG_HONOR_SCORE_TICKS = 330 // points }; enum BattlegroundBuffObjects { BG_OBJECTID_SPEEDBUFF_ENTRY = 179871, BG_OBJECTID_REGENBUFF_ENTRY = 179904, BG_OBJECTID_BERSERKERBUFF_ENTRY = 179905 }; const uint32 Buff_Entries[3] = { BG_OBJECTID_SPEEDBUFF_ENTRY, BG_OBJECTID_REGENBUFF_ENTRY, BG_OBJECTID_BERSERKERBUFF_ENTRY }; enum BattlegroundStatus { STATUS_NONE = 0, STATUS_WAIT_QUEUE = 1, STATUS_WAIT_JOIN = 2, STATUS_IN_PROGRESS = 3, STATUS_WAIT_LEAVE = 4 // custom }; enum BattlegroundStartingEvents { BG_STARTING_EVENT_NONE = 0x00, BG_STARTING_EVENT_1 = 0x01, //BG_STARTING_EVENT_2 = 0x02, //unused BG_STARTING_EVENT_3 = 0x04, BG_STARTING_EVENT_4 = 0x08, BG_STARTING_EVENT_5 = 0x10, }; struct BattlegroundPlayer { uint32 OfflineRemoveTime; // for tracking and removing offline players from queue after 2 minutes uint32 TotalOfflineTime; uint32 Team; // Player's team }; struct BattlegroundObjectInfo { BattlegroundObjectInfo() : object(nullptr), timer(0), spellid(0) {} GameObject *object; int32 timer; uint32 spellid; }; struct PlayerLogInfo { ObjectGuid::LowType guid; std::string ip; uint32 heal; uint32 damage; uint8 kills; }; enum ScoreType { SCORE_KILLING_BLOWS = 1, SCORE_DEATHS = 2, SCORE_HONORABLE_KILLS = 3, SCORE_BONUS_HONOR = 4, //EY, but in MSG_PVP_LOG_DATA opcode! SCORE_DAMAGE_DONE = 5, SCORE_HEALING_DONE = 6, //WS SCORE_FLAG_CAPTURES = 7, SCORE_FLAG_RETURNS = 8, //AB SCORE_BASES_ASSAULTED = 9, SCORE_BASES_DEFENDED = 10, //AV SCORE_GRAVEYARDS_ASSAULTED = 11, SCORE_GRAVEYARDS_DEFENDED = 12, SCORE_TOWERS_ASSAULTED = 13, SCORE_TOWERS_DEFENDED = 14, SCORE_MINES_CAPTURED = 15, SCORE_LEADERS_KILLED = 16, SCORE_SECONDARY_OBJECTIVES = 17, // TODO : implement them SCORE_DAMAGE_TAKEN = 20, SCORE_HEALING_TAKEN = 21, }; enum ArenaType { ARENA_TYPE_2v2 = 2, ARENA_TYPE_3v3 = 3, ARENA_TYPE_5v5 = 5 }; enum BattlegroundType { TYPE_BATTLEGROUND = 3, TYPE_ARENA = 4 }; enum BattlegroundWinner { WINNER_HORDE = 0, WINNER_ALLIANCE = 1, WINNER_NONE = 2 }; /* re enable this if GroupJoinBattlegroundResult is not usable on BC enum BattlegroundJoinError { BG_JOIN_ERR_OK = 0, BG_JOIN_ERR_OFFLINE_MEMBER = 1, BG_JOIN_ERR_GROUP_TOO_MANY = 2, BG_JOIN_ERR_MIXED_FACTION = 3, BG_JOIN_ERR_MIXED_LEVELS = 4, BG_JOIN_ERR_MIXED_ARENATEAM = 5, BG_JOIN_ERR_GROUP_MEMBER_ALREADY_IN_QUEUE = 6, BG_JOIN_ERR_GROUP_DESERTER = 7, BG_JOIN_ERR_ALL_QUEUES_USED = 8, BG_JOIN_ERR_GROUP_NOT_ENOUGH = 9 }; */ class BattlegroundScore { public: BattlegroundScore() : KillingBlows(0), HonorableKills(0), Deaths(0), DamageDone(0), HealingDone(0), BonusHonor(0) {}; virtual ~BattlegroundScore() //virtual destructor is used when deleting score from scores map = default;; uint32 KillingBlows; uint32 Deaths; uint32 HonorableKills; uint32 BonusHonor; uint32 DamageDone; uint32 HealingDone; uint32 DamageTaken; uint32 HealingTaken; }; enum BGHonorMode { BG_NORMAL = 0, BG_HOLIDAY, BG_HONOR_MODE_NUM }; typedef std::map<uint64, BattlegroundScore*> BattlegroundScoreMap; /* This class is used to: 1. Add player to battleground 2. Remove player from battleground 3. some certain cases, same for all battlegrounds 4. It has properties same for all battlegrounds */ class TC_GAME_API Battleground { friend class BattlegroundMgr; public: /* Construction */ Battleground(); /*Battleground(const Battleground& bg);*/ virtual ~Battleground(); virtual void Update(time_t diff); // must be implemented in BG subclass of BG specific update code, but must in begginning call parent version virtual bool SetupBattleground() // must be implemented in BG subclass { return true; } void Reset(); // resets all common properties for battlegrounds virtual void ResetBGSubclass() // must be implemented in BG subclass { } /* Battleground */ // Get methods: std::string const& GetName() const { return m_Name; } BattlegroundTypeId GetTypeID() const { return m_TypeID; } BattlegroundBracketId GetBracketId() const { return m_BracketId; } uint32 GetInstanceID() const { return m_InstanceID; } uint32 GetStatus() const { return m_Status; } uint32 GetClientInstanceID() const { return m_ClientInstanceID; } uint32 GetLastResurrectTime() const { return m_LastResurrectTime; } uint32 GetMaxPlayers() const { return m_MaxPlayers; } uint32 GetMinPlayers() const { return m_MinPlayers; } uint32 GetMinLevel() const { return m_LevelMin; } uint32 GetMaxLevel() const { return m_LevelMax; } uint32 GetMaxPlayersPerTeam() const { return m_MaxPlayersPerTeam; } uint32 GetMinPlayersPerTeam() const { return m_MinPlayersPerTeam; } int GetStartDelayTime() const { return m_StartDelayTime; } uint32 GetTimeLimit() const { return m_timeLimit; } time_t GetStartTimestamp() const { return time(nullptr) - GetStartTime(); } uint8 GetArenaType() const { return m_ArenaType; } uint8 GetWinner() const { return m_Winner; } uint32 GetScriptId() const { return ScriptId; } uint32 GetBattlemasterEntry() const; uint32 GetStartTime() const { return m_StartTime; } uint32 GetEndTime() const { return m_EndTime; } // Set methods: void SetName(std::string Name) { m_Name = Name; } void SetTypeID(BattlegroundTypeId TypeID) { m_TypeID = TypeID; } //here we can count minlevel and maxlevel for players void SetBracket(PvPDifficultyEntry const* bracketEntry); void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; } void SetStatus(BattlegroundStatus Status); void SetClientInstanceID(uint32 InstanceID) { m_ClientInstanceID = InstanceID; } void SetStartTime(uint32 Time) { m_StartTime = Time; } void SetEndTime(uint32 Time) { m_EndTime = Time; } void SetLastResurrectTime(uint32 Time) { m_LastResurrectTime = Time; } void SetMaxPlayers(uint32 MaxPlayers) { m_MaxPlayers = MaxPlayers; } void SetMinPlayers(uint32 MinPlayers) { m_MinPlayers = MinPlayers; } void SetLevelRange(uint32 min, uint32 max) { m_LevelMin = min; m_LevelMax = max; } void SetRated(bool state) { m_IsRated = state; } void SetArenaType(uint8 type) { m_ArenaType = type; } void SetArenaorBGType(bool _isArena) { m_IsArena = _isArena; } void SetWinner(uint8 winner) { m_Winner = winner; } void SetScriptId(uint32 scriptId) { ScriptId = scriptId; } //Set a time limit before closing void SetTimeLimit(uint32 limit) { m_timeLimit = limit; } //Decrease timer before gates opening void ModifyStartDelayTime(int diff) { m_StartDelayTime -= diff; } //Set timer before gates opening void SetStartDelayTime(int Time); void SetMaxPlayersPerTeam(uint32 MaxPlayers) { m_MaxPlayersPerTeam = MaxPlayers; } void SetMinPlayersPerTeam(uint32 MinPlayers) { m_MinPlayersPerTeam = MinPlayers; } void AddToBGFreeSlotQueue(); //this queue will be useful when more battlegrounds instances will be available void RemoveFromBGFreeSlotQueue(); //this method could delete whole BG instance, if another free is available void DecreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; } void IncreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; } void PlayerInvitedInRatedArena(Player* player, uint32 team); uint32 GetInvitedCount(uint32 team) const { if( team == ALLIANCE ) return m_InvitedAlliance; else return m_InvitedHorde; } bool HasFreeSlots() const; uint32 GetFreeSlotsForTeam(uint32 Team) const; bool IsArena() const { return m_IsArena; } bool isBattleground() const { return !m_IsArena; } bool isRated() const { return m_IsRated; } typedef std::map<ObjectGuid, BattlegroundPlayer> BattlegroundPlayerMap; BattlegroundPlayerMap const& GetPlayers() const { return m_Players; } uint32 GetPlayersSize() const { return m_Players.size(); } std::map<ObjectGuid, BattlegroundScore*>::const_iterator GetPlayerScoresBegin() const { return PlayerScores.begin(); } std::map<ObjectGuid, BattlegroundScore*>::const_iterator GetPlayerScoresEnd() const { return PlayerScores.end(); } uint32 GetPlayerScoresSize() const { return PlayerScores.size(); } uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); } void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid); void RemovePlayerFromResurrectQueue(ObjectGuid player_guid); void StartBattleground(); GameObject* GetBGObject(uint32 type, bool logError = true); Creature* GetBGCreature(uint32 type, bool logError = true); /* Location */ void SetMapId(uint32 MapID) { m_MapId = MapID; } uint32 GetMapId() const { return m_MapId; } // Map pointers void SetBgMap(BattlegroundMap* map) { m_Map = map; } BattlegroundMap* GetBgMap() const { ASSERT(m_Map); return m_Map; } BattlegroundMap* FindBgMap() const { return m_Map; } void SetTeamStartPosition(TeamId TeamID, Position const& pos); Position const* GetTeamStartPosition(TeamId teamId) const; void SetStartMaxDist(float startMaxDist) { m_StartMaxDist = startMaxDist; } float GetStartMaxDist() const { return m_StartMaxDist; } /* Packet Transfer */ // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!) virtual void FillInitialWorldStates(WorldPacket& /*data*/) {} void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender = nullptr, bool self = true); void SendPacketToAll(WorldPacket *packet); void PlaySoundToTeam(uint32 SoundID, uint32 TeamID); void PlaySoundToAll(uint32 SoundID); template<class Do> void BroadcastWorker(Do& _do); void CastSpellOnTeam(uint32 SpellID, uint32 TeamID); void RewardHonorToTeam(uint32 Honor, uint32 TeamID); void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID); void RewardMark(Player *plr,uint32 count); void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count); void RewardQuest(Player *plr); void UpdateWorldState(uint32 Field, uint32 Value); void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source); void EndBattleground(uint32 winner); void BlockMovement(Player *plr); void SendWarningToAll(int32 entry, ...); void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = nullptr); void PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ...); // specialized version with 2 string id args void SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 strId1 = 0, int32 strId2 = 0); void SendMessageToAll(char const* text); void SendMessageToAll(int32 entry); /* Raid Group */ Group *GetBgRaid(uint32 TeamID) const; void SetBgRaid(uint32 TeamID, Group *bg_raid); virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); void BuildPvPLogDataPacket(WorldPacket& data); static TeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE; } uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; } uint32 GetAlivePlayersCountByTeam(uint32 Team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases void UpdatePlayersCountByTeam(uint32 Team, bool remove) { if(remove) --m_PlayersCount[GetTeamIndexByTeamId(Team)]; else ++m_PlayersCount[GetTeamIndexByTeamId(Team)]; } uint32 GetArenaTeamIdForIndex(uint32 index) { return _arenaTeamIds[index]; } // used for rated arena battles void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { _arenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; } uint32 GetArenaTeamIdForTeam(uint32 Team) const { return _arenaTeamIds[GetTeamIndexByTeamId(Team)]; } void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; } int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } void SetArenaMatchmakerRating(uint32 Team, uint32 MMR) { m_ArenaTeamMMR[GetTeamIndexByTeamId(Team)] = MMR; } uint32 GetArenaMatchmakerRating(uint32 Team) const { return m_ArenaTeamMMR[GetTeamIndexByTeamId(Team)]; } /* Triggers handle */ // must be implemented in BG subclass virtual void HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) {} // must be implemented in BG subclass if need AND call base class generic code virtual void HandleKillPlayer(Player *player, Player *killer); virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/); /* Battleground events */ /* these functions will return true event is possible, but false if player is bugger */ virtual void EventPlayerDroppedFlag(Player* /*player*/) {} virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {} virtual void EventPlayerCapturedFlag(Player* /*player*/, uint32 /* BgObjectType */) {} void EventPlayerLoggedIn(Player* player); void EventPlayerLoggedOut(Player* player); /* Death related */ virtual WorldSafeLocsEntry const* GetClosestGraveYard(float /*x*/, float /*y*/, float /*z*/, uint32 /*team*/) { return nullptr; } virtual void AddPlayer(Player *plr); // must be implemented in BG subclass void AddOrSetPlayerToCorrectBgGroup(Player* player, uint32 team); virtual void RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket); // can be extended in in BG subclass void HandleTriggerBuff(ObjectGuid const& go_guid); void SetHoliday(bool is_holiday); // TODO: make this protected: GuidVector BgObjects; GuidVector BgCreatures; void SpawnBGObject(uint32 type, uint32 respawntime); bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime = 0, bool inactive = false); // void SpawnBGCreature(uint32 type, uint32 respawntime); Creature* AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime = 0); bool DelCreature(uint32 type); bool DelObject(uint32 type); bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team); int32 GetObjectType(ObjectGuid const& guid); void DoorOpen(uint32 type); void DoorClose(uint32 type); static const char* GetTrinityString(int32 entry); virtual bool HandlePlayerUnderMap(Player * plr) {return false;} // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player uint32 GetPlayerTeam(ObjectGuid guid); bool IsPlayerInBattleground(ObjectGuid guid); bool ToBeDeleted() const { return m_SetDeleteThis; } void SetDeleteThis() {m_SetDeleteThis = true;} typedef std::set<ObjectGuid> SpectatorList; void AddSpectator (ObjectGuid playerGuid) {m_Spectators.insert(playerGuid); } void onAddSpectator (Player *spectator); void RemoveSpectator(ObjectGuid playerGuid) { m_Spectators.erase(playerGuid); } bool HaveSpectators() { return (m_Spectators.size() > 0); } void SendSpectateAddonsMsg(SpectatorAddonMsg msg); bool isSpectator(ObjectGuid guid); bool canEnterSpectator(Player *spectator); virtual bool IsSpellAllowed(uint32 /*spellId*/, Player const* /*player*/) const { return true; } // because BattleGrounds with different types and same level range has different m_BracketId uint8 GetUniqueBracketId() const; protected: //this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends Battleground void EndNow(); void PlayerAddedToBGCheckIfBGIsRunning(Player* player); void _ProcessOfflineQueue(uint32 diff); void _CheckSafePositions(uint32 diff); void _ProcessLeave(uint32 diff); /* Scorekeeping */ std::map<ObjectGuid, BattlegroundScore*> PlayerScores; // Player scores // must be implemented in BG subclass virtual void RemovePlayer(Player * /*player*/, ObjectGuid /*guid*/) {} /* Player lists, those need to be accessible by inherited classes */ BattlegroundPlayerMap m_Players; // Spirit Guide guid + Player list GUIDS std::map<ObjectGuid, std::vector<ObjectGuid> > m_ReviveQueue; /* this is important variable used for invitation messages */ uint8 m_Events; bool m_BuffChange; uint32 m_score[2]; //array that keeps general team scores, used to determine who gets most marks when bg ends prematurely BGHonorMode m_HonorMode; private: /* Battleground */ BattlegroundTypeId m_TypeID; //Battleground type uint32 m_InstanceID; //Battleground Instance's GUID! uint32 m_Status; uint32 m_ClientInstanceID; // the instance-id which is sent to the client and without any other internal use uint32 m_StartTime; //elapsed time since the very beginning int32 m_EndTime; // it is set to 120000 when bg is ending and it decreases itself uint32 m_ValidStartPositionTimer; uint32 m_LastResurrectTime; BattlegroundBracketId m_BracketId; uint8 m_ArenaType; // 2=2v2, 3=3v3, 5=5v5 bool m_InBGFreeSlotQueue; // used to make sure that BG is only once inserted into the BattlegroundMgr.BGFreeSlotQueue[bgTypeId] deque bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave // this variable is not used .... it can be found in many other ways... but to store it in BG object instance is useless //uint8 m_BattlegroundType; // 3=BG, 4=arena //instead of uint8 (in previous line) is bool used bool m_IsArena; uint8 m_Winner; // 0=alliance, 1=horde, 2=none int32 m_StartDelayTime; bool m_IsRated; // is this battle rated? bool m_PrematureCountDown; uint32 m_PrematureCountDownTimer; uint32 m_timeLimit; std::string m_Name; /* Player lists */ std::vector<ObjectGuid> m_ResurrectQueue; // Player GUID GuidDeque m_OfflineQueue; // Player GUID, contain all disconected players not yet kicked out /* Invited counters are useful for player invitation to BG - do not allow, if BG is started to one faction to have 2 more players than another faction */ /* Invited counters will be changed only when removing already invited player from queue, removing player from battleground and inviting player to BG */ /* Invited players counters*/ uint32 m_InvitedAlliance; uint32 m_InvitedHorde; /* Raid Group */ Group *m_BgRaids[2]; // 0 - alliance, 1 - horde /* Players count by team */ uint32 m_PlayersCount[2]; /* Arena team ids by team */ uint32 _arenaTeamIds[2]; int32 m_ArenaTeamRatingChanges[2]; uint32 m_ArenaTeamMMR[BG_TEAMS_COUNT]; /* Limits */ uint32 m_LevelMin; uint32 m_LevelMax; uint32 m_MaxPlayersPerTeam; uint32 m_MaxPlayers; uint32 m_MinPlayersPerTeam; uint32 m_MinPlayers; /* Location */ uint32 m_MapId; BattlegroundMap* m_Map; Position StartPosition[BG_TEAMS_COUNT]; float m_StartMaxDist; uint32 ScriptId; std::map<ObjectGuid, PlayerLogInfo*> m_team1LogInfo, m_team2LogInfo; SpectatorList m_Spectators; }; #endif
00ff24839b85442851365335800c6a2ce6174fe1
ac48dc874f5550d03648c28b1eda5720202eb55c
/sensors/dsps/libhalsensors/inc/MultiShake.h
343a044fddde0bec72681eb8063253a1406b2a70
[]
no_license
difr/msm8937-8953_qcom_vendor
464e478cae4a89de34ac79f4d615e5141c40cbcb
6cafff53eca7f0c28fa9c470b5211423cf47fd40
refs/heads/master
2020-03-20T09:58:48.935110
2018-05-27T04:13:22
2018-05-27T04:13:22
137,355,108
0
1
null
null
null
null
UTF-8
C++
false
false
1,609
h
MultiShake.h
/*============================================================================ @file MultiShake.h @brief MultiShake class definition. Copyright (c) 2015 Qualcomm Technologies, Inc. All Rights Reserved. Confidential and Proprietary - Qualcomm Technologies, Inc. ============================================================================*/ #ifndef ANDROID_MULTISHAKE_SENSOR_H #define ANDROID_MULTISHAKE_SENSOR_H #include "SAMSensor.h" #include "sns_sam_multishake_v01.h" /*============================================================================ * Class MultiShake =============================================================================*/ class MultiShake : public SAMSensor { public: MultiShake(int handle); ~MultiShake(); int enable(int en); /*=========================================================================== FUNCTION: processResp Process the response to the sensor1 SENSOR1_MSG_TYPE_RESP Parameters @msg_hdr : sensor1 message header @msg_ptr : sensor1 message data ===========================================================================*/ void processResp(sensor1_msg_header_s *msg_hdr, void *msg_ptr); /*=========================================================================== FUNCTION: processInd Process the response to the sensor1 SENSOR1_MSG_TYPE_IND Parameters @msg_hdr : sensor1 message header @msg_ptr : sensor1 message data ===========================================================================*/ void processInd(sensor1_msg_header_s *msg_hdr, void *msg_ptr); }; #endif
d2613806853fbc1615db7b2abfa05d29b2866220
9870e11c26c15aec3cc13bc910e711367749a7ff
/HYSBZ/hy_1367.cpp
02f0df72ae70415e2c38d73ddf19866c0189e668
[]
no_license
liuq901/code
56eddb81972d00f2b733121505555b7c7cbc2544
fcbfba70338d3d10bad2a4c08f59d501761c205a
refs/heads/master
2021-01-15T23:50:10.570996
2016-01-16T16:14:18
2016-01-16T16:14:18
12,918,517
1
1
null
null
null
null
UTF-8
C++
false
false
1,545
cpp
hy_1367.cpp
#include <cstdio> #include <cstdlib> #include <cctype> typedef long long ll; int root,l[1000001],r[1000001],d[1000001]; ll a[1000002],b[1000002],v[1000001]; int main() { void read(ll &),insert(int,ll),del(); ll get(); int n; scanf("%d",&n); for (int i=1;i<=n;i++) { read(a[i]); a[i]-=i; } insert(1,a[1]); int k=1; a[n+1]=1LL<<60; for (int i=2;i<=n+1;i++) { ll x=get(); if (x<=a[i]) { for (int j=k;j<=i-1;j++) b[j]=x; insert(i,a[i]); k=i; } else { insert(i,a[i]); if (i-k&1) del(); } } ll ans=0; for (int i=1;i<=n;i++) ans+=abs(a[i]-b[i]); printf("%I64d\n",ans); system("pause"); return(0); } void read(ll &x) { char ch=' '; while (!isdigit(ch)) ch=getchar(); x=ch-'0'; while (1) { ch=getchar(); if (!isdigit(ch)) return; x=x*10+ch-'0'; } } void insert(int x,ll value) { int merge(int,int); v[x]=value; l[x]=r[x]=d[x]=0; if (root) root=merge(root,x); else root=x; } void del() { int merge(int,int); root=merge(l[root],r[root]); } int merge(int x,int y) { if (!x) return(y); if (!y) return(x); if (v[x]<v[y]) { int t; t=x,x=y,y=t; } r[x]=merge(r[x],y); if (d[l[x]]<d[r[x]]) { int t; t=l[x],l[x]=r[x],r[x]=t; } if (!r[x]) d[x]=0; else d[x]=d[r[x]]+1; return(x); } ll get() { return(v[root]); }
f5c83931329a4089b670e943992702d45f32f111
ae1bb960e93468819ab8fa14e6b07cd111b885c0
/Second_year/Triannual1/ED/6-Final/src/testletras.cpp
ff9363f395f4a27898752859cdf2ddf1c2c804e5
[]
no_license
Asmilex/CppUniversityProjects
b50deb5a0e480e35834ba832234f0df98923505e
37d074b32d0e9daed4c03b15b212e9ebe13c9555
refs/heads/master
2021-10-11T18:16:56.572056
2019-01-28T23:30:03
2019-01-28T23:30:03
114,488,606
0
0
null
null
null
null
UTF-8
C++
false
false
3,905
cpp
testletras.cpp
#include "letras.h" #include <string.h> #include <cstring> using namespace std; int juego_puntuaciones ( Bolsa_Letras letras ) { char opcion; size_t amount_letters = letras.get_list_letters().size(); do { letras.generate_random_letters( amount_letters ); list< char > lista_letras = letras.get_list_letters(); cout << "\nLista de lerras generadas:\n"; for ( auto letra: lista_letras ) cout << letra << " "; string sol_user; cout << "\nDame tu solución: "; cin >> sol_user; if ( letras.pertenece_bolsa(sol_user) ) cout << "La puntuación de tu palabra es " << letras.puntuacion_palabra(sol_user) << endl; else cout << "La palabra no pertenece al diccionario\n"; cout << "\nHold my beer: " << endl; auto palabras = letras.search_rarest_words(); for ( auto word: palabras ) cout << word << " (" << letras.puntuacion_palabra(word) << "), " ; cout << "\n\n¿Quieres seguir jugando? (S/N) "; cin >> opcion; } while ( toupper(opcion) == 'S' ); return 0; } int juego_longitud ( Bolsa_Letras& letras ) { char opcion; size_t amount_letters = letras.get_amount_letters(); //cout << letras; do { letras.generate_random_letters( amount_letters ); list< char > lista_letras = letras.get_list_letters(); cout << "\nLista de lerras generadas:\n"; for ( auto letra: lista_letras ) cout << letra << " "; string sol_user; cout << "\nDame tu solución: "; cin >> sol_user; if ( !letras.pertenece_bolsa(sol_user) ) cout << "\nLa palabra que me has dado no está en el diccionario\n"; else cout << "\nPuntuación de la palabra: " << sol_user.size() << endl; cout << "\nBúsqueda de palabras con una longitud máxima de " << letras.get_amount_letters() << ":\n"; auto palabras = letras.search_longest_words( amount_letters ); for ( auto word: palabras ) cout << word << " (" << word.size() << "), " ; cout << "\n\n¿Quieres seguir jugando? (S/N) "; cin >> opcion; } while ( toupper(opcion) == 'S'); return 0; } int main ( int argc, char const *argv[] ) { // ────────────────────────────────────────────────────────── PARSE ARGUMENTS ───── if ( argc != 5 ) { cerr << "Parámetros: ./testletras diccionario letras num_letras {L/P}"; return 1; } if ( strcmp( argv[4], "L" ) != 0 && strcmp( argv[4], "P" ) != 0 ) { cerr << "El último parámetro no es ni L ni P"; return 1; } // Diccionario ifstream dic_file( argv[1] ); if ( !dic_file ) { cerr << "No se ha podido abrir el fichero " << argv[1] << endl; return 1; } Diccionario diccionario; dic_file >> diccionario; // Bolsa_Letras string archivo_letras = argv[2]; Bolsa_Letras letras( diccionario, atoi(argv[3]) ); // ─────────────────────────────────────────────────────────── MODOS DE JUEGO ───── cout << letras; if ( strcmp( argv[4], "P" ) == 0 ) juego_puntuaciones( letras ); else juego_longitud( letras ); char opcion; cout << "\n¿Quieres guardar los resultados en el fichero " << argv[1] << "? (S/N) "; cin >> opcion; if ( toupper(opcion) == 'S' ) { if (letras.save_file( argv[2] ) ) cout << "\nArchivo guardado correctamente\n"; else cout << "\nNo se ha podido guardar el archivo\n"; } return 0; }
c73e18dabc98c6a6b17b92f08161fcd84ed87906
08f388ad9a5ef896532be6fe9cc34b9b04b70f1a
/arduino mega/atmega/radio_functions.ino
bcd1d40ca21647bc0ec12e6dfd2f4fa1967d102f
[]
no_license
frnhr/dagor-dome
bc2067acec45287cbc4333b783fe2ac5d74e92ff
b1f9efaf2708e00694461c065b215786c23caf79
refs/heads/master
2020-12-13T11:25:31.647483
2014-12-13T19:53:44
2014-12-13T19:53:44
18,734,281
1
0
null
null
null
null
UTF-8
C++
false
false
1,975
ino
radio_functions.ino
// radio_functions.ino // (included from atmega.ino) /* * The radio loop. * Handles communication with the dome arduino C3 (a.k.a. "server") via intermediary Arduino C2. * Communication with C2 is performed in the simplest way, by develar dedicated lines ("pins"). Maybe will add SPI... * * Why "radio loop"? Because this Arduino used to perform functions that are now on C2, namely radio communication with C3. */ void radio_loop() { // door switch has priority in any case if (doorSwitchRead(door_switch_close) || controllerRead(controller_close)) { door_close(); } else if (doorSwitchRead(door_switch_open) || controllerRead(controller_open)) { door_open(); } else { door_clear(); } } /* * Simple negative-logic. */ int doorSwitchRead(int pin) { return digitalRead(pin) == 0; } unsigned long controller_last_failed_read_millis = 0; unsigned long controller_plug_in_deadzone = 5000; // controller will become responsive after this ammount of time /* * This function reads controller buttons. * It also detects when controller is disconnected (i.e. all pins are HIGH due to pullups), if so returns 0. */ int controllerRead(int pin) { if ((digitalRead(controller_close) && digitalRead(controller_open)) || (digitalRead(controller_up) && digitalRead(controller_down))) { controller_last_failed_read_millis = millis(); return 0; } else if (millis() - controller_last_failed_read_millis < controller_plug_in_deadzone) { return 0; } return digitalRead(pin); } /* * Open Sesame! */ void door_open() { digitalWrite(do_open_pin, LOW); digitalWrite(do_close_pin, HIGH); } /* * Close Sesame! */ void door_close() { digitalWrite(do_close_pin, LOW); digitalWrite(do_open_pin, HIGH); } /* * Give it a rest Sesame! */ void door_clear() { digitalWrite(do_open_pin, LOW); digitalWrite(do_close_pin, LOW); }
ba1ee38b148ec767acfa3647825cfa9d4207fa13
f96f9244a9e1e4711c27c6d969e513999c4e84a5
/middleware/xatmi/source/tx.cpp
90804f79d42b3ee32f4e227462b70c2083e988af
[ "MIT" ]
permissive
casualcore/casual
88965684f908a46dcc998238aa78726e0143bb05
7311cc481f3b823d0c86fc09171fbd17e3c39fc1
refs/heads/feature/1.7/main
2023-09-04T01:22:09.633159
2023-07-07T15:33:29
2023-07-18T08:48:49
477,282,028
14
4
MIT
2023-09-14T07:52:38
2022-04-03T08:34:20
C++
UTF-8
C++
false
false
4,685
cpp
tx.cpp
//! //! Copyright (c) 2015, The casual project //! //! This software is licensed under the MIT license, https://opensource.org/licenses/MIT //! #include "tx.h" #include "common/transaction/context.h" #include "common/code/tx.h" #include "common/code/category.h" #include "common/exception/capture.h" #include "common/cast.h" #include "common/algorithm/compare.h" #include "common/log/trace.h" namespace local { namespace { struct Trace : casual::common::log::Trace { template< typename T> Trace( T&& value) : casual::common::log::Trace( std::forward< T>( value), casual::common::log::category::transaction) {} }; auto convert( casual::common::code::tx value) { return casual::common::cast::underlying( value); } auto code() { auto error = casual::common::exception::capture(); if( casual::common::code::is::category< casual::common::code::tx>( error.code())) return static_cast< casual::common::code::tx>( error.code().value()); return casual::common::code::tx::error; } auto handle() { return convert( local::code()); } template< typename E, typename... Args> int wrap( E&& executer, Args&&... args) { try { return convert( executer( std::forward< Args>( args)...)); } catch( ...) { return local::handle(); } } } // <unnamed> } // local int tx_begin() { local::Trace trace{ "tx_begin"}; return local::wrap( [](){ return casual::common::transaction::Context::instance().begin(); }); } int tx_close() { local::Trace trace{ "tx_close"}; return local::wrap( [](){ return casual::common::transaction::Context::instance().close(); }); } int tx_commit() { local::Trace trace{ "tx_commit"}; return local::wrap( [](){ return casual::common::transaction::Context::instance().commit(); }); } int tx_open() { local::Trace trace{ "tx_open"}; return local::wrap( [](){ return casual::common::transaction::Context::instance().open(); }); } int tx_rollback() { local::Trace trace{ "tx_rollback"}; return local::wrap( [](){ return casual::common::transaction::Context::instance().rollback(); }); } int tx_set_commit_return( COMMIT_RETURN value) { local::Trace trace{ "tx_set_commit_return"}; return local::wrap( []( auto value) { using Return = casual::common::transaction::commit::Return; if( ! casual::common::algorithm::compare::any( Return{ value}, Return::completed, Return::logged)) return casual::common::code::tx::argument; return casual::common::transaction::Context::instance().set_commit_return( Return{ value}); }, value); } int tx_set_transaction_control( TRANSACTION_CONTROL value) { local::Trace trace{ "tx_set_transaction_control"}; return local::wrap( []( auto value) { using Control = casual::common::transaction::Control; auto control = Control{ value}; if( ! casual::common::algorithm::compare::any( control, Control::chained, Control::unchained, Control::stacked)) return casual::common::code::tx::argument; return casual::common::transaction::Context::instance().set_transaction_control( control); }, value); } int tx_set_transaction_timeout( TRANSACTION_TIMEOUT timeout) { local::Trace trace{ "tx_set_transaction_timeout"}; return local::wrap( []( auto value){ return casual::common::transaction::Context::instance().set_transaction_timeout( std::chrono::seconds{ value}); }, timeout); } int tx_info( TXINFO* info) { try { local::Trace trace{ "tx_info"}; return casual::common::transaction::Context::instance().info( info) ? 1 : 0; } catch( ...) { switch( local::code()) { using code = casual::common::code::tx; case code::protocol: return local::convert( code::protocol); default: return local::convert( code::fail); } } } /* casual extension */ int tx_suspend( XID* xid) { local::Trace trace{ "tx_suspend"}; return local::wrap( [xid](){ return casual::common::transaction::Context::instance().suspend( xid); }); } int tx_resume( const XID* xid) { local::Trace trace{ "tx_resume"}; return local::wrap( [xid](){ return casual::common::transaction::Context::instance().resume( xid); }); } COMMIT_RETURN tx_get_commit_return() { local::Trace trace{ "tx_get_commit_return"}; return casual::common::cast::underlying( casual::common::transaction::Context::instance().get_commit_return()); }
33379bb1932b6bee0c2d89442a441c71cf6f545c
ce5294a10a4843419f334a070712b0623f6a1525
/main.cpp
ead049bdd17250c98f23a1003118bce52d2ed63f
[]
no_license
sandsmark/kfontview-standalone
99a87b5ae6dacb64993be1d5aee2862903099e5f
abf1f1de39272c3bf0e508f8803d8aedb4c67dee
refs/heads/master
2021-11-05T12:18:33.885820
2021-09-19T15:05:44
2021-09-19T15:05:44
181,045,421
2
0
null
null
null
null
UTF-8
C++
false
false
569
cpp
main.cpp
#include <QApplication> #include <QDebug> #include <QFile> #include "FontPreview.h" int main(int argc, char *argv[]) { if (argc < 2) { qDebug() << "need a font"; return 1; } if (!QFile::exists(argv[1])) { qWarning() << argv[1] << "does not exist"; return 1; } QApplication app(argc, argv); KFI::CFontPreview preview; preview.showFont(argv[1]); if (argc > 2) { //preview.engine()->setPreviewString(QString::fromLocal8Bit(argv[2])); } preview.show(); app.exec(); return 0; }
0eec74b7ee91d42d7b0486ae2f07467e03b43842
bc9f32b311957fdf1a6c583d46904641821d0caa
/src/parameter_learner.hpp
a6595a47d085ac478be763c2512bc4f046e42549
[]
no_license
silasxue/RGM-AOGTracker
118d7b449dc750b86ed121368fcbf328cef518ac
ea0739a1f28c365bf65e40426d28f18b556fc426
refs/heads/master
2021-01-18T04:01:18.965317
2016-05-06T20:13:50
2016-05-06T20:13:50
58,340,852
0
1
null
2016-05-09T01:46:09
2016-05-09T01:46:08
null
UTF-8
C++
false
false
7,170
hpp
parameter_learner.hpp
#ifndef RGM_PARAMETER_LEARNER_HPP_ #define RGM_PARAMETER_LEARNER_HPP_ #include "inference_dp.hpp" #include "lbfgs.hpp" #include "AOGrid.hpp" #include "tracker_result.hpp" namespace RGM { // Predeclaration template <int Dimension> class ParameterLearner_; template <int Dimension> class Loss_; enum objFuncValType { OBJ_FG = 0, OBJ_BG, OBJ_REG, OBJ_TOTAL }; // cache information typedef Eigen::Matrix < double, 1, OBJ_TOTAL + 1 > CacheInfo; // Loss provides objective function and gradient evaluations. template <int Dimension> class Loss_ : public LBFGS::IFunction { public: /// Constructor Loss_(ParameterLearner & leaner, TrainSampleSet & positives, TrainSampleSet & negatives, double C, int maxIterations); /// Returns the length of the concatenated parameter vector virtual int dim() const { return learner_.getGrammar().dim();} virtual double operator()(const double * x, double * grad = 0); /// Computes the cache info CacheInfo computeCacheInfo(); private: ParameterLearner & learner_; TrainSampleSet & positives_; TrainSampleSet & negatives_; vector<TrainSample * > samples_; double C_; int maxIterations_; CacheInfo cacheInfo_; DEFINE_RGM_LOGGER; }; // class Loss /// Estimating the parameters of AOGrammar Model using Latent SSVM template <int Dimension> class ParameterLearner_ { public: typedef typename FeaturePyr::Cell Cell; typedef typename FeaturePyr::Level Level; typedef typename Appearance::Param AppParam; /// Constructor explicit ParameterLearner_(AOGrammar & g, int maxNumSamples, bool useZeroPt, Scalar maxMemoryMB); explicit ParameterLearner_(AOGrammar & g, const string & featCacheDir, int maxNumSamples, bool useZeroPt, Scalar maxMemoryMB); /// Destructor virtual ~ParameterLearner_(); /// Trains a grammar // Scalar train(const vector<PosData> & pos, const vector<DataIdx> & posIdx, // int numFP, const vector<NegData> & neg, int numNegToUse, // TrainParam trainParam, int numRelabel, int numNegMining); /// Estimates parameters of a grammar Eigen::VectorXd train(TrainSampleSet & positives, TrainSampleSet & negatives, Scalar C, int maxIter); /// Training tracker Scalar train(TrackerResult &input, int count, int numFrameUsedToTrain, int numRelabel, float fgOverlap, float maxBgOverlap, bool nms, bool dividedByUnion, bool useOverlapLoss, int maxNumEx, float C, int partScale, bool restart, bool useRootOnly, vector<bool> &nodeOnOffHistory, vector<bool> &edgeOnOffHistory, string & saveDir); Scalar trainRoot(TrackerResult &input, int count, int numFrameUsedToTrain, float maxBgOverlap, bool dividedByUnion, int maxNumEx, float C, int partScale, bool useRootOnly, bool useZeroP = true); Scalar trainOnline(OneFrameResult &res, std::vector<ParseTree> &pts, int maxNumEx, Scalar fgOverlap, Scalar maxBgOverlap, bool dividedByUnion, bool useZeroPt, int partScale, float C); /// Returns the queue of the previous parameter vector const std::deque<Eigen::VectorXd> * wHist() const { return wHist_; } std::deque<Eigen::VectorXd> *& getWHist() { return wHist_; } const Eigen::VectorXd * normDowHist() const { return normDowHist_; } Eigen::VectorXd *& getNormDowHist() { return normDowHist_; } /// Returns grammar const AOGrammar & grammar() const { return *grammar_; } AOGrammar & getGrammar() { return *grammar_; } void setGrammar(AOGrammar & g) { RGM_CHECK(!g.empty(), error); grammar_ = &g; } /// Returns feature cache directory const string & featCacheDir() const { return featCacheDir_; } string & getFeatCacheDir() { return featCacheDir_; } /// Returns bg mu const Cell & bgmu() const { return bgmu_; } Cell & getBgmu() { return bgmu_; } /// Returns a pt in pool ParseTree * getPtInPool(int * idx = NULL); /// Clears pos set and set the pt pool states void clearPosSet(); /// Clears neg set and set the pt pool states void clearNegSet(); /// Returns the number of available slots of pts in the pool int numPtsToFill(); /// Returns the size of pt pool int szPtPool(); /// Checks the pool bool checkPtPool(); /// Creates a pt for the AOGrammar with object root only ParseTree * createOneRootPt(Level & feat); /// Creates a sample for the AOGrammar with object root only bool createOneRootSample(TrainSample & sample, bool isPos, bool useZeroPt, Level & feat, Level * featx); /// Computes T-Node scores in a AOGrid void computeAOGridTermNodeScores(AppParam & wx, AOGrid & grid, vector<ParseTree *> & pts, bool isPos); /// Computes both latent pos and hard neg bool getTrackerTrainEx(TrackerResult & input, const vector<int> &frameIdx, int maxNumEx, Scalar fgOverlap, Scalar maxBgOverlap, bool dividedByUnion, bool useZeroPt = true); bool getTrackerTrainEx_ver2(TrackerResult & input, const vector<int> &frameIdx, int maxNumEx, Scalar fgOverlap, Scalar maxBgOverlap, bool dividedByUnion, bool useZeroPt = true); /// Computes both latent pos and hard neg bool getTrackerTrainEx1(TrackerResult & input, const vector<int> &frameIdx, int maxNumEx, Scalar fgOverlap, Scalar maxBgOverlap, bool dividedByUnion, bool useZeroPt = true); /// Init margin-bound pruning void initMarginBoundPruning(); /// Copy pt pool void copyPool(); void restorePool(); private: AOGrammar * grammar_; InferenceParam inferenceParam_; string featCacheDir_; // precomputed feature pyr. Cell bgmu_; vector<ParseTree > ptPool_; vector<bool> ptPoolState_; bool useZeroPt_; TrainSampleSet posSet_; vector<int> posFilterStat_; vector<int> posPtStat_; TrainSampleSet negSet_; vector<int> negFilterStat_; vector<int> negPtStat_; // copy ptPool vector<ParseTree > ptPoolCpy_; vector<bool> ptPoolStateCpy_; TrainSampleSet posSetCpy_; TrainSampleSet negSetCpy_; Scalar maxMemoryInUse_; int maxNumExInUse_; // Margin-bound pruning state Historical weight vectors std::deque<Eigen::VectorXd> * wHist_; // Norms of the difference between the current weight vector and // each historical weight vector Eigen::VectorXd * normDowHist_; DEFINE_RGM_LOGGER; }; } #endif
4aa3831559d42087f2c8905c48c6d87381e95ac1
016c4ca9ea582ac1f71bea5c485c5a74fa71d4e3
/ImageReconstruction/Master/DetectorType.cpp
eb210feaa4daa3ba2d1a858985f99433fea5f04c
[]
no_license
jackjoynson/MedicalImaging
bad71569f6af4c3b46c63f739fc920a7e1354e78
55bb413132d6770329d079b32e4dc2faeb1c4747
refs/heads/master
2021-05-11T07:10:21.083577
2018-03-17T11:04:36
2018-03-17T11:04:36
118,009,298
0
0
null
null
null
null
UTF-8
C++
false
false
313
cpp
DetectorType.cpp
// // DetectorType.cpp // // // Created by ziyue wang on 23/01/2018. // #include "DetectorType.h" DetectorType::DetectorType(){ } DetectorType::DetectorType(double x, double y, double z, bool scatter){ _DetectorXCord = x; _DetectorYCord = y; _DetectorZCord = z; isScatter = scatter; }
688b137752b65e8fc5fe10ce79d1749beae70837
e7037db5dcf40fbaeadb319ca6bd4b0ba2d84cd4
/c_and_CPP/Dynamic Programming/Memoization/LongestIncreasingSubsequence.cpp
18a149da2b8e5ba437df4537344632892c78c24c
[]
no_license
heer14/Programming
6dc27a40d94be3df1fb0ac21e79e62cd480522d0
c831729dfe390543bfb9c66c2fa7a08ec9abafc6
refs/heads/master
2020-03-19T07:38:17.588848
2020-01-31T11:08:20
2020-01-31T11:08:20
136,134,567
0
0
null
null
null
null
UTF-8
C++
false
false
697
cpp
LongestIncreasingSubsequence.cpp
#include<iostream> #include<stdlib.h> using namespace std; int *a; int n; int *lis; void printLis(){ for(int i=0;i<n;i++)cout << lis[i] << " "; cout << endl; } int LIS(){ lis= (int *)malloc(n*sizeof(int)); for(int i=0 ; i < n;i++) lis[i] = 1; printLis(); for(int i=1 ; i<n;i++) { for(int j=0;j< i;j++){ if(a[i] > a[j]){ lis[i] = max(lis[i] , lis[j] + 1); } printLis(); } } int ans = lis[n-1]; free(lis); return ans; } int main(){ cout << "enter size of array : "; cin >> n; cout << "enter array :" <<endl; a= (int *)malloc(n*sizeof(int)); for(int i=0;i<n;i++) cin >> a[i]; cout << "Longest common subsequance is : " << LIS() << endl; free(a); return 0; }
60071469d52e42e8635afc547decafd394696cf1
f987adbe43b00477f2d438f4995fad5461c12d51
/DemoAbstractFactory/Source.cpp
8ac48db3f710c16881bdf0295c8415d0d8a34c60
[]
no_license
thaobktin/CnCPP
bbd1d04c6fc9b707616888068642b937ed62ba95
212c0cc03cb7e4bda6a5bbc2e61dd449257f1622
refs/heads/master
2021-04-26T23:13:58.422298
2018-03-05T17:27:09
2018-03-05T17:27:09
123,951,323
0
1
null
null
null
null
UTF-8
C++
false
false
591
cpp
Source.cpp
#include "AbstractFactory.h" #include "Dongvat.h" #include "Thucvat.h" #include "DongvatFactory.h" #include "ThucvatFactory.h" #include<conio.h> #include <iostream> //comment this for demo #define TAO_DONG_VAT int main() { AbstractFactory* factory = NULL; Sinhvat* sinhvat = NULL; #ifdef TAO_DONG_VAT factory = new DongvatFactory(); sinhvat = factory->getSinhvat(Dongvat::CON_CHO); sinhvat->hienthiTen(); #else factory = new ThucvatFactory(); sinhvat = factory->getSinhvat(Thucvat::CAY_LUA); sinhvat->hienthiTen(); #endif delete sinhvat; delete factory; getch(); return 0; }
eba411c9d8e5a7e1961050eb5943db4f91c0d06e
461188dca96f46443a951cb74504f3ac171b3792
/LuaAV/modules/ga/src/c3/test.c3.cpp
ddf2b5461cc90d30786623a1ae70a43b9ba59bf3
[]
no_license
italoadler/LuaAV
f1e7d713c3efd6b0e2ac607f32df1cc71bbc22be
f2a7fbc6bb4c5d7c0668a6a49135a617f638f2b4
refs/heads/master
2021-01-15T18:26:40.264978
2017-07-25T17:20:25
2017-07-25T17:20:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
563
cpp
test.c3.cpp
#include <stdio.h> #include "c3ga.h" int main(int argc, const char *argv[]) { c3ga::e1_t _e1; c3ga::e2_t _e2; c3ga::e3_t _e3; c3ga::no_t _no; c3ga::ni_t _ni; // c3ga::exp bug c3ga::mv res1 = _e1^_e2*3.14159; c3ga::mv res2 = _e3^_ni; c3ga::mv res3 = res1-res2; c3ga::mv res4 = c3ga::exp(res3); printf("--------------------\n"); printf("c3ga::exp bug:\n"); printf("%s\n", res1.toString_f().c_str()); printf("%s\n", res2.toString_f().c_str()); printf("%s\n", res3.toString_f().c_str()); printf("%s\n", res4.toString_f().c_str()); return 0; }
05a76b69dd49070364b0d2fac90e780529dd5ca7
2a8b8217b2d4d469621addbda266d28ba7f8233e
/TSP.cpp
1db2b45ecb1028c592f41023246a6b525cbaf9c4
[]
no_license
rostun/TSP
553cdd61b951014387c28922501b976d21ef97f6
4c0bb1bc484ec6e49c5eeb9bbe8b7827f234453b
refs/heads/master
2021-01-10T04:26:37.556830
2016-03-12T01:54:14
2016-03-12T01:54:14
53,427,980
1
1
null
null
null
null
UTF-8
C++
false
false
2,007
cpp
TSP.cpp
/* Rosa Tung + Sam Nelson + Kara Franco Date Modified: 3.11.16 */ //timers #include <chrono> #include <ctime> using namespace std::chrono; #include "fileFilter.h" //deal with file inputs and outputs #include "point.h" //city class that stores cityID, X and Y coordinates #include "graph.h" //graph class that stores tour vector and algorithms int main() { ifstream readFile; ofstream writeFile; string fileName; vector <string> myCities; vector <int> cities; //make a 2d vector of x and y coordinates cout << "Enter txt filename, don't put extension" << endl; cin >> fileName; //extract parent arrays from file extractLines(readFile, fileName, myCities); for(unsigned int place = 0; place < myCities.size(); place++) //if 3 lines, goes through 9 times { //fileFilter extractInts(myCities, place, cities); //put strings into myCities, convert them into integers and put those into cities vector } vector<Point> theMap; //tour vector vector<int> theTour; //ended up not using for(unsigned int i = 0; i < cities.size(); i=i+3) { Point cityHolder(cities[i], cities[i+1], cities[i+2]); //city input theMap.push_back(cityHolder); //push city objects into tour vector } Graph greedySolution(theMap, theTour); //make graph object; includes vector tour and algorithms /*for(unsigned int i = 0; i<theMap.size(); i++) { cout << greedySolution.getPoints()[i].getCityID() << endl; //returns our cities we just made }*/ int tourDistance; //start timer high_resolution_clock::time_point t1 = high_resolution_clock::now(); tourDistance = greedySolution.greedyTSP(theMap); //put tour through algorithms high_resolution_clock::time_point t2 = high_resolution_clock::now(); duration<double> time_span1 = duration_cast<duration<double>>(t2 - t1); cout << "Time: " << time_span1.count() << endl; writeFile.open(fileName + ".txt.tour"); //write to file outputFile(theMap, tourDistance, writeFile); writeFile.close(); return 0; }
09e481af97eab786bf81ffc3573e3cb255899504
716b59ef2ee44c13300c9b91dfd467aea75f7165
/GL/Source/Scenes/Scene16Particles.h
1cea0981e65c5ccb153f0d69f10865801b9dfd61
[]
no_license
GCourtney27/OpenGLRenderingEngine
af46fbf658c6ff6c528fb1e921f13ca3ba6764fa
d93701253e29b310d7193a683ad8863ec99b97d4
refs/heads/master
2020-06-24T07:47:57.642395
2019-07-25T21:03:38
2019-07-25T21:03:38
198,900,580
0
0
null
null
null
null
UTF-8
C++
false
false
698
h
Scene16Particles.h
#pragma once #include "core/scene.h" #include "..\Objects\ParticleSystem.h" class Scene16Particles : public Scene { public: Scene16Particles(class Engine* engine) : Scene(engine) {} virtual ~Scene16Particles() {} bool Initialize() override; void Shutdown() override; void Update() override; void Render() override; const char* Name() override { return "Scene16Particles"; } const char* Desc() override { return "Particle System"; } void* operator new(size_t i) { return _mm_malloc(i, 16); } void operator delete(void* p) { _mm_free(p); } private: glm::vec2 m_uvOffset = glm::vec2(1.0f, 1.0f); float m_direction = 1.0f; GLuint m_framebuffer = 0; float m_time = 0.0f; };
e14bc30c0fd2b6bc95d8cb92a6c7c8bb01233bf5
ace20ae898aadf18c4ef8a2355b528422fc27bb5
/codeforces/558C.cpp
35119ca47c4ca7836df862ef4baa7022f7ecd2db
[]
no_license
pidddgy/competitive-programming
19fd79e7888789c68bf93afa3e63812587cbb0fe
ec86287a0a70f7f43a13cbe26f5aa9c5b02f66cc
refs/heads/master
2022-01-28T07:01:07.376581
2022-01-17T21:37:06
2022-01-17T21:37:06
139,354,420
0
3
null
2021-04-06T16:56:29
2018-07-01T19:03:53
C++
UTF-8
C++
false
false
1,931
cpp
558C.cpp
// https://codeforces.com/contest/558/problem/C #include <bits/stdc++.h> using namespace std; // #define cerr if(false) cerr #define cerr cout #define watch(x) cerr << (#x) << " is " << (x) << endl; #define endl '\n' #define ld long double #define int long long #define pii pair<int, int> #define fi first #define se second #define sz(a) (int)a.size() #define all(x) (x).begin(), (x).end() void solve() { } const int maxn = 300500; int n; int a[maxn]; int cnt[maxn]; int steps[maxn]; int vis[maxn]; int dis[maxn]; signed main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++) { int x; cin >> x; queue<int> Q; Q.push(x); dis[x] = 0; while(!Q.empty()) { int S = Q.front(); Q.pop(); if(S > 100500) continue; if(vis[S] == i) continue; vis[S] = i; steps[S] += dis[S]; cnt[S]++; dis[S/2] = dis[S]+1; dis[S*2] = dis[S]+1; Q.push(S/2); Q.push(S*2); } } int mi = LLONG_MAX; for(int i = 0; i <= 1e5; i++) { if(cnt[i] == n) { mi = min(mi, steps[i]); } } cout << mi << endl; } /* operations are bit shifts odd numbers can -1 in two operations each number has two edges for some reason it is tree do tree reroot dp 7 -> 3 dfs maintain sum of distances in each subtree -> cur maintain number of a[i] in subtree -> sum dfs update ans for every to: cur -= sum[to] sum[v] -= sum[to] cur += sum[v] sum[to] += sum[v] 0 is bad, handle that edge case by having all elements go to 0 */ // Did you read the bounds? // Did you make typos? // Are there edge cases (N=1?) // Are array sizes proper? // Integer overflow? // DS reset properly between test cases? // Is using long longs causing TLE? // Are you using floating points?
e8c255757cb62f7319d9d66fa63dc1df71a2df5e
9d851f5315bce6e24c8adcf6d2d2b834f288d2b2
/chipyard/generators/gemmini/src/main/scala/berkeley-hardfloat/test-MulAddRecF16_add/dut.cpp
ba04c0fe54844a172b1fd679029336b8cfb4261a
[ "LicenseRef-scancode-bsd-3-clause-jtag", "BSD-3-Clause" ]
permissive
ajis01/systolicMM
b9830b4b00cb7f68d49fb039a5a53c04dcaf3e60
d444d0b8cae525501911e8d3c8ad76dac7fb445c
refs/heads/master
2021-08-17T22:54:34.204694
2020-03-18T03:31:59
2020-03-18T03:31:59
247,648,431
0
1
null
2021-03-29T22:26:24
2020-03-16T08:27:34
C++
UTF-8
C++
false
false
64,464
cpp
dut.cpp
// Verilated -*- C++ -*- // DESCRIPTION: Verilator output: Design implementation internals // See dut.h for the primary calling header #include "dut.h" // For This #include "dut__Syms.h" //-------------------- // STATIC VARIABLES //-------------------- VL_CTOR_IMP(dut) { dut__Syms* __restrict vlSymsp = __VlSymsp = new dut__Syms(this, name()); dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Reset internal values // Reset structure values _ctor_var_reset(); } void dut::__Vconfigure(dut__Syms* vlSymsp, bool first) { if (0 && first) {} // Prevent unused this->__VlSymsp = vlSymsp; } dut::~dut() { delete __VlSymsp; __VlSymsp=NULL; } //-------------------- void dut::eval() { VL_DEBUG_IF(VL_DBG_MSGF("+++++TOP Evaluate dut::eval\n"); ); dut__Syms* __restrict vlSymsp = this->__VlSymsp; // Setup global symbol table dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; #ifdef VL_DEBUG // Debug assertions _eval_debug_assertions(); #endif // VL_DEBUG // Initialize if (VL_UNLIKELY(!vlSymsp->__Vm_didInit)) _eval_initial_loop(vlSymsp); // Evaluate till stable int __VclockLoop = 0; QData __Vchange = 1; while (VL_LIKELY(__Vchange)) { VL_DEBUG_IF(VL_DBG_MSGF("+ Clock loop\n");); _eval(vlSymsp); __Vchange = _change_request(vlSymsp); if (VL_UNLIKELY(++__VclockLoop > 100)) VL_FATAL_MT(__FILE__,__LINE__,__FILE__,"Verilated model didn't converge"); } } void dut::_eval_initial_loop(dut__Syms* __restrict vlSymsp) { vlSymsp->__Vm_didInit = true; _eval_initial(vlSymsp); int __VclockLoop = 0; QData __Vchange = 1; while (VL_LIKELY(__Vchange)) { _eval_settle(vlSymsp); _eval(vlSymsp); __Vchange = _change_request(vlSymsp); if (VL_UNLIKELY(++__VclockLoop > 100)) VL_FATAL_MT(__FILE__,__LINE__,__FILE__,"Verilated model didn't DC converge"); } } //-------------------- // Internal Methods void dut::_initial__TOP__1(dut__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_initial__TOP__1\n"); ); dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body // INITIAL at test-MulAddRecF16_add/ValExec_MulAddRecF16_add.v:1086 vlTOPp->io_check = 1U; } VL_INLINE_OPT void dut::_combo__TOP__2(dut__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_combo__TOP__2\n"); ); dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Variables VL_SIGW(__Vtemp2,95,0,3); VL_SIGW(__Vtemp3,95,0,3); VL_SIGW(__Vtemp6,95,0,3); VL_SIGW(__Vtemp7,95,0,3); VL_SIGW(__Vtemp10,95,0,3); VL_SIGW(__Vtemp11,95,0,3); VL_SIGW(__Vtemp14,95,0,3); VL_SIGW(__Vtemp15,95,0,3); VL_SIGW(__Vtemp18,95,0,3); VL_SIGW(__Vtemp19,95,0,3); VL_SIGW(__Vtemp22,95,0,3); VL_SIGW(__Vtemp23,95,0,3); // Body vlTOPp->ValExec_MulAddRecF16_add__DOT___T_143 = ((0U == (0x1fU & ((IData)(vlTOPp->io_expected_out) >> 0xaU))) & (0U == (0x3ffU & (IData)(vlTOPp->io_expected_out)))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_133 = ((0x200U & (IData)(vlTOPp->io_expected_out)) ? 0U : ((0x100U & (IData)(vlTOPp->io_expected_out)) ? 1U : ((0x80U & (IData)(vlTOPp->io_expected_out)) ? 2U : ((0x40U & (IData)(vlTOPp->io_expected_out)) ? 3U : ((0x20U & (IData)(vlTOPp->io_expected_out)) ? 4U : ((0x10U & (IData)(vlTOPp->io_expected_out)) ? 5U : ((8U & (IData)(vlTOPp->io_expected_out)) ? 6U : ((4U & (IData)(vlTOPp->io_expected_out)) ? 7U : ((2U & (IData)(vlTOPp->io_expected_out)) ? 8U : 9U))))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_59 = ((0U == (IData)(vlTOPp->io_roundingMode)) | (4U == (IData)(vlTOPp->io_roundingMode))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_88 = ((0U == (0x1fU & ((IData)(vlTOPp->io_b) >> 0xaU))) & (0U == (0x3ffU & (IData)(vlTOPp->io_b)))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_33 = ((0U == (0x1fU & ((IData)(vlTOPp->io_a) >> 0xaU))) & (0U == (0x3ffU & (IData)(vlTOPp->io_a)))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_78 = ((0x200U & (IData)(vlTOPp->io_b)) ? 0U : ((0x100U & (IData)(vlTOPp->io_b)) ? 1U : ((0x80U & (IData)(vlTOPp->io_b)) ? 2U : ((0x40U & (IData)(vlTOPp->io_b)) ? 3U : ((0x20U & (IData)(vlTOPp->io_b)) ? 4U : ((0x10U & (IData)(vlTOPp->io_b)) ? 5U : ((8U & (IData)(vlTOPp->io_b)) ? 6U : ((4U & (IData)(vlTOPp->io_b)) ? 7U : ((2U & (IData)(vlTOPp->io_b)) ? 8U : 9U))))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_23 = ((0x200U & (IData)(vlTOPp->io_a)) ? 0U : ((0x100U & (IData)(vlTOPp->io_a)) ? 1U : ((0x80U & (IData)(vlTOPp->io_a)) ? 2U : ((0x40U & (IData)(vlTOPp->io_a)) ? 3U : ((0x20U & (IData)(vlTOPp->io_a)) ? 4U : ((0x10U & (IData)(vlTOPp->io_a)) ? 5U : ((8U & (IData)(vlTOPp->io_a)) ? 6U : ((4U & (IData)(vlTOPp->io_a)) ? 7U : ((2U & (IData)(vlTOPp->io_a)) ? 8U : 9U))))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_142 = (0x3fU & (((0U == (0x1fU & ((IData)(vlTOPp->io_expected_out) >> 0xaU))) ? (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_133)) : (0x1fU & ((IData)(vlTOPp->io_expected_out) >> 0xaU))) + (0x10U | ((0U == (0x1fU & ((IData)(vlTOPp->io_expected_out) >> 0xaU))) ? 2U : 1U)))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_87 = (0x3fU & (((0U == (0x1fU & ((IData)(vlTOPp->io_b) >> 0xaU))) ? (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_78)) : (0x1fU & ((IData)(vlTOPp->io_b) >> 0xaU))) + (0x10U | ((0U == (0x1fU & ((IData)(vlTOPp->io_b) >> 0xaU))) ? 2U : 1U)))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_32 = (0x3fU & (((0U == (0x1fU & ((IData)(vlTOPp->io_a) >> 0xaU))) ? (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_23)) : (0x1fU & ((IData)(vlTOPp->io_a) >> 0xaU))) + (0x10U | ((0U == (0x1fU & ((IData)(vlTOPp->io_a) >> 0xaU))) ? 2U : 1U)))); vlTOPp->io_expected_recOut = (((0x10000U & ((IData)(vlTOPp->io_expected_out) << 1U)) | (0xe000U & ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_143) ? 0U : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_142) >> 3U)) | ((3U == (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_142) >> 4U))) & (0U != (0x3ffU & (IData)(vlTOPp->io_expected_out))))) << 0xdU))) | ((0x1c00U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_142) << 0xaU)) | (0x3ffU & ((0U == (0x1fU & ((IData)(vlTOPp->io_expected_out) >> 0xaU))) ? (0x3feU & (((0x3ffU & (IData)(vlTOPp->io_expected_out)) << (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_133)) << 1U)) : (IData)(vlTOPp->io_expected_out))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c = (((0x10000U & ((IData)(vlTOPp->io_b) << 1U)) | (0xe000U & ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_88) ? 0U : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_87) >> 3U)) | ((3U == (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_87) >> 4U))) & (0U != (0x3ffU & (IData)(vlTOPp->io_b))))) << 0xdU))) | ((0x1c00U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_87) << 0xaU)) | (0x3ffU & ((0U == (0x1fU & ((IData)(vlTOPp->io_b) >> 0xaU))) ? (0x3feU & (((0x3ffU & (IData)(vlTOPp->io_b)) << (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_78)) << 1U)) : (IData)(vlTOPp->io_b))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a = (((0x10000U & ((IData)(vlTOPp->io_a) << 1U)) | (0xe000U & ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_33) ? 0U : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_32) >> 3U)) | ((3U == (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_32) >> 4U))) & (0U != (0x3ffU & (IData)(vlTOPp->io_a))))) << 0xdU))) | ((0x1c00U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_32) << 0xaU)) | (0x3ffU & ((0U == (0x1fU & ((IData)(vlTOPp->io_a) >> 0xaU))) ? (0x3feU & (((0x3ffU & (IData)(vlTOPp->io_a)) << (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_23)) << 1U)) : (IData)(vlTOPp->io_a))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfC = ((3U == (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xeU))) & (~ (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xdU))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig = (((0U != (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xdU))) << 0xaU) | (0x3ffU & vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isNaNAOrB = ((3U == (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xeU))) & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xdU)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notNaN_addZeros = ((0U == (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xdU))) & (0U == (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xdU)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfA = ((3U == (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xeU))) & (~ (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xdU))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawA_sig = (((0U != (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xdU))) << 0xaU) | (0x3ffU & vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags = (1U & ((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a ^ vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c) >> 0x10U)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__sNatCAlignDist = (0xffU & (((IData)(0xeU) + VL_EXTENDS_II(8,7, (0x3fU & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xaU)))) - (0x3fU & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xaU)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isInf = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfA) | (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfC)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_invalidExc = (((((3U == (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xeU))) & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xdU)) & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawA_sig) >> 9U))) | (((3U == (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xeU))) & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xdU)) & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig) >> 9U)))) | ((((~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isNaNAOrB)) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfA)) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfC)) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_sign = (1U & ((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0x10U) ^ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__isMinCAlign = ((0U == (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xdU))) | VL_GTS_III(1,8,8, 0U, (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__sNatCAlignDist))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__isNaNOut = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_invalidExc) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isNaNAOrB) | ((3U == (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xeU))) & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xdU)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_61 = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__isMinCAlign) | (0xbU >= (0x7fU & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__sNatCAlignDist)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist = (0x3fU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__isMinCAlign) ? 0U : ((0x23U > (0x7fU & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__sNatCAlignDist))) ? (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__sNatCAlignDist) : 0x23U))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_114 = (0xffU & (((0U != (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xdU))) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_61)) ? (0x3fU & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xaU)) : ((IData)(3U) + VL_EXTENDS_II(8,7, (0x3fU & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0xaU)))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_CIsDominant = ((0U != (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c >> 0xdU))) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_61)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_87 = ((((0U != (0xfU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig) >> 8U))) << 2U) | (((0U != (0xfU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig) >> 4U))) << 1U) | (0U != (0xfU & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig))))) & ((2U & (VL_SHIFTRS_III(17,17,4, 0x10000U, (0xfU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist) >> 2U))) >> 7U)) | (1U & (VL_SHIFTRS_III(17,17,4, 0x10000U, (0xfU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist) >> 2U))) >> 9U)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__mainAlignedSigC = (VL_ULL(0x7fffffffff) & VL_SHIFTRS_QQI(39,39,6, (((QData)((IData)( (0xfffU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags) ? (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig)) : (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig))))) << 0x1bU) | (QData)((IData)( ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags) ? 0x7ffffffU : 0U)))), (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__alignedSigC = ((VL_ULL(0x1ffffffffe) & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__mainAlignedSigC >> 2U)) | (QData)((IData)( ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags) ? ((7U == (7U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__mainAlignedSigC))) & (0U == (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_87))) : ((0U != (7U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__mainAlignedSigC))) | (0U != (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_87))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_mulAddResult = (0x7fffffU & ((0x1ffc00U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawA_sig) << 0xaU)) + (0x3fffffU & (IData)( (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__alignedSigC >> 1U))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum = (((QData)((IData)((0x1fffU & ((0x400000U & vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_mulAddResult) ? ((IData)(1U) + (IData)( (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__alignedSigC >> 0x17U))) : (IData)( (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__alignedSigC >> 0x17U)))))) << 0x17U) | (QData)((IData)(((0x7ffffeU & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_mulAddResult << 1U)) | (1U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__alignedSigC)))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_absSigSum = (0xffffffU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags) ? (~ (IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum >> 0xcU))) : ((0x600000U & ((IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__alignedSigC >> 0x22U)) << 0x15U)) | (0x1fffffU & (IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum >> 0xdU)))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum = (0x1ffffffU & ((1U & (IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum >> 0x19U))) ? (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum)) : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum) + (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_20 = (VL_ULL(0x7fffffffff) & ((QData)((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_absSigSum)) << (0xfU & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum = ((0x1000U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0xcU)) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0x16U))) << 0xbU) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0x14U))) << 0xaU) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0x12U))) << 9U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0x10U))) << 8U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0xeU))) << 7U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0xcU))) << 6U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 0xaU))) << 5U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 8U))) << 4U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 6U))) << 3U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 4U))) << 2U) | (((0U != (3U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum >> 2U))) << 1U) | (0U != (3U & vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum)))))))))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2 = ((0x1000U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 0U : ((0x800U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 1U : ((0x400U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 2U : ((0x200U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 3U : ((0x100U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 4U : ( (0x80U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 5U : ((0x40U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 6U : ((0x20U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 7U : ((0x10U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 8U : ((8U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 9U : ((4U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 0xaU : ((2U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum)) ? 0xbU : 0xcU)))))))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp = (0x7fU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_CIsDominant) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_114) - ((0x7cU & (VL_NEGATE_I((IData)( (1U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags) >> 1U)))) << 2U)) | (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags))) : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_114) - ((0x40U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2) << 2U)) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2) << 1U))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_115 = (VL_ULL(0xffffffffffffff) & ((QData)((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum)) << ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2) << 1U))); __Vtemp2[0U] = 0U; __Vtemp2[1U] = 0U; __Vtemp2[2U] = 1U; VL_SHIFTRS_WWI(65,65,6, __Vtemp3, __Vtemp2, (0x3fU & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp)))); __Vtemp6[0U] = 0U; __Vtemp6[1U] = 0U; __Vtemp6[2U] = 1U; VL_SHIFTRS_WWI(65,65,6, __Vtemp7, __Vtemp6, (0x3fU & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_16 = ((0xfU & ((__Vtemp3[1U] << 0x15U) | (__Vtemp3[0U] >> 0xbU))) | (0xf0U & ((__Vtemp7[1U] << 0x1dU) | (0x1ffffff0U & (__Vtemp7[0U] >> 3U))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_sig = ((0x3ffeU & ((IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_115 >> 0xdU)) << 1U)) | ((0U != (7U & (IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_115 >> 0xaU)))) | (0U != (((8U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum) >> 2U)) | (((0U != (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum) >> 3U))) << 2U) | (((0U != (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum) >> 1U))) << 1U) | (0U != (2U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum) << 1U)))))) & ((4U & (VL_SHIFTRS_III(9,9,3, 0x100U, (7U & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2) >> 1U)))) << 1U)) | ((2U & (VL_SHIFTRS_III(9,9,3, 0x100U, (7U & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2) >> 1U)))) >> 1U)) | (1U & (VL_SHIFTRS_III(9,9,3, 0x100U, (7U & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2) >> 1U)))) >> 3U)))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_26 = ((0x33U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_16) >> 2U)) | (0xccU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_16) << 2U))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isZero = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notNaN_addZeros) | ((~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_CIsDominant)) & (0U == (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_sig) >> 0xcU))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sign = (1U & ((((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfA) & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0x10U)) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfC) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_sign))) | ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notNaN_addZeros) & (2U != (IData)(vlTOPp->io_roundingMode))) & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0x10U)) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_sign))) | (((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notNaN_addZeros) & (2U == (IData)(vlTOPp->io_roundingMode))) & ((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0x10U) | (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_sign)))) | (((~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfA) | (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfC))) & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notNaN_addZeros))) & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_CIsDominant) ? (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_sign) : ((0U == (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_sig) >> 0xcU))) ? (2U == (IData)(vlTOPp->io_roundingMode)) : ((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a >> 0x10U) ^ (IData)( (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum >> 0x19U)))))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_CIsDominant) ? ((0x3ffeU & ((IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_20 >> 0xbU)) << 1U)) | (((0U != (7U & (IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_20 >> 8U)))) | (0U != ((((0U != (7U & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_absSigSum >> 8U))) << 2U) | (((0U != (0xfU & (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_absSigSum >> 4U))) << 1U) | (0U != (0xfU & vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_absSigSum)))) & ((2U & VL_SHIFTRS_III(32,5,2, 0x10U, (3U & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist) >> 2U))))) | (1U & (VL_SHIFTRS_III(5,5,2, 0x10U, (3U & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist) >> 2U)))) >> 2U)))))) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags) ? (0U != (0x7ffU & (~ (IData)( (vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum >> 1U))))) : (0U != (0xfffU & (IData)((vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum >> 1U))))))) : (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_sig)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__commonCase = (1U & (((~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__isNaNOut)) & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isInf))) & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isZero)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__roundMagUp = (((2U == (IData)(vlTOPp->io_roundingMode)) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sign)) | ((3U == (IData)(vlTOPp->io_roundingMode)) & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sign)))); __Vtemp10[0U] = 0U; __Vtemp10[1U] = 0U; __Vtemp10[2U] = 1U; VL_SHIFTRS_WWI(65,65,6, __Vtemp11, __Vtemp10, (0x3fU & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp)))); __Vtemp14[0U] = 0U; __Vtemp14[1U] = 0U; __Vtemp14[2U] = 1U; VL_SHIFTRS_WWI(65,65,6, __Vtemp15, __Vtemp14, (0x3fU & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp)))); __Vtemp18[0U] = 0U; __Vtemp18[1U] = 0U; __Vtemp18[2U] = 1U; VL_SHIFTRS_WWI(65,65,6, __Vtemp19, __Vtemp18, (0x3fU & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp)))); __Vtemp22[0U] = 0U; __Vtemp22[1U] = 0U; __Vtemp22[2U] = 1U; VL_SHIFTRS_WWI(65,65,6, __Vtemp23, __Vtemp22, (0x3fU & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48 = ((((0x550U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_26) << 3U)) | (0xaa0U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_26) << 5U))) | ((8U & (__Vtemp11[0U] >> 0xcU)) | ((4U & (__Vtemp15[0U] >> 0xeU)) | ((2U & (__Vtemp19[0U] >> 0x10U)) | (1U & (__Vtemp23[0U] >> 0x12U)))))) | (1U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) >> 0xdU))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow_roundMagUp = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_59) | (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__roundMagUp)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_56 = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) & (1U | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) << 1U))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_53 = ((~ (1U | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) << 1U))) & (3U | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) << 2U))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_54 = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_53)); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_58 = ((0U != (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_54)) | (0U != (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_56))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_80 = (0x1fffU & ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_59) & (0U != (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_54))) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__roundMagUp) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_58))) ? (((IData)(1U) + (0xfffU & (((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) >> 2U) | (0x3fffffffU & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48))))) & (~ ((((0U == (IData)(vlTOPp->io_roundingMode)) & (0U != (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_54))) & (0U == (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_56))) ? (1U | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) << 1U)) : 0U))) : ((0xfffU & (((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) & (~ (3U | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) << 2U)))) >> 2U)) | (((6U == (IData)(vlTOPp->io_roundingMode)) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_58)) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_53) >> 1U) : 0U)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83 = (0xffU & (VL_EXTENDS_II(8,7, (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp)) + VL_EXTENDS_II(8,7, (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_80) >> 0xbU))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMinNonzeroMagOut = (((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__commonCase) & VL_GTS_III(1,8,8, 8U, (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83))) & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__roundMagUp) | (6U == (IData)(vlTOPp->io_roundingMode)))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__commonCase) & VL_LTES_III(1,4,4, 3U, (0xfU & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83) >> 4U)))); vlTOPp->io_actual_exceptionFlags = ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_invalidExc) << 4U) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow) << 2U)) | ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__commonCase) & (VL_GTS_III(1,8,8, 8U, (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83)) | ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_58) & VL_GTES_III(1,2,2, 0U, (3U & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp) >> 5U)))) & ((0x2000U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig)) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) >> 1U) : (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48))) & (~ (((((IData)(vlTOPp->io_detectTininess) & (~ ((0x2000U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig)) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) >> 2U) : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48) >> 1U)))) & ((0x2000U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig)) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_80) >> 0xcU) : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_80) >> 0xbU))) & (0U != (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_54))) & (((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_59) & ((0x2000U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig)) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) >> 2U) : ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) >> 1U))) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__roundMagUp) & ((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) >> 0xdU) & ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig) >> 2U)) | (0U != (3U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig))))))))))) << 1U) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__commonCase) & (VL_GTS_III(1,8,8, 8U, (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83)) | (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_58)))))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMaxFiniteMagOut = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow) & (~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow_roundMagUp))); vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__notNaN_isInfOut = ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isInf) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow_roundMagUp))); vlTOPp->io_actual_out = ((((~ (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__isNaNOut)) & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sign)) << 0x10U) | ((0xfc00U & ((((((((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83) & (~ (((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isZero) | VL_GTS_III(1,8,8, 8U, (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83))) ? 0x38U : 0U))) & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMinNonzeroMagOut) ? 0x37U : 0U))) & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMaxFiniteMagOut) ? 0x10U : 0U))) & (~ ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__notNaN_isInfOut) ? 8U : 0U))) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMinNonzeroMagOut) ? 8U : 0U)) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMaxFiniteMagOut) ? 0x2fU : 0U)) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__notNaN_isInfOut) ? 0x30U : 0U)) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__isNaNOut) ? 0x38U : 0U)) << 0xaU)) | (0x3ffU & (((((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__isNaNOut) | (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isZero)) | VL_GTS_III(1,8,8, 8U, (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83))) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__isNaNOut) ? 0x200U : 0U) : ((0x2000U & (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig)) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_80) >> 1U) : (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_80))) | ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMaxFiniteMagOut) ? 0x3ffU : 0U))))); vlTOPp->ValExec_MulAddRecF16_add__DOT___T_172 = ((0xfU & (vlTOPp->io_actual_out >> 0xdU)) == (0xfU & (vlTOPp->io_expected_recOut >> 0xdU))); vlTOPp->io_pass = ((((0U == (7U & (vlTOPp->io_actual_out >> 0xdU))) | (7U == (7U & (vlTOPp->io_actual_out >> 0xdU)))) ? ((IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_172) & ((0x3ffU & vlTOPp->io_actual_out) == (0x3ffU & vlTOPp->io_expected_recOut))) : ((6U == (7U & (vlTOPp->io_actual_out >> 0xdU))) ? (IData)(vlTOPp->ValExec_MulAddRecF16_add__DOT___T_172) : (vlTOPp->io_actual_out == vlTOPp->io_expected_recOut))) & ((IData)(vlTOPp->io_actual_exceptionFlags) == (IData)(vlTOPp->io_expected_exceptionFlags))); } void dut::_eval(dut__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_eval\n"); ); dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body vlTOPp->_combo__TOP__2(vlSymsp); } void dut::_eval_initial(dut__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_eval_initial\n"); ); dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body vlTOPp->_initial__TOP__1(vlSymsp); } void dut::final() { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::final\n"); ); // Variables dut__Syms* __restrict vlSymsp = this->__VlSymsp; dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; } void dut::_eval_settle(dut__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_eval_settle\n"); ); dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body vlTOPp->_combo__TOP__2(vlSymsp); } VL_INLINE_OPT QData dut::_change_request(dut__Syms* __restrict vlSymsp) { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_change_request\n"); ); dut* __restrict vlTOPp VL_ATTR_UNUSED = vlSymsp->TOPp; // Body // Change detection QData __req = false; // Logically a bool return __req; } #ifdef VL_DEBUG void dut::_eval_debug_assertions() { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_eval_debug_assertions\n"); ); // Body if (VL_UNLIKELY((clock & 0xfeU))) { Verilated::overWidthError("clock");} if (VL_UNLIKELY((reset & 0xfeU))) { Verilated::overWidthError("reset");} if (VL_UNLIKELY((io_roundingMode & 0xf8U))) { Verilated::overWidthError("io_roundingMode");} if (VL_UNLIKELY((io_detectTininess & 0xfeU))) { Verilated::overWidthError("io_detectTininess");} if (VL_UNLIKELY((io_expected_exceptionFlags & 0xe0U))) { Verilated::overWidthError("io_expected_exceptionFlags");} } #endif // VL_DEBUG void dut::_ctor_var_reset() { VL_DEBUG_IF(VL_DBG_MSGF("+ dut::_ctor_var_reset\n"); ); // Body clock = VL_RAND_RESET_I(1); reset = VL_RAND_RESET_I(1); io_a = VL_RAND_RESET_I(16); io_b = VL_RAND_RESET_I(16); io_roundingMode = VL_RAND_RESET_I(3); io_detectTininess = VL_RAND_RESET_I(1); io_expected_out = VL_RAND_RESET_I(16); io_expected_exceptionFlags = VL_RAND_RESET_I(5); io_expected_recOut = VL_RAND_RESET_I(17); io_actual_out = VL_RAND_RESET_I(17); io_actual_exceptionFlags = VL_RAND_RESET_I(5); io_check = VL_RAND_RESET_I(1); io_pass = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_a = VL_RAND_RESET_I(17); ValExec_MulAddRecF16_add__DOT__mulAddRecFN_io_c = VL_RAND_RESET_I(17); ValExec_MulAddRecF16_add__DOT___T_23 = VL_RAND_RESET_I(4); ValExec_MulAddRecF16_add__DOT___T_32 = VL_RAND_RESET_I(6); ValExec_MulAddRecF16_add__DOT___T_33 = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT___T_78 = VL_RAND_RESET_I(4); ValExec_MulAddRecF16_add__DOT___T_87 = VL_RAND_RESET_I(6); ValExec_MulAddRecF16_add__DOT___T_88 = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT___T_133 = VL_RAND_RESET_I(4); ValExec_MulAddRecF16_add__DOT___T_142 = VL_RAND_RESET_I(6); ValExec_MulAddRecF16_add__DOT___T_143 = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT___T_172 = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isNaNAOrB = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfA = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_isInfC = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_doSubMags = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul_io_toPostMul_CIsDominant = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_mulAddResult = VL_RAND_RESET_I(23); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_invalidExc = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isInf = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_isZero = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sign = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sExp = VL_RAND_RESET_I(7); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul_io_rawOut_sig = VL_RAND_RESET_I(14); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawA_sig = VL_RAND_RESET_I(12); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__rawC_sig = VL_RAND_RESET_I(12); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__sNatCAlignDist = VL_RAND_RESET_I(8); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__isMinCAlign = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_61 = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__CAlignDist = VL_RAND_RESET_I(6); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__mainAlignedSigC = VL_RAND_RESET_Q(39); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_87 = VL_RAND_RESET_I(3); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT__alignedSigC = VL_RAND_RESET_Q(37); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_preMul__DOT___T_114 = VL_RAND_RESET_I(8); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_sign = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__sigSum = VL_RAND_RESET_Q(36); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__CDom_absSigSum = VL_RAND_RESET_I(24); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_20 = VL_RAND_RESET_Q(39); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_absSigSum = VL_RAND_RESET_I(25); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_reduced2AbsSigSum = VL_RAND_RESET_I(13); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_normDistReduced2 = VL_RAND_RESET_I(4); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT___T_115 = VL_RAND_RESET_Q(56); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notCDom_sig = VL_RAND_RESET_I(14); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__mulAddRecFNToRaw_postMul__DOT__notNaN_addZeros = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__roundMagUp = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_16 = VL_RAND_RESET_I(8); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_26 = VL_RAND_RESET_I(8); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_48 = VL_RAND_RESET_I(12); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_53 = VL_RAND_RESET_I(14); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_54 = VL_RAND_RESET_I(14); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_56 = VL_RAND_RESET_I(14); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_58 = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_59 = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_80 = VL_RAND_RESET_I(13); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT___T_83 = VL_RAND_RESET_I(8); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__isNaNOut = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__commonCase = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__overflow_roundMagUp = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMinNonzeroMagOut = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__pegMaxFiniteMagOut = VL_RAND_RESET_I(1); ValExec_MulAddRecF16_add__DOT__mulAddRecFN__DOT__roundRawFNToRecFN__DOT__roundAnyRawFNToRecFN__DOT__notNaN_isInfOut = VL_RAND_RESET_I(1); }
cc859ce8ced5c4237e1b54cf58270d085f8d13c0
8afb86d9c8718fafe428525ef7a533773be433d4
/src/Renderer/Texture2D.h
039884b9c4f505bf6eb6440d7497c7048ec0371e
[]
no_license
Smirnov-Peter-Alekseevich-pmgic-studio/BattleCity
cdce0aa61ec5b3d0f20112a7bea1faa12215242b
6ca9a91b5d6e2efe6bff6422be7c431d701e611b
refs/heads/main
2023-04-12T05:37:04.449561
2021-05-16T08:44:51
2021-05-16T08:44:51
354,054,236
0
0
null
null
null
null
UTF-8
C++
false
false
1,395
h
Texture2D.h
#pragma once #include <glad/glad.h> #include <string> #include <glm/vec2.hpp> #include <map> namespace Renderer { class Texture2D { public: struct SubTexture2D{ glm::vec2 leftBottomUV; glm::vec2 rightTopUV; SubTexture2D( const glm::vec2& _leftBottomUV, const glm::vec2& _rightTopVM) : leftBottomUV(_leftBottomUV), rightTopUV(_rightTopVM){} SubTexture2D() :leftBottomUV(0.f), rightTopUV(1.f){} }; Texture2D( const GLuint width,const GLuint height, const unsigned char* data, const unsigned int chanels, const GLenum filter, const GLenum wrapMode ); Texture2D() = delete; ~Texture2D(); Texture2D(const Texture2D&) = delete; Texture2D& operator=(const Texture2D&) = delete; Texture2D& operator=(Texture2D&& texture2D); Texture2D(Texture2D&& texture2D); const SubTexture2D& getSubTexture(const std::string& name) const; void bind() const; void addSubTexture(const std::string& nameSubTexture,const glm::vec2& leftBottomVM,const glm::vec2& rightTopVM); unsigned int width() const {return m_width;}; unsigned int height() const {return m_height;}; private: GLuint m_ID; GLenum m_mode; unsigned int m_width; unsigned int m_height; std::map<std::string,SubTexture2D> m_subTextures; }; }
ec6f0f6554ecf2a38287c3ad800e8420f1ed6497
29dec8d4ab5ded7f0b3f2cdac3304918f9846b8f
/epam29.09.cpp
fd60e63beef3d5505bfd2734ddba92723f8619d8
[]
no_license
halovvv/epamLabs
f950a556873355a04efcaeff5b36ec6ee1131d3a
663f925a7ce3fc581f2b697cc026aed1f8ff9e67
refs/heads/main
2022-12-24T00:35:46.614933
2020-10-07T17:40:52
2020-10-07T17:40:52
302,111,652
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,200
cpp
epam29.09.cpp
#include <iostream> using namespace std; struct students // 1 пункт { string Surname; string Name; int Score[3]; int Sum; }; void showData(students* st, int amount) { for (int i = 0; i != amount; i++) //4 пункт { cout << "#" << i + 1 << " Surname:\t" << st[i].Surname << "\t" << " Name:\t" << st[i].Name << "\t" << endl; for (int j = 0; j < 3; j++) { cout << "Score # " << j + 1 << ": " << st[i].Score[j] << endl; } } } // 4 пункт void punktPiat(students* st, int amount) { for (int i = 0; i != amount; i++) { if (st[i].Sum % 4 == 0) { int sum = 0; for (int j = 0; j != 3; j++) { sum += st[i].Score[j]; st[i].Sum = sum / 3; } } else if (st[i].Sum % 4 == 1) { int max = st[i].Score[0]; for (int j = 0; j != 3; j++) { if (max < st[i].Score[j]) st[i].Sum = st[i].Score[j]; } } else if (st[i].Sum % 4 == 2) { int min = st[i].Score[0]; for (int j = 0; j != 3; j++) { if (min > st[i].Score[j]) st[i].Sum = st[i].Score[j]; } } else if (st[i].Sum % 4 == 3) { int sum = 0; for (int j = 0; j != 3; j++) { sum += st[i].Score[j]; st[i].Sum = sum; } } } } // 5 пункт int main() { int amount, sum; cout << "Please enter amount of students" << endl; cin >> amount; if (amount < 2) // 2 пункт { cout << "Please enter bigger number" << endl; } else //3 пункт { students* st = new students[amount]; for (int i = 0; i != amount; i++) { cout << "#" << i + 1 << " Please enter surname" << endl; cin >> st[i].Surname; cout << "#" << i + 1 << " Please enter name" << endl; cin >> st[i].Name; cout << "#" << i + 1 << " Please enter scores" << endl; for (int j = 0; j <3;j++ ) { cin >> st[i].Score[j]; } } showData(st,amount); punktPiat(st,amount); cout << "\t Sorted data\t" << endl; cout << " --------------------------------------------------------------------\t" << endl; showData(st, amount); // 6 пункт delete[] st; //7 пункт } }
002f50d33394a061da000c9807209c89714826e4
4aa08d49eca9ad51cbd9493236a72a427388cfe1
/src/MathParser.cpp
fa459543800a0e04bf5729ac0d2f9fc842822f7c
[]
no_license
pmarathe25/Math
0b85651a1a1628adb107adfe81fb57c2944971be
35a248eae472b584058a75dd616eb048ad324778
refs/heads/master
2021-01-20T18:33:31.270667
2017-10-20T23:04:21
2017-10-20T23:04:21
62,969,309
0
0
null
null
null
null
UTF-8
C++
false
false
6,681
cpp
MathParser.cpp
#include "MathParser.hpp" #include <algorithm> namespace StealthMath { MathParser::MathParser() { } double MathParser::parse(std::string expression) { // Remove spaces. expression = strmanip::remove(expression, " "); // Balance parentheses. expression = strmanip::balance(expression, '(', ')'); return parseClean(expression); } void MathParser::setOperatorPrecedenceList(const std::vector<std::string>& newList) { operatorPrecedenceList = newList; } void MathParser::addBinaryOperator(const std::string& op, double (*func)(double, double)) { binaryOperatorFunctions[op] = func; // Push the operator to the front of the precedence list. operatorPrecedenceList.insert(operatorPrecedenceList.begin(), op); } void MathParser::addBinaryOperator(const std::map<std::string, double (*)(double, double)> ops) { binaryOperatorFunctions.insert(ops.begin(), ops.end()); // Push all provided operators onto the front of the precedence list. for (std::map<std::string, double (*)(double, double)>::const_iterator op = ops.begin(); op != ops.end(); op++) { operatorPrecedenceList.insert(operatorPrecedenceList.begin(), op -> first); } } void MathParser::addUnaryOperator(const std::string& op, double (*func)(double)) { unaryOperatorFunctions[op] = func; // Push the operator to the front of the precedence list. operatorPrecedenceList.insert(operatorPrecedenceList.begin(), op); } void MathParser::addUnaryOperator(const std::map<std::string, double (*)(double)>& ops) { unaryOperatorFunctions.insert(ops.begin(), ops.end()); // Push all provided operators onto the front of the precedence list. for (std::map<std::string, double (*)(double)>::const_iterator op = ops.begin(); op != ops.end(); op++) { operatorPrecedenceList.insert(operatorPrecedenceList.begin(), op -> first); } } double MathParser::parseClean(const std::string& expression) { // If there are no operators, return the double value of the expression. if (!strmanip::contains(expression, operatorPrecedenceList)) { return std::stod(strmanip::remove(expression, "()")); } // Evaluate innermost parentheses first. strmanip::Indices inner = strmanip::findInnermost(expression, '(', ')'); if (inner.first != -1) { // Recursively parse the inner expression excluding the parentheses and then parse the new expression. return parseClean(expression.substr(0, inner.first) + std::to_string(parseClean(expression.substr(inner.first + 1, inner.second - inner.first - 1))) + expression.substr(inner.second + 1)); } // Evaluate operators in the order they are provided in the precedence list. for (std::vector<std::string>::iterator op = operatorPrecedenceList.begin(); op != operatorPrecedenceList.end(); op++) { // Find the first instance of the operator. int operatorLocation = expression.find(*op); if (operatorLocation != std::string::npos) { // If this is a binary operator call a binary function, otherwise call a unary function. if (binaryOperatorFunctions.count(*op) > 0) { // Create a struct to hold the two operators and the start and end indices of the expression. BinaryOperands binaryOperands = findBinaryOperands(expression, *op, operatorLocation); return parseClean(expression.substr(0, binaryOperands.indices.first) + std::to_string((*binaryOperatorFunctions.at(*op))(binaryOperands.firstOperand, binaryOperands.secondOperand)) + expression.substr(binaryOperands.indices.second)); } else if (unaryOperatorFunctions.count(*op) > 0) { // Create a struct to hold the operator and the start and end indices of the expression. UnaryOperand unaryOperand = findUnaryOperand(expression, *op, operatorLocation); return parseClean(expression.substr(0, unaryOperand.indices.first) + std::to_string((*unaryOperatorFunctions.at(*op))(unaryOperand.firstOperand)) + expression.substr(unaryOperand.indices.second)); } } } } MathParser::UnaryOperand MathParser::findUnaryOperand(const std::string& expression, const std::string& op, int operatorLocation) { UnaryOperand temp; // Get the index of the beginning of the first operand.. int operandStart = expression.find_last_not_of("0123456789.", operatorLocation - 1) + 1; // Get the index after the end of the unary operator. int operatorEnd = operatorLocation + op.size(); // If this is the last operator in the string, set the index to the end of the string. operatorEnd = (operatorEnd == std::string::npos) ? expression.length() - 1 : operatorEnd; // Get the operand as a double. double operand = std::stod(expression.substr(operandStart, operatorLocation - operandStart)); temp.indices.first = operandStart; temp.indices.second = operatorEnd; temp.firstOperand = operand; return temp; } // Gives the values and locations of the operands. MathParser::BinaryOperands MathParser::findBinaryOperands(const std::string& expression, const std::string& op, int operatorLocation) { BinaryOperands temp; // Get the index of the beginning of the first operand.. int firstOperandStart = expression.find_last_not_of("0123456789.", operatorLocation - 1) + 1; // Get the index after the end of the second operand. int secondOperandEnd = expression.find_first_not_of("0123456789.", operatorLocation + op.size()); // If this is the last operand in the string, set the index to the end of the string. secondOperandEnd = (secondOperandEnd == std::string::npos) ? expression.length() : secondOperandEnd; // Get the two operands as doubles. double firstOperand = std::stod(expression.substr(firstOperandStart, operatorLocation - firstOperandStart)); double secondOperand = std::stod(expression.substr(operatorLocation + op.size(), secondOperandEnd + 1 - operatorLocation)); temp.indices.first = firstOperandStart; temp.indices.second = secondOperandEnd; temp.firstOperand = firstOperand; temp.secondOperand = secondOperand; return temp; } }
7fb91c6dcd2973c72f0cb8fceffeb16166d065a3
ff18be417439435d0db3756181a9e98c55cf25e3
/ACM-ICPC/ACM-ICPC_12/Amritapuri/online contest/ACM-ICPC Amritapuri 2012 Online Competition Accepted Solutions/D/cpp/00006227_D_TEAMDIV_amicpc120394.cpp
c3ac2932f839a2e690f903d3527de25020fccedb
[]
no_license
rovinbhandari/Programming_Scripting
3952b45636f10e46c05dede29492eb0828857448
ee67f9289883d3686ed5cf41dbae13e1313bcfb0
refs/heads/master
2023-06-22T13:52:03.559222
2023-06-20T13:40:32
2023-06-20T13:47:22
4,378,004
6
1
null
2019-03-25T14:44:18
2012-05-19T12:25:13
C++
UTF-8
C++
false
false
1,757
cpp
00006227_D_TEAMDIV_amicpc120394.cpp
#include <iostream> #include <algorithm> #include <vector> #include <set> #include <cstring> #include <string> #include <sstream> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;i++) #define FOR(i,a,n) for(int i=(int)a;i<(int)n;i++) #define FOR1(i,n) for(int i=1;i<=(int)n;i++) #define ALL(c) c.begin(),c.end() #define FORE(it,c) for(typeof(c.begin()) it=c.begin();it!=c.end();it++) typedef long long int lli; typedef pair<int,int> ii; const int N = 20010; vector<int> E[N]; int C[N]; bool V[N]; bool dfs(int i, int color = 0){ if(C[i] != -1){ if(C[i] == color) return false; } C[i] = 1 - color; if(V[i]) return true; V[i] = 1; bool ret = true; REP(j,E[i].size()) ret &= dfs(E[i][j], C[i]); return ret; } int main(){ ios::sync_with_stdio(false); int T; cin >> T; while(T--){ int n; cin >> n; REP(i,n) E[i].clear(); memset(V,0,sizeof(V)); memset(C,-1,sizeof(C)); REP(i,n){ int k; cin >> k; int v; REP(j,k){ cin >> v; E[i].push_back(v); E[v].push_back(i); } } bool pos = 1; int comps = 0; REP(i,n){ if(!V[i]){ comps++; pos &= dfs(i); } } lli ans = 1; if(pos) { const lli MOD = 1e9 + 7; REP(i,comps) { ans *= 2; if(ans >= MOD) ans %= MOD; } } else ans = 0; cout << ans << "\n"; } return 0; }
7e5d4fbef69967ee86f57e76dbcf6dca4465355d
ac453c5afa6797e11411fa07f9bf491c989e59fd
/include/hal/Adc.hpp
be45dfcfb75ad274ebb65bf700b79b0e76c8efb1
[ "BSD-3-Clause" ]
permissive
charanyaarvind/StratifyAPI
0344a3b13b933cde242221677fbb9f91301645ef
adfd1bc8354489378d53c6acd77ebedad5790b4f
refs/heads/master
2020-03-27T11:14:38.510797
2018-08-28T03:06:57
2018-08-28T03:06:57
146,473,720
0
0
BSD-3-Clause
2018-08-28T16:10:27
2018-08-28T16:10:27
null
UTF-8
C++
false
false
4,030
hpp
Adc.hpp
/*! \file */ //Copyright 2011-2018 Tyler Gilbert; All Rights Reserved #ifndef SAPI_ADC_HPP_ #define SAPI_ADC_HPP_ #include <sos/dev/adc.h> #include "PinAssignment.hpp" #include "Periph.hpp" namespace hal { /*! \brief ADC Attributes Class * \details This class is for containing ADC attributes. */ class AdcAttr : public PinAssignmentPeriphAttr<adc_attr_t, adc_pin_assignment_t> {}; /*! \brief ADC Pin Assignment * \details This class allows simple manipulation of the adc_pin_assignment_t. */ class AdcPinAssignment : public PinAssignment<adc_pin_assignment_t>{}; /*! \brief ADC Peripheral Class * \details This class implements ADC device peripherals. * * \code * #include <sapi/hal.hpp> * * int main(int argc, char * argv[]){ * Adc adc(0); //create an instance of ADC to access port 0 * u32 samples[16]; * adc.init(); //initialize the ADC using the default configuration * adc.read(0, samples, 16*sizeof(u32)); //read 16 samples from channel 0 * adc.read(1, samples, 16*sizeof(u32)); //read 16 samples from channel 1 * adc.close(); //close the ADC * } * \endcode * */ class Adc : public Periph<adc_info_t, adc_attr_t, 'a'> { public: /*! \details Initializes the object with \a port. */ Adc(port_t port); enum { FLAG_SET_CONVERTER = ADC_FLAG_SET_CONVERTER, FLAG_IS_LEFT_JUSTIFIED = ADC_FLAG_IS_LEFT_JUSTIFIED, FLAG_IS_RIGHT_JUSTIFIED = ADC_FLAG_IS_RIGHT_JUSTIFIED, SET_CONVERTER /*! See ADC_FLAG_SET_CONVERTER */ = ADC_FLAG_SET_CONVERTER, IS_LEFT_JUSTIFIED /*! See ADC_FLAG_IS_LEFT_JUSTIFIED */ = ADC_FLAG_IS_LEFT_JUSTIFIED, IS_RIGHT_JUSTIFIED /*! Set to specify right justified data */ = ADC_FLAG_IS_RIGHT_JUSTIFIED, SET_MASTER = ADC_FLAG_SET_MASTER /*! Used with MCUs that have more than one ADC that can operate in master/slave mode */, SET_SLAVE = ADC_FLAG_SET_SLAVE /*! Used with MCUs that have more than one ADC that can operate in master/slave mode */, IS_TRIGGER_TMR = ADC_FLAG_IS_TRIGGER_TMR /*! Used to trigger the ADC read on a timer event */, IS_TRIGGER_EINT = ADC_FLAG_IS_TRIGGER_EINT /*! Used to trigger the ADC read on a external interrupt */, SET_CHANNELS = ADC_FLAG_SET_CHANNELS /*! Configure the channels withouth changing ADC settings */, IS_SCAN_MODE = ADC_FLAG_IS_SCAN_MODE /*! ADC will read every enabled channel when reading rather than the channel based on the location value */, IS_TRIGGER_EINT_EDGE_RISING = ADC_FLAG_IS_TRIGGER_EINT_EDGE_RISING, IS_TRIGGER_EINT_EDGE_FALLING = ADC_FLAG_IS_TRIGGER_EINT_EDGE_FALLING, IS_GROUP = ADC_FLAG_IS_GROUP }; /*! \details Sets the attributes of the ADC. * * @param o_flags The ADC flags (e.g. FLAG_SET_CONVERTER) * @param freq The ADC frequency (set to 0 to use the maximum available) * @param pin_assignment A pointer to the pin assignment data structure (0 to use default pin assignment) * @return Zero on success or less than zero for an error */ int set_attr(u32 o_flags, u32 freq, const adc_pin_assignment_t * pin_assignment = 0) const { adc_attr_t attr; attr.o_flags = o_flags; if( pin_assignment != 0 ){ memcpy(&attr.pin_assignment, pin_assignment, sizeof(adc_pin_assignment_t)); } else { memset(&attr.pin_assignment, 0xff, sizeof(adc_pin_assignment_t)); } attr.freq = freq; return Periph::set_attr(attr); } /*! \details Opens the ADC port and sets the attributes as specified. * * @param o_flags The ADC flags (e.g. FLAG_SET_CONVERTER) * @param freq The ADC frequency (set to 0 to use the maximum available) * @param pin_assignment A pointer to the pin assignment data structure (0 to use default pin assignment) * @return Zero on success or less than zero for an error * */ int init(u32 o_flags, u32 freq, const adc_pin_assignment_t * pin_assignment = 0){ if( open() < 0 ){ return -1; } return set_attr(o_flags, freq, pin_assignment); } using Periph::init; using Periph::set_attr; private: }; } #endif /* SAPI_ADC_HPP_ */
a78a190ff19dfff6332edfb97c57a34446cc494a
fd183defc064165daf2902b91fbb2e4cb7f1b9c7
/VolumeSingleScatter/main.cpp
669460eddaab6f4470f9b70c692fd0ca4587c0c5
[]
no_license
daydreamer2023/VolumeSingleScattering
b8d894250941c83e3222dc062bd34c7b78e67055
34a8e866a1a31d341f34ab3fe2b5ab7e78f7c45e
refs/heads/master
2021-09-10T23:04:00.002949
2018-04-03T20:29:01
2018-04-03T20:29:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
40,788
cpp
main.cpp
#if defined(_WIN32) #include <Windows.h> #endif // // main.cpp // RayTracer // // Created by WangYue on 16/9/20. // Copyright © 2016年 WangYue. All rights reserved. // // g++ -c main.cpp #define inf 1e20 #define eps 1e-20 #include <iostream> #include <fstream> #include <sstream> #include <string> #include <vector> #include <cmath> #include <limits> #include <math.h> #include <time.h> #include <algorithm> #include <stdlib.h> #include <stdio.h> #include "Vector3.h" #include "Camera.h" #include "Color.h" #include "Light.h" #include "Sphere.h" #include "Plane.h" #include "Triangle.h" #include "MotionSphere.h" #include "Sampler.h" #include "Random.h" #include "Volume.h" #include "MCSampler1D.h" #include "MCSampler2D.h" using namespace std; inline double clamp(double x) { return x < 0 ? 0 : x > 1 ? 1 : x; } inline int toDisplayValue(double x){ return int( pow(clamp(x), 1.0/2.2) * 255 + .5); } void savePPM(const char *filename, int w, int h, Color *pixelColors){ #if defined(_WIN32) FILE *f; fopen_s(&f, filename, "w"); #else FILE *f = fopen(filename, "w"); #endif fprintf(f, "P3\n%d %d\n%d\n", w, h, 255); for (int p = 0; p < w * h; p++) { fprintf(f,"%d %d %d ", toDisplayValue(pixelColors[p].x), toDisplayValue(pixelColors[p].y), toDisplayValue(pixelColors[p].z)); } fclose(f); } bool collectIntersections(vector<double> &intersections,vector<Object*> &objects, Ray &cameraRay){ // Find intersections of cameraRay with every object, if there's no intersection, return inf. // If there's no intersection, return false. bool IntersectionExists = false; for( int index = 0 ; index < objects.size(); index ++) { double t = objects[index]->findIntersection(cameraRay); if(t > 0){ intersections.push_back(t); if(!IntersectionExists) IntersectionExists = true; } else intersections.push_back(inf); } return IntersectionExists; } bool ClosestIntersectionObject(vector<Object*> &objects, Ray &cameraRay, double &t, int &id){ // Find the object that has the closest intersection point // Return true if there's intersection, then t is the first intersection point among all spheres vector<double> intersections; t = inf; if( collectIntersections(intersections, objects, cameraRay)) for( int index = 0; index < intersections.size(); index ++ ) { // Find the smallest t; if(intersections.at(index)<t){ t = intersections.at(index); id = index; } } return t < inf; }; bool trace( Vector3 &orig, Vector3 &dir, vector<Object*> &objects, double &tNear, int &index) { tNear = inf; Ray ray (orig, dir); for (int k = 0; k < objects.size() - 1; ++k) { if (objects[k]->findIntersection(ray) < tNear && objects[k]->findIntersection(ray) > 0 ) { tNear = objects[k]->findIntersection(ray) ; index = k; } } return (tNear<inf); } bool traceAll( Vector3 &orig, Vector3 &dir, vector<Object*> &objects, double &tNear, int &index) { tNear = inf; Ray ray (orig, dir); for (int k = 0; k < objects.size() ; ++k) { if (objects[k]->findIntersection(ray) < tNear && objects[k]->findIntersection(ray) > 0 ) { tNear = objects[k]->findIntersection(ray) ; index = k; } } return (tNear<inf); } Color getPixelColorPointLight(vector<Object*> &objects, int id, double &t, Ray &ray, Light &light){ Color c; Object* obj; // Intersection Point Vector3 intersectionPoint = ray.getOrigin() + ray.getDirection() * t; Vector3 normal; if(id>=0){ obj = objects.at(id); // Normal of intersection point, point out of the sphere normal = obj->getNormalAt(intersectionPoint); } else{ obj = objects.at(objects.size() - 1); normal = Vector3 (0,0,1); } // If there are multiple lights, should be a for loop here // Light direction, from intersection point to the light position Vector3 lightDirection = light.getLightPosition() - intersectionPoint ; // Square of Distance between light and point double distance2 = lightDirection.dot(lightDirection); // Light direction lightDirection = lightDirection.norm(); double tNear = inf; int shadowObjIndex = 0; // Shadow check // Move the shadow point a little bit along normal double offset = 1e-9; Vector3 shadowPointOrig = (ray.getDirection().dot(normal) < 0) ? intersectionPoint + normal * offset : intersectionPoint - normal * offset ; bool inShadow = trace(shadowPointOrig, lightDirection, objects, tNear, shadowObjIndex ) && tNear * tNear < distance2 ; double cosine; if(obj->insideObject(light.getLightPosition())){ cosine = clamp(- lightDirection.dot(normal)); } else{ cosine = clamp(lightDirection.dot(normal)); } double L_r; double fr = 1 / M_PI; if(id>=0){ L_r = clamp(light.getRadiance() * fr * cosine * (1 - inShadow) / (distance2 * 4 * M_PI)); } else{ L_r = light.getRadiance() * fr * (1 - inShadow) / ( distance2 * 4 * M_PI); // cout<<distance2<<endl; } //task1 //double L_r = light.getRadiance() * fr * cosine / (distance2 * 4 * M_PI); // cout<<distance2<<endl; c = obj->getObjectColor() * L_r ; return c; } Color getPixelColorWithSphereLight(vector<Object*> &objects, int id, double &t_ray, Ray &ray, Vector3& hitPoint, const int N, const SampleMode sampleMode){ Color c; // Intersection Point Vector3 intersectionPoint = ray.getOrigin() + ray.getDirection() * t_ray; // Get the light Obj // Here the last object in vector is light by default. Sphere* LightObj =(Sphere*)objects.at(objects.size() - 1); // Normal of intersection point Object* obj; Vector3 normal; if(id>=0){ obj = objects.at(id); normal = obj->getNormalAt(intersectionPoint); if(obj->insideObject(LightObj->getSphereCenter())){ normal = normal * -1; } } else{ obj = objects.at(objects.size() - 1); normal = Vector3(0,0,1); } // vector3 from intersection point X to light center C Vector3 XC = LightObj->getSphereCenter() - intersectionPoint; // ThetaMax double sinThetaMax = LightObj->getSphereRadius() / XC.length(); double cosThetaMax = sqrt(1 - sinThetaMax * sinThetaMax); double lightR = LightObj->getSphereRadius(); if( id == objects.size() - 1){ c = obj->getObjectColor(); } else{ // Monte Carlo Begins double L_r = 0.0; for(int m = 0; m < N; m++){ Vector3 sampleLightDirection; sampleLightDirection = getSample(*LightObj,intersectionPoint, sampleMode, normal, sinThetaMax).norm(); Ray secondary (intersectionPoint, sampleLightDirection); double t = LightObj->findIntersection(secondary); if(t > eps) { Vector3 sampleLightPoint = intersectionPoint + sampleLightDirection * t; hitPoint = sampleLightPoint; // Check if there are intersections between light sample and intersection point. // Light direction, from intersection point to the light position Vector3 lightDirection = sampleLightPoint - intersectionPoint ; // Distance between light sample point and the intersection point double distance2 = lightDirection.dot(lightDirection); // Light direction lightDirection = lightDirection.norm(); double tNear = inf; int shadowObjIndex = 0; // Shadow check // Move the shadow point a little bit along normal double offset = 1e-9; Vector3 shadowPointOrig = (ray.getDirection().dot(normal) < 0) ? intersectionPoint + normal * offset : intersectionPoint - normal * offset ; bool inShadow = trace(shadowPointOrig, lightDirection, objects, tNear, shadowObjIndex ) && tNear * tNear < distance2 ; double L_i = 10.0; double fr = 0.0; Vector3 lightSampleNormal = LightObj->getNormalAt(sampleLightPoint); double cosThetaI = clamp(lightDirection.dot(normal)); double cosThetaO = clamp(-lightSampleNormal.dot(lightDirection)); if(id<0){ cosThetaI = 1; } if(obj->getMaterial() == DIFFUSE){ fr = 1 / M_PI; } else if(obj->getMaterial() == SPECULAR)// Blinn-phong { Vector3 HalfWay = normal + lightDirection; HalfWay = HalfWay.norm(); fr = pow( HalfWay.dot(normal), obj->getExponent()) * (obj->getExponent() + 2) / (2 * M_PI); } else { cout<< "no model for such material!"; } switch (sampleMode) { case Importance_Solid_Angle: { double pdfConstant = 2 * M_PI * (1 - cosThetaMax); L_r = L_r + fr * L_i * cosThetaI * (1 - inShadow) * pdfConstant ; } break; case Importance_Surface_Area: { // pdf = distance * distance / (CosThetaO * Area) double Area = 2 * M_PI * (1 - sinThetaMax) * lightR * lightR / distance2; // Fr = (fr(x, Wi, Wr) * Li(r(x, Wik), -Wik)) * cosThetaI / pdf; // L_r = fr * L_i * (1 - inShadow) * cosThetaI * cosThetaO * area / distance L_r += fr * L_i * (1 - inShadow) * cosThetaI * cosThetaO * Area ; } break; case Uniform_Solid_Angle: { L_r += fr * L_i * (1 - inShadow) * cosThetaI * 4 * M_PI ; } break; case Cosine_Weighted: { L_r += fr * L_i * (1 - inShadow) * M_PI; } break; case Uniform_Hemisphere_Solid_Angle: { L_r += fr * L_i * (1 - inShadow) * cosThetaI * 2 * M_PI ; } break; default: cout<<"inavailable sample mode"<<endl; } } else // No intersection for sample light ray with sphere light { // cout<<"miss out"<<endl; } } L_r = clamp(L_r/N); c = obj->getObjectColor() * L_r ; } return c; } Color getPixelColorWithSphereLightDBG(vector<Object*> &objects, int id, double &t, Ray &ray, Light &light, const int N, const SampleMode sampleMode){ Color c; Object* obj = objects.at(id); // Intersection Point Vector3 intersectionPoint = ray.getOrigin() + ray.getDirection() * t; // Normal of intersection point Vector3 normal = obj->getNormalAt(intersectionPoint); if(obj->insideObject(light.getLightPosition())){ normal = normal * -1; } // Get the light Obj // Here the last object in vector is light by default. Sphere* LightObj =(Sphere*)objects.at(objects.size() - 1); // vector3 from intersection point X to light center C Vector3 XC = LightObj->getSphereCenter() - intersectionPoint; // ThetaMax double sinThetaMax = LightObj->getSphereRadius() / XC.length(); double cosThetaMax = sqrt(1 - sinThetaMax * sinThetaMax); double lightR = LightObj->getSphereRadius(); if( id == objects.size() - 1){ c = obj->getObjectColor(); } else{ // Monte Carlo Begins Vector3 L_r (0.0,0.0,0.0); for(int m = 0; m < N; m++){ Vector3 sampleLightDirection; sampleLightDirection = getSample(*LightObj,intersectionPoint, sampleMode, normal, sinThetaMax).norm(); //sampleLightDirection = CosWeightedRandomHemisphereDirection2(normal); Ray secondary (intersectionPoint, sampleLightDirection); double t = LightObj->findIntersection(secondary); if(t > eps) { //cout<<"no miss "<<endl; Vector3 sampleLightPoint = intersectionPoint + sampleLightDirection * t; // Check if there are intersections between light sample and intersection point. // Light direction, from intersection point to the light position Vector3 lightDirection = sampleLightPoint - intersectionPoint ; // Distance between light sample point and the intersection point double distance2 = lightDirection.dot(lightDirection); // Light direction lightDirection = lightDirection.norm(); double tNear = inf; int shadowObjIndex = 0; // Shadow check // Move the shadow point a little bit along normal double offset = 1e-9; Vector3 shadowPointOrig = (ray.getDirection().dot(normal) < 0) ? intersectionPoint + normal * offset : intersectionPoint - normal * offset ; bool inShadow = trace(shadowPointOrig, lightDirection, objects, tNear, shadowObjIndex ) && tNear * tNear < distance2 ; Vector3 L_i (10.0,10.0,10.0); Vector3 lightSampleNormal = LightObj->getNormalAt(sampleLightPoint); double cosThetaI = clamp(lightDirection.dot(normal)); double cosThetaO = clamp(-lightSampleNormal.dot(lightDirection)); double brdf = 0.0; if(obj->getMaterial() == DIFFUSE){ brdf = 1 / M_PI; } else if(obj->getMaterial() == SPECULAR) { Vector3 outgoing = (normal * (normal.dot(lightDirection))* 2 - lightDirection).norm() ; //Vector3 Half = (outgoing + lightDirection).norm(); double temp =(outgoing.dot(ray.getDirection())); brdf = pow( -1 * temp, obj->getExponent()) * (obj->getExponent() + 2) / (2 * M_PI); //brdf = pow( Half.dot(normal), obj->getExponent()) * (obj->getExponent() + 2) / (2 * M_PI); // if((normal.dot(lightDirection)<=0)||brdf <eps) // cout<<"???"; cout<<"still but with phong cosine power"; } else { cout<< "no model for such material!"; } switch (sampleMode) { case Importance_Solid_Angle: { double pdfConstant = 2 * M_PI * (1 - cosThetaMax); L_r = L_r + L_i * cosThetaI * (1 - inShadow) * pdfConstant * brdf; } break; case Importance_Surface_Area: { // pdf = distance * distance / (CosThetaO * Area) double Area = 2 * M_PI * (1 - sinThetaMax) * lightR * lightR / distance2; // Fr = (fr(x, Wi, Wr) * Li(r(x, Wik), -Wik)) * cosThetaI / pdf; // L_r = fr * L_i * (1 - inShadow) * cosThetaI * cosThetaO * area / distance L_r += L_i * (1 - inShadow) * cosThetaI * cosThetaO * Area * brdf ; } break; case Uniform_Solid_Angle: { L_r += L_i * (1 - inShadow) * cosThetaI * 4 * M_PI * brdf; } break; case Importance_Phong:{ L_r += L_i * (1 - inShadow) * cosThetaI; } break; case Cosine_Weighted:{ L_r += L_i * (1 - inShadow) * brdf; } break; default: cout<<"inavailable sample mode"<<endl; } } // else // No intersection for sample light ray with sphere light // { // // cout<<"miss out"<<endl; // } } L_r = L_r/N; c = obj->getObjectColor() * L_r ; // c = L_r ; } return c; } Color getPixelColorAmbientOcclusion(vector<Object*> &objects, int id, double &t, Ray &ray, Light &light, const int N, const SampleMode sampleMode){ Color c; Object* obj = objects.at(id); // Intersection Point Vector3 intersectionPoint = ray.getOrigin() + ray.getDirection() * t; // Normal of intersection point, point out of the sphere Vector3 normal = obj->getNormalAt(intersectionPoint); double L_r = 0.0; for(int m = 0; m < N; m++){ Vector3 sampleLightDirection = getSample((Sphere&)*obj,intersectionPoint, sampleMode, normal, 0.0).norm() ; if(sampleLightDirection.dot(normal)<=0){ //cout<<"hh"<<endl; sampleLightDirection = sampleLightDirection * (-1); } Ray secondary (intersectionPoint, sampleLightDirection); // Check if there are intersections in the direction. double tNear = inf; int shadowObjIndex = 0; // Shadow check // Move the shadow point a little bit along normal double offset = 1e-9; Vector3 shadowPointOrig = (ray.getDirection().dot(normal) < 0) ? intersectionPoint + normal * offset : intersectionPoint - normal * offset ; bool inShadow = traceAll(shadowPointOrig, sampleLightDirection, objects, tNear, shadowObjIndex ) ; double cosThetaI = clamp(sampleLightDirection.dot(normal)); switch (sampleMode) { case Cosine_Weighted: { double ro = 1.0; L_r += ro * (1 - inShadow) / M_PI ; } break; default:// Uniform_Solid_Angle: L_r += (1 - inShadow) * cosThetaI * 2 / M_PI; break; } } L_r = L_r/N; c = obj->getObjectColor() * L_r ; return c; } Color getPixelColor_ExplicitPathTracing(vector<Object*> &objects, int id, double &t, Ray &ray, Light &light, int N, const SampleMode sampleMode){ // N is iteration times Color c (0,0,0), L_direct (0,0,0), L_indirect (0,0,0); Object* hitObj = objects.at(id); if(id == objects.size() - 1){ // The hit point is on light c = hitObj->getRadiance(); } else{ //if(N < 8) { // The hit point is on another object // Ld += contribution from light; L_direct = getPixelColorWithSphereLightDBG(objects, id, t, ray, light, 1, sampleMode); // ω’ = random direction in hemisphere above n; // Li += brdf * shade(trace(x, ω’)) * dot(n, ω’) / (p(ω’)); Vector3 intersectionPoint = ray.getOrigin() + ray.getDirection() * t; Vector3 normal = hitObj->getNormalAt(intersectionPoint); if(hitObj->insideObject(ray.getOrigin())){ normal = normal * -1; } double offset = 1e-9; Vector3 offsetIntersectionPoint = (ray.getDirection().dot(normal) < 0) ? intersectionPoint + normal * offset : intersectionPoint - normal * offset ; // russian roulette Color ObjColor = hitObj->getObjectColor(); // Q is the largest among r g b double Q = max(ObjColor.x, max(ObjColor.y, ObjColor.z)); // if random is smaller than Q // if objColor is very near to black, then Q should be very small, so the chance of randf() < Q should be small, so it have a better chance to not recurse again. if(randf() < Q){ // Shoot a new ray Vector3 w ; Ray second_ray; int IndexOfClosestObject; double hit_t; bool missScene = true; // Avoid double count do{ w = getSampleUniformSolidAngleHemisphere(intersectionPoint, normal); second_ray = Ray (offsetIntersectionPoint,w); missScene = !ClosestIntersectionObject(objects, second_ray, hit_t, IndexOfClosestObject); }while(IndexOfClosestObject == objects.size() -1); //if(!missScene){ double brdf = 1 / M_PI; double cosine = clamp(normal.dot(w)); double pdf = 1 / (2 * M_PI); L_indirect = hitObj ->getObjectColor() * getPixelColor_ExplicitPathTracing(objects, IndexOfClosestObject, hit_t, second_ray, light, ++N, sampleMode) * brdf * cosine / (Q * pdf); //} } } c = (L_direct + L_indirect ); } return c; } Color getPixelColor_ImplicitPathTracing(vector<Object*> &objects, int id, double &t, Ray &ray, Light &light, int Depthi, const SampleMode sampleMode){ // N is iteration times Color c (0,0,0), L_indirect (0,0,0); Object* hitObj = objects.at(id); if(id == objects.size() - 1){ // The hit point is on light c = c + hitObj->getRadiance() ; } else{ if(Depthi < 2) { // The hit point is on another object // ω’ = random direction in hemisphere above n; // Li += brdf * shade(trace(x, ω’)) * dot(n, ω’) / (p(ω’)); Vector3 intersectionPoint = ray.getOrigin() + ray.getDirection() * t; Vector3 normal = hitObj->getNormalAt(intersectionPoint); if(hitObj->insideObject(ray.getOrigin())){ normal = normal * -1; } double offset = 1e-9; Vector3 offsetIntersectionPoint = (ray.getDirection().dot(normal) < 0) ? intersectionPoint + normal * offset : intersectionPoint - normal * offset ; Vector3 w = getSample((Sphere&)objects, offsetIntersectionPoint, sampleMode, normal, 0.0); Ray second_ray (offsetIntersectionPoint,w); int IndexOfClosestObject; double hit_t; bool MissScene = !ClosestIntersectionObject(objects, second_ray, hit_t, IndexOfClosestObject); double throughput = 1; if(!MissScene){ double cosine = clamp(normal.dot(w)); double brdf = 1 / M_PI; double pdf = 1 / (2 * M_PI); switch (sampleMode) { case Uniform_Hemisphere_Solid_Angle: throughput *= brdf * cosine / pdf; break; case Cosine_Weighted: pdf = 1 / M_PI; throughput *= brdf / pdf; break; default: cout<< " no such sampling strategy! " << endl; break; } L_indirect = hitObj->getObjectColor() * getPixelColor_ImplicitPathTracing(objects, IndexOfClosestObject, hit_t, second_ray, light, ++Depthi, sampleMode) * throughput; } c = c + L_indirect; } else{ Vector3 hitpoint ; c = c + getPixelColorWithSphereLight(objects, id, t, ray, hitpoint, 100, sampleMode); } } return c; } Color getPixelColor_VolumeSingleScatter(vector<Object*> &objects, int id, double &t_MAX, Ray &ray, int STEPS, Volume* volume, Light& light){ Color pixelColor; Color Li(0,0,0); Sphere* hitObj = (Sphere*)objects.at(id); Color background = hitObj->getObjectColor(); Vector3 hitPoint = ray.getOrigin() + ray.getDirection() * t_MAX; double transmittance = volume->getTransmittanceHomogeneos(ray.getOrigin(), hitPoint); Li = Li + background * transmittance; double stepSize = t_MAX / STEPS; double t_march = 0; Vector3 x_march = ray.getOrigin(); double transmittanceFromEye = 0.0; // ray marching in the volume before hit the surface for(int i = 0 ; i < STEPS - 1; i++){ t_march += stepSize; x_march = ray.getOrigin() + ray.getDirection() * t_march; transmittanceFromEye = volume->getTransmittanceHomogeneos(ray.getOrigin(), x_march); double sigmaS = volume->getSigmaS(); double pf = volume->getPhaseFuctionValue(); //Vector3 lightHitPoint; // Color Le = getPixelColorWithSphereLight(objects, -1, t_march, ray, lightHitPoint, 1, Importance_Solid_Angle); Color Le = getPixelColorPointLight(objects, -1, t_march, ray, light); double transmittanceFromLight = volume->getTransmittanceHomogeneos(x_march, light.getLightPosition()); Li = Li + Le * transmittanceFromEye * sigmaS * pf * transmittanceFromLight * stepSize; } return Li; } Color getPixelColor_VolumeSingleScatter_point(vector<Object*> &objects, int id, double &t_MAX, Ray &ray, int STEPS, Volume* volume, Light& light){ Color pixelColor; Color Li(0,0,0); // Sphere* hitObj = (Sphere*)objects.at(id); Color background =getPixelColorPointLight(objects, id, t_MAX, ray, light); // Vector3 hitPoint = ray.getOrigin() + ray.getDirection() * t_MAX; double transmittance = volume->getTransmittanceHomogeneos(t_MAX); //double transmittance = volume->getTransmittanceHomogeneos(ray.getOrigin(), hitPoint); Li = background * transmittance; double stepSize = t_MAX / STEPS; double t_march = 0; Vector3 x_march; double transmittanceFromEye = 0.0; // ray marching in the volume before hit the surface for(int i = 0 ; i < STEPS - 1; i++){ t_march += stepSize; x_march = ray.getOrigin() + ray.getDirection() * t_march; //transmittanceFromEye = volume->getTransmittanceHomogeneos(ray.getOrigin(), x_march); transmittanceFromEye = volume->getTransmittanceHomogeneos(t_march); double sigmaS = volume->getSigmaS(); double pf = volume->getPhaseFuctionValue(); Color Le = getPixelColorPointLight(objects, -1, t_march, ray, light); double transmittanceFromLight = volume->getTransmittanceHomogeneos(x_march, light.getLightPosition()); Li = Li + Le * transmittanceFromEye * sigmaS * pf * transmittanceFromLight * stepSize; } return Li; } Color getPixelColor_VolumeSingleScatter_point2(vector<Object*> &objects, int id, double &t_MAX, Ray &ray, int MCsamples, Volume* volume, Light& light){ Color pixelColor; Color Li(0,0,0), Ls(0,0,0); double sigmaT = volume->getSigmaT(); double sigmaS = volume->getSigmaS(); Vector3 lightPos = light.getLightPosition(); // if(id == objects.size() - 1){ // cout<<endl; // } Color background =getPixelColorPointLight(objects, id, t_MAX, ray, light); double transmittance = volume->getTransmittanceHomogeneos(t_MAX); Li = background * transmittance; sampleMode1D sampleMode = Distance; for(int i = 0 ; i < MCsamples; i++){ double pdf; double tempDist; double t_sample = sample1DDBG(ray, lightPos, t_MAX, sigmaT, pdf, sampleMode,tempDist); Vector3 x_sample = ray.getOrigin() + ray.getDirection() * t_sample; double transmittanceFromEye = volume->getTransmittanceHomogeneos(t_sample); double pf = volume->getPhaseFuctionValue(); Color Le = getPixelColorPointLight(objects, -1, t_sample, ray, light); double transmittanceFromLight = volume->getTransmittanceHomogeneos(x_sample, light.getLightPosition()); // // cout<<tempDist<<endl; // // cout<<"--"<<endl; Ls = Ls + Le * transmittanceFromEye * sigmaS * pf * transmittanceFromLight / pdf; } Li = Li + Ls / MCsamples; return Li; } Color getPixelColor_VolumeSingleScatter_sphere(vector<Object*> &objects, int id, double &t_MAX, Ray &ray, int STEPS, Volume* volume, Light& light){ Color pixelColor; Color Li(0,0,0); if(id == objects.size() - 1){ cout<<endl; } Vector3 hitPoint; Color background = getPixelColorWithSphereLight(objects, id, t_MAX, ray, hitPoint,1,Importance_Solid_Angle); //Vector3 hitPoint = ray.getOrigin() + ray.getDirection() * t_MAX; double transmittance = volume->getTransmittanceHomogeneos(t_MAX); //double transmittance = volume->getTransmittanceHomogeneos(ray.getOrigin(), hitPoint); Li = background * transmittance; double stepSize = t_MAX / STEPS; double t_march = 0; Vector3 x_march; double transmittanceFromEye = 0.0; // ray marching in the volume before hit the surface for(int i = 0 ; i < STEPS - 1; i++){ t_march += stepSize; x_march = ray.getOrigin() + ray.getDirection() * t_march; //transmittanceFromEye = volume->getTransmittanceHomogeneos(ray.getOrigin(), x_march); transmittanceFromEye = volume->getTransmittanceHomogeneos(t_march); double sigmaS = volume->getSigmaS(); double pf = volume->getPhaseFuctionValue(); Vector3 lightHitPoint; Color Le = getPixelColorWithSphereLight(objects, -1, t_march, ray, lightHitPoint, 1, Importance_Solid_Angle); double transmittanceFromLight = volume->getTransmittanceHomogeneos(x_march, lightHitPoint); Li = Li + Le * transmittanceFromEye * sigmaS * pf * transmittanceFromLight * stepSize; } return Li; } Color getPixelColor_VolumeSingleScatter_sphere2(vector<Object*> &objects, int id, double &t_MAX, Ray &ray, int MCsamples, Volume* volume, Light& light){ Color pixelColor; Color Li(0,0,0), Ls(0,0,0); double sigmaT = volume->getSigmaT(); double sigmaS = volume->getSigmaS(); Vector3 lightPos = light.getLightPosition(); Vector3 hitPoint; // if(id == objects.size() - 1){ // cout<<endl; // } Color background = getPixelColorWithSphereLight(objects, id, t_MAX, ray, hitPoint,1,Importance_Solid_Angle); double transmittance = volume->getTransmittanceHomogeneos(t_MAX); Li = background * transmittance; sampleMode1D sampleMode = EquiAngular; for(int i = 0 ; i < MCsamples; i++){ double pdf; double tempDist; double t_sample = sample1DDBG(ray, lightPos, t_MAX, sigmaT, pdf, sampleMode,tempDist); Vector3 x_sample = ray.getOrigin() + ray.getDirection() * t_sample; double transmittanceFromEye = volume->getTransmittanceHomogeneos(t_sample); double pf = volume->getPhaseFuctionValue(); Color Le = getPixelColorWithSphereLight(objects, -1, t_sample, ray, hitPoint,1,Importance_Solid_Angle); double transmittanceFromLight = volume->getTransmittanceHomogeneos(x_sample, light.getLightPosition()); // // cout<<tempDist<<endl; // // cout<<"--"<<endl; Ls = Ls + Le * transmittanceFromEye * sigmaS * pf * transmittanceFromLight / pdf; } Li = Li + Ls / MCsamples; return Li; } //Color vPT(x, ω) //tmax = nearestSurface(x, ω) //t = -log(1 - rand()) / σt // Sample free path //if t < tmax: // Volume interaction //x += t * ω //pdf_t = σt * exp(-σt * t) //(ω’, pdf_ω’) = samplePF(ω) //return σs * Tr(t) * PF(ω) / (pdf_t * pdf_ω’) * vPT(x,ω’) //else: // Surface interaction //x += tmax * ω //Pr_tmax = exp(-σt * tmax) //(ω’, pdf_ω’) = sampleBRDF(n, ω) //return Tr(tmax) * BRDF(ω, ω’) / (Pr_tmax * pdf_ω’) * vPT(x, ω’) void renderDBG(const int width, const int height, vector<Object*> objects, const char *filename, Camera& Cam, Light& light, Volume* volume,const int Samples, const SampleMode mode, int AASample, AASamplerStrategy aaSampleStrategy){ int n = width * height; Color *pixels = new Color[n]; int idx; Color pixelColor; // Anti-aliasing // sample of each pixel int AAdepth = AASample; int SampleSum = AAdepth * AAdepth; Sampler sampler(width, height, AAdepth); Color sumColor (0,0,0); #pragma omp parallel for schedule(dynamic, 1) private(pixelColor) for (int y = 0; y < height; y++){ fprintf(stderr,"\r%5.2f%%",100.*y/(height-1)); for(int x = 0; x < width; x++){ idx = (height - y - 1) * width + x; sumColor = Color(0,0,0); // if(x == 255 && y == 289){ // // cout<<"dd"<<endl; // } double sampleX = double(x), sampleY = double(y); Sample s(sampleX,sampleY); vector<Sample> samples; sampler.getSample(&s, samples, aaSampleStrategy); for (int current = 0; current < samples.size(); current ++) { Vector3 camRayOrigin = Cam.getCamPosition(); sampleX = samples.at(current).getX(); sampleY = samples.at(current).getY(); Vector3 camRayDirection = Cam.getCamUp() * ( sampleX /width - .5) + Cam.getCamRight() * ( sampleY /height - .5) + Cam.getCamDirection(); camRayDirection = camRayDirection.norm(); double motionTime = randf(); Ray cameraRay(camRayOrigin,camRayDirection,motionTime); //Ray cameraRay(camRayOrigin,camRayDirection); double t; int IndexOfClosestObject; if(ClosestIntersectionObject(objects, cameraRay, t, IndexOfClosestObject)){ Vector3 hitPoint; // pixelColor = getPixelColor_ImplicitPathTracing(objects,IndexOfClosestObject, t,cameraRay, light, 0, mode); pixelColor = getPixelColorPointLight(objects, IndexOfClosestObject, t, cameraRay, light); //pixelColor = getPixelColor_VolumeSingleScatter_point2(objects, IndexOfClosestObject, t, cameraRay, 8, volume,light); //pixelColor = getPixelColorWithSphereLight(objects,IndexOfClosestObject, t,cameraRay, hitPoint, Samples, mode); //pixelColor = getPixelColorWithSphereLightDBG(objects, IndexOfClosestObject, t, cameraRay, light, Samples, mode); //pixelColor = getPixelColorAmbientOcclusion(objects,IndexOfClosestObject, t,cameraRay, light, Samples, mode); } else{ pixelColor = Color(1,1,1); } sumColor = sumColor + pixelColor; } pixels[idx] = sumColor / (SampleSum) ; } } savePPM(filename, width, height, pixels); delete []pixels; } int main(){ cout << "rendering..." << endl; int width = 512, height = 384; double AspectRatio = double(width)/double(height); double TanHalfFOV = 0.57735 ; Vector3 CamPos (50, 50, 275.0); //Vector3 CamPos (0, 0, 200.0); Vector3 LookAt (0, -0.05, -1); //Vector3 LookAt (0, 0, -1); Vector3 CamDir = (LookAt).norm(); Vector3 CamUp ( AspectRatio * TanHalfFOV, 0., 0.); Vector3 CamRight = (CamUp.cross(CamDir)).norm() * TanHalfFOV; Camera Cam (CamPos,CamDir,CamUp,CamRight); Vector3 light_position(50, 68.6 - .27, 81.6); double radiance = 40000.0; Light light(light_position, Color(1,1,1),radiance); Volume homogeneousVolume(0.0001,0.003); Vector3 sphereO0 = light_position; Vector3 sphereO1(1e5 + 1, 40.8, 81.6); Vector3 sphereO2(-1e5 + 99, 40.8, 81.6); Vector3 sphereO3(50, 40.8, 1e5); Vector3 sphereO4(50, 1e5, 81.6); Vector3 sphereO5(50, -1e5 + 81.6, 81.6); Vector3 sphereO6(27, 16.5, 47); Vector3 sphereO7(73, 16.5, 78); Vector3 sphereO8(50, 68.6 - .27, 81.6); Vector3 sphereO9(50, -1e5, 81.6); Vector3 bigSphereVolume((1e3)/2, 40.8, 81.6); Color c1 (.75, .25, .25); Color c2 (.25, .25, .75); Color c3(.75, .75, .75); Color c4(.999, .999, .999); Color c5(1,1,1); Color black(0,0,0); Vector3 dir1 (5,0,0); Vector3 radiance1 (10,10,10); Vector3 radiance2 (0,0,0); double exp = 2; Sphere spheres[] = { // // Sphere(1e5, sphereO1, c1,exp,radiance2, DIFFUSE), // Sphere(1e5, sphereO2, c2,exp,radiance2, DIFFUSE), // Sphere(1e5, sphereO3, c3,exp,radiance2, DIFFUSE), // Sphere(1e5, sphereO4, c3,exp,radiance2, DIFFUSE), // Sphere(1e5, sphereO5, c3,exp,radiance2, DIFFUSE), Sphere(16.5, sphereO6, c4, exp,radiance2, DIFFUSE), Sphere(16.5, sphereO7, c4, exp,radiance2, DIFFUSE), Sphere(1e3, bigSphereVolume, black, exp, radiance1, DIFFUSE), Sphere(2, sphereO8, c5, exp, radiance1, DIFFUSE), }; MotionSphere mSphere[2] = { MotionSphere(16.5, sphereO6, c4, dir1, 0.0), MotionSphere(16.5, sphereO7, c4, dir1, 0.0), }; // bool temp1 = spheres[0].insideObject(CamPos); // bool temp2 = spheres[0].insideObject(spheres[1].getSphereCenter()); vector<Object*> objects; // for (int i = 0; i< int(sizeof(mSphere)/sizeof(MotionSphere)); i++){ // objects.push_back(&mSphere[i]); // } for (int i = 0; i< int(sizeof(spheres)/sizeof(Sphere)); i++){ objects.push_back((Object*)&spheres[i]); } renderDBG(width,height, objects, "D:/Yue/VolumeSingleScattering/dist-step8.ppm", Cam, light, &homogeneousVolume,1, Importance_Solid_Angle,4, Jittered); return 0; }
e766ad948cc08539d70afe14f1dfe83af0e57f53
f37d8d2dcdf3b3f1aabb09e7b5f69ddbe4a75c09
/t3d-graphics-engine-master/T3D/T3D/HouseBoatMove.h
a142f012d1c29436da72cba01ffe08e038c77339
[]
no_license
Ken-na/RoboPirates
8d4f568f0a66c1ba61592a69a239ca0e97e275c4
dd8af05e4e4eb8dfc1cd32fbe994b52902de38d0
refs/heads/master
2023-03-02T09:38:34.898547
2021-02-01T10:18:29
2021-02-01T10:18:29
334,792,779
0
0
null
null
null
null
UTF-8
C++
false
false
325
h
HouseBoatMove.h
#pragma once //#include "T3DApplication.h" #include "task.h" namespace T3D { class HouseBoatMove : public Task { public: HouseBoatMove(T3DApplication *app); ~HouseBoatMove(void); virtual void update(float dt); //void init(); //~AnimationTask(T3DApplication *app); float elapsedTime; Transform *obj; }; }
a1a4cef7c1474ff5ebe181cbd6338f317fb7d01e
775acebaa6559bb12365c930330a62365afb0d98
/source/public/interfaces/ui/IMenuCustomizationData.h
0087f7298ce737c31a5870f93fec16b519bc08d5
[]
no_license
Al-ain-Developers/indesing_plugin
3d22c32d3d547fa3a4b1fc469498de57643e9ee3
36a09796b390e28afea25456b5d61597b20de850
refs/heads/main
2023-08-14T13:34:47.867890
2021-10-05T07:57:35
2021-10-05T07:57:35
339,970,603
1
1
null
2021-10-05T07:57:36
2021-02-18T07:33:40
C++
UTF-8
C++
false
false
7,506
h
IMenuCustomizationData.h
//======================================================================================== // // $File: //depot/devtech/16.0.x/plugin/source/public/interfaces/ui/IMenuCustomizationData.h $ // // Owner: lance bushore // // $Author: pmbuilder $ // // $DateTime: 2020/11/06 13:08:29 $ // // $Revision: #2 $ // // $Change: 1088580 $ // // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved. // // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance // with the terms of the Adobe license agreement accompanying it. If you have received // this file from a source other than Adobe, then your use, modification, or // distribution of it requires the prior written permission of Adobe. // //======================================================================================== #pragma once #ifndef __IMenuCustomizationData__ #define __IMenuCustomizationData__ #include "AppUIID.h" #include "IPMUnknown.h" #include "ActionID.h" #include "K2Vector.h" #include "BravoForwardDecl.h" class IXMLOutStream; /** This interface is used to get and set menu customization info, on the workspace boss, or on the kSetMenuCustomizationPrefsCmdBoss */ class IMenuCustomizationData : public IPMUnknown { public: enum { kDefaultIID = IID_IMENUCUSTOMIZATIONDATA }; typedef enum { kNoMenuColor = -1, kBlueMenuColor = 0, kGrayMenuColor = 1, kGreenMenuColor = 2, kOrangeMenuColor = 3, kRedMenuColor = 4, kVioletMenuColor = 5, kYellowMenuColor = 6, kNumberOfMenuColors = 7 // It's intentional that the number of colors is 7 and not 8. "kNoMenuColor" isn't considered a real color. } tMenuColor; typedef enum { kNormal = 0, kSelected, kDisabled, kNumberOfStates } tMenuState; /** structure describing a submenu */ struct CustomizedSubMenuPath { typedef object_type data_type; PMString fSubMenuPath; }; /** structure describing a colorized menu item */ struct MenuColorStruct { typedef base_type data_type; MenuColorStruct(ActionID id, tMenuColor index) : fActionID(id), fColorIndex(index){} ActionID fActionID; tMenuColor fColorIndex; }; /** structure to describe a colorized submenu */ struct SubMenuColorStruct { typedef object_type data_type; SubMenuColorStruct(IMenuCustomizationData::CustomizedSubMenuPath menuPath, tMenuColor index) : fColorizedSubMenuPath(menuPath), fColorIndex(index){} IMenuCustomizationData::CustomizedSubMenuPath fColorizedSubMenuPath; tMenuColor fColorIndex; }; /** Get the name of the default menu customization set. */ virtual const PMString& GetDefaultMenuSetName() const = 0; /** Set the menu set info - name, modified state, whether or not this set is a preset(as opposed to user-created), and indicate if the file should be read from disk */ virtual bool16 SetCurrentMenuSetInfo(const PMString& menuSetName,bool16 isModified,bool16 isPreset,bool16 readShortcutSetFromDisk)= 0; /** Get the name of the current menu customization set */ virtual const PMString& GetCurrentMenuSetName() const= 0; /** Check if the current menu customization set is modified from the version on disk */ virtual bool16 IsCurrentMenuSetModified() const= 0; /** Check if the current menu customization set is a preset(as opposed to user-created) */ virtual bool16 IsCurrentMenuSetPreset() const= 0; /** Hides a submenu with the specified path */ virtual void HideSubMenu(const PMString& menuPath) = 0; /** Shows a submenu with the specified path */ virtual void ShowSubMenu(const PMString& menuPath) = 0; /** Check if submenu with the given path is hidden.*/ virtual bool16 IsSubMenuHidden(const PMString& menuPath) const= 0; /** Get the list of all the currently hidden submenus.*/ virtual const K2Vector<CustomizedSubMenuPath>& GetHiddenSubMenus() const = 0; /** Set the list of the currently hidden submenus.*/ virtual void SetHiddenSubMenus(const K2Vector<CustomizedSubMenuPath>& hiddenSubMenuList) = 0; /** Clear the list of the currently hidden submenus.*/ virtual void ClearAllHiddenSubMenus() = 0; /* Hides a menu by action id. This may hide multiple menu items that share an ActionID */ virtual void HideMenuAction(const ActionID action) = 0; /** Show a menu by action id. */ virtual void ShowMenuAction(const ActionID action) = 0; /** Check if menu item with given ActionID is hidden.*/ virtual bool16 IsMenuActionHidden(ActionID action) const = 0; /** Get the list of all the currently hidden menu items.*/ virtual const K2Vector<ActionID>& GetHiddenMenuActions() const = 0; /** Set the list of the currently hidden menu items.*/ virtual void SetHiddenMenuActions(const K2Vector<ActionID>& hiddenActionList) = 0; /** Clear the list of the currently hidden menu items.*/ virtual void ClearAllHiddenActions() = 0; /** Set the color for a submenu */ virtual void SetSubMenuColor(const PMString& menuPath, tMenuColor colorIndex) = 0; /** Get color of submenu with given path */ virtual tMenuColor GetSubMenuColor(const PMString& menuPath) const = 0; /** Get the list of all the currently colored submenus.*/ virtual const K2Vector<SubMenuColorStruct>& GetColoredSubMenus() const = 0; /** Set the list of the currently colored submenus.*/ virtual void SetColoredSubMenus(const K2Vector<SubMenuColorStruct>& coloredSubMenuList) = 0; /** Clear the list of the currently colored submenus.*/ virtual void ClearAllColoredSubMenus() = 0; virtual void SetMenuActionColor(const ActionID action, tMenuColor colorIndex) = 0; /** Get color of menu item with given ActionID */ virtual tMenuColor GetMenuActionColor(ActionID action) const = 0; /** Get the list of all the currently colored menu items.*/ virtual const K2Vector<MenuColorStruct>& GetColoredMenuActions() const = 0; /** Set the list of the currently colored menu items.*/ virtual void SetColoredMenuActions(const K2Vector<MenuColorStruct>& coloredActionList) = 0; /** Clear the list of the currently colored menu items.*/ virtual void ClearAllColoredMenuActions() = 0; /** Return kTrue if any menus, submenus are hidden or colored, kFalse otherwise. */ virtual bool16 GetMenusAreHiddenOrColorized() const = 0; /** Clear all hidden menus, submenus, and colorization on menus and submenus */ virtual void ClearAllMenusAndColorization() = 0; /** Write menu customization to XML. Returns kTrue if successful. */ virtual bool16 WriteXMLMenuFile(IXMLOutStream* s) const = 0; /** Save current customization to a file. Returns kTrue if successful. */ virtual bool16 SaveCurrentMenuSetToFile(const PMString& menuSetName) const = 0; typedef enum { /** kMenuFileNoError success*/ kMenuReadFileNoError = 0, /** kMenuFileNotFound File was not found*/ kMenuFileNotFound, /** kMenuFileWrongPlatform File appears to be from wrong platform(i.e. trying to open windows shortcut set on mac)*/ kMenuFileWrongPlatform, /** kMenuFileFormatWrongOrCorrupt File isn't a known type of shortcut set*/ kMenuFileFormatWrongOrCorrupt, /** kMenuFileFormatIncompatible File isn't a version that can be understood*/ kMenuFileFormatIncompatible } MenuSetReadFileError; /** Reads menu customization from stream */ virtual MenuSetReadFileError ReadXMLMenuFile(IPMStream* s) = 0; }; #endif // __IMenuCustomizationData__
b894dbf3904955f39d3869f49e09ba433676c0f7
617f1777427d6302bf55de8cfd8c642ff189c1af
/Codeforces/gravity.cpp
642bf7ee38432506daa61fe22ff04df3c17c399b
[]
no_license
alywaly13/codechef
76c89593e7d2f87cbd1ed3e59def99f23a1cfb50
084b5b2d1a33d5b733dabaa7c99bd2a44c7f7236
refs/heads/master
2020-05-19T19:43:20.928761
2015-08-13T03:38:35
2015-08-13T03:38:35
40,637,234
1
0
null
null
null
null
UTF-8
C++
false
false
1,526
cpp
gravity.cpp
#include <iostream> #include <cmath> #include <string> #include <cstdlib> using namespace std; void calc(string a, string b){ // cout << a.length(); // cout <<b.length(); int last; long switches = -1; for(long i = 0; i < a.size(); i++) { if (a[i]=='#' && b[i]=='#'){ cout << "No"; return; } else if (a[i]=='#' && b[i]=='.'){ // cout<<"b"; if (last !=2){ switches++; // cout<<switches; } last=2; } else if (b[i]=='#' && a[i]=='.'){ // cout<<"a"; if (last!=1){ switches++; // cout<<switches; } last=1; } else if (b[i]=='.' && a[i]=='.'){ // cout<<"."; } } cout<<"Yes\n"; cout <<switches; } void gravity(){ long t; cin >> t; string a; string b; for (long i=0; i<t; i++){ cin>> a; cin >>b; // if (a.length() > 18000){ // char *str = "Foo"; // Compiler marks the constant string as read-only // *str = 'b'; // } // if (a.length() > 190000){ // cout << 5/0; // } calc(a,b); cout<<"\n"; } } //int main() { //// int a; //// int b; //// int c; //// cin>>a; //// cin>>b; //// cin>>c; //// cout << abs(a-b+c) << " " << a-b+c; //// cout<< abs(a-b+c+c); // gravity(); // // your code goes here // return 0; //}
8e827bc0d9c710ff6824b64ef4aa557d646afb64
9f0c3e15eb57eb0d3c74cf5a949905b5b167021f
/Tree/Pruning.cpp
0abe6f7d8850fb776212fac69e570b56e53f973a
[]
no_license
BhJia/Data-Structure
87899768917836ca921baf00d1f78bf12ef618ca
48f5537832c746902c33e53cc187eea9a55f7a6b
refs/heads/main
2023-08-04T14:12:22.511869
2021-09-28T01:08:00
2021-09-28T01:08:00
411,091,843
1
0
null
null
null
null
UTF-8
C++
false
false
2,671
cpp
Pruning.cpp
#include <bits/stdc++.h> using namespace std; template <class T> struct TreeNode { T val; TreeNode *left, *right; TreeNode() : left(nullptr), right(nullptr){}; TreeNode(T &x) : val(x), left(nullptr), right(nullptr){}; TreeNode(T &x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right){}; }; // 二叉树剪枝:给定一颗值为0或1的二叉树,将所有不存在1的子树去掉 // 方法1:BFS迭代+判断是否有1 template <class T> TreeNode<T> *pruneTree(TreeNode<T> *root) { if (!root || hasNoOne(root)) //注意这里要先判断整棵树是否都是没有1的 return nullptr; queue<TreeNode<T>> q; q.push(root); while (!q.empty()) { TreeNode<T> *t = q.front(); q.pop(); if (hasNoOne(t->left)) //先判断左右子树是否有1,如果没有,直接设为空 t->left = nullptr; if (hasNoOne(t->right)) t->right = nullptr; if (t->left) //再把非空的左右子树入队 q.push(t->left); if (t->right) q.push(t->right); } return root; } // 判断是否有1 template <class T> bool hasNoOne(TreeNode<T> *root) { if (!root) return true; if (root->val == 1) return false; return hasNoOne(root->left) && hasNoOne(root->right); } // 方法2:递归+优先判断根节点 template <class T> TreeNode<T> *pruneTree(TreeNode<T> *root) { if (!root || hasNoOne(root)) return nullptr; root->left = pruneTree(root->left); root->right = pruneTree(root->right); return root; } // 方法3:递归+最后判断根节点 template <class T> TreeNode<T> *pruneTree(TreeNode<T> *root) { if (!root) return nullptr; root->left = pruneTree(root->left); root->right = pruneTree(root->right); // 剪枝之后如果只剩下值为0的根节点,把根节点也删掉,否则返回根节点 return root->val==0 && !root->left && !root->right?nullptr:root; } // 修剪二叉搜索树:给定二叉搜索树根节点和low,high,返回节点值在low-high之间的节点相对结构 // 思路:与二叉树剪枝相似的递归方法 template <class T> TreeNode<T> *trimBST(TreeNode<T> *root, int low, int high) { if (!root) return nullptr; if (root->val > high) //如果根节点值超过上界,那么把根节点和右子树直接删掉,返回剪枝后的左子树 return trimBST(root->left, low, high); if (root->val < low) return trimBST(root->right, low, high); root->left = trimBST(root->left, low, high); root->right = trimBST(root->right, low, high); return root; }
b0cd86c4ba7a6a762c093f0c50b6c791d8276835
7503aa76d5f67825b589d3ad567bbee12c1d2460
/parsingrfframe.h
6c4bd1dda1a72920187baa1a5986aa1bfe0999ad
[]
no_license
zy14443/NFC_Frame_Viewer
b56085c1f5bb48832347fb1fb6e0f8c7790368ab
0c9939fb8ed8711489eb20fc1172c174ddbaad86
refs/heads/main
2023-07-17T15:44:49.711356
2021-09-07T18:30:44
2021-09-07T18:30:44
404,082,023
0
0
null
null
null
null
UTF-8
C++
false
false
1,310
h
parsingrfframe.h
#ifndef PARSINGRFFRAME_H #define PARSINGRFFRAME_H /******************************************************************************* * THIS INFORMATION IS PROPRIETARY TO BROADCOM CORP * * ------------------------------------------------------------------------------ * * Copyright (c) 2011 Broadcom Corp. * * ALL RIGHTS RESERVED * ******************************************************************************** * * File Name: parsingrfframe.h * * Abstract: The is the class for NCI frame with the name of NFC_FRAME_LOG_NTF. * This class inherits ParsingNCI. * * Functions: * *******************************************************************************/ #include "parsing.h" #include "parsingnci.h" #include "importmessages.h" class ParsingRFFrame : public ParsingNCI { public: ParsingRFFrame(unsigned int ID, unsigned int byteLength, unsigned char rawData[] // #ifdef FILE_OUTPUT , char * pFilePath // #endif ); virtual int parse(); private: int m_MT; int m_PBF; int m_GID; int m_OID; int m_TimeStamp; int m_Protocol; int m_Bytelen; int m_Bitlen; int m_dir; }; #endif // PARSINGRFFRAME_H
1c0254901309e8e4a2d20f0a6e0c5c6675cd2fee
4720509cf38d03eee361055a4af3625173c446e9
/classe.cpp
62e953384d3b0eeea9b7b47b46fbde463feb0597
[]
no_license
FernandoFaveroRo/AtividadePOO
bd7c8cdca89e7322cde4d20436894eb5b38864a7
6ada0c29b7101c89bd810881b501317c7fa6bd42
refs/heads/main
2023-05-12T09:41:43.163992
2023-05-07T15:29:32
2023-05-07T15:29:32
354,914,851
0
0
null
null
null
null
UTF-8
C++
false
false
2,090
cpp
classe.cpp
#include "classe.hpp" // ---------- POLIGONO ---------// Poligono::Poligono(){ this->base = 0.0; this->altura = 0.0; } Poligono::Poligono(float x, float y){ this->base = x; this->altura = y; } float Poligono::getBase(){ return this->base; } float Poligono::setBase(float x){ this->base = x; } float Poligono::getAltura(){ return this->altura; } void Poligono::setAltura(float y){ this->altura = y; } // ---------- RETANGULO ---------// float Retangulo::areaRet { this->areaRet = base * altura; } float Retangulo::perimetroRet { this->perimetroRet = 2 * (base + altura); } // ---------- TRIANGULO ---------// float Triangulo::AreaTri { this->AreaTri = (base * altura) / 2; } // ---------- QUADRADO ---------// float Quadrado::AreaQua { this->AreaQua = base * altura; } // ---------- CIRCULO ---------// Circulo::Circulo(){ this->raio = 0.0; } void Circulo::Circulo(float raio){ this->raio = raio; } float Circulo::getRaio(){ return this->raio; } void Circulo::setRaio(float r){ this->raio = r; } float Circulo::AreaCirc(float raio) { this->AreaCirc = pi * pow(raio,2); } // ---------- ESFERA ---------// float Esfera::AreaEsfera(float raio){ this->AreaEsfera = 4 * pi * pow(raio,2); } float Esfera::VolumeEsfera(){ this->VolumeEsfera = 4 * (pi * pow(raio,3))/3; } // ---------- CONE ---------// Cone::Cone(){ this->altura = 0; } float Cone::getAltura(){ return this->altura; } void Cone::setAltura(float altura){ this->Altura = Altura; } float Cone::VolumeCone(){ this->VolumeCone = (pi * pow(raio, 2) * altura) / 3 } // ---------- PARALELEPIPEDO ---------// Paralelepipedo::Paralelepipedo(){ this->Comprimento = 0; } float Cone::getComprimento(){ return this->altura; } void Cone::setComprimento(float Comprimento){ this->Comprimento = Comprimento; } float Paralelepipedo::AreaParale(){ this->AreaParale = 2* ((area*base) + (area*comprimento) + (base * comprimento)); } float Paralelepipedo::VolumeParale(){ this->VolumeParale = base * altura * comprimento; }
a673b59cab355f04598ee9a24d9f7b6693a16483
20e4a665595f2290f38cbca7f3fde4476b6d8da4
/2020.09.17-Homework-1/Task4/Source.cpp
2efcb6731e1a99538126d6d750e81677e512d21f
[ "Apache-2.0" ]
permissive
st021213/programming-bach-2020-autumn
64fa2926628127883ede25c6621daefbe2cfe691
b0b62cc3ac46b981f272bc362398e63b4cb62e7f
refs/heads/master
2023-02-01T08:16:14.238574
2020-12-17T07:59:53
2020-12-17T07:59:53
298,191,586
2
1
null
null
null
null
WINDOWS-1251
C++
false
false
516
cpp
Source.cpp
#include<iostream> using namespace std; /* 4. Написать программу, печатающую все простые числа, не превосходящие заданного числа. ввод: 18 вывод : 2, 3, 5, 7, 11, 17 */ bool isPrime(int n) { for (int i = 2; i * i <= n; ++i) { if (n % i == 0) { return false; } } return true; } int main() { int n = 0; cin >> n; for (int i = 2; i <= n; ++i) { if (isPrime(i)) { cout << i << " "; } } return EXIT_SUCCESS; }
743316b455fb8c0f01f125eced0ba9f52f671e02
efe51f3a9520a9c295a0d065df239f7fef1eac6d
/lextest.cc
5bdc04d18d892743201de6901445db6b241d9677
[]
no_license
KabirUttamsingh/Compiler
4e4653e99e457f81bc659d4bb4f70d7a5506ff6c
199fa220dced5ab761e5412204ccb6beb28575bd
refs/heads/master
2021-07-08T20:23:18.571819
2017-09-27T22:15:33
2017-09-27T22:15:33
105,075,162
1
0
null
null
null
null
UTF-8
C++
false
false
636
cc
lextest.cc
#include "token.h" #include "lexer.h" #include <iostream> #include <fstream> #include <string> using namespace std; void processFile(istream& in) { Lexer lexer(in); Token token; token = lexer.nextToken(); printf(" Type Lexeme Line # Pos\n"); while (token.getType() != Token::ENDOFFILE) { printf("%5d %-10s %5d %5d\n", token.getType(), token.getLexeme().c_str(), token.getLine(), token.getPos()); token = lexer.nextToken(); } } int main(int argc, char **argv) { ifstream in; if (argc > 1) { in.open(argv[1]); processFile(in); in.close(); } else { processFile(cin); } }
65b282422716419247d8ca895d88c1dc55805a83
7fa46faf52cad727faf012ff60f07ebd17882c63
/terminal_new/audiowidget.cpp
44b8a343b525adb0d930b5c6726b289806ad199d
[]
no_license
chunhui204/qt-project
c945ba632b9d6408ae98816cbae791cae1373a22
9fd13829437a59fc47f3287808502b8336a02512
refs/heads/master
2020-03-22T18:15:54.641483
2018-10-14T01:55:08
2018-10-14T01:55:08
140,448,280
0
0
null
null
null
null
UTF-8
C++
false
false
2,611
cpp
audiowidget.cpp
#include "audiowidget.h" #include "ui_audiowidget.h" AudioWidget::AudioWidget(QWidget *parent) : QWidget(parent), ui(new Ui::AudioWidget) { ui->setupUi(this); initUI(); } void AudioWidget::initUI() { // 初始化绘图组件customPlot ui->customPlot->addGraph(); ui->customPlot->graph(0)->setPen(QPen(Qt::blue)); // line color blue for first graph // ui->customPlot->graph(0)->setBrush(QBrush(QColor(0, 0, 255, 20))); // first graph will be filled with translucent blue //y周范围 ui->customPlot->yAxis->setRange(-1,1);//(-32768, 32768); ui->customPlot->xAxis->setRange(0, 5, Qt::AlignLeft); QSharedPointer<QCPAxisTickerTime> timeTicker(new QCPAxisTickerTime); timeTicker->setTimeFormat("%m:%s"); ui->customPlot->xAxis->setTicker(timeTicker); ui->customPlot->axisRect()->setupFullAxesBox(); // 上方和右边坐标显示 ui->customPlot->xAxis2->setVisible(true); ui->customPlot->xAxis2->setTickLabels(false); ui->customPlot->yAxis2->setVisible(true); ui->customPlot->yAxis2->setTickLabels(false); // make left and bottom axes always transfer their ranges to right and top axes: connect(ui->customPlot->xAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->xAxis2, SLOT(setRange(QCPRange))); connect(ui->customPlot->yAxis, SIGNAL(rangeChanged(QCPRange)), ui->customPlot->yAxis2, SLOT(setRange(QCPRange))); // let the ranges scale themselves so graph 0 fits perfectly in the visible area: // ui->customPlot->graph(0)->rescaleAxes(); // Allow user to drag axis ranges with mouse, zoom with mouse wheel and select graphs by clicking: ui->customPlot->axisRect(0)->setRangeDrag(Qt::Horizontal); ui->customPlot->axisRect(0)->setRangeZoom(Qt::Horizontal); ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); } AudioWidget::~AudioWidget() { delete ui; } void AudioWidget::onLabelPredicted(int label) { if(label == -1) ui->label->setText(QString::fromLocal8Bit("未知类别")); else if(label == -2) ui->label->setText(QString::fromLocal8Bit("未进行预测")); else ui->label->setText(QString::fromLocal8Bit("类别")+QString::number(label, 10)); } void AudioWidget::onCurvePainted(QVector<double> xs, QVector<double> ys) { if(xs.isEmpty()) ui->customPlot->graph(0)->setData(xs, xs); // 清空界面 else { for(int i=0; i< xs.size() ; i++) ui->customPlot->graph(0)->addData(xs[i], ys[i]); ui->customPlot->xAxis->setRange(xs[0], 5, Qt::AlignHCenter); } ui->customPlot->replot(); }
35599391bef495a17a419cbb80787cd93bc5e043
ff7f92968d200843a6a480dda8247e9fe26d094b
/client/src/game_io/final_match.cpp
f7401b95aaef9dd73fea983b09815601f695b0b6
[]
no_license
IngErnestoAlvarez/CounterStrike
e7b36867de2b4cd2ac1a19fb8cf4217a89b40043
0155ce1ef31c1c5abaefcad36f196cdd0845c502
refs/heads/main
2023-07-18T17:07:28.168997
2021-07-20T20:24:12
2021-07-20T20:24:12
373,655,897
2
0
null
null
null
null
UTF-8
C++
false
false
771
cpp
final_match.cpp
#include "game_io/final_match.h" FinalMatchScreen::FinalMatchScreen(SdlWindow &window, FinalScores *fs, TeamID myTeam) : myTeam(myTeam), score(window), winner(window, "VICTORIA", BLUE, 60), looser(window, "DERROTA", RED, 60), fs(fs) { winner.set_pos(50, 100); looser.set_pos(50, 100); } FinalMatchScreen::~FinalMatchScreen() {} void FinalMatchScreen::update(std::vector<PlayerScore> teamA, std::vector<PlayerScore> teamB) { score.setTeams(teamA, teamB); } void FinalMatchScreen::render() { TeamID winner = fs->getWinnerTeam(); if (winner == myTeam) { this->winner.render(); } else { this->looser.render(); } score.render(); }
4a917c374bd12ac567e033869411247b7d63a93c
1cfc1bf471fac442968051d081878f811d8e9b5f
/QualEye/BloberClass.cpp
4219df89def4a3477179b6889de4ae619e79aeb4
[]
no_license
ess-seb/QualEye
a8418f0b2d053a2fe0783959c9dde731d8c29ad3
bdaca30434946323e336e2366751f8a37d056d0c
refs/heads/master
2016-09-11T08:20:27.318254
2014-09-07T11:09:35
2014-09-07T11:09:35
23,758,008
1
0
null
null
null
null
UTF-8
C++
false
false
4,222
cpp
BloberClass.cpp
#include "StdAfx.h" #include "BloberClass.h" #include <cv.h> #include <cxcore.h> #include <highgui.h> #include <Math.h> #include <string> #include <iostream> #include <blob.h> #include <BlobResult.h> //#include <BlobExtraction.h> #include <BlobLibraryConfiguration.h> static IplImage* image_resized; static IplImage* image2_blobs; CBlobResult blobsResult; double min_blob; double max_blob; CBlob *myBlob; MScale *myBScaler; CBlobGetElongation get_elongation; CBlobGetMinorAxisLength get_minor_axe; CBlobGetBreadth get_breadth; CBlobGetLength get_length; using std::string; BloberClass::BloberClass(double bMinArea, double bMaxArea, MScale* myBScaler_ex) { myBScaler = myBScaler_ex; min_blob = bMinArea; max_blob = bMaxArea; } void BloberClass::configBlober(double bMinArea, double bMaxArea) { min_blob = bMinArea; max_blob = bMaxArea; } void BloberClass::setBlobResult(CBlobResult blobResult_ex) { blobsResult = blobResult_ex; } CBlobResult BloberClass::blobThemAll(IplImage* input_img) { // find blobs in image blobsResult = CBlobResult( input_img, NULL, 255 ); blobsResult.Filter( blobsResult, B_EXCLUDE, CBlobGetArea(), B_LESS, min_blob); blobsResult.Filter( blobsResult, B_EXCLUDE, CBlobGetArea(), B_GREATER, max_blob); return blobsResult; } void BloberClass::showThemAll(IplImage* output_img) { for (int i = 0; i < blobsResult.GetNumBlobs(); i++ ) { myBlob = blobsResult.GetBlob(i); myBlob->FillBlob( output_img, CV_RGB(255,230,0)); } CBlob blobWithMinArea; CBlob blobWithMaxArea; blobsResult.GetNthBlob( CBlobGetArea(), 0, blobWithMaxArea ); blobsResult.GetNthBlob( CBlobGetArea(), blobsResult.GetNumBlobs() - 1, blobWithMinArea ); blobWithMaxArea.FillBlob( output_img, CV_RGB( 255, 0, 0 )); blobWithMinArea.FillBlob( output_img, CV_RGB( 50, 150, 255 )); } void BloberClass::textThemAll(IplImage* output_img) { CvFont* font = new CvFont(); cvInitFont( font, CV_FONT_HERSHEY_PLAIN, 0.6, 0.6, 0, 1, 8 ); CvFont* fontB = new CvFont(); cvInitFont( fontB, CV_FONT_HERSHEY_PLAIN, 1, 1, 0, 1, 8 ); char area_buf[10]; char elong_buf[10]; char breadth_buf[10]; char minorAxe_buf[10]; char lenght_buf[10]; char id_buf[10]; char scale_buf[10]; for (int i = 0; i < blobsResult.GetNumBlobs(); i++ ) { myBlob = blobsResult.GetBlob(i); double area = myBScaler->px2ToReal(myBlob->Area()); double elong = myBScaler->pxToReal(get_elongation(*myBlob)); double minorAxe = myBScaler->pxToReal(get_minor_axe(*myBlob)); double breadth = myBScaler->pxToReal(get_breadth(*myBlob)); double lenght = myBScaler->pxToReal(get_length(*myBlob)); int idb = myBlob->GetID(); _gcvt( area,4, area_buf); _gcvt( elong, 4, elong_buf); _gcvt( breadth, 4, breadth_buf); _gcvt( lenght, 4, lenght_buf); _gcvt( minorAxe, 4, minorAxe_buf); _gcvt( idb, 5, id_buf); _gcvt( myBScaler->getScale(), 5, scale_buf); cvPutText( output_img, ("A:" + string(area_buf)).c_str(), cvPoint(myBlob->MaxX()+4,myBlob->MinY()), font, cvScalar(220,220,0) ); cvPutText( output_img, ("EL:" + string(elong_buf)).c_str(), cvPoint(myBlob->MaxX()+4,myBlob->MinY()+7), font, cvScalar(220,0,0) ); cvPutText( output_img, ("B:" + string(breadth_buf)).c_str(), cvPoint(myBlob->MaxX()+4,myBlob->MinY()+14), font, cvScalar(220,0,220) ); cvPutText( output_img, ("L:" + string(lenght_buf)).c_str(), cvPoint(myBlob->MaxX()+4,myBlob->MinY()+21), font, cvScalar(0,0,220) ); cvPutText( output_img, ("MA:" + string(minorAxe_buf)).c_str(), cvPoint(myBlob->MaxX()+4,myBlob->MinY()+28), font, cvScalar(0,220,220) ); cvPutText( output_img, id_buf, cvPoint(myBlob->MaxX()+4,myBlob->MinY()-7), font, cvScalar(0,0,0) ); cvPutText( output_img, scale_buf, cvPoint(10,10), fontB, cvScalar(130,255,130) ); } CBlob blobWithMinArea; CBlob blobWithMaxArea; blobsResult.GetNthBlob( CBlobGetArea(), 0, blobWithMaxArea ); blobsResult.GetNthBlob( CBlobGetArea(), blobsResult.GetNumBlobs() - 1, blobWithMinArea ); blobWithMaxArea.FillBlob( output_img, CV_RGB( 255, 0, 0 )); blobWithMinArea.FillBlob( output_img, CV_RGB( 50, 150, 255 )); delete font; } CBlobResult BloberClass::getBlobResult() { return blobsResult; } BloberClass::~BloberClass(void) { cvDestroyAllWindows(); }
c722093f8744ab3e7916d2cead9e4a630c6cce6f
04c3023905e3bf1493b1e2310b74c3a5c7fa332c
/structs.h
f2ac3625a61a99e3c5bb868af98fbc778bc5c4d4
[]
no_license
lx9t01/CG5
7310b1e562c8a7baf6ac217597c56652e5208c6f
119a8ce5d2ca5f84dc1d6fb6963bd26db247051f
refs/heads/master
2021-01-10T07:39:15.023945
2015-11-18T04:12:56
2015-11-18T04:12:56
46,394,490
0
0
null
null
null
null
UTF-8
C++
false
false
2,917
h
structs.h
#pragma once #ifndef STRUCTS_H #define STRUCTS_H #include <string> #include <vector> #include <stdio.h> #include <math.h> #include <fstream> #include <iostream> #include <sstream> using namespace std; struct Vec3f { double x, y, z; }; struct Vertex { double x, y, z; Vertex(float x1, float y1, float z1){ x = x1; y = y1; z = z1; } }; struct Face { int idx1, idx2, idx3; Face(int a1, int a2, int a3){ idx1 = a1; idx2 = a2; idx3 = a3; } }; struct Mesh_Data { std::vector<Vertex*> *vertices; std::vector<Face*> *faces; }; #endif struct Point_Light { float position[4]; //xyzw float color[3]; //rgb range? float attenuation_k; }; struct Transforms { float translation[3]; //xyz float rotation[3]; float scaling[3]; float rotation_angle; // angle in deg }; class GraphObj { public: GraphObj(char* s){ v = new vector<Vertex*>(); f = new vector<Face*>(); ifstream objfile(s); string ch; string x, y, z; string str; if (objfile.is_open()) { while (!objfile.eof()) { objfile >> ch >> x >> y >> z; if (ch == "v") { Vertex v1(stof(x), stof(y), stof(z)); v->push_back(&v1); } else if (ch == "f") { Face f1(stoi(x), stoi(y), stoi(z)); f->push_back(&f1); } else cout << "Fail to read obj line"; } f->pop_back(); // one more last line objfile.close(); } else { cout << "File not open.\n"; } } GraphObj(){ v = new vector<Vertex*>(); f = new vector<Face*>(); } // ~GraphObj(){ // for (int i = 0; i < v->size(); i++){ // delete (*v)[i]; // } // delete v; // // for (int j = 0; j < f->size(); j++){ // delete (*f)[j]; // } // delete f; // } string getName(); unsigned int getNumber(); bool setName(string s); bool setNumber(unsigned int n); string getPrintName(); bool setPrintName(string s); int dupMore(); int getDupNumber(); vector<Vertex*> *getVertex(); vector<Face*> *getFace(); bool setVertex(vector<Vertex*> v1); bool setFace(vector<Face*> f1); bool setAmbient(float r, float g,float b); bool setDiffuse(float r, float g, float b); bool setSpecular(float r, float g, float b); bool setShininess(float p); float ambient[3]; float diffuse[3]; float specular[3]; float shininess; vector<Transforms> transform_sets; private: string objname; string printname; unsigned int objnumber; int dupnumber=0; vector<Vertex*> *v; vector<Face*> *f; };
cf68c0e1958a8c090e989e637f7c83ccc08844ea
84caa80560aade813c5a53846461bc1ea2e95fb9
/Proj4/main.cpp
cad52dfa088217252e9252396003fa85db424299
[]
no_license
hennoz/FYS3150Project4
5c163b91ca05da53b77e4512eca968eeabad8635
e0af43c35d814c960d7341ba7077806435015288
refs/heads/master
2020-04-04T10:35:58.769716
2018-11-20T07:19:08
2018-11-20T07:19:08
154,859,463
0
0
null
null
null
null
UTF-8
C++
false
false
6,590
cpp
main.cpp
#include <iostream> #include <random> #include <fstream> #include <iomanip> #include "analytical.h" #include "metropolissampling.h" #include <mpi.h> #include <chrono> using namespace std; ofstream outfile; void output( int dim, double T, double *ExpectVal, int MCcycles, double timing ); int main( int argc, char *argv[] ) { for ( int i = 80; i <= 80; i += 20 ) { // Loop thru main for L=40,60,80,100 double *ExpectVal = new double[5]; // Should contain E,E^2,M,M^2,|M| double *TotalExpectVal = new double[5]; for( int i = 0; i < 5; i++ ) TotalExpectVal[i] = 0; //------------------------------------------------------------------------- // Project 4c) string filename; int ordered = 0; // Choose 1 for ordered matrix, choose 0 for random matrix int dim = 140; // Dimension of the matrix L int MCcycles = 100000; //1e6 // double InitialTemp = 2.0; //2.260 // double FinalTemp = 2.6; // 2.278 double InitialTemp = 2.260; // For mill cycles double FinalTemp = 2.278; double TimeStep = 0.001; double timing; chrono::high_resolution_clock::time_point t1; chrono::high_resolution_clock::time_point t2; // Initialize parallellization with MPI int nProcs; // Number of processes int my_rank; // Rank MPI_Init (&argc, &argv); MPI_Comm_size ( MPI_COMM_WORLD, &nProcs ); MPI_Comm_rank ( MPI_COMM_WORLD, &my_rank ); // Broadcast dim, InitialTemp, FinalTemp and TimeStep to all processes MPI_Bcast (&dim, 1, MPI_INT, 0, MPI_COMM_WORLD); MPI_Bcast (&InitialTemp, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Bcast (&FinalTemp, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); MPI_Bcast (&TimeStep, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD); int cycleInterval = MCcycles/nProcs; int loopStart = my_rank*cycleInterval; int loopStop = (my_rank+1)*cycleInterval; // Write to file first line to make easy to read for humans if ( my_rank == 0 ) { outfile.open("/Users/hennoz/FYS3150Project4/CRAP_4e_Dim" + to_string(dim) + "_cycles" + to_string(MCcycles) + ".txt", std::ios_base::app); // outfile.open("Lattice" + to_string(dim) + "Cycles" + to_string(MCcycles) + ".txt"); // outfile.open("4b" + to_string(dim) + ".txt", std::ios_base::app); outfile << setw(15) << setprecision(8) << "T"; outfile << setw(15) << setprecision(8) << "E"; outfile << setw(15) << setprecision(8) << "E2"; outfile << setw(15) << setprecision(8) << "M"; outfile << setw(15) << setprecision(8) << "M2"; outfile << setw(15) << setprecision(8) << "M abs"; outfile << setw(15) << setprecision(8) << "chi"; outfile << setw(15) << setprecision(8) << "C_V"; outfile << setw(15) << setprecision(8) << "Runtime"; outfile << setw(15) << setprecision(8) << "#cycles" << endl; } for ( double T = InitialTemp; T <= FinalTemp; T += TimeStep) { double acceptRatio = 0; // Reset if (my_rank==0) t1 = chrono::high_resolution_clock::now(); MetropolisSampling( dim, MCcycles, loopStart, loopStop, T, ExpectVal, ordered, acceptRatio ); for ( int i = 0; i < 5; i++ ) { MPI_Reduce(&ExpectVal[i], &TotalExpectVal[i], 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD); } if (my_rank==0) { t2 = chrono::high_resolution_clock::now(); chrono::duration<double> time_span = std::chrono::duration_cast<chrono::duration<double>>(t2 - t1); timing = time_span.count(); output( dim, T, TotalExpectVal, MCcycles, timing ); } // ofstream outfile; // outfile.open("/Users/hennoz/FYS3150Project4/acceptsRatioVsT.txt", std::ios_base::app); // outfile << setw(15) << setprecision(8) << T; // outfile << setw(15) << setprecision(8) << acceptRatio << endl; // outfile.close(); } outfile.close(); //------------------------------------------------------------------------ // //------------------------------------------------------------------------ // // PROJECT 4b) // int dim = 2; // // To get money results, 1e7 MCcycles is needed // int MCcycles = 1e6; // double T = 1.0; // MetropolisSampling ( dim, MCcycles, 1, MCcycles, T, ExpectVal, 1 ); // cout << endl; // cout << "<E> (analytic) = " << E_()/(dim*dim) << endl; // cout << "|M| (analytic) = " << absM()/(dim*dim) << endl; // cout << "Heat capacity (analytic) = " << CV()/( dim*dim ) << endl; // cout << "Susceptibility (analytic) = " << xhi()/( dim*dim ) << endl; // //-------------------------------------------------------------------------- delete [] ExpectVal; delete [] TotalExpectVal; } MPI_Finalize (); return 0; } void output( int dim, double T, double *ExpectVal, int MCcycles, double timing ) { for( int i = 0; i < 5; i++ ) ExpectVal[i] /= MCcycles; double E_variance = (ExpectVal[1] - ExpectVal[0]*ExpectVal[0])/dim/dim; // double M_variance = (ExpectVal[3] - ExpectVal[2]*ExpectVal[2])/dim/dim; double M_variance = (ExpectVal[3] - ExpectVal[4]*ExpectVal[4])/dim/dim; // Use |M| for calc. chi // cout << "E_variance " << E_variance << endl; // cout << "T = " << T << " done...\n"; outfile << setw(15) << setprecision(8) << T; // Temp outfile << setw(15) << setprecision(8) << ExpectVal[0]/dim/dim; // <E> outfile << setw(15) << setprecision(8) << ExpectVal[1]/dim/dim; // <E^2> outfile << setw(15) << setprecision(8) << ExpectVal[2]/dim/dim; // <M> outfile << setw(15) << setprecision(8) << ExpectVal[3]/dim/dim; // <M^2> = |M|^2 outfile << setw(15) << setprecision(8) << ExpectVal[4]/dim/dim; // |M| outfile << setw(15) << setprecision(8) << M_variance/T; // chi outfile << setw(15) << setprecision(8) << E_variance/(T*T); // C_V outfile << setw(15) << setprecision(8) << timing; // RunTime outfile << setw(15) << setprecision(8) << MCcycles << endl; // # MCcycles }
b64c2867a91d3d4650f9873cd529a3b32d54c860
c686516041c5489c7a49911715effe2224334bf4
/WD_Alg/5th/5_3_3_12.cpp
b43529054d94cc47ccf4d0164434d05844b453de
[]
no_license
ccccqyc/Books
58326ba6b94c719e0bf94ee985b9a756001cae3e
77b131a1ba4bcb40fdb47cbcfdeae91d94c270dd
refs/heads/master
2023-06-26T09:44:58.931630
2021-08-01T07:26:43
2021-08-01T07:26:43
297,269,258
0
0
null
null
null
null
UTF-8
C++
false
false
844
cpp
5_3_3_12.cpp
// 第五章 树与二叉树 // 5.3.3 二 12 // 打印值为x结点祖先 #include <malloc.h> #include <cstdio> typedef int ElemType; // 二叉树 typedef struct BitNode { ElemType data; BitNode *lchild, *rchild; } BitNode, *BitTree; // 思路后续遍历,查询到x值的结点,终止遍历,输出队列中祖先 void search(BitTree T, ElemType x) { Queue Q; initQueue(Q); //初始化遍历队列. BitNode *p = T; if (T == NULL) return; if (isEmpty(Q) || p != NULL) { while (p != NULL && p->data != x) { EnQueue(Q, p); p = p->lchild; } //找到结点 if (p->data == x && !isEmpty(Q)) { do { DeQueue(Q, p); //出队 printf("%d", p->data); } while (!isEmpty(Q)); exit(1); } } }
9cfff6c591ef3e6bb1e054bceee38399eadd7d2b
84257c31661e43bc54de8ea33128cd4967ecf08f
/ppc_85xx/usr/include/c++/4.2.2/gnu/javax/security/auth/login/ConfigFileParser.h
c8f707479b01ccbf2f98b5385eaffbc1dc2dace6
[]
no_license
nateurope/eldk
9c334a64d1231364980cbd7bd021d269d7058240
8895f914d192b83ab204ca9e62b61c3ce30bb212
refs/heads/master
2022-11-15T01:29:01.991476
2020-07-10T14:31:34
2020-07-10T14:31:34
278,655,691
0
0
null
null
null
null
UTF-8
C++
false
false
1,385
h
ConfigFileParser.h
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*- #ifndef __gnu_javax_security_auth_login_ConfigFileParser__ #define __gnu_javax_security_auth_login_ConfigFileParser__ #pragma interface #include <java/lang/Object.h> extern "Java" { namespace gnu { namespace javax { namespace security { namespace auth { namespace login { class ConfigFileParser; class ConfigFileTokenizer; } } } } } } class gnu::javax::security::auth::login::ConfigFileParser : public ::java::lang::Object { public: virtual ::java::util::Map *getLoginModulesMap () { return map; } virtual void parse (::java::io::Reader *); private: void initParser (::java::io::Reader *); jboolean parseAppOrOtherEntry (); jboolean parseACE (::java::util::List *); void abort (::java::lang::String *); ::java::lang::String *validateClassName (::java::lang::String *); ::java::lang::String *expandParamValue (::java::lang::String *); public: ConfigFileParser (); private: static ::java::util::logging::Logger *log; ::gnu::javax::security::auth::login::ConfigFileTokenizer * __attribute__((aligned(__alignof__( ::java::lang::Object )))) cft; ::java::util::Map *map; public: static ::java::lang::Class class$; }; #endif /* __gnu_javax_security_auth_login_ConfigFileParser__ */
1bac148aee01d804f3db8a58122649eef2d73466
b0b024d8d68593d622aa4f3b2a4af20045207818
/C++/Append_Last_Kth_Node(LinkList).cpp
5bf90ed7343b0a233bd0d08991d96b07297771fe
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Anshuman212/HacktoberFest2021
41c7529faa1640ec319103cc72a2264c1d65d9ed
9dba6d7492a171298acfcf59ed4599bb5095a48c
refs/heads/main
2023-08-13T12:45:04.009408
2021-10-13T05:32:29
2021-10-13T05:32:29
415,319,296
0
1
MIT
2021-10-09T13:37:55
2021-10-09T13:37:55
null
UTF-8
C++
false
false
2,046
cpp
Append_Last_Kth_Node(LinkList).cpp
#include<iostream> using namespace std; class node{ public: int data; node* next; node(int val){ data=val; next=NULL; } }; void insertAtTail(node* &head,int val){ //insert node at the tail of linklist node* n=new node(val); // make a new node to data is insert if (head==NULL) // condition wif linklist is empty { head=n; return; } node* temp=head; // make a pointer temp which is point head for traversing the linkedlist while (temp->next!=NULL) { temp=temp->next; } temp->next=n; } int lenght(node* head) { node* temp=head; int l=0; while (temp!=NULL) { l++; temp=temp->next; } return l; } node* append(node* &head,int k) { node* newtail; node* newhead; node* tail=head; int l=lenght(head); //k=k%l; int count=1; while (tail->next!=NULL) { if (count==l-k) { newtail=tail; } if (count==l-k+1) { newhead=tail; } tail=tail->next; count++; } newtail->next=NULL; tail->next=head; return newhead; } void display(node* head) // display function { node* temp=head; while (temp!=NULL) { cout<<temp->data<<" -> "; temp=temp->next; } cout<<"NULL"<<endl; } int main() { node* head=NULL; //-------------------------------------------------------this is user defiend--------- // int arr[]={1,2,3,4,5,6}; // for (int i = 0; i < 6; i++) // { // insertAtTail(head,arr[i]); // } // display(head); // node* newnode=append(head,3); // display(newnode); insertAtTail(head,1); insertAtTail(head,2); insertAtTail(head,3); insertAtTail(head,4); insertAtTail(head,5); display(head); node* newhead=append(head,2); display(newhead); return 0; }
4af86227a146d631081a5ad54c23859ba3869c7b
c0b471f8cfd32f02cbcaa0db86afc8075d3ea95b
/OneMoreTalk_Client/friendlistitem.h
1e3a2a79dc084a6c0c364102cb7806bcf6c4e2d0
[ "MIT" ]
permissive
xqyzjl/OneMoreTalk
83889710c1f607b83162e3ae0da7562ce80dc039
aa7209357f87d7f314eace86faba21a5fd161082
refs/heads/main
2023-07-29T11:25:13.004867
2021-09-04T13:56:11
2021-09-04T13:56:11
403,068,431
0
0
null
null
null
null
UTF-8
C++
false
false
621
h
friendlistitem.h
#ifndef FRIENDLISTITEM_H #define FRIENDLISTITEM_H #include <QWidget> #include <QLabel> #include <QDebug> #include <QListWidgetItem> class FriendListItem : public QWidget { Q_OBJECT public: explicit FriendListItem(QWidget *parent = nullptr); void setID(int id); void setDot(bool); void setSign(QString); QPixmap getIcon() const {return *(icon->pixmap());} QString getName() const {return name->text();} QString getSign() const {return sign->text();} int id,pos; private: QLabel *icon,*name,*sign,*dot; private slots: void slot_PinfoChanged(); }; #endif // FRIENDLISTITEM_H