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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ae61bd1ee18c6c0afb8b3ca2f6c8c4522ec26c36
|
7c1a2f169fe4a88b72baac39301afeb51a455857
|
/bin/deltam_cr.hpp
|
89e80e36cf3cf1f91622caa144f1ea7580500fc4
|
[] |
no_license
|
matteo-dc/riqed
|
8b34317f6c6a601cc13468e77b43ee50ceaba617
|
31eba54c173e17a23ecd2cde9a65e35c3daeaea4
|
refs/heads/master
| 2022-12-29T17:29:55.042226
| 2018-05-02T16:19:44
| 2018-05-02T16:19:44
| 92,728,300
| 0
| 1
| null | 2018-02-05T13:41:23
| 2017-05-29T10:10:16
|
C++
|
UTF-8
|
C++
| false
| false
| 52
|
hpp
|
deltam_cr.hpp
|
#ifndef DELTAM_CR_HPP
#define DELTAM_CR_HPP
#endif
|
f151e7071f60763d84f75d817fa784d93e92cc4e
|
dc2656823dcdf9df818402b1e539ea7741663a14
|
/2_两数相加.cpp
|
2dbc0395c922930a6a3b271a673889bf77efd4a0
|
[] |
no_license
|
Husaimawx/MyLeetcode
|
e1dab1191516188a204e9b7868cd129a0b1b4112
|
eeb6dc934ad2b76b1aca79b43b9da494126c2aca
|
refs/heads/main
| 2023-07-29T00:13:14.419480
| 2021-09-19T05:54:34
| 2021-09-19T05:54:34
| 408,043,526
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,687
|
cpp
|
2_两数相加.cpp
|
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
//Definition for singly-linked list.
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
string* stdin_to_string(){
string stdin;
getline(cin,stdin);
//cout << "stdin: " << stdin << " size: " << stdin.size() << endl;
int pos = stdin.find('+');
// cout << pos << endl;
string str1 = stdin.substr(1, pos-3);
string str2 = stdin.substr(pos+3, stdin.size()-pos-4);
// cout << str1 << " size: " << str1.size() << endl;
// cout << str2 << " size: " << str1.size() << endl;
string* strs = new string[2];
strs[0] = str1;
strs[1] = str2;
return strs;
}
ListNode* string_to_list(string str){
ListNode *head;
head = new ListNode(-1);
ListNode* p;
p = head;
for (int i = 0; i < str.length(); i++)
{
//cout << i << ":" << endl;
if (str[i] < '0' || str[i] > '9'){
i += 3;
//cout << "jump " << endl;
}
else {
//cout << "catch " << str[i] << endl;
p->next = new ListNode((int)(str[i])-(int)('0'));
p = p->next;
}
}
return head;
}
void list_to_stdout(ListNode* list){
ListNode* p;
p = list;
while(p){
cout << p->val;
if(p->next){
cout << " -> ";
p = p->next;
}
else break;
}
}
void showList(ListNode* listnode){
ListNode* p;
p = listnode;
//cout << " show " << endl;
while(p){
cout << p->val << endl;
if(p->next)p = p->next;
else break;
}
}
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
ListNode* ans = new ListNode(-1);
int bit = 0;
int overflow = 0;
ListNode* p1 = l1->next;
ListNode* p2 = l2->next;
ListNode* pans = ans;
while(p1&&p2){
//cout << " sub " << p1->val << " " << p2->val << endl;
bit = p1->val + p2->val + overflow;
if (bit > 9) {
overflow = 1;
bit = bit - 10;
}
else {
overflow = 0;
}
//cout << " bit " << bit << endl;
pans -> next = new ListNode(bit);
pans = pans -> next;
p1 = p1->next;
p2 = p2->next;
}
while (p1){
bit = p1->val + overflow;
if (bit > 9) {
overflow = 1;
bit = bit - 10;
}
else {
overflow = 0;
}
pans -> next = new ListNode(bit);
pans = pans -> next;
p1 = p1->next;
}
while (p2){
bit = p2->val + overflow;
if (bit > 9) {
overflow = 1;
bit = bit - 10;
}
else {
overflow = 0;
}
pans -> next = new ListNode(bit);
pans = pans -> next;
p2 = p2->next;
}
if (!p1&&!p2&&overflow)
{
pans -> next = new ListNode(overflow);
pans = pans -> next;
}
return ans -> next;
}
};
int main(){
Solution s;
string* strs = s.stdin_to_string();
s.list_to_stdout(s.addTwoNumbers(s.string_to_list(strs[0]),s.string_to_list(strs[1])));
return 0;
}
|
e064b5757889d8e5d690f59ab83aa733d81f0014
|
701627009d06bf746544b48ed6ab1e1877e3cce7
|
/Circuit/main.cpp
|
f46ba786c5d1fff26ecb36b599cbd70ba5377a55
|
[] |
no_license
|
d-robbins/CircuitSimulator
|
1902dad9f0da4f6f43d4b33125d25b270b34bcab
|
bc601f5925c98b8d4addd3fc04f26f8b14d66da1
|
refs/heads/main
| 2023-04-23T19:08:53.457200
| 2021-05-05T17:42:55
| 2021-05-05T17:42:55
| 359,702,736
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,739
|
cpp
|
main.cpp
|
#include <iostream>
#include <SFML/Graphics.hpp>
#include "Board.h"
#include "Component.h"
#include "Wire.h"
#include "Menu.h"
int main()
{
std::cout << sizeof(double) << std::endl;
sf::View view(sf::FloatRect(0, 0, 1280, 720));
sf::RenderWindow window(sf::VideoMode(1280, 720), "Circuit Sim");
window.setFramerateLimit(60);
window.setView(view);
const auto white = sf::Color(255, 255, 255, 255);
auto board = std::make_shared<CBoard>();
auto menu = std::make_shared<CMenu>(board.get());
bool toggle = false;
bool powerToggle = false;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else if (event.type == sf::Event::MouseButtonPressed)
{
sf::Vector2i p = sf::Mouse::getPosition(window);
board->OnClick(sf::Vector2f((float)p.x, (float)p.y));
menu->OnClick(sf::Vector2f((float)p.x, (float)p.y));
}
else if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::P)
{
board->WireMode(!toggle);
}
else if (event.key.code == sf::Keyboard::G)
{
board->PowerToggle(!powerToggle);
}
else if (event.key.code == sf::Keyboard::Escape)
{
window.close();
}
}
}
window.clear(white);
board->Render(window, event);
menu->Render(window);
window.display();
}
return 0;
}
|
59f40ed9c1dd072e21c81809c7fc747efae0c7d0
|
230764d82733fac64c3e0eae1ce0a4030965dc4a
|
/aistreams/util/file_helpers.h
|
d7e70557f9bbbb325069cbcd864f4049cb9b1c1d
|
[
"Apache-2.0"
] |
permissive
|
isabella232/aistreams
|
478f6ae94189aecdfd9a9cc19742bcb4b4e20bcc
|
209f4385425405676a581a749bb915e257dbc1c1
|
refs/heads/master
| 2023-03-06T14:49:27.864415
| 2020-09-25T19:48:04
| 2020-09-25T19:48:04
| 298,772,653
| 0
| 0
|
Apache-2.0
| 2021-02-23T10:11:29
| 2020-09-26T08:40:34
| null |
UTF-8
|
C++
| false
| false
| 1,319
|
h
|
file_helpers.h
|
/*
* Copyright 2020 Google LLC
*
* 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.
*/
#ifndef AISTREAMS_UTIL_FILE_HELPERS_H_
#define AISTREAMS_UTIL_FILE_HELPERS_H_
#include "absl/strings/match.h"
#include "aistreams/port/status.h"
namespace aistreams {
namespace file {
// Reads the contents of the file `file_name` into `output`.
//
// REQUIRES: `output` is non-null.
Status GetContents(absl::string_view file_name, std::string* output);
// Writes the data provided in `content` to the file `file_name`. It overwrites
// any existing content.
Status SetContents(absl::string_view file_name, absl::string_view content);
// Decides if the named path `file_name` exists.
Status Exists(absl::string_view file_name);
} // namespace file
} // namespace aistreams
#endif // AISTREAMS_UTIL_FILE_HELPERS_H_
|
9d4891fe5868fea954b6b726c8da9c89809db2d9
|
2bb0725d62e75bfb901005610b8ee40fd0d9f40f
|
/OBI/2003/Elastico/elastico.cpp
|
a925359527301d47791143e87c4525f6c021ada9
|
[] |
no_license
|
geraldolsribeiro/contests
|
623965ede4536ef9654866a1b991c8abf10369f0
|
5c41e07c1e54a48b15ab1816190ac571c8a35593
|
refs/heads/master
| 2021-01-21T21:05:13.464323
| 2017-03-09T18:35:18
| 2017-03-09T18:35:18
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,471
|
cpp
|
elastico.cpp
|
/*****************************
* Elastico - Seletiva IOI 2003
*
* Autor: Vinicius J. S. Souza
* Data: 21/07/2010
* Tecnicas: programacao dinamica + geometria computacional
* Dificuldade: 7
*******************************/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
struct point {
double x, y;
point(double x = 0, double y = 0): x(x), y(y) {}
/* produto vetorial */
double operator %(point q) { return x * q.y - y * q.x; }
};
int N, dp[205][205];
point pontos[205];
bool fcmp(const point &a, const point &b) {
float v = atan2(a.y, a.x) - atan2(b.y, b.x);
return v <= 0;
}
bool antiHorario(point &base, point &a, point &b) {
point vetorA = point(a.x - base.x, a.y - base.y);
point vetorB = point(b.x - base.x, b.y - base.y);
return (vetorA % vetorB) > 0.0;
}
int main() {
int tcase = 1;
while(true) {
scanf("%d", &N);
if (!N)
break;
for (int i = 1; i <= N; i++) {
scanf("%d %d", &pontos[i].x, &pontos[i].y);
}
sort(pontos+1, pontos+N+1, fcmp);
pontos[0].x = pontos[0].y = 0;
int maxv = 1;
for (int i = 1; i <= N; i++) {
dp[i][0] = 1;
for (int j = 1; j < i; j++) {
dp[i][j] = 0;
for (int k = 0; k < j; k++) {
if (dp[j][k] > dp[i][j] && antiHorario(pontos[i], pontos[k], pontos[j]))
dp[i][j] = dp[j][k];
}
dp[i][j]++;
if (dp[i][j] > maxv)
maxv = dp[i][j];
}
}
printf("Teste %d\n%d\n\n", tcase++, maxv+1);
}
return 0;
}
|
39a476398c5a2457c3869d96912d9b6d452db180
|
877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a
|
/app/src/main/cpp/dir7941/dir7942/dir8062/dir8063/dir12766/dir12767/dir13029/dir15097/dir15260/dir15321/dir15524/dir15932/dir16377/file16432.cpp
|
4270c4023e4323965d2b3b63856729c23c3c8c20
|
[] |
no_license
|
tgeng/HugeProject
|
829c3bdfb7cbaf57727c41263212d4a67e3eb93d
|
4488d3b765e8827636ce5e878baacdf388710ef2
|
refs/heads/master
| 2022-08-21T16:58:54.161627
| 2020-05-28T01:54:03
| 2020-05-28T01:54:03
| 267,468,475
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 115
|
cpp
|
file16432.cpp
|
#ifndef file16432
#error "macro file16432 must be defined"
#endif
static const char* file16432String = "file16432";
|
d24bc5978acd74d1fa1eb2d73f9e60585474350d
|
fb360e279486848df52bbc0b50952f1e102fcd4d
|
/src/core/fuckmake.h
|
60924deec0742186b6af991aecbdea0c1c8c34b6
|
[
"MIT"
] |
permissive
|
JeppeSRC/FuckMake
|
70e586e2ac8187e56da7575ae83b143b880bac4b
|
5d31a48353cc1744cd5dff4fd99f857ceb195890
|
refs/heads/master
| 2022-05-28T00:38:10.214563
| 2022-05-22T08:04:45
| 2022-05-22T08:20:10
| 196,611,082
| 8
| 1
|
MIT
| 2021-03-18T17:06:27
| 2019-07-12T16:26:42
|
C++
|
UTF-8
|
C++
| false
| false
| 1,706
|
h
|
fuckmake.h
|
#pragma once
#include <util/list.h>
#include <util/string.h>
#include <omp.h>
struct Variable {
String name;
String value;
};
struct Action {
String name;
List<String> actions;
};
struct Target {
String name;
List<String> targets;
};
class FuckMake {
private:
List<Variable> variables;
List<Action> actions;
List<Target> targets;
private:
void Parse(String& string);
void ParseVariables(String& string);
void ParseActions(String& string);
void ParseTargets(String& string);
void ProcessVariables(String& string);
void ProcessFunctions(String& string);
void ProcessInputOuput(String& string, const String& input, const String& output);
void ProcessTarget(const Target* target);
bool CheckWildcardPattern(const String& source, const String& pattern);
void ProcessGetFiles(String& string);
void ProcessDeleteFiles(String& string);
void ProcessMsg(String& string);
void ProcessExecuteList(String& string);
void ProcessExecute(String& string);
void ProcessExecuteTarget(String& string);
void ProcessCall(String& string);
uint64 FindMatchingParenthesis(const String& string, uint64 start);
List<String> SplitArgumentList(const String& string);
void InitializeBuiltinVaraibles();
Variable* GetVariable(const String& name);
Action* GetAction(const String& name);
Target* GetTarget(const String& name);
String rootDir;
bool rootSet;
public:
static bool PrintDebugMessages;
static omp_lock_t msgMutex;
static String DefaultTargetName;
public:
FuckMake(const String& rootDir, const String& filename);
void Run(const String& target);
static void InitLock();
static void DestroyLock();
};
|
c30d48f52055c8c41a41679738a58fea4a48eab8
|
3c085d2e66d7b6e54a41bebfef42cd7185414e05
|
/RevisingQuadEquaHB.cpp
|
c9703cebb0366a3e80ce99f6b64972ad4515e7e4
|
[] |
no_license
|
Vortez2471/Coding-Blocks-Launchpad-II
|
2424ef41490c400960da2d6c66f10915e779f486
|
c7dd4f25de79f5a9fd9fec1e290f50bc824dec05
|
refs/heads/master
| 2020-07-04T20:13:11.315843
| 2019-08-14T18:07:31
| 2019-08-14T18:07:31
| 202,401,101
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 410
|
cpp
|
RevisingQuadEquaHB.cpp
|
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long
void quad(ll a,ll b,ll c)
{
ll sum=b*b-4*a*c;
if(sum<0)
cout<<"Imaginary";
if(sum==0)
cout<<"Real and Equal\n"<<(-b/(2*a))<<" "<<(-b/(2*a));
else
cout<<"Real and Distinct\n"<<((-b-sqrt(sum))/(2*a))<<" "<<((-b+sqrt(sum))/(2*a));
}
int main()
{
ll a,b,c;
cin>>a>>b>>c;
quad(a,b,c);
return 0;
}
|
fe86bdfb867d100bbb788f9f81c6e944d6bc0a9e
|
fede625fdba4acf6c09c97d1a8a1f4f083818f81
|
/source/util.cpp
|
8e012d66004a72da5e95f150a8ac6e2a917d1d37
|
[] |
no_license
|
Stary2001/upd8er
|
c9ea4a62b8f8c1862f666e8faf7107e6e51c0860
|
b7adf7da2473189364b84b9ae61f0e875565c3a9
|
refs/heads/master
| 2021-01-21T15:27:56.915976
| 2017-06-23T15:00:58
| 2017-06-23T15:00:58
| 91,847,296
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,644
|
cpp
|
util.cpp
|
#include <fstream>
#include <3ds.h>
#include <stdlib.h>
#include <string.h>
#include "util.h"
Result util::file_sha256(std::string file, u8 *hash)
{
Result res;
std::ifstream f(file.c_str(), std::ios::in | std::ios::binary);
f.seekg(0, std::ios::end);
size_t file_sz = f.tellg();
f.seekg(0, std::ios::beg);
u8 *buff = (u8*)malloc(file_sz);
memset(hash, 0, 0x20);
f.read((char*)buff, file_sz);
res = sha256(buff, file_sz, hash);
free(buff);
f.close();
return res;
}
Result util::sha256(u8 *buffer, size_t len, u8 *hash)
{
return FSUSER_UpdateSha256Context(buffer, len, hash);
}
std::string util::read_file(std::string file)
{
std::ifstream f(file.c_str(), std::ios::in | std::ios::binary);
f.seekg(0, std::ios::end);
size_t file_sz = f.tellg();
f.seekg(0, std::ios::beg);
std::string s;
s.resize(file_sz);
f.read((char*)s.data(), file_sz);
f.close();
return s;
}
void util::read_file_buffer(std::string file, u8*& buff, size_t &len)
{
std::ifstream f(file.c_str(), std::ios::in | std::ios::binary);
f.seekg(0, std::ios::end);
size_t file_sz = f.tellg();
f.seekg(0, std::ios::beg);
buff = (u8*)malloc(file_sz);
len = file_sz;
f.read((char*)buff, file_sz);
f.close();
}
void util::write_file(std::string file, std::string content)
{
util::write_file_buffer(file, (u8*)content.data(), content.length());
}
void util::write_file_buffer(std::string file, u8* buff, size_t len)
{
std::ofstream f(file.c_str(), std::ios::out | std::ios::binary);
f.write((char*)buff, len);
f.close();
}
bool util::file_exists(std::string file)
{
std::ifstream f(file.c_str(), std::ios::in | std::ios::binary);
if(f.good())
{
f.close();
return true;
}
return false;
}
size_t util::align_up(size_t in, size_t align)
{
if(in % align == 0) return in;
return in + (align - (in % align));
}
u64 util::bswap64(u64 in)
{
u64 out = 0;
char in_b[8];
memcpy(in_b, &in, 8);
for(int i = 0; i < 8; i++)
{
out |= ((u64)in_b[i]) << (8-i)*8;
}
return out;
}
void util::to_hex(std::string &s, u8 *buff, size_t len)
{
s = "";
const char *chars = "0123456789abcdef";
for(int i = 0; i < len; i++)
{
s += chars[(buff[i] & 0xf0) >> 4];
s += chars[buff[i] & 0xf];
}
}
void util::from_hex(u8 *buff, size_t len, std::string &s)
{
for(int i = 0; i < len; i++)
{
char c = s[i*2];
if(c >= '0' && c <= '9') { buff[i] = (c - '0') << 4; }
else if(c >= 'a' && c <= 'f') { buff[i] = 0xa + (c - 'a') << 4; }
c = s[(i*2) + 1];
if(c >= '0' && c <= '9') { buff[i] |= (c - '0'); }
else if(c >= 'a' && c <= 'f') { buff[i] |= 0xa + (c - 'a'); }
}
}
std::string util::get_tmp_dir()
{
return "/upd8er/tmp";
}
|
25f96dcea248e382f6bf6c4ce7521f059879e584
|
b0eb5f8c2656afa1a77e3dfb407d03025a9c1d84
|
/D3D11/DisplacementMapping/Main/DisplacementMappingApp.cpp
|
f083e862f899d151d4917783d932ca3207bed357
|
[] |
no_license
|
mandragorn66/dx11
|
ee1126d6487dfe0dac1c1d3aa945f39510a446f5
|
7807a73bd58011e1fc43dc3a4404ed4e9027bc39
|
refs/heads/master
| 2021-01-13T02:03:14.816972
| 2014-05-31T20:58:16
| 2014-05-31T20:58:16
| 35,515,523
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 16,816
|
cpp
|
DisplacementMappingApp.cpp
|
#include "DisplacementMappingApp.h"
#include <DirectXColors.h>
#include <DirectXMath.h>
#include <DxErrorChecker.h>
#include <GeometryGenerator.h>
#include <MathHelper.h>
namespace
{
const float gMinTessellationFactor = 0.0001f;
const float gMaxTessellationFactor = 5.0f;
const float gTessellationOffset = 0.0025f;
}
namespace Framework
{
void DisplacementMappingApp::updateScene(const float dt)
{
//
// Control the camera.
//
if (GetAsyncKeyState('W') & 0x8000)
CameraUtils::walk(50.0f * dt, mCamera);
if (GetAsyncKeyState('S') & 0x8000)
CameraUtils::walk(-50.0f * dt, mCamera);
if (GetAsyncKeyState('A') & 0x8000)
CameraUtils::strafe(-50.0f * dt, mCamera);
if (GetAsyncKeyState('D') & 0x8000)
CameraUtils::strafe(50.0f * dt, mCamera);
if (GetAsyncKeyState('G') & 0x8000)
mTesselationFactor = (gMaxTessellationFactor < mTesselationFactor + gTessellationOffset) ? gMaxTessellationFactor : mTesselationFactor + gTessellationOffset;
if (GetAsyncKeyState('H') & 0x8000)
mTesselationFactor = (mTesselationFactor - gTessellationOffset < gMinTessellationFactor) ? gMinTessellationFactor : mTesselationFactor - gTessellationOffset;
/*if (GetAsyncKeyState('F') & 0x8000)
mTesselationFactor = 8.0f;
if (GetAsyncKeyState('G') & 0x8000)
mTesselationFactor = 16.0f;
if (GetAsyncKeyState('H') & 0x8000)
mTesselationFactor = 32.0f;
if (GetAsyncKeyState('J') & 0x8000)
mTesselationFactor = 64.0f;*/
if (GetAsyncKeyState('T') & 0x8000)
mWireframeMode = true;
if (GetAsyncKeyState('Y') & 0x8000)
mWireframeMode = false;
mRotationAmmount += 0.25f * dt;
}
void DisplacementMappingApp::drawScene()
{
// Update states
mImmediateContext->ClearRenderTargetView(mRenderTargetView, reinterpret_cast<const float*>(&DirectX::Colors::Black));
mImmediateContext->ClearDepthStencilView(mDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
CameraUtils::updateViewMatrix(mCamera);
setShapesGeneralSettings();
//drawFloor();
drawCylinder();
//drawSphere();
//drawBox();
// Present results
const HRESULT result = mSwapChain->Present(0, 0);
DxErrorChecker(result);
}
void DisplacementMappingApp::onMouseMove(WPARAM btnState, const int32_t x, const int32_t y)
{
if ((btnState & MK_LBUTTON) != 0)
{
// Make each pixel correspond to a quarter of a degree.
const float dx = DirectX::XMConvertToRadians(0.15f * static_cast<float>(x - mLastMousePos.x));
const float dy = DirectX::XMConvertToRadians(0.15f * static_cast<float>(y - mLastMousePos.y));
CameraUtils::pitch(dy, mCamera);
CameraUtils::rotateAboutYAxis(dx, mCamera);
}
mLastMousePos.x = x;
mLastMousePos.y = y;
}
void DisplacementMappingApp::setShapesGeneralSettings()
{
ID3D11VertexShader* vertexShader = Managers::ShadersManager::mShapesVS;
ID3D11PixelShader* pixelShader = Managers::ShadersManager::mShapesPS;
ID3D11HullShader* hullShader = Managers::ShadersManager::mShapesHS;
ID3D11DomainShader* domainShader = Managers::ShadersManager::mShapesDS;
ID3D11InputLayout* inputLayout = Managers::ShadersManager::mShapesIL;
// Set input layout, primitive topology and rasterizer state
mImmediateContext->IASetInputLayout(inputLayout);
mImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_3_CONTROL_POINT_PATCHLIST);
//mImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
mImmediateContext->RSSetState(mWireframeMode ? Managers::PipelineStatesManager::mWireframeRS : nullptr);
//
// Update constant buffers
//
mShapesHSPerFrameBuffer.mData.mTessellationFactor = mTesselationFactor;
ConstantBufferUtils::copyData(*mImmediateContext, mShapesHSPerFrameBuffer);
const DirectX::XMMATRIX viewProjection = CameraUtils::computeViewProjectionMatrix(mCamera);
DirectX::XMStoreFloat4x4(&mShapesDSPerFrameBuffer.mData.mViewProjection, DirectX::XMMatrixTranspose(viewProjection));
mShapesDSPerFrameBuffer.mData.mEyePositionW = mCamera.mPosition;
ConstantBufferUtils::copyData(*mImmediateContext, mShapesDSPerFrameBuffer);
memcpy(&mShapesPSPerFrameBuffer.mData.mDirectionalLight, &mDirectionalLight, sizeof(mDirectionalLight));
mShapesPSPerFrameBuffer.mData.mEyePositionW = mCamera.mPosition;
ConstantBufferUtils::copyData(*mImmediateContext, mShapesPSPerFrameBuffer);
mShapesPSPerObjectBuffer.mData.mMaterial = mShapesMaterial;
ConstantBufferUtils::copyData(*mImmediateContext, mShapesPSPerObjectBuffer);
//
// Set constant buffers
//
ID3D11Buffer* vertexShaderBuffers = mShapesVSPerObjectBuffer.mBuffer;
mImmediateContext->VSSetConstantBuffers(0, 1, &vertexShaderBuffers);
ID3D11Buffer* hullShaderBuffer = mShapesHSPerFrameBuffer.mBuffer;
mImmediateContext->HSSetConstantBuffers(0, 1, &hullShaderBuffer);
ID3D11Buffer* domainShaderBuffer = mShapesDSPerFrameBuffer.mBuffer;
mImmediateContext->DSSetConstantBuffers(0, 1, &domainShaderBuffer);
ID3D11Buffer* pixelShaderBuffers[] = { mShapesPSPerFrameBuffer.mBuffer, mShapesPSPerObjectBuffer.mBuffer };
mImmediateContext->PSSetConstantBuffers(0, 2, pixelShaderBuffers);
//
// Set shaders
//
mImmediateContext->VSSetShader(vertexShader, nullptr, 0);
mImmediateContext->HSSetShader(hullShader, nullptr, 0);
mImmediateContext->DSSetShader(domainShader, nullptr, 0);
mImmediateContext->PSSetShader(pixelShader, nullptr, 0);
//
// Set sampler states
//
mImmediateContext->DSSetSamplers(0, 1, &Managers::PipelineStatesManager::mAnisotropicSS);
mImmediateContext->PSSetSamplers(0, 1, &Managers::PipelineStatesManager::mAnisotropicSS);
}
void DisplacementMappingApp::drawBox()
{
// Useful info
ID3D11Buffer* vertexBuffer = Managers::GeometryBuffersManager::mBoxBufferInfo->mVertexBuffer;
ID3D11Buffer* indexBuffer = Managers::GeometryBuffersManager::mBoxBufferInfo->mIndexBuffer;
const uint32_t baseVertexLocation = Managers::GeometryBuffersManager::mBoxBufferInfo->mBaseVertexLocation;
const uint32_t startIndexLocation = Managers::GeometryBuffersManager::mBoxBufferInfo->mStartIndexLocation;
const uint32_t indexCount = Managers::GeometryBuffersManager::mBoxBufferInfo->mIndexCount;
// Update index buffer
uint32_t stride = sizeof(VertexData);
uint32_t offset = 0;
mImmediateContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R32_UINT, 0);
// Update vertex buffer
mImmediateContext->IASetVertexBuffers(0, 1, &vertexBuffer, &stride, &offset);
//
// Update per object constant buffer for land
//
DirectX::XMFLOAT3 rotation(0.0, mRotationAmmount, 0.0f);
DirectX::XMMATRIX world = DirectX::XMMatrixRotationRollPitchYawFromVector(DirectX::XMLoadFloat3(&rotation)) * DirectX::XMLoadFloat4x4(&mBoxWorld);
// Update world matrix
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorld, DirectX::XMMatrixTranspose(world));
// Update world inverse transpose matrix
DirectX::XMMATRIX worldInverseTranspose = MathHelper::inverseTranspose(world);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorldInverseTranspose, DirectX::XMMatrixTranspose(worldInverseTranspose));
// Update texture transform matrix.
DirectX::XMMATRIX texTransform = DirectX::XMLoadFloat4x4(&mShapesTexTransform);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mTexTransform, DirectX::XMMatrixTranspose(texTransform));
ConstantBufferUtils::copyData(*mImmediateContext, mShapesVSPerObjectBuffer);
ID3D11ShaderResourceView* pixelShaderResources[] = { Managers::ResourcesManager::mBoxDiffuseMapSRV, Managers::ResourcesManager::mBoxNormalMapSRV };
mImmediateContext->PSSetShaderResources(0, 2, pixelShaderResources);
ID3D11ShaderResourceView* domainShaderResources = Managers::ResourcesManager::mBoxNormalMapSRV;
mImmediateContext->DSSetShaderResources(0, 1, &domainShaderResources);
mImmediateContext->DrawIndexed(indexCount, startIndexLocation, baseVertexLocation);
}
void DisplacementMappingApp::drawSphere()
{
// Useful info
ID3D11Buffer* vertexBuffer = Managers::GeometryBuffersManager::mSphereBufferInfo->mVertexBuffer;
ID3D11Buffer* indexBuffer = Managers::GeometryBuffersManager::mSphereBufferInfo->mIndexBuffer;
const uint32_t baseVertexLocation = Managers::GeometryBuffersManager::mSphereBufferInfo->mBaseVertexLocation;
const uint32_t startIndexLocation = Managers::GeometryBuffersManager::mSphereBufferInfo->mStartIndexLocation;
const uint32_t indexCount = Managers::GeometryBuffersManager::mSphereBufferInfo->mIndexCount;
// Update index buffer
uint32_t stride = sizeof(VertexData);
uint32_t offset = 0;
mImmediateContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R32_UINT, 0);
// Update vertex buffer
mImmediateContext->IASetVertexBuffers(0, 1, &vertexBuffer, &stride, &offset);
//
// Update per object constant buffer for land
//
DirectX::XMFLOAT3 rotation(0.0, mRotationAmmount, 0.0f);
DirectX::XMMATRIX world = DirectX::XMMatrixRotationRollPitchYawFromVector(DirectX::XMLoadFloat3(&rotation)) * DirectX::XMLoadFloat4x4(&mSphereWorld);
// Update world matrix
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorld, DirectX::XMMatrixTranspose(world));
// Update world inverse transpose matrix
DirectX::XMMATRIX worldInverseTranspose = MathHelper::inverseTranspose(world);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorldInverseTranspose, DirectX::XMMatrixTranspose(worldInverseTranspose));
// Update texture transform matrix.
DirectX::XMMATRIX texTransform = DirectX::XMLoadFloat4x4(&mShapesTexTransform);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mTexTransform, DirectX::XMMatrixTranspose(texTransform));
ConstantBufferUtils::copyData(*mImmediateContext, mShapesVSPerObjectBuffer);
ID3D11ShaderResourceView* pixelShaderResources[] = { Managers::ResourcesManager::mSpheresDiffuseMapSRV, Managers::ResourcesManager::mSpheresNormalMapSRV };
mImmediateContext->PSSetShaderResources(0, 2, pixelShaderResources);
ID3D11ShaderResourceView* domainShaderResources = Managers::ResourcesManager::mSpheresNormalMapSRV;
mImmediateContext->DSSetShaderResources(0, 1, &domainShaderResources);
mImmediateContext->DrawIndexed(indexCount, startIndexLocation, baseVertexLocation);
}
void DisplacementMappingApp::drawCylinder()
{
// Useful info
ID3D11Buffer* vertexBuffer = Managers::GeometryBuffersManager::mCylinderBufferInfo->mVertexBuffer;
ID3D11Buffer* indexBuffer = Managers::GeometryBuffersManager::mCylinderBufferInfo->mIndexBuffer;
const uint32_t baseVertexLocation = Managers::GeometryBuffersManager::mCylinderBufferInfo->mBaseVertexLocation;
const uint32_t startIndexLocation = Managers::GeometryBuffersManager::mCylinderBufferInfo->mStartIndexLocation;
const uint32_t indexCount = Managers::GeometryBuffersManager::mCylinderBufferInfo->mIndexCount;
//
// Set vertex and index buffers
//
uint32_t stride = sizeof(VertexData);
uint32_t offset = 0;
mImmediateContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R32_UINT, 0);
mImmediateContext->IASetVertexBuffers(0, 1, &vertexBuffer, &stride, &offset);
//
// Update per object constant buffer
//
DirectX::XMFLOAT3 rotation(0.0, mRotationAmmount, 0.0f);
DirectX::XMMATRIX world = DirectX::XMMatrixRotationRollPitchYawFromVector(DirectX::XMLoadFloat3(&rotation)) * DirectX::XMLoadFloat4x4(&mCylinderWorld);
// Update world matrix
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorld, DirectX::XMMatrixTranspose(world));
// Update world inverse transpose matrix
DirectX::XMMATRIX worldInverseTranspose = MathHelper::inverseTranspose(world);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorldInverseTranspose, DirectX::XMMatrixTranspose(worldInverseTranspose));
// Update texture transform matrix.
DirectX::XMMATRIX texTransform = DirectX::XMLoadFloat4x4(&mShapesTexTransform);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mTexTransform, DirectX::XMMatrixTranspose(texTransform));
ConstantBufferUtils::copyData(*mImmediateContext, mShapesVSPerObjectBuffer);
ID3D11ShaderResourceView* pixelShaderResources[] = { Managers::ResourcesManager::mCylinderDiffuseMapSRV, Managers::ResourcesManager::mCylinderNormalMapSRV };
mImmediateContext->PSSetShaderResources(0, 2, pixelShaderResources);
ID3D11ShaderResourceView* domainShaderResources = Managers::ResourcesManager::mCylinderNormalMapSRV;
mImmediateContext->DSSetShaderResources(0, 1, &domainShaderResources);
mImmediateContext->DrawIndexed(indexCount, startIndexLocation, baseVertexLocation);
}
void DisplacementMappingApp::drawFloor()
{
// Useful info
ID3D11Buffer* vertexBuffer = Managers::GeometryBuffersManager::mFloorBufferInfo->mVertexBuffer;
ID3D11Buffer* indexBuffer = Managers::GeometryBuffersManager::mFloorBufferInfo->mIndexBuffer;
const uint32_t baseVertexLocation = Managers::GeometryBuffersManager::mFloorBufferInfo->mBaseVertexLocation;
const uint32_t startIndexLocation = Managers::GeometryBuffersManager::mFloorBufferInfo->mStartIndexLocation;
const uint32_t indexCount = Managers::GeometryBuffersManager::mFloorBufferInfo->mIndexCount;
// Update index buffer
uint32_t stride = sizeof(VertexData);
uint32_t offset = 0;
mImmediateContext->IASetIndexBuffer(indexBuffer, DXGI_FORMAT_R32_UINT, 0);
// Update vertex buffer
mImmediateContext->IASetVertexBuffers(0, 1, &vertexBuffer, &stride, &offset);
//
// Update per object constant buffer
//
DirectX::XMMATRIX world = DirectX::XMLoadFloat4x4(&mFloorWorld);
// Update world matrix
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorld, DirectX::XMMatrixTranspose(world));
// Update world inverse transpose matrix
DirectX::XMMATRIX worldInverseTranspose = MathHelper::inverseTranspose(world);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mWorldInverseTranspose, DirectX::XMMatrixTranspose(worldInverseTranspose));
// Update texture transform matrix.
DirectX::XMMATRIX texTransform = DirectX::XMLoadFloat4x4(&mShapesTexTransform);
DirectX::XMStoreFloat4x4(&mShapesVSPerObjectBuffer.mData.mTexTransform, DirectX::XMMatrixTranspose(texTransform));
ConstantBufferUtils::copyData(*mImmediateContext, mShapesVSPerObjectBuffer);
ID3D11ShaderResourceView* pixelShaderResources[] = { Managers::ResourcesManager::mFloorDiffuseMapSRV, Managers::ResourcesManager::mFloorNormalMapSRV };
mImmediateContext->PSSetShaderResources(0, 2, pixelShaderResources);
ID3D11ShaderResourceView* domainShaderResources = Managers::ResourcesManager::mFloorNormalMapSRV;
mImmediateContext->DSSetShaderResources(0, 1, &domainShaderResources);
// Set pixel shader per object buffer
mShapesPSPerObjectBuffer.mData.mMaterial = mFloorMaterial;
ConstantBufferUtils::copyData(*mImmediateContext, mShapesPSPerObjectBuffer);
mImmediateContext->DrawIndexed(indexCount, startIndexLocation, baseVertexLocation);
}
}
|
1df570455de72c11d047b2d365a723d8bdfc8186
|
4bd79e21347c371725f3438eaf7f925670f61cfe
|
/src/parameter_controller.cpp
|
fce700507358d49bc48887d125565b4f709daac4
|
[
"MIT"
] |
permissive
|
liqiangnlp/WordRepresentation
|
a304b5a3ab560ab2c179454b525f1ade23db0b7a
|
b4de2c60eb79373a601ce904e1acb86577425e48
|
refs/heads/master
| 2021-01-19T23:25:35.511197
| 2017-03-03T10:14:45
| 2017-03-03T10:14:45
| 83,785,433
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,687
|
cpp
|
parameter_controller.cpp
|
/*
* $Id:
* 0003
*
* $File:
* parameter_controller.cpp
*
* $Proj:
* WordRepresentation
*
* $Func:
* header file of control parameters
*
* $Version:
* 1.0.0
*
* $Created by:
* Qiang Li
*
* $Email
* liqiangneu@gmail.com
*
* $Last Modified by:
* 2012-12-04,09:56
*/
#include "parameter_controller.h"
namespace word2vector_parameter_controller {
void GetParameter::GetParamsOfWord2Vector() {
cerr<<"Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<<"[FUNCTION]\n"
<<" Word2Vector\n"
<<"[OPTION]\n"
<<" -config : Configuration file.\n"
<<" -input : Use inputted text data to train the model.\n"
<<" -size : Set size of word vectors.\n"
<<" -window : Set max skip length between words.\n"
<<" -binary : Save the resulting vectors in binary moded.\n"
<<" -output : Save the resulting words vectors.\n"
<<" -save-vocab : The vocabulary will be saved to file.\n"
<<" -read-vocab : The vocabulary will be read from file, no constructed from the training data.\n"
<<" -log : Log File.\n"
<<"[EXAMPLE]\n"
<<" WordRepresentation --WORD2VEC -config config-file\n"
<<flush;
return;
}
void GetParameter::GetParamsOfWrrbm() {
cerr<<"Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<<"[FUNCTION]\n"
<<" Word Representation RBM\n"
<<"[OPTION]\n"
<<" -config : Configuration file.\n"
<<"[EXAMPLE]\n"
<<" WordRepresentation --WRRBM -config config-file\n"
<<flush;
return;
}
void GetParameter::GetParamsOfDistance() {
cerr <<"Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<<"[FUNCTION]\n"
<<" Distance\n"
<<"[OPTION]\n"
<<" -config : Configuration file.\n"
<<"[EXAMPLE]\n"
<<" WordRepresentation --DISTANCE -config config-file\n"
<<flush;
return;
}
void GetParameter::GetParamsOfAccuracy() {
cerr <<"Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<<"[FUNCTION]\n"
<<" Accuracy\n"
<<"[OPTION]\n"
<<" -config : Configuration file.\n"
<<"[EXAMPLE]\n"
<<" WordRepresentation --ACCURACY -config config-file\n"
<<flush;
return;
}
void GetParameter::GetParamsOfAnalogy() {
cerr <<"Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<<"[FUNCTION]\n"
<<" Analogy\n"
<<"[OPTION]\n"
<<" -config : Configuration file.\n"
<<"[EXAMPLE]\n"
<<" WordRepresentation --Analogy -config config-file\n"
<<flush;
return;
}
void GetParameter::GetParamsOfWord2Phrase() {
cerr <<"Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<<"[FUNCTION]\n"
<<" Word2Phrase\n"
<<"[OPTION]\n"
<<" -config : Configuration file.\n"
<<"[EXAMPLE]\n"
<<" WordRepresentation --WORD2PHRASE -config config-file\n"
<<flush;
return;
}
bool GetParameter::GetAllFunctions(int argc) {
if (argc <= 1) {
cerr << "Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<< "[USAGE]\n"
<< " WordRepresentation <action> [OPTIONS]\n"
<< "[ACTION]\n"
<< " --WORD2VEC : Training Word2Vector Model.\n"
<< " --WRRBM : Training WRRBM Model.\n"
<< " --WORD2PHRASE : Convert Word 2 Phrase.\n"
<< " --DISTANCE : Compute Distance.\n"
<< " --ACCURACY : Compute Accuracy.\n"
<< " --ANALOGY : Analogy.\n"
<< "[TOOLS]\n"
<< " >> Training Word2Vector Model\n"
<< " WordRepresentation --WORD2VEC\n"
<< " WordRepresentation --WRRBM\n"
<< " WordRepresentation --WORD2PHRASE\n"
<< " WordRepresentation --DISTANCE\n"
<< " WordRepresentation --ACCURACY\n"
<< " WordRepresentation --ANALOGY\n\n"
<< flush;
return true;
}
return false;
}
bool GetParameter::GetAllFunctions(int argc, string argv) {
if ((argc % 2 != 0) || (argc % 2 == 0) && \
((argv != "--WORD2VEC") && (argv != "--DISTANCE") && \
(argv != "--ACCURACY") && (argv != "--ANALOGY") && \
(argv != "--WORD2PHRASE") && (argv != "--WRRBM"))) {
cerr << "Vector Representation of Words Toolkit V1.0.0, liqiangneu@gmail.com\n"
<< "[USAGE]\n"
<< " WordRepresentation <action> [OPTIONS]\n"
<< "[ACTION]\n"
<< " --WORD2VEC : Training Word2Vector Model.\n"
<< " --WRRBM : Training WRRBM Model.\n"
<< " --WORD2PHRASE : Convert Word 2 Phrase.\n"
<< " --DISTANCE : Compute Distance.\n"
<< " --ACCURACY : Compute Accuracy.\n"
<< " --ANALOGY : Analogy.\n"
<< "[TOOLS]\n"
<< " >> Training Word2Vector Model\n"
<< " WordRepresentation --WORD2VEC\n"
<< " WordRepresentation --WRRBM\n"
<< " WordRepresentation --WORD2PHRASE\n"
<< " WordRepresentation --DISTANCE\n"
<< " WordRepresentation --ACCURACY\n"
<< " WordRepresentation --ANALOGY\n\n"
<< flush;
return true;
}
return false;
}
bool GetParameter::GetParameters( int argc, string argv ) {
if (argc == 2) {
if (argv == "--WORD2VEC") {
GetParamsOfWord2Vector();
} else if (argv == "--WRRBM") {
GetParamsOfWrrbm();
} else if (argv == "--DISTANCE") {
GetParamsOfDistance();
} else if (argv == "--ACCURACY") {
GetParamsOfAccuracy();
} else if (argv == "--ANALOGY") {
GetParamsOfAnalogy();
} else if (argv == "--WORD2PHRASE") {
GetParamsOfWord2Phrase();
}
return true;
}
return false;
}
}
|
d5910c4af50dbcd192b79531f07dad838eb0adaa
|
be4b1a68e9a14b02c7ef9ab0809a0f3f018b8d49
|
/Engine/Code/Engine/Renderer/MeshGenerator.cpp
|
26855c7f1935b269d407a3bdcac2a58900d82426
|
[] |
no_license
|
rayray0117/EV1_Projects
|
2df6bcc5ad23011ca7ee04fe8d4773f29bbfe890
|
4851a9d2c280757279a8c2929607593da52372e5
|
refs/heads/master
| 2021-09-14T03:44:39.343253
| 2018-05-07T20:12:11
| 2018-05-07T20:12:11
| 124,570,896
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,167
|
cpp
|
MeshGenerator.cpp
|
#include "Engine/Renderer/MeshGenerator.hpp"
#include "../Core/EngineBase.hpp"
void MeshGenerator::TestVoxel(const Vector3& position, std::vector<Vertex3D>& vertexBuffer)
{
//Bottom (-Z)
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 0.f), Vector2(0.f, 0.f), Rgba(127, 127, 0)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 0.f), Vector2(1.f, 0.f), Rgba(127, 127, 0)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 0.f), Vector2(1.f, 1.f), Rgba(127, 127, 0)));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 0.f), Vector2(0.f, 1.f), Rgba(127, 127, 0)));
//Top (+Z)
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 1.f), Vector2(0.f, 1.f), Rgba(127, 127, 255)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 1.f), Vector2(1.f, 1.f), Rgba(127, 127, 255)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 1.f), Vector2(1.f, 0.f), Rgba(127, 127, 255)));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 1.f), Vector2(0.f, 0.f), Rgba(127, 127, 255)));
// East (+X)
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 0.f), Vector2(0.f, 1.f), Rgba(255, 127, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 0.f), Vector2(1.f, 1.f), Rgba(255, 127, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 1.f), Vector2(1.f, 0.f), Rgba(255, 127, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 1.f), Vector2(0.f, 0.f), Rgba(255, 127, 127)));
// West (-X)
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 1.f), Vector2(1.f, 0.f), Rgba(0, 127, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 1.f), Vector2(0.f, 0.f), Rgba(0, 127, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 0.f), Vector2(0.f, 1.f), Rgba(0, 127, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 0.f), Vector2(1.f, 1.f), Rgba(0, 127, 127)));
// South (-Y)
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 0.f), Vector2(0.f, 1.f), Rgba(127, 0, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 0.f), Vector2(1.f, 1.f), Rgba(127, 0, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 1.f), Vector2(1.f, 0.f), Rgba(127, 0, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 1.f), Vector2(0.f, 0.f), Rgba(127, 0, 127)));
// North (+Y)
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 1.f), Vector2(1.f, 0.f), Rgba(127, 255, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 1.f), Vector2(0.f, 0.f), Rgba(127, 255, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 0.f), Vector2(0.f, 1.f), Rgba(127, 255, 127)));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 0.f), Vector2(1.f, 1.f), Rgba(127, 255, 127)));
}
void MeshGenerator::Cube(const Vector3& position, std::vector<Vertex3D>& vertexBuffer, unsigned int subdivision /*= 0*/)
{
// Front (+Z)
Vector3 normalZPos(0.f, 0.f, -1.f);
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 0.f), Vector2(0.f, 0.f), normalZPos, Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 0.f), Vector2(1.f, 0.f), normalZPos, Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 0.f), Vector2(1.f, 1.f), normalZPos, Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 0.f), Vector2(0.f, 1.f), normalZPos, Vector3::XAXIS));
// Back (-Z)
Vector3 normalZNeg(0.f, 0.f, 1.f);
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 1.f), Vector2(0.f, 1.f), normalZNeg, -Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 1.f), Vector2(1.f, 1.f), normalZNeg, -Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 1.f), Vector2(1.f, 0.f), normalZNeg, -Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 1.f), Vector2(0.f, 0.f), normalZNeg, -Vector3::XAXIS));
// Left (-X)
Vector3 normalXNeg(1.f, 0.f, 0.f);
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 0.f), Vector2(0.f, 0.f), normalXNeg, -Vector3::ZAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 1.f), Vector2(1.f, 0.f), normalXNeg, -Vector3::ZAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 1.f), Vector2(1.f, 1.f), normalXNeg, -Vector3::ZAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 0.f), Vector2(0.f, 1.f), normalXNeg, -Vector3::ZAXIS));
// Right (+X)
Vector3 normalXPos(-1.f, 0.f, 0.f);
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 0.f), Vector2(0.f, 1.f), normalXPos, Vector3::ZAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 1.f), Vector2(1.f, 1.f), normalXPos, Vector3::ZAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 1.f), Vector2(1.f, 0.f), normalXPos, Vector3::ZAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 0.f), Vector2(0.f, 0.f), normalXPos, Vector3::ZAXIS));
// Top (+Y)
Vector3 normalYPos(0.f, 1.f, 0.f);
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 0.f), Vector2(0.f, 1.f), normalYPos, Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 1.f, 1.f), Vector2(1.f, 1.f), normalYPos, Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 1.f), Vector2(1.f, 0.f), normalYPos, Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 1.f, 0.f), Vector2(0.f, 0.f), normalYPos, Vector3::XAXIS));
// Bottom (-Y)
Vector3 normalYNeg(0.f, -1.f, 0.f);
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 0.f), Vector2(0.f, 0.f), normalYNeg, -Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(1.f, 0.f, 1.f), Vector2(1.f, 0.f), normalYNeg, -Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 1.f), Vector2(1.f, 1.f), normalYNeg, -Vector3::XAXIS));
vertexBuffer.push_back(Vertex3D(position + Vector3(0.f, 0.f, 0.f), Vector2(0.f, 1.f), normalYNeg, -Vector3::XAXIS));
UNUSED(subdivision);
}
|
a3115da1ff27f58e14c8e7c7dc070db3a1a439ff
|
dfd413672b1736044ae6ca2e288a69bf9de3cfda
|
/chrome/common/json_value_serializer.cc
|
1e739e6bde24e31c612bb7b00859f6710d1734d0
|
[
"BSD-3-Clause"
] |
permissive
|
cha63506/chromium-capsicum
|
fb71128ba218fec097265908c2f41086cdb99892
|
b03da8e897f897c6ad2cda03ceda217b760fd528
|
HEAD
| 2017-10-03T02:40:24.085668
| 2010-02-01T15:24:05
| 2010-02-01T15:24:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,764
|
cc
|
json_value_serializer.cc
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/json_value_serializer.h"
#include "base/file_util.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/string_util.h"
JSONStringValueSerializer::~JSONStringValueSerializer() {}
bool JSONStringValueSerializer::Serialize(const Value& root) {
if (!json_string_ || initialized_with_const_string_)
return false;
base::JSONWriter::Write(&root, pretty_print_, json_string_);
return true;
}
Value* JSONStringValueSerializer::Deserialize(std::string* error_message) {
if (!json_string_)
return NULL;
return base::JSONReader::ReadAndReturnError(*json_string_,
allow_trailing_comma_,
error_message);
}
/******* File Serializer *******/
bool JSONFileValueSerializer::Serialize(const Value& root) {
std::string json_string;
JSONStringValueSerializer serializer(&json_string);
serializer.set_pretty_print(true);
bool result = serializer.Serialize(root);
if (!result)
return false;
int data_size = static_cast<int>(json_string.size());
if (file_util::WriteFile(json_file_path_,
json_string.data(),
data_size) != data_size)
return false;
return true;
}
Value* JSONFileValueSerializer::Deserialize(std::string* error_message) {
std::string json_string;
if (!file_util::ReadFileToString(json_file_path_, &json_string)) {
return NULL;
}
JSONStringValueSerializer serializer(json_string);
return serializer.Deserialize(error_message);
}
|
f81f99c91c5a35b6d03804179f2c933e8c99410b
|
781c0521d2c6144af49f0bf8f493ce1559a4f340
|
/test/SanityTest.cpp
|
a97c8a2e73e5b2f59adfb247527dae67a006afbb
|
[
"Unlicense"
] |
permissive
|
WebF0x/StrongAI
|
e165ae31e729627ee3b00df00a3a174be9ffcf74
|
970f95869782401988a33f8fe484c16bfd3b3d5b
|
refs/heads/master
| 2020-04-15T16:57:10.500245
| 2016-09-02T15:34:21
| 2016-09-02T15:34:21
| 15,386,260
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,706
|
cpp
|
SanityTest.cpp
|
#include "UnitTest++/UnitTest++.h"
#include <vector>
#include <exception>
SUITE( SanityTest )
{
TEST( check )
{
CHECK( true );
}
TEST( checkEqual )
{
const int expected = 42;
const int actual = 42;
CHECK_EQUAL( expected, actual );
}
TEST( checkClose )
{
const double expected = 10;
const double actual = 9.9;
const double tolerance = 0.1;
CHECK_CLOSE( expected, actual, tolerance );
}
TEST( checkArrayEqual )
{
const std::vector< int > expected( { 1, 2, 3, 4 } );
const std::vector< int > actual( { 1, 2, 3, 4 } );
const int length = 4;
CHECK_ARRAY_EQUAL( expected, actual, length );
}
TEST( checkArrayClose )
{
const std::vector< double > expected ( { 1 , 2 , 3 , 4 } );
const std::vector< double > actual ( { 1.1, 2.1, 2.9, 3.9 } );
const int length = 4;
const double tolerance = 0.1;
CHECK_ARRAY_CLOSE( expected, actual, length, tolerance );
}
TEST( checkArray2DClose )
{
std::vector< std::vector< double > > expected;
expected.push_back( { 1.10, 1.20, 1.30 } );
expected.push_back( { 2.10, 2.20, 2.30 } );
std::vector< std::vector< double > > actual;
actual.push_back( { 1.11, 1.21, 1.31 } );
actual.push_back( { 2.09, 2.19, 2.29 } );
const int rows = 2;
const int columns = 3;
const double tolerance = 0.1;
CHECK_ARRAY2D_CLOSE( expected, actual, rows, columns, tolerance );
}
TEST( checkThrow )
{
CHECK_THROW( throw std::exception(), std::exception );
}
}
|
ac6f0ff7040a8be2c6c174c7824aedd9017473a8
|
a451485f8045e7d7f364f7b92d0bfa468678c3ad
|
/grading/sphere.cpp
|
48aa3b9b4fccc7f375f094cdfc25ed078f04d996
|
[] |
no_license
|
ChauAbdul786/CS130Project1
|
3d219d9c8845b2f89be98a9ebf4327784e3cc892
|
3b20c296a0210eda3213d2f47e5d2c33c512fbf6
|
refs/heads/master
| 2023-08-17T12:51:01.168870
| 2021-10-16T00:42:53
| 2021-10-16T00:42:53
| 416,557,837
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,661
|
cpp
|
sphere.cpp
|
#include "sphere.h"
#include "ray.h"
// Determine if the ray intersects with the sphere
Hit Sphere::Intersection(const Ray& ray, int part) const
{ //(a) t^2 * dot(B, B) +
//(b) 2t * dot(B, A - C) +
//(c) dot(A - C, A - C) - r^2
//Where A = vec endpoint
// B = direction vector
// C = center of sphere
double a = dot(ray.direction, ray.direction);
double b = 2 * dot(ray.direction, (ray.endpoint - center));
double c = dot((ray.endpoint - center), (ray.endpoint - center)) - (radius * radius);
Hit h;
double t0 = -1;
double t1 = -1;
double discriminant = ((b * b) - (4 * (a * c)));
if(discriminant >= 0){ //There is an intersection with the sphere
t0 = (sqrt(discriminant) - b) / (2 * a); //Calculate the (potentially) 2 intersection points w the sphere
t1 = ((0 - b) - sqrt(discriminant)) / (2 * a);
}
if(t0 < small_t){ //Check if either intersection is < small_t
t0 = -1;
}
if(t1 < small_t){
t1 = -1;
}
if((t0 > 0) || (t1 > 0)){ //Check that either of the intersection points are > small_t
h.object = this;
}
if(t0 > 0 && t1 > 0){ //Intersection through the sphere
h.dist = std::min(t0, t1); //Distance is the closer intersection point of the two
}else if(t0 == t1){ //Intersection is tangent to sphere
h.dist = t0;
}
return h;
}
vec3 Sphere::Normal(const vec3& point, int part) const
{
vec3 normal;
TODO; // compute the normal direction
return normal;
}
Box Sphere::Bounding_Box(int part) const
{
Box box;
TODO; // calculate bounding box
return box;
}
|
9509c00b4c8030648d8413672ff35ee60149040c
|
e94559835dec204537927865800f95b81a191b7f
|
/Tympan/geometric_methods/ConvexHullFinder/TYCalculParcours.cpp
|
94f0037c4c77be02e93c421372ebd3a27b9833ec
|
[] |
no_license
|
FDiot/code_tympan3
|
64530a3fc8a392cdbe26f478a9ea9ce03abab051
|
cf4383c4a162962b68df470e2bf757ad534880b9
|
refs/heads/master
| 2022-04-07T10:54:05.711913
| 2019-10-24T13:27:42
| 2019-10-24T13:27:42
| 239,812,326
| 1
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 19,884
|
cpp
|
TYCalculParcours.cpp
|
/*
* Copyright (C) <2012> <EDF-R&D> <FRANCE>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
*
*/
#include <stdio.h>
#include <math.h>
#include "Tympan/models/common/3d.h"
#include "TYCalculParcours.h"
#include <assert.h>
int nNbAbandonsParPointNuples = 0;
TYCalculParcours::TYCalculParcours(int nNbSegMax, bool bVertical)
{
_bVertical = bVertical;
_nNbSegMax = nNbSegMax;
//Creation d'un set geometrique pour les donnees d'entree:
_geoImporterDXF = new TYSetGeometriqueParcours;
_geoImporterDXF->_nNbPolylines = 0;
_geoImporterDXF->AllouerPolylignes(_nNbSegMax);
_geoImporterDXF->_nNbPointTotal = 0;
_geoImporterDXF->_ListePoint = new TYPointParcours[2 * _nNbSegMax];
//Creation d'un set geometrique pour le segment d'entree Source-Recepteur:
_geoSR = new TYSetGeometriqueParcours;
_geoSR->_nNbPolylines = 0;
_geoSR->AllouerPolylignes(1);
_geoSR->_nNbPointTotal = 0;
_geoSR->_ListePoint = new TYPointParcours[2];
_vectorPoint.clear();
}
TYCalculParcours::~TYCalculParcours()
{
SAFE_DELETE(_geoImporterDXF);
SAFE_DELETE(_geoSR);
_vectorPoint.clear();
}
void TYCalculParcours::InitChangementVariable2D3D(bool bAxeXMoinsSignifiant)
{
//Changement de variable en entree pour traitement 2D (une coordonnee ne sera pas prise en compte)
if (_bVertical)
{
//Lorsque le rayon Source-Recepteur est plus oriente suivant Y que X (repere Tympan),
//on garde Y (au lieu de X) comme seconde composante (apres Z, l'altitude = la premiere composante 2D).
//Remarques :
//* la composante ignoree est tout de meme stockee et restituee a la fin (cgangement de variable)
//* on ne fait que choisir des points existants
//(on n'en calcule pas de nouveaux -du moins pour le calcul vertical-)
//* pour les calculs horizontaux, seuls les points sur le trajet Source-Recepteur sont susceptibles
//d'etre issus de calculs au lieu de selection. La coordonnee Z de ces points resulte alors d'une interpollation (cf methode IntersectionDroites)
//Exemple: le rayon Source-Recepteur est parallele a l'axe Y; dans ce cas, le plan 2D est (0y, 0z)
if (bAxeXMoinsSignifiant)
{
_indexXInOut = 1;//Y->X
_indexYInOut = 2;//Z->Y
_indexZInOut = 0;//X->Z
}
else
{
_indexXInOut = 0;
_indexYInOut = 2;//Z->Y
_indexZInOut = 1;//Y->Z
}
}
else
{
_indexXInOut = 0;
_indexYInOut = 1;
_indexZInOut = 2;
}
}
TYCalculParcours::TYCalculParcours(TYSetGeometriqueParcours* geoImporterDXF, TYSetGeometriqueParcours* geoSR, bool bVertical)
{
_geoSR = geoSR;
_geoImporterDXF = geoImporterDXF;
_bVertical = bVertical;
_nNbSegMax = -1;//on se souvient que les polylignes ont ete importees petit a petit
}
void TYCalculParcours::AjouterSegment(double* ptA, double* ptB, bool isInfra, bool isEcran, TYSetGeometriqueParcours* geo)
{
//create point1 from ptA
TYPointParcours p1_temp;
p1_temp.isInfra = isInfra; p1_temp.isEcran = isEcran;
p1_temp.x = ptA[_indexXInOut]; p1_temp.y = ptA[_indexYInOut]; p1_temp.z = ptA[_indexZInOut];
//create point2 from ptB
TYPointParcours p2_temp;
p2_temp.isInfra = isInfra; p2_temp.isEcran = isEcran;
p2_temp.x = ptB[_indexXInOut]; p2_temp.y = ptB[_indexYInOut]; p2_temp.z = ptB[_indexZInOut];
bool ptA_AlreadyExists = false;
bool ptB_AlreadyExists = false;
int indicePt1Doublon = -1;
int indicePt2Doublon = -1;
//verifier si ptA et ptB pas de doublons dans la liste de point
for(int i =_vectorPoint.size() -1 ;i>=0;i--){
if((_vectorPoint[i]->isEcran == p1_temp.isEcran) && (_vectorPoint[i]->isInfra == p1_temp.isInfra) && TYPointParcours::Confondus(_vectorPoint[i],&p1_temp)){
ptA_AlreadyExists = true;
indicePt1Doublon = i;
break;
}
}
for(int i =_vectorPoint.size() -1 ;i>=0;i--){
if((_vectorPoint[i]->isEcran == p2_temp.isEcran) && (_vectorPoint[i]->isInfra == p2_temp.isInfra) && TYPointParcours::Confondus(_vectorPoint[i],&p2_temp)){
ptB_AlreadyExists = true;
indicePt2Doublon = i;
break;
}
}
if(ptA_AlreadyExists & !ptB_AlreadyExists){//SI doublon ptA
TYPointParcours* p2 = &(geo->_ListePoint[geo->_nNbPointTotal]);
p2->isInfra = isInfra; p2->isEcran = isEcran;
p2->x = ptB[_indexXInOut]; p2->y = ptB[_indexYInOut]; p2->z = ptB[_indexZInOut]; p2->Identifiant = geo->_nNbPointTotal;
p2->Identifiant = geo->_nNbPointTotal;
_vectorPoint.push_back(p2);
geo->_nNbPointTotal++;
geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(_vectorPoint[indicePt1Doublon], p2);
geo->_nNbPolylines++;
//delete p1;
}
else if(!ptA_AlreadyExists & ptB_AlreadyExists){//SI doublon ptB
TYPointParcours* p1 = &(geo->_ListePoint[geo->_nNbPointTotal]);
p1->isInfra = isInfra; p1->isEcran = isEcran;
p1->x = ptA[_indexXInOut]; p1->y = ptA[_indexYInOut]; p1->z = ptA[_indexZInOut]; p1->Identifiant = geo->_nNbPointTotal;
p1->Identifiant = geo->_nNbPointTotal;
_vectorPoint.push_back(p1);
geo->_nNbPointTotal++;
geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(p1, _vectorPoint[indicePt2Doublon]);
geo->_nNbPolylines++;
//delete p2;
}
else if(ptA_AlreadyExists & ptB_AlreadyExists){//SI doublon ptA et ptB
geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(_vectorPoint[indicePt1Doublon], _vectorPoint[indicePt2Doublon]);
geo->_nNbPolylines++;
//delete p1,p2;
}
else{//SI aucun doublon
TYPointParcours* p1 = &(geo->_ListePoint[geo->_nNbPointTotal]);
p1->isInfra = isInfra; p1->isEcran = isEcran;
p1->x = ptA[_indexXInOut]; p1->y = ptA[_indexYInOut]; p1->z = ptA[_indexZInOut]; p1->Identifiant = geo->_nNbPointTotal;
p1->Identifiant = geo->_nNbPointTotal;
geo->_nNbPointTotal++;
TYPointParcours* p2 = &(geo->_ListePoint[geo->_nNbPointTotal]);
p2->isInfra = isInfra; p2->isEcran = isEcran;
p2->x = ptB[_indexXInOut]; p2->y = ptB[_indexYInOut]; p2->z = ptB[_indexZInOut]; p2->Identifiant = geo->_nNbPointTotal;
p2->Identifiant = geo->_nNbPointTotal;
geo->_nNbPointTotal++;
_vectorPoint.push_back(p1);
_vectorPoint.push_back(p2);
//On ajoute une polyligne a geo:
geo->_ListePolylines[geo->_nNbPolylines].ajouteSegment(p1, p2);
geo->_nNbPolylines++;
}
}
void TYCalculParcours::AjouterSegmentCoupe(double* ptA, double* ptB, bool isInfra, bool isEcran)
{
assert(_geoSR->_nNbPolylines <= _nNbSegMax);
AjouterSegment(ptA, ptB, isInfra, isEcran, _geoImporterDXF);
}
void TYCalculParcours::AjouterSegmentSR(double* ptA, double* ptB)
{
assert(_geoSR->_nNbPointTotal == 0);
assert(_geoSR->_nNbPolylines == 0);
//On fait ici le choix du systeme de coordonnee:
double dDeltaX = fabs(ptA[0] - ptB[0]);
double dDeltaY = fabs(ptA[1] - ptB[1]);
InitChangementVariable2D3D(dDeltaX < dDeltaY);
//InitChangementVariable2D3D(ptA[0] == ptB[0]);
AjouterSegment(ptA, ptB, false, false, _geoSR);
}
void TYCalculParcours::PointTrajetGauche(int i, double* pt)
{
PointTrajet(i, pt, _geoTrajetGauche);
}
void TYCalculParcours::PointTrajetDroite(int i, double* pt)
{
PointTrajet(i, pt, _geoTrajetDroite);
}
void TYCalculParcours::PointTrajet(int i, double* pt, TYSetGeometriqueParcours* geo)
{
assert(i < geo->_nNbPointTotal);
pt[_indexXInOut] = geo->_ListePoint[i].x;
pt[_indexYInOut] = geo->_ListePoint[i].y;
pt[_indexZInOut] = geo->_ListePoint[i].z;
}
int TYCalculParcours::NombrePointsTrajetDroite()
{
if (NULL == _geoTrajetDroite)
{
return 0;
}
double ptA[3];
double ptB[3];
PointTrajet(0, ptA, _geoSR);
PointTrajet(1, ptB, _geoSR);
return _geoTrajetDroite->_nNbPointTotal;
}
int TYCalculParcours::NombrePointsTrajetGauche()
{
if (NULL == _geoTrajetGauche)
{
return 0;
}
double ptA[3];
double ptB[3];
PointTrajet(0, ptA, _geoSR);
PointTrajet(1, ptB, _geoSR);
return _geoTrajetGauche->_nNbPointTotal;
}
bool TYCalculParcours::Traitement()
{
_geoTrajetGauche = NULL;
_geoTrajetDroite = NULL;
bool resTraitement = Traite(_geoSecondePasseGauche, _geoSecondePasseDroite, _geoTrajetGauche, _geoTrajetDroite);
return resTraitement;
}
bool TYCalculParcours::CalculTrajet(TYSetGeometriqueParcours& geoCourant, bool bCoteGauche, bool* PointsAGauche, bool* PointsADroite, TYSetGeometriqueParcours& geoPremierePasse, TYSetGeometriqueParcours*& geoTrajet)
{
bool bPasEnferme = true;
//3.4 Calcul des trajets
//A partir de maintenant, on ne traite plus qu'un seul cote
//bool bCoteGauche = true;
//3.4.1 Ramener les points traversant la frontiere sur la frontiere
int* IndexePointsFrontiere = new int[geoCourant._nNbPointTotal];
int NbPointsFrontiere = 0;
//=>Construire un tableau donnant directement la propriete "intersection"
bool* EstUnPointIntersectant = new bool[geoCourant._nNbPointTotal];
//on considere ici que les polylignes sont en fait des segments (vrai venant de Tympan)
geoCourant.RamenerPointsTraversantLaFrontiere(_geoSR->_ListePoint[0], _geoSR->_ListePoint[1], IndexePointsFrontiere, NbPointsFrontiere, EstUnPointIntersectant, bCoteGauche, PointsAGauche, PointsADroite);
//On va plus loin que s'il y a des points d'intersection (sinon, c'est SR)
if (NbPointsFrontiere)
{
//3.4.2 Mettre bout a bout les polylignes
//Merger les segments: on considere ici que chaque point ne peut appartenir a plus de 2 polylignes (a verifier en venant de Tympan)
Connexite* Connexes = new Connexite[geoCourant._nNbPointTotal];
bool bOk = geoCourant.ListerPointsConnexes(Connexes);
if (!bOk)
{
bPasEnferme = false;//on a trouve des points n-uples; comme on ne sait pas les gerer, on pretexte un enfermemnt
nNbAbandonsParPointNuples++;
}
else
{
//Est-on enferme ? C'est le cas si en suivant une polyligne intersectante,
//on se retrouve avant S ou apres R sur [S,R]
//Comme on doit parcourir toutes les polylignes intersectantes, on en profite pour calculer les trajets:
bPasEnferme = geoCourant.PremierePasse(_geoSR->_ListePoint[0], _geoSR->_ListePoint[1], IndexePointsFrontiere, NbPointsFrontiere, EstUnPointIntersectant, Connexes, geoPremierePasse);
}
if (bPasEnferme)
{
geoTrajet = &geoPremierePasse;
}
SAFE_DELETE_LIST(Connexes);
}
SAFE_DELETE_LIST(EstUnPointIntersectant);
SAFE_DELETE_LIST(IndexePointsFrontiere);
return bPasEnferme;
}
int TYCalculParcours::Traite(
TYSetGeometriqueParcours& geoSecondePasseGauche,
TYSetGeometriqueParcours& geoSecondePasseDroite,
TYSetGeometriqueParcours*& geoTrajetGauche,
TYSetGeometriqueParcours*& geoTrajetDroite)
{
// Preparation des donnees
//1. Le segment SR doit etre present
assert(NULL != _geoSR);
if (NULL == _geoSR->_ListePoint)
{
return -1;
}
//2. On attribue des identifiants speciaux aux points S & R, pour ne pas les melanger a d'autres
_geoSR->_ListePoint[0].Identifiant = INDENTIFIANT_SOURCE;
_geoSR->_ListePoint[1].Identifiant = INDENTIFIANT_RECEPTEUR;
//S'il n'y a pas d'obstacle:
if (0 == _geoImporterDXF->_nNbPointTotal)
{
//On copie _geoSR
geoSecondePasseGauche.Copy(*_geoSR);
geoSecondePasseDroite.Copy(*_geoSR);
//On n'ecrit pas le fichier
return 0;
}
//3.1 Filtrage
//3.1.1 Filtrage sur les polylignes
if (!_bVertical)
{
TYPointParcours** pTableauECD = NULL;
int nbPtsECD = 0;
TYPointParcours** pTableauECG = NULL;
int nbPtsECG = 0;
TYSetGeometriqueParcours geoGauche;
TYSetGeometriqueParcours geoDroite;
_geoImporterDXF->SupressionPolylignesRedondantes();
//3.2 Marquage des points a gauche ou a droite
bool* PointsAGauche = NULL;
bool* PointsADroite = NULL;
_geoImporterDXF->MarquePointsADroiteEtAGauche(_geoSR->_ListePoint[0], _geoSR->_ListePoint[1], PointsAGauche, PointsADroite);
//3.3 Separation des points suivants le ci��te droit au gauche
//Cette separation donne deja les segments intersectant [SR]
_geoImporterDXF->SeparationDroiteGauche(PointsAGauche, PointsADroite, geoGauche, geoDroite);
//3.4 Calcul des trajets
TYSetGeometriqueParcours geoPremierePasseGauche;
bool bPasEnfermeAGauche = CalculTrajet(geoGauche, true, PointsAGauche, PointsADroite, geoPremierePasseGauche, geoTrajetGauche);
if (bPasEnfermeAGauche)
{
geoGauche.SecondePasse(geoPremierePasseGauche, geoSecondePasseGauche, true, pTableauECG, nbPtsECG);
geoTrajetGauche = &geoSecondePasseGauche;
}
TYSetGeometriqueParcours geoPremierePasseDroite;
bool bPasEnfermeADroite = CalculTrajet(geoDroite, false, PointsAGauche, PointsADroite, geoPremierePasseDroite, geoTrajetDroite);
if (bPasEnfermeADroite)
{
geoDroite.SecondePasse(geoPremierePasseDroite, geoSecondePasseDroite, false, pTableauECD, nbPtsECD);
geoTrajetDroite = &geoSecondePasseDroite;
}
SAFE_DELETE_LIST(PointsAGauche);
SAFE_DELETE_LIST(PointsADroite);
SAFE_DELETE_LIST(pTableauECD);
SAFE_DELETE_LIST(pTableauECG);
}
else
{
//Il suffit de calculer l'EC de l'ensemble des points formes par ceux d'abscisse compris entre Sx & Rx,
//et d'en prendre la partie superieure
//Avant, on termine le merge entrepris avant, ie qu'on ne reordonne la liste pour mettre en premier les nons doublons
//_geoImporterDXF->GenerePointNonConfondus();
//Hypotheses:
//On suppose que ni source ni recepteur ne sont dans un batiment
TYPointParcours** TableauDePointsSelectionnes = new TYPointParcours*[_geoImporterDXF->_nNbPointTotal + 2]; // +2 pour prendre en compte les points S et R qui sont ajoutes
int nNbPointsSelectiones = _geoImporterDXF->SelectionnePointsEntreSetRetDuCoteDeSR(_geoSR, TableauDePointsSelectionnes, _geoImporterDXF->_nNbPointTotal);
TYPointParcours** TableauDePointsEC = new TYPointParcours*[nNbPointsSelectiones];
//int nNbPointsEC = TYSetGeometriqueParcours::EnveloppeConvexeLes2PremiersPointsEtantLesPlusBas(TableauDePointsSelectionnes, nNbPointsSelectiones, TableauDePointsEC);
int nNbPointsEC;
bool bWrong = false;
int idx = 0;
TYPointParcours A, B;
// xbh: corrige le pb de trajet vu sur le projet UMP 1.7 insono.xml
// Ce n'est vraiment pas optimal, mais je n'ai pas trouve de meilleure solution
// avec l'algorithme actuel que d'eliminer les points posant probleme et de recalculer
// l'enveloppe convexe a partir du nouvel ensemble de points.
// Cela a l'air de mieux fonctionner, mais il doit rester des cas ou des problemes persistent.
// En particulier, on suppose dans le filtrage de l'enveloppe que l'on n'a pas de points de rebroussements.
// Ce qui est faux dans le cas ou on passe par dessus un mur d'epaisseur nulle (mais ce cas est-il possible dans Tympan??)
do
{
nNbPointsEC = TYSetGeometriqueParcours::EnveloppeConvexeLes2PremiersPointsEtant(TableauDePointsSelectionnes, nNbPointsSelectiones, TableauDePointsEC, false);
// xbh: ajout d'une deuxieme passe pour filter l'enveloppe convexe en eliminant les points de rebroussements
bWrong = false;
idx = 0;
for (int i = 0; i < nNbPointsEC; i++)
{
if (i > 1)
{
A = TYPointParcours::vecteur2D(*TableauDePointsEC[i - 1], *TableauDePointsEC[i - 2]);
B = TYPointParcours::vecteur2D(*TableauDePointsEC[i - 1], *TableauDePointsEC[i]);
if (TYPointParcours::Scalaire(A, B) > 0) // point de rebroussement dans l'enveloppe, on l'oublie pour lisser l'enveloppe
{
bWrong = true;
idx = i - 1;
break; // on s'arrete ici...
}
else if (ABS(TYPointParcours::Scalaire(A, B)) < EPSILON_13)
{
// on autorise les angles a 90i�� que lors du suivis du contour d'un obstacle
if (!_geoImporterDXF->AppartienneMemePolyligne(TableauDePointsEC[i - 2], TableauDePointsEC[i - 1], TableauDePointsEC[i]))
{
bWrong = true;
idx = i - 1;
break; // on s'arrete ici...
}
}
else if ((A.x == 0.0f) || (B.x == 0.0f))
{
// on autorise les segments verticaux que lors du suivis du contour d'un obstacle
if (!_geoImporterDXF->AppartienneMemePolyligne(TableauDePointsEC[i - 2], TableauDePointsEC[i - 1], TableauDePointsEC[i]))
{
bWrong = true;
idx = i - 1;
break; // on s'arrete ici...
}
}
}
}
if (bWrong) // Si un point pose pb, on l'elimine et on recommence le calcul de l'enveloppe...
{
int k;
for (k = 0; k < nNbPointsSelectiones; k++)
{
if (TableauDePointsEC[idx] == TableauDePointsSelectionnes[k])
{
idx = k;
break; // on a trouve le point, on stop ici
}
}
for (k = idx; k < nNbPointsSelectiones - 1; k++)
{
// On decale tout le tableau
TableauDePointsSelectionnes[k] = TableauDePointsSelectionnes[k + 1];
}
nNbPointsSelectiones--;
}
}
while (bWrong);
//Les points doivent etre ordonnes pour le trajet; on sait que le premier point est S, le second R
//Si S est a droite de R, il faudra reordonner les points pour le trajet
bool bAGaucheDeSR = (_geoSR->_ListePoint[0].x < _geoSR->_ListePoint[1].x);
geoSecondePasseGauche.CreerTrajetAPartirDuneListeDePointsTriee(TableauDePointsEC, nNbPointsEC, bAGaucheDeSR, true);
geoTrajetGauche = &geoSecondePasseGauche;
SAFE_DELETE_LIST(TableauDePointsEC);
SAFE_DELETE_LIST(TableauDePointsSelectionnes);
}
return 0;
}
|
6b667f9626e4f31b2cc6c96d6629ff9d2cdd4a1d
|
4e2670544e785abfd9e3691e5edbb86e86d2aa03
|
/AdInfinitumSept14/SG.cpp
|
ea9303b5396279fd8acfb491daf6be31ad8039d3
|
[] |
no_license
|
Anmol2307/Hackerrank
|
f7eab0bc5baee70cd1a39ce1d32d6a8a17c2a700
|
b39884b38948d1027e49b115e4338811654f4c19
|
refs/heads/master
| 2020-08-04T21:46:31.718524
| 2015-06-14T19:41:17
| 2015-06-14T19:41:17
| 19,476,257
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,687
|
cpp
|
SG.cpp
|
#include <bits/stdc++.h>
using namespace std;
inline void inp(int &n ) {//fast input function
n=0;
int ch=getchar(),sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}
while( ch >= '0' && ch <= '9' )
n=(n<<3)+(n<<1)+ ch-'0', ch=getchar();
n=n*sign;
}
typedef unsigned long long llu;
#define MAX 30000
#define eps 1e-3
double xc, yc, r;
bool check (double x1, double y1, double x2, double y2) {
double c1x = xc - x1;
double c1y = yc - y1;
double e1x = x2 - x1;
double e1y = y2 - y1;
double k = c1x*e1x + c1y*e1y;
if (k > 0){
double len = sqrt(e1x*e1x + e1y*e1y);
k = (double)((double)k/(double)len);
if (k < len){
if (abs(c1x*c1x + c1y*c1y - k*k - r*r) <= eps){
return true;
}
}
}
return false;
}
bool check2 (double x1, double y1, double x2, double y2) {
// v = P1 - P0
// w = P - P0
double e1x = x2 - x1;
double e1y = y2 - y1;
double c1x = xc - x1;
double c1y = yc - y1;
double c1 = c1x*e1x + c1y*e1y;
double c2 = e1x*e1x + e1y*e1y;
if ( c1 <= 0 ) {
// return false;
if ((x1-xc)*(x1-xc) + (y1-yc)*(y1-yc) - r*r <= 0) return true;
else return false;
// return d(P, P0)
}
if ( c2 <= c1 ) {
// return false;
if ((x2-xc)*(x2-xc) + (y2-yc)*(y2-yc) - r*r <= 0) return true;
else return false;
// return d(P, P1)
}
double b = c1 / c2;
e1x = x1 + b*e1x;
e1y = y1 + b*e1y;
if ((e1x-xc)*(e1x-xc) + (e1y-yc)*(e1y-yc) - r*r <= 0) return true;
else return false;
// return true;
// return d(P, Pb)
}
int main () {
int t;
inp(t);
int i = 1;
while (t--) {
scanf("%lf %lf %lf",&xc,&yc,&r);
double x1,y1,x2,y2,x3,y3;
scanf("%lf %lf",&x1,&y1);
scanf("%lf %lf",&x2,&y2);
scanf("%lf %lf",&x3,&y3);
double one = (x1-xc)*(x1-xc) + (y1-yc)*(y1-yc) - r*r;
double two = (x2-xc)*(x2-xc) + (y2-yc)*(y2-yc) - r*r;
double three = (x3-xc)*(x3-xc) + (y3-yc)*(y3-yc) - r*r;
// printf("%lf %lf %lf\n",one,two,three);
double mi = min(one,min(two,three));
double ma = max(one,max(two,three));
// printf("%lf %lf\n",mi,ma);
if (mi <= 0 && ma >= 0) {
// printf("Yahan par hoon %d\n", i);
printf("YES\n");
// i++;
}
else {
// Check if line is tangent to a circle
// Distance of point from line
// printf("Came Here bitch! %d %lf %lf\n",i,mi,ma);
bool one = check2(x1,y1,x2,y2);
bool two = check2(x2,y2,x3,y3);
bool three = check2(x3,y3,x1,y1);
if (ma < 0) printf("NO\n");
else if (mi > 0 && (one || two || three)) printf("YES\n");
else printf("NO\n");
// i++;
}
}
}
|
f67caf02577d49888867eb3d1829bf4778d31a24
|
317f2542cd92aa527c2e17af5ef609887a298766
|
/tools/target_10_2_0_1155/qnx6/usr/include/QtLocationSubset/qgeoboundingbox.h
|
2cb7e58f72bca31e9f426cb388b0ba9d9841d695
|
[] |
no_license
|
sborpo/bb10qnx
|
ec77f2a96546631dc38b8cc4680c78a1ee09b2a8
|
33a4b75a3f56806f804c7462d5803b8ab11080f4
|
refs/heads/master
| 2020-07-05T06:53:13.352611
| 2014-12-12T07:39:35
| 2014-12-12T07:39:35
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,810
|
h
|
qgeoboundingbox.h
|
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QGEOBOUNDINGBOX_H
#define QGEOBOUNDINGBOX_H
#include "qgeoboundingarea.h"
#include <QSharedDataPointer>
#include <QMetaType>
QT_BEGIN_HEADER
QTMS_BEGIN_NAMESPACE
class QGeoCoordinate;
class QGeoBoundingBoxPrivate;
class Q_LOCATION_EXPORT QGeoBoundingBox : public QGeoBoundingArea
{
public:
QGeoBoundingBox();
QGeoBoundingBox(const QGeoCoordinate ¢er, double degreesWidth, double degreesHeight);
QGeoBoundingBox(const QGeoCoordinate &topLeft, const QGeoCoordinate &bottomRight);
QGeoBoundingBox(const QGeoBoundingBox &other);
~QGeoBoundingBox();
QGeoBoundingBox& operator = (const QGeoBoundingBox &other);
bool operator == (const QGeoBoundingBox &other) const;
bool operator != (const QGeoBoundingBox &other) const;
QGeoBoundingArea::AreaType type() const;
bool isValid() const;
bool isEmpty() const;
void setTopLeft(const QGeoCoordinate &topLeft);
QGeoCoordinate topLeft() const;
void setTopRight(const QGeoCoordinate &topRight);
QGeoCoordinate topRight() const;
void setBottomLeft(const QGeoCoordinate &bottomLeft);
QGeoCoordinate bottomLeft() const;
void setBottomRight(const QGeoCoordinate &bottomRight);
QGeoCoordinate bottomRight() const;
void setCenter(const QGeoCoordinate ¢er);
QGeoCoordinate center() const;
void setWidth(double degreesWidth);
double width() const;
void setHeight(double degreesHeight);
double height() const;
bool contains(const QGeoCoordinate &coordinate) const;
bool contains(const QGeoBoundingBox &boundingBox) const;
bool intersects(const QGeoBoundingBox &boundingBox) const;
void translate(double degreesLatitude, double degreesLongitude);
QGeoBoundingBox translated(double degreesLatitude, double degreesLongitude) const;
QGeoBoundingBox united(const QGeoBoundingBox &boundingBox) const;
QGeoBoundingBox operator | (const QGeoBoundingBox &boundingBox) const;
QGeoBoundingBox& operator |= (const QGeoBoundingBox &boundingBox);
private:
QSharedDataPointer<QGeoBoundingBoxPrivate> d_ptr;
};
inline QGeoBoundingBox QGeoBoundingBox::operator | (const QGeoBoundingBox &boundingBox) const
{
return united(boundingBox);
}
QTMS_END_NAMESPACE
Q_DECLARE_METATYPE(QtMobilitySubset::QGeoBoundingBox)
QT_END_HEADER
#endif
|
930ac568c56f80bf1bce9600e287f1e70d817bbf
|
fb3c1e036f18193d6ffe59f443dad8323cb6e371
|
/src/flash/AVMSWF/api/flash/display/AS3Scene.h
|
1c76f8ce8bd6cb7f629555e8bff942a324a7c130
|
[] |
no_license
|
playbar/nstest
|
a61aed443af816fdc6e7beab65e935824dcd07b2
|
d56141912bc2b0e22d1652aa7aff182e05142005
|
refs/heads/master
| 2021-06-03T21:56:17.779018
| 2016-08-01T03:17:39
| 2016-08-01T03:17:39
| 64,627,195
| 3
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,458
|
h
|
AS3Scene.h
|
#ifndef _AS3Scene_
#define _AS3Scene_
namespace avmplus{namespace NativeID{
class SceneClassSlots{
friend class SlotOffsetsAndAsserts;
public://Declare your STATIC AS3 slots here!!!
private:};
class SceneObjectSlots{
friend class SlotOffsetsAndAsserts;
public:
//Declare your MEMBER AS3 slots here!!!
private:};
}}
namespace avmshell{
class SceneObject;
class SceneClass : public ClassClosure
{
public:
SceneClass(VTable *vtable);
ScriptObject *createInstance(VTable *ivtable, ScriptObject *delegate);
SceneObject* CreateScene(Stringp name,int nFrames,int offset);
private:
#ifdef _SYMBIAN
public:
#endif
friend class avmplus::NativeID::SlotOffsetsAndAsserts;
avmplus::NativeID::SceneClassSlots m_slots_SceneClass;
};
class SceneObject : public ScriptObject
{
public:
SceneObject(VTable* _vtable, ScriptObject* _delegate, int capacity);
virtual ~SceneObject()
{
}
public:
DRCWB(ArrayObject*) m_pLabels;
DRCWB(Stringp) m_strName;
int m_nFrames;
int m_nOffset;
//public:
// inline void SetLabels(ArrayObject*pArray)
// { m_pLabels=pArray; }
ArrayObject* AS3_labels_get(){return m_pLabels;}
Stringp AS3_name_get(){return m_strName;}
int AS3_numFrames_get(){return m_nFrames;}
private:
#ifdef _SYMBIAN
public:
#endif
friend class avmplus::NativeID::SlotOffsetsAndAsserts;
avmplus::NativeID::SceneObjectSlots m_slots_SceneObject;
};}
#endif
|
4bb94774c2c343e8aa58d08350fa9fa65f0186b3
|
5054030b328525f129b62a7975815b6ea815e500
|
/main.cpp
|
ec4f393db6169158ca6de99a8c25a9d0875efb2a
|
[] |
no_license
|
Babin6139/Linkedlist
|
bac32deeeeb2b94df9d79846c04555a9b6bf1030
|
ea47048798fb64d75bccd6d2363dd17c00f72337
|
refs/heads/master
| 2020-09-20T19:46:27.108755
| 2019-11-27T23:36:29
| 2019-11-27T23:36:29
| 224,575,197
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 291
|
cpp
|
main.cpp
|
#include <iostream>
#include "linked.h"
using namespace std;
int main(){
List l1;
l1.addToHead(1);
l1.addToHead(2);
l1.addToHead(4);
l1.addToHead(4);
l1.traverse();
Node* outputptr=new Node();
l1.retrieve(2,outputptr);
cout<<outputptr->info;
l1.add
}
|
2794003764594e641edeb4c65c57acc43e96d7b6
|
196c2e381d1119cb1481f41334e6c1af791aa06a
|
/BOJ/20. 분할정복/2263 트리의 순회.cpp
|
2d88a8c7318b9a30a575b1164106bc7690be3627
|
[] |
no_license
|
YuSangBeom/algorithm
|
5541d70422c8e5fa67c6fb1ef571dd184a093bdf
|
d31dbcf240a4dc24744ff5c4caf4ccf1db846119
|
refs/heads/master
| 2023-05-01T12:10:03.547130
| 2021-05-16T14:53:56
| 2021-05-16T14:53:56
| null | 0
| 0
| null | null | null | null |
UHC
|
C++
| false
| false
| 4,762
|
cpp
|
2263 트리의 순회.cpp
|
////#include<iostream>
////#include<vector>
////#include<algorithm>
////
////using namespace std;
////
////vector<int> postorder, inorder;
////
////
//////struct TreeNode {
////// string label; //저장할 자료 (물론 꼭 문자열일 필요는 없다.)
////// TreeNode* parent; //부모 노드를 가리키는 포인터
////// vector<TreeNode*> children; //자손 노드들을 가리키는 포인터의 배열
//////};
////
////////주어진 트리의 각 노드에 저장된 값을 모두 출력한다.
//////void printLabels(TreeNode* root) {
////// //루트에 저장된 값을 출력한다.
////// cout << root->label << endl;
////// //각 자손들을 루트로 하는 서브트리에 포함된 값들을 재귀적으로 호출한다.
////// for (int i = 0; i < root->children.size(); i++)
////// printLabels(root->children[i]);
//////}
////
////////root를 루트로 하는 트리의 높이를 구한다.
//////int height(TreeNode* root) {
////// int h = 0;
////// for (int i = 0; i < root->children.size(); i++)
////// h = max(h, 1 + height(root->children[i]));
////// return h;
//////}
////
////vector<int> slice(const vector<int>& v, int a, int b) {
//// return vector<int>(v.begin() + a, v.begin() + b);
////}
////
////////트리의 전위탐색 결과와 중위탐색 결과가 주어질 때 후위탐색 결과를 출력한다.
//////void printPostOrder(const vector<int>& preorder, const vector<int>& inorder) {
////// //트리에 포함된 노드의 수
////// const int N = preorder.size();
////// //기저 사례:텅 빈 트리면 곧장 종료
////// if (preorder.empty()) return;
////// //이 트리의 루트는 전위 탐색 결과로부터 곧장 알 수 있다.
////// const int root = preorder[0];
////// //이 트리의 왼쪽 서브트리의 크기는 중위 탐색 결과에서 루트의 위치를 찾아서 알 수 있다.
////// const int L = find(inorder.begin(), inorder.end(), root) - inorder.begin();
////// //오른쪽 서브트리의 크기는 N에서 왼쪽 서브트리와 루트를 빼면 알 수 있다.
////// const int R = N - 1 - L;
////// //왼쪽과 오른쪽 서브트리의 순회 결과를 출력
////// printPostOrder(slice(preorder, 1, L + 1), slice(inorder, 0, L));
////// printPostOrder(slice(preorder, L + 1, N), slice(inorder, L + 1, N));
////// //후위 순회이므로 루트를 가장 마지막에 출력한다.
////// cout << root << ' ';
//////}
////
//////트리의 중위탐색 결과와 후위탐색 결과가 주어질 때 전위탐색 결과를 출력한다.
////void printPreOrder(const int inorderStart, const int inorderEnd, const int postorderStart, const int postorderEnd) {
//// ////트리에 포함된 노드의 수
//// const int N = postorderEnd - postorderStart;
//// const int inN = inorderEnd- inorderStart;
//// ////기저 사례:텅 빈 트리면 곧장 종료
////
//// //이 트리의 루트는 후위 탐색 결과로부터 곧장 알 수 있다.
//// const int root = postorder[postorderEnd-1];
//// if (postorderEnd - postorderStart == 1) {
//// cout << root << ' ';
//// return;
//// }
//// /*const int root = postorder[N - 1];
//// if (N == 1) {
//// cout << root << ' ';
//// return;
//// }*/
//// //이 트리의 왼쪽 서브트리의 크기는 중위 탐색 결과에서 루트의 위치를 찾아서 알 수 있다.
//// const int L = find(inorder.begin(), inorder.end(), root) - inorder.begin();
//// //전위 순회이므로 루트를 가장 먼저 출력한다.
//// cout << root << ' ';
//// //왼쪽과 오른쪽 서브트리의 순회 결과를 출력
////
////
//// printPreOrder(inorderStart, L, postorderStart, postorderStart + L);
//// printPreOrder(L+2, inorderEnd, postorderStart + L+1, postorderEnd-1);
////
////
//// //printPreOrder(slice(inorder, 0, L), slice(postorder, 0, R+1));
//// //printPreOrder(slice(inorder, L + 1, inN), slice(postorder, R+1, N-1));
////
////}
////
////int main() {
//// int N,temp;
//// cin >> N;
////
//// for (int i = 0; i < N; i++) {
//// cin >> temp;
//// inorder.push_back(temp);
//// }
//// for (int i = 0; i < N; i++) {
//// cin >> temp;
//// postorder.push_back(temp);
//// }
//// printPreOrder(0,N, 0,N);
////}
//
//#include <iostream>
//using namespace std;
//
//int postOrder[100001];
//int inOrder[100001];
//int find_root[100001];
//int n;
//void func(int s, int e, int s2, int e2) {
// if (s > e) return;
// int root = postOrder[e2];
// cout << root << " ";
// int pos = find_root[root];
// func(s, pos - 1, s2, s2 + (pos - 1 - s));
// func(pos + 1, e, s2 + pos - s, e2 - 1);
// return;
//}
//
//int main() {
// cin >> n;
// for (int i = 0; i < n; ++i) {
// cin >> inOrder[i];
// find_root[inOrder[i]] = i;
// }
// for (int i = 0; i < n; ++i) cin >> postOrder[i];
// func(0, n - 1, 0, n - 1);
//}
//
|
10afc645ab19e9752025f55d14dc4cdabe26e58f
|
e5a65c61cffefdd60494c79abc8ffc59113af688
|
/gaspar/src/cs2604/huffman/decode.cpp
|
d2009ce3d6cc19035c831319df749ec3c87b00a3
|
[] |
no_license
|
kejadlen/college
|
f784b09d7352d4c1a021c083de93c181eb9c2244
|
8e044ac3201d26c2da5d0d87dc84c472858bdbda
|
refs/heads/master
| 2023-01-06T03:38:52.669619
| 2012-02-12T23:36:04
| 2012-02-12T23:36:04
| 3,425,142
| 0
| 0
| null | 2022-12-31T16:33:35
| 2012-02-12T22:14:23
|
TeX
|
UTF-8
|
C++
| false
| false
| 289
|
cpp
|
decode.cpp
|
#include "Huffman.cpp"
int main(int argc, char **argv) {
if(argc != 4) {
cout<<"decode needs three arguments: treefile, encodedmessagefile, messagefile"<<endl;
exit(0);
}
else {
Huffman *temp = new Huffman();
temp->decodeFile(argv[1], argv[2], argv[3]);
delete temp;
}
}
|
ddc43383db93cc3b9d1f0ee5ca383e4e75cc2597
|
c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64
|
/Engine/Source/ThirdParty/IntelTBB/IntelTBB-4.0/src/tbb/tbb_main.cpp
|
b7a3219062581326837c2a59f30f5bb6a44a7e44
|
[
"MIT",
"LicenseRef-scancode-proprietary-license"
] |
permissive
|
windystrife/UnrealEngine_NVIDIAGameWorks
|
c3c7863083653caf1bc67d3ef104fb4b9f302e2a
|
b50e6338a7c5b26374d66306ebc7807541ff815e
|
refs/heads/4.18-GameWorks
| 2023-03-11T02:50:08.471040
| 2022-01-13T20:50:29
| 2022-01-13T20:50:29
| 124,100,479
| 262
| 179
|
MIT
| 2022-12-16T05:36:38
| 2018-03-06T15:44:09
|
C++
|
UTF-8
|
C++
| false
| false
| 8,946
|
cpp
|
tbb_main.cpp
|
/*
Copyright 2005-2012 Intel Corporation. All Rights Reserved.
The source code contained or described herein and all documents related
to the source code ("Material") are owned by Intel Corporation or its
suppliers or licensors. Title to the Material remains with Intel
Corporation or its suppliers and licensors. The Material is protected
by worldwide copyright laws and treaty provisions. No part of the
Material may be used, copied, reproduced, modified, published, uploaded,
posted, transmitted, distributed, or disclosed in any way without
Intel's prior express written permission.
No license under any patent, copyright, trade secret or other
intellectual property right is granted to or conferred upon you by
disclosure or delivery of the Materials, either expressly, by
implication, inducement, estoppel or otherwise. Any license under such
intellectual property rights must be express and approved by Intel in
writing.
*/
#include "tbb/tbb_config.h"
#include "tbb_main.h"
#include "governor.h"
#include "tbb_misc.h"
#include "itt_notify.h"
namespace tbb {
namespace internal {
//------------------------------------------------------------------------
// Begin shared data layout.
// The following global data items are mostly read-only after initialization.
//------------------------------------------------------------------------
//! Padding in order to prevent false sharing.
static const char _pad[NFS_MaxLineSize - sizeof(int)] = {};
//------------------------------------------------------------------------
// governor data
basic_tls<generic_scheduler*> governor::theTLS;
unsigned governor::DefaultNumberOfThreads;
rml::tbb_factory governor::theRMLServerFactory;
bool governor::UsePrivateRML;
//------------------------------------------------------------------------
// market data
market* market::theMarket;
market::global_market_mutex_type market::theMarketMutex;
//------------------------------------------------------------------------
// One time initialization data
//! Counter of references to global shared resources such as TLS.
atomic<int> __TBB_InitOnce::count;
__TBB_atomic_flag __TBB_InitOnce::InitializationLock;
//! Flag that is set to true after one-time initializations are done.
bool __TBB_InitOnce::InitializationDone;
#if DO_ITT_NOTIFY
static bool ITT_Present;
static bool ITT_InitializationDone;
#endif
#if !(_WIN32||_WIN64) || __TBB_SOURCE_DIRECTLY_INCLUDED
static __TBB_InitOnce __TBB_InitOnceHiddenInstance;
#endif
//------------------------------------------------------------------------
// generic_scheduler data
//! Pointer to the scheduler factory function
generic_scheduler* (*AllocateSchedulerPtr)( arena*, size_t index );
//! Table of primes used by fast random-number generator (FastRandom).
/** Also serves to keep anything else from being placed in the same
cache line as the global data items preceding it. */
static const unsigned Primes[] = {
0x9e3779b1, 0xffe6cc59, 0x2109f6dd, 0x43977ab5,
0xba5703f5, 0xb495a877, 0xe1626741, 0x79695e6b,
0xbc98c09f, 0xd5bee2b3, 0x287488f9, 0x3af18231,
0x9677cd4d, 0xbe3a6929, 0xadc6a877, 0xdcf0674b,
0xbe4d6fe9, 0x5f15e201, 0x99afc3fd, 0xf3f16801,
0xe222cfff, 0x24ba5fdb, 0x0620452d, 0x79f149e3,
0xc8b93f49, 0x972702cd, 0xb07dd827, 0x6c97d5ed,
0x085a3d61, 0x46eb5ea7, 0x3d9910ed, 0x2e687b5b,
0x29609227, 0x6eb081f1, 0x0954c4e1, 0x9d114db9,
0x542acfa9, 0xb3e6bd7b, 0x0742d917, 0xe9f3ffa7,
0x54581edb, 0xf2480f45, 0x0bb9288f, 0xef1affc7,
0x85fa0ca7, 0x3ccc14db, 0xe6baf34b, 0x343377f7,
0x5ca19031, 0xe6d9293b, 0xf0a9f391, 0x5d2e980b,
0xfc411073, 0xc3749363, 0xb892d829, 0x3549366b,
0x629750ad, 0xb98294e5, 0x892d9483, 0xc235baf3,
0x3d2402a3, 0x6bdef3c9, 0xbec333cd, 0x40c9520f
};
//------------------------------------------------------------------------
// End of shared data layout
//------------------------------------------------------------------------
//------------------------------------------------------------------------
// Shared data accessors
//------------------------------------------------------------------------
unsigned GetPrime ( unsigned seed ) {
return Primes[seed%(sizeof(Primes)/sizeof(Primes[0]))];
}
//------------------------------------------------------------------------
// __TBB_InitOnce
//------------------------------------------------------------------------
void __TBB_InitOnce::add_ref() {
if( ++count==1 )
governor::acquire_resources();
}
void __TBB_InitOnce::remove_ref() {
int k = --count;
__TBB_ASSERT(k>=0,"removed __TBB_InitOnce ref that was not added?");
if( k==0 )
governor::release_resources();
}
//------------------------------------------------------------------------
// One-time Initializations
//------------------------------------------------------------------------
//! Defined in cache_aligned_allocator.cpp
void initialize_cache_aligned_allocator();
//! Defined in scheduler.cpp
void Scheduler_OneTimeInitialization ( bool itt_present );
#if DO_ITT_NOTIFY
/** Thread-unsafe lazy one-time initialization of tools interop.
Used by both dummy handlers and general TBB one-time initialization routine. **/
void ITT_DoUnsafeOneTimeInitialization () {
if ( !ITT_InitializationDone ) {
ITT_Present = (__TBB_load_ittnotify()!=0);
ITT_InitializationDone = true;
ITT_SYNC_CREATE(&market::theMarketMutex, SyncType_GlobalLock, SyncObj_SchedulerInitialization);
}
}
/** Thread-safe lazy one-time initialization of tools interop.
Used by dummy handlers only. **/
extern "C"
void ITT_DoOneTimeInitialization() {
__TBB_InitOnce::lock();
ITT_DoUnsafeOneTimeInitialization();
__TBB_InitOnce::unlock();
}
#endif /* DO_ITT_NOTIFY */
//! Performs thread-safe lazy one-time general TBB initialization.
void DoOneTimeInitializations() {
__TBB_InitOnce::lock();
// No fence required for load of InitializationDone, because we are inside a critical section.
if( !__TBB_InitOnce::InitializationDone ) {
__TBB_InitOnce::add_ref();
if( GetBoolEnvironmentVariable("TBB_VERSION") )
PrintVersion();
bool itt_present = false;
#if DO_ITT_NOTIFY
ITT_DoUnsafeOneTimeInitialization();
itt_present = ITT_Present;
#endif /* DO_ITT_NOTIFY */
initialize_cache_aligned_allocator();
governor::initialize_rml_factory();
Scheduler_OneTimeInitialization( itt_present );
// Force processor groups support detection
governor::default_num_threads();
// Dump version data
governor::print_version_info();
PrintExtraVersionInfo( "Tools support", itt_present ? "enabled" : "disabled" );
__TBB_InitOnce::InitializationDone = true;
}
__TBB_InitOnce::unlock();
}
#if (_WIN32||_WIN64) && !__TBB_SOURCE_DIRECTLY_INCLUDED && !__TBB_BUILD_LIB__
//! Windows "DllMain" that handles startup and shutdown of dynamic library.
extern "C" bool WINAPI DllMain( HANDLE /*hinstDLL*/, DWORD reason, LPVOID /*lpvReserved*/ ) {
switch( reason ) {
case DLL_PROCESS_ATTACH:
__TBB_InitOnce::add_ref();
break;
case DLL_PROCESS_DETACH:
__TBB_InitOnce::remove_ref();
// It is assumed that InitializationDone is not set after DLL_PROCESS_DETACH,
// and thus no race on InitializationDone is possible.
if( __TBB_InitOnce::initialization_done() ) {
// Remove reference that we added in DoOneTimeInitializations.
__TBB_InitOnce::remove_ref();
}
break;
case DLL_THREAD_DETACH:
governor::terminate_auto_initialized_scheduler();
break;
}
return true;
}
#endif /* (_WIN32||_WIN64) && !__TBB_SOURCE_DIRECTLY_INCLUDED && !__TBB_BUILD_LIB__ */
void itt_store_pointer_with_release_v3( void* dst, void* src ) {
ITT_NOTIFY(sync_releasing, dst);
__TBB_store_with_release(*static_cast<void**>(dst),src);
}
void* itt_load_pointer_with_acquire_v3( const void* src ) {
void* result = __TBB_load_with_acquire(*static_cast<void*const*>(src));
ITT_NOTIFY(sync_acquired, const_cast<void*>(src));
return result;
}
#if DO_ITT_NOTIFY
void call_itt_notify_v5(int t, void *ptr) {
switch (t) {
case 0: ITT_NOTIFY(sync_prepare, ptr); break;
case 1: ITT_NOTIFY(sync_cancel, ptr); break;
case 2: ITT_NOTIFY(sync_acquired, ptr); break;
case 3: ITT_NOTIFY(sync_releasing, ptr); break;
}
}
#else
void call_itt_notify_v5(int /*t*/, void* /*ptr*/) {}
#endif
void* itt_load_pointer_v3( const void* src ) {
void* result = *static_cast<void*const*>(src);
return result;
}
void itt_set_sync_name_v3( void* obj, const tchar* name) {
ITT_SYNC_RENAME(obj, name);
suppress_unused_warning(obj && name);
}
} // namespace internal
} // namespace tbb
|
cacc4c547837c851760bed8441041cdeee704fd4
|
7395135e922f4780774b89140f4bee0bbd659994
|
/src/pandas/dispatch.cc
|
5cced21d24c4a94b37fdf298f86f3b9abeade8e3
|
[
"BSD-3-Clause",
"LicenseRef-scancode-other-permissive",
"BSD-2-Clause"
] |
permissive
|
femtotrader/pandas2
|
0c631fd0077421e9bc2b356625b3391696abb8ff
|
10ba4cbde079367e72aa4e646d9f2be5ff3c2151
|
refs/heads/pandas-2.0
| 2021-01-13T05:49:49.894393
| 2016-10-27T22:29:37
| 2016-10-27T22:29:37
| 72,233,768
| 0
| 0
| null | 2016-10-28T18:52:47
| 2016-10-28T18:52:47
| null |
UTF-8
|
C++
| false
| false
| 1,074
|
cc
|
dispatch.cc
|
// This file is a part of pandas. See LICENSE for details about reuse and
// copyright holders
#include "pandas/dispatch.h"
#include "pandas/common.h"
namespace pandas {
#define MAKE_TYPE_CASE(NAME, CapName) \
case NAME: \
*out = new CapName##Type(); \
break;
Status primitive_type_from_enum(DataType::TypeId tp_enum, DataType** out) {
switch (tp_enum) {
MAKE_TYPE_CASE(DataType::INT8, Int8);
MAKE_TYPE_CASE(DataType::INT16, Int16);
MAKE_TYPE_CASE(DataType::INT32, Int32);
MAKE_TYPE_CASE(DataType::INT64, Int64);
MAKE_TYPE_CASE(DataType::UINT8, UInt8);
MAKE_TYPE_CASE(DataType::UINT16, UInt16);
MAKE_TYPE_CASE(DataType::UINT32, UInt32);
MAKE_TYPE_CASE(DataType::UINT64, UInt64);
MAKE_TYPE_CASE(DataType::FLOAT32, Float);
MAKE_TYPE_CASE(DataType::FLOAT64, Double);
MAKE_TYPE_CASE(DataType::BOOL, Boolean);
MAKE_TYPE_CASE(DataType::PYOBJECT, PyObject);
default:
return Status::NotImplemented("Not a primitive type");
}
return Status::OK();
}
} // namespace pandas
|
d5121c5a9d80793cd28477fe0f8c72f3c2f17bdc
|
e83fd6a92810c746415a0648306ba2549d2df6ce
|
/src/Physics/SphereCollider.cpp
|
81c7ed603276adba1b3d46a5cb8c6e8df5ec511f
|
[] |
no_license
|
Craigspaz/Axle
|
e59906af68a9d9b7e3fc7902cb4b70d630b09811
|
9a37162e393dba9f1a5b5769a6d88cd59a3e4a37
|
refs/heads/master
| 2023-06-05T15:08:47.044512
| 2021-06-23T01:38:12
| 2021-06-23T01:38:12
| 114,414,532
| 0
| 0
| null | 2020-10-12T18:05:57
| 2017-12-15T21:59:07
|
C
|
UTF-8
|
C++
| false
| false
| 112
|
cpp
|
SphereCollider.cpp
|
#include "Physics/SphereCollider.h"
SphereCollider::SphereCollider()
{
}
SphereCollider::~SphereCollider()
{
}
|
54e64ccbcd77e8a60a21254ea3b637490847c60a
|
fa35fbd2bd6c5e169cceedf5e571154e857fa841
|
/Busca.cpp
|
81f7a807658f1ed5f0aa865b38f0be74bacd3087
|
[] |
no_license
|
feknows/estruturajean
|
36a45e4b9acbedcf6dfa4fcb34b18e7c82c29173
|
c2aa1e8c4fbb0b902f9a5b5bb042513531f36b80
|
refs/heads/master
| 2021-06-22T20:58:54.861511
| 2017-08-24T23:16:25
| 2017-08-24T23:16:25
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 366
|
cpp
|
Busca.cpp
|
/* Algoritmo sequencial ou linear de Busca */
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
main(){
int vetor[6]={2,5,1,6,9,44};
int chave=9;
for(int i=0;i<6;i++){
if (vetor[i]==chave){
printf("\n\n Achado no indice %d",i);
// break; se tiver valor repetido retorna o primeiro
}
}
getch();
}
|
cb04a987e9ae42dc72151af5f48b5fe494b95f50
|
23819413de400fa78bb813e62950682e57bb4dc0
|
/Rounds/Round-659/a.cpp
|
cbff0fd0bcbcd1b5f52d408ea9e7a81e4bf87d6f
|
[] |
no_license
|
Manzood/CodeForces
|
56144f36d73cd35d2f8644235a1f1958b735f224
|
578ed25ac51921465062e4bbff168359093d6ab6
|
refs/heads/master
| 2023-08-31T16:09:55.279615
| 2023-08-20T13:42:49
| 2023-08-20T13:42:49
| 242,544,327
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 666
|
cpp
|
a.cpp
|
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" = "<<x<<endl;
int main() {
int t;
cin >> t;
while (t--) {
int n;
scanf("%d", &n);
vector <int> a(n);
for (int i=0; i<n; i++) {
scanf("%d", &a[i]);
}
vector <string> ans(n+1);
for (int i=0; i<n+1; i++) {
ans[i] = "";
if (i == 0) {
for (int j=0; j<200; j++) {
ans[i] += "a";
}
}
else {
for (int j=0; j<200 ; j++) {
if (j < a[i-1])
ans[i] += ans[i-1][j];
else {
if (ans[i-1][j] == 'a') ans[i] += 'b';
else ans[i] += 'a';
}
}
}
}
for (int i=0; i<ans.size(); i++) {
cout << ans[i] << '\n';
}
}
}
|
7ee378a256943dd1c7212dff42bb2a2f83649507
|
25ebfb3313fc4c816959d5546001652b5d4fa610
|
/StreetFighter/ModuleScenerySelection.cpp
|
b35733d5caa6188643ee86f5f839ccdfa0de2ee9
|
[] |
no_license
|
N4bi/Street-Fighter
|
21eb42d42992ea5683b4207dc1f09205f258c842
|
73a57aad7313d55d453d6032920d2af17174bf8d
|
refs/heads/master
| 2016-09-05T14:46:47.022031
| 2015-06-12T04:35:23
| 2015-06-12T04:35:23
| 34,381,544
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,800
|
cpp
|
ModuleScenerySelection.cpp
|
#include "Globals.h"
#include "Application.h"
#include "ModuleScenerySelection.h"
ModuleScenerySelection::ModuleScenerySelection(Application* app, bool start_enabled) : Module(app, start_enabled)
{
graphics = NULL;
//map
/* map.x = 50;
map.y = 50;
map.w = 150;
map.h = 150;*/
map.x = 405;
map.y = 426;
map.w = 261;
map.h = 125;
//countries
countries.x = 60;
countries.y = 445;
countries.w = 271;
countries.h = 100;
// usa
usa.x = 380;
usa.y = 600;
usa.w = 32;
usa.h = 26;
//japan
japan.x = 429;
japan.y = 594;
japan.w = 44;
japan.h = 38;
//p1
p1selection.frames.PushBack({ 62, 663, 36, 39 });
p1selection.frames.PushBack({ 99, 662, 36, 39 });
p1selection.loop = true;
p1selection.speed = 0.08f;
//p2
p2selection.frames.PushBack({ 62, 706, 40, 40 });
p2selection.frames.PushBack({ 99, 706, 40, 40 });
p2selection.loop = true;
p2selection.speed = 0.08f;
//faces
faces.x = 61;
faces.y = 569;
faces.w = 132;
faces.h = 68;
//indicator ryu
indicatorRyu.x = 363;
indicatorRyu.y = 668;
indicatorRyu.w = 105;
indicatorRyu.h = 13;
//indicator ken
indicatorKen.x = 363;
indicatorKen.y = 726;
indicatorKen.w = 105;
indicatorKen.h = 13;
}
ModuleScenerySelection::~ModuleScenerySelection()
{}
// Load assets
bool ModuleScenerySelection::Start()
{
LOG("Loading Scenery Selection Screen");
bool ret = true;
graphics = App->textures->Load("Game/portraits.png");
App->audio->PlayMusic("Game/sounds/music/selection.ogg");
App->renderer->camera.x = App->renderer->camera.y = 0;
sceneKen = false;
sceneRyu = false;
return ret;
}
// UnLoad assets
bool ModuleScenerySelection::CleanUp()
{
LOG("Unloading Scenery Selection Screen");
App->textures->Unload(graphics);
return true;
}
// Update: draw background
update_status ModuleScenerySelection::Update()
{
// Draw everything --------------------------------------
App->renderer->Blit(graphics, 57, 9, &map);
App->renderer->Blit(graphics, 39, 24, &countries);
App->renderer->Blit(graphics, 174, 67, &japan);
App->renderer->Blit(graphics, 276, 57, &usa);
App->renderer->Blit(graphics, 127, 144, &faces);
App->renderer->Blit(graphics, 15, 150, &indicatorRyu);
App->renderer->Blit(graphics, 15, 200, &indicatorKen);
App->renderer->Blit(graphics, 127, 140, &(p1selection.GetCurrentFrame()), 0.92f);
App->renderer->Blit(graphics, 127, 176, &(p2selection.GetCurrentFrame()), 0.92f);
if (App->input->GetKey(SDL_SCANCODE_KP_1) == KEY_UP)
{
sceneRyu = true;
App->audio->PlayFx(0, 0);
App->fade->FadeToBlack(App->scenery_selection, App->vs_scene, 2.0f);
}
else if (App->input->GetKey(SDL_SCANCODE_KP_2) == KEY_UP)
{
sceneKen = true;
App->audio->PlayFx(0, 0);
App->fade->FadeToBlack(App->scenery_selection, App->vs_scene, 2.0f);
}
return UPDATE_CONTINUE;
}
|
65e01f7087c27dd1c6f5aa1133b2686fca311fb6
|
e3f4c50130dac43b07e19778b9c002a3b3c1c3ee
|
/ZigbeeEndpoint/Arduino/zb_motionsensor/zb_motionsensor.ino
|
48c8b17dda08bce11ba02399a3495bc34c98a138
|
[] |
no_license
|
firefeather/SyntroZigbee
|
44d22664800fe0f60e8d59e92fb05d75e94a5788
|
8de1168d3738a1d723cd868bf93f0f648ae84561
|
refs/heads/master
| 2020-12-06T19:13:44.537567
| 2013-05-09T12:24:05
| 2013-05-09T12:24:05
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 6,501
|
ino
|
zb_motionsensor.ino
|
//
// Copyright (c) 2012 Pansenti, LLC.
//
// This file is part of Syntro
//
// Syntro is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Syntro is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Syntro. If not, see <http://www.gnu.org/licenses/>.
//
//
// A Parallax PIR motion sensor attached to an Arduino board that also
// has a Zigbee radio.
//
// The Zigbee should be in API mode.
//
// The default configuration assumes Serial and the radio is configured
// for a baud rate of 115200.
//
// Only tested with an UNO
//
// The system must be 'armed' before it will send the state of the
// motion sensor. It also needs a destination radio address which it
// gets from the 'arming' packet.
//
// Write one byte to the Arduino, non-zero arms, zero disarms.
//
// The Arduino board LED will be lit when the system is 'armed'.
//
// The Arduino will send back a 1 byte report whenever the sensor changes
// state. One is on, zero is off.
//
#define STATE_GET_START_DELIMITER 0
#define STATE_GET_LENGTH 1
#define STATE_GET_FRAME_TYPE 2
#define STATE_GET_SRC_ADDRESS 3
#define STATE_GET_SRC_SHORT_ADDRESS 4
#define STATE_GET_DST_SHORT_ADDRESS 5
#define STATE_GET_RECEIVE_OPTIONS 6
#define STATE_GET_DATA 20
#define STATE_GET_CHECKSUM 30
#define START_DELIMITER 0x7E
#define FRAME_TYPE_TRANSMIT_REQUEST 0x10
#define FRAME_TYPE_TRANSMIT_STATUS 0x8B
#define FRAME_TYPE_RECEIVE_PACKET 0x90
#define FRAME_TYPE_EXPLICIT_RX_IND 0x91
#define MAX_RX_FRAMELEN 28
#define BOARD_LED_PIN 13
#define MOTION_SENSOR_PIN 2
unsigned int rxState;
unsigned int rxCount;
unsigned int rxFrameLength;
unsigned char rxBuff[MAX_RX_FRAMELEN + 4];
unsigned char clientAddress[10];
bool armed;
int motionDetected;
unsigned long nextSendTime;
void setup()
{
rxState = STATE_GET_START_DELIMITER;
rxCount = 0;
armed = false;
// set to an invalid value so we detect 'change' on the first sensor read
motionDetected = -1;
nextSendTime = 0;
Serial.begin(115200);
pinMode(BOARD_LED_PIN, OUTPUT);
pinMode(MOTION_SENSOR_PIN, INPUT);
}
void loop()
{
if (readLoop()) {
processCommand();
}
if (armed) {
if (millis() > nextSendTime) {
if (stateChanged()) {
sendSensorState();
if (motionDetected) {
// the sensor stays armed for 3 seconds
nextSendTime = millis() + 3000;
}
else {
nextSendTime = millis() + 100;
}
}
}
}
}
bool stateChanged()
{
int val = digitalRead(MOTION_SENSOR_PIN);
if (motionDetected != val) {
motionDetected = val;
return true;
}
return false;
}
// Assumes that at this point we are looking at a proper 'Receive Packet'
// or an 'Explicit RX Indicator' packet
void processCommand()
{
int i, val;
if (rxCount < 17) {
return;
}
if (rxBuff[3] == FRAME_TYPE_EXPLICIT_RX_IND) {
val = rxBuff[21];
}
else {
val = rxBuff[15];
}
if (val == 0) {
armed = false;
digitalWrite(BOARD_LED_PIN, LOW);
}
else {
// copy src address and src short address into txBuff
for (i = 0; i < 10; i++) {
clientAddress[i] = rxBuff[i + 4];
}
armed = true;
// so we don't respond immediately
delay(50);
digitalWrite(BOARD_LED_PIN, HIGH);
}
}
void sendSensorState()
{
int i;
unsigned char tx[24];
// most tx fields never change
tx[0] = 0x7E;
tx[1] = 0; // len MSB
tx[2] = 15; // len LSB
tx[3] = FRAME_TYPE_TRANSMIT_REQUEST;
tx[4] = 0x00; // frame id, we don't want a response
// bytes 5-12 are the dest address
// bytes 13-14 are the dest net address
// we saved this when we got armed
for (i = 0; i < 10; i++) {
tx[i+5] = clientAddress[i];
}
tx[15] = 0x00; // broadcast radius, default
tx[16] = 0x00; // no options
tx[17] = 0xff & motionDetected;
tx[18] = calculateChecksum(tx + 3, 15);
Serial.write(tx, 19);
}
// Return true if we've assembled a valid packet
bool readLoop()
{
unsigned char c;
bool readDone = false;
while (!readDone && Serial.available()) {
c = Serial.read();
switch (rxState) {
case STATE_GET_START_DELIMITER:
if (c == START_DELIMITER) {
rxBuff[0] = c;
rxCount = 1;
rxState = STATE_GET_LENGTH;
}
break;
case STATE_GET_LENGTH:
rxBuff[rxCount++] = c;
if (rxCount == 3) {
rxFrameLength = (rxBuff[1] << 8) + rxBuff[2];
if (rxFrameLength < MAX_RX_FRAMELEN) {
rxState = STATE_GET_FRAME_TYPE;
}
else {
rxState = STATE_GET_START_DELIMITER;
rxCount = 0;
}
}
break;
case STATE_GET_FRAME_TYPE:
rxBuff[rxCount++] = c;
if (c == FRAME_TYPE_RECEIVE_PACKET || c == FRAME_TYPE_EXPLICIT_RX_IND) {
rxState = STATE_GET_DATA;
}
else {
// not a real receive packet
rxState = STATE_GET_START_DELIMITER;
rxCount = 0;
}
break;
case STATE_GET_DATA:
rxBuff[rxCount++] = c;
if (rxCount == rxFrameLength + 3) {
rxState = STATE_GET_CHECKSUM;
}
break;
case STATE_GET_CHECKSUM:
rxBuff[rxCount++] = c;
if (rxCount >= rxFrameLength + 3) {
c = calculateChecksum(rxBuff + 3, rxFrameLength);
// if the checksum is good, handle it
if (c == rxBuff[rxCount - 1]) {
readDone = true;
}
rxState = STATE_GET_START_DELIMITER;
}
break;
}
}
return readDone;
}
unsigned char calculateChecksum(unsigned char *data, int len)
{
int i;
unsigned char sum = data[0];
for (i = 1; i < len; i++) {
sum += data[i];
}
return 0xff - sum;
}
|
288538d2b9c8447df69c6e4e3ae5979171a0140e
|
01104279b836ad0d787e5792ec24159d84516cee
|
/MyMFC/CDataDirectory.h
|
b92e3682f6a9e85f91a1dc2f596a169e18055179
|
[] |
no_license
|
keeplearning/MyHousekeeper
|
3e019ee85bd781eae16f4c502b012d2e7a18e12f
|
4706ccbf59669979c8df135929edae53c87cde7f
|
refs/heads/master
| 2020-04-03T20:50:51.385523
| 2018-10-31T13:17:57
| 2018-10-31T13:17:57
| 155,560,376
| 8
| 6
| null | null | null | null |
GB18030
|
C++
| false
| false
| 741
|
h
|
CDataDirectory.h
|
#pragma once
// CDataDirectory 对话框
class CDataDirectory : public CDialogEx
{
DECLARE_DYNAMIC(CDataDirectory)
public:
CDataDirectory(LPBYTE pBuff, IMAGE_NT_HEADERS *pNt, CWnd* pParent = nullptr); // 标准构造函数
virtual ~CDataDirectory();
// 对话框数据
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIRECTORY_DLG };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
IMAGE_NT_HEADERS * m_pNt;
virtual BOOL OnInitDialog();
DWORD RvaToFoa(DWORD dwRva);
void ParseResources(LPBYTE pResRoot, IMAGE_RESOURCE_DIRECTORY* pRes, int nLevel = 1);
CTreeCtrl m_treeCtrl;
LPBYTE m_pBuff;
HTREEITEM hRoot3;
HTREEITEM hResChild1;
HTREEITEM hResChild2;
};
|
6322ee5162407bbdf70ec05844ae3013634677a1
|
0ce9e3d0643571994e5d95e1182e6a31ac9728c2
|
/data_acquisition/ptu/libs/vectornav/libvncxx/include/vn/sensorfeatures.h
|
63322b98dbad80dcab6f9bc0dcb943c573bd2eed
|
[
"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
| 6,711
|
h
|
sensorfeatures.h
|
#ifndef _VN_SENSORFEATURES_H_
#define _VN_SENSORFEATURES_H_
#include <string>
#include <vector>
#include "vn/sensors.h"
#include "vn/version.h"
namespace vn {
namespace sensors {
/// \brief Provides indication of what features are available for a given sensors.
class VnSensorFeatures
{
public:
/// \brief Creates a new feature indicator.
VnSensorFeatures();
/// \brief Constructs a new feature indicator based on the provided specifics.
/// \param[in] modelNumber The model number as read from the sensor.
/// \param[in] firmwareVersion The firmware version number as read from the sensor.
VnSensorFeatures(std::string modelNumber, std::string firmwareVersion, uint32_t hardwareRevision);
/// \brief Returns the list of supported Async Data Output Types.
/// \return Collection of supported types.
std::vector<vn::protocol::uart::AsciiAsync> supportedAsyncDataOutputTypes();
/// \brief Returns the factory default value for Async Data Output Type.
/// \return The default Async Data Output Type.
vn::protocol::uart::AsciiAsync defaultAsyncDataOutputType();
/// \brief Indicates if the sensor supports the User Tag register.
/// \return Indicates if available.
bool supportsUserTag();
/// \brief Indicates if the sensor supports dual serial ports.
/// \return Indicates if available.
bool supportsDualSerialOutputs();
/// \brief Indicates if the sensor supports the Magnetic and Gravity Reference Vectors register.
/// \return Indicates if available.
bool supportsMagneticAndGravityReferenceVectors();
/// \brief Indicates if the sensor supports the Filter Measurements Variance Parameters register.
/// \return Indicates if available.
bool supportsFilterMeasurementsVarianceParameters();
/// \brief Indicates if the sensor supports the Filter Active Tuning Parameters register.
/// \return Indicates if available.
bool supportsFilterActiveTuningParameters();
/// \brief Indicates if the sensor supports the Magnetometer Compensation register.
/// \return Indicates if available.
bool supportsMagnetometerCompensation();
/// \brief Indicates if the sensor supports the Acceleration Compensation register.
/// \return Indicates if available.
bool supportsAccelerationCompensation();
/// \brief Indicates if the sensor supports the Gyro Compensation register.
/// \return Indicates if available.
bool supportsGyroCompensation();
/// \brief Indicates if the sensor supports the Communication Protocol Control register.
/// \return Indicates if available.
bool supportsCommunicationProtocolControl();
/// \brief Indicates if the sensor supports the Synchronization Control register.
/// \return Indicates if available.
bool supportsSynchronizationControl();
/// \brief Indicates if the sensor supports the Filter Basic Control register.
/// \return Indicates if available.
bool supportsFilterBasicControl();
/// \brief Indicates if the sensor supports the VPE Basic Control register.
/// \return Indicates if available.
bool supportsVpeBasicControl();
/// \brief Indicates if the sensor supports the VPE Magnetometer Basic Control register.
/// \return Indicates if available.
bool supportsVpeMagnetometerBasicTuning();
/// \brief Indicates if the sensor supports the VPE Magnetometer Advanced Control register.
/// \return Indicates if available.
bool supportsVpeMagnetometerAdvancedTuning();
/// \brief Indicates if the sensor supports the VPE Accelerometer Basic Control register.
/// \return Indicates if available.
bool supportsVpeAccelerometerBasicTuning();
/// \brief Indicates if the sensor supports the VPE Accelerometer Advanced Control register.
/// \return Indicates if available.
bool supportsVpeAccelerometerAdvancedTuning();
/// \brief Indicates if the sensor supports the VPE Gyro Basic Control register.
/// \return Indicates if available.
bool supportsVpeGyroBasicTuning();
/// \brief Indicates if the sensor supports the Filter Startup Gyro Bias register.
/// \return Indicates if available.
bool supportsFilterStartupGyroBias();
/// \brief Indicates if the sensor supports the Magnetometer Calibration Control register.
/// \return Indicates if available.
bool supportsMagnetometerCalibrationControl();
/// \brief Indicates if the sensor supports the Indoor Heading Mode Control register.
/// \return Indicates if available.
bool supportsIndoorHeadingModeControl();
/// \brief Indicates if the sensor supports the GPS Configuration register.
/// \return Indicates if available.
bool supportsGpsConfiguration();
/// \brief Indicates if the sensor supports the GPS Antenna Offset register.
/// \return Indicates if available.
bool supportsGpsAntennaOffset();
/// \brief Indicates if the sensor supports the GPS Compass Baseline register.
/// \return Indicates if available.
bool supportsGpsCompassBaseline();
/// \brief Indicates if the sensor supports the Binary Output registers.
/// \return Indicates if available.
bool supportsBinaryOutput();
/// \brief Indicates if the sensor supports the IMU Filtering Configuration register.
/// \return Indicates if available.
bool supportsImuFilteringConfiguration();
/// \brief Indicates if the sensor supports the Delta Theta and Delta Velocity Configuration register.
/// \return Indicates if available.
bool supportsDeltaThetaAndDeltaVelocityConfiguration();
/// \brief Indicates if the sensor supports the Startup Filter Bias Estimate register.
/// \return Indicates if available.
bool supportsStartupFilterBiasEstimate();
/// \brief Indicates if the sensor supports the INS Basic Configuration register.
/// \return Indicates if available.
bool supportsInsBasicConfiguration();
/// \brief Indicates if the sensor supports the Velocity Compensation Control register.
/// \return Indicates if available.
bool supportsVelocityCompensationControl();
/// \brief Indicates if the sensor supports the Reference Vector Configuration register.
/// \return Indicates if available.
bool supportsReferenceVectorConfiguration();
/// \brief Indicates if the sensor supports the IMU Rate Configuration register.
/// \return Indicates if available.
bool supportsImuRateConfiguration();
/// \brief Indicates if the sensor supports the INS Advanced Configuration register.
/// \return Indicates if available.
bool supportsInsAdvancedConfiguration();
private:
VnSensor::Family _family;
vn::Version _ver;
uint32_t _rev;
};
}
}
#endif
|
a8b3701a2ec285c0c9dd7cc06e58c4c67a6635e4
|
88b130d5ff52d96248d8b946cfb0faaadb731769
|
/documentapi/src/vespa/documentapi/messagebus/messages/getdocumentreply.cpp
|
450f3bd23c91dbc5c8f33c249eed35fb61fca56c
|
[
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
vespa-engine/vespa
|
b8cfe266de7f9a9be6f2557c55bef52c3a9d7cdb
|
1f8213997718c25942c38402202ae9e51572d89f
|
refs/heads/master
| 2023-08-16T21:01:12.296208
| 2023-08-16T17:03:08
| 2023-08-16T17:03:08
| 60,377,070
| 4,889
| 619
|
Apache-2.0
| 2023-09-14T21:02:11
| 2016-06-03T20:54:20
|
Java
|
UTF-8
|
C++
| false
| false
| 971
|
cpp
|
getdocumentreply.cpp
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "getdocumentreply.h"
#include <vespa/documentapi/messagebus/documentprotocol.h>
#include <vespa/document/fieldvalue/document.h>
namespace documentapi {
GetDocumentReply::GetDocumentReply() :
DocumentAcceptedReply(DocumentProtocol::REPLY_GETDOCUMENT),
_document(),
_lastModified(0)
{}
GetDocumentReply::~GetDocumentReply() {}
GetDocumentReply::GetDocumentReply(document::Document::SP document) :
DocumentAcceptedReply(DocumentProtocol::REPLY_GETDOCUMENT),
_document(std::move(document)),
_lastModified(0)
{
if (_document) {
_lastModified = _document->getLastModified();
}
}
void
GetDocumentReply::setDocument(document::Document::SP document)
{
_document = std::move(document);
if (document.get()) {
_lastModified = document->getLastModified();
} else {
_lastModified = 0u;
}
}
}
|
2b089ea343acb8e53376182fcc11f55f8f616ce6
|
0e6e81a3788fd9847084991c3177481470546051
|
/Explore/Tencent/code by cpp/089_Gray Code.cpp
|
a7db415ba09adef5a3567b24af3b14260b2a3202
|
[] |
no_license
|
Azhao1993/Leetcode
|
6f84c62620f1bb60f82d4383764b777a4caa2715
|
1c1f2438e80d7958736dbc28b7ede562ec1356f7
|
refs/heads/master
| 2020-03-25T19:34:30.946119
| 2020-03-05T14:28:17
| 2020-03-05T14:28:17
| 144,089,629
| 4
| 2
| null | 2019-11-18T00:30:31
| 2018-08-09T02:10:26
|
C++
|
UTF-8
|
C++
| false
| false
| 1,808
|
cpp
|
089_Gray Code.cpp
|
#include<iostream>
#include<vector>
using namespace std;
/*
89. 格雷编码
格雷编码是一个二进制数字系统,在该系统中,两个连续的数值仅有一个位数的差异。
给定一个代表编码总位数的非负整数 n,打印其格雷编码序列。格雷编码序列必须以 0 开头。
示例 1:
输入: 2
输出: [0,1,3,2]
解释:
00 - 0 01 - 1 11 - 3 10 - 2
对于给定的 n,其格雷编码序列并不唯一。
例如,[0,2,3,1] 也是一个有效的格雷编码序列。
00 - 0 10 - 2 11 - 3 01 - 1
示例 2:
输入: 0
输出: [0]
解释: 我们定义格雷编码序列必须以 0 开头。
给定编码总位数为 n 的格雷编码序列,其长度为 2n。当 n = 0 时,长度为 20 = 1。
因此,当 n = 0 时,其格雷编码序列为 [0]。
*/
class Solution {
public:
vector<int> grayCode(int n) {
vector<int> arr;
if(n<0)return arr;
arr.push_back(0);
int val = 1;
// 每次新加一位的时候,倒着进行加
for(int i=1;i<=n;i++){
for(int j=arr.size()-1;j>=0;j--)
arr.emplace_back(arr[j]+val);
val = val << 1;
}
return arr;
// 一次循环,快一点
vector<int> res;
res.push_back(0);
if (n == 0) return res;
int cur = 0,pre = 0;
for (int i = 1; i < pow(2, n); i++) {
if ((i&(i - 1) )== 0) {
cur = i;
pre = i - 1;
}
res.push_back(cur + res[pre]);
if (pre > 0) pre--;
}
return res;
}
};
int main(){
Solution* so = new Solution();
vector<int> num = so->grayCode(5);
for(auto it:num)
cout<<it<<' ';
cout<<endl;
return 0;
}
|
c0890386a99fb54a5920e9f1319b6e37a45b80a4
|
f63024e68a0c8af63f7199c75eb54f48529efac4
|
/BlinkSharp/Core/Prediction/RingPrediction.cpp
|
11a160ebe9bd8481577a44fbedf672b83909fcf6
|
[] |
no_license
|
RekzaiSharp/BlinkSharp
|
d886281c2c8fea1b59b0b28af94d4712ff2eae6f
|
e76f0a990b595509a8f937ae874fe9ce16805b49
|
refs/heads/master
| 2021-10-24T20:30:09.529798
| 2019-02-02T16:34:11
| 2019-02-02T16:34:11
| 167,058,405
| 0
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,961
|
cpp
|
RingPrediction.cpp
|
#include "RingPrediction.h"
#include "CirclePrediction.h"
RingPrediction::RingPrediction(SPrediction& engine)
: ISPredictionBase::ISPredictionBase(engine)
{
}
PredictionResult RingPrediction::GetPrediction(AIBaseClient *target, float width, float delay, float missile_speed, float range, bool collisionable, eSpellType type)
{
return GetPrediction(target, width, delay, missile_speed, range, collisionable, type,
Player.GetServerPosition(), Player.GetServerPosition(), target->GetWaypoints(),
m_prediction_engine.GetPathTrackerEngine().GetAvgMovChangeTime(target),
m_prediction_engine.GetPathTrackerEngine().GetLastMovChangeTime(target),
m_prediction_engine.GetPathTrackerEngine().GetAvgPathLenght(target),
m_prediction_engine.GetPathTrackerEngine().GetLastAngleDiff(target));
}
PredictionResult RingPrediction::GetPrediction(AIBaseClient *target, float width, float delay, float missile_speed, float range, bool collisionable, eSpellType type, const Vector3& from, const Vector3& range_check_from)
{
return GetPrediction(target, width, delay, missile_speed, range, collisionable, type, from, range_check_from,
target->GetWaypoints(),
m_prediction_engine.GetPathTrackerEngine().GetAvgMovChangeTime(target),
m_prediction_engine.GetPathTrackerEngine().GetLastMovChangeTime(target),
m_prediction_engine.GetPathTrackerEngine().GetAvgPathLenght(target),
m_prediction_engine.GetPathTrackerEngine().GetLastAngleDiff(target));
}
PredictionResult RingPrediction::GetPrediction(AIBaseClient *target, float width, float delay, float missile_speed, float range, bool collisionable, eSpellType type, const Vector3& from, const Vector3& range_check_from, const std::vector<Vector3>& path, float avgt, float movt, float avgp, float anglediff)
{
PredictionInput input(target, delay, missile_speed, width, range, collisionable, type, from, range_check_from);
input.avg_reaction_time_ = avgt;
input.last_mov_change_time_ = movt;
input.avg_path_lenght_ = avgp;
input.last_angle_diff_ = anglediff;
input.path_ = path;
return GetPrediction(input);
}
PredictionResult RingPrediction::GetPrediction(PredictionInput input)
{
auto result = CirclePrediction(m_prediction_engine).GetPrediction(input);
if (result.hit_chance_ > kHitChanceLow)
{
Vector2 direction = (result.cast_position_ - Geometry::Helpers::To2D(input.from_) + Geometry::Helpers::To2D(input.target_->GetDirection())).Normalize();
result.cast_position_ -= direction * (input.spell_.width_ - input.spell_.ring_radius_);
if (Geometry::Helpers::Distance(Geometry::Helpers::To2D(input.range_check_from_), result.cast_position_) > input.spell_.range_)
{
result.hit_chance_ = kHitChanceOutOfRange;
}
}
return result;
}
PredictionAoeResult RingPrediction::GetAoePrediction(float width, float delay, float missile_speed, float range, const Vector3& from, const Vector3& range_check_from)
{
throw std::exception("not implemented");
}
RingPrediction::~RingPrediction()
{
}
|
901e3f1fb3df52171620630a40fc1c0f895ec235
|
bb751d3609c078192a0f0b196035c7e758d53d71
|
/src/math/random/random_manager.cpp
|
881855f718db4b3f18a8e3b6a2824bf7b8f6214b
|
[] |
no_license
|
ProfDru/C--Random-Particle-Generator
|
bdf3b839e4313021b9d01c8f83cffaf46a1ccb84
|
662a1f1a3af6dfe76ae8d4088a67a873d487711a
|
refs/heads/master
| 2023-02-05T08:00:11.706604
| 2020-12-02T21:53:34
| 2020-12-02T21:53:34
| 296,649,177
| 1
| 0
| null | 2020-12-02T21:53:36
| 2020-09-18T14:46:28
|
C++
|
UTF-8
|
C++
| false
| false
| 605
|
cpp
|
random_manager.cpp
|
#include <math/random/random_manager.h>
#include <math/random/distributions/uniform.h>
#include <cmath>
#include <algorithm>
namespace rpg::math::random {
Generator GlobalRandom::rand_gen(RNG_Algorithm::DEFAULT);
std::unique_ptr<Distribution> GlobalRandom::dist =
std::unique_ptr<Distribution>(new Uniform(0, 1));
float GlobalRandom::GetRandomNumber() {
return dist->get_number(rand_gen);
}
float GlobalRandom::GetRandomNumber(float min, float max) {
const float random_number = GlobalRandom::GetRandomNumber();
return std::lerp(min, max, random_number);
}
} // namespace rpg::math::random
|
b0335dc1d46e1ba64b990a8f7e631226ab1e1144
|
7dd74bd241150d0895921a6b96b768c319e9b580
|
/Code/Testing/calatkGaussianBlurringTest.cxx
|
532c32326c8f85d62f9c2163efac6ab720736464
|
[
"Apache-2.0"
] |
permissive
|
cpatrick/calatk
|
71db343e16136ba32e41484c67ca081a9a359739
|
849c17919ac5084b5b067c7631bc2aa1efd650df
|
refs/heads/master
| 2021-01-19T08:12:14.506068
| 2012-12-13T19:40:34
| 2012-12-13T19:40:34
| 7,138,608
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,766
|
cxx
|
calatkGaussianBlurringTest.cxx
|
/*
*
* Copyright 2011, 2012 by the CALATK development team
*
* 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.
*
*
*/
/**
* Tests Gaussian blurring of an image
*
*/
#include "VectorImage.h"
#include "VectorImageUtils.h"
#include "CGaussianKernel.h"
typedef double TFLOAT;
const unsigned int DIMENSION = 2;
int calatkGaussianBlurringTest( int argc, char* argv[] )
{
if ( argc != 3 )
{
std::cerr << "Usage: " << argv[0] << " <original image> <blurred output image>" << std::endl;
return EXIT_FAILURE;
}
std::cout << "Input: " << argv[1] << std::endl;
std::cout << "Output: " << argv[2] << std::endl;
typedef CALATK::VectorImage< TFLOAT, DIMENSION > VectorImageType;
typedef CALATK::VectorImageUtils< TFLOAT, DIMENSION > VectorImageUtilsType;
VectorImageType::Pointer pIm = VectorImageUtilsType::readFileITK( argv[1] );
VectorImageType::Pointer pImBlurred = new VectorImageType( pIm );
typedef CALATK::CGaussianKernel< TFLOAT, DIMENSION > GaussianKernelType;
GaussianKernelType::Pointer gaussianKernel = new GaussianKernelType();
gaussianKernel->SetSigma( 0.1 );
gaussianKernel->ConvolveWithKernel( pImBlurred );
VectorImageUtilsType::writeFileITK( pImBlurred, argv[2] );
return EXIT_SUCCESS;
}
|
74625ee10cdc0fd7e60d125b0c8376fb648ee051
|
49fae9a1403a2c33522c946047af1f4ef97b033e
|
/samples/embeeb/app/model/diskinfo.h
|
2d8aaf2190ae398955b3c39751cac806b8f05dbe
|
[
"MIT"
] |
permissive
|
blockspacer/oaknut
|
7cd3bba921d40d712852033b8fee9a441a0bcf80
|
03b37965ad84745bd5c077a27d8b53d58a173662
|
refs/heads/master
| 2022-12-03T00:32:45.155903
| 2020-08-24T23:05:26
| 2020-08-24T23:05:26
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,058
|
h
|
diskinfo.h
|
//
// Copyright © 2018 Sandcastle Software Ltd. All rights reserved.
//
#pragma once
#include "../app.h"
class DiskInfo : public Object, public ISerializeToVariant
{
public:
sp<class Game> _game;
string _title;
string _publisher;
string _mediaFilename;
string _mediaFileHash;
string _imageFilename;
string _platform;
string _format;
float _version;
string _qualifiers;
string _localFilePath;
DiskInfo();
string diskUrl();
string imageUrl();
// ISerializableToVariant
void fromVariant(const variant& v) override;
void toVariant(variant& v) override;
protected:
string fileToUrl(string filename);
};
class Game : public Object, public ISerializeToVariant {
public:
string _title;
vector<variant> _publishers;
vector<sp<DiskInfo>> _diskInfos;
// ISerializeToVariant
void fromVariant(const variant& v) override;
void toVariant(variant& v) override;
//- (id)initAsLocalDisk:(NSString*)localFilePath fileHash:(NSString*)fileHash diskInfo:(DiskInfo*)diskInfo;
DiskInfo* defaultDiskInfo();
};
|
c0a7c386c3394f0d014cd1e46f4272a7f36012fe
|
cb7ac15343e3b38303334f060cf658e87946c951
|
/source/runtime/D3D11RHI/D3D11Shader.cpp
|
76708bc91966e8c7410c6a4199e9ced5be515c1a
|
[] |
no_license
|
523793658/Air2.0
|
ac07e33273454442936ce2174010ecd287888757
|
9e04d3729a9ce1ee214b58c2296188ec8bf69057
|
refs/heads/master
| 2021-11-10T16:08:51.077092
| 2021-11-04T13:11:59
| 2021-11-04T13:11:59
| 178,317,006
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 14,567
|
cpp
|
D3D11Shader.cpp
|
#include "d3d11shader.h"
#include "D3D11DynamicRHI.h"
#include "Serialization/MemoryReader.h"
#include "D3D11Util.h"
#include "D3D11Resource.h"
#include "BoundShaderStateCache.h"
#include "D3D11ConstantBuffer.h"
namespace Air
{
template<typename TShaderType>
static inline void readShaderOptionalData(ShaderCodeReader& inShaderCode, TShaderType& outShader)
{
auto packedResourceCounts = inShaderCode.findOptionalData<ShaderCodePackedResourceCounts>();
BOOST_ASSERT(packedResourceCounts);
outShader.bShaderNeedsGlobalConstantBuffer = packedResourceCounts->bGlobalConstantBufferUsed;
const ANSICHAR* ansName = inShaderCode.findOptionalData('n');
outShader.mShaderName = ansName ? ansName : "";
int32 constantBufferTableSize = 0;
auto * constantBufferData = inShaderCode.findOptionalDataAndSize('u', constantBufferTableSize);
if (constantBufferData && constantBufferTableSize > 0)
{
BufferReader CBReader((void*)constantBufferData, constantBufferTableSize, false);
TArray<wstring> names;
CBReader << names;
BOOST_ASSERT(outShader.mConstantBuffers.size() == 0);
for (int32 index = 0; index < names.size(); ++index)
{
outShader.mConstantBuffers.push_back(names[index]);
}
}
}
VertexShaderRHIRef D3D11DynamicRHI::RHICreateVertexShader(const TArray<uint8>& code)
{
ShaderCodeReader shaderCode(code);
D3D11VertexShader* shader = new D3D11VertexShader();
MemoryReader ar(code, true);
ar << shader->mShaderResourceTable;
int32 offset = ar.tell();
const uint8* codePtr = code.data() + offset;
const size_t codeSize = shaderCode.getActualShaderCodeSize() - offset;
readShaderOptionalData(shaderCode, *shader);
VERIFYD3d11RESULT(mD3D11Device->CreateVertexShader((void*)codePtr, codeSize, nullptr, shader->mResource.getInitReference()));
shader->mCode = code;
shader->mOffset = offset;
return shader;
}
HullShaderRHIRef D3D11DynamicRHI::RHICreateHullShader(const TArray<uint8>& code)
{
ShaderCodeReader shaderCode(code);
D3D11HullShader* shader = new D3D11HullShader();
MemoryReader ar(code, true);
ar << shader->mShaderResourceTable;
int32 offset = ar.tell();
const uint8* codePtr = code.data();
const size_t codeSize = shaderCode.getActualShaderCodeSize() - offset;
readShaderOptionalData(shaderCode, *shader);
VERIFYD3d11RESULT(mD3D11Device->CreateHullShader(codePtr, codeSize, nullptr, shader->mResource.getInitReference()));
return shader;
}
DomainShaderRHIRef D3D11DynamicRHI::RHICreateDomainShader(const TArray<uint8>& code)
{
ShaderCodeReader shaderCode(code);
D3D11DomainShader* shader = new D3D11DomainShader();
MemoryReader ar(code, true);
ar << shader->mShaderResourceTable;
int32 offset = ar.tell();
const uint8* codePtr = code.data();
const size_t codeSize = shaderCode.getActualShaderCodeSize() - offset;
readShaderOptionalData(shaderCode, *shader);
VERIFYD3d11RESULT(mD3D11Device->CreateDomainShader(codePtr, codeSize, nullptr, shader->mResource.getInitReference()));
return shader;
}
PixelShaderRHIRef D3D11DynamicRHI::RHICreatePixelShader(const TArray<uint8>& code)
{
ShaderCodeReader shaderCode(code);
D3D11PixelShader* shader = new D3D11PixelShader();
MemoryReader ar(code, true);
ar << shader->mShaderResourceTable;
int32 offset = ar.tell();
const uint8* codePtr = code.data() + offset;
const size_t codeSize = shaderCode.getActualShaderCodeSize() - offset;
readShaderOptionalData(shaderCode, *shader);
VERIFYD3d11RESULT(mD3D11Device->CreatePixelShader(codePtr, codeSize, nullptr, shader->mResource.getInitReference()));
return shader;
}
ComputeShaderRHIRef D3D11DynamicRHI::RHICreateComputeShader(const TArray<uint8>& code)
{
ShaderCodeReader shaderCode(code);
D3D11ComputeShader* shader = new D3D11ComputeShader();
MemoryReader ar(code, true);
ar << shader->mShaderResourceTable;
int32 offset = ar.tell();
const uint8* codePtr = code.data();
const size_t codeSize = shaderCode.getActualShaderCodeSize() - offset;
readShaderOptionalData(shaderCode, *shader);
VERIFYD3d11RESULT(mD3D11Device->CreateComputeShader(codePtr, codeSize, nullptr, shader->mResource.getInitReference()));
return shader;
}
GeometryShaderRHIRef D3D11DynamicRHI::RHICreateGeometryShader(const TArray<uint8>& code)
{
ShaderCodeReader shaderCode(code);
D3D11GeometryShader* shader = new D3D11GeometryShader();
MemoryReader ar(code, true);
ar << shader->mShaderResourceTable;
int32 offset = ar.tell();
const uint8* codePtr = code.data();
const size_t codeSize = shaderCode.getActualShaderCodeSize() - offset;
readShaderOptionalData(shaderCode, *shader);
VERIFYD3d11RESULT(mD3D11Device->CreateGeometryShader(codePtr, codeSize, nullptr, shader->mResource.getInitReference()));
return shader;
}
void D3D11DynamicRHI::RHISetShaderConstantBuffer(RHIVertexShader* vertexShader, uint32 bufferIndex, RHIConstantBuffer* bufferRHI)
{
D3D11ConstantBuffer* buffer = ResourceCast(bufferRHI);
{
ID3D11Buffer* constantBuffer = buffer ? buffer->mResource : NULL;
mStateCache.setConstantBuffer<SF_Vertex>(constantBuffer, bufferIndex);
}
mBoundConstantBuffers[SF_Vertex][bufferIndex] = bufferRHI;
mDirtyConstantBuffers[SF_Vertex] |= (1 << bufferIndex);
}
void D3D11DynamicRHI::RHISetShaderConstantBuffer(RHIPixelShader* pixelShader, uint32 bufferIndex, RHIConstantBuffer* bufferRHI)
{
D3D11ConstantBuffer* buffer = ResourceCast(bufferRHI);
{
ID3D11Buffer* constantBuffer = buffer->mResource;
mStateCache.setConstantBuffer<SF_Pixel>(constantBuffer, bufferIndex);
}
mBoundConstantBuffers[SF_Pixel][bufferIndex] = bufferRHI;
mDirtyConstantBuffers[SF_Pixel] |= (1 << bufferIndex);
}
void D3D11DynamicRHI::RHISetShaderConstantBuffer(RHIHullShader* pixelShader, uint32 bufferIndex, RHIConstantBuffer* bufferRHI)
{
D3D11ConstantBuffer* buffer = ResourceCast(bufferRHI);
{
ID3D11Buffer* constantBuffer = buffer->mResource;
mStateCache.setConstantBuffer<SF_Hull>(constantBuffer, bufferIndex);
}
mBoundConstantBuffers[SF_Hull][bufferIndex] = bufferRHI;
mDirtyConstantBuffers[SF_Hull] |= (1 << bufferIndex);
}
void D3D11DynamicRHI::RHISetShaderConstantBuffer(RHIDomainShader* domainShader, uint32 bufferIndex, RHIConstantBuffer* bufferRHI)
{
D3D11ConstantBuffer* buffer = ResourceCast(bufferRHI);
{
ID3D11Buffer* constantBuffer = buffer->mResource;
mStateCache.setConstantBuffer<SF_Domain>(constantBuffer, bufferIndex);
}
mBoundConstantBuffers[SF_Domain][bufferIndex] = bufferRHI;
mDirtyConstantBuffers[SF_Domain] |= (1 << bufferIndex);
}
void D3D11DynamicRHI::RHISetShaderConstantBuffer(RHIGeometryShader* pixelShader, uint32 bufferIndex, RHIConstantBuffer* bufferRHI)
{
D3D11ConstantBuffer* buffer = ResourceCast(bufferRHI);
{
ID3D11Buffer* constantBuffer = buffer->mResource;
mStateCache.setConstantBuffer<SF_Geometry>(constantBuffer, bufferIndex);
}
mBoundConstantBuffers[SF_Geometry][bufferIndex] = bufferRHI;
mDirtyConstantBuffers[SF_Geometry] |= (1 << bufferIndex);
}
void D3D11DynamicRHI::RHISetShaderConstantBuffer(RHIComputeShader* computeShader, uint32 bufferIndex, RHIConstantBuffer* bufferRHI)
{
D3D11ConstantBuffer* buffer = ResourceCast(bufferRHI);
{
ID3D11Buffer* constantBuffer = buffer->mResource;
mStateCache.setConstantBuffer<SF_Compute>(constantBuffer, bufferIndex);
}
mBoundConstantBuffers[SF_Compute][bufferIndex] = bufferRHI;
mDirtyConstantBuffers[SF_Compute] |= (1 << bufferIndex);
}
void D3D11DynamicRHI::RHISetShaderParameter(RHIVertexShader* vertexShader, uint32 bufferIndex, uint32 baseIndex, uint32 numBytes, const void* newValue)
{
mVSUnifomBuffers[bufferIndex]->updateUniform((const uint8*)newValue, baseIndex, numBytes);
}
void D3D11DynamicRHI::RHISetShaderParameter(RHIHullShader* hullShader, uint32 bufferIndex, uint32 baseIndex, uint32 numBytes, const void* newValue)
{
mHSUnifomBuffers[bufferIndex]->updateUniform((const uint8*)newValue, baseIndex, numBytes);
}
void D3D11DynamicRHI::RHISetShaderParameter(RHIDomainShader* hullShader, uint32 bufferIndex, uint32 baseIndex, uint32 numBytes, const void* newValue)
{
mDSUnifomBuffers[bufferIndex]->updateUniform((const uint8*)newValue, baseIndex, numBytes);
}
void D3D11DynamicRHI::RHISetShaderParameter(RHIGeometryShader* hullShader, uint32 bufferIndex, uint32 baseIndex, uint32 numBytes, const void* newValue)
{
mGSUnifomBuffers[bufferIndex]->updateUniform((const uint8*)newValue, baseIndex, numBytes);
}
void D3D11DynamicRHI::RHISetShaderParameter(RHIPixelShader* hullShader, uint32 bufferIndex, uint32 baseIndex, uint32 numBytes, const void* newValue)
{
mPSUnifomBuffers[bufferIndex]->updateUniform((const uint8*)newValue, baseIndex, numBytes);
}
static DXGI_FORMAT getPlatformTextureResourceFormat(DXGI_FORMAT inFormat, uint32 inFlags);
void D3D11DynamicRHI::RHISetShaderParameter(RHIComputeShader* hullShader, uint32 bufferIndex, uint32 baseIndex, uint32 numBytes, const void* newValue)
{
mCSUnifomBuffers[bufferIndex]->updateUniform((const uint8*)newValue, baseIndex, numBytes);
}
GeometryShaderRHIRef D3D11DynamicRHI::RHICreateGeometryShaderWithStreamOutput(const TArray<uint8>& code, const StreamOutElementList& elementList, uint32 numStrides, const uint32* strides, int32 rasterizedStream)
{
ShaderCodeReader shaderCode(code);
D3D11GeometryShader* shader = new D3D11GeometryShader();
MemoryReader ar(code, true);
ar << shader->mShaderResourceTable;
int32 offset = ar.tell();
const uint8* codePtr = code.data() + offset;
const size_t codeSize = shaderCode.getActualShaderCodeSize();
uint32 d3dRasterizedStream = rasterizedStream;
if (rasterizedStream == -1)
{
d3dRasterizedStream = D3D11_SO_NO_RASTERIZED_STREAM;
}
D3D11_SO_DECLARATION_ENTRY streamOutEntries[D3D11_SO_STREAM_COUNT * D3D11_SO_OUTPUT_COMPONENT_COUNT];
for (int32 entryIndex = 0; entryIndex < elementList.size(); entryIndex++)
{
streamOutEntries[entryIndex].Stream = elementList[entryIndex].mStream;
streamOutEntries[entryIndex].SemanticName = elementList[entryIndex].mSemanticName;
streamOutEntries[entryIndex].SemanticIndex = elementList[entryIndex].mSementicIndex;
streamOutEntries[entryIndex].StartComponent = elementList[entryIndex].mStartComponent;
streamOutEntries[entryIndex].ComponentCount = elementList[entryIndex].mComponentCount;
streamOutEntries[entryIndex].OutputSlot = elementList[entryIndex].mOutputSlot;
}
VERIFYD3d11RESULT(mD3D11Device->CreateGeometryShaderWithStreamOutput(codePtr, codeSize, streamOutEntries, elementList.size(), strides, numStrides, d3dRasterizedStream, NULL, shader->mResource.getInitReference()));
auto packedResourceCounts = shaderCode.findOptionalData<ShaderCodePackedResourceCounts>();
BOOST_ASSERT(packedResourceCounts);
shader->bShaderNeedsGlobalConstantBuffer = packedResourceCounts->bGlobalConstantBufferUsed;
shader->mShaderName = shaderCode.findOptionalData('n');
return shader;
}
BoundShaderStateRHIRef D3D11DynamicRHI::RHICreateBoundShaderState(RHIVertexDeclaration* vertexDeclaration, RHIVertexShader* vertexShaderRHI, RHIHullShader* hullShaderRHI, RHIDomainShader* domainShaderRHI, RHIGeometryShader* geometryShaderRHI, RHIPixelShader* pixelShaderRHI)
{
BOOST_ASSERT(isInRenderingThread());
BOOST_ASSERT(GIsRHIInitialized && mD3D11Context);
CachedBoundShaderStateLink* cachedBoundShaderStateLink = getCachedBoundShaderState(vertexDeclaration, vertexShaderRHI, pixelShaderRHI, hullShaderRHI, domainShaderRHI, geometryShaderRHI);
if (cachedBoundShaderStateLink)
{
return cachedBoundShaderStateLink->mBoundShaderState;
}
else
{
return new D3D11BoundShaderState(vertexDeclaration, vertexShaderRHI, pixelShaderRHI, hullShaderRHI, domainShaderRHI, geometryShaderRHI, mD3D11Device);
}
}
#define TEST_HR(t) {hr = t;}
D3D11BoundShaderState::D3D11BoundShaderState(RHIVertexDeclaration* inVertexDeclarationRHI, RHIVertexShader* inVertexShaderRHI, RHIPixelShader* inPixelShaderRHI, RHIHullShader* inHullShaderRHI, RHIDomainShader* inDomainShaderRHI, RHIGeometryShader* inGeometryShaderRHI, ID3D11Device* direct3DDevice)
:mCachedLink(inVertexDeclarationRHI, inVertexShaderRHI, inPixelShaderRHI,inHullShaderRHI, inDomainShaderRHI, inGeometryShaderRHI, this)
{
D3D11VertexDeclaration* inVertexDeclaration = D3D11DynamicRHI::ResourceCast(inVertexDeclarationRHI);
D3D11VertexShader* inVertexShader = D3D11DynamicRHI::ResourceCast(inVertexShaderRHI);
D3D11PixelShader* inPixelShader = D3D11DynamicRHI::ResourceCast(inPixelShaderRHI);
D3D11HullShader* inHullShader = D3D11DynamicRHI::ResourceCast(inHullShaderRHI);
D3D11DomainShader* inDomainShader = D3D11DynamicRHI::ResourceCast(inDomainShaderRHI);
D3D11GeometryShader* inGeometryShader = D3D11DynamicRHI::ResourceCast(inGeometryShaderRHI);
D3D11_INPUT_ELEMENT_DESC nullInputElement;
Memory::memzero(&nullInputElement, sizeof(D3D11_INPUT_ELEMENT_DESC));
ShaderCodeReader vertexShaderCode(inVertexShader->mCode);
HRESULT hr;
TEST_HR(direct3DDevice->CreateInputLayout(inVertexDeclaration ? inVertexDeclaration->mVertexElements.data() : &nullInputElement, inVertexDeclaration ? inVertexDeclaration->mVertexElements.size() : 0, &inVertexShader->mCode[inVertexShader->mOffset], vertexShaderCode.getActualShaderCodeSize() - inVertexShader->mOffset, mInputLayout.getInitReference()), direct3DDevice);
mVertexShader = inVertexShader->mResource;
mPixelShader = inPixelShader->mResource;
mHullShader = inHullShader ? inHullShader->mResource : NULL;
mDomainShader = inDomainShader ? inDomainShader->mResource : NULL;
mGeometryShader = inGeometryShader ? inGeometryShader->mResource : NULL;
Memory::memzero(&bShaderNeedsGlobalUniformBuffer, sizeof(bShaderNeedsGlobalUniformBuffer));
bShaderNeedsGlobalUniformBuffer[SF_Vertex] = inVertexShader->bShaderNeedsGlobalConstantBuffer;
bShaderNeedsGlobalUniformBuffer[SF_Pixel] = inPixelShader->bShaderNeedsGlobalConstantBuffer;
bShaderNeedsGlobalUniformBuffer[SF_Hull] = inHullShader ? inHullShader->bShaderNeedsGlobalConstantBuffer : false;
bShaderNeedsGlobalUniformBuffer[SF_Domain] = inDomainShader ? inDomainShader->bShaderNeedsGlobalConstantBuffer : false;
bShaderNeedsGlobalUniformBuffer[SF_Geometry] = inGeometryShader ? inGeometryShader->bShaderNeedsGlobalConstantBuffer : false;
static_assert(ARRAY_COUNT(bShaderNeedsGlobalUniformBuffer) == SF_NumFrequencies, "EShaderFrequency size should match with array count of bShaderNeedsGlobalConstantBuffer.");
}
D3D11BoundShaderState::~D3D11BoundShaderState()
{
}
}
|
b48a3d5d6ddd2edceba3939a44f1cba5c0e22edc
|
bf2ba1f3ccd60ef2174afe6ef0809a420e569b2f
|
/controls/analisys/linechart/IncrementalPlot.h
|
c72ffffd846052ceb96ec895300f24d723ff462d
|
[] |
no_license
|
38277105/30GroundN
|
e2ec2bbc7c18acf1239487781a85629cfad53a03
|
ec44ecd3675387083c64aeb239ed7a8986dbb6d2
|
refs/heads/master
| 2023-08-21T05:35:36.823147
| 2021-10-29T06:03:50
| 2021-10-29T06:03:50
| 409,119,376
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,074
|
h
|
IncrementalPlot.h
|
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
/**
* @file
* @brief Defition of class IncrementalPlot
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef INCREMENTALPLOT_H
#define INCREMENTALPLOT_H
#include <QTimer>
#include <qwt_plot.h>
#include <qwt_legend.h>
#include <QMap>
#include "ChartPlot.h"
class QwtPlotCurve;
/**
* @brief Plot data container for growing data
*/
class CurveData
{
public:
CurveData();
void append(double *x, double *y, int count);
/** @brief The number of datasets held in the data structure */
int count() const;
/** @brief The reserved size of the data structure in units */
int size() const;
const double *x() const;
const double *y() const;
private:
int d_count;
QVector<double> d_x;
QVector<double> d_y;
};
/**
* @brief Incremental plotting widget
*
* This widget plots data incrementally when new data arrives.
* It will only repaint the minimum screen content necessary to avoid
* a too high CPU consumption. It auto-scales the plot to new data.
*/
class IncrementalPlot : public ChartPlot
{
Q_OBJECT
public:
/** @brief Create a new, empty incremental plot */
IncrementalPlot(QWidget *parent = NULL);
virtual ~IncrementalPlot();
/** @brief Get the state of the grid */
bool gridEnabled() const;
/** @brief Read out data from a curve */
int data(const QString &key, double* r_x, double* r_y, int maxSize);
public slots:
/** @brief Append one data point */
void appendData(const QString &key, double x, double y);
/** @brief Append multiple data points */
void appendData(const QString &key, double* x, double* y, int size);
/** @brief Reset the plot scaling to the default value */
void resetScaling();
/** @brief Update the plot scale based on current data/symmetric mode */
void updateScale();
/** @brief Remove all data from the plot and repaint */
void removeData();
/** @brief Show the plot legend */
void showLegend(bool show);
/** @brief Show the plot grid */
void showGrid(bool show);
/** @brief Set new plot style */
void setStyleText(const QString &style);
/** @brief Set symmetric axis scaling mode */
void setSymmetric(bool symmetric);
protected slots:
/** @brief Handle the click on a legend item */
void handleLegendClick(QwtPlotItem* item, bool on);
protected:
bool symmetric; ///< Enable symmetric plotting
QwtLegend* legend; ///< Plot legend
double xmin; ///< Minimum x value seen
double xmax; ///< Maximum x value seen
double ymin; ///< Minimum y value seen
double ymax; ///< Maximum y value seen
QString styleText; ///< Curve style set by setStyleText
private:
QMap<QString, CurveData* > d_data; ///< Data points
/** Helper function to apply styleText style to the given curve */
void updateStyle(QwtPlotCurve *curve);
};
#endif /* INCREMENTALPLOT_H */
|
76850ec728a013121fdd9876e845bf58f2b29b72
|
a5a99f646e371b45974a6fb6ccc06b0a674818f2
|
/Alignment/SurveyAnalysis/plugins/SurveyInputCSCfromPins.cc
|
861b9ca0af2f4283608d394722116d3a8c7a4851
|
[
"Apache-2.0"
] |
permissive
|
cms-sw/cmssw
|
4ecd2c1105d59c66d385551230542c6615b9ab58
|
19c178740257eb48367778593da55dcad08b7a4f
|
refs/heads/master
| 2023-08-23T21:57:42.491143
| 2023-08-22T20:22:40
| 2023-08-22T20:22:40
| 10,969,551
| 1,006
| 3,696
|
Apache-2.0
| 2023-09-14T19:14:28
| 2013-06-26T14:09:07
|
C++
|
UTF-8
|
C++
| false
| false
| 13,389
|
cc
|
SurveyInputCSCfromPins.cc
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "Alignment/CommonAlignment/interface/SurveyDet.h"
#include "Alignment/MuonAlignment/interface/AlignableMuon.h"
#include "Alignment/CommonAlignment/interface/AlignableNavigator.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "DataFormats/DetId/interface/DetId.h"
#include "Alignment/MuonAlignment/interface/AlignableCSCChamber.h"
#include "Alignment/MuonAlignment/interface/AlignableCSCStation.h"
#include <iostream>
#include <fstream>
#include "TFile.h"
#include "TTree.h"
#include "TRandom3.h"
#include "SurveyInputCSCfromPins.h"
#define SQR(x) ((x) * (x))
SurveyInputCSCfromPins::SurveyInputCSCfromPins(const edm::ParameterSet &cfg)
: DTGeoToken_(esConsumes()),
CSCGeoToken_(esConsumes()),
GEMGeoToken_(esConsumes()),
m_pinPositions(cfg.getParameter<std::string>("pinPositions")),
m_rootFile(cfg.getParameter<std::string>("rootFile")),
m_verbose(cfg.getParameter<bool>("verbose")),
m_errorX(cfg.getParameter<double>("errorX")),
m_errorY(cfg.getParameter<double>("errorY")),
m_errorZ(cfg.getParameter<double>("errorZ")),
m_missingErrorTranslation(cfg.getParameter<double>("missingErrorTranslation")),
m_missingErrorAngle(cfg.getParameter<double>("missingErrorAngle")),
m_stationErrorX(cfg.getParameter<double>("stationErrorX")),
m_stationErrorY(cfg.getParameter<double>("stationErrorY")),
m_stationErrorZ(cfg.getParameter<double>("stationErrorZ")),
m_stationErrorPhiX(cfg.getParameter<double>("stationErrorPhiX")),
m_stationErrorPhiY(cfg.getParameter<double>("stationErrorPhiY")),
m_stationErrorPhiZ(cfg.getParameter<double>("stationErrorPhiZ")) {}
void SurveyInputCSCfromPins::orient(align::LocalVector LC1,
align::LocalVector LC2,
double a,
double b,
double &T,
double &dx,
double &dy,
double &dz,
double &PhX,
double &PhZ) {
double cosPhX, sinPhX, cosPhZ, sinPhZ;
LocalPoint LP1(LC1.x(), LC1.y() + a, LC1.z() + b);
LocalPoint LP2(LC2.x(), LC2.y() - a, LC2.z() + b);
LocalPoint P((LP1.x() - LP2.x()) / (2. * a), (LP1.y() - LP2.y()) / (2. * a), (LP1.z() - LP2.z()) / (2. * a));
LocalPoint Pp((LP1.x() + LP2.x()) / (2.), (LP1.y() + LP2.y()) / (2.), (LP1.z() + LP2.z()) / (2.));
T = P.mag();
sinPhX = P.z() / T;
cosPhX = sqrt(1 - SQR(sinPhX));
cosPhZ = P.y() / (T * cosPhX);
sinPhZ = -P.x() / (T * cosPhZ);
PhX = atan2(sinPhX, cosPhX);
PhZ = atan2(sinPhZ, cosPhZ);
dx = Pp.x() - sinPhZ * sinPhX * b;
dy = Pp.y() + cosPhZ * sinPhX * b;
dz = Pp.z() - cosPhX * b;
}
void SurveyInputCSCfromPins::errors(double a,
double b,
bool missing1,
bool missing2,
double &dx_dx,
double &dy_dy,
double &dz_dz,
double &phix_phix,
double &phiz_phiz,
double &dy_phix) {
dx_dx = 0.;
dy_dy = 0.;
dz_dz = 0.;
phix_phix = 0.;
phiz_phiz = 0.;
dy_phix = 0.;
const double trials = 10000.; // two significant digits
for (int i = 0; i < trials; i++) {
LocalVector LC1, LC2;
if (missing1) {
LC1 = LocalVector(gRandom->Gaus(0., m_missingErrorTranslation),
gRandom->Gaus(0., m_missingErrorTranslation),
gRandom->Gaus(0., m_missingErrorTranslation));
} else {
LC1 = LocalVector(gRandom->Gaus(0., m_errorX), gRandom->Gaus(0., m_errorY), gRandom->Gaus(0., m_errorZ));
}
if (missing2) {
LC2 = LocalVector(gRandom->Gaus(0., m_missingErrorTranslation),
gRandom->Gaus(0., m_missingErrorTranslation),
gRandom->Gaus(0., m_missingErrorTranslation));
} else {
LC2 = LocalVector(gRandom->Gaus(0., m_errorX), gRandom->Gaus(0., m_errorY), gRandom->Gaus(0., m_errorZ));
}
double dx, dy, dz, PhX, PhZ, T;
orient(LC1, LC2, a, b, T, dx, dy, dz, PhX, PhZ);
dx_dx += dx * dx;
dy_dy += dy * dy;
dz_dz += dz * dz;
phix_phix += PhX * PhX;
phiz_phiz += PhZ * PhZ;
dy_phix += dy * PhX; // the only non-zero off-diagonal element
}
dx_dx /= trials;
dy_dy /= trials;
dz_dz /= trials;
phix_phix /= trials;
phiz_phiz /= trials;
dy_phix /= trials;
}
void SurveyInputCSCfromPins::analyze(const edm::Event &, const edm::EventSetup &iSetup) {
if (theFirstEvent) {
edm::LogInfo("SurveyInputCSCfromPins") << "***************ENTERING INITIALIZATION******************"
<< " \n";
std::ifstream in;
in.open(m_pinPositions.c_str());
Double_t x1, y1, z1, x2, y2, z2, a, b, tot = 0.0, maxErr = 0.0, h, s1, dx, dy, dz, PhX, PhZ, T;
int ID1, ID2, ID3, ID4, ID5, i = 1, ii = 0;
TFile *file1 = new TFile(m_rootFile.c_str(), "recreate");
TTree *tree1 = new TTree("tree1", "alignment pins");
if (m_verbose) {
tree1->Branch("displacement_x_pin1_cm", &x1, "x1/D");
tree1->Branch("displacement_y_pin1_cm", &y1, "y1/D");
tree1->Branch("displacement_z_pin1_cm", &z1, "z1/D");
tree1->Branch("displacement_x_pin2_cm", &x2, "x2/D");
tree1->Branch("displacement_y_pin2_cm", &y2, "y2/D");
tree1->Branch("displacement_z_pin2_cm", &z2, "z2/D");
tree1->Branch("error_vector_length_cm", &h, "h/D");
tree1->Branch("stretch_diff_cm", &s1, "s1/D");
tree1->Branch("stretch_factor", &T, "T/D");
tree1->Branch("chamber_displacement_x_cm", &dx, "dx/D");
tree1->Branch("chamber_displacement_y_cm", &dy, "dy/D");
tree1->Branch("chamber_displacement_z_cm", &dz, "dz/D");
tree1->Branch("chamber_rotation_x_rad", &PhX, "PhX/D");
tree1->Branch("chamber_rotation_z_rad", &PhZ, "PhZ/D");
}
const DTGeometry *dtGeometry = &iSetup.getData(DTGeoToken_);
const CSCGeometry *cscGeometry = &iSetup.getData(CSCGeoToken_);
const GEMGeometry *gemGeometry = &iSetup.getData(GEMGeoToken_);
AlignableMuon *theAlignableMuon = new AlignableMuon(dtGeometry, cscGeometry, gemGeometry);
AlignableNavigator *theAlignableNavigator = new AlignableNavigator(theAlignableMuon);
const auto &theEndcaps = theAlignableMuon->CSCEndcaps();
for (const auto &aliiter : theEndcaps) {
addComponent(aliiter);
}
while (in.good()) {
bool missing1 = false;
bool missing2 = false;
in >> ID1 >> ID2 >> ID3 >> ID4 >> ID5 >> x1 >> y1 >> z1 >> x2 >> y2 >> z2 >> a >> b;
if (fabs(x1 - 1000.) < 1e5 && fabs(y1 - 1000.) < 1e5 && fabs(z1 - 1000.) < 1e5) {
missing1 = true;
x1 = x2;
y1 = y2;
z1 = z2;
}
if (fabs(x2 - 1000.) < 1e5 && fabs(y2 - 1000.) < 1e5 && fabs(z2 - 1000.) < 1e5) {
missing2 = true;
x2 = x1;
y2 = y1;
z2 = z1;
}
x1 = x1 / 10.0;
y1 = y1 / 10.0;
z1 = z1 / 10.0;
x2 = x2 / 10.0;
y2 = y2 / 10.0;
z2 = z2 / 10.0;
CSCDetId layerID(ID1, ID2, ID3, ID4, 1);
// We cannot use chamber ID (when ID5=0), because AlignableNavigator gives the error (aliDet and aliDetUnit are undefined for chambers)
Alignable *theAlignable1 = theAlignableNavigator->alignableFromDetId(layerID);
Alignable *chamberAli = theAlignable1->mother();
LocalVector LC1 = chamberAli->surface().toLocal(GlobalVector(x1, y1, z1));
LocalVector LC2 = chamberAli->surface().toLocal(GlobalVector(x2, y2, z2));
orient(LC1, LC2, a, b, T, dx, dy, dz, PhX, PhZ);
GlobalPoint PG1 = chamberAli->surface().toGlobal(LocalPoint(LC1.x(), LC1.y() + a, LC1.z() + b));
chamberAli->surface().toGlobal(LocalPoint(LC2.x(), LC2.y() - a, LC2.z() + b));
LocalVector lvector(dx, dy, dz);
GlobalVector gvector = (chamberAli->surface()).toGlobal(lvector);
chamberAli->move(gvector);
chamberAli->rotateAroundLocalX(PhX);
chamberAli->rotateAroundLocalZ(PhZ);
double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
errors(a, b, missing1, missing2, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
align::ErrorMatrix error = ROOT::Math::SMatrixIdentity();
error(0, 0) = dx_dx;
error(1, 1) = dy_dy;
error(2, 2) = dz_dz;
error(3, 3) = phix_phix;
error(4, 4) = m_missingErrorAngle;
error(5, 5) = phiz_phiz;
error(1, 3) = dy_phix;
error(3, 1) = dy_phix; // just in case
chamberAli->setSurvey(new SurveyDet(chamberAli->surface(), error));
if (m_verbose) {
edm::LogInfo("SurveyInputCSCfromPins") << " survey information = " << chamberAli->survey() << " \n";
LocalPoint LP1n = chamberAli->surface().toLocal(PG1);
LocalPoint hiP(LP1n.x(), LP1n.y() - a * T, LP1n.z() - b);
h = hiP.mag();
s1 = LP1n.y() - a;
if (h > maxErr) {
maxErr = h;
ii = i;
}
edm::LogInfo("SurveyInputCSCfromPins")
<< " \n"
<< "i " << i++ << " " << ID1 << " " << ID2 << " " << ID3 << " " << ID4 << " " << ID5 << " error " << h
<< " \n"
<< " x1 " << x1 << " y1 " << y1 << " z1 " << z1 << " x2 " << x2 << " y2 " << y2 << " z2 " << z2 << " \n"
<< " error " << h << " S1 " << s1 << " \n"
<< " dx " << dx << " dy " << dy << " dz " << dz << " PhX " << PhX << " PhZ " << PhZ << " \n";
tot += h;
tree1->Fill();
}
}
in.close();
if (m_verbose) {
file1->Write();
edm::LogInfo("SurveyInputCSCfromPins")
<< " Total error " << tot << " Max Error " << maxErr << " N " << ii << " \n";
}
file1->Close();
for (const auto &aliiter : theEndcaps) {
fillAllRecords(aliiter);
}
delete theAlignableMuon;
delete theAlignableNavigator;
edm::LogInfo("SurveyInputCSCfromPins") << "*************END INITIALIZATION***************"
<< " \n";
theFirstEvent = false;
}
}
void SurveyInputCSCfromPins::fillAllRecords(Alignable *ali) {
if (ali->survey() == nullptr) {
AlignableCSCChamber *ali_AlignableCSCChamber = dynamic_cast<AlignableCSCChamber *>(ali);
AlignableCSCStation *ali_AlignableCSCStation = dynamic_cast<AlignableCSCStation *>(ali);
if (ali_AlignableCSCChamber != nullptr) {
CSCDetId detid(ali->geomDetId());
if (abs(detid.station()) == 1 && (detid.ring() == 1 || detid.ring() == 4)) {
align::ErrorMatrix error = ROOT::Math::SMatrixIdentity();
error(0, 0) = m_missingErrorTranslation;
error(1, 1) = m_missingErrorTranslation;
error(2, 2) = m_missingErrorTranslation;
error(3, 3) = m_missingErrorAngle;
error(4, 4) = m_missingErrorAngle;
error(5, 5) = m_missingErrorAngle;
ali->setSurvey(new SurveyDet(ali->surface(), error));
} else {
double a = 100.;
double b = -9.4034;
if (abs(detid.station()) == 1 && detid.ring() == 2)
a = -90.260;
else if (abs(detid.station()) == 1 && detid.ring() == 3)
a = -85.205;
else if (abs(detid.station()) == 2 && detid.ring() == 1)
a = -97.855;
else if (abs(detid.station()) == 2 && detid.ring() == 2)
a = -164.555;
else if (abs(detid.station()) == 3 && detid.ring() == 1)
a = -87.870;
else if (abs(detid.station()) == 3 && detid.ring() == 2)
a = -164.555;
else if (abs(detid.station()) == 4 && detid.ring() == 1)
a = -77.890;
double dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix;
errors(a, b, true, true, dx_dx, dy_dy, dz_dz, phix_phix, phiz_phiz, dy_phix);
align::ErrorMatrix error = ROOT::Math::SMatrixIdentity();
error(0, 0) = dx_dx;
error(1, 1) = dy_dy;
error(2, 2) = dz_dz;
error(3, 3) = phix_phix;
error(4, 4) = m_missingErrorAngle;
error(5, 5) = phiz_phiz;
error(1, 3) = dy_phix;
error(3, 1) = dy_phix; // just in case
ali->setSurvey(new SurveyDet(ali->surface(), error));
}
}
else if (ali_AlignableCSCStation != nullptr) {
align::ErrorMatrix error = ROOT::Math::SMatrixIdentity();
error(0, 0) = m_stationErrorX;
error(1, 1) = m_stationErrorY;
error(2, 2) = m_stationErrorZ;
error(3, 3) = m_stationErrorPhiX;
error(4, 4) = m_stationErrorPhiY;
error(5, 5) = m_stationErrorPhiZ;
ali->setSurvey(new SurveyDet(ali->surface(), error));
}
else {
align::ErrorMatrix error = ROOT::Math::SMatrixIdentity();
ali->setSurvey(new SurveyDet(ali->surface(), error * (1e-10)));
}
}
for (const auto &iter : ali->components()) {
fillAllRecords(iter);
}
}
// Plug in to framework
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(SurveyInputCSCfromPins);
|
caab279a75371a0762b3ddcb105470ebed90f622
|
00fbd04b404e5aae9c1edb1ea3df68675e109867
|
/Server/beaconshandler.cpp
|
cff9fb25b1469856a6f87f774ed01e4c23ee7322
|
[] |
no_license
|
ShellCode33/Aral
|
2f533fa93e67a424abde3cae0a5311776c33bd21
|
1ab94eb2c7d0b8c263b7634ad18f91ef2fe19cf6
|
refs/heads/master
| 2021-09-02T10:42:33.013204
| 2018-01-02T00:44:16
| 2018-01-02T00:44:16
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,529
|
cpp
|
beaconshandler.cpp
|
#include "beaconshandler.h"
using namespace std;
BeaconsHandler::BeaconsHandler(ClientsHandler &clients_handler) : Server(UDP), _clients_handler(clients_handler)
{
}
string BeaconsHandler::receive_string()
{
char buffer[BUFFER_SIZE];
memset(buffer, 0, BUFFER_SIZE);
struct sockaddr_in sender;
memset(&sender, 0, sizeof(struct sockaddr_in));
socklen_t c = sizeof(sender);
int bytes_received = recvfrom(_serv_sock, buffer, BUFFER_SIZE-1, 0, (struct sockaddr*)&sender, &c); //On essaye de lire BUFFER_SIZE octets sur le socket
if(bytes_received <= 0) {
cerr << "socket error" << endl;
return "";
}
return string(buffer);
}
void BeaconsHandler::run()
{
cout << "BeaconsHandler looping..." << endl;
while(true)
{
string boat_string = receive_string();
if(boat_string.length() > 0)
{
Boat *boat_received = Boat::create(boat_string); //On crée un bateau à partir de la chaine de carac que l'on recoit
Boat *boat_to_update = nullptr;
for(Boat *boat : _boats)
{
if(boat->getName() == boat_received->getName())
{
boat_to_update = boat;
break;
}
}
if(boat_to_update != nullptr)
{
cout << boat_received->getName() << " updated" << endl;
cout << boat_received->capToString() << endl;
boat_to_update->setCap(boat_received->getVdirection(), boat_received->getHdirection());
boat_to_update->setLocation(boat_received->getLatitude(), boat_received->getLongitude());
boat_to_update->setTime(boat_received->getLastTimeReceiving());
cout << "sending : " << boat_to_update->toString() << " to clients !" << endl;
for(Client *client : _clients_handler.getClients())
{
_clients_handler.send_packet_to(client, BOAT_UPDATED);
_clients_handler.send_string_to(client, boat_to_update->toString());
}
}
else
{
_boats.push_back(boat_received);
for(Client *client : _clients_handler.getClients())
{
_clients_handler.send_packet_to(client, BOAT_CREATED);
_clients_handler.send_string_to(client, boat_received->toString());
}
}
}
}
}
|
ac05dc3a18cda1eb26edcdc91f2f3745abd68221
|
ffda80bd2f906bd0766ad68aeadd39d202f82925
|
/include/cbt/nodes/context_t.hpp
|
b0e74ad0cd7865a010db3f8ba416b56b8022a425
|
[] |
no_license
|
taiyu-len/continuation-behavior-tree
|
9f4690778324d0aa9d07f116151f01f4a51e5f9b
|
d0b52c2fd8ac24e3faa7fa29cbe8cbc83d85a963
|
refs/heads/master
| 2020-04-08T14:49:19.734927
| 2018-12-14T02:07:21
| 2018-12-14T02:30:48
| 159,453,329
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,472
|
hpp
|
context_t.hpp
|
#ifndef CBT_NODES_CONTEXT_T_HPP
#define CBT_NODES_CONTEXT_T_HPP
#include "cbt/behavior.hpp"
#include <memory>
namespace cbt
{
namespace detail
{
template<typename T, typename F>
struct context_type
{
auto operator()() noexcept -> status;
static auto make(F) -> context_result<T>;
private:
context_type(F&& f): _reset(std::move(f)) {}
T _value;
F _reset;
};
template<typename T, typename F>
auto context_type<T, F>::operator()() noexcept -> status
{
try { _reset(_value); }
catch (...) { return status::failure; }
return status::success;
}
template<typename T, typename F>
auto context_type<T, F>::make(F x) -> context_result<T>
{
auto tree = behavior{ context_type{std::move(x)} };
auto *p = std::addressof(tree.get<context_type>()._value);
return {
std::move(tree),
p
};
}
template<typename T, typename F>
using context_t = context_type<std::decay_t<T>, std::decay_t<F>>;
} // detail
template<typename T, typename F>
auto context(F&& f) -> context_result<T>
{
constexpr bool x = std::is_invocable<F, T&>::value;
if constexpr (x)
{
return detail::context_t<T, F>::make(std::forward<F>(f));
}
else
{
static_assert(x, "context called with invalid initialization function");
static_assert(x, "F is not invocable as void(T)");
}
}
template<typename T>
auto context() -> context_result<T>
{
auto reset = +[](T& p){ p = T{}; };
return detail::context_t<T, decltype(reset)>::make(reset);
}
} // namespace cbt
#endif // CBT_NODES_CONTEXT_T_HPP
|
d2018c075fa730e46ca2d001c3838751afef7920
|
d5ce8cddb5d54d9c2b90f8d52ec3fd3499a51334
|
/ELSys/TextManager.cpp
|
5786575b0f9ebf0f073048faa85403b9062facd6
|
[] |
no_license
|
Elaviers/ELLib
|
7a9adb92da1d96df9cc28f935be62e48bb98fb5b
|
3c5d36d2d19438d32e9cf44fe5efeacb46aca51c
|
refs/heads/master
| 2023-05-30T21:50:28.327148
| 2021-07-05T16:42:39
| 2021-07-05T16:42:39
| 286,592,944
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 467
|
cpp
|
TextManager.cpp
|
#include "TextManager.hpp"
TextProvider* TextManager::_CreateResource(const Array<byte>& data, const String& name, const String& extension, const Context& ctx)
{
TextProvider* provider = new TextProvider();
provider->Set(String(data.begin(), data.GetSize()));
return provider;
}
void TextManager::_ResourceRead(TextProvider& provider, const Array<byte>& data, const String& extension, const Context& ctx)
{
provider.Set(String(data.begin(), data.GetSize()));
}
|
7b3a8d5868aa69b80bbc744312ea3b9d69637f1b
|
ef5504db423f7b0258d8bdefacb12236d76f2bb6
|
/src/ztools/collect_matchine_info/collect_matchine_info_main.cpp
|
f2aa4aa7d8f4d618f8a1bece0b7da7435b6e1d4a
|
[] |
no_license
|
tafchain/vprotocol
|
cc0fc6f7453072a6941af761bb79f1a33dca6127
|
bd2b5b83046d8af7746617a130fb56be230ce4cc
|
refs/heads/master
| 2023-06-02T12:44:19.228025
| 2021-06-17T07:49:42
| 2021-06-17T07:49:42
| 377,747,826
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 437
|
cpp
|
collect_matchine_info_main.cpp
|
#include "ace/OS_main.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_time.h"
#include "dsc/dsc_license.h"
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
CDscLicense rLicense;
CDscString strHardware;
if( rLicense.getMatchineStr(strHardware) )
{
ACE_OS::printf("get local identifier failed!\n");
return -1;
}
ACE_OS::printf("matchine info:<%s>\n",strHardware.c_str());
return 0;
}
|
9e22d953f5b24909c8583725c8410250b9e21824
|
5437b207e5a4dd21acb2ea4254cb136afc58446d
|
/desiredSpeedCalculator.cpp
|
90264ea1bf4de98baee64953278191102419790f
|
[] |
no_license
|
KyleBjornson/sysc5104_a1
|
90e0d2730e7ea31f29f9b54b33e3e4190550f263
|
0a1e4c904700070fd7bd3f3c063746b4754ccad3
|
refs/heads/master
| 2020-04-03T03:45:02.093477
| 2018-11-03T01:54:23
| 2018-11-03T01:54:23
| 154,994,512
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 13,133
|
cpp
|
desiredSpeedCalculator.cpp
|
/*******************************************************************
*
* DESCRIPTION: Atomic Model desiredSpeedCalculator
*
* AUTHORS: Ben Earle, Kyle Bjornson
*
* EMAIL: ben.earle@cmail.carleton.ca, kyle.bjornson@cmail.carleton.ca
*
* DATE: November 2nd, 2018
*
*******************************************************************/
/** include files **/
#include "desiredSpeedCalculator.h" // class DesiredSpeedCalculator
#include "message.h" // class ExternalMessage, InternalMessage
#include "mainsimu.h" // MainSimulator::Instance().getParameter( ... )
#include <math.h> //sqrt
#define DEBUG 0
#define SUPRESS_ODO 1
#define TYPE_MASK(msg) ((msg >> 14) & 0x0003)
#define VALUE_MASK(msg) ((msg >> 9) & 0x001F)
#define DISTANCE_MASK(msg) (msg & 0x1FF)
/** public functions **/
/*******************************************************************
* Function Name: DesiredSpeedCalculator
********************************************************************/
DesiredSpeedCalculator::DesiredSpeedCalculator( const string &name )
: Atomic( name )
, leftRangeIn( addInputPort( "leftRangeIn" ) )
, centerRangeIn( addInputPort( "centerRangeIn" ) )
, rightRangeIn( addInputPort( "rightRangeIn" ) )
, speedIn( addInputPort( "speedIn" ) )
, odometerIn( addInputPort( "odometerIn" ) )
, infrastructureIn( addInputPort( "infrastructureIn" ) )
, desiredSpeedReachedIn( addInputPort( "desiredSpeedReachedIn" ) )
, desiredSpeedOut( addOutputPort( "desiredSpeedOut" ) )
{
leftRange = 0;
centerRange = 0;
rightRange = 0;
speedLimit = 0;
odometer = 0;
emergencySpeed.value = 0;
emergencySpeed.distance = 0;
desiredSpeed.value = 0;
desiredSpeed.distance = 0;
speed = 0;
nextSign.type = NONE;
}
/*******************************************************************
* Function Name: initFunction
********************************************************************/
Model &DesiredSpeedCalculator::initFunction() {
this-> passivate();
return *this ;
}
/*******************************************************************
* Function Name: externalFunction
********************************************************************/
//The desired speed calc is not very good, we need more logic to smooth the handling of obstacles in its path.
//We ran out of time on the assignment and didn't get to play around with this too much.
//We hope to improve it in the future.
Model &DesiredSpeedCalculator::externalFunction( const ExternalMessage &msg ) {
if( msg.port() == leftRangeIn) {
leftRange = float(msg.value());
if (this->state() == passive) {
passivate();
} else {
holdIn(active, nextChange());
}
} else if( msg.port() == centerRangeIn) {
centerRange = float(msg.value());
#if DEBUG
std::cout << "There is an update to the center range: " << centerRange <<"\n";
#endif
//float brakingDistance = ((speed < desiredSpeed.value) ? (desiredSpeed.value) : (speed))^2/200;
float brakingDistance = speed*speed/200;
if(centerRange <= 2) {
#if DEBUG
std::cout << "There is an obstacle in close range.\n";
#endif
emergencySpeed.value = 0;
emergencySpeed.distance = 1;
holdIn(active, Time::Zero);
} else if (centerRange < (brakingDistance + 2)){
#if DEBUG
std::cout << "There is an obstacle within risk of collision.\n";
#endif
emergencySpeed.value = 0;
emergencySpeed.distance = centerRange;
holdIn(active, Time::Zero);
} else if (centerRange < (brakingDistance + 10)){
#if DEBUG
std::cout << "There is an obstacle close to being considered a risk.\n";
#endif
emergencySpeed.value = sqrt(200*(centerRange - 2)) ;//-2 since that is our buffer region
emergencySpeed.distance = 10;
holdIn(active, Time::Zero);
} else if (emergencySpeed.value != 0 || emergencySpeed.distance != 0) {
#if DEBUG
std::cout << "There are no obstacles that are within risk of collision.\n";
std::cout << "The return to infrastructure control: " << nextSign.type << ", " << nextSign.value << ", "<< nextSign.distance << "\n";
#endif
emergencySpeed.value = 0;
emergencySpeed.distance = 0;
switch(nextSign.type) {
case NONE:
desiredSpeed.value = speedLimit;
desiredSpeed.distance = ACCELERATE_DISTANCE;
break;
case STOP:
desiredSpeed.value = 0;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
case YIELD:
desiredSpeed.value = YIELD_SPEED;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
case SPEED:
desiredSpeed.value = nextSign.value;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
default:
break;
}
holdIn(active, Time::Zero);
} else if (this->state() == passive) {
passivate();
} else {
/* Should only happen if stopped at an intersection, wait until timeout */
holdIn(active, nextChange());
}
} else if( msg.port() == rightRangeIn) {
rightRange = float(msg.value());
if (this->state() == passive) {
passivate();
} else {
holdIn(active, nextChange());
}
} else if (msg.port() == speedIn) {
#if DEBUG
std::cout << "Got speedIn " << float(msg.value()) <<"\n";
#endif
speed = float(msg.value());
float brakingDistance = speed*speed/200;
if(centerRange <= 2) {
#if DEBUG
std::cout << "There is an obstacle in close range.\n";
#endif
emergencySpeed.value = 0;
emergencySpeed.distance = 1;
holdIn(active, Time::Zero);
} else if (centerRange < (brakingDistance + 2)){
#if DEBUG
std::cout << "There is an obstacle within risk of collision.\n";
#endif
emergencySpeed.value = 0;
emergencySpeed.distance = centerRange;
holdIn(active, Time::Zero);
} else if (centerRange < (brakingDistance + 10)){
#if DEBUG
std::cout << "There is an obstacle close to being considered a risk.\n";
#endif
emergencySpeed.value = sqrt(200*(centerRange - 2));
emergencySpeed.distance = 10;
holdIn(active, Time::Zero);
} else if (emergencySpeed.value != 0 || emergencySpeed.distance != 0) {
#if DEBUG
std::cout << "There are no obstacles that are within risk of collision.\n";
std::cout << "The return to infrastructure control: " << nextSign.type << ", " << nextSign.value << ", "<< nextSign.distance << "\n";
#endif
emergencySpeed.value = 0;
emergencySpeed.distance = 0;
switch(nextSign.type) {
case NONE:
desiredSpeed.value = speedLimit;
desiredSpeed.distance = ACCELERATE_DISTANCE;
break;
case STOP:
desiredSpeed.value = 0;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
case YIELD:
desiredSpeed.value = YIELD_SPEED;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
case SPEED:
desiredSpeed.value = nextSign.value;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
default:
break;
}
holdIn(active, Time::Zero);
} else {
holdIn(active, nextChange());
}
} else if (msg.port() == odometerIn) {
odometer = float(msg.value());
#if DEBUG & !SUPRESS_ODO
std::cout << "Got odometerIn " << float(msg.value()) <<"\n";
#endif
if (this->state() == passive) {
if(emergencySpeed.value == 0 && emergencySpeed.distance == 0 && odometer == nextSign.distance) {
holdIn(active, Time::Zero);
} else {
passivate();
}
} else {
holdIn(active, nextChange());
}
} else if (msg.port() == infrastructureIn) {
unsigned long temp = msg.value();
#if DEBUG
std::cout << "Got infrastructureIn " << temp <<"\n";
#endif
if (this->state() == passive) {
int x = TYPE_MASK(temp);
nextSign.type = ((x == 0) ? NONE : ((x == 2) ? STOP : ((x == 1) ? YIELD : SPEED))); //top 2 bits are used for type
nextSign.value = VALUE_MASK(temp) *5; //next 5 for the value if needed (in km/5hr to preserve bits)
nextSign.distance = DISTANCE_MASK(temp); //distance in m using the remianing bits
nextSign.distance += odometer;
#if DEBUG
std::cout << "The msg contents are: " << nextSign.type << ", " << nextSign.value << ", "<< nextSign.distance << "\n";
#endif
switch(nextSign.type) {
case NONE:
desiredSpeed.value = speedLimit;
desiredSpeed.distance = ACCELERATE_DISTANCE;
break;
case STOP:
desiredSpeed.value = 0;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
case YIELD:
desiredSpeed.value = YIELD_SPEED;
desiredSpeed.distance = (nextSign.distance - odometer);
break;
case SPEED:
speedLimit = nextSign.value;
desiredSpeed.value = nextSign.value;
desiredSpeed.distance = (nextSign.distance - odometer);
#if DEBUG
std::cout << "Setting the new speed limit: " << desiredSpeed.value << "\n";
#endif
break;
default:
break;
}
holdIn(active, Time::Zero);
} else {
holdIn(active, nextChange());
}
} else if (msg.port() == desiredSpeedReachedIn) {
#if DEBUG
std::cout << "We reached the desired speed: " << speed << "\n";
#endif
if(emergencySpeed.value != 0 || emergencySpeed.distance != 0) {
#if DEBUG
std::cout << "Speed was being controlled by LiDAR, wait until the path is clear " << "\n";
#endif
/* IF the lidar obstacle detection is controlling the car, wait until path is clear */
passivate();
} else {
#if DEBUG
std::cout << "Speed was being controlled by infrastructure. Next Sign: " << nextSign.type << ", " << nextSign.value << ", "<< nextSign.distance << ", speed: " << speed << "\n";
#endif
switch(nextSign.type) {
case NONE:
/*Should never happen */
break;
case STOP:
if(leftRange > STOP_DISTANCE && rightRange > STOP_DISTANCE && centerRange > STOP_DISTANCE) {
/* The intersection is clear, continue driving */
desiredSpeed.value = speedLimit;
desiredSpeed.distance = ACCELERATE_DISTANCE;
nextSign.type = NONE;
holdIn(active, Time::Zero);
} else {
holdIn(active, WAIT_TIMEOUT);
}
break;
case YIELD:
if(leftRange > YIELD_DISTANCE && rightRange > YIELD_DISTANCE && centerRange > YIELD_DISTANCE) {
/* The intersection is clear, continue driving */
desiredSpeed.value = speedLimit;
desiredSpeed.distance = ACCELERATE_DISTANCE;
nextSign.type = NONE;
holdIn(active, Time::Zero);
} else if (desiredSpeed.value != 0){
desiredSpeed.value = 0;
desiredSpeed.distance = 1;
holdIn(active, Time::Zero);
} else {
holdIn(active, WAIT_TIMEOUT);
}
break;
case SPEED:
nextSign.type = NONE;
passivate();
break;
default:
break;
}
}
}
return *this;
}
/*******************************************************************
* Function Name: internalFunction
********************************************************************/
Model &DesiredSpeedCalculator::internalFunction( const InternalMessage & ){
if(emergencySpeed.value != 0 || emergencySpeed.distance != 0) {
/* IF the lidar obstical detection is controlling the car, wait until path is clear */
passivate();
} else {
switch(nextSign.type) {
case NONE:
/*Occurs if @ a clear stop or yield sign */
passivate();
break;
case STOP:
if(leftRange > STOP_DISTANCE && rightRange > STOP_DISTANCE && centerRange > STOP_DISTANCE && (nextSign.distance <= odometer) ) {
/* The intersection is clear, continue driving */
desiredSpeed.value = speedLimit;
desiredSpeed.distance = ACCELERATE_DISTANCE;
nextSign.type = NONE;
holdIn(active, Time::Zero);
} else {
holdIn(active, WAIT_TIMEOUT);
}
break;
case YIELD:
if(leftRange > YIELD_DISTANCE && rightRange > YIELD_DISTANCE && centerRange > YIELD_DISTANCE && (nextSign.distance <= odometer) ) {
/* The intersection is clear, continue driving */
desiredSpeed.value = speedLimit;
desiredSpeed.distance = ACCELERATE_DISTANCE;
nextSign.type = NONE;
holdIn(active, Time::Zero);
} else {
holdIn(active, WAIT_TIMEOUT);
}
break;
case SPEED:
passivate();
break;
default:
break;
}
}
return *this ;
}
/*******************************************************************
* Function Name: outputFunction
********************************************************************/
Model &DesiredSpeedCalculator::outputFunction( const InternalMessage &msg) {
int out;
if(emergencySpeed.value != 0 || emergencySpeed.distance != 0) {
#if DEBUG
std::cout << "Sending new emergency speed " << emergencySpeed.value << "\n";
#endif
if(emergencySpeed.distance > 0x1FF) emergencySpeed.distance =0x1FFF;
if(emergencySpeed.value > 0x7F) emergencySpeed.value =0x7F;
out = ((emergencySpeed.value & 0x7F) << 9) + (emergencySpeed.distance & 0x1FF);
sendOutput( msg.time(), desiredSpeedOut, out);
} else {
#if DEBUG
std::cout << "Sending new desired speed " << desiredSpeed.value << "\n";
#endif
if(desiredSpeed.distance > 0x1FF) desiredSpeed.distance =0x1FFF;
if(desiredSpeed.value > 0x7F) desiredSpeed.value =0x7F;
out = ((desiredSpeed.value & 0x7F) << 9) + (desiredSpeed.distance & 0x1FF);
sendOutput( msg.time(), desiredSpeedOut, out);
}
return *this ;
}
|
9f2b5e6b9b579ac297ce8db8420d7de9a13e39a8
|
00dbe4fd5f00fab51f959fdf32ddb185daa8de30
|
/P516.cpp
|
ceab8c578157c0067c1e44117ee5dd8824158bb3
|
[] |
no_license
|
LasseD/uva
|
c02b21c37700bd6f43ec91e788b2787152bfb09b
|
14b62742d3dfd8fb55948b2682458aae676e7c14
|
refs/heads/master
| 2023-01-29T14:51:42.426459
| 2023-01-15T09:29:47
| 2023-01-15T09:29:47
| 17,707,082
| 3
| 4
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,369
|
cpp
|
P516.cpp
|
#include <iostream>
#include <stdio.h>
#define PRIME_LEN 16400
class PrimeHandler {
bool primes[PRIME_LEN];
public:
void init() {
for(int i = 0; i < PRIME_LEN; ++i)
primes[i] = true;
// Sieve primes:
for(int i = 0; i*i < PRIME_LEN; ++i) {
if(!primes[i])
continue;
// Mark all uneven multiples as non-prime:
int basePrime = 1+2*(i+1);
for(int multiple = 3; true; multiple += 2) {
int notAPrime = basePrime*multiple;
int notAPrimeI = notAPrime/2-1;
if(notAPrimeI >= PRIME_LEN)
break;
primes[notAPrimeI] = false;
}
}
}
bool isPrime(long n) const {
if(n == 2)
return true;
if(n < 2 || (n%2==0))
return false;
return primes[n/2-1];
}
int nextPrime(int n) const {
int ni = n/2;
while(!primes[ni]) {
++ni;
}
return 1+(ni+1)*2;
}
int prevPrime(int n) const {
int ni = n/2-2;
while(!primes[ni])
--ni;
return 1+(ni+1)*2;
}
};
bool readInt(char *w, int &pos, int &a) {
a = 0;
char c;
while(isprint(c = w[pos++])) {
if(c >= '0' && c <= '9')
a = 10*a+(c-'0');
else if(a != 0)
return true;
}
return false;
}
int slowExp(int p, int e) {
int ret = 1;
for(int i = 0; i < e; ++i)
ret*=p;
return ret;
}
int main() {
// Compute prime numbers:
PrimeHandler ph;
ph.init();
int p, e;
char w[1000];
while(true) {
// Compute n:
gets(w);
int n = 1;
int pos = 0;
readInt(w, pos, p);
if(p == 0)
return 0;
while(true) {
bool go = readInt(w, pos, e);
n *= slowExp(p, e);
if(!go)
break;
readInt(w, pos, p);
}
// Subtract one:
//std::cerr << "For n=" << n << " outputting n-1 = " << (n-1) << std::endl;
--n;
// Output new value:
int prime = n % 2 == 0 ? n+1 : n;
prime = ph.nextPrime(prime);
bool first = true;
while(prime >= 3) {
int times = 0;
while(n % prime == 0) {
n /= prime;
++times;
}
if(times > 0) {
if(!first)
std::cout << " ";
first = false;
std::cout << prime << " " << times;
}
prime = ph.prevPrime(prime);
}
int times2 = 0;
while(n % 2 == 0) {
n /= 2;
++times2;
}
if(times2 > 0) {
if(!first)
std::cout << " ";
std::cout << 2 << " " << times2;
}
std::cout << std::endl;
}
}
|
a4869b8659fdecfe3aec904e8e8f097222ecdc69
|
c8cb134531c883d7c389fecee63a99f67f19bc8a
|
/dstream/dsmain/DSFrame.cpp
|
ec45d200d9b70b736c8735860c9ddc9fac42ef54
|
[
"MIT"
] |
permissive
|
renzbagaporo/depthstream
|
ddced4bb41f9144b7dfcccc1dc92efae7b65b9df
|
9ad0febf3e7c0af5ccfbdca2746ce24b353c76a1
|
refs/heads/master
| 2021-01-10T23:05:42.019805
| 2017-12-22T10:48:45
| 2017-12-22T10:48:45
| 115,082,722
| 12
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,773
|
cpp
|
DSFrame.cpp
|
#include "DSFrame.h"
DSFrame::DSFrame(){}
DSFrame::~DSFrame(){}
DSFrame::DSFrame(const cv::String &left_frame_path, const cv::String &right_frame_path){
this->left_frame = cv::imread(left_frame_path);
this->right_frame = cv::imread(right_frame_path);
if (!(left_frame.data && right_frame.data)) throw DSException(stereo_exceptions::IO_ERROR);
if (!(this->left_frame.rows == this->right_frame.rows && this->left_frame.cols == this->right_frame.cols)) throw DSException(stereo_exceptions::SIZE_ERROR);
this->height = (this->left_frame.rows + this->right_frame.rows) / 2;
this->width = (this->left_frame.cols + this->right_frame.cols) / 2;
}
DSFrame::DSFrame(const cv::String &left_frame_path, const cv::String &right_frame_path, DSRectifier rectifier){
this->left_frame = cv::imread(left_frame_path);
this->right_frame = cv::imread(right_frame_path);
if (!(left_frame.data && right_frame.data)) throw DSException(stereo_exceptions::IO_ERROR);
if (!(this->left_frame.rows == this->right_frame.rows && this->left_frame.cols == this->right_frame.cols)) throw DSException(stereo_exceptions::SIZE_ERROR);
this->height = (this->left_frame.rows + this->right_frame.rows) / 2;
this->width = (this->left_frame.cols + this->right_frame.cols) / 2;
if (!(this->height == rectifier.get_height() && this->width == rectifier.get_width())) throw DSException(stereo_exceptions::SIZE_ERROR);
rectifier.rectify(this->left_frame, this->right_frame);
}
DSFrame::DSFrame(cv::Mat left_frame, cv::Mat right_frame){
this->left_frame = left_frame.clone();
this->right_frame = right_frame.clone();
if (!(this->left_frame.data && this->right_frame.data)) throw DSException(stereo_exceptions::IO_ERROR);
if (!(this->left_frame.rows == this->right_frame.rows && this->left_frame.cols == this->right_frame.cols)) throw DSException(stereo_exceptions::SIZE_ERROR);
this->height = (this->left_frame.rows + this->right_frame.rows) / 2;
this->width = (this->left_frame.cols + this->right_frame.cols) / 2;
}
DSFrame::DSFrame(cv::Mat left_frame, cv::Mat right_frame, DSRectifier rectifier){
this->left_frame = left_frame.clone();
this->right_frame = right_frame.clone();
if (!(this->left_frame.data && this->right_frame.data)) throw DSException(stereo_exceptions::IO_ERROR);
if (!(this->left_frame.rows == this->right_frame.rows && this->left_frame.cols == this->right_frame.cols)) throw DSException(stereo_exceptions::SIZE_ERROR);
this->height = (this->left_frame.rows + this->right_frame.rows) / 2;
this->width = (this->left_frame.cols + this->right_frame.cols) / 2;
if (!(this->height == rectifier.get_height() && this->width == rectifier.get_width())) throw DSException(stereo_exceptions::SIZE_ERROR);
rectifier.rectify(this->left_frame, this->right_frame);
}
|
cf8166c009e8ad379852f5a324e84e9e46dd65e0
|
53c4c607786fd3e5b33ed34e9e54c331f1902523
|
/hh/xlib/src/mysql2/DBConnect.cpp
|
3945fb82c5fae40692c94494af1356391c36e480
|
[] |
no_license
|
thereisnoposible/Shared
|
7057d30de955900cf4c7dc706c9f619c57914469
|
a7fdfb0cefed951609cb288a2e3be3f24cbedde4
|
refs/heads/master
| 2020-12-03T10:38:47.042091
| 2018-03-13T08:38:16
| 2018-03-13T08:38:16
| 68,799,603
| 0
| 1
| null | null | null | null |
GB18030
|
C++
| false
| false
| 3,763
|
cpp
|
DBConnect.cpp
|
#include "../include/mysql2/DBConnect.h"
#include "../include/mysql2/DBInterface.h"
#include "../include/mysql2/DBService2.h"
namespace xlib
{
//--------------------------------------------------------------------
DBConnect::DBConnect(const char* host, const char* user, const char* passwd, const char* db,
int32 port, const char* charset, int32 flag, LogService2* p)
: m_bQuit(false)
{
m_pDBInterface = new DBInterface();
bool b = m_pDBInterface->open(host, user, passwd, db, port, charset, flag);
if (b)
{//发起工作线程
m_pThread = new boost::thread(boost::bind(&DBConnect::workThreadFun, this));
}
else
{
//抛出异常
throw("DBConnect error,Can not connect database!");
}
}
//--------------------------------------------------------------------
DBConnect::~DBConnect(void)
{
//关闭连接
close();
//等待线程退出
m_pThread->join();
//释放内存
if (m_pThread)
{
delete m_pThread;
m_pThread = nullptr;
}
if (m_pDBInterface)
{
delete m_pDBInterface;
m_pDBInterface = nullptr;
}
}
//--------------------------------------------------------------------
void DBConnect::workThreadFun()
{
//循环处理
while (!m_bQuit)
{
boost::mutex::scoped_lock oLock(m_CommandMutex);
size_t size = m_CommandCollect.size();
if (0 == size)
{
m_Condition.wait(oLock);
continue;
}
//有数据,取出一条数据,并进行操作
DBCommandPtr pCommand = m_CommandCollect.front();
m_CommandCollect.pop_front();
oLock.unlock();
handleDBCommand(pCommand);
//结果压回DBService,等待DBService的update处理
m_ResultHandle(pCommand);
}
//未写完的记录,采用同步方式写入数据库!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DBCommandCollect::iterator it = m_CommandCollect.begin();
for (; it != m_CommandCollect.end(); it++)
{
handleDBCommand(*it);
}
}
//-------------------------------------------------------------------------------------------
void DBConnect::handleDBCommand(DBCommandPtr& pCommand)
{
bool b = false;
int32 roweffect = 0;
//设置为执行成功
pCommand->m_Result = true;
///执行sql命令并回调
switch (pCommand->m_CmdType)
{
case DCT_querySQL:
b = m_pDBInterface->querySQL(pCommand->m_Sql, pCommand->m_query);
if (b == false)
{
pCommand->m_Result = false;
}
break;
case DCT_execSQL:
roweffect = m_pDBInterface->execSQL(pCommand->m_Sql);
if (roweffect == -1)
{
pCommand->m_Result = false;
}
break;
case DCT_execProcedurce:
b = m_pDBInterface->execProcedurce(pCommand->m_Sql);
if (b == false)
{
pCommand->m_Result = false;
}
break;
case DCT_execProcedurceQuery:
b = m_pDBInterface->execProcedurce(pCommand->m_Sql);
if (b == false)
{
pCommand->m_Result = false;
break;
}
if (pCommand->m_getResultSql.empty() == false)
{//有查询操作
b = m_pDBInterface->querySQL(pCommand->m_getResultSql, pCommand->m_query);
if (b == false)
{
pCommand->m_Result = false;
break;
}
}
break;
default:
{
throw("Error when excute sql!");
}
}
}
//-------------------------------------------------------------------
void DBConnect::close()
{
m_bQuit = true;
m_Condition.notify_all();
}
//-------------------------------------------------------------------
bool DBConnect::addCommand(DBCommandPtr pCommand)
{
boost::mutex::scoped_lock oLock(m_CommandMutex);
m_CommandCollect.push_back(pCommand);
oLock.unlock();
m_Condition.notify_all();
return true;
}
//-------------------------------------------------------------------
void DBConnect::setResultHandle(DBCallBack cb)
{
m_ResultHandle = cb;
}
}
|
6a2ea4bf721fcf4e63f3d0441d998abd2a850a11
|
c7b270492e0348214dd9d65fa651280506d09bd8
|
/final_version/ros_deneme/src/hectorquad/src/motionUtilities.hpp
|
c4629f75e4104b5e8e95e359f5fb3710756bcc97
|
[] |
no_license
|
erenerisken/drone_motion
|
10f54eca3df9fdb2a4a56f9a3e0fc1194cc4987e
|
727dcc5759963e5f84873557606b719cabdc5f1c
|
refs/heads/master
| 2021-07-25T05:13:03.691489
| 2020-07-08T06:03:02
| 2020-07-08T06:03:02
| 196,026,836
| 6
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 8,901
|
hpp
|
motionUtilities.hpp
|
#ifndef _MOTIONUTILITIES_HPP_
#define _MOTIONUTILITIES_HPP_
#include <ros/ros.h>
#include <iostream>
#include <vector>
#include <geometry_msgs/Vector3.h>
#include <algorithm>
#define FLOAT_EPSILON 0.001
#define EPSILON 0.1
#define QUAD_RADII 1.0
#define CLEARENCE 0.85 //(Coursera: Motion planning lecture)
#define QUAD_COUNT 4
#define COLLISION_COEFF 3
#define SKIP_COEFF 3
#define OBSTACLE_RADIUS 1.0
#define COLLISION_RADIUS 0.8
#define MAX_SPEED 1.3
#define INITIAL_HEIGHT 0.6 //not to hit object while going to start point
#define SLOPE_EPSILON 0.79 //Stable value 0.54 - 30 deg // 1.04 - 60 deg
#define HEIGHT 0.6 //from ground
#define PROBABILITY 0.07 // puts A* magic into RRT*
typedef std::vector<std::vector<int> > Matrix;
typedef std::pair<int, int> intint;
bool equalFloat(double a, double b)
{
return fabs(a-b) <= FLOAT_EPSILON;
}
bool isObstacle(const std::string &name)
{
if(name == "quadrotor" || name == "ground_plane" || name.substr(0,3) == "uav")
return false;
return true;
}
class Coordinate
{
public:
double x,y,z;
Coordinate(double x, double y, double z) : x(x), y(y), z(z) {}
Coordinate()
{
x = y = z = 0;
}
bool operator==(const Coordinate &rhs)
{
return equalFloat(x, rhs.x) && equalFloat(y, rhs.y) && equalFloat(z, rhs.z);
}
bool operator!=(const Coordinate &rhs)
{
return !(*this == rhs);
}
friend std::ostream& operator<<(std::ostream &os, const Coordinate &c)
{
os<<"x = "<<c.x<<" y = "<<c.y<<" z = "<<c.z;
return os;
}
geometry_msgs::Vector3 getVector3()
{
geometry_msgs::Vector3 ret;
ret.x = x;
ret.y = y;
ret.z = z;
return ret;
}
};
class Obstacle
{
public:
virtual bool inObstacle(const Coordinate &c) = 0;
virtual bool separates(const Coordinate &c1, const Coordinate &c2) = 0;
bool operator==(const Obstacle &rhs)
{
return name == rhs.name && coord == rhs.coord;
}
friend std::ostream &operator<<(std::ostream &os, const Obstacle &obs)
{
os<<obs.name<<" "<<obs.coord;
return os;
}
Coordinate coord;
std::string name;
};
class Cylinder : public Obstacle
{
public:
double r, h;
Cylinder(const std::string &name, const Coordinate &c, double r, double h) : r(r), h(h)
{
this->name = name;
coord = c;
}
bool inObstacle(const Coordinate &c)
{
if (c.z > h)
{
return false;
}
return sqrt(pow(c.x - coord.x, 2) + pow(c.y - coord.y, 2)) < r + CLEARENCE;
}
bool separates(const Coordinate &c1, const Coordinate &c2)
{
//Move everything to frame origined at the center of the cylinder
const double ax = c1.x - coord.x;
const double ay = c1.y - coord.y;
const double bx = c2.x - coord.x;
const double by = c2.y - coord.y;
const double R = r + CLEARENCE;
//set a,b,c of quadratic equation
const double a = pow(bx - ax, 2) + pow(by - ay, 2);
const double b = 2.0 * (ax * (bx - ax) + ay * (by - ay));
const double c = ax * ax + ay * ay - R * R;
//get discriminant
const double disc = b * b - 4.0 * a * c;
if (disc <= 0)
{
return false;
}
const double t1 = (-b + sqrt(disc)) / (2.0 * a);
const double t2 = (-b - sqrt(disc)) / (2.0 * a);
return (t1 >= 0.0 && t1 <= 1.0) || (t2 >= 0.0 && t2 <= 1.0);
}
};
double dist(const geometry_msgs::Vector3 &c1, const geometry_msgs::Vector3 &c2)
{
return sqrt((c1.x - c2.x) * (c1.x - c2.x) + (c1.y - c2.y) * (c1.y - c2.y) + (c1.z - c2.z) * (c1.z - c2.z));
}
double dist(const Coordinate &c1, const Coordinate &c2)
{
return sqrt((c1.x - c2.x) * (c1.x - c2.x) + (c1.y - c2.y) * (c1.y - c2.y) + (c1.z - c2.z) * (c1.z - c2.z));
}
bool equalCoord(Coordinate &a, Coordinate &b)
{
return fabs(a.x - b.x) < EPSILON && fabs(a.y - b.y) < EPSILON
&& fabs(a.z - b.z) < EPSILON;
}
Coordinate getClosestPoint(const Coordinate &p, const Coordinate &a, const Coordinate &b)
{
if(equalFloat(b.x, a.x))
{
Coordinate ret;
ret.z = p.z;
ret.x = b.x;
ret.y = p.y;
if (ret.y > std::max(a.y, b.y))
{
ret.y = std::max(a.y, b.y);
}
if (ret.y < std::min(a.y, b.y))
{
ret.y = std::min(a.y, b.y);
}
return ret;
}
if(equalFloat(b.y, a.y))
{
Coordinate ret;
ret.z = p.z;
ret.x = p.x;
ret.y = a.y;
if (ret.x > std::max(a.x, b.x))
{
ret.x = std::max(a.x, b.x);
}
if (ret.x < std::min(a.x, b.x))
{
ret.x = std::min(a.x, b.x);
}
return ret;
}
const float m1 = (b.y - a.y) / (b.x - a.x);
const float m2 = -1.0 / m1;
const float n1 = b.y - m1 * b.x;
const float n2 = p.y - m2 * p.x;
Coordinate ret;
ret.z = p.z;
ret.x = (n2 - n1) / (m1 - m2);
ret.y = m1*ret.x + n1;
if (ret.y > std::max(a.y, b.y))
{
ret.y = std::max(a.y, b.y);
}
if (ret.y < std::min(a.y, b.y))
{
ret.y = std::min(a.y, b.y);
}
if (ret.x > std::max(a.x, b.x))
{
ret.x = std::max(a.x, b.x);
}
if (ret.x < std::min(a.x, b.x))
{
ret.x = std::min(a.x, b.x);
}
return ret;
}
namespace planningUtilities
{
bool isLinear(const Coordinate &a, const Coordinate &b, const Coordinate &c)
{
double slope1 = a.x == b.x ? -999.0 : (b.y - a.y) / (b.x - a.x);
double slope2 = b.x == c.x ? -999.0 : (c.y - b.y) / (c.x - b.x);
return fabs(slope2 - slope1) < SLOPE_EPSILON;
}
int dist(intint c1, intint c2)
{
//return abs(c1.second - c2.second) + abs(c1.first - c2.first);
return (int)sqrt(pow((c1.second - c2.second),2) + pow((c1.first - c2.first) ,2));
}
std::vector<Coordinate> filterCoordinates(std::vector<Coordinate> &route, std::vector<Obstacle*> *obs)
{
//return route;
std::vector<Coordinate> ret;
for (size_t i = 0; i < route.size()-1; i++)
{
ret.push_back(route[i]);
for (size_t j = route.size()-1; j > i; j--)
{
bool clearPath = true;
for (auto obstPtr = obs->begin(); obstPtr < obs->end(); obstPtr++)
{
if((*obstPtr)->separates(route[i], route[j]))
{
clearPath = false;
break;
}
}
if(!clearPath)
{
continue;
}
ret.push_back(route[j]);
i = j;
break;
}
}
return ret;
}
}
#endif
|
2246f8573a289d7d2d5002d8d6624bce11062e00
|
dfadd879ccc98bb99c45651a33c80c18181589d9
|
/ZeroLibraries/Meta/LocalModifications.hpp
|
2374eb2a64d401e00a2d3cb52bbec099d8d17d40
|
[
"MIT"
] |
permissive
|
zeroengineteam/ZeroCore
|
f690bcea76e1040fe99268bd83a2b76e3e65fb54
|
14dc0df801b4351a2e9dfa3ce2dc27f68f8c3e28
|
refs/heads/1.4.2
| 2022-02-26T04:05:51.952560
| 2021-04-09T23:27:57
| 2021-04-09T23:27:57
| 148,349,710
| 54
| 27
|
MIT
| 2022-02-08T18:28:30
| 2018-09-11T16:51:46
|
C++
|
UTF-8
|
C++
| false
| false
| 8,119
|
hpp
|
LocalModifications.hpp
|
///////////////////////////////////////////////////////////////////////////////
///
/// \file LocalModifications.hpp
///
/// Authors: Joshua Claeys
/// Copyright 2015-2016, DigiPen Institute of Technology
///
///////////////////////////////////////////////////////////////////////////////
#pragma once
namespace Zero
{
namespace ObjectContext
{
DeclareStringConstant(Instance);
}
// Forward declarations
class ObjectRestoreState;
//-------------------------------------------------------------------------- Contextual Object State
class ObjectState
{
public:
//--------------------------------------------------------------------------------------- Child Id
struct ChildId
{
explicit ChildId(StringParam typeName = "", Guid id = cInvalidUniqueId);
ChildId(BoundType* type, Guid id = cInvalidUniqueId);
ChildId(HandleParam object);
ChildId(Object* object);
size_t Hash() const;
bool operator==(const ChildId& rhs) const;
String mTypeName;
Guid mId;
};
/// Typedefs.
typedef HashSet<PropertyPath> ModifiedProperties;
typedef HashSet<ChildId> ChildrenMap;
typedef const ChildId& ChildIdParam;
/// Constructor.
ObjectState();
ObjectState* Clone();
void Combine(ObjectState* state);
/// Checks both IsSelfModified and AreChildrenModified.
bool IsModified();
bool IsModified(HandleParam object, bool ignoreOverrideProperties);
bool IsSelfModified();
bool IsSelfModified(HandleParam object, bool ignoreOverrideProperties);
bool AreChildrenModified();
void ClearModifications();
void ClearModifications(HandleParam object, bool retainOverrideProperties);
/// The 'cachedData' is strictly for performance to save allocations when this function
/// is called multiple times.
void ClearModifications(bool retainOverrideProperties, HandleParam object,
ModifiedProperties& cachedMemory);
/// Property modifications.
bool IsPropertyModified(PropertyPathParam property);
bool HasModifiedProperties();
void SetPropertyModified(PropertyPathParam property, bool state);
ModifiedProperties::range GetModifiedProperties();
/// Child modifications.
void ChildAdded(ChildIdParam childId);
void ChildRemoved(ChildIdParam childId);
bool IsChildLocallyAdded(ChildIdParam childId);
bool IsChildLocallyRemoved(ChildIdParam childId);
bool IsChildOrderModified();
void SetChildOrderModified(bool state);
ChildrenMap::range GetAddedChildren();
ChildrenMap::range GetRemovedChildren();
/// Properties
ModifiedProperties mModifiedProperties;
/// The engine uses these as both Hierarchy children and Components. They can be either
/// type names or guids.
ChildrenMap mAddedChildren;
ChildrenMap mRemovedChildren;
/// Whether or not the order of the children has changed.
bool mChildOrderModified;
};
//----------------------------------------------------------------------- Local Object Modifications
class LocalModifications : public ExplicitSingleton<LocalModifications, Object>
{
public:
ObjectState* GetObjectState(HandleParam object, bool createNew = false, bool validateStorage = true);
/// Is the object modified in any way? Checks IsSelfModified and IsChildrenModified.
bool IsModified(HandleParam object, bool checkHierarchy, bool ignoreOverrideProperties);
/// Finds the closest parent (or itself) that inherits from other data. This will not recurse
/// past parents that inherit from data. See the comment in the implementation of the
/// 'MetaDataInheritance::ShouldStoreLocalModifications' function for a more detailed
/// explanation.
Handle GetClosestInheritedObject(HandleParam object, bool checkParents);
/// Clear all modifications on the given object.
void ClearModifications(HandleParam object, bool clearChildren, bool retainOverrideProperties);
/// The 'cachedData' is strictly for performance to save allocations as it recurses.
void ClearModifications(HandleParam object, bool clearChildren, bool retainOverrideProperties,
ObjectState::ModifiedProperties& cachedMemory);
/// Property modifications.
bool IsPropertyModified(HandleParam object, PropertyPathParam property);
void SetPropertyModified(HandleParam object, PropertyPathParam property, bool state);
/// Child modifications.
void ChildAdded(HandleParam object, ObjectState::ChildIdParam childId);
void ChildRemoved(HandleParam object, ObjectState::ChildIdParam childId);
bool IsChildLocallyAdded(HandleParam object, ObjectState::ChildIdParam childId);
bool IsChildLocallyRemoved(HandleParam object, ObjectState::ChildIdParam childId);
bool IsObjectLocallyAdded(HandleParam object, bool recursivelyCheckParents);
bool IsChildOrderModified(HandleParam object);
void SetChildOrderModified(HandleParam object, bool state);
/// Returns the object state stored for this object and removes it from the global map.
ObjectState* TakeObjectState(HandleParam object);
/// Updates the local modifications for the given object.
void RestoreObjectState(HandleParam object, ObjectState* objectState);
void CombineObjectState(HandleParam object, ObjectState* objectState);
private:
bool IsModified(HandleParam object, HandleParam propertyPathParent,
bool checkHierarchy, bool ignoreOverrideProperties);
HashMap<Handle, ObjectState*> mObjectStates;
};
//---------------------------------------------------------------------------- Meta Data Inheritance
DeclareEnum2(InheritIdContext,
// This is used when saving a modified instance of an object (e.g. a Cog inside a level file).
Instance,
// This is used when saving out the definition of an object (e.g. uploading to Archetype). This
// should only return the base inherit id (e.g. base archetype id).
Definition);
// This is required IF you have the 'StoreLocalModifications' flag set on meta.
class MetaDataInheritance : public ReferenceCountedEventObject
{
public:
ZilchDeclareType(TypeCopyMode::ReferenceType);
/// A unique identifier for this object. This will be used
virtual Guid GetUniqueId(HandleParam object);
/// This allows us to choose which objects we want to store local modifications.
/// For example, we don't want to store changed for non-Archetyped Cogs or for
/// Resources that don't inherit from other Resources.
virtual bool ShouldStoreLocalModifications(HandleParam object);
virtual void Revert(HandleParam object);
virtual bool CanPropertyBeReverted(HandleParam object, PropertyPathParam propertyPath);
virtual void RevertProperty(HandleParam object, PropertyPathParam propertyPath);
virtual void RestoreRemovedChild(HandleParam parent, ObjectState::ChildId childId);
virtual void SetPropertyModified(HandleParam object, PropertyPathParam propertyPath, bool state);
/// When a modification of an object is being reverted, the object has to be rebuilt to
/// properly get the old value. This function should basically re-create the object
/// (i.e. Archetype being rebuilt).
virtual void RebuildObject(HandleParam object) = 0;
/// Does this object inherit from other data? Short-hand to ShouldStoreLocalModifications.
/// See the comment in the implementation for ShouldStoreLocalModifications to get a better
/// description of what objects should and should not stored local modifications.
static bool InheritsFromData(HandleParam object);
};
//---------------------------------------------------------------------------- Meta Data Inheritance
// Implement this if the object itself can inherit from other data (e.g. Cog, Material)
class MetaDataInheritanceRoot : public MetaDataInheritance
{
public:
ZilchDeclareType(TypeCopyMode::ReferenceType);
/// The id this object inherits from.
virtual String GetInheritId(HandleParam object, InheritIdContext::Enum context) = 0;
virtual void SetInheritId(HandleParam object, StringParam inheritId) = 0;
};
}//namespace Zero
|
0b26002354c5695c393bbbe8454a6ccbf4d55a6c
|
5d3130f99f6aaf730bcd8a12f0fe6c22a3b334ba
|
/src/view/SimplestUI/SimplestUIMainMenu.hpp
|
33bec901384a3a11b83448ab713b39f04171b751
|
[] |
no_license
|
Generall14/VendeurAssistant
|
32b9e54dee259a9a34ea30bf93f9ce67f398ba7c
|
d0b720d2d81bc624820fe9893da65a6676057b6d
|
refs/heads/master
| 2020-05-09T18:46:55.023272
| 2019-04-14T18:57:24
| 2019-04-14T18:57:24
| 181,354,875
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 187
|
hpp
|
SimplestUIMainMenu.hpp
|
#ifndef SIMPLESTUIMAINMENU_HPP
#define SIMPLESTUIMAINMENU_HPP
#include "../../controller/State.hpp"
class SimplestUIMainMenu : public State
{
public:
virtual request Run();
};
#endif
|
01b1781026f7d38ae11b15caaa5608dfbdeaa54e
|
38616fa53a78f61d866ad4f2d3251ef471366229
|
/3rdparty/GPSTk/ext/lib/Procframe/SolverWMS.cpp
|
9b0b6ee4dc558eff13d01d2efccb7372c66b0d8d
|
[
"MIT",
"GPL-3.0-only",
"LGPL-2.0-or-later",
"LGPL-3.0-only",
"LGPL-2.1-or-later",
"GPL-1.0-or-later"
] |
permissive
|
wuyou33/Enabling-Robust-State-Estimation-through-Measurement-Error-Covariance-Adaptation
|
3b467fa6d3f34cabbd5ee59596ac1950aabf2522
|
2f1ff054b7c5059da80bb3b2f80c05861a02cc36
|
refs/heads/master
| 2020-06-08T12:42:31.977541
| 2019-06-10T15:04:33
| 2019-06-10T15:04:33
| 193,229,646
| 1
| 0
|
MIT
| 2019-06-22T12:07:29
| 2019-06-22T12:07:29
| null |
UTF-8
|
C++
| false
| false
| 8,954
|
cpp
|
SolverWMS.cpp
|
//============================================================================
//
// This file is part of GPSTk, the GPS Toolkit.
//
// The GPSTk is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 3.0 of the License, or
// any later version.
//
// The GPSTk is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with GPSTk; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
//
// Copyright 2004, The University of Texas at Austin
// Dagoberto Salazar - gAGE ( http://www.gage.es ). 2006, 2007, 2008, 2011
//
//============================================================================
//============================================================================
//
//This software developed by Applied Research Laboratories at the University of
//Texas at Austin, under contract to an agency or agencies within the U.S.
//Department of Defense. The U.S. Government retains all rights to use,
//duplicate, distribute, disclose, or release this software.
//
//Pursuant to DoD Directive 523024
//
// DISTRIBUTION STATEMENT A: This software has been approved for public
// release, distribution is unlimited.
//
//=============================================================================
/**
* @file SolverWMS.cpp
* Class to compute the Weighted Least Mean Squares Solution
*/
#include "SolverBase.hpp"
#include "SolverWMS.hpp"
#include "MatrixFunctors.hpp"
namespace gpstk
{
// Returns a string identifying this object.
std::string SolverWMS::getClassName() const
{ return "SolverWMS"; }
/* Default constructor. When fed with GNSS data structures, the
* default equation definition to be used is the common GNSS
* code equation.
*/
SolverWMS::SolverWMS()
{
// First, let's define a set with the typical unknowns
TypeIDSet tempSet;
tempSet.insert(TypeID::dx);
tempSet.insert(TypeID::dy);
tempSet.insert(TypeID::dz);
tempSet.insert(TypeID::cdt);
// Now, we build the default definition for a common GNSS
// code-based equation
defaultEqDef.header = TypeID::prefitC;
defaultEqDef.body = tempSet;
} // End of 'SolverWMS::SolverWMS()'
/* Explicit constructor. Sets the default equation definition
* to be used when fed with GNSS data structures.
*
* @param eqDef gnssEquationDefinition to be used
*/
SolverWMS::SolverWMS(const gnssEquationDefinition& eqDef)
{
setDefaultEqDefinition(eqDef);
} // End of 'SolverWMS::SolverWMS()'
/* Compute the Weighted Least Mean Squares Solution of the given
* equations set.
*
* @param prefitResiduals Vector of prefit residuals
* @param designMatrix Design matrix for the equation system
* @param weightVector Vector of weights assigned to each
* satellite.
*
* @return
* 0 if OK
* -1 if problems arose
*/
int SolverWMS::Compute( const Vector<double>& prefitResiduals,
const Matrix<double>& designMatrix,
const Vector<double>& weightVector )
throw(InvalidSolver)
{
// By default, results are invalid
valid = false;
// Check that everyting has a proper size
int wSize = static_cast<int>(weightVector.size());
int pSize = static_cast<int>(prefitResiduals.size());
if (!(wSize==pSize))
{
InvalidSolver e("prefitResiduals size does not match dimension \
of weightVector");
GPSTK_THROW(e);
}
Matrix<double> wMatrix(wSize,wSize,0.0); // Declare a weight matrix
// Fill the weight matrix diagonal with the content of
// the weight vector
for (int i=0; i<wSize; i++)
{
wMatrix(i,i) = weightVector(i);
}
// Call the more general SolverWMS::Compute() method
return SolverWMS::Compute(prefitResiduals, designMatrix, wMatrix);
} // End of method 'SolverWMS::Compute()'
// Compute the Weighted Least Mean Squares Solution of the given
// equations set.
//
// @param prefitResiduals Vector of prefit residuals
// @param designMatrix Design matrix for equation system
// @param weightMatrix Matrix of weights
//
// @return
// 0 if OK
// -1 if problems arose
//
int SolverWMS::Compute( const Vector<double>& prefitResiduals,
const Matrix<double>& designMatrix,
const Matrix<double>& weightMatrix )
throw(InvalidSolver)
{
// By default, results are invalid
valid = false;
if (!(weightMatrix.isSquare()))
{
InvalidSolver e("Weight matrix is not square");
GPSTK_THROW(e);
}
int wRow = static_cast<int>(weightMatrix.rows());
int pRow = static_cast<int>(prefitResiduals.size());
if (!(wRow==pRow))
{
InvalidSolver e("prefitResiduals size does not match dimension of \
weightMatrix");
GPSTK_THROW(e);
}
int gCol = static_cast<int>(designMatrix.cols());
int gRow = static_cast<int>(designMatrix.rows());
if (!(gRow==pRow))
{
InvalidSolver e("prefitResiduals size does not match dimension \
of designMatrix");
GPSTK_THROW(e);
}
Matrix<double> AT = transpose(designMatrix);
covMatrix.resize(gCol, gCol);
covMatrixNoWeight.resize(gCol, gCol);
solution.resize(gCol);
// Temporary storage for covMatrix. It will be inverted later
covMatrix = AT * weightMatrix * designMatrix;
// Let's try to invert AT*W*A matrix
try {
covMatrix = inverseChol( covMatrix );
}
catch(...)
{
InvalidSolver e("Unable to invert matrix covMatrix");
GPSTK_THROW(e);
}
// Temporary storage for covMatrixNoWeight. It will be inverted later
covMatrixNoWeight = AT * designMatrix;
// Let's try to invert AT*A matrix
try {
covMatrixNoWeight = inverseChol( covMatrixNoWeight );
}
catch(...)
{
InvalidSolver e("Unable to invert matrix covMatrixNoWeight");
GPSTK_THROW(e);
}
// Now, compute the Vector holding the solution...
solution = covMatrix * AT * weightMatrix * prefitResiduals;
// ... and the postfit residuals Vector
postfitResiduals = prefitResiduals - designMatrix * solution;
// If everything is fine so far, then the results should be valid
valid = true;
return 0;
} // End of method 'SolverWMS::Compute()'
/* Returns a reference to a satTypeValueMap object after solving
* the previously defined equation system.
*
* @param gData Data object holding the data.
*/
satTypeValueMap& SolverWMS::Process(satTypeValueMap& gData)
throw(ProcessingException)
{
try
{
// First, let's fetch the vector of prefit residuals
Vector<double> prefit(gData.getVectorOfTypeID(defaultEqDef.header));
// Second, generate the corresponding geometry/design matrix
Matrix<double> dMatrix(gData.getMatrixOfTypes(defaultEqDef.body));
// Third, generate the appropriate weights vector
Vector<double> weightsVector(gData.getVectorOfTypeID(TypeID::weight));
// Call the Compute() method with the defined equation model.
// This equation model MUST HAS BEEN previously set, usually when
// creating the SolverWMS object with the appropriate constructor.
Compute(prefit, dMatrix, weightsVector);
// Now we have to add the new values to the data structure
if ( defaultEqDef.header == TypeID::prefitC )
{
gData.insertTypeIDVector(TypeID::postfitC, postfitResiduals);
}
if ( defaultEqDef.header == TypeID::prefitL )
{
gData.insertTypeIDVector(TypeID::postfitL, postfitResiduals);
}
return gData;
}
catch(Exception& u)
{
// Throw an exception if something unexpected happens
ProcessingException e( getClassName() + ":"
+ u.what() );
GPSTK_THROW(e);
}
} // End of method 'SolverWLMS::Process()'
} // End of namespace gpstk
|
78bdec0944d7215a97e83f51a98f2e71b0ab7fcd
|
c9f21583f5ca62c1dca0193651f53a4875a1dbd3
|
/unittest/audio_device_unit_test.cpp
|
80222f0e3625584c0880cd283217130b5cd1b82f
|
[] |
no_license
|
templeblock/audioengine
|
caab69096dd79a1930b0f0e63ad242a6b21e0e41
|
70e9e01fdded031b64f68dfe5d2176c5edcea075
|
refs/heads/master
| 2020-12-23T22:28:02.098191
| 2017-04-21T13:02:15
| 2017-04-21T13:02:15
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,042
|
cpp
|
audio_device_unit_test.cpp
|
#include "header.h"
#include <algorithm>
#include <string>
#include <iostream>
#include <cctype>
//#include "dispatch_example.cpp"
// Example: main calls myfunc
extern int test_vcl( int argc, char* argv[] );
#include "base/asyntask.h"
void test_async_task()
{
AsynTask asyn_task;
for ( auto i : {5,2,3,3,1} )
asyn_task.PostTask( i, false, [] ( uint32_t id ) { printf( "%d ", id ); } );
system( "pause" );
}
#include "webrtc/common_audio/real_fourier.h"
#include "base/time_cvt.hpp"
#include <unordered_map>
void test_fft()
{
const int order = 512;
using namespace webrtc;
auto pfft = RealFourier::Create( lround(log10(order)) );
float arr[order];
for ( int i = 0; i < order; i++ )
{
arr[i] = (float)i;
}
std::complex<float> caar[order];
Timer t;
for ( int i = 0; i < 2000; i++ )
{
pfft->Forward( arr, caar );
pfft->Inverse( caar, arr );
}
cout << "Ooura Implemented fft processed time: "<<t.elapsed() <<"ms"<< endl;
for ( int i = 0; i < order; i++ )
{
caar[i] = (float)i;
}
t.reset();
for ( int i = 0; i < 2000; i++ )
{
CFFT::Forward( caar, order );
CFFT::Inverse( caar, order );
}
cout <<"LIBROW implemented fft processed time :"<< t.elapsed() << "ms"<<endl;
t.reset();
}
#include "audio_gain_control.h"
void test_voice_scale()
{
WavReader reader_rec( "D:/log/test-16000.wav" );
int samplerate = reader_rec.SampleRate();
int channel = reader_rec.NumChannels();
WavWriter writer( "D:/log/test1.wav", samplerate, channel );
AudioGainControl agc;
const int size = 160;
agc.Init( size, [&size] ( std::valarray< std::complex<float> >&frec, std::valarray<float>& amplitide, std::valarray<float>& angle ) {
for ( int i = 0; i < size/8; i++ )
{
amplitide[i] *= 2;
}
return false; } );
int16_t pPCMData[size] = { 0 };
for ( ;; )
{
if ( 0 == reader_rec.ReadSamples( size, pPCMData ) )
{
break;
}
agc.ScaleVoice( pPCMData, size );
writer.WriteSamples( pPCMData, size );
}
}
void test_array();
void test_audio_processing(int argc,char**argv);
void test_codec();
void test_asio( int argc, char** argv );
void test_simulate_internet( int argc, char** argv );
void test_sound_to_text();
void test_audio_device();
void test_chrono();
#include <tuple>
void debug_out( const char* format, int argc, ... )
{
}
#define MACRO(format,...) debug_out(format,std::tuple_size<decltype(std::make_tuple(__VA_ARGS__))>::value, __VA_ARGS__ )
template <typename T>
T Argument( T value )
{
return value;
}
template <typename ... Args>
void Print( char const * const format,
Args const & ... args )
{
std::cout<<sizeof...( args )<<std::endl;
if ( sizeof...( args ) == 0 )
{
printf("%s",format);
}
else
{
char buf[512];// = { 0 };
sprintf( buf, format, Argument( args ) ... );
std::cout << buf << "\n";
}
}
void test_rtp_rtcp_test( int argc, char** argv );
int main( int argc, char** argv )
{
// Print( "%s%s" );
// test_asio(argc,argv);
// test_chrono();
//test_array();
// test_codec();
// test_audio_processing(argc,argv);
// test_async_task();
// test_audio_device();
// test_conv();
// test_hrtf(45,0,"C:/Users/zhangnaigan/Desktop/3D_test_Audio/es01.wav","D:/pro-48000-1.wav");
// test_real_time_3d();
// test_mit_hrtf_get();
//test_circular_buffer();
// test_play_mp3();
// test_vcl( argc, argv );
// test_audio_ns();
// test_audio_processing();
// test_aac_enc();
// test_aac_dec();
// test_aac_pasre_head();
// test_aac_dec_file();
// run_mp32wav( "E:/CloudMusic/凡人歌.mp3" );
//test_array();
// test_fft();
// test_voice_scale();
// test_simulate_internet(argc,argv);
// test_sound_to_text();
test_rtp_rtcp_test( argc, argv );
system( "pause" );
return 0;
}
|
143599ed5bc735c2b8b55ee3ccae011e91191c64
|
ead9b4e788bab8542a39215358e32c0df8a9533c
|
/SAS/OTDB/include/OTDB/OTDBcontrol.h
|
26dc08a4898fdcb5ffad9f061be8ddcfb6f2181f
|
[] |
no_license
|
iniyannatarajan/pyimager-olegs-mods
|
34968740d47d8e38d65ff4005d215e6f87ea2a80
|
6218fdbed57c8c442238372cda408a69e91b2bb7
|
refs/heads/master
| 2022-11-12T21:50:18.539394
| 2015-08-18T09:30:25
| 2015-08-18T09:30:25
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,197
|
h
|
OTDBcontrol.h
|
//# OTDBcontrol.h: Special connectiontype for events and actions.
//#
//# Copyright (C) 2002-2004
//# ASTRON (Netherlands Foundation for Research in Astronomy)
//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl
//#
//# This program is free software; you can redistribute it and/or modify
//# it under the terms of the GNU General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or
//# (at your option) any later version.
//#
//# This program is distributed in the hope that it will be useful,
//# but WITHOUT ANY WARRANTY; without even the implied warranty of
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//# GNU General Public License for more details.
//#
//# You should have received a copy of the GNU General Public License
//# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//#
//# $Id: OTDBcontrol.h 7384 2006-01-05 12:21:03Z cvs $
#ifndef LOFAR_OTDB_OTDBCONTROL_H
#define LOFAR_OTDB_OTDBCONTROL_H
// \file
// Special connectiontype for events and actions.
//# Never #include <config.h> or #include <lofar_config.h> in a header file!
//# Includes
#include <OTDB/OTDBconnection.h>
namespace LOFAR {
namespace OTDB {
// \addtogroup OTDB
// @{
//# --- Forward Declarations ---
//# classes mentioned as parameter or returntype without virtual functions.
class ...;
// Special connectiontype for events and actions.
// ...
class OTDBcontrol : public OTDBconnection
{
public:
OTDBcontrol (const string& username,
const string& passwd,
const string& database);
~OTDBcontrol();
actionID addAction (eventIDType anEventID,
actionType anActionType,
const string& description);
private:
// Copying is not allowed
OTDBcontrol(const OTDBcontrol& that);
OTDBcontrol& operator=(const OTDBcontrol& that);
//# --- Datamembers ---
...
};
//# --- Inline functions ---
// ... example
//#
//# operator<<
//#
inline ostream& operator<< (ostream& os, const OTDBcontrol& aOTDBcontrol)
{
return (c.print(os));
}
// @}
} // namespace OTDB
} // namespace LOFAR
#endif
|
deee2be99f0a16cd605d3947cd7d7fe3ddb7c57d
|
367dba59ad84e9a34f9794b4a46484a6b89b16be
|
/tools/Assembler/ShapeFunctions/FEBasis.cpp
|
90a1312668092e79b51fe4f2e7ef692b35b611eb
|
[] |
no_license
|
rickarkin/PyMesh-win
|
fea0842b0fd3ef98646809be19daf3b20bca659f
|
c16ba28ba1ebea8556d6761169685c2588978404
|
refs/heads/master
| 2021-01-21T01:43:30.563214
| 2016-08-18T08:58:44
| 2016-08-18T08:58:44
| 65,174,117
| 12
| 3
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,504
|
cpp
|
FEBasis.cpp
|
/* This file is part of PyMesh. Copyright (c) 2015 by Qingnan Zhou */
#include "FEBasis.h"
using namespace PyMesh;
FEBasis::FEBasis(FEBasis::FEMeshPtr mesh) {
m_shape_func = ShapeFunction::create(mesh, "linear");
m_integrator = Integrator::create(mesh, m_shape_func);
}
Float FEBasis::evaluate_func(size_t elem_idx,
size_t local_func_idx, const VectorF& coord) {
return m_shape_func->evaluate_func(elem_idx, local_func_idx, coord);
}
VectorF FEBasis::evaluate_grad(size_t elem_idx,
size_t local_func_idx, const VectorF& coord) {
return m_shape_func->evaluate_grad(elem_idx, local_func_idx, coord);
}
Float FEBasis::integrate_func_func(size_t elem_idx,
size_t local_func_i, size_t local_func_j) {
return m_integrator->integrate_func(elem_idx, local_func_i, local_func_j);
}
Float FEBasis::integrate_grad_grad(size_t elem_idx,
size_t local_func_i, size_t local_func_j) {
return m_integrator->integrate_grad(elem_idx, local_func_i, local_func_j);
}
Float FEBasis::integrate_grad_C_grad(size_t elem_idx,
size_t local_func_i, size_t local_func_j, const MatrixF& C) {
return m_integrator->integrate_grad_C(elem_idx,
local_func_i, local_func_j, C);
}
MatrixF FEBasis::integrate_material_contraction(size_t elem_idx,
size_t local_func_i, size_t local_func_j,
const MaterialPtr material) {
return m_integrator->integrate_material_contraction(elem_idx,
local_func_i, local_func_j, material);
}
|
1691ee5ab9c817321f8cdc8cb816c7eb4420ab2e
|
bd58ce297dda9acd2bfa5dc2311f6598268c7caa
|
/Homework/Level 2/Section 2.4/Exercise 2/Exercise2.4.2/Exercise2.4.2/Exercise2.4.2.cpp
|
5d2f3c5c4d4824263505f9777c286e96c2197bb9
|
[] |
no_license
|
songgaoxian/Advanced_C
|
b17c91fa6416306f48199926483474da0df92099
|
92b7d78a50e614c8f5bd121be7cef3476b345f9f
|
refs/heads/master
| 2020-05-27T23:41:28.967920
| 2017-02-20T18:22:41
| 2017-02-20T18:22:41
| 82,583,567
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,738
|
cpp
|
Exercise2.4.2.cpp
|
#include "C.h"
int main() {
/*
//for b)
//declare and initialize shared_ptr
std::shared_ptr<double> d(new double(2.2));
{ //display initial use count of d
cout << "Use ccount: ";
cout << d.use_count() << std::endl;
//create instance of C1 with d
C1 object1(d);
object1.print();
cout << "\nUse count: ";
cout<<d.use_count()<<std::endl;
{
//create instance of C2 with d
C2 object2(d);
object2.print();
cout << "\nUse count: ";
cout << d.use_count() << std::endl;
}
//display the use count for ccomparison
cout << "\nUse count outside inner scope: ";
cout << d.use_count() << std::endl;
}
cout << d.use_count() << std::endl;
//end of b)
*/
//for c)
//declare and initialize shared_ptr
std::shared_ptr<Point> p(new Point(1.1,2.2));
{ //display initial use count of d
cout << "Use ccount: ";
cout << p.use_count() << std::endl;
//create instance of C1 with d
C1 object1(p);
object1.print();
cout << "\nUse count: ";
cout << p.use_count() << std::endl;
{
//create instance of C2 with d
C2 object2(p);
object2.print();
cout << "\nUse count: ";
cout << p.use_count() << std::endl;
}
//display the use count for ccomparison
cout << "\nUse count outside inner scope: ";
cout << p.use_count() << std::endl;
}
cout << p.use_count() << std::endl;
//end of c)
//for d)
//declare and initialize shared pointer
std::shared_ptr<int> sp1(new int(6));
//copy sp1 to spCopy
std::shared_ptr<int> spCopy(sp1);
//assign sp1 to spAssign
std::shared_ptr<int> spAssign = sp1;
//create sp2
std::shared_ptr<int> sp2(new int(15));
//compare sp1 and sp2
if (sp1 == sp2) {
cout << "sp1 equals to spw\n";
}
else if (sp1 < sp2) {
cout << "sp1 is less than sp2\n";
}
else if (sp1 > sp2) {
cout << "sp1 is greater than sp2\n";
}
//check if the shared pointer is the only owner
cout << "is sp2 unique? " << sp2.unique() << std::endl;
cout << "is sp1 unique? " << sp1.unique() << std::endl;
//display value before swap
cout << "before swap: *sp1=" << *sp1 << "; *sp2=" << *sp2 << std::endl;
//do the swap
std::swap(sp1, sp2);
//display value after swap
cout << "after swap: *sp1=" << *sp1 << "; *sp2=" << *sp2 << std::endl;
//create spMid for ownership transferring
std::shared_ptr<int> spMid = std::move(sp2);
//transfer ownership from sp1 to sp2
sp2 = std::move(sp1);
//transfer ownership from spMid to sp1
sp1 = std::move(spMid);
//reinitialize shared_ptr as empty
sp1.reset();
if (sp1 == 0) {
cout << "after reset, the shared_ptr is empty\n";
}
else {
cout << "still not empty\n";
}
//end of d)
return 0;
}
|
34d35f7d017d248837b8afa34bd58528de23d39d
|
40f61cb9296db754d2dfc38dcd84b71251a65a0f
|
/src/FindModuleInstance.h
|
47b5e955663d8d0ffbc90e2ecb7085fdd94b146b
|
[
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
poena/systemc-clang
|
99761d24f23b63672b724569e2de20fe8c923530
|
e44e97794bb7f2413ce60d7623c36647ad242e29
|
refs/heads/master
| 2020-10-01T14:07:38.136166
| 2019-12-12T02:47:01
| 2019-12-12T02:47:01
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 706
|
h
|
FindModuleInstance.h
|
#ifndef _FIND_MODULE_INSTANCE_H_
#define _FIND_MODULE_INSTANCE_H_
#include "clang/AST/DeclCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "llvm/Support/raw_ostream.h"
namespace scpar {
using namespace clang;
using namespace std;
class FindModuleInstance : public RecursiveASTVisitor<FindModuleInstance> {
public:
FindModuleInstance(CXXRecordDecl *, llvm::raw_ostream &);
virtual bool VisitCXXConstructExpr(CXXConstructExpr *expr);
virtual bool VisitFieldDecl(FieldDecl *fdecl);
virtual ~FindModuleInstance();
void dump();
string getInstanceName() const;
private:
CXXRecordDecl *declaration_;
llvm::raw_ostream &os_;
string instance_name_;
};
} // namespace scpar
#endif
|
89bdac79c524cf440521a0fda7b702c6637128b6
|
2944427265e7ac86292a1f0d51b770944656f59a
|
/mission/sdv.TANOA/dialog/clothing.hpp
|
a42af59f08081589c8b8ea1a8fcb95c0d3454abe
|
[
"CC0-1.0"
] |
permissive
|
PC-Gamercom/pcg_tanoa
|
939d0856c9aa2f16ea72771b756bc309b93030c0
|
36df0ebdcb5cc46af61536d9850b5f8c0c15265e
|
refs/heads/master
| 2020-12-19T06:02:41.209072
| 2016-08-09T11:01:00
| 2016-08-09T11:01:00
| 61,654,721
| 14
| 6
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,952
|
hpp
|
clothing.hpp
|
class Life_Clothing {
idd = 3100;
name= "Life_Clothing";
movingEnable = 1;
enableSimulation = 1;
//onLoad = "[] execVM 'core\client\keychain\init.sqf'";
class controlsBackground {
class Life_RscTitleBackground:Life_RscText {
colorBackground[] = {"(profilenamespace getvariable ['GUI_BCG_RGB_R',0.3843])", "(profilenamespace getvariable ['GUI_BCG_RGB_G',0.7019])", "(profilenamespace getvariable ['GUI_BCG_RGB_B',0.8862])", "(profilenamespace getvariable ['GUI_BCG_RGB_A',0.7])"};
idc = -1;
x = 0.0821059 * safezoneW + safezoneX;
y = 0.212176 * safezoneH + safezoneY;
w = 0.318;
h = (1 / 25);
};
class MainBackground:Life_RscText {
colorBackground[] = {0, 0, 0, 0.7};
idc = -1;
x = 0.0822359 * safezoneW + safezoneX;
y = 0.236099 * safezoneH + safezoneY;
w = 0.318;
h = 0.5 - (22 / 250);
};
};
class controls
{
class Title : Life_RscTitle
{
colorBackground[] = {0, 0, 0, 0};
idc = 3103;
text = "";
x = 0.0821059 * safezoneW + safezoneX;
y = 0.212176 * safezoneH + safezoneY;
w = 0.6;
h = (1 / 25);
};
class ClothingList : Life_RscListBox
{
idc = 3101;
text = "";
sizeEx = 0.035;
onLBSelChanged = "[_this] call life_fnc_changeClothes;";
x = 0.0842977 * safezoneW + safezoneX;
y = 0.240498 * safezoneH + safezoneY;
w = 0.3;
h = 0.35;
};
class PriceTag : Life_RscStructuredText
{
idc = 3102;
text = "";
sizeEx = 0.035;
x = 0.0853304 * safezoneW + safezoneX;
y = 0.439419 * safezoneH + safezoneY;
w = 0.2;
h = (1 / 25);
};
class TotalPrice : Life_RscStructuredText
{
idc = 3106;
text = "";
sizeEx = 0.035;
x = 0.148258 * safezoneW + safezoneX;
y = 0.439419 * safezoneH + safezoneY;
w = 0.2;
h = (1 / 25);
};
class FilterList : Life_RscCombo
{
idc = 3105;
colorBackground[] = {0,0,0,0.7};
onLBSelChanged = "_this call life_fnc_clothingFilter";
x = 0.0822359 * safezoneW + safezoneX;
y = 0.468 * safezoneH + safezoneY;
w = 0.318;
h = 0.035;
};
class CloseButtonKey : Life_RscButtonMenu
{
idc = -1;
text = "$STR_Global_Close";
onButtonClick = "closeDialog 0; [] call life_fnc_playerSkins;";
x = 0.147 * safezoneW + safezoneX;
y = 0.489992 * safezoneH + safezoneY;
w = (6.25 / 40);
h = (1 / 25);
};
class BuyButtonKey : Life_RscButtonMenu
{
idc = -1;
text = "$STR_Global_Buy";
onButtonClick = "[] call life_fnc_buyClothes;";
x = 0.0822359 * safezoneW + safezoneX;
y = 0.489992 * safezoneH + safezoneY;
w = (6.25 / 40);
h = (1 / 25);
};
class viewAngle : life_RscXSliderH
{
color[] = {1, 1, 1, 0.45};
colorActive[] = {1, 1, 1, 0.65};
idc = 3107;
text = "";
onSliderPosChanged = "[4,_this select 1] call life_fnc_s_onSliderChange;";
tooltip = "";
x = 0.25 * safezoneW + safezoneX;
y = 0.95 * safezoneH + safezoneY;
w = 0.5 * safezoneW;
h = 0.02 * safezoneH;
};
};
};
|
d61b8fffb2f38c16fa49e061e670126796d5fba2
|
ea41b223a1956f7b474eafe2b6a30986f0493be8
|
/SDK/杀机_StartScreen_parameters.hpp
|
c31b0c287e1cf2060a3dc87adac05df4776cfca4
|
[] |
no_license
|
Chazyboy775/Dead-by-Daylight-SDK
|
0717a27f79fd4c9da76219894af3f9e2e8c69361
|
28253097481d359694b34dd852222fc75981977c
|
refs/heads/master
| 2022-04-03T17:25:22.678211
| 2020-02-14T02:10:56
| 2020-02-14T02:10:56
| null | 0
| 0
| null | null | null | null |
WINDOWS-1252
|
C++
| false
| false
| 1,228
|
hpp
|
杀机_StartScreen_parameters.hpp
|
#pragma once
// ÀèÃ÷ɱ»ú (4.22.3) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ɱ»ú_StartScreen_classes.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function StartScreen.StartScreen_C.K2Node_MatineeController_1_FadedOutEvent
struct AStartScreen_C_K2Node_MatineeController_1_FadedOutEvent_Params
{
};
// Function StartScreen.StartScreen_C.K2Node_MatineeController_1_Finished
struct AStartScreen_C_K2Node_MatineeController_1_Finished_Params
{
};
// Function StartScreen.StartScreen_C.ReceiveBeginPlay
struct AStartScreen_C_ReceiveBeginPlay_Params
{
};
// Function StartScreen.StartScreen_C.BeginDestroyTravelSequence
struct AStartScreen_C_BeginDestroyTravelSequence_Params
{
};
// Function StartScreen.StartScreen_C.ExecuteUbergraph_StartScreen
struct AStartScreen_C_ExecuteUbergraph_StartScreen_Params
{
int* EntryPoint; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
5d0cc96676c35a7a0364f2433ef3aa7709b3154c
|
2d5a7e8f3454b8577442a7d058768ea3086769ee
|
/homework/hw3-FrozenRouter-master/src/fibonacci.cpp
|
f884f12933c1c390ca8e4b7cec6e087eb02d303b
|
[] |
no_license
|
LoveHRTF/ENGN-2912B
|
3946517c604e360f88c17cff93e353628c22fa6e
|
6650fbe5829a90c1ba790f0a625cdb07e76ebc4b
|
refs/heads/master
| 2020-07-31T00:33:15.036055
| 2019-09-23T18:12:27
| 2019-09-23T18:12:27
| 210,418,342
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 332
|
cpp
|
fibonacci.cpp
|
#include "fibonacci.h"
// TODO: Implement a recursive fibonacci function.
unsigned long long int fibonacci(int n){
unsigned long long int my_Fibonacci;
if (n == 0){
my_Fibonacci = 0;
} else if (n == 1){
my_Fibonacci = 1;
} else {
my_Fibonacci = fibonacci(n-2) + fibonacci(n-1);
}
return my_Fibonacci;
}
|
3029f1e21bee5e1f123c1dc0f8edc8019da11aae
|
c20c4812ac0164c8ec2434e1126c1fdb1a2cc09e
|
/Source/Source/Tools/SceneEditor/KListCtrl.h
|
09931b572546cbf29d27de289f1695de4afec98d
|
[
"MIT"
] |
permissive
|
uvbs/FullSource
|
f8673b02e10c8c749b9b88bf18018a69158e8cb9
|
07601c5f18d243fb478735b7bdcb8955598b9a90
|
refs/heads/master
| 2020-03-24T03:11:13.148940
| 2018-07-25T18:30:25
| 2018-07-25T18:30:25
| 142,408,505
| 2
| 2
| null | 2018-07-26T07:58:12
| 2018-07-26T07:58:12
| null |
UTF-8
|
C++
| false
| false
| 131
|
h
|
KListCtrl.h
|
#pragma once
#include "afxcmn.h"
class KListCtrl : public CListCtrl
{
public:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP()
};
|
547405e39cfaf40d3b471de49cd378b7cb8a1699
|
e0951f0c08fb24ce57d5b6fb3f364e314e94ac67
|
/demo/2016.08.15-c-plus-plus/getting-started/function-default.cpp
|
f661b1da301da6ce93f306634181cf7966c6d0d0
|
[] |
no_license
|
chyingp/blog
|
1a69ddcd8acbcf20c80995d274e81450c278f32f
|
4fcfd719ed01f446d8f1eea721551e71db4909cf
|
refs/heads/master
| 2023-08-27T00:23:18.260234
| 2023-07-27T15:50:03
| 2023-07-27T15:50:03
| 9,654,619
| 491
| 279
| null | 2023-01-12T23:53:47
| 2013-04-24T18:17:08
| null |
UTF-8
|
C++
| false
| false
| 252
|
cpp
|
function-default.cpp
|
#include <iostream>
using namespace std;
// 基础:函数声明+定义
int getMax (int a, int b = 20) {
return a >= b ? a : b;
}
int main () {
int a = 20;
int max = getMax(a);
cout << "max is " << max << endl;
return 0;
}
|
517d217de903775149450bf4c5801d01241d0c92
|
0eff74b05b60098333ad66cf801bdd93becc9ea4
|
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_20232.cpp
|
717083b2f45bd6813f2d18d32a369b43f08d2728
|
[] |
no_license
|
niuxu18/logTracker-old
|
97543445ea7e414ed40bdc681239365d33418975
|
f2b060f13a0295387fe02187543db124916eb446
|
refs/heads/master
| 2021-09-13T21:39:37.686481
| 2017-12-11T03:36:34
| 2017-12-11T03:36:34
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 45
|
cpp
|
Kitware_CMake_repos_basic_block_block_20232.cpp
|
{
SET_REQ_WIN32_ERROR(req, UV_EPERM);
}
|
0cc69d96c53e8f5e2d6185f41ab0965cd13b74b4
|
4491a810f77d635620442c6ef5e70ade50eecbe8
|
/file/[Tjoi 2013]松鼠聚会.cpp
|
c5985277c7eac1339b8c7f3f3d614c29f52dc917
|
[] |
no_license
|
cooook/OI_Code
|
15473a3b7deafa365d20ae36820f3281884209bf
|
45d46b69f2d02b31dcc42d1cd5a5593a343d89af
|
refs/heads/master
| 2023-04-03T21:35:57.365441
| 2021-04-15T14:36:02
| 2021-04-15T14:36:02
| 358,290,530
| 2
| 1
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,348
|
cpp
|
[Tjoi 2013]松鼠聚会.cpp
|
#include <bits/stdc++.h>
#define MAXN 100005
#define int long long
typedef long long ll;
int n,L[MAXN][2],R[MAXN][2],now,sum[MAXN];
template <typename _t>
inline _t read() {
_t x = 0, f = 1; char ch = getchar();
for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -f;
for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
return x * f;
}
struct Point {
int d[2],id;
inline int& operator [] (const int &x) {return d[x];}
inline bool operator < (const Point &x) {
return d[now] == x.d[now]?d[now ^ 1] < x.d[now ^ 1]:d[now] < x.d[now];
}
}pt[MAXN];
inline void Work(bool type) {
now = type;
std::sort(&pt[1],&pt[n+1]);
memset(sum,0,sizeof sum);
for (int i = 1; i <= n; i++) sum[i] = sum[i-1] + (i - 1) * (pt[i][type] - pt[i-1][type]),L[pt[i].id][type] = sum[i];
memset(sum,0,sizeof sum);
for (int i = n; i >= 1; i--) sum[i] = sum[i+1] + (n - i) * (pt[i+1][type] - pt[i][type]),R[pt[i].id][type] = sum[i];
return;
}
signed main() {
n = read<int>();
for (int i = 1; i <= n; i++) {
register int x = read<int>(),y = read<int>();
pt[i][0] = x + y;
pt[i][1] = x - y;
pt[i].id = i;
}
Work(false); Work(true);
ll Ans = 1e18;
for (int i = 1; i <= n; i++) Ans = std::min(Ans,L[i][0] + L[i][1] + R[i][0] + R[i][1]);
printf("%lld\n",Ans >> 1);
getchar(); getchar();
return 0;
}
|
d8680acf77e19d2791c4113d5cd30cd8fa156c20
|
9f2b6abc2913ed2d9794391897e1c22b4ed96681
|
/Game/Object.h
|
5b8776d51f2ede9667251452bdee17934a1b2ceb
|
[] |
no_license
|
Kaktusowy500/Fly-Pigeon-Fly
|
d3489c5c0f659fcc91b169214dee31f27d62914e
|
49f24974039d21d83fccad526d25ee3d055c5eba
|
refs/heads/main
| 2023-04-19T14:55:54.605032
| 2021-05-09T18:34:57
| 2021-05-09T18:34:57
| 365,816,186
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 436
|
h
|
Object.h
|
#pragma once
#include<SFML/Graphics.hpp>
class Object
{
// General class for game objects like obstacles and bonuses
sf::Sprite sprite;
float movementSpeed;
public:
Object(sf::Texture* texture, float x = 400, float y = 400, float widthScale =1.2, float heightScale =1.2);//position (left top corner cords)
virtual ~Object();
virtual sf::FloatRect getBounds() const;
void update();
void render(sf::RenderTarget* target);
};
|
ecfecf6dea4dd98a92fee953fe3dd85eee139d98
|
99893eba68e6cd401a42576f57fe84bf5a0401d5
|
/funcao_exemplo_HX711/funcao_exemplo_HX711.ino
|
361811d955ea4b8ceda4ed2da6b821ef2b39f44f
|
[] |
no_license
|
evans-picolo/ESP8266
|
374f867f10d0f06fee95ecc7d20c03a23c39c24f
|
1be7943891c548c348a39a0ca9c82ff843d2413f
|
refs/heads/master
| 2023-01-04T06:54:21.427163
| 2020-10-12T21:14:03
| 2020-10-12T21:14:03
| 283,371,374
| 0
| 0
| null | 2020-10-04T01:03:49
| 2020-07-29T01:50:52
|
C++
|
UTF-8
|
C++
| false
| false
| 1,213
|
ino
|
funcao_exemplo_HX711.ino
|
/*
Teste de função em C para funcionamento do CI HX711
Conversor AD para célula de carga
Eng. Wagner Rambo
Outubro de 2016
*/
// --- Mapeamento de Hardware ---
#define ADDO 5 //Data Out
#define ADSK 4 //SCK
// --- Protótipo das Funções Auxiliares ---
unsigned long ReadCount(); //conversão AD do HX711
// --- Variáveis Globais ---
unsigned long convert;
// --- Configurações Iniciais ---
void setup()
{
pinMode(ADDO, INPUT_PULLUP); //entrada para receber os dados
pinMode(ADSK, OUTPUT); //saída para SCK
Serial.begin(9600);
} //end setup
// --- Loop Infinito ---
void loop()
{
convert = ReadCount();
Serial.println(convert);
delay(100);
} //end loop
// --- Funções ---
unsigned long ReadCount()
{
unsigned long Count = 0;
unsigned char i;
digitalWrite(ADSK, LOW);
while(digitalRead(ADDO));
for(i=0;i<24;i++)
{
digitalWrite(ADSK, HIGH);
Count = Count << 1;
digitalWrite(ADSK, LOW);
if(digitalRead(ADDO)) Count++;
} //end for
digitalWrite(ADSK, HIGH);
Count = Count^0x800000;
digitalWrite(ADSK, LOW);
return(Count);
} //end ReadCount
|
d72bc32997d8de2312aa824b90eee5ce31e4c5be
|
8a0a2fccd4f622a288a87cb29f8d040a40dfd2d6
|
/src/calculator.cpp
|
c246e085f8ffe59ed5fd4a84d564c2fc8bb13533
|
[] |
no_license
|
plugosh/CalculatorQT
|
fae9eb21926a1b8af7b956d67f61139df905bb6b
|
5f68f7d1b36d9d7f1ec7f58ac54ca9d48a3a22b7
|
refs/heads/master
| 2022-12-27T14:08:13.960228
| 2020-10-10T10:01:36
| 2020-10-10T10:01:36
| 286,767,065
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,526
|
cpp
|
calculator.cpp
|
#include "calculator.h"
#include "ui_calculator.h"
#include <math.h>
Calculator::Calculator(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Calculator)
{
ui->setupUi(this);
//SADFSADFASDFSA
ui->det2->setText(QString::number(0));
ui->Display->setText(QString::number(0));
ui->shiftWidget->setVisible(false);
ui->matrixWidget->setVisible(false);
ui->ApplyWidget->setVisible(false);
ui->toggleRad->setStyleSheet("background-color: #D2691E");
ui->toggleDeg->setStyleSheet("background-color: MistyRose");
//numbers and trygonometry
QPushButton *sButtons[18];
for(int i=0;i<18;++i)
{
QString buttonName="b_"+QString::number(i);
sButtons[i]=Calculator::findChild<QPushButton *>(buttonName);
if(i<10){
connect(sButtons[i], SIGNAL(released()),this,SLOT(NumberPressed()));
}
else {
connect(sButtons[i], SIGNAL(released()),this,SLOT(TrgFunctions()));
}
}
connect(ui->add,SIGNAL(released()),this,SLOT(fadd()));
connect(ui->subtract,SIGNAL(released()),this,SLOT(fsubtract()));
connect(ui->divade,SIGNAL(released()),this,SLOT(fdivade()));
connect(ui->multiply,SIGNAL(released()),this,SLOT(fmultiply()));
connect(ui->allClear,SIGNAL(released()),this,SLOT(allClear()));
connect(ui->b_leftBracket,SIGNAL(released()),this,SLOT(leftBracket()));
connect(ui->b_rightBracket,SIGNAL(released()),this,SLOT(rightBracket()));
connect(ui->b_clear,SIGNAL(released()),this,SLOT(Clear()));
connect(ui->Off,SIGNAL(released()),this,SLOT(TurnOff()));
connect(ui->OFF2,SIGNAL(released()),this,SLOT(TurnOff()));
connect(ui->Log,SIGNAL(released()),this,SLOT(Log()));
connect(ui->naturalLog,SIGNAL(released()),this,SLOT(Ln()));
connect(ui->power,SIGNAL(released()),this,SLOT(xPowy()));
connect(ui->b_e,SIGNAL(released()),this,SLOT(e()));
connect(ui->b_PI,SIGNAL(released()),this,SLOT(PI()));
connect(ui->b_e_2,SIGNAL(released()),this,SLOT(e()));
connect(ui->b_PI_2,SIGNAL(released()),this,SLOT(PI()));
connect(ui->root,SIGNAL(released()),this,SLOT(SquareRoot()));
connect(ui->SHIFT,SIGNAL(released()),this,SLOT(shiftChange()));
connect(ui->SHIFT_2,SIGNAL(released()),this,SLOT(shiftChange()));
connect(ui->toComplex,SIGNAL(released()),this,SLOT(matrixChange()));
connect(ui->toCalc,SIGNAL(released()),this,SLOT(matrixChange()));
connect(ui->toggleDeg,SIGNAL(released()),this,SLOT(SetDeg()));
connect(ui->toggleRad,SIGNAL(released()),this,SLOT(SetRad()));
connect(ui->epowx,SIGNAL(released()),this,SLOT(ePowx()));
connect(ui->tenpowx,SIGNAL(released()),this,SLOT(tenPowx()));
connect(ui->b_DOT,SIGNAL(released()),this,SLOT(dotButton()));
connect(ui->solution,SIGNAL(released()),this,SLOT(SOLUTION()));
connect(ui->Det,SIGNAL(released()),this,SLOT(SetDet()));
connect(ui->Rev,SIGNAL(released()),this,SLOT(SetReverse()));
connect(ui->ClearMatrix,SIGNAL(released()),this,SLOT(ClearMatrix()));
connect(ui->Add,SIGNAL(released()),this,SLOT(addMatrix()));
connect(ui->Mult,SIGNAL(released()),this,SLOT(multMatrix()));
connect(ui->Apply,SIGNAL(released()),this,SLOT(addmultMatrix()));
}
Calculator::~Calculator()
{
delete ui;
}
void Calculator::NumberPressed()
{
QPushButton *button=(QPushButton *)sender();
QString buttonValue = button->text();
QString displayValue = ui->Display->text();
Calculator::CheckIfZero(isZero);
if(isZero)
{
ui->Display->setText(buttonValue);
}
else
{
std::string isbracket = displayValue.toStdString();
if(isbracket[isbracket.size()]-1==')')
{
ui->Display->setText(displayValue+"*"+buttonValue);
}
else
{
ui->Display->setText(displayValue+buttonValue);
}
}
lastSign = buttonValue;
}
void Calculator::allClear()
{
ui->Display->setText("0");
lastSign = 'n';
}
void Calculator::Clear()
{
QString DisplayValue=ui->Display->text();
std::string DisVal = DisplayValue.toStdString();
int size = DisVal.size();
if(size>1)
{
DisVal.erase(size-1,1);
DisplayValue=(QString::fromStdString(DisVal));
ui->Display->setText(DisplayValue);
}
else
{
ui->Display->setText("0");
}
lastSign = DisVal[DisVal.size()-1];
}
void Calculator::TurnOff()
{
QApplication::quit();
}
|
070daeb7712af2fb9f1a6dbcd193e2d044a1a084
|
efef952b7038a1c6222cb3428a1ddd5ef4dbc388
|
/BO.cpp
|
b786493ed49a380bf53e41fdab7d16f806fc9445
|
[] |
no_license
|
shuhei-ut/sotsuron
|
e8bce1abe71be4aa78b2ff4da7ba7daa754af0a3
|
fe583b2cc43068c1472a0d3787bc58b024bf2c7e
|
refs/heads/master
| 2021-05-30T09:02:25.936725
| 2015-12-26T11:25:26
| 2015-12-26T11:25:26
| null | 0
| 0
| null | null | null | null |
SHIFT_JIS
|
C++
| false
| false
| 3,187
|
cpp
|
BO.cpp
|
#include <iostream>
#include <Eigen/Dense>
#include <time.h>
#include "const.h"
#include "myfunc.h"
#include "obj.h"
#include "sev.h"
#include "argmax.h"
#include "debug.h"
using namespace std;
using namespace Eigen;
Eigen::VectorXd k(Eigen::VectorXd x){
if (t == 0){
//【起こり得ない状況】//
return VectorXd::Zero(1);
}
else{
VectorXd kx = VectorXd::Zero(t);
for (int i = 0; i < t; i++){
kx(i) = kernel(x, D_q.col(i));
}
return kx;
}
}
void update_m(){
VectorXd ones = VectorXd::Constant(t, 1.0);
VectorXd v = Kinv.topLeftCorner(t, t) * ones;
double a = v.transpose() * f.head(t);
double b = v.transpose() * ones;
mean = a / b;
}
void update_K(Eigen::VectorXd x){ // x = x_nextを想定
if (t == 0){
K(0,0) = 1;
Kinv(0,0) = 1;
}
else{
//Kの更新
VectorXd kx = k(x);
K.block(0,t,t,1) = kx;
K.block(t,0,1,t) = kx.transpose();
K(t, t) = 1;
//Ainv, Sinvの計算
MatrixXd Ainv = Kinv.topLeftCorner(t,t);
double S = 1 - kx.transpose()*Ainv*kx;
double Sinv = 1 / S;
//Kinvの更新
Kinv.topLeftCorner(t, t) = Ainv + Sinv*(Ainv * kx * kx.transpose() * Ainv);
VectorXd binv = -Sinv*Ainv*kx;
Kinv.block(0, t, t, 1) = binv;
Kinv.block(t, 0, 1, t) = binv.transpose();
Kinv(t, t) = Sinv;
}
}
double mu(Eigen::VectorXd x){
if (t == 0)
return mean;
else{
VectorXd m1 = VectorXd::Constant(t, mean);
VectorXd kx = k(x);
return mean + kx.transpose() * Kinv.topLeftCorner(t, t) * (f.head(t)-m1.head(t));
}
}
double sigma(Eigen::VectorXd x){
VectorXd kx = k(x);
double sigma2 = 1 - kx.transpose() * Kinv.topLeftCorner(t, t) * kx;
if (sigma2 < 0)
return 0;
else
return sqrt(sigma2);
}
double u(Eigen::VectorXd x){
double sigma_ = sigma(x);
if (sigma_ < sigma_thre)
return 0;
else{
double mu_ = mu(x);
double gamma = (mu_ - maxf) / sigma_;
return (mu_ - maxf)*cdf(gamma) + sigma_*pdf(gamma);
}
}
VectorXd u_over_k(VectorXd x){
double sigma_ = sigma(x);
double mu_ = mu(x);
double gamma = (mu_ - maxf) / sigma_;
VectorXd m1 = VectorXd::Constant(t,mean);
VectorXd v = VectorXd::Zero(t);
v = cdf(gamma)*(f.head(t) - m1.head(t)) - (pdf(gamma) / sigma_)*k(x);
return Kinv.topLeftCorner(t, t)*v;
}
MatrixXd k_over_x(VectorXd x){
MatrixXd A = MatrixXd::Zero(d, t);
for (int j = 0; j < t; j++){
A.col(j) = kernel(D_q.col(j), x) * (D_q.col(j) - x);
}
return A;
}
VectorXd u_over_x(VectorXd x){
if (sigma(x) < sigma_thre)
return VectorXd::Zero(d);
else
return k_over_x(x)*u_over_k(x);
}
pair<double, VectorXd> BO(){
VectorXd x_next = VectorXd::Zero(d);
VectorXd x_opt = VectorXd::Zero(d);
for (t = 0; t < T; t++){
//【tはこの時点におけるデータセットのサイズ】//
update_m();
x_next = argmax_u();
debug_inside(x_next, x_opt);
//データセットの更新
D_q.col(t) = x_next;
f(t) = sev_x(x_next, (Uy0 + Ly0) / 2, Uy0, Ly0).first;
if (f(t)>maxf){
maxf = f(t);
x_opt = x_next;
t_find = t;
finding_time_BO = clock();
}
//【この時点でデータセットのサイズはt+1】//
update_K(x_next);
//【updateが行われた後,Kのサイズはt+1】//
}
return make_pair(maxf, x_opt);
}
|
9728473940cf4d7737b8ed2b96ecf0a9831f2787
|
06aca2ae0b2b1f66378b4ae52ba52fbc16c2be43
|
/Pong/Balle.h
|
1f4d49e336637ddb388c2d448303fbd87593b201
|
[] |
no_license
|
klaoude/Pong
|
17ee2a88d40452e739d57da398420daa4139ddd5
|
1f6efa94d3690686edd8bf9a4de9a7185fe73066
|
refs/heads/master
| 2016-09-06T19:55:57.287304
| 2015-09-29T20:10:19
| 2015-09-29T20:10:19
| 21,369,165
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 347
|
h
|
Balle.h
|
#pragma once
#include <SDL.h>
class Balle
{
public:
Balle();
Balle(int x, int y, SDL_Surface* surface);
~Balle();
void render(SDL_Surface* surface);
void moveR();
void moveL();
void moveDiago();
Uint32 getId();
SDL_Rect getRect();
private:
static Uint32 currentId;
Uint32 id;
SDL_Surface* balle;
SDL_Rect rect;
};
|
03b62bbdf62d7d71f202c4330a729478cd96a46d
|
2f1364cbbb9691c89a06c03c1e909c2371c93a35
|
/Part_5_A_Playable _Game/Playable/bulletPool.h
|
6e69bf2b09d5fc9e7cdb2a8d4a4b3fb943decfbe
|
[] |
no_license
|
romitgodi/2D-Game-Design
|
19d014cd1af568c3485149db5183856662a33fcb
|
4a0639adeb53374218e675a5877821904287f93a
|
refs/heads/master
| 2021-07-25T22:02:59.218441
| 2017-11-08T00:11:50
| 2017-11-08T00:11:50
| 105,484,188
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 847
|
h
|
bulletPool.h
|
#ifndef _BULLETPOOL_H
#define _BULLETPOOL_H
#include <list>
#include "bullet.h"
class BulletPool {
public:
BulletPool(const std::string& );
BulletPool(const BulletPool& );
~BulletPool();
void draw() const;
void update( Uint32 ticks);
void shoot(const Vector2f& pos, const Vector2f& vel);
unsigned int bulletCount() const { return bulletList.size(); }
unsigned int freeCount() const { return freeList.size(); }
bool shooting() const { return bulletList.empty(); }
bool hasBulletCollided(const Drawable* d);
void drawHUD();
void clearList();
private:
std::string name;
SDL_Surface* bulletSurface;
Frame* bulletFrame;
float frameInterval;
float timeSinceLastFrame;
mutable std::list<Bullet> bulletList;
mutable std::list<Bullet> freeList;
BulletPool& operator=(const BulletPool&);
};
#endif /* _BULLETPOOL_H */
|
eae29269a7d789f8c5bb1a367d2edd376ad45c5e
|
5a25d05923d17dd56df81ae482ffe7c43c769cff
|
/Source/DungeonMathster/StartRoom.h
|
4c3b392d1d41a71ddca1bd9787ceb5f08ced906f
|
[] |
no_license
|
skypekitten9/Dungeon-Query
|
2a9bfcd44308d2fbe0964e87c67165c98ebfbf95
|
16626605648e1fd18fc85194ec3bd11f6b28a8fd
|
refs/heads/master
| 2023-04-03T12:09:50.566832
| 2021-04-15T15:24:37
| 2021-04-15T15:24:37
| 351,754,354
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,119
|
h
|
StartRoom.h
|
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/TriggerBox.h"
#include "Components/TextRenderComponent.h"
#include "Door.h"
#include "Internationalization/Text.h"
#include "HighscoreSave.h"
#include "Kismet/GameplayStatics.h"
#include "StartRoom.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class DUNGEONMATHSTER_API UStartRoom : public UActorComponent
{
GENERATED_BODY()
public:
UStartRoom();
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
protected:
virtual void BeginPlay() override;
private:
void SetupDoor();
void SetupPlayer();
void VerifyTriggerVolume();
void SetupTextComponent();
void LoadHighscore();
UPROPERTY(EditAnywhere) AActor* DoorActor = nullptr;
UPROPERTY(EditAnywhere) ATriggerBox* TriggerVolume = nullptr;
bool HasOpenedDoor = false;
UDoor* DoorComponent = nullptr;
UTextRenderComponent* TextComponent = nullptr;
AActor* Player = nullptr;
};
|
59ad5a5f7610628190b7d98ab868ac73122aed12
|
9f7d3ade04219b868c9041a0b58b85039e705b18
|
/Stack/Stack/LinkedStack.h
|
ca430a6f4dffe0ef49bccbfe04a29723c2dcbe22
|
[] |
no_license
|
semerdzhiev/sdp-samples
|
afd6d514f093ea25bf604fffa3d101efd605e0da
|
715ad17dde43a291520e82e71dc2c657a1609dc4
|
refs/heads/master
| 2021-12-12T13:58:22.754923
| 2021-12-05T22:10:13
| 2021-12-05T22:10:13
| 24,499,959
| 43
| 34
| null | 2021-10-04T05:48:00
| 2014-09-26T13:14:50
|
C++
|
UTF-8
|
C++
| false
| false
| 5,650
|
h
|
LinkedStack.h
|
/********************************************************************
*
* This file is part of the Data structures and algorithms in C++ package
*
* Author: Atanas Semerdzhiev
* URL: https://github.com/semerdzhiev/sdp-samples
*
*/
#pragma once
#include <exception>
///
/// An linked implementation of a FILO stack
///
/// The size of the stack grows and shrinks dynamically
/// depending on the number of stored elements.
/// Memory for the stack's elements is allocated on the heap.
///
/// \tparam TYPE
/// Type of the elements stored in the stack
///
template <typename TYPE>
class LinkedStack {
class Box {
public:
TYPE Data;
Box* pNext;
Box(const TYPE& Data, Box* pNext = NULL)
: Data(Data), pNext(pNext)
{
}
};
private:
Box* pTop; /// Pointer to the top of the stack
size_t Size; /// Number of elements in the stack
public:
///
/// Constructs an empty stack
///
LinkedStack()
{
ZeroVariables();
}
///
/// Destructor
///
~LinkedStack()
{
Destroy();
}
///
/// Copy construtor
///
/// \exception std::bad_alloc If memory allocation fails
///
LinkedStack(LinkedStack const & Other)
{
ZeroVariables();
CopyFrom(Other); // CopyFrom cleans up all resouces
// if copying fails
}
///
/// The operator frees the currently allocated memory first
/// and after that performs the copying.
/// If copying fails, the stack will be left empty.
///
/// \exception std::bad_alloc If memory allocation fails
///
LinkedStack& operator=(const LinkedStack & Other)
{
if (this != &Other)
{
Destroy();
CopyFrom(Other);
}
return *this;
}
public:
///
/// Pushes a new element on the stack
///
/// \exception std::bad_alloc If memory allocation fails
///
void Push(const TYPE & Element)
{
pTop = new Box(Element, pTop);
++Size;
}
///
/// Removes and returns the element on top of the stack
///
/// \param [out] Element
/// A parameter, which will receive the value of the top element.
/// If the stack is empty, this element will not be altered.
///
/// \return
/// true if the operation was successful or
/// false if the stack was empty.
///
bool Pop(TYPE& Element)
{
if (Size == 0)
return false;
Element = pTop->Data;
Pop();
return true;
}
///
/// Removes the element on the top of the stack
///
/// If the stack is empty, the function does nothing
///
void Pop()
{
if (pTop)
{
Box* pOld = pTop;
pTop = pTop->pNext;
delete pOld;
--Size;
}
}
///
/// Retrieves the element on the top of the stack
///
/// \exception std::exception If the stack is empty
///
TYPE& Peek()
{
if (Size == 0)
throw std::exception();
return pTop->Data;
}
const TYPE& Peek() const
{
if (Size == 0)
throw std::exception();
return pTop->Data;
}
///
/// Empties the stack
///
/// The function removes all elements and
/// frees the memory allocated for the stack.
///
void Clear()
{
Destroy();
}
///
/// Returns the number of elements currently stored in the stack
///
size_t GetSize() const
{
return Size;
}
///
/// Checks whether the stack is empty
///
bool IsEmpty() const
{
return Size == 0;
}
private:
///
/// Assigns initial values for the data-members of the object
///
/// The values are proper for an empty stack for which no memory
/// is allocated. e.g. on construction or after freeing the memory.
///
void ZeroVariables()
{
pTop = 0;
Size = 0;
}
///
/// Empties the stack and frees the allocated memory
///
void Destroy()
{
Box* p;
while (pTop)
{
p = pTop;
pTop = pTop->pNext;
delete p;
}
ZeroVariables();
}
///
/// Makes the current object a copy of another one
///
/// The function assumes that the object is empty
/// (i.e. no memory is allocated for it)
///
/// \param Other
/// Object to copy from. Can be either empty or non-empty
///
/// \exception std::bad_alloc
/// If the copy operation fails
///
void CopyFrom(const LinkedStack & Other)
{
if (Other.IsEmpty())
return;
Box *ours, *theirs;
// Create a copy of the chain of elements in Other.
// If copying fails, the function should clean up.
try
{
pTop = new Box(Other.pTop->Data);
ours = pTop;
theirs = Other.pTop->pNext;
while (theirs)
{
ours->pNext = new Box(theirs->Data);
ours = ours->pNext;
theirs = theirs->pNext;
}
Size = Other.Size;
}
catch (std::bad_alloc&)
{
Destroy(); // OK to call it, because:
// 1. pTop points to the top of the cloned chain
// 2. Boxes are allocated in such a manner, so that the
// for the last box pNext == NULL
throw;
}
}
};
|
5a4374dac9b7cc831f3674f924fee688cb8dce51
|
ba4fbf70e05754385cf29b7adc7a3948e5ab6c46
|
/qsort_compiletime.cc
|
4712d2e087bb66c4afb6bce190baae3566842f43
|
[] |
no_license
|
catterer/problems
|
db57ce2d2581ffd47ab94e92a39b9b17d9ab011b
|
2da31fc0252a19985f0f739924a0325c4b78ab1e
|
refs/heads/master
| 2023-03-10T09:14:41.864030
| 2023-02-26T09:54:23
| 2023-02-26T09:54:23
| 82,280,108
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,941
|
cc
|
qsort_compiletime.cc
|
#include <iostream>
// template<typename T>
// class Writer;
// template<>
// class Writer<int> {
// public:
// static void write(int t) {
// std::cout << "i" << t << "\n";
// }
// };
// template<int i>
// class Writer<char[i]> {
// public:
// static void write(const char* c) {
// std::cout << c << "\n";
// }
// };
// template<typename T, typename ...Args>
// void write(const T& t, Args&& ...args) {
// Writer<T>::write(t);
// if constexpr (sizeof...(args) > 0)
// write(std::forward<Args>(args)...);
// }
template<typename T, T ...Elements>
struct List;
template<typename T, T Head, T ...Tail>
struct List<T, Head, Tail...> {
using tail = List<T, Tail...>;
};
template<typename L>
struct Swap;
template<typename T, T el1, T el2, T ...Tail>
struct Swap<List<T, el1, el2, Tail...>> {
using type = List<T, el2, el1, Tail...>;
};
template<typename La, typename Lb>
struct Concat;
template<typename T, T... TailA, T ...TailB>
struct Concat<List<T, TailA...>, List<T, TailB...>> {
using type = List<T, TailA..., TailB...>;
};
template<bool B, typename T, typename F>
struct Cond {
using type = T;
};
template<typename T, typename F>
struct Cond<false,T,F> {
using type = F;
};
template<typename L, auto val,
template<auto a, auto b> typename Pred>
struct Filter;
template<typename T, T Val, template<T a, T b> typename Pred>
struct Filter<List<T>, Val, Pred> {
using type = List<T>;
};
template<typename T, T Head, T ...Tail, T Val, template<T a, T b> typename Pred>
struct Filter<List<T, Head, Tail...>, Val, Pred>{
using filtered_tail = typename Filter<List<T, Tail...>, Val, Pred>::type;
using type = typename Cond<
Pred<Head, Val>::value,
typename Concat<List<T, Head>, filtered_tail>::type,
filtered_tail
>::type;
};
template<int a, int b>
struct IntLess {
static constexpr bool value = a < b;
};
template<int a, int b>
struct IntGE {
static constexpr bool value = a >= b;
};
template<typename L>
struct QuickSelect;
template<typename T>
struct QuickSelect<List<T>> {
using lesser = List<T>;
using greater = List<T>;
};
template<typename T, T V, T ...Tail>
struct QuickSelect<List<T, V, Tail...>> {
static constexpr T base = V;
using lesser = typename Filter<List<T, Tail...>, V, IntLess>::type;
using greater = typename Filter<List<T, Tail...>, V, IntGE>::type;
};
template<typename L>
struct Qsort;
template<typename T>
struct Qsort<List<T>> {
using type = List<T>;
};
template<typename T, T V>
struct Qsort<List<T, V>> {
using type = List<T, V>;
};
template<typename T, T Va, T Vb, T ...Tail>
struct Qsort<List<T, Va, Vb, Tail...>> {
using QS = QuickSelect<List<T, Va, Vb, Tail...>>;
using left = typename Qsort<typename QS::lesser>::type;
using right = typename Qsort<typename QS::greater>::type;
using type = typename Concat<left,typename Concat<List<T, QS::base>, right>::type>::type;
};
int main() {
List<int, 1,2,3> l;
static_assert(std::is_same<List<int, 2,1>::tail, List<int, 1>>::value);
(void)l;
static_assert(std::is_same<Swap<List<int, 1, 2, 3>>::type, List<int, 2, 1, 3>>::value);
static_assert(std::is_same<Concat<List<int, 1, 2>, List<int, 3, 4>>::type, List<int, 1,2,3,4>>::value);
static_assert(std::is_same<Concat<List<int>, List<int, 3, 4>>::type, List<int,3,4>>::value);
static_assert(std::is_same<Concat<List<int>, List<int>>::type, List<int>>::value);
static_assert(std::is_same<Filter<List<int, 1, 2, 3, 2>, 3, IntLess>::type, List<int, 1,2,2>>::value);
static_assert(std::is_same<QuickSelect<List<int, 5, 1, 6, 2, 7>>::lesser, List<int, 1, 2>>::value);
static_assert(std::is_same<QuickSelect<List<int, 5, 1, 6, 2, 7>>::greater, List<int, 6, 7>>::value);
static_assert(std::is_same<Qsort<List<int, 5, 1, 6, 2, 7>>::type, List<int, 1, 2, 5, 6, 7>>::value);
return 0;
}
|
3156a14e29c1a9db31ac450a27f782135be15319
|
f6f71cfb5ee9ee5604a969e3b5ad07ff88b922f8
|
/Library/Alive.cpp
|
946906ac5e14db64d6a78905f738a2d0844b1a3b
|
[] |
no_license
|
paulmedok/Shop
|
4ff4e6987fb6baf2a2773f552692e16a3ac861ed
|
f0d27167653ae0c3e06975a75d42c609e5486795
|
refs/heads/master
| 2016-09-05T16:57:07.147061
| 2015-09-03T09:40:59
| 2015-09-03T09:40:59
| 41,851,964
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 971
|
cpp
|
Alive.cpp
|
#include "stdafx.h"
#include "Alive.h"
Alive::Alive(char* name, char* color, double price){
mPrice = price;
mName = name;
mColor = color;
}
Alive::Alive(const Alive &Right){
mPrice = Right.mPrice;
int nLength = strlen(Right.mName) + 1;
mName = new char[nLength];
memcpy(mName, Right.mName, sizeof(char)*nLength);
nLength = strlen(Right.mColor) + 1;
mColor = new char[nLength];
memcpy(mColor, Right.mColor, sizeof(char)*nLength);
}
Alive::~Alive()
{
delete mName;
delete mColor;
}
void Alive::SetPrice(double price){
mPrice = price;
}
double Alive::GetPrice(){
return mPrice;
}
void Alive::SetName(char *name){
int nLength = strlen(name) + 1;
mName = new char[nLength];
memcpy(mName, name, sizeof(char)*nLength);
}
char* Alive::GetName(){
return mName;
}
void Alive::SetColor(char *color){
int nLength = strlen(color) + 1;
mColor = new char[nLength];
memcpy(mColor, color, sizeof(char)*nLength);
}
char* Alive::GetColor(){
return mColor;
}
|
37c3867b6cfc227ce6a90e329def9fc31b7c81d6
|
05db8a70a2134afc5c830b7f2af779647f643202
|
/src/request/EzyRequestSerializer.cpp
|
d0f8f2fe190a9a4e09465243bcff2375a100299c
|
[] |
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
| 316
|
cpp
|
EzyRequestSerializer.cpp
|
#include "EzyRequestSerializer.h"
EZY_NAMESPACE_START_WITH(request)
entity::EzyArray* EzyRequestSerializer::serialize(int cmd, entity::EzyArray* data) {
auto array = entity::EzyArray::create();
array->addInt(cmd);
array->addItem(data);
array->retain();
return array;
}
EZY_NAMESPACE_END_WITH
|
143100446a8a53ef50e346e14252e42ec2458ad1
|
5ec18020303e8b3c5c383d780c1fa2ed42701f86
|
/include/ts_extractor.h
|
e394d63ed9a4d3bc14d9c389eb4c7becdb3d086e
|
[] |
no_license
|
seranu/TS2RAW
|
cc8e99ef8321e29783e2e1369610b887c737d7ff
|
039bb4598cb28e8767e8620c89e25094197108f9
|
refs/heads/master
| 2021-07-19T08:44:34.878551
| 2017-10-25T19:24:09
| 2017-10-25T19:24:09
| 107,693,690
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 734
|
h
|
ts_extractor.h
|
#ifndef _TS_EXTRACTOR_H_
#define _TS_EXTRACTOR_H_
#include <string>
#include "utils.h"
namespace ts2raw {
// class that can be used to separate video and
// audio data from input TS stream file
class TSExtractor {
public:
// Extract video and audio raw data from TS stream
// <aInputFilename> file path of input TS stream file
// <aOutputVideoFilename> file path of output video file
// <aOutputAudioFilename> file path of output audio file
// @throws TSException
static void Extract(const std::string& aInputFilename,
const std::string& aOutputVideoFilename,
const std::string& aOutputAudioFilename);
};
} // namespace ts2raw
#endif //_TS_EXTRACTOR_H_
|
3f13c0a641f0d049039671636bf33df1cad2a509
|
42ab733e143d02091d13424fb4df16379d5bba0d
|
/libs/utils/include/utils/ostream.h
|
cc4df031fae653497b9e7e144bac6b141b3b8028
|
[
"Apache-2.0",
"CC0-1.0",
"LicenseRef-scancode-unknown-license-reference"
] |
permissive
|
google/filament
|
11cd37ac68790fcf8b33416b7d8d8870e48181f0
|
0aa0efe1599798d887fa6e33c412c09e81bea1bf
|
refs/heads/main
| 2023-08-29T17:58:22.496956
| 2023-08-28T17:27:38
| 2023-08-28T17:27:38
| 143,455,116
| 16,631
| 1,961
|
Apache-2.0
| 2023-09-14T16:23:39
| 2018-08-03T17:26:00
|
C++
|
UTF-8
|
C++
| false
| false
| 4,285
|
h
|
ostream.h
|
/*
* Copyright (C) 2019 The Android Open Source Project
*
* 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.
*/
#ifndef TNT_UTILS_OSTREAM_H
#define TNT_UTILS_OSTREAM_H
#include <utils/bitset.h>
#include <utils/compiler.h>
#include <utils/PrivateImplementation.h>
#include <string>
#include <string_view>
#include <utility>
namespace utils::io {
struct ostream_;
class UTILS_PUBLIC ostream : protected utils::PrivateImplementation<ostream_> {
friend struct ostream_;
public:
virtual ~ostream();
ostream& operator<<(short value) noexcept;
ostream& operator<<(unsigned short value) noexcept;
ostream& operator<<(char value) noexcept;
ostream& operator<<(unsigned char value) noexcept;
ostream& operator<<(int value) noexcept;
ostream& operator<<(unsigned int value) noexcept;
ostream& operator<<(long value) noexcept;
ostream& operator<<(unsigned long value) noexcept;
ostream& operator<<(long long value) noexcept;
ostream& operator<<(unsigned long long value) noexcept;
ostream& operator<<(float value) noexcept;
ostream& operator<<(double value) noexcept;
ostream& operator<<(long double value) noexcept;
ostream& operator<<(bool value) noexcept;
ostream& operator<<(const void* value) noexcept;
ostream& operator<<(const char* string) noexcept;
ostream& operator<<(const unsigned char* string) noexcept;
ostream& operator<<(std::string const& s) noexcept;
ostream& operator<<(std::string_view const& s) noexcept;
ostream& operator<<(ostream& (* f)(ostream&)) noexcept { return f(*this); }
ostream& dec() noexcept;
ostream& hex() noexcept;
protected:
ostream& print(const char* format, ...) noexcept;
class Buffer {
public:
Buffer() noexcept;
~Buffer() noexcept;
Buffer(const Buffer&) = delete;
Buffer& operator=(const Buffer&) = delete;
const char* get() const noexcept { return buffer; }
std::pair<char*, size_t> grow(size_t s) noexcept;
void advance(ssize_t n) noexcept;
void reset() noexcept;
private:
void reserve(size_t newSize) noexcept;
char* buffer = nullptr; // buffer address
char* curr = nullptr; // current pointer
size_t size = 0; // size remaining
size_t capacity = 0; // total capacity of the buffer
};
Buffer& getBuffer() noexcept;
Buffer const& getBuffer() const noexcept;
private:
virtual ostream& flush() noexcept = 0;
friend ostream& hex(ostream& s) noexcept;
friend ostream& dec(ostream& s) noexcept;
friend ostream& endl(ostream& s) noexcept;
friend ostream& flush(ostream& s) noexcept;
enum type {
SHORT, USHORT, CHAR, UCHAR, INT, UINT, LONG, ULONG, LONG_LONG, ULONG_LONG, FLOAT, DOUBLE,
LONG_DOUBLE
};
const char* getFormat(type t) const noexcept;
};
// handles utils::bitset
inline ostream& operator << (ostream& o, utils::bitset32 const& s) noexcept {
return o << (void*)uintptr_t(s.getValue());
}
// handles vectors from libmath (but we do this generically, without needing a dependency on libmath)
template<template<typename T> class VECTOR, typename T>
inline ostream& operator<<(ostream& stream, const VECTOR<T>& v) {
stream << "< ";
for (size_t i = 0; i < v.size() - 1; i++) {
stream << v[i] << ", ";
}
stream << v[v.size() - 1] << " >";
return stream;
}
inline ostream& hex(ostream& s) noexcept { return s.hex(); }
inline ostream& dec(ostream& s) noexcept { return s.dec(); }
inline ostream& endl(ostream& s) noexcept { s << '\n'; return s.flush(); }
inline ostream& flush(ostream& s) noexcept { return s.flush(); }
} // namespace utils::io
#endif // TNT_UTILS_OSTREAM_H
|
6927606e0424e027adc315936c41c1b3d5df4708
|
bd0636c61421941ee9d44d3ded8941e94a1a9de8
|
/sensorbug/sensorbug.h
|
f4ae0d5a1cb67d1abf0bb7b686862435ca9a7721
|
[] |
no_license
|
BluBugTwob/BluBug
|
3a0305953747b73140b164996dc850ba92259c4e
|
9277fd3fa3087f0f76ea3303d8874285c981dd8c
|
refs/heads/master
| 2021-01-12T12:06:29.714143
| 2016-10-29T18:03:20
| 2016-10-29T18:03:20
| 72,300,848
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 510
|
h
|
sensorbug.h
|
/*
sensor.h - Library for flashing sensor code.
Created by sathishkumar, july, 2016.
Released into the public domain.
*/
#ifndef sensorbug_h
#define sensorbug_h
#include "Arduino.h"
class sensorbug
{
public:
float sensor1();
float sensor2();
float sensor3();
float sensor4();
float sensor5();
float sensor6();
float ultrastart();
float ultrainchval( float);
float ultracmval( float);
float ultrainch();
float ultracm();
};
#endif
|
5162cbe5305ba648ca824e458167f977ffe4316d
|
2a980c53768d643eaee47bee14a1a9573696040b
|
/MatrixMultiplication/matrix.cpp
|
a694f9b045d774602c4d272af666e2836bdb584c
|
[] |
no_license
|
hamedrq7/Strassen-s-Matrix-Multiplication
|
1f5f415634e83760adf064f93d93e833fae04a23
|
a6fb47f2702b624f923454765db94734e68ae249
|
refs/heads/master
| 2021-04-24T12:42:23.392175
| 2020-03-26T00:11:12
| 2020-03-26T00:11:12
| 250,119,874
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 4,274
|
cpp
|
matrix.cpp
|
//
// Created by hamed on 3/24/2020.
//
#include "matrix.h"
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
int matrix::getCols() {return this->cols;}
int matrix::getRows() {return this->rows;}
void matrix::setCols(int inputCols) {this->cols = inputCols;}
void matrix::setRows(int inputRows) {this->rows = inputRows;}
void matrix::show() {
//cout << "Matrix: \n";
for(int i = 0; i < this->rows; i++)
{
for(int j = 0; j < this->cols; j++)
{
cout << this->numbers[i][j] << " ";
}
cout << "\n";
}
}
void matrix::setMatrix() {
for(int i = 0; i < this->rows; i++)
{
vector <int> v;
this->numbers.push_back(v);
for(int j = 0; j < this->cols; j++)
{
int temp;
cin >> temp;
numbers[i].push_back(temp);
}
}
}
matrix::matrix(int row, int col, bool set) {
this -> rows = row;
this -> cols = col;
if(set) {
setMatrix();
}
}
matrix::matrix() = default;
matrix::matrix(matrix a, matrix b) {
if(a.getCols() != b.getRows()) {
cout << "Invalid! (rows!=cols)\n";
this->~matrix();
}
else {
this->rows = a.getRows();
this->cols = b.getCols();
for(int i = 0; i < a.getRows(); i++) {
vector <int> v;
this->numbers.push_back(v);
for(int j = 0; j < b.getCols(); j++) {
int sum = 0;
for(int k = 0; k < a.getCols(); k++) {
sum += a.numbers[i][k] * b.numbers[k][j];
}
this->numbers[i].push_back(sum);
}
}
}
}
void matrix::setRecursiveMatrix(matrix source, int indexI, int indexJ) {
this->setRows(source.getRows()/2);
this->setCols(source.getCols()/2);
this->pushBackByRowCol();
//cout << "+ ";
for(int i = 0; i < source.getRows()/2; i++) {
vector <int> v;
for(int j = 0; j < source.getCols()/2; j++) {
this->setSpecificElement(source.getSpecificElement(i + indexI*source.getRows()/2 , j + indexJ*source.getCols()/2), i, j);
}
}
}
void matrix::setMatrixByVector(vector<vector<int> > sourceNums) {
this->numbers = sourceNums;
}
vector<vector<int> > matrix::getNumbers() {
return this->numbers;
}
int matrix::getSpecificElement(int rowIndex, int colIndex) {
return this->numbers[rowIndex][colIndex];
}
void matrix::setSpecificElement(int numberToPut, int rowDestination, int colDestination) {
this->numbers[rowDestination][colDestination] = numberToPut;
}
void matrix::pushBackByRowCol() {
for(int i = 0; i < this->getRows(); i++) {
vector <int> v(this->getCols());
this->numbers.push_back(v);
}
}
void matrix::set4MatricesToOne(matrix matrix, int indexI, int indexJ) {
//ghable in havaset bashe pushback karde baashi
//optimal kon baadaan:
//(if haro bardar generic kon):
if(indexI == 0 && indexJ == 0) {
for(int i = 0; i < this->getRows()/2; i++) {
for(int j = 0; j < this->getCols()/2; j++) {
this->setSpecificElement(matrix.getSpecificElement(i, j), i, j);
}
}
}
else if(indexI == 0 && indexJ == 1) {
for(int i = 0; i < this->getRows()/2; i++) {
for(int j = 0; j < this->getCols()/2; j++) {
this->setSpecificElement(matrix.getSpecificElement(i, j), i, j+this->getCols()/2);
}
}
}
else if(indexI == 1 && indexJ == 0) {
for(int i = 0; i < this->getRows()/2; i++) {
for(int j = 0; j < this->getCols()/2; j++) {
this->setSpecificElement(matrix.getSpecificElement(i, j), i+this->getRows()/2, j);
}
}
}
else if(indexI == 1 && indexJ == 1) {
for(int i = 0; i < this->getRows()/2; i++) {
for(int j = 0; j < this->getCols()/2; j++) {
this->setSpecificElement(matrix.getSpecificElement(i, j), i+this->getRows()/2, j+this->getCols()/2);
}
}
}
}
matrix::~matrix() = default;
|
cb20552f975a56863c732e49b6e9cdf545681ba5
|
afe2bab8d0e9a1a9fccae220d4d86053f0bf1a6a
|
/DVDLogoCoco/Classes/HelloWorldScene.cpp
|
ef27e4645888b74c6f5522874c7e40f7be8e47c4
|
[] |
no_license
|
ChaseVriezema/cocoDVDLogo
|
db841a912fa637dc495367304f0c60e9fe94ffc3
|
9fe2f6957b49b9e06aa95ac989437687ea0ad26a
|
refs/heads/master
| 2021-01-24T02:17:13.448419
| 2018-02-25T14:13:46
| 2018-02-25T14:13:46
| 122,841,760
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,668
|
cpp
|
HelloWorldScene.cpp
|
#include "HelloWorldScene.h"
#include "SimpleAudioEngine.h"
USING_NS_CC;
Scene* HelloWorld::createScene()
{
return HelloWorld::create();
}
// Print useful error message instead of segfaulting when files are not there.
static void problemLoading(const char* filename)
{
printf("Error while loading: %s\n", filename);
printf("Depending on how you compiled you might have to add 'Resources/' in front of filenames in HelloWorldScene.cpp\n");
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Scene::init() )
{
return false;
}
auto visibleSize = Director::getInstance()->getVisibleSize();
//initialize the starting velocity
velocity = Vec2(120.0, 120.0);
//initalize the DVD logo sprite
sprite = Sprite::create("DVD_video_logo.png");
if (sprite == nullptr)
{
problemLoading("'DVD_video_logo.png'");
}
else
{
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
sprite->setScale(0.15f, 0.15f);
// add the sprite as a child to this layer
this->addChild(sprite, 0);
this->scheduleUpdate();
}
return true;
}
//update method
void HelloWorld::update(float delta){
//get needed variables
auto position = sprite->getPosition();
auto spriteBox = sprite->getBoundingBox();
//update position
position += velocity * delta;
sprite->setPosition(position);
//account for visible origin offset
position -= Director::getInstance()->getVisibleOrigin();
//collision detection and handling
if (position.x - (spriteBox.size.width/2) < 0 || position.x + (spriteBox.size.width/2) > Director::getInstance()->getVisibleSize().width){
velocity.x *= -1;
sprite->setColor(Color3B(cocos2d::RandomHelper::random_int(1, 255), cocos2d::RandomHelper::random_int(1, 255), cocos2d::RandomHelper::random_int(1, 255)));
}
if (position.y - (spriteBox.size.height/2) < 0 || position.y + (spriteBox.size.height/2) > Director::getInstance()->getVisibleSize().height){
velocity.y *= -1;
sprite->setColor(Color3B(cocos2d::RandomHelper::random_int(1, 255), cocos2d::RandomHelper::random_int(1, 255), cocos2d::RandomHelper::random_int(1, 255)));
}
}
void HelloWorld::menuCloseCallback(Ref* pSender)
{
//Close the cocos2d-x game scene and quit the application
Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
|
1825ed0d976f0e1e8ec8b105e664c58922a304b1
|
95a3e8914ddc6be5098ff5bc380305f3c5bcecb2
|
/src/ControlsConfig_bin/controlsconfig_bin.h
|
ab22b0b1e3cd54123a8b09fe505b90470ab36d47
|
[] |
no_license
|
danishcake/FusionForever
|
8fc3b1a33ac47177666e6ada9d9d19df9fc13784
|
186d1426fe6b3732a49dfc8b60eb946d62aa0e3b
|
refs/heads/master
| 2016-09-05T16:16:02.040635
| 2010-04-24T11:05:10
| 2010-04-24T11:05:10
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 599
|
h
|
controlsconfig_bin.h
|
#ifndef CONTROLSCONFIG_BIN_H
#define CONTROLSCONFIG_BIN_H
#include <QtGui/QMainWindow>
#include "ui_controlsconfig_bin.h"
class ControlsConfig_bin : public QMainWindow
{
Q_OBJECT
public:
ControlsConfig_bin(QWidget *parent = 0, Qt::WFlags flags = 0);
~ControlsConfig_bin();
protected:
void closeEvent(QCloseEvent *event);
private:
Ui::ControlsConfig_binClass ui;
int old_player_id;
bool menu_exit;
private slots:
void player_id_changed(int player_id);
void exit_no_save();
void exit_and_save();
void reset_to_default();
};
#endif // CONTROLSCONFIG_BIN_H
|
18124aa676c1620d165d289d26168e4bf589e43f
|
a24674ae7ed77dc1ea9ab9a6d47ba6e7ca014e97
|
/N-QUEEN.cpp
|
10b77531c9a472328779119130e989de083db4ed
|
[
"MIT"
] |
permissive
|
VamsiKrishna04/Hacktoberfest-2021
|
2511c12e609ce5745a7e6d6e2fd4f44d112a5032
|
e787ca5213bd21bd9e6ae55f918c0041f4664482
|
refs/heads/main
| 2023-09-03T10:48:29.002413
| 2021-10-30T15:25:49
| 2021-10-30T15:25:49
| 422,917,943
| 0
| 0
|
MIT
| 2021-10-30T15:24:56
| 2021-10-30T15:24:55
| null |
UTF-8
|
C++
| false
| false
| 1,681
|
cpp
|
N-QUEEN.cpp
|
#include<bits/stdc++.h>
using namespace std;
bool issafe(int row, int col, vector<vector<char>> &pos, int n)
{
for(int i=row, j=col; i>=0 && j>=0;j--) if(pos[i][j]==1) return false;
for(int i=row, j=col; i>=0 && j>=0;i--,j--) if(pos[i][j]==1) return false;
for(int i=row, j=col; i<n && j>=0;i++,j--) if(pos[i][j]==1) return false;
return true;
}
bool issafe2(int row, int col, vector<vector<char>> &pos, int n, vector<int> &rowhash,
vector<int> &thirdhash, vector<int> &firsthash)
{
if(rowhash[row]==1 || thirdhash[row + col] ==1|| firsthash[n-1-row+col]==1)
return false;
return true;
}
bool findpos(int col, vector<vector<char>> &pos,int n, vector<int> &rowhash,
vector<int> &thirdhash, vector<int> &firsthash)
{
if(col==n)
{
for(int i=0;i<n;i++){
for(int j=0;j<n;j++)
cout<<pos[i][j]<<" ";
cout<<endl;
}
cout<<endl<<endl;
return true;
}
for(int row=0;row<n;row++)
{
if(issafe2(row,col,pos,n,rowhash,thirdhash,firsthash)){
pos[row][col]='Q';
rowhash[row]=1;
thirdhash[row+col]=1;
firsthash[n-1-row+col]=1;
if(findpos(col+1,pos,n,rowhash,thirdhash,firsthash)==true) return true;
pos[row][col]='.';
rowhash[row]=0;
thirdhash[row+col]=0;
firsthash[n-1-row+col]=0;
}
}
return false;
}
int main()
{
int n;
cin>>n;
vector<vector<char>> pos(n, vector<char>(n,'.'));
vector<int> rowhash(n,0);
vector<int> thirdhash(2*n-1,0);
vector<int> firsthash(2*n-1,0);
findpos(0,pos,n,rowhash,thirdhash,firsthash);
}
|
c81517881ad45501c6063c64e117fd72a8093e85
|
010279e2ba272d09e9d2c4e903722e5faba2cf7a
|
/contrib/libs/zeromq/sources/src/io_thread.cpp
|
8c394d4ae0ecaafabb1461002341ef39fba88c42
|
[
"GPL-3.0-only",
"LGPL-3.0-only",
"LicenseRef-scancode-zeromq-exception-lgpl-3.0",
"Apache-2.0"
] |
permissive
|
catboost/catboost
|
854c1a1f439a96f1ae6b48e16644be20aa04dba2
|
f5042e35b945aded77b23470ead62d7eacefde92
|
refs/heads/master
| 2023-09-01T12:14:14.174108
| 2023-09-01T10:01:01
| 2023-09-01T10:22:12
| 97,556,265
| 8,012
| 1,425
|
Apache-2.0
| 2023-09-11T03:32:32
| 2017-07-18T05:29:04
|
Python
|
UTF-8
|
C++
| false
| false
| 3,022
|
cpp
|
io_thread.cpp
|
/*
Copyright (c) 2007-2015 Contributors as noted in the AUTHORS file
This file is part of libzmq, the ZeroMQ core engine in C++.
libzmq is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
As a special exception, the Contributors give you permission to link
this library with independent modules to produce an executable,
regardless of the license terms of these independent modules, and to
copy and distribute the resulting executable under terms of your choice,
provided that you also meet, for each linked independent module, the
terms and conditions of the license of that module. An independent
module is a module which is not derived from or based on this library.
If you modify this library, you must extend this exception to your
version of the library.
libzmq is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <new>
#include "io_thread.hpp"
#include "platform.hpp"
#include "err.hpp"
#include "ctx.hpp"
zmq::io_thread_t::io_thread_t (ctx_t *ctx_, uint32_t tid_) :
object_t (ctx_, tid_)
{
poller = new (std::nothrow) poller_t (*ctx_);
alloc_assert (poller);
mailbox_handle = poller->add_fd (mailbox.get_fd (), this);
poller->set_pollin (mailbox_handle);
}
zmq::io_thread_t::~io_thread_t ()
{
delete poller;
}
void zmq::io_thread_t::start ()
{
// Start the underlying I/O thread.
poller->start ();
}
void zmq::io_thread_t::stop ()
{
send_stop ();
}
zmq::mailbox_t *zmq::io_thread_t::get_mailbox ()
{
return &mailbox;
}
int zmq::io_thread_t::get_load ()
{
return poller->get_load ();
}
void zmq::io_thread_t::in_event ()
{
// TODO: Do we want to limit number of commands I/O thread can
// process in a single go?
command_t cmd;
int rc = mailbox.recv (&cmd, 0);
while (rc == 0 || errno == EINTR) {
if (rc == 0)
cmd.destination->process_command (cmd);
rc = mailbox.recv (&cmd, 0);
}
errno_assert (rc != 0 && errno == EAGAIN);
}
void zmq::io_thread_t::out_event ()
{
// We are never polling for POLLOUT here. This function is never called.
zmq_assert (false);
}
void zmq::io_thread_t::timer_event (int)
{
// No timers here. This function is never called.
zmq_assert (false);
}
zmq::poller_t *zmq::io_thread_t::get_poller ()
{
zmq_assert (poller);
return poller;
}
void zmq::io_thread_t::process_stop ()
{
poller->rm_fd (mailbox_handle);
poller->stop ();
}
|
d60fbca4be405997b6959aa379e9b8423029403e
|
c385197459289938d6c22c4071dbab865f2a3e2c
|
/Queue.h
|
5dc0f413ab9c15873c13b6e7bf7fb62ea79447e5
|
[] |
no_license
|
emekuns/EDS
|
d52224fce744636be0a9ce0f59984ea34bf9e0cc
|
0242a29c0a6c142199472af1977e5dbfc16ac8e8
|
refs/heads/master
| 2021-01-10T12:37:11.448839
| 2016-03-01T19:49:37
| 2016-03-01T19:49:37
| 50,630,621
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 336
|
h
|
Queue.h
|
/**** Queue interface */
#ifndef __QUEUE_H_INCLUDED__
#define __QUEUE_H_INCLUDED__
#include "Node.h"
class ListItem;
class Queue {
private:
Node *front;
Node *back;
int size;
public:
Queue();
int getSize();
bool isEmpty();
void enqueue(ListItem *item);
ListItem *getFront();
ListItem *dequeue();
}; // class Queue
#endif
|
0544bc976343c1afc35bb12d7ce3bf49dbb53d91
|
bd96fe1bfbf98236d8457a5929433a2aae333fe1
|
/Leuckart/LeetCode_010_RegularExpressionMatching.cpp
|
e28208621151e841fb8b7d85bce0671213ccfdf3
|
[] |
no_license
|
Alfeim/njuee_LeetCode_Solutions
|
1879c99c8c999f08d97980acf10490da5ebeaaea
|
ed1a8f4dd90739c6359c71a1278efd811bafe354
|
refs/heads/master
| 2020-06-13T12:05:46.521182
| 2020-01-11T07:14:38
| 2020-01-11T07:14:38
| 194,647,358
| 2
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,924
|
cpp
|
LeetCode_010_RegularExpressionMatching.cpp
|
/**************************************************
> File Name: LeetCode_010_RegularExpressionMatching.cpp
> Author: Leuckart
> Time: 2019-06-09 15:04
**************************************************/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Solution
{
public:
bool isMatch(string s, string p)
{
if (!s.length() && !p.length())
{
return true;
}
if (s.length() && !p.length())
{
return false;
}
if (!s.length())
{
if (p.length() % 2 == 1)
{
return false;
}
int p_half = p.length() / 2;
for (int i = 0; i < p_half; i++)
{
if (p[2 * i + 1] != '*')
{
return false;
}
}
return true;
}
if (p.length() >= 2 && p[1] == '*')
{
if (isMatch(s.substr(0), p.substr(2)))
{
return true;
}
for (int i = 1; (s[i - 1] == p[0]) || (p[0] == '.'); i++)
{
if (isMatch(s.substr(i), p.substr(2)))
return true;
else if (i == s.length())
return false;
}
}
else
{
if (s[0] == p[0] || p[0] == '.')
return isMatch(s.substr(1), p.substr(1));
}
return false;
}
bool isMatch_DynamicProgramming(string s, string p)
{
vector<vector<bool>> match(s.length() + 3, vector<bool>(p.length() + 3, false));
match[0][0] = true;
match[1][1] = s[0] == p[0] || p[0] == '.';
for (int j = 2; j < p.length() + 1; j += 2)
{
match[0][j] = match[0][j - 2] && p[j - 1] == '*';
}
for (int i = 1; i < s.length() + 1; i++)
{
for (int j = 2; j < p.length() + 1; j++)
{
if (p[j - 1] != '*')
{
match[i][j] = match[i - 1][j - 1] && (s[i - 1] == p[j - 1] || p[j - 1] == '.');
}
else
{
match[i][j] = match[i][j - 2] || (match[i - 1][j] && (s[i - 1] == p[j - 2] || p[j - 2] == '.'));
}
}
}
return match[s.length()][p.length()];
}
};
int main()
{
Solution sol;
cout << sol.isMatch("aa", "a*") << endl;
return 0;
}
|
392a10914759f480b50c2c5c85f0ce251e0f1b4c
|
e7e245b6f266ab277997b06e9d334f62fd67494e
|
/FACTORIAL.CPP
|
ebeab6c81f59d0295eeb563d45506015bb936d83
|
[] |
no_license
|
amankumarkeshu/Spoj-Questions
|
22c2ec58db9ca4ce02c106629018edc1633ecc5f
|
29c9f16fb028979e7bfa5b7bf9091715290a0afd
|
refs/heads/master
| 2020-03-28T17:51:49.314185
| 2019-04-17T10:06:24
| 2019-04-17T10:06:24
| 148,829,949
| 3
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,088
|
cpp
|
FACTORIAL.CPP
|
#include<bits/stdc++.h>
#define fr(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define fr1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define frr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define frab(i,a,b,c) for(ll (i) = a ; (i) <= (b) ; (i)+=(c))
#define vll vector<ll>
#define vvll vector< vll >
#define pll pair<ll ,ll >
#define vpll vector< pll >
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define fst first
#define scd second
#define MOD 1000000007
#define ll long long
#define mod 1000000007
#define MAX 100000
#define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
using namespace std;
void read( ll &a)
{
scanf("%lld",&a);
}
void read( ll &a, ll &b)
{
scanf("%lld %lld",&a,&b);
}
void read( ll &a, ll &b,ll &c)
{
scanf("%lld %lld %lld",&a,&b,&c);
}
void read(ll &a,ll &b,ll &c,ll &d)
{
scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
}
void write(vll &oneD)
{
for(ll i=0;i<oneD.size();i++)
{
printf("%lld ",oneD[i]);
}
printf("\n");
}
void write(vvll &twoD)
{
for(ll i=0;i<twoD.size();i++)
{
write(twoD[i]);
}
}
void write(vpll &oneDP){
fr(i,oneDP.size())
{
printf("%lld %lld\n" , oneDP[i].fst , oneDP[i].scd);
}
}
void write(map< ll , ll > &mpp){
for(map<ll , ll >::iterator it = mpp.begin() ; it != mpp.end() ; it++)
{
cout<<it->fst<<" : "<<it->scd<<endl;
}
cout<<endl;
}
bool sortbysecdesc ( const pll &a , const pll &b)
{
return (a.scd > b.scd );
}
bool sortbysecasc( const pll &a, const pll &b )
{
return (a.scd < b.scd);
}
ll multiply(ll x, ll res[], ll res_size);
void factorial(ll n)
{
ll res[MAX];
// Initialize result
res[0] = 1;
ll res_size = 1;
// Apply simple factorial formula n! = 1 * 2 * 3 * 4...*n
for (ll x=2; x<=n; x++)
res_size = multiply(x, res, res_size);
//return res;
cout << "Factorial of given number is \n";
for (ll i=res_size-1; i>=0; i--)
cout << res[i]%mod;
}
// This function multiplies x with the number
// represented by res[].
// res_size is size of res[] or number of digits in the
// number represented by res[]. This function uses simple
// school mathematics for multiplication.
// This function may value of res_size and returns the
// new value of res_size
long long multiply(ll x, ll res[],ll res_size)
{
ll carry = 0; // Initialize carry
// One by one multiply n with individual digits of res[]
for (ll i=0; i<res_size; i++)
{
ll prod = res[i] * x + carry;
// Store last digit of 'prod' in res[]
res[i] = prod % 10;
// Put rest in carry
carry = prod/10;
}
// Put carry in res and increase result size
while (carry)
{
res[res_size] = carry%10;
carry = carry/10;
res_size++;
}
return res_size;
}
int main()
{
ll i,j,m,n,t,k,p,u,v;
read(t);
while(t--)
{
read(n);
factorial(n);
cout<<endl;
}
}
|
efc2edc41c54b3ceba494bfa18fc4d95ce75ec3d
|
98baa81e3fe7d0a4e8690673cf1cca03e7fb90c0
|
/edge.cpp
|
07e55f9cdabe3f3e0370b6d668b8c57273670930
|
[] |
no_license
|
yp6969/Generic_map
|
7b0bdabf7812dfa9100436a236a63675206c3ae3
|
6af99eb4cd64c781eb537c1bf99f12ef4f32a0e6
|
refs/heads/master
| 2022-10-09T04:29:35.219197
| 2020-06-09T19:36:11
| 2020-06-09T19:36:11
| 269,088,893
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,657
|
cpp
|
edge.cpp
|
//
// Created by Pinhas on 14/05/2020.
//
#include "edge.h"
edge::edge(unsigned int id , unsigned int number_of_neighbors) : id(id) , number_of_neighbors(number_of_neighbors){
neighbor = new unsigned int[number_of_neighbors+1];
neighbor[0] = id; // neighbor[0] is me !
carList = NULL;
}
edge::~edge(){
car* c = carList;
delete [] neighbor;
while(c){
car* prev = c;
c = c->next;
delete prev;
}
}
/**
* adding car to the end of the car list
* @param c
*/
void edge::addCar(car* c) {
if(!carList){
carList = c;
return;
}
car* temp = carList;
while(temp->next){
temp = temp->next;
}
temp->next = c;
}
/**
* remove car from the top of the car list
* @return the removal car
*/
car* edge::removeCar(){
car* temp = carList;
carList = carList->next;
temp->next = NULL;
return temp;
}
/**
* @param type of the car
* @return the spesific junction to move to
* depending on the type of the car
*/
const int edge::getProbability(const car& c) const {
int index = 0 ;
if(number_of_neighbors) {
index = c.prob(number_of_neighbors);
}
return neighbor[index];
}
/**
* print the junction with the car list
* @param out : ostream cout
* @param junction
* @return cout
*/
ostream& operator<<(ostream& out , edge& junction ){
out<<junction.id<<":";
car* head = junction.carList;
while(head){
out<<" ";
out<<head->getName();
head = head->next;
}
out<<endl;
out.flush();
return out;
}
|
96cae541d06edce613546fbd3db7d665cce2b52d
|
1e5ce757067f157f53f3c499837f4cdab34e6acd
|
/examples/specific/typedef.h
|
a278b94f98951ed801c7bc9129dde510588beb30
|
[
"BSD-3-Clause"
] |
permissive
|
diegov/breathe
|
b745a5c46a4f09f364e8b057aeb1193be6e02e97
|
636510ab71e231ed928a6fb821d43bd2f54dcc0f
|
refs/heads/master
| 2020-12-29T02:54:12.145004
| 2012-11-08T02:06:13
| 2012-11-08T02:06:13
| 6,589,800
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 234
|
h
|
typedef.h
|
class TypeDefTest {
};
/* A dummy typedef */
typedef TypeDefTest (*TypeDefTestFuncPtr)(void);
typedef void* (*voidFuncPtr)(float, int);
typedef void* voidPointer;
typedef float* floatPointer;
typedef float floatingPointNumber;
|
643d7786e430d73682162635b6cb156bda4715f1
|
69a70fcaf776db8094b803473a5dbcd2b418251b
|
/one_star/272 - TEX Quotes/uva272.cpp
|
8e0d6e50cfb62bb8281f10bc34f671f8f6fd0031
|
[] |
no_license
|
chinghsiang0912/Uva_pratice
|
6ea14fc7560e4cf5d105ff81ab8ce49e866f7ef5
|
274d90698a759929a9d942a0ad7609e16ac0022a
|
refs/heads/master
| 2021-01-10T13:37:05.886779
| 2016-02-03T06:36:36
| 2016-02-03T06:36:36
| 49,492,747
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 417
|
cpp
|
uva272.cpp
|
#include "stdio.h"
#include "stdlib.h"
int main(void){
char s[500];
int c=0;
while(gets(s)){
for(int i=0;i<500;i++){
if(s[i]=='\0'){break;}
if(s[i]=='\"'){
c++;
if(c%2==1)printf("``");
else printf("''");
}
else
printf("%c",s[i]);
}
printf("\n");
}
return 0;
}
|
bb7d6f1d21478a5e09b178cf6d47067b83e7b206
|
5e7b47a5a1e059acf238adac3a115d472c9d16aa
|
/Cobertura.hpp
|
2f11e3ea1f0812a2d2c6cd58a6a4017b9c653a0e
|
[] |
no_license
|
brunorchaves/2021-1-exercicio-revisao-refatoracao
|
27d523363b1021469c681885934a16e70055062a
|
95f14896d47138a80b136f516e15ff8b7905ae44
|
refs/heads/main
| 2023-07-09T12:38:30.376759
| 2021-08-17T20:46:18
| 2021-08-17T20:46:18
| 397,284,920
| 0
| 0
| null | 2021-08-17T14:22:02
| 2021-08-17T14:22:01
| null |
UTF-8
|
C++
| false
| false
| 515
|
hpp
|
Cobertura.hpp
|
#ifndef COBERTURA_HPP
#define COBERTURA_HPP
#include "Imovel.hpp"
#include "Cliente.hpp"
using namespace std;
#define TAXA_C_COBERTURA 10
class Cobertura : public Imovel {
public:
Cobertura()
{
tipo = "[Cobertura]";
taxaComissao = TAXA_C_COBERTURA;
}
double valor() {
double v = AREA * valorMetro2;
return v;
}
double comissao() {
double c = AREA * valorMetro2;
return ((c * TAXA_C_COBERTURA)/100);
}
};
#endif
|
95fc40a4de32bc1bc23e8ec0106b9e3d7099bb2a
|
8a3fce9fb893696b8e408703b62fa452feec65c5
|
/MassMailer/MassMailer/MassMailer/App/Smtplist.h
|
d55af11f38910033922ef84822f1d44c5e1b8d75
|
[] |
no_license
|
win18216001/tpgame
|
bb4e8b1a2f19b92ecce14a7477ce30a470faecda
|
d877dd51a924f1d628959c5ab638c34a671b39b2
|
refs/heads/master
| 2021-04-12T04:51:47.882699
| 2011-03-08T10:04:55
| 2011-03-08T10:04:55
| 42,728,291
| 0
| 2
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 780
|
h
|
Smtplist.h
|
#pragma once
#include "../Public/Tools.h"
template < typename type, template<typename> class table>
class Property
{
private:
};
class SmtpList
{
typedef map<string,tagSmtp> MpSmtp;
private:
MpSmtp m_smtp;
void Load()
{
m_smtp.clear();
ifstream in("smtp.ini");
if ( in.eof())
{
return;
}
string type,smtp;
long port;
while ( !in.eof() )
{
in >> type >> smtp >> port;
m_smtp[ type ] = tagSmtp(port,smtp);
}
}
public:
SmtpList()
{
Load();
}
bool GetSmtp( string type , tagSmtp & smtp) const
{
MpSmtp::iterator itr = m_smtp.find( type );
if ( itr != m_smtp.end() )
{
smtp = itr->second;
return true;
}
return false;
}
};
|
4f4585ea5322b9a940ea92600f9df4eb309d74c2
|
762e9bfa224f1f27d9491a2c9ff7045cd67f3cf2
|
/qcsrc/common/gamemodes/gamemode/cts/_mod.inc
|
f60b8de4cfc4c7da886439a61d481ef4649cd1ea
|
[] |
no_license
|
xonotic/xonotic-data.pk3dir
|
3a8b29cfa8e1fae07ff8d6bef829a6946ec9f941
|
1a2350574ac7bf2bd44888e6ff03a1f4cb1f96b3
|
refs/heads/master
| 2023-08-31T04:40:24.920794
| 2023-08-28T05:23:19
| 2023-08-28T05:23:19
| 23,666,155
| 13
| 16
| null | 2022-01-17T14:46:18
| 2014-09-04T14:38:49
|
C
|
UTF-8
|
C++
| false
| false
| 229
|
inc
|
_mod.inc
|
// generated file; do not modify
#include <common/gamemodes/gamemode/cts/cts.qc>
#ifdef CSQC
#include <common/gamemodes/gamemode/cts/cl_cts.qc>
#endif
#ifdef SVQC
#include <common/gamemodes/gamemode/cts/sv_cts.qc>
#endif
|
600a5d84a58484189c98597d53fc03e70a8c27c7
|
a6316215cdcb43bc3b8d2d770bcc163c54966c41
|
/Light/AmbientOccluder.cpp
|
cc287e259ca113f9b87f2337aad3c373b9e4937e
|
[] |
no_license
|
Frank-Jan/raytracer
|
7ca1bef2a7fb9d0c09cf1d4eb0d8e6d03943efaf
|
e8c2621cba59202e2fe661253b2ddb09b7a5d9cd
|
refs/heads/master
| 2023-04-14T04:16:27.625364
| 2021-04-23T23:39:48
| 2021-04-23T23:39:48
| 360,160,280
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 1,293
|
cpp
|
AmbientOccluder.cpp
|
#include "AmbientOccluder.h"
#include "Sampler.h"
#include "ShadeRec.h"
#include "world/SimpleWorld.h"
#include "Triangle.h"
AmbientOccluder::AmbientOccluder(const Color& c, FLOAT _ls) :
sampler(nullptr), color(c), ls(_ls)
{ }
AmbientOccluder::AmbientOccluder(FLOAT r, FLOAT g, FLOAT b, FLOAT _ls) :
sampler(nullptr), color(r,g,b), ls(_ls)
{ }
AmbientOccluder::~AmbientOccluder()
{
delete sampler;
}
void AmbientOccluder::set_sampler(Sampler *_sampler)
{
delete sampler;
sampler = _sampler;
}
Vector3D AmbientOccluder::get_direction(const ShadeRec &sr)
{
Vector3D sp = sampler->sample_hemisphere(1);
return sp.x() * u + sp.y() * v + sp.z() * w;
}
bool AmbientOccluder::in_shadow(const Ray &ray, const ShadeRec &sr) const
{
FLOAT t;
// for(const Triangle* geo : sr.world.objects) {
// if(geo->shadow_hit(ray, t))
// return true;
// }
return false;
}
Color AmbientOccluder::L(const ShadeRec &sr)
{
w = sr.normal;
// jitter up vector in case the normal is vertical
v = w^Vector3D(0.0072, 1.0, 0.0034);
v._normalize();
u = v^w;
Ray shadowRay;
shadowRay.o = sr.hit_point;
shadowRay.d = get_direction(sr);
if(in_shadow(shadowRay, sr))
return (min_amount * ls * color);
return ls * color;
}
|
47d8f728fc8e6fd315b817abbd1d0feb6fb8a6a1
|
6cb2a259ac1955eede3e9b11d24f48cbfd1ea114
|
/primer/vector/vector_expression.cc
|
60cdfd1339a6c53be6a5dc5b10bbf8301ade5f4e
|
[] |
no_license
|
Doogplus/cplusplus-exercise
|
4491a7981b1c15bc6ba32f2fef703c68daf69cb6
|
cad9294854a600dfd551355c7fde8e301d067861
|
refs/heads/master
| 2021-06-12T14:08:53.414533
| 2017-04-06T11:39:02
| 2017-04-06T11:39:02
| null | 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 3,170
|
cc
|
vector_expression.cc
|
#include <vector>
#include <assert.h>
#include <iostream>
using std::vector;
using std::cout;
using std::endl;
template<typename E>
class VecExpression {
public:
typedef vector<double> container_type;
// 类型名是指这里最终要指出的是个类型名,而不是变量。
// 例如container_type::size_type完全有可能是类container_type里
// 的一个static对象。而且当我们这样写的时候,C++默认就是解释为
// 一个变量的。所以,为了和变量区分,必须使用typename告诉编译器。
typedef typename container_type::size_type size_type;
typedef typename container_type::value_type value_type;
typedef typename container_type::reference reference;
size_type size() const { return static_cast<E const&>(*this).size(); }
value_type operator[](size_type i) { return static_cast<E const&>(*this)[i]; }
operator E&() { return static_cast<E&>(*this); }
operator E const&() const { return static_cast<const E&>(*this); }
};
class Vec: public VecExpression<Vec> {
public:
Vec(size_type n): data_(n) {}
template<typename E>
Vec(VecExpression<E> const& vec) {
E const& v = vec;
data_.resize(vec.size());
for (size_type i = 0; i != v.size(); i++) {
data_[i] = v[i];
}
}
size_type size() const { return data_.size(); }
value_type operator[](size_type i) const { return data_[i]; }
reference operator[](size_type i) { return data_[i]; }
private:
container_type data_;
};
template<typename E1, typename E2>
class VecDifference: public VecExpression<VecDifference<E1, E2> > {
public:
typedef Vec::size_type size_type;
typedef Vec::value_type value_type;
VecDifference(VecExpression<E1> const& u, VecExpression<E2> const& v): u_(u), v_(v) {
assert(u.size() == v.size());
}
size_type size() const { return u_.size(); }
value_type operator[](size_type i) const { return u_[i] - v_[i]; }
private:
E1 const& u_;
E2 const& v_;
};
template<typename E>
class VecScaled: public VecExpression<VecScaled<E> > {
public:
typedef Vec::size_type size_type;
typedef Vec::value_type value_type;
VecScaled(double alpha, VecExpression<E> const& u): alpha_(alpha), u_(u) {}
size_type size() const { return u_.size(); }
value_type operator[](size_type i) const { return alpha_ * u_[i]; }
private:
double alpha_;
E const& u_;
};
template<typename E1, typename E2>
VecDifference<E1, E2> operator-(VecExpression<E1> const& u, VecExpression<E2> const& v) {
return VecDifference<E1, E2>(u, v);
}
template<typename E>
VecScaled<E> operator*(double alpha, VecExpression<E> const& u) {
return VecScaled<E>(alpha, u);
}
int main() {
Vec v1(10), v2(10);
for (int i = 0; i < 10; i++) {
v1[i] = i * i;
v2[i] = i;
}
Vec v3 = 10 * (v1 - 2 * v2);
for (int i = 0; i < 10; i++) {
cout << v3[i] << " ";
}
cout << endl;
}
|
32a7e42f1adfdd81580f88c5fa3552a57bbdebbe
|
3927f71571f5a9ced3af587d0791585c8070c6d3
|
/codeforces/1237/c1/duipai.cpp
|
60aa821a55b7019c6661defbc82a781ddb0c9737
|
[] |
no_license
|
lzh12139/MySolutions
|
38805d49f8d150a22e949121aa1a90c536d446a1
|
15ad346fb76e08707e04ecd2da90871721c357fa
|
refs/heads/master
| 2021-07-18T09:21:27.769268
| 2021-01-08T14:19:28
| 2021-01-08T14:19:28
| 231,051,033
| 0
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 873
|
cpp
|
duipai.cpp
|
#include<bits/stdc++.h>
using namespace std;
int vis[2010];
int x[2010],y[2010],z[2010];
bool judge(int a,int b,int j,int c[]){
return min(c[a],c[b])<=c[j]&&c[j]<=max(c[a],c[b]);
}
int main(){
ifstream in("in.txt");
ifstream ans("out.txt");
int n;in>>n;
for(int i=1;i<=n;i++)in>>x[i]>>y[i]>>z[i];
for(int i=1;i<=n/2;i++){
int a,b;ans>>a>>b;
if(vis[a])cout<<"error:vis "<<a<<"\n";
if(vis[b])cout<<"error:vis "<<b<<"\n";
vis[a]=1,vis[b]=1;
for(int j=1;j<=n;j++)
if(!vis[j]&&judge(a,b,j,x)&&judge(a,b,j,y)&&judge(a,b,j,z)){
cout<<"WA: "<<i<<"\n";
cout<<x[a]<<" "<<y[a]<<" "<<z[a]<<"\n";
cout<<x[b]<<" "<<y[b]<<" "<<z[b]<<"\n";
cout<<x[j]<<" "<<y[j]<<" "<<z[j]<<"\n";
cout<<"\n";
}
}
cout<<"over";
}
|
99d39638d85b71debc1326713302ec84f25a8226
|
417a9da2a5577b1386a6d99469fe83e6bc042acb
|
/src/detail/checknan.cpp
|
bb23606e512f621ef2be2e2144abe5181bc6d2c5
|
[] |
no_license
|
pdziekan/bicycles
|
8a4b53a15439106766c1ccb1f0bb02516d72258f
|
232ae864ef551de59841d9850e4ab7b1a307d81e
|
refs/heads/master
| 2020-09-12T05:06:43.091626
| 2017-09-06T09:29:24
| 2017-09-06T09:29:24
| 66,357,308
| 0
| 1
| null | 2016-12-13T15:23:30
| 2016-08-23T10:28:10
|
C++
|
UTF-8
|
C++
| false
| false
| 337
|
cpp
|
checknan.cpp
|
#pragma once
#ifdef NDEBUG
#define nancheck(arr, name) ((void)0)
#else
#define nancheck(arr, name) {if(!std::isfinite(sum(arr))) {\
std::cout << "A not-finite number detected in: " << name << std::endl;\
std::cout << arr;\
assert(0);}}
#endif
|
47407207155f7829f1dcd7c9190af46f964880a6
|
54f352a242a8ad6ff5516703e91da61e08d9a9e6
|
/Source Codes/AtCoder/arc051/C/1098712.cpp
|
7cb03f7973734de025c42cf8fd9bb1562a445aea
|
[] |
no_license
|
Kawser-nerd/CLCDSA
|
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
|
aee32551795763b54acb26856ab239370cac4e75
|
refs/heads/master
| 2022-02-09T11:08:56.588303
| 2022-01-26T18:53:40
| 2022-01-26T18:53:40
| 211,783,197
| 23
| 9
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 2,107
|
cpp
|
1098712.cpp
|
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
using namespace std;
const int MOD = 1e9 + 7;
int power(int n, int p) {
if (p == 0)
return 1;
long long res = 1;
long long add = n;
while (p > 0) {
if (p & 1)
res = (res * add) % MOD;
p >>= 1;
add = add*add%MOD;
}
return res;
}
int main() {
int n, a, b;
cin >> n >> a >> b;
vector<long long> dat(n);
FOR(i, 0, n) {
cin >> dat[i];
}
sort(dat.begin(), dat.end());
if (a == 1) {
for (auto t : dat) {
cout << t << endl;
}
return 0;
}
long long maxx = dat.back();
priority_queue<long long, vector<long long>, greater<long long>> pq;
for (auto t : dat)
pq.push(t);
int cnt = 0;
while (1) {
long long t = pq.top();
if (b == 0 || t*a >= maxx)
break;
pq.pop();
t *= a;
pq.push(t);
cnt++;
b--;
}
vector<long long> res(n);
FOR(i, 0, n) {
long long t = pq.top() % MOD;
pq.pop();
int pos = (2 * n + i - b%n) % n;
int divnum = (b - i - 1 < 0 ? 0 : max(0, ((b - i - 1) / n) + 1));
long long mod = power(a, divnum);
long long ttt = (mod * t) % MOD;
res[pos] = ttt;
}
for (auto t : res)
cout << t << endl;
// a >= a_n????????
// a < a_n???
// a >= a_n???????????????
return 0;
}
|
59c99db0e36f8f98da57e7af3e3881aab64a7a94
|
9b775ad06355064e5eeb01d807b53cd309f2a866
|
/Sorting/Selection Sort/C++/SelectionSort.cpp
|
bb32db6e17d5b0a036ba6fc6a4326df7155f8ca3
|
[] |
no_license
|
pratikjain04/ACM-ICPC-Algorithms
|
f29095b70a78e617f2f945ae2af10abc46e99df9
|
a85c1b4dd4cf0f460844a629013c7f571cc46f99
|
refs/heads/master
| 2020-06-12T06:42:49.814246
| 2019-10-17T19:39:44
| 2019-10-17T19:39:44
| 194,222,848
| 3
| 2
| null | 2019-10-17T19:39:45
| 2019-06-28T06:50:52
|
C++
|
UTF-8
|
C++
| false
| false
| 679
|
cpp
|
SelectionSort.cpp
|
#include <bits/stdc++.h>
using namespace std;
void SelectionSort(int array[], int tam){
int i, j;
int menor, troca;
for(i = 0; i < tam-1; i++){
menor = i;
for(j = i+1; j < tam; j++){
if(array[j] < array[menor]){
menor = j;
}
}
if(i != menor){
troca = array[i];
array[i] = array[menor];
array[menor] = troca;
}
}
}
int main(){
int vetor[10] = {5,6,8,3,4,2,1,0,9,7};
SelectionSort(vetor, 10);
printf("Your sorted array is:\n");
for(int i = 0; i < 10; i++){
printf("%d ", vetor[i]);
}
printf("\n");
return 0;
}
|
df569fecd09c70f612327eb00f37680b88643f3e
|
6ab9a3229719f457e4883f8b9c5f1d4c7b349362
|
/timus/T1083.cpp
|
e01e4f280d980441505ec3eba7bf890cf549fd6d
|
[] |
no_license
|
ajmarin/coding
|
77c91ee760b3af34db7c45c64f90b23f6f5def16
|
8af901372ade9d3d913f69b1532df36fc9461603
|
refs/heads/master
| 2022-01-26T09:54:38.068385
| 2022-01-09T11:26:30
| 2022-01-09T11:26:30
| 2,166,262
| 33
| 15
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 205
|
cpp
|
T1083.cpp
|
#include <cstdio>
#include <cstring>
int main(void){
char f[32];
for(int n; scanf("%d%s", &n, f) == 2; ){
int r = 1, k = strlen(f);
while(n > 0) r *= n, n -= k;
printf("%d\n", r);
}
return 0;
}
|
40b18a7076281b6b63c56a5e5528e21a706444ea
|
af9f3ec2c6325092b77637ebd0a327e5b520b0f7
|
/iOS/IncidentPlatform/IncidentPlatform/Dimension/MeshMd3.cpp
|
af8cf11891a64f84ca19147b18557826fdd72ac1
|
[] |
no_license
|
IncidentTechnologies/IncidentPlatform
|
eb270d9ff0018ea19fbe04c9595ebdce8974341f
|
da3d96c7a7ef35791f3f2fc55805f43875f41fe0
|
refs/heads/master
| 2021-06-11T06:29:34.117387
| 2017-03-06T03:20:31
| 2017-03-06T03:20:31
| 17,033,548
| 1
| 0
| null | null | null | null |
UTF-8
|
C++
| false
| false
| 12,209
|
cpp
|
MeshMd3.cpp
|
#include "MeshMd3.h"
#include <math.h>
#define PI 4.0*atan(1.0)
RESULT MeshMd3::LoadMesh() {
RESULT r = R_SUCCESS;
int BytesRead = 0;
FILE *file;
char TempPath[MD3_MAX_PATH];
int CurSurfaceOffset;
if(m_pszPath == NULL) {
file = fopen(m_pszFilename, "rb");
if(file == NULL) {
printf("Could not open %s\n", m_pszFilename);
CBRM(0, "");
}
}
else {
memset(TempPath, 0, sizeof(char) * MD3_MAX_PATH);
strcpy(TempPath, m_pszPath);
strcat(TempPath, m_pszFilename);
printf("%s\n", TempPath);
file = fopen(TempPath, "rb");
if(file == NULL) {
printf("Could not open %s\n", TempPath);
CBRM(0, "");
}
}
BytesRead = fread(&m_header, sizeof(Md3Header), 1, file);
CR(CheckMd3Header());
PrintMd3HeaderInfo();
// Set up the frames
m_frames = new Md3Frame[m_header.NumFrames];
memset(m_frames, 0, sizeof(Md3Frame) * m_header.NumFrames);
// While we should be here anyways we should use the offset
fseek(file, m_header.FrameOffset, SEEK_SET);
for(int i = 0; i < m_header.NumFrames; i++)
{
BytesRead = fread(&(m_frames[i]), sizeof(Md3Frame), 1, file);
//printf("Frame:%d name:%s\n", i, m_frames[i].Name);
}
// Set up the Tags
m_tags = new Md3Tag[m_header.NumTags];
memset(m_tags, 0, sizeof(Md3Tag) * m_header.NumTags);
// While we should be here anyways we use the offset
fseek(file, m_header.TagOffset, SEEK_SET);
for(int i = 0; i < m_header.NumTags; i++)
{
BytesRead = fread(&(m_tags[i]), sizeof(Md3Tag), 1, file);
//printf("Tag:%d name:%s\n", i, m_tags[i].Name);
}
// Set up the surfaces and memory stuffs
m_surfaces = new Md3Surface[m_header.NumSurfaces];
memset(m_surfaces, 0, sizeof(Md3Surface) * m_header.NumSurfaces);
m_shaders = new Md3Shader*[m_header.NumSurfaces];
memset(m_shaders, 0, sizeof(Md3Shader*) * m_header.NumSurfaces);
m_triangles = new Md3Triangle*[m_header.NumSurfaces];
memset(m_triangles, 0, sizeof(Md3Triangle*) * m_header.NumSurfaces);
m_texcoords = new Md3TexCoord*[m_header.NumSurfaces];
memset(m_texcoords, 0, sizeof(Md3TexCoord*) * m_header.NumSurfaces);
m_vertices = new Md3Vertex*[m_header.NumSurfaces];
memset(m_vertices, 0, sizeof(Md3Vertex*) * m_header.NumSurfaces);
// TEXTURES (TEMP)
m_ppszTextures = new char*[m_header.NumSurfaces];
// Use this counter to keep track of the different surface objects
CurSurfaceOffset = m_header.SurfaceOffset;
// While we should be here anyways we use the offset
fseek(file, m_header.SurfaceOffset, SEEK_SET);
for(int i = 0; i < m_header.NumSurfaces; i++) {
BytesRead = fread(&(m_surfaces[i]), sizeof(Md3Surface), 1, file);
// Print MD3 Surface Info
PrintMd3SurfaceInfo(i);
// Check surface ok
CRM(CheckMd3Surface(i), "Surface not ok");
// While we should already be here we should fast forward
fseek(file, CurSurfaceOffset + m_surfaces[i].ShaderOffset, SEEK_SET);
// Set up the shaders
m_shaders[i] = new Md3Shader[m_surfaces[i].NumShaders];
memset(m_shaders[i], 0, sizeof(Md3Shader) * m_surfaces[i].NumShaders);
for(int j = 0; j < m_surfaces[i].NumShaders; j++) {
BytesRead = fread(&(m_shaders[i][j]), sizeof(Md3Shader), 1, file);
printf("Surface:%d Shader:%d Shader Index:%d name:%s\n", i, j, m_shaders[i][j].ShaderIndex, m_shaders[i][j].Name);
}
// Fast forward to triangles
fseek(file, CurSurfaceOffset + m_surfaces[i].TrianglesOffset, SEEK_SET);
// Set up the triangles
m_triangles[i] = new Md3Triangle[m_surfaces[i].NumTriangles];
memset(m_triangles[i], 0, sizeof(Md3Triangle) * m_surfaces[i].NumTriangles);
for(int j = 0; j < m_surfaces[i].NumTriangles; j++) {
BytesRead = fread(&(m_triangles[i][j]), sizeof(Md3Triangle), 1, file);
//printf("Surface:%d Triangle:%d\n", i, j);
}
// Fast forward to Texture Coordinates
fseek(file, CurSurfaceOffset + m_surfaces[i].STOffset, SEEK_SET);
// Set up the TexCoords
// There are the same number of TexCoords as there are vertices
m_texcoords[i] = new Md3TexCoord[m_surfaces[i].NumVertices];
memset(m_texcoords[i], 0, sizeof(Md3TexCoord) * m_surfaces[i].NumVertices);
for(int j = 0; j < m_surfaces[i].NumVertices; j++) {
BytesRead = fread((&m_texcoords[i][j]), sizeof(Md3TexCoord), 1, file);
//printf("Surface:%d TexCoord:%d\n", i, j);
}
// Fast forward to the Vertices
fseek(file, CurSurfaceOffset + m_surfaces[i].XYZNormalOffset, SEEK_SET);
// Set up the Vertices
// There are as many vertices as Frames * Vertices
// each set of vertices represents a different frame of animation
m_vertices[i] = new Md3Vertex[m_header.NumFrames * m_surfaces[i].NumVertices];
memset(m_vertices[i], 0, sizeof(Md3Vertex) * m_header.NumFrames * m_surfaces[i].NumVertices);
for(int j = 0; j < m_header.NumFrames * m_surfaces[i].NumVertices; j++) {
BytesRead = fread((&m_vertices[i][j]), sizeof(Md3Vertex), 1, file);
// printf("Surface:%d Vertex:%d x:%d y:%d z:%d\n", i, j, m_vertices[i][j].Coord[0], m_vertices[i][j].Coord[1], m_vertices[i][j].Coord[2]);
}
// This should be the end of the surface object so we move on to the next one
// Seek to the end of the surface object
fseek(file, CurSurfaceOffset + m_surfaces[i].EndOffset, SEEK_SET);
CurSurfaceOffset = CurSurfaceOffset + m_surfaces[i].EndOffset;
}
// **********************
// DONE LOADING FROM FILE
// **********************
// Once we are done gathering all of the data out of the file
// we push it into our own vertex format
m_DimensionVertices = new vertex*[m_header.NumSurfaces];
memset(m_DimensionVertices, 0, sizeof(vertex*) * m_header.NumSurfaces);
for(int i = 0; i < m_header.NumSurfaces; i++)
{
// For each surface we fill the dimension vertex buffer
// NOTE: at the moment we are not doing multiple frames
m_DimensionVertices[i] = new vertex[m_surfaces[i].NumVertices * m_header.NumFrames];
memset(m_DimensionVertices[i], 0, sizeof(vertex) * m_surfaces[i].NumVertices * m_header.NumFrames);
for(int j = 0; j < m_surfaces[i].NumVertices * m_header.NumFrames; j++)
{
m_DimensionVertices[i][j].set(m_vertices[i][j].Coord[0] * (float)(1.0/64),
m_vertices[i][j].Coord[1] * (float)(1.0/64),
m_vertices[i][j].Coord[2] * (float)(1.0/64));
// Decode the normals
float lat = (float)(m_vertices[i][j].Normal[0] * (2.0f * PI)) / 255.0f;
float lng = (float)(m_vertices[i][j].Normal[1] * (2.0f * PI)) / 255.0f;
float tempX = cos(lat) * sin(lng);
float tempY = sin(lat) * sin(lng);
float tempZ = cos(lng);
m_DimensionVertices[i][j].SetNormal(tempX, tempY, tempZ);
m_DimensionVertices[i][j].Normalize();
// Vertex Color
m_DimensionVertices[i][j].SetColor(1.0f, 1.0f, 1.0f, 1.0f);
// Pass in the UV coordinates
m_DimensionVertices[i][j].SetUV(m_texcoords[i][j % m_surfaces[i].NumVertices].ST[0], m_texcoords[i][j % m_surfaces[i].NumVertices].ST[1]);
}
}
CRM(LoadTextures(), "Could not load textures!");
Error:
return r;
}
#define MD3_FILE_DELIMS "'()/\\"
RESULT MeshMd3::ParseOutFilename(char* pszPath, char* &n_pszTextureFile)
{
RESULT r = R_SUCCESS;
char *temp = strtok(pszPath, MD3_FILE_DELIMS);
char *last;
while(temp != NULL)
{
last = temp;
temp = strtok(NULL, MD3_FILE_DELIMS);
}
// Last one should be the filename
// check to see that this file exists
n_pszTextureFile = new char[MD3_MAX_PATH];
if(m_pszPath != NULL)
{
strcpy(n_pszTextureFile, m_pszPath);
strcat(n_pszTextureFile, last);
}
else
{
strcpy(n_pszTextureFile, last);
}
FILE *TextureFile;
TextureFile = fopen(n_pszTextureFile, "r");
if(TextureFile == NULL)
{
delete n_pszTextureFile;
return R_FAIL;
}
else
{
fclose(TextureFile);
return R_SUCCESS;
}
Error:
return r;
}
RESULT MeshMd3::LoadTextures()
{
RESULT r = R_SUCCESS;
for(int i = 0; i < m_header.NumSurfaces; i++)
{
// Find the shaders (textures)
for(int j = 0; j < m_surfaces[i].NumShaders; j++)
{
char *temp = NULL;
// There seems to be a bug with some of the
// md3 file formats where the first character of the
// name is /0 . Since this is fixed memory it is safe
// to parse through the block to look for any non zero character
char *TempName = m_shaders[i][j].Name;
for(int k = 0; k < MD3_SHADER_NAME_LENGTH; k++)
{
if(*TempName == '\0')
TempName++;
else
break;
}
if(*TempName != '\0')
{
//ParseOutFilename(m_shaders[i][j].Name, temp);
ParseOutFilename(TempName, temp);
}
if(temp == NULL)
{
printf("%s does not exist!\n", m_shaders[i][j].Name);
}
else
{
printf("found %s\n", temp);
CRM(AddTexture(temp, TEXTURE_DIFFUSE), "Could not add texture FAILURE!");
}
}
}
Error:
return r;
}
RESULT MeshMd3::PrintMd3HeaderInfo()
{
RESULT r = R_SUCCESS;
printf("Md3 File\n**********\n");
printf("version:%d\n", m_header.Version);
printf("name:%s\n", m_header.Name);
printf("NumFrames:%d\n", m_header.NumFrames);
printf("NumTags:%d\n", m_header.NumTags);
printf("NumSurfaces:%d\n", m_header.NumSurfaces);
printf("NumSkins:%d\n", m_header.NumSkins);
Error:
return r;
}
RESULT MeshMd3::PrintMd3SurfaceInfo(int i)
{
RESULT r = R_SUCCESS;
printf("Md3 Surface:%d\n***********\n", i);
printf("Name:%s\n", m_surfaces[i].Name);
printf("NumFrames:%d\n", m_surfaces[i].NumFrames);
printf("NumShaders:%d\n", m_surfaces[i].NumShaders);
printf("NumTriangles:%d\n", m_surfaces[i].NumTriangles);
printf("NumVerts:%d\n", m_surfaces[i].NumVertices);
Error:
return r;
}
RESULT MeshMd3::CheckMd3Surface(int i)
{
RESULT r = R_SUCCESS;
CBRM(m_surfaces[i].ID == MD3_IDENT, "Md3Surface ID incorrect");
CBRM(m_surfaces[i].NumFrames > MD3_MAX_FRAMES, "Md3Surface too many frames!");
CBRM(m_surfaces[i].NumFrames == m_header.NumFrames, "Md3Surface mismatch header frames");
CBRM(m_surfaces[i].NumShaders > MD3_MAX_SHADERS, "Md3Surface too many shaders!");
CBRM(m_surfaces[i].NumTriangles > MD3_MAX_TRIANGLES, "Md3Surface too many triangles!");
CBRM(m_surfaces[i].NumVertices > MD3_MAX_VERTICES, "Md3Surface too many vertices!");
Error:
return r;
}
RESULT MeshMd3::CheckMd3Header()
{
RESULT r = R_SUCCESS;
CBRM(m_header.ID == MD3_IDENT, "Md3Header ID incorrect");
CBRM(m_header.NumFrames > MD3_MAX_FRAMES, "Md3Header too many frames!");
CBRM(m_header.NumSurfaces > MD3_MAX_SURFACES, "Md3Header too many surfaces!");
CBRM(m_header.NumTags > MD3_MAX_TAGS, "Md3Header too many tags!");
Error:
return r;
}
RESULT MeshMd3::SetAnimation(float AnimationSpeed, int StartFrame, int FrameLength)
{
m_AnimationSpeed = AnimationSpeed;
m_AnimationStartFrame = StartFrame;
m_AnimationFrameLength = FrameLength;
m_Animation_f = true;
return R_SUCCESS;
}
RESULT MeshMd3::SetFrame(int frame)
{
m_AnimationStartFrame = frame;
return R_SUCCESS;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.