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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
330c8695646c8ff387baeefd7db4d25e15672dbd | d2b667b5953eef78e770b413d9e88a6cb69f6eb4 | /filter/Array.h | 2a19759bd198699ddb3792151e54e2b61625fdec | [
"Apache-2.0"
] | permissive | PetrosStav/CppImageFiltersProjectAUEB | a70ab461ee65921d6d2b9632e6b1a0de09cbf55a | ee859145daee28a309dad1e4b060f8bd7f94df1b | refs/heads/master | 2020-05-20T07:26:41.572034 | 2019-06-07T12:11:20 | 2019-06-07T12:11:20 | 185,451,437 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,206 | h | Array.h | /*!\file Array.h*/
#ifndef _ARRAY_
#define _ARRAY_
/*!\namespace math Contains every class or function associated with math objects and functions*/
namespace math
{
//---------------------------------------------------------------------------------------------
// Do NOT modify this section. For the implementation, see comment below the class declaration
//---------------------------------------------------------------------------------------------
/*! The Array class implements a generic two-dimensional array of elements of type T.
*/
template <typename T>
class Array
{
protected:
//! Flat storage of the elements of the array of type T
T * buffer;
//! The width of the array (number of columns)
unsigned int width,
//! The height of the array (number of rows)
height;
public:
/*! Reports the width (columns) of the array
*
* \return the width.
*/
unsigned int getWidth() const { return width; }
/*! Reports the height (rows) of the array
*
* \return the height.
*/
unsigned int getHeight() const { return height; }
/*! Obtains a constant pointer to the internal data.
*
* This is NOT a copy of the internal array data, but rather a pointer
* to the internally allocated space.
*/
void * const getRawDataPtr();
/*! Returns a reference to the element at the zero-based position (column x, row y).
*
* \param x is the zero-based column index of the array.
* \param y is the zero-based row index of the array.
*
* \return a reference to the element at position (x,y)
*/
T & operator () (int x, int y);
/*! Returns a constant reference to the element at the zero-based position (column x, row y).
*
* \param x is the zero-based column index of the array.
* \param y is the zero-based row index of the array.
*
* \return a reference to the element at position (x,y)
*/
const T & operator () (int x, int y) const;
/*! Constructor with array size.
*
* No default constructor is provided as it makes no sense.
*
* \param w is the width (columns) of the array
* \param h is the height (rows) of the array
*/
Array(unsigned int w, unsigned int h);
/*! Copy constructor.
*
* No default constructor is provided as it makes no sense.
*
* \param source is the array to replicate.
*/
Array(const Array<T> & source);
/*! Copy assignment operator
*
* \param source is the array to replicate.
*/
Array & operator = (const Array<T> & source);
/*! Equality operator.
*
* \param right is the array to compare the current object to.
*
* \return true if the current array and the source have the same dimensions AND
* one by one their elements of type T are the same.
*/
bool operator == (const Array<T> & right) const;
/*! Changes the internal array data storage size.
*
* If the one or both of the given dimensions are smaller, the array should be clipped
* by discarding the remaining elements in the rows and/or columns outside the margins.
* If the new dimensions are larger, pad the old elements with default values of type T.
* If the array is not yet allocated (zero width and height), allocate the internal buffer and
* set the array size according to the given dimensions.
*
* \param new_width is the user-provided width to resize the array to.
* \param new_height is the user-provided height to resize the array to.
*/
void resize(unsigned int new_width, unsigned int new_height);
/*! Virtual destructor.
*/
virtual ~Array();
};
//---------------------------------------------------------------------------------------------
// Do NOT add the member function implementation here. Add all implementations in the Array.hpp
// file included below. The two files will be concatenated upon preprocessing.
//---------------------------------------------------------------------------------------------
} // namespace math
#include "Array.hpp"
#endif |
213bd7fec25cce51bc0d297d5a583af2074c0efd | a7e26cad3d26929371a6db1e8b133c42c6e7f80a | /lab3_sort/array.hpp | 1185a19dc12f846bb862209ecfb479972eae1f1a | [] | no_license | oljakon/analysis-of-algorithms | f53d96f4e4e308f5e3bb7b32d24933c27c2d9166 | 0bf8901d3ad9b4e9e2e5a4eb8e748575ca818a90 | refs/heads/master | 2022-03-25T03:45:10.965135 | 2020-01-06T13:38:19 | 2020-01-06T13:38:19 | 220,699,858 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 324 | hpp | array.hpp | #ifndef array_hpp
#define array_hpp
//#include <stdio.h>
#include <iostream>
int* init_array(int array_size);
void fill_array(int* array, int array_size);
void make_array(int* array, int array_size, int flag, int rand_max);
void print_array(int* array, int array_size);
unsigned long long tick();
#endif /* array_hpp */
|
f1889b3566902cf9278570c5da805adea565916d | 40bb1be8709396d26ed5cf0ced80cc0f796c130e | /samples/seq/set_intersection.cc | 4b6b38ad94e2d12c96d879fe5c77c647fafc06c4 | [
"BSD-2-Clause"
] | permissive | takuya-araki/vstl | 8e333c88bb0382f5ca51804b60dc20f5d98473a3 | 712bb5b24a6164ea1e4560ec58d9d48bf7e36652 | refs/heads/master | 2023-08-19T06:49:12.960949 | 2023-08-16T12:12:07 | 2023-08-16T12:12:07 | 231,082,545 | 9 | 1 | BSD-2-Clause | 2023-08-15T11:43:27 | 2019-12-31T12:05:13 | C++ | UTF-8 | C++ | false | false | 798 | cc | set_intersection.cc | #include <vstl/common/utility.hpp>
#include <vstl/seq/core/set_operations.hpp>
#include "sample_util.hpp"
using namespace std;
int main(int argc, char* argv[]){
vector<int> l1 = {0,2,4,6,8,10};
vector<int> r1 = {0,1,2,3,4,5};
cout << "left: ";
for(auto i: l1) cout << i << " ";
cout << endl << "right: ";
for(auto i: r1) cout << i << " ";
cout << endl;
auto res = vstl::seq::set_intersection(l1,r1);
cout << "intersection: " << endl;
for(auto i: res) cout << i << " ";
cout << endl;
auto left = gen_left<int>(argc, argv);
auto right = gen_right<int>(argc, argv);
auto t1 = vstl::get_dtime();
vstl::seq::set_intersection(left, right);
auto t2 = vstl::get_dtime();
auto size = left.size();
cout << "time of " << size << " data: " << t2-t1 << " sec" << endl;;
}
|
f35313f58e4fef108642c290f64d4dac5c2961f2 | 32fa631560057c5847afec6ff6b6aa8a85034e4f | /src/phoboz/surface.cpp | 605a949b86c7fbbcf8d896db8cb9b41ac15510c3 | [] | no_license | phoboz/dragonscurse | fe4791b096bc1d85f9d7ad147c86a35e13b7b97c | c0f0f12a687147a0d757256b9c397ac08c7d695e | refs/heads/master | 2021-01-18T16:28:12.716400 | 2020-09-11T20:57:03 | 2020-09-11T20:57:03 | 7,941,204 | 4 | 3 | null | 2014-11-14T16:45:55 | 2013-01-31T17:07:36 | C++ | UTF-8 | C++ | false | false | 2,863 | cpp | surface.cpp | #include "SDL_image.h"
#include "phoboz/surface.h"
bool Surface::m_initialized = false;
bool Surface::init()
{
bool result = false;
if (m_initialized) {
result = true;
}
else {
if (SDL_Init(SDL_INIT_EVERYTHING) >= 0) {
atexit(SDL_Quit);
m_initialized = true;
result = true;
}
}
return result;
}
Surface::~Surface()
{
if (m_loaded) {
SDL_FreeSurface(m_s);
m_loaded = false;
}
}
bool Surface::load(const char *fn)
{
m_loaded = false;
if (init()) {
SDL_Surface* tmp = IMG_Load(fn);
if (tmp) {
m_s = SDL_DisplayFormatAlpha(tmp);
SDL_FreeSurface(tmp);
if (m_s) {
m_loaded = true;
}
}
}
return m_loaded;
}
bool Surface::set_screen(int w, int h, bool fullscreen)
{
m_loaded = false;
if (init()) {
int flags = SDL_HWSURFACE | SDL_DOUBLEBUF;
if (fullscreen) {
flags |= SDL_FULLSCREEN;
}
m_s = SDL_SetVideoMode(w, h, 32, flags);
if (m_s) {
m_loaded = true;
}
}
return m_loaded;
}
void Surface::get_pixel(Color *c, int x, int y)
{
// Extracting color components from a 32-bit color value
SDL_PixelFormat *fmt;
Uint32 temp, *pixel;
fmt = m_s->format;
SDL_LockSurface(m_s);
pixel= (Uint32 *) m_s->pixels + y * m_s->pitch / 4 + x;
SDL_UnlockSurface(m_s);
// Get Red component
temp = *pixel & fmt->Rmask; // Isolate red component
temp = temp >> fmt->Rshift; //Shift it down to 8-bit
temp = temp << fmt->Rloss; //Expand to a full 8-bit number
c->set_r((Uint8) temp);
// Get Green component
temp = *pixel & fmt->Gmask; // Isolate green component
temp = temp >> fmt->Gshift; // Shift it down to 8-bit
temp = temp << fmt->Gloss; // Expand to a full 8-bit number
c->set_g((Uint8) temp);
// Get Blue component
temp = *pixel & fmt->Bmask; // Isolate blue component
temp = temp >> fmt->Bshift; // Shift it down to 8-bit
temp = temp << fmt->Bloss; // Expand to a full 8-bit number
c->set_b((Uint8) temp);
// Get Alpha component
temp = *pixel & fmt->Amask; // Isolate alpha component
temp = temp >> fmt->Ashift; // Shift it down to 8-bit
temp = temp << fmt->Aloss; // Expand to a full 8-bit number
c->set_a((Uint8) temp);
}
void Surface::fill_rect(Rect *rect, Color *c)
{
SDL_Rect dest_rect = *rect;
SDL_Color col = *c;
int pixel = SDL_MapRGB(get_format(), col.r, col.g, col.b);
SDL_FillRect(m_s, &dest_rect, pixel);
}
void Surface::draw(Rect *src_rect, Surface *dest, Rect *dest_rect)
{
SDL_Rect sdl_src_rect = *src_rect;
SDL_Rect sdl_dest_rect = *dest_rect;
SDL_BlitSurface(m_s, &sdl_src_rect, dest->m_s, &sdl_dest_rect);
}
|
efb9e2b94e50f10e4f4931c154cc0e960bfb0e87 | 1503234bdcce94b443001e6696150679fa238455 | /projects/yaget/branch/legacy/Research/swap_buffers/rendering/dx9/SwapChainDX9.h | f27d83bc22d1900e9f99338a8cfc26db8d4a45b4 | [] | no_license | eglowacki/yaget_legacy | 69db4be7c9cbfc5a1758b18bc8c12324a7071440 | b4b7498bc9824811c14682078795fc3f5a50632a | refs/heads/master | 2021-01-15T15:31:04.791791 | 2016-07-10T22:44:03 | 2016-07-10T22:44:03 | 48,589,107 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,737 | h | SwapChainDX9.h | //--------------------------------------------------------------------------------------------------------------------//
// DX9 SWAP CHAIN CLASS //
// (MULTIPLE VIEWS) //
// 22/05/02, Mythos //
// 31/07/03: DX9
//--------------------------------------------------------------------------------------------------------------------//
#ifndef _MYTHOS_SWAPCHAINDX9_H_
#define _MYTHOS_SWAPCHAINDX9_H_
#pragma once
//----------------------------------------------- INCLUDES -----------------------------------------------------------//
#define D3D_OVERLOADS
#include <d3d9.h>
#include "Rendering/SwapChain.h"
//----------------------------------------------- CLASSES ------------------------------------------------------------//
//--------------------------------------------------------------------------------------------------------------------//
// CSwapChainDX9 //
//--------------------------------------------------------------------------------------------------------------------//
namespace Mythos
{
class CSwapChainDX9 : public CSwapChain
{
// public methods
public:
// constructors & destructor
CSwapChainDX9 (u32 u32Handle,bool boWindowed,bool boZBuffer,HWND hWnd,u32 u32Width,u32 u32Height);
virtual ~CSwapChainDX9 (void);
// get/set
IDirect3DSwapChain9* GetInterface (void) const;
void SetInterface (IDirect3DSwapChain9* pInterface);
IDirect3DSurface9* GetBackBuffer (void) const;
void SetBackBuffer (IDirect3DSurface9* pBackBuffer);
IDirect3DSurface9* GetZStencil (void) const;
void SetZStencil (IDirect3DSurface9* pZStencil);
// protected data
protected:
IDirect3DSwapChain9* m_pInterface;
IDirect3DSurface9* m_pBackBuffer;
IDirect3DSurface9* m_pZStencil;
};
// smart ptr
_SMART_POINTER_(CSwapChainDX9)
}
//----------------------------------------------- INLINES ------------------------------------------------------------//
#ifndef _DEBUG
#include "SwapChainDX9.inl"
#endif
//--------------------------------------------------------------------------------------------------------------------//
#endif // _MYTHOS_SWAPCHAINDX9_H_
|
c6047f61bac9a85aecb017c7553c1825011719fb | 5e3b68418178fde3010c40e59036de1cfaeddf7c | /disk.h | 929696518fc75bf59c2b65c6f379165cf40bd8b4 | [] | no_license | Congb19/FileSystem | 176cdccf7b005927fbf647b72cd499a0b8be978a | 658c01b981b0c2b939a5714b3c1bdb41623521eb | refs/heads/master | 2020-12-04T21:45:55.053445 | 2020-01-09T19:47:54 | 2020-01-09T19:47:54 | 231,911,068 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 690 | h | disk.h | //
// Created by Congb on 2020/1/5.
//
#ifndef FILESYSTEM_DISK_H
#define FILESYSTEM_DISK_H
#include <iostream>
#include <cmath>
#include <vector>
#include "node.h"
#define DISK_SIZE 1000
#define BLOCK_SIZE 8
using namespace std;
struct block {
string data;
int size=BLOCK_SIZE;
bool used=false;
};
class disk {
public:
disk();
~disk();
bool set(int start, int len, bool usage);
bool use(int start, int len);
bool free(int start, int len);
int nearfit(int len);
int bestfit(int len);
addr write(string data);
string read(int start, int len);
private:
vector<block> datas;
int frees=DISK_SIZE;
};
#endif //FILESYSTEM_DISK_H
|
54f3bc6f1f060a489c6b5cab7a8e367aa4b24a4a | 28c0401f23f37ae4f25253a2f31d87d25a365796 | /src/util/part_io.h | e2d04a33dc2f70ee426e9faca24d16b622399736 | [
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | equalitie/ouinet | 3cdb85aa9893c4ea8f493ee1f0a7c8e22c2db073 | a915e29bc152556106b078070eb9e59756e50e6e | refs/heads/master | 2023-08-31T14:08:43.869481 | 2023-04-14T05:17:38 | 2023-04-14T05:17:38 | 104,485,565 | 117 | 15 | MIT | 2023-03-07T21:52:22 | 2017-09-22T14:45:45 | C++ | UTF-8 | C++ | false | false | 1,567 | h | part_io.h | #pragma once
#include "../response_part.h"
#include <ostream>
namespace ouinet { namespace http_response {
inline
std::ostream& operator<<(std::ostream& o, const http_response::Head& h) {
o << "Head";
return o;
}
inline
std::ostream& operator<<(std::ostream& o, const http_response::ChunkHdr& c) {
o << "ChunkHdr size:" << c.size << " exts:" << c.exts;
return o;
}
inline
std::ostream& operator<<(std::ostream& o, const http_response::ChunkBody& b) {
o << "ChunkBody size:" << b.size() << " remain:" << b.remain;
return o;
}
inline
std::ostream& operator<<(std::ostream& o, const http_response::Body& b) {
o << "Body";
return o;
}
inline
std::ostream& operator<<(std::ostream& o, const http_response::Trailer& t) {
o << "Trailer";
bool first = true;
for (auto& f : t) {
if (!first) o << ";";
first = false;
o << " " << f.name_string() << ":" << f.value();
}
return o;
}
inline
std::ostream& operator<<(std::ostream& o, const http_response::Part& p) {
util::apply(p, [&](const auto& p_) { o << p_; });
return o;
}
inline
std::ostream& operator<<(std::ostream& o, const http_response::Part::Type& t) {
using Type = http_response::Part::Type;
switch (t) {
case Type::HEAD: o << "HEAD"; break;
case Type::BODY: o << "BODY"; break;
case Type::CHUNK_HDR: o << "CHUNK_HDR"; break;
case Type::CHUNK_BODY: o << "CHUNK_BODY"; break;
case Type::TRAILER: o << "TRAILER"; break;
}
return o;
}
}}
|
3b55353d8cef0df6121c602f038e0209085d785a | 74098a03c8b497f43836b3b22dd31ebf8cb19120 | /CodeChef/maxval2.cpp | 20f6427d7d4328b307877796b9e3172602e0e4bc | [] | no_license | sekhar76405/Problem_Solving | 99868383e00eb023aac83fe38a7f3d4cda64aad0 | ff0e29b76c0ed20bb05f4de758327808dae4513e | refs/heads/master | 2023-03-25T09:45:55.911434 | 2021-03-17T18:10:36 | 2021-03-17T18:10:36 | 329,359,687 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 650 | cpp | maxval2.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
long *arr = new long[n];
long long total =0;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
sort(arr, arr + n);
long pos=0, neg=0;
for(int i=0;i<n;i++)
{
if(arr[i]<0)
{
neg = neg + arr[i];
}
if(arr[i]>=0)
{
pos = pos + arr[i];
}
}
if(pos < (-neg))
{
total = arr[1] - arr[0] + arr[0]*arr[1];
cout<<total<<endl;
}
else
{
total = arr[n-1] - arr[n-2] + arr[n-1]*arr[n-2];
cout<<total<<endl;
}
}
} |
89301253692c5432512495255f64bb9b44a4a726 | 5aa0f5c9c2d2a9b20d3651e90cbc6912412ac76c | /CommonUtil/TUtil.cpp | 2ffd1062bf05e382283a86e2acff35d36b20a132 | [] | no_license | tamenut/stm2 | 936e0b7d94d2ff13b855a5c334dd05a1ff252689 | c440a96248443bf5edcf0ebd9a7791c059aa6337 | refs/heads/master | 2020-11-27T01:38:15.998309 | 2019-12-20T15:54:55 | 2019-12-20T15:54:55 | 229,259,075 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 15,952 | cpp | TUtil.cpp | #include "TUtil.h"
#ifdef WIN32
#include <windows.h>
#include "psapi.h"
#else
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <arpa/inet.h>
#endif
enum FLAG_ENDIAN
{
FLAG_BIG_ENDIAN = false,//0,
FLAG_LITTLE_ENDIAN = true//1
};
//문자열의 앞, 뒤에 공백을 제거
void ignore_blank(char *bp)
{
int src_i=0, dst_i=0;
while((bp[src_i]==' ') || (bp[src_i]=='\t'))
{
if(bp[src_i] == 0)
{
break;
}
src_i++;
}
while(bp[src_i] != 0)
{
bp[dst_i++] = bp[src_i++];
}
//bp[dst_i]='\0';
dst_i--;
while(bp[dst_i]==' ' || bp[dst_i]=='\t'){
dst_i--;
}
bp[++dst_i]='\0';
}
/*
인수로 받은 문자열의 맨앞에 공백을 없애는 함수
*/
/*
char *ignore_blank(char *bp)
{
int i=0;
while((bp[i]==' ') || (bp[i]=='\t'))
{
if(bp[i] == 0)
{
break;
}
i++;
}
return &bp[i];
}
*/
//#ifndef WIN32
#if 1
/*
파일에서 한줄을 읽어 return하는 함수
*/
#if 1
int read_line(FILE *fp, char *bp)
{
int res = 0;
bp[0] = '\0';
if(fgets(bp, MAX_LINE_LENGTH, fp) == NULL)
{
res = -1;
}
else
{
if(bp[strlen(bp)-1] == '\n')
bp[strlen(bp)-1] = '\0';
}
remove_comment(bp);
ignore_blank(bp);
//읽어들인 문자열도 없고 파일의 끝인경우는 -1 리턴
//읽어들인 문자열의 사이즈를 리턴
if(strlen(bp) > 0 && res == -1)
{
res = strlen(bp);
}
return res;
}
#else
int read_line(FILE *fp, char *bp)
{
char c = '\0';
int i = 0;
int res = 0;
/*
do
{
c = getc(fp);
if( c == EOF || c == '\n')
break;
}while(true);
bp[i] = '\0';
*/
/* Read one line from the source file */
while( (c = getc(fp)) != '\n' )
{
if( c == EOF ) /* return FALSE on unexpected EOF */
{
res = -1;
break;
}
bp[i++] = c;
}
bp[i] = '\0';
ignore_blank(bp);
if(strlen(bp) > 0 && res == -1)
{
res = strlen(bp);
}
return res;
}
#endif
void getParam(char *buff, char *param, int &offset)
{
int src_i=offset, dst_i=0;
#if 1
while ((buff[src_i] != ' ') && (buff[src_i] != '\t') && buff[src_i] != 0)
{
param[dst_i++] = buff[src_i++];
if (buff[src_i] == 0)
{
break;
}
}
param[dst_i] = '\0';
offset = ++src_i;
#else
while((buff[src_i]==' ') || (buff[src_i]=='\t'))
{
if(buff[src_i] == 0)
{
break;
}
src_i++;
}
while(buff[src_i] != 0)
{
param[dst_i++] = buff[src_i++];
}
//bp[dst_i]='\0';
param[++dst_i]='\0';
#endif
}
//인자로 받은 문자열이 Section인지를 확인
bool isSection(char *buff)
{
bool res = false;
int len = strlen(buff);
if(buff[0] == '[' && buff[len-1] == ']')
res = true;
return res;
}
//인자로 받은 Section이 정의 되어있는지 확인하여
//Section이 정의 되어 있으면 파일 포인터를 다음 라인으로 변경
bool isDefinedSection(FILE *fp, const char *section)
{
bool res = true;
char t_section[MAX_LINE_LENGTH];
char buff[MAX_LINE_LENGTH];
sprintf(t_section,"[%s]",section);
do
{
if( read_line(fp,buff) == -1)
{
res = false;
break;
}
}while( strcmp(buff,t_section) );
return res;
}
char *getEntryStr(FILE *fp, const char *entry, char *buff)
{
char *res = NULL;
int len = strlen(entry);
while(read_line(fp,buff) != -1)
{
if(isSection(buff) == true)
{
break;
}
if(strncmp(buff,entry,len) == 0)
{
res = strrchr(buff,'='); /* Parse out the equal sign */
res++;
ignore_blank(res);
break;
}
}
return res;
}
//#if 1
/************************************************************************
* Function: get_private_profile_int()
* Arguments: <char *> section - the name of the section to search for
* <char *> entry - the name of the entry to find the value of
* <int> def - the default value in the event of a failed read
* <char *> file_name - the name of the .ini file to read from
* Returns: the value located at entry
*************************************************************************/
#ifdef WIN32
int get_private_profile_int(char *section, char *entry, int def, char *file_name)
#else
int get_private_profile_int(const char *section, const char *entry, int def, const char *file_name)
#endif
{
FILE *fp = fopen(file_name,"r");
char *ep;
char buff[MAX_LINE_LENGTH];
int res = def;
if( fp != NULL )
{
if(isDefinedSection(fp, (const char*)section) == true)
{
ep = getEntryStr(fp, (const char*)entry, buff);
if( ep != NULL && strlen(ep) > 0)
{
res = atoi(ep);
}
}
fclose(fp);
}
return res;
}
//#if 1
/************************************************************************
* Function: get_private_profile_float()
* Arguments: <char *> section - the name of the section to search for
* <char *> entry - the name of the entry to find the value of
* <int> def - the default value in the event of a failed read
* <char *> file_name - the name of the .ini file to read from
* Returns: the value located at entry
*************************************************************************/
#ifdef WIN32
float get_private_profile_float(char *section, char *entry, float def, char *file_name)
#else
float get_private_profile_float(const char *section, const char *entry, float def, const char *file_name)
#endif
{
FILE *fp = fopen(file_name,"r");
char *ep;
char buff[MAX_LINE_LENGTH];
float res = def;
if( fp != NULL )
{
if(isDefinedSection(fp, (const char*)section) == true)
{
ep = getEntryStr(fp, (const char*)entry, buff);
if( ep != NULL && strlen(ep) > 0)
{
res = (float)atof(ep);
}
}
fclose(fp);
}
return res;
}
/**************************************************************************
* Function: get_private_profile_string()
* Arguments: <char *> section - the name of the section to search for
* <char *> entry - the name of the entry to find the value of
* <char *> def - default string in the event of a failed read
* <char *> buffer - a pointer to the buffer to copy into
* <int> buffer_len - the max number of characters to copy
* <char *> file_name - the name of the .ini file to read from
* Returns: the number of characters copied into the supplied buffer
***************************************************************************/
#ifdef WIN32
int get_private_profile_string(char *section, char *entry, char *def, char *buffer, int buffer_len, char *file_name)
#else
int get_private_profile_string(const char *section, const char *entry, const char *def, char *buffer, int buffer_len, const char *file_name)
#endif
{
FILE *fp = fopen(file_name,"r");
char *ep;
char buff[MAX_LINE_LENGTH];
int res = 0;
strncpy(buffer, def, buffer_len);
res = strlen(def);
if( fp != NULL)
{
if(isDefinedSection(fp, section) == true)
{
ep = getEntryStr(fp, entry, buff);
if(ep != NULL)
{
strncpy(buffer, ep, buffer_len-1);
buffer[buffer_len-1] = '\0';
res = strlen(buffer);
}
}
fclose(fp);
}
return res;
}
#endif
void remove_comment(char *buf)
{
char *res = NULL;
res = strstr(buf, "//");
if(res != NULL)
{
*res = '\0';
}
}
bool is_comment(char *buf)
{
bool res = false;
if(buf[0] == ';' || memcmp(buf, "//", 2) == 0)
res =true;
return res;
}
#ifdef WIN32
char* parse_file_name(char *file_path)
{
char *file_name;
while(*file_path)
{
if(*file_path == '\\' && (file_path +1) != NULL )
{
file_name = file_path+1;
}
else
{ }
file_path++; //mv pointer
}
return file_name;
}
#endif
void miilisec_sleep(unsigned int miliseconds)
{
#ifdef WIN32
Sleep(miliseconds);
#else
usleep(miliseconds*1000);
#endif
}
#ifdef LINUX
int get_process_name_by_pid(int pid, char *name)
{
bool result = true;
char file_name[256];
//sprintf(file_name, "/proc/%d/cmdline", pid);
sprintf(file_name, "/proc/%d/comm", pid);
FILE *fp = fopen(file_name, "r");
if(!fp)
{
result = false;
}
else
{
size_t read_len = fread(name, sizeof(char), MAX_PROCESS_NAME, fp);
if(read_len > 0)
name[read_len-1]='\0';
else
result = false;
fclose(fp);
}
return result;
}
#endif
const char *get_current_process_name()
{
static char *buf = NULL;
if(buf == NULL)
{
buf = new char[128];
#ifdef WIN32
DWORD pid = GetCurrentProcessId();
HANDLE handle =
OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
#if 1
GetModuleBaseName(handle, 0, buf, 512);
char *tmp = (char*)strchr(buf, '.');
if(tmp != NULL)
*tmp = '\0';
#else
GetModuleFileName(handle, 0, tmp, 512);
strcpy(buf, parse_file_name(tmp));
#endif
CloseHandle(handle);
#else
get_process_name_by_pid(getpid(), buf);
#endif
}
return buf;
}
int get_process_id()
{
#ifdef WIN32
int pid = GetCurrentProcessId();
#else
int pid = getpid();
#endif
return pid;
}
int ntohss_t(const char* src, char* dst)
{
memcpy(dst, src, 1);
return 1;
}
int htonss_t(const char* src, char* dst)
{
memcpy(dst, src, 1);
return 1;
}
int ntohs_t(const char* src, char* dst)
{
int systemEndian = get_system_endian();
if(systemEndian == FLAG_BIG_ENDIAN)
memcpy(dst, src, 2);
else
swap2bytes(src, dst);
return 2;
}
int htons_t(const char* src, char* dst)
{
int systemEndian = get_system_endian();
if(systemEndian == FLAG_BIG_ENDIAN)
memcpy(dst, src, 2);
else
swap2bytes(src, dst);
return 2;
}
int ntohl_t(const char* src, char* dst)
{
int systemEndian = get_system_endian();
if(systemEndian == FLAG_BIG_ENDIAN)
memcpy(dst, src, 4);
else
swap4bytes(src, dst);
return 4;
}
int htonl_t(const char* src, char* dst)
{
int systemEndian = get_system_endian();
if(systemEndian == FLAG_BIG_ENDIAN)
memcpy(dst, src, 4);
else
swap4bytes(src, dst);
return 4;
}
int ntohll_t(const char* src, char* dst)
{
int systemEndian = get_system_endian();
if(systemEndian == FLAG_BIG_ENDIAN)
memcpy(dst, src, 8);
else
swap8bytes(src, dst);
return 8;
}
int htonll_t(const char* src, char* dst)
{
int systemEndian = get_system_endian();
if(systemEndian == FLAG_BIG_ENDIAN)
memcpy(dst, src, 8);
else
swap8bytes(src, dst);
return 8;
}
int ntohstr_t(const char* src, char* dst, unsigned int str_len)
{
memcpy(dst, src, str_len);
return str_len;
}
int htonstr_t(const char* src, char* dst, unsigned int str_len)
{
memcpy(dst, src, str_len);
return str_len;
}
void swap2bytes(const char* src, char* dst)
{
(void)( \
*((char *)(dst) + 0) = *((char *)(src) + 1), \
*((char *)(dst) + 1) = *((char *)(src) ) \
);
}
void swap4bytes(const char* src, char* dst)
{
(void)( \
*((char *)(dst) + 0) = *((char *)(src) + 3), \
*((char *)(dst) + 1) = *((char *)(src) + 2), \
*((char *)(dst) + 2) = *((char *)(src) + 1), \
*((char *)(dst) + 3) = *((char *)(src) ) \
);
}
void swap8bytes(const char* src, char* dst)
{
(void)( \
*((char *)(dst) + 0) = *((char *)(src) + 7), \
*((char *)(dst) + 1) = *((char *)(src) + 6), \
*((char *)(dst) + 2) = *((char *)(src) + 5), \
*((char *)(dst) + 3) = *((char *)(src) + 4), \
*((char *)(dst) + 4) = *((char *)(src) + 3), \
*((char *)(dst) + 5) = *((char *)(src) + 2), \
*((char *)(dst) + 6) = *((char *)(src) + 1), \
*((char *)(dst) + 7) = *((char *)(src) ) \
);
}
bool get_system_endian()
{
static bool bEndian;
static bool isProcess = false;
if(isProcess == false)
{
isProcess = true;
int i = 0x00000001;
if ( ((char *)&i)[0] )
bEndian = true;//Little Endian
else
bEndian = false;//Big Endian
}
return bEndian;
}
void wsa_startup()
{
#if defined(WIN32)
static bool is_process= false;
if(is_process==false)
{
WSADATA wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
is_process = true;
}
#endif
}
int ntoh_t(char &value, char *payload)
{
return ntohss_t(payload, &value);
}
int ntoh_t(unsigned char &value, char *payload)
{
return ntohss_t(payload, (char*)&value);
}
int ntoh_t(short &value, char *payload)
{
return ntohs_t(payload, (char*)&value);
}
int ntoh_t(unsigned short &value, char *payload)
{
return ntohs_t(payload, (char*)&value);
}
int ntoh_t(int &value, char *payload)
{
return ntohl_t(payload, (char*)&value);
}
int ntoh_t(unsigned int &value, char *payload)
{
return ntohl_t(payload, (char*)&value);
}
int ntoh_t(long &value, char *payload)
{
return ntohl_t(payload, (char*)&value);
}
int ntoh_t(unsigned long &value, char *payload)
{
return ntohl_t(payload, (char*)&value);
}
int ntoh_t(long long &value, char *payload)
{
return ntohll_t(payload, (char*)&value);
}
int ntoh_t(float &value, char *payload)
{
return ntohl_t(payload, (char*)&value);
}
int ntoh_t(double &value, char *payload)
{
return ntohll_t(payload, (char*)&value);
}
int ntoh_t(char *str, unsigned int str_len, char *payload)
{
return ntohstr_t(payload, str, str_len);
}
/*
int ntoh_t(SerializedPayload &str, char *payload)
{
return ntohstr_t(payload, str.get_payload_ptr(), str.get_payload_len());
}
*/
int hton_t(char &value, char *payload)
{
return htonss_t(&value, payload);
}
int hton_t(unsigned char &value, char *payload)
{
return htonss_t((const char*)&value, payload);
}
int hton_t(short &value, char *payload)
{
return htons_t((const char*)&value, payload);
}
int hton_t(unsigned short &value, char *payload)
{
return htons_t((const char*)&value, payload);
}
int hton_t(int &value, char *payload)
{
return htonl_t((const char*)&value, payload);
}
int hton_t(unsigned int &value, char *payload)
{
return htonl_t((const char*)&value, payload);
}
int hton_t(long &value, char *payload)
{
return htonl_t((const char*)&value, payload);
}
int hton_t(unsigned long &value, char *payload)
{
return htonl_t((const char*)&value, payload);
}
int hton_t(long long &value, char *payload)
{
return htonll_t((const char*)&value, payload);
}
int hton_t(float &value, char *payload)
{
return htonl_t((const char*)&value, payload);
}
int hton_t(double &value, char *payload)
{
return htonll_t((const char*)&value, payload);
}
int hton_t(char *str, unsigned int str_len, char *payload)
{
return htonstr_t(str, payload, str_len);
}
char ntoh_t(char &value)
{
return value;
}
unsigned char ntoh_t(unsigned char &value)
{
return value;
}
short ntoh_t(short &value)
{
return ntohs(value);
}
unsigned short ntoh_t(unsigned short &value)
{
return ntohs(value);
}
int ntoh_t(int &value)
{
return ntohl(value);
}
unsigned int ntoh_t(unsigned int &value)
{
return ntohl(value);
}
long ntoh_t(long &value)
{
return ntohl(value);
}
unsigned long ntoh_t(unsigned long &value)
{
return ntohl(value);
}
long long ntoh_t(long long &value)
{
long long new_value;
ntohll_t((char*)&value, (char*)&new_value);
return new_value;
}
float ntoh_t(float &value)
{
float new_value;
ntohl_t((char*)&value, (char*)&new_value);
return new_value;
}
double ntoh_t(double &value)
{
double new_value;
ntohll_t((char*)&value, (char*)&new_value);
return new_value;
}
char hton_t(char &value)
{
return value;
}
unsigned char hton_t(unsigned char &value)
{
return value;
}
short hton_t(short &value)
{
return htons(value);
}
unsigned short hton_t(unsigned short &value)
{
return htons(value);
}
int hton_t(int &value)
{
return htonl(value);
}
unsigned int hton_t(unsigned int &value)
{
return htonl(value);
}
long hton_t(long &value)
{
return htonl(value);
}
unsigned long hton_t(unsigned long &value)
{
return htonl(value);
}
long long hton_t(long long &value)
{
long long new_value;
htonll_t((char*)&value, (char*)&new_value);
return new_value;
}
float hton_t(float &value)
{
float new_value;
htonl_t((char*)&value, (char*)&new_value);
return new_value;
}
double hton_t(double &value)
{
double new_value;
htonll_t((char*)&value, (char*)&new_value);
return new_value;
}
/*
int hton_t(SerializedPayload &str, char *payload)
{
return htonstr_t(str.get_payload_ptr(), payload, str.get_payload_len());
}
*/
|
14534ecff63cbff99833f4848255c9f2824c61db | b8cc062a0acf6a39794b6d3f041baad8a6c10acf | /Práctica 4 final/fecha.h | 28d7cabda121d9a3e0ef0f30717dc8fe62190e31 | [] | no_license | Char-Mander/Conecta-4-sin-punteros | d8aa945b57d828d893ebb7e477e7e7ccc202b8fa | cd444b920f9d9c943dc4c331448d1a4474290667 | refs/heads/master | 2020-06-12T12:22:37.153610 | 2019-06-28T15:42:57 | 2019-06-28T15:42:57 | 194,297,542 | 0 | 0 | null | null | null | null | ISO-8859-10 | C++ | false | false | 566 | h | fecha.h | // LAURA JIMENEZ FERNANDEZ & DAVID LOSILLA CADENAS
// L2-G12
#ifndef fecha_h //Realizamos un ifndef para evitar que fecha en algun modulo aparezca definida dos veces, ya que en el modulogestor y mainP4 nos encontrariamos con problemas
#define fecha_h
#include <iostream>
typedef time_t tFecha; //Definimos el tipo tFecha
tFecha fechaActual();//Funcion que nos permite saber cual es la fecha actual
std::string stringFecha(tFecha fecha, bool hora); //Funcion que nos permite pasar un tFecha a un formato valido de dia/mes/aņo con hora opcional
#endif fecha_h |
8dab651ba69e105795fff7483e5b29fb4e164fa5 | e05aab08368b6b86fbe0b1afeb76da3537d7dfd7 | /demo/p2p_demo/server.cpp | d755f40994bff3bb4d5738c3f4690ea8e5e70e67 | [
"BSD-2-Clause"
] | permissive | kerolex/DBoW2 | 7127ea41d0a936ecd5bda22e78972dad16acf02f | 712a59e28f8c7a0537962ba565326c5c440a5119 | refs/heads/master | 2020-03-23T12:48:34.945532 | 2019-04-13T15:56:34 | 2019-04-13T15:56:34 | 141,583,366 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,808 | cpp | server.cpp | /**
* File: Demo.cpp
* Date: November 2011
* Author: Dorian Galvez-Lopez
* Description: demo application of DBoW2
* License: see the LICENSE.txt file
*/
#include <cassert>
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <thread>
// DBoW2
#include <DBoW2.h> // defines OrbVocabulary and OrbDatabase
#include <TemplatedVocabulary.h>
// DLib
#include <DUtils/DUtils.h>
#include <DVision/DVision.h>
// OpenCV
#include <opencv2/opencv.hpp>
#include <zmq.h>
using namespace DBoW2;
using namespace DUtils;
using namespace std;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const int DESC_TH = 50;
const float LOWE_RATIO = 0.8;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void loadFeatures(vector<vector<cv::Mat> > &features, std::string videopath);
/**
*
*/
void changeStructure(const cv::Mat &plain, vector<cv::Mat> &out);
// @Override
void changeStructure(const vector<cv::Mat> &plain_vec, cv::Mat& out);
void testVocCreation(const vector<vector<cv::Mat> > &feats1);
/**
* @fn
*
* @brief
*
* Features are matched using the fast BoW approach and the nearest neighbour
* with distance ratio to remove ambiguities and minimum threshold
*/
int SearchByBoW(const cv::Mat& desc1, const cv::Mat& desc2,
const DBoW2::FeatureVector &vFeatVec1,
const DBoW2::FeatureVector &vFeatVec2,
std::map<int, int>& matches12, const int& desc_th,
const float& lowe_ratio);
/**
* @fn DescriptorDistance
*
* Bit set count operation from
* http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
*
* @param a First ORB descriptor whose dimension is 32 bytes (i.e. 32 elements
* of uchar values)
* @param a Second ORB descriptor whose dimension is 32 bytes (i.e. 32 elements
* of uchar values)
*/
int DescriptorDistance(const cv::Mat &a, const cv::Mat &b);
typedef DBoW2::TemplatedVocabulary<DBoW2::FORB::TDescriptor, DBoW2::FORB> ORBVocabulary;
void listener() {
// Socket to talk to clients
void *context = zmq_ctx_new();
void *responder = zmq_socket(context, ZMQ_REP);
int rc = zmq_bind(responder, "tcp://*:5555");
assert(rc == 0);
while (1) {
char buffer[10];
zmq_recv(responder, buffer, 10, 0);
printf("Server: Received Hello\n");
sleep(1); // Do some 'work'
zmq_send(responder, "World", 5, 0);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void wait() {
cout << endl << "Press enter to continue" << endl;
getchar();
}
// ----------------------------------------------------------------------------
int main(int argc, char* argv[]) {
std::thread* ptListener = new thread(&listener);
//Load ORB Vocabulary from disk (ORB-SLAM learnt vocabulary)
cout << endl << "Loading ORB Vocabulary. This could take a while..." << endl;
std::string strVocFile = argv[2];
ORBVocabulary* mpVocabulary = new ORBVocabulary();
bool bVocLoad = mpVocabulary->loadFromTextFile(strVocFile);
if (!bVocLoad) {
std::cerr << "Wrong path to vocabulary. " << std::endl;
cerr << "Falied to open at: " << strVocFile << endl;
exit(-1);
}
cout << "Vocabulary loaded!" << endl << endl;
cout << "Vocabulary information: " << endl << &mpVocabulary << endl << endl;
/// Parse input parameters
std::string videopath = argv[1];
vector < vector<cv::Mat> > feats;
loadFeatures(feats, videopath);
testVocCreation(feats1);
std::cout << "Finished!" << std::endl;
return EXIT_SUCCESS;
}
// ----------------------------------------------------------------------------
void loadFeatures(vector<vector<cv::Mat> > &features, std::string videopath,
ORBVocabulary* mpVocabulary) {
cv::VideoCapture cam1(videopath + "%06d.png");
if (!cam1.isOpened()) {
return;
}
int nFrames = cam1.get(CV_CAP_PROP_FRAME_COUNT);
features.clear();
features.reserve(nFrames);
OrbDatabase db(mpVocabulary, false, 0); // false = do not use direct index
cv::Ptr < cv::ORB > orb = cv::ORB::create(1000);
cout << "Extracting ORB features..." << endl;
for (int i = 0; i < nFrames; ++i) {
stringstream ss;
ss << "images/image" << i << ".png";
cv::Mat rgb_img;
cam1 >> rgb_img; // Get a new frame from the video
if (rgb_img.empty()) {
std::cerr << "!!! Failed imread(): image not found !!!" << std::endl;
return;
}
// Convert RGB to gray image
cv::Mat mImGray = rgb_img;
if (mImGray.channels() == 3) {
cvtColor(mImGray, mImGray, CV_RGB2GRAY);
}
cv::Mat mask;
vector < cv::KeyPoint > keypoints;
cv::Mat descriptors;
orb->detectAndCompute(mImGray, mask, keypoints, descriptors);
features.push_back(vector<cv::Mat>());
changeStructure(descriptors, features.back());
db.add(features[i]);
}
}
// ----------------------------------------------------------------------------
void changeStructure(const cv::Mat &plain, vector<cv::Mat> &out) {
out.resize(plain.rows);
for (int i = 0; i < plain.rows; ++i) {
out[i] = plain.row(i);
}
}
void changeStructure(const vector<cv::Mat> &plain_vec, cv::Mat& out) {
out.release();
for (size_t i = 0; i < plain_vec.size(); ++i) {
out.push_back(plain_vec[i].clone());
}
}
// ----------------------------------------------------------------------------
void testVocCreation(const vector<vector<cv::Mat> > &feats1) {
// lets do something with this vocabulary
cout << "Matching images against themselves (0 low, 1 high): " << endl;
BowVector v1;
DBoW2::FeatureVector fv1;
int nFeats1 = (int) feats1.size();
for (int i = 0; i < nFeats1; i++) {
cv::Mat D1;
changeStructure(feats1[i], D1);
mpVocabulary->transform(feats1[i], v1, fv1, 4);
std::cout << "# features in first image: " << D1.rows << std::endl;
}
cout << "Done" << endl;
}
// Features are matched using the fast BoW approach and the nearest neighbour
// with distance ratio to remove ambiguities and minimum threshold
int SearchByBoW(const cv::Mat& desc1, const cv::Mat& desc2,
const DBoW2::FeatureVector &vFeatVec1,
const DBoW2::FeatureVector &vFeatVec2,
std::map<int, int>& matches12, const int& desc_th,
const float& lowe_ratio) {
matches12.clear();
int nmatches = 0; // number of matches
DBoW2::FeatureVector::const_iterator f1it = vFeatVec1.begin();
DBoW2::FeatureVector::const_iterator f2it = vFeatVec2.begin();
DBoW2::FeatureVector::const_iterator f1end = vFeatVec1.end();
DBoW2::FeatureVector::const_iterator f2end = vFeatVec2.end();
while (f1it != f1end && f2it != f2end) {
if (f1it->first == f2it->first) {
for (size_t i1 = 0, iend1 = f1it->second.size(); i1 < iend1; i1++) {
const size_t idx1 = f1it->second[i1];
const cv::Mat &d1 = desc1.row(idx1);
int bestDist1 = 256;
int bestIdx2 = -1;
int bestDist2 = 256;
for (size_t i2 = 0, iend2 = f2it->second.size(); i2 < iend2; i2++) {
const size_t idx2 = f2it->second[i2];
const cv::Mat &d2 = desc2.row(idx2);
int dist = DescriptorDistance(d1, d2);
if (dist < bestDist1) {
bestDist2 = bestDist1;
bestDist1 = dist;
bestIdx2 = idx2;
} else if (dist < bestDist2) {
bestDist2 = dist;
}
}
if (bestDist1 < desc_th) {
if (static_cast<float>(bestDist1)
< lowe_ratio * static_cast<float>(bestDist2)) {
matches12[idx1] = bestIdx2;
nmatches++;
}
}
}
f1it++;
f2it++;
} else if (f1it->first < f2it->first) {
f1it = vFeatVec1.lower_bound(f2it->first);
} else {
f2it = vFeatVec2.lower_bound(f1it->first);
}
}
return nmatches;
}
//
int DescriptorDistance(const cv::Mat &a, const cv::Mat &b) {
const int *pa = a.ptr<int32_t>();
const int *pb = b.ptr<int32_t>();
int dist = 0;
for (int i = 0; i < 8; i++, pa++, pb++) {
unsigned int v = *pa ^ *pb;
v = v - ((v >> 1) & 0x55555555);
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
dist += (((v + (v >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
}
return dist;
}
void CreateDatabase(const vector<vector<vector<float> > > &features,
ORBVocabulary* mpVocabulary)
{
cout << "Creating a small database..." << endl;
OrbDatabase db(mpVocabulary, false, 0); // false = do not use direct index
// (so ignore the last param)
// The direct index is useful if we want to retrieve the features that
// belong to some vocabulary node.
// db creates a copy of the vocabulary, we may get rid of "voc" now
// add images to the database
for(int i = 0; i < NIMAGES; i++)
{
db.add(features[i]);
}
cout << "... done!" << endl;
cout << "Database information: " << endl << db << endl;
// and query the database
cout << "Querying the database: " << endl;
QueryResults ret;
for(int i = 0; i < NIMAGES; i++)
{
db.query(features[i], ret, 4);
// ret[0] is always the same image in this case, because we added it to the
// database. ret[1] is the second best match.
cout << "Searching for Image " << i << ". " << ret << endl;
}
cout << endl;
// we can save the database. The created file includes the vocabulary
// and the entries added
cout << "Saving database..." << endl;
db.save("small_db.yml.gz");
cout << "... done!" << endl;
// once saved, we can load it again
cout << "Retrieving database once again..." << endl;
Surf64Database db2("small_db.yml.gz");
cout << "... done! This is: " << endl << db2 << endl;
}
// ----------------------------------------------------------------------------
|
dc9ba7f896994e72e150486c4acd32fb57b05360 | 3a342688dc086a8d16317943b6766485d28e2bc4 | /emic/mega/mega.ino | 8738708639929828eb194eebf77bfe1e6e746abb | [] | no_license | fmbfla/Arduino | 18fa50214b895a3a1a07570e89005e35a89f61da | 22c1b025d8530660ac1b20942c8c98b08b5d0c9c | refs/heads/master | 2021-01-10T18:25:03.955216 | 2014-12-14T04:08:43 | 2014-12-14T04:08:43 | 27,907,587 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 10,646 | ino | mega.ino |
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <SoftwareSerial.h>
#include <Wire.h>
#include "RTClib.h"
#include <Adafruit_BMP085.h>
#include <DHT.h>
#define DHTPIN A1 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define rxPin 50 // Serial input (connects to Emic 2 SOUT)
#define txPin 51 // Serial output (connects to Emic 2 SIN)
DHT dht(DHTPIN, DHTTYPE);
SoftwareSerial emicSerial = SoftwareSerial(rxPin, txPin);
long randNumber; //Random number used for random voice picker
//int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
// emic will say the month
char* Month[] = {
"null", "January,", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
// emic will say the day
// Sunday is 0 from the now.dayOfWeek() call of the RTC
char* weekDays[] = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
//emic will say the numerical version of the calander day in human standard slang.
// there is no "0" day so I just put the word null in, the sketch will read the RTC "Library"(RTC SOFT) and say the correct numerical calender day
char* Day[] = {
"null", "First", "Second", "Third","Forth", "Fifth", "Sixth", "Seventh","Eighth", "Nineth", "Tenth", "Eleventh", "Twelfth","Thirteenth","Fourteenth","fifthteenth","Sixteenth","Seventeenth","EightTeenth","Nine Teenth","Twenty eth","Twenty first","Twenty Second","Twenty third","Twenty Forth","Twenty Fifth","Twenty Sixth","Twenty Seventh","Twenty Eighth","Twenty Ninth"," Thirty eth","Thirty First"};
//Speaking volume
char* loudest = ("V18\n");
char* loud = ("V10\n");
char* normal = ("V0\n");
char* quiet = ("V-10\n");
//Speaking speed
char* fastest = ("W200\n");
char* fast = ("W175\n");
char* medium = ("W150\n");
char* slow = ("W100\n");
/*
// below is for voice reference
0: Perfect Paul (Paulo)
1: Huge Harry (Francisco)
2: Beautiful Betty
3: Uppity Ursula
4: Doctor Dennis (Enrique)
5: Kit the Kid
6: Frail Frank
7: Rough Rita
8: Whispering Wendy (Beatriz)
*/
//Speaking voice
char* Paul = ("N0\n");//Voice 0 - 8
char* Harry = ("N1\n");//Voice 0 - 8
char* Betty = ("N2\n");//Voice 0 - 8
char* Ursula = ("N3\n");//Voice 0 - 8
char* Dennis = ("N4\n");//Voice 0 - 8
char* Kit = ("N5\n");//Voice 0 - 8
char* Frank = ("N6\n");//Voice 0 - 8
char* Rita = ("N7\n");//Voice 0 - 8
char* Wendy = ("N8\n");//Voice 0 - 8
//Random Speaking voice's
char* voice[]={
"N0\n","N1\n","N2\n","N3\n","N4\n","N5\n","N6\n","N7\n","N8\n"};
Adafruit_BMP085 bmp;
RTC_DS1307 rtc;
void setup () {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
Serial.begin(9600);
Serial.println("Arduino MEGA 2560 / EMIC test");
emicSerial.begin(9600);
dht.begin();
bmp.begin();
rtc.begin();
Serial.println("rtc sensor Started");
//rtc.adjust(DateTime(__DATE__, __TIME__));
Serial.println("End of setup function");
}
void loop () {
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float hi = dht.computeHeatIndex(f, h);
Serial.println();
DateTime now = rtc.now();
if ((now.minute()==15) && (now.second() < 10 )){
date();
Time();
}
if ((now.minute()==30) && (now.second() < 10 )){
date();
Time();
}
if ((now.minute()==45) && (now.second() < 10 )){
date();
Time();
}
if ((now.minute()==59) && (now.second() > 55 )){
date();
Time();
}
Serial.print("Time: ");
if(now.hour() < 10){ // Zero padding if value less than 10 ie."09" instead of "9"
Serial.print(" ");
Serial.print((now.hour()> 12) ? now.hour() - 12 : ((now.hour() == 0) ? 12 : now.hour()), DEC); // Conversion to AM/PM
}
else{
Serial.print((now.hour() > 12) ? now.hour() - 12 : ((now.hour() == 0) ? 12 : now.hour()), DEC); // Conversion to AM/PM
}
Serial.print(':');
if(now.minute() < 10){ // Zero padding if value less than 10 ie."09" instead of "9"
Serial.print("0");
Serial.print(now.minute(), DEC);
}
else{
Serial.print(now.minute(), DEC);
}
Serial.print(':');
if(now.second() < 10){ // Zero padding if value less than 10 ie."09" instead of "9"
Serial.print("0");
Serial.print(now.second(), DEC);
}
else{
Serial.print(now.second(), DEC);
}
if(now.hour() < 12){ // Adding the AM/PM sufffix
Serial.println(" AM");
}
else{
Serial.println(" PM");
}
Serial.println();
//Serial.print("Temperature: \t");
//Serial.print(t,1);
//Serial.println(" *C ");
Serial.print("with the currentTemperature at ");
Serial.print(f,1);
Serial.println(" degrees fahrenheit ");
if (hi>t){
Serial.print("and will feel ");
Serial.print(hi-f,1);
Serial.print(" degrees hotter than the posted temperature");
Serial.print(" with a measured Heat Index of, ");
Serial.print(hi,1);
Serial.println(" fahrenheit");
}
Serial.print("The Humidity is at ");
Serial.print(h,1);
Serial.print(" % ");
Serial.print(" The Barometric Pressure is ");
Serial.print(bmp.readPressure()* 0.0002953,1);
Serial.println(" inHg");
/*
Serial.print("Altitude = \t\t");
Serial.print(bmp.readAltitude(102025)*3.28084);
Serial.println(" feet");
Serial.print("Pressure at sealevel =\t");
Serial.print(bmp.readSealevelPressure()* 0.0002953);
Serial.println(" inHg");
Serial.println();
*/
delay(3000);
}
void date(){
DateTime now = rtc.now();
emicSerial.print('\n');//tell emic your done sending text
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
delay(10); // Short delay
emicSerial.flush();
emicSerial.print(Harry);//Voice 0 - 8
emicSerial.print(fast);
emicSerial.print('S'); //tell emic your ready to send text
emicSerial.print("Todays Date IS, ");
emicSerial.print(now.dayOfWeek()[weekDays]);
emicSerial.print(',');
emicSerial.print(now.month()[Month]);
emicSerial.print(',');
emicSerial.print(now.day()[Day]);
emicSerial.print('\n');//tell emic your done sending text
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
delay(10); // Short delay
emicSerial.flush();
}
void Time(){
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float hi = dht.computeHeatIndex(f, h);
DateTime now = rtc.now();
emicSerial.print('\n');//tell emic your done sending text
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
delay(10); // Short delay
emicSerial.flush(); // Flush the receive buffer
emicSerial.print(loudest);
emicSerial.print(fast); //Speed 0 - 200 = fastest
emicSerial.print(Betty);//Voice 0 - 8
emicSerial.print('S'); //tell emic your ready to send text
emicSerial.print(" The Current Time is.");
if(now.hour() < 10){ // Zero padding if value less than 10 ie."09" instead of "9"
emicSerial.print((now.hour() > 12) ? now.hour() - 12 : ((now.hour() == 0) ? 12 : now.hour()), DEC); // Conversion to AM/PM
emicSerial.print(":");
}
else{
emicSerial.print((now.hour() > 12) ? now.hour() - 12 : ((now.hour() == 0) ? 12 : now.hour()), DEC); // Conversion to AM/PM
emicSerial.print(":");
}
if(now.minute()<=1){ // if minutes are less than 10
emicSerial.print("oh-Clock."); // Put an the letters "oh" here so that the emic say's three-oh-five PM/AM. like we would say "3:05 PM/AM" and not "Three zero five AM/PM".
}
else if((now.minute()>=1)&&(now.minute()<=9)) { // if minutes are less than 10
emicSerial.print("oh,"); // Put an the letters "oh" here so that the emic say's three-oh-five PM/AM. like we would say "3:05 PM/AM" and not "Three zero five AM/PM".
emicSerial.print(now.minute());
}
else{
emicSerial.print(now.minute()); //emic will say the minutes as the are read
}
if(now.hour() < 12){ // Adding the AM/PM sufffix
emicSerial.print(" AM."); // ie; if less than 12, say AM
}
else{
emicSerial.print(" PM.");//If more than 12, then say PM
}
//Serial.print("Temperature: \t");
//Serial.print(t,1);
//Serial.println(" *C ");
emicSerial.print("with the current Temperature at, ");
emicSerial.print(f,1);
emicSerial.print("degrees fare in height, ");
if (hi>t){
emicSerial.print("and will feel, ");
emicSerial.print(hi-f,1);
emicSerial.print(" degrees hotter than the posted temperature, ");
emicSerial.print(" with a measured Heat Index of, ");
emicSerial.print(hi,1);
emicSerial.print(" degrees fare in height, ");
}
emicSerial.print("The Humidity is at, ");
emicSerial.print(h,1);
emicSerial.print(" % ");
emicSerial.print(" and the Barometric Pressure is, ");
emicSerial.print(bmp.readPressure()* 0.0002953,1);
emicSerial.print(" Inches of mercury");
emicSerial.print('\n');//tell emic your done sending text
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
delay(10); // Short delay
emicSerial.flush();
delay(5000);
}
void alarm(){
emicSerial.print('\n');//tell emic your done sending text
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
delay(10); // Short delay
emicSerial.flush(); // Flush the receive buffer
// Speaking Volume (-48 - 18) 18 = highest
emicSerial.print(loudest);
emicSerial.print(fastest); //Speed 0 - 200 = fastest
// Uncoment below to pick and hold a single voice, just type the name from the boiler plate you want to use (case sensitive)
emicSerial.print(Paul);//Voice 0 - 8
emicSerial.print('S'); //tell emic your ready to send text
emicSerial.print("It's time to WAKE UP.");
emicSerial.print('\n');//tell emic your done sending text
while (emicSerial.read() != ':'); // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
delay(10); // Short delay
emicSerial.flush();
delay(3000);
}
|
5ce561fdeb9c27c1abcce07e7bd983cd8ae7c61c | 4a92c7117306482e7d977ca06c32cc896bcaf605 | /src/findpos.cc | bcc30ae256e389efb5ae1759c99879ea6495e118 | [] | no_license | trmrsh/cpp-ultracam | faaf8822916e783ee80c52c1eed9c2f013fdf5df | df5550424fc68f47350e0f7d5696dc2d765e5f17 | refs/heads/master | 2021-01-17T13:07:14.325517 | 2019-01-10T00:00:36 | 2019-01-10T00:00:36 | 11,367,193 | 1 | 1 | null | 2015-12-10T15:51:13 | 2013-07-12T11:26:18 | C++ | UTF-8 | C++ | false | false | 6,716 | cc | findpos.cc | #include <cstdlib>
#include <string>
#include "trm/subs.h"
#include "trm/constants.h"
#include "trm/ultracam.h"
void sub_back(float* y, int i1, int i2);
/*! \file
\brief Defines the findpos function
*/
/**
* findpos is a workhorse routine for measuring target positions
* as required when defining aperture positions.
*
* findpos works as follows: given an initial starting position
* and search half-width, it collapses a box around the initial position
* and then measures the centroid in x and y by cross-correlating with
* a gaussian profile. It then refines this by performing a weighted collapse
* with weights given by the gaussian width and centred upon the position
* after the first part. The idea is that the first pass is relatively insensitive
* to where the target is within the box, but can be affected by the presence of
* other nearby stars, whereas the second pass needs a good initial position, but
* is not much affected by other stars.
*
* If the routine gets stuck it will throw an Ultracam_Error.
*
* If you compile with -DPLOT then extra plotting section are enabled which can be useful
* for checking on troublesome cases.
*
* \param dat 2D array such that dat[iy][ix] gives the value of (ix,iy).
* \param var 2D array such that var[iy][ix] gives the variance of (ix,iy).
* \param nx X dimension of array
* \param ny Y dimension of array
* \param fwhm_x FWHM to use in X
* \param fwhm_y FWHM to use in Y
* \param hwidth_x Half-width to use in X. Collapse is over a region
* +/- hwidth_x around the pixel nearest to the start position.
* \param hwidth_y Half-width to use in Y.
* \param xstart Start position in X. Used to define the initial search region.
* \param ystart Start position in Y.Used to define the initial search region.
* \param bias if true, the search will be made starting from the initial position defined by
* xstart & ystart. If false, the initial search will start from the maxima of the 1D correlations.
* bias=true is less likely to get confused by cosmic rays and other targets, bias=false is better
* at coping with large shifts and bad guiding.
* \param xpos Final X position. The centre of pixel 0,0 has position 0,0.
* \param ypos Final Y position.
* \param ex uncertainty in final X position. For this to be right, the data must be bias-subtracted.
* \param ey uncertainty in final Y position. For this to be right, the data must be bias-subtracted.
*/
void Ultracam::findpos(internal_data **dat, internal_data **var, int nx, int ny, float fwhm_x, float fwhm_y,
int hwidth_x, int hwidth_y, float xstart, float ystart, bool bias,
double& xpos, double &ypos, float& ex, float& ey){
try {
// Check start position
if(xstart <= -0.5 || xstart >= nx-0.5 || ystart <= -0.5 || ystart >= ny-0.5)
throw Ultracam_Error("findpos: initial posiion outside array boundary");
// Define region to examine
int xlo = int(xstart+0.5) - hwidth_x;
int xhi = int(xstart+0.5) + hwidth_x;
int ylo = int(ystart+0.5) - hwidth_y;
int yhi = int(ystart+0.5) + hwidth_y;
// Make sure its in range
xlo = xlo < 0 ? 0 : xlo;
xhi = xhi < nx ? xhi : nx-1;
ylo = ylo < 0 ? 0 : ylo;
yhi = yhi < ny ? yhi : ny-1;
// Collapse in X
float xprof[nx], vxprof[nx];
for(int ix=xlo; ix<=xhi; ix++)
xprof[ix] = vxprof[ix] = 0.;
for(int iy=ylo; iy<=yhi; iy++){
for(int ix=xlo; ix<=xhi; ix++){
xprof[ix] += dat[iy][ix];
vxprof[ix] += var[iy][ix];
}
}
// Search for maximum
int xmax = xlo+1;
float fmax = xprof[xmax];
if(!bias){
for(int ix=xlo+1; ix<=xhi-1; ix++){
if(xprof[ix] > fmax){
fmax = xprof[ix];
xmax = ix;
}
}
xstart = float(xmax);
}
// Measure first X position
sub_back(xprof, xlo, xhi);
Subs::centroid(xprof,vxprof,xlo,xhi,fwhm_x,xstart,true,xpos,ex);
// Collapse in Y
float yprof[ny], vyprof[ny];
for(int iy=ylo; iy<=yhi; iy++)
vyprof[iy] = yprof[iy] = 0.;
for(int iy=ylo; iy<=yhi; iy++){
for(int ix=xlo; ix<=xhi; ix++){
yprof[iy] += dat[iy][ix];
vyprof[iy] += var[iy][ix];
}
}
// Search for maximum
int ymax = ylo+1;
fmax = yprof[ymax];
if(!bias){
for(int iy=ylo+1; iy<=yhi-1; iy++){
if(yprof[iy] > fmax){
fmax = yprof[iy];
ymax = iy;
}
}
ystart = float(ymax);
}
// Measure first Y position
sub_back(yprof, ylo, yhi);
Subs::centroid(yprof,vyprof,ylo,yhi,fwhm_y,ystart,true,ypos,ey);
// Redefine region to examine
xlo = int(xpos+0.5) - hwidth_x;
xhi = int(xpos+0.5) + hwidth_x;
ylo = int(ypos+0.5) - hwidth_y;
yhi = int(ypos+0.5) + hwidth_y;
// Make sure its in range
xlo = xlo < 0 ? 0 : xlo;
xhi = xhi < nx ? xhi : nx-1;
ylo = ylo < 0 ? 0 : ylo;
yhi = yhi < ny ? yhi : ny-1;
// Weighted collapse in X
float wgt;
float norm = 0.;
for(int ix=xlo; ix<=xhi; ix++){
xprof[ix] = 0.;
vxprof[ix] = 0.;
}
for(int iy=ylo; iy<=yhi; iy++){
wgt = exp(-Subs::sqr((float(iy)-ypos)/(fwhm_y/Constants::EFAC))/2.);
norm += wgt;
for(int ix=xlo; ix<=xhi; ix++){
xprof[ix] += wgt*dat[iy][ix];
vxprof[ix] += wgt*wgt*var[iy][ix];
}
}
xstart = xpos;
// Measure weighted X position
sub_back(xprof, xlo, xhi);
Subs::centroid(xprof,vxprof,xlo,xhi,fwhm_x,xstart,true,xpos,ex);
// Weighted collapse in Y
for(int iy=ylo; iy<=yhi; iy++){
yprof[iy] = 0.;
vyprof[iy] = 0.;
}
norm = 0.;
for(int ix=xlo; ix<=xhi; ix++){
wgt = exp(-Subs::sqr((float(ix)-xpos)/(fwhm_x/Constants::EFAC))/2.);
norm += wgt;
for(int iy=ylo; iy<=yhi; iy++){
yprof[iy] += wgt*dat[iy][ix];
vyprof[iy] += wgt*wgt*var[iy][ix];
}
}
// Measure weighted Y position
ystart = ypos;
sub_back(yprof, ylo, yhi);
Subs::centroid(yprof,vyprof,ylo,yhi,fwhm_y,ystart,true,ypos,ey);
}
catch(const Subs::Subs_Error& err){
throw Ultracam_Error("Ultracam::findpos: failed to measure position. Re-thrown this error\n" + err);
}
}
// Subtracts median as an estimate of the background
// y is the array, i1 and i2 are the first and last elements
// to consider. This is to help the centroiding which may otherwise
// be affected by edge effects.
void sub_back(float* y, int i1, int i2){
// make a temporary copy of the input data
float temp[i2-i1+1];
for(int i=i1,j=0; i<=i2; i++,j++) temp[j] = y[i];
// determine the median
float back = Subs::select(temp,i2-i1+1,(i2-i1+1)/2);
// subtract
for(int i=i1; i<=i2; i++) y[i] -= back;
}
|
53392c2d48220e8be24595d9d06f1b75b82c18c4 | 2d5c007accefee5c9c59f3372d938b34d798e970 | /app/main.cpp | 4a4a63e9ec8384a3c248ceda7081dd7e09c31ac8 | [] | no_license | KDE/latte-dock | c638d8efa528424611f30c5eac72353c9cc0b448 | 853a7735a425ec6bb0379da1a8b4fbc13a7992ad | refs/heads/master | 2023-08-31T19:13:48.228397 | 2023-08-28T02:17:27 | 2023-08-28T02:17:27 | 101,990,564 | 1,680 | 155 | null | 2022-12-28T13:38:35 | 2017-08-31T10:43:37 | C++ | UTF-8 | C++ | false | false | 24,054 | cpp | main.cpp | /*
SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
// local
#include "config-latte.h"
#include "apptypes.h"
#include "lattecorona.h"
#include "layouts/importer.h"
#include "templates/templatesmanager.h"
// C++
#include <memory>
#include <csignal>
// Qt
#include <QApplication>
#include <QDebug>
#include <QQuickWindow>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDBusConnection>
#include <QDBusInterface>
#include <QDir>
#include <QFile>
#include <QLockFile>
#include <QSessionManager>
#include <QSharedMemory>
#include <QTextStream>
// KDE
#include <KCrash>
#include <KLocalizedString>
#include <KAboutData>
#include <KDBusService>
#include <KQuickAddons/QtQuickSettings>
//! COLORS
#define CNORMAL "\e[0m"
#define CIGREEN "\e[1;32m"
#define CGREEN "\e[0;32m"
#define CICYAN "\e[1;36m"
#define CCYAN "\e[0;36m"
#define CIRED "\e[1;31m"
#define CRED "\e[0;31m"
inline void configureAboutData();
inline void detectPlatform(int argc, char **argv);
inline void filterDebugMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg);
QString filterDebugMessageText;
QString filterDebugLogFile;
int main(int argc, char **argv)
{
//Plasma scales itself to font DPI
//on X, where we don't have compositor scaling, this generally works fine.
//also there are bugs on older Qt, especially when it comes to fractional scaling
//there's advantages to disabling, and (other than small context menu icons) few advantages in enabling
//On wayland, it's different. Everything is simpler as all co-ordinates are in the same co-ordinate system
//we don't have fractional scaling on the client so don't hit most the remaining bugs and
//even if we don't use Qt scaling the compositor will try to scale us anyway so we have no choice
if (!qEnvironmentVariableIsSet("PLASMA_USE_QT_SCALING")) {
qunsetenv("QT_DEVICE_PIXEL_RATIO");
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
} else {
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
}
QQuickWindow::setDefaultAlphaBuffer(true);
qputenv("QT_WAYLAND_DISABLE_FIXED_POSITIONS", {});
const bool qpaVariable = qEnvironmentVariableIsSet("QT_QPA_PLATFORM");
detectPlatform(argc, argv);
QApplication app(argc, argv);
qunsetenv("QT_WAYLAND_DISABLE_FIXED_POSITIONS");
if (!qpaVariable) {
// don't leak the env variable to processes we start
qunsetenv("QT_QPA_PLATFORM");
}
KQuickAddons::QtQuickSettings::init();
KLocalizedString::setApplicationDomain("latte-dock");
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("latte-dock")));
//protect from closing app when changing to "alternative session" and back
app.setQuitOnLastWindowClosed(false);
configureAboutData();
QCommandLineParser parser;
parser.addHelpOption();
parser.addVersionOption();
parser.addOptions({
{{"r", "replace"}, i18nc("command line", "Replace the current Latte instance.")}
, {{"d", "debug"}, i18nc("command line", "Show the debugging messages on stdout.")}
, {{"cc", "clear-cache"}, i18nc("command line", "Clear qml cache. It can be useful after system upgrades.")}
, {"enable-autostart", i18nc("command line", "Enable autostart for this application")}
, {"disable-autostart", i18nc("command line", "Disable autostart for this application")}
, {"default-layout", i18nc("command line", "Import and load default layout on startup.")}
, {"available-layouts", i18nc("command line", "Print available layouts")}
, {"available-dock-templates", i18nc("command line", "Print available dock templates")}
, {"available-layout-templates", i18nc("command line", "Print available layout templates")}
, {"layout", i18nc("command line", "Load specific layout on startup."), i18nc("command line: load", "layout_name")}
, {"import-layout", i18nc("command line", "Import and load a layout."), i18nc("command line: import", "absolute_filepath")}
, {"suggested-layout-name", i18nc("command line", "Suggested layout name when importing a layout file"), i18nc("command line: import", "suggested_name")}
, {"import-full", i18nc("command line", "Import full configuration."), i18nc("command line: import", "file_name")}
, {"add-dock", i18nc("command line", "Add Dock/Panel"), i18nc("command line: add", "template_name")}
, {"single", i18nc("command line", "Single layout memory mode. Only one layout is active at any case.")}
, {"multiple", i18nc("command line", "Multiple layouts memory mode. Multiple layouts can be active at any time based on Activities running.")}
});
//! START: Hidden options for Developer and Debugging usage
QCommandLineOption graphicsOption(QStringList() << QStringLiteral("graphics"));
graphicsOption.setDescription(QStringLiteral("Draw boxes around of the applets."));
graphicsOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(graphicsOption);
QCommandLineOption withWindowOption(QStringList() << QStringLiteral("with-window"));
withWindowOption.setDescription(QStringLiteral("Open a window with much debug information"));
withWindowOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(withWindowOption);
QCommandLineOption maskOption(QStringList() << QStringLiteral("mask"));
maskOption.setDescription(QStringLiteral("Show messages of debugging for the mask (Only useful to devs)."));
maskOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(maskOption);
QCommandLineOption timersOption(QStringList() << QStringLiteral("timers"));
timersOption.setDescription(QStringLiteral("Show messages for debugging the timers (Only useful to devs)."));
timersOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(timersOption);
QCommandLineOption spacersOption(QStringList() << QStringLiteral("spacers"));
spacersOption.setDescription(QStringLiteral("Show visual indicators for debugging spacers (Only useful to devs)."));
spacersOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(spacersOption);
QCommandLineOption overloadedIconsOption(QStringList() << QStringLiteral("overloaded-icons"));
overloadedIconsOption.setDescription(QStringLiteral("Show visual indicators for debugging overloaded applets icons (Only useful to devs)."));
overloadedIconsOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(overloadedIconsOption);
QCommandLineOption edgesOption(QStringList() << QStringLiteral("kwinedges"));
edgesOption.setDescription(QStringLiteral("Show visual window indicators for hidden screen edge windows."));
edgesOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(edgesOption);
QCommandLineOption localGeometryOption(QStringList() << QStringLiteral("localgeometry"));
localGeometryOption.setDescription(QStringLiteral("Show visual window indicators for calculated local geometry."));
localGeometryOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(localGeometryOption);
QCommandLineOption layouterOption(QStringList() << QStringLiteral("layouter"));
layouterOption.setDescription(QStringLiteral("Show visual debug tags for items sizes."));
layouterOption.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(layouterOption);
QCommandLineOption filterDebugTextOption(QStringList() << QStringLiteral("debug-text"));
filterDebugTextOption.setDescription(QStringLiteral("Show only debug messages that contain specific text."));
filterDebugTextOption.setFlags(QCommandLineOption::HiddenFromHelp);
filterDebugTextOption.setValueName(i18nc("command line: debug-text", "filter_debug_text"));
parser.addOption(filterDebugTextOption);
QCommandLineOption filterDebugInputMask(QStringList() << QStringLiteral("input"));
filterDebugInputMask.setDescription(QStringLiteral("Show visual window indicators for calculated input mask."));
filterDebugInputMask.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(filterDebugInputMask);
QCommandLineOption filterDebugEventSinkMask(QStringList() << QStringLiteral("events-sink"));
filterDebugEventSinkMask.setDescription(QStringLiteral("Show visual indicators for areas of EventsSink."));
filterDebugEventSinkMask.setFlags(QCommandLineOption::HiddenFromHelp);
parser.addOption(filterDebugEventSinkMask);
QCommandLineOption filterDebugLogCmd(QStringList() << QStringLiteral("log-file"));
filterDebugLogCmd.setDescription(QStringLiteral("Forward debug output in a log text file."));
filterDebugLogCmd.setFlags(QCommandLineOption::HiddenFromHelp);
filterDebugLogCmd.setValueName(i18nc("command line: log-filepath", "filter_log_filepath"));
parser.addOption(filterDebugLogCmd);
//! END: Hidden options
parser.process(app);
if (parser.isSet(QStringLiteral("enable-autostart"))) {
Latte::Layouts::Importer::enableAutostart();
}
if (parser.isSet(QStringLiteral("disable-autostart"))) {
Latte::Layouts::Importer::disableAutostart();
qGuiApp->exit();
return 0;
}
//! print available-layouts
if (parser.isSet(QStringLiteral("available-layouts"))) {
QStringList layouts = Latte::Layouts::Importer::availableLayouts();
if (layouts.count() > 0) {
qInfo() << i18n("Available layouts that can be used to start Latte:");
for (const auto &layout : layouts) {
qInfo() << " " << layout;
}
} else {
qInfo() << i18n("There are no available layouts, during startup Default will be used.");
}
qGuiApp->exit();
return 0;
}
//! print available-layout-templates
if (parser.isSet(QStringLiteral("available-layout-templates"))) {
QStringList templates = Latte::Layouts::Importer::availableLayoutTemplates();
if (templates.count() > 0) {
qInfo() << i18n("Available layout templates found in your system:");
for (const auto &templatename : templates) {
qInfo() << " " << templatename;
}
} else {
qInfo() << i18n("There are no available layout templates in your system.");
}
qGuiApp->exit();
return 0;
}
//! print available-dock-templates
if (parser.isSet(QStringLiteral("available-dock-templates"))) {
QStringList templates = Latte::Layouts::Importer::availableViewTemplates();
if (templates.count() > 0) {
qInfo() << i18n("Available dock templates found in your system:");
for (const auto &templatename : templates) {
qInfo() << " " << templatename;
}
} else {
qInfo() << i18n("There are no available dock templates in your system.");
}
qGuiApp->exit();
return 0;
}
//! disable restore from session management
//! based on spectacle solution at:
//! - https://bugs.kde.org/show_bug.cgi?id=430411
//! - https://invent.kde.org/graphics/spectacle/-/commit/8db27170d63f8a4aaff09615e51e3cc0fb115c4d
QGuiApplication::setFallbackSessionManagementEnabled(false);
auto disableSessionManagement = [](QSessionManager &sm) {
sm.setRestartHint(QSessionManager::RestartNever);
};
QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement);
QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement);
//! choose layout for startup
bool defaultLayoutOnStartup = false;
int memoryUsage = -1;
QString layoutNameOnStartup = "";
QString addViewTemplateNameOnStartup = "";
//! --default-layout option
if (parser.isSet(QStringLiteral("default-layout"))) {
defaultLayoutOnStartup = true;
} else if (parser.isSet(QStringLiteral("layout"))) {
layoutNameOnStartup = parser.value(QStringLiteral("layout"));
if (!Latte::Layouts::Importer::layoutExists(layoutNameOnStartup)) {
qInfo() << i18nc("layout missing", "This layout doesn't exist in the system.");
qGuiApp->exit();
return 0;
}
}
//! --replace option
QString username = qgetenv("USER");
if (username.isEmpty())
username = qgetenv("USERNAME");
QLockFile lockFile {QDir::tempPath() + "/latte-dock." + username + ".lock"};
int timeout {100};
if (parser.isSet(QStringLiteral("replace")) || parser.isSet(QStringLiteral("import-full"))) {
qint64 pid{ -1};
if (lockFile.getLockInfo(&pid, nullptr, nullptr)) {
kill(static_cast<pid_t>(pid), SIGINT);
timeout = -1;
}
}
if (!lockFile.tryLock(timeout)) {
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
bool addview{parser.isSet(QStringLiteral("add-dock"))};
bool importlayout{parser.isSet(QStringLiteral("import-layout"))};
bool enableautostart{parser.isSet(QStringLiteral("enable-autostart"))};
bool disableautostart{parser.isSet(QStringLiteral("disable-autostart"))};
bool validaction{false};
if (iface.isValid()) {
if (addview) {
validaction = true;
iface.call("addView", (uint)0, parser.value(QStringLiteral("add-dock")));
qGuiApp->exit();
return 0;
} else if (importlayout) {
validaction = true;
QString suggestedname = parser.isSet(QStringLiteral("suggested-layout-name")) ? parser.value(QStringLiteral("suggested-layout-name")) : QString();
iface.call("importLayoutFile", parser.value(QStringLiteral("import-layout")), suggestedname);
qGuiApp->exit();
return 0;
} else if (enableautostart || disableautostart){
validaction = true;
} else {
// LayoutPage = 0
iface.call("showSettingsWindow", 0);
}
}
if (!validaction) {
qInfo() << i18n("An instance is already running!, use --replace to restart Latte");
}
qGuiApp->exit();
return 0;
}
//! clear-cache option
if (parser.isSet(QStringLiteral("clear-cache"))) {
QDir cacheDir(QDir::homePath() + "/.cache/lattedock/qmlcache");
if (cacheDir.exists()) {
cacheDir.removeRecursively();
qDebug() << "Cache directory found and cleared...";
}
}
//! import-full option
if (parser.isSet(QStringLiteral("import-full"))) {
bool imported = Latte::Layouts::Importer::importHelper(parser.value(QStringLiteral("import-full")));
if (!imported) {
qInfo() << i18n("The configuration cannot be imported");
qGuiApp->exit();
return 0;
}
}
//! import-layout option
if (parser.isSet(QStringLiteral("import-layout"))) {
QString suggestedname = parser.isSet(QStringLiteral("suggested-layout-name")) ? parser.value(QStringLiteral("suggested-layout-name")) : QString();
QString importedLayout = Latte::Layouts::Importer::importLayoutHelper(parser.value(QStringLiteral("import-layout")), suggestedname);
if (importedLayout.isEmpty()) {
qInfo() << i18n("The layout cannot be imported");
qGuiApp->exit();
return 0;
} else {
layoutNameOnStartup = importedLayout;
}
}
//! memory usage option
if (parser.isSet(QStringLiteral("multiple"))) {
memoryUsage = (int)(Latte::MemoryUsage::MultipleLayouts);
} else if (parser.isSet(QStringLiteral("single"))) {
memoryUsage = (int)(Latte::MemoryUsage::SingleLayout);
}
//! add-dock usage option
if (parser.isSet(QStringLiteral("add-dock"))) {
QString viewTemplateName = parser.value(QStringLiteral("add-dock"));
QStringList viewTemplates = Latte::Layouts::Importer::availableViewTemplates();
if (viewTemplates.contains(viewTemplateName)) {
if (layoutNameOnStartup.isEmpty()) {
//! Clean layout template is applied and proper name is used
QString emptytemplatepath = Latte::Layouts::Importer::layoutTemplateSystemFilePath(Latte::Templates::EMPTYLAYOUTTEMPLATENAME);
QString suggestedname = parser.isSet(QStringLiteral("suggested-layout-name")) ? parser.value(QStringLiteral("suggested-layout-name")) : viewTemplateName;
QString importedLayout = Latte::Layouts::Importer::importLayoutHelper(emptytemplatepath, suggestedname);
if (importedLayout.isEmpty()) {
qInfo() << i18n("The layout cannot be imported");
qGuiApp->exit();
return 0;
} else {
layoutNameOnStartup = importedLayout;
}
}
addViewTemplateNameOnStartup = viewTemplateName;
}
}
//! text filter for debug messages
if (parser.isSet(QStringLiteral("debug-text"))) {
filterDebugMessageText = parser.value(QStringLiteral("debug-text"));
}
//! log file for debug output
if (parser.isSet(QStringLiteral("log-file")) && !parser.value(QStringLiteral("log-file")).isEmpty()) {
filterDebugLogFile = parser.value(QStringLiteral("log-file"));
}
//! debug/mask options
if (parser.isSet(QStringLiteral("debug")) || parser.isSet(QStringLiteral("mask")) || parser.isSet(QStringLiteral("debug-text"))) {
qInstallMessageHandler(filterDebugMessageOutput);
} else {
const auto noMessageOutput = [](QtMsgType, const QMessageLogContext &, const QString &) {};
qInstallMessageHandler(noMessageOutput);
}
auto signal_handler = [](int) {
qGuiApp->exit();
};
std::signal(SIGKILL, signal_handler);
std::signal(SIGINT, signal_handler);
KCrash::setDrKonqiEnabled(true);
KCrash::setFlags(KCrash::AutoRestart | KCrash::AlwaysDirectly);
Latte::Corona corona(defaultLayoutOnStartup, layoutNameOnStartup, addViewTemplateNameOnStartup, memoryUsage);
KDBusService service(KDBusService::Unique);
return app.exec();
}
inline void filterDebugMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
if (msg.endsWith("QML Binding: Not restoring previous value because restoreMode has not been set.This behavior is deprecated.In Qt < 6.0 the default is Binding.RestoreBinding.In Qt >= 6.0 the default is Binding.RestoreBindingOrValue.")
|| msg.endsWith("QML Binding: Not restoring previous value because restoreMode has not been set.\nThis behavior is deprecated.\nYou have to import QtQml 2.15 after any QtQuick imports and set\nthe restoreMode of the binding to fix this warning.\nIn Qt < 6.0 the default is Binding.RestoreBinding.\nIn Qt >= 6.0 the default is Binding.RestoreBindingOrValue.\n")
|| msg.endsWith("QML Binding: Not restoring previous value because restoreMode has not been set.\nThis behavior is deprecated.\nYou have to import QtQml 2.15 after any QtQuick imports and set\nthe restoreMode of the binding to fix this warning.\nIn Qt < 6.0 the default is Binding.RestoreBinding.\nIn Qt >= 6.0 the default is Binding.RestoreBindingOrValue.")
|| msg.endsWith("QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... }")) {
//! block warnings because they will be needed only after qt6.0 support. Currently Binding.restoreMode can not be supported because
//! qt5.9 is the minimum supported version.
return;
}
if (!filterDebugMessageText.isEmpty() && !msg.contains(filterDebugMessageText)) {
return;
}
const char *function = context.function ? context.function : "";
QString typeStr;
switch (type) {
case QtDebugMsg:
typeStr = "Debug";
break;
case QtInfoMsg:
typeStr = "Info";
break;
case QtWarningMsg:
typeStr = "Warning" ;
break;
case QtCriticalMsg:
typeStr = "Critical";
break;
case QtFatalMsg:
typeStr = "Fatal";
break;
};
const char *TypeColor;
if (type == QtInfoMsg || type == QtWarningMsg) {
TypeColor = CGREEN;
} else if (type == QtCriticalMsg || type == QtFatalMsg) {
TypeColor = CRED;
} else {
TypeColor = CIGREEN;
}
if (filterDebugLogFile.isEmpty()) {
qDebug().nospace() << TypeColor << "[" << typeStr.toStdString().c_str() << " : " << CGREEN << QTime::currentTime().toString("h:mm:ss.zz").toStdString().c_str() << TypeColor << "]" << CNORMAL
#ifndef QT_NO_DEBUG
<< CIRED << " [" << CCYAN << function << CIRED << ":" << CCYAN << context.line << CIRED << "]"
#endif
<< CICYAN << " - " << CNORMAL << msg;
} else {
QFile logfile(filterDebugLogFile);
logfile.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream logts(&logfile);
logts << "[" << typeStr.toStdString().c_str() << " : " << QTime::currentTime().toString("h:mm:ss.zz").toStdString().c_str() << "]"
<< " - " << msg << Qt::endl;
}
}
inline void configureAboutData()
{
KAboutData about(QStringLiteral("lattedock")
, QStringLiteral("Latte Dock")
, QStringLiteral(VERSION)
, i18n("Latte is a dock based on plasma frameworks that provides an elegant and "
"intuitive experience for your tasks and plasmoids. It animates its contents "
"by using parabolic zoom effect and tries to be there only when it is needed."
"\n\n\"Art in Coffee\"")
, KAboutLicense::GPL_V2
, QStringLiteral("\251 2016-2017 Michail Vourlakos, Smith AR"));
about.setHomepage(WEBSITE);
about.setProgramLogo(QIcon::fromTheme(QStringLiteral("latte-dock")));
about.setDesktopFileName(QStringLiteral("latte-dock"));
about.setProductName(QByteArray("lattedock"));
// Authors
about.addAuthor(QStringLiteral("Michail Vourlakos"), QString(), QStringLiteral("mvourlakos@gmail.com"));
about.addAuthor(QStringLiteral("Smith AR"), QString(), QStringLiteral("audoban@openmailbox.org"));
KAboutData::setApplicationData(about);
}
//! used the version provided by PW:KWorkspace
inline void detectPlatform(int argc, char **argv)
{
if (qEnvironmentVariableIsSet("QT_QPA_PLATFORM")) {
return;
}
for (int i = 0; i < argc; i++) {
if (qstrcmp(argv[i], "-platform") == 0 ||
qstrcmp(argv[i], "--platform") == 0 ||
QByteArray(argv[i]).startsWith("-platform=") ||
QByteArray(argv[i]).startsWith("--platform=")) {
return;
}
}
const QByteArray sessionType = qgetenv("XDG_SESSION_TYPE");
if (sessionType.isEmpty()) {
return;
}
if (qstrcmp(sessionType, "wayland") == 0) {
qputenv("QT_QPA_PLATFORM", "wayland");
} else if (qstrcmp(sessionType, "x11") == 0) {
qputenv("QT_QPA_PLATFORM", "xcb");
}
}
|
8b6178104a6916a35482b98caa8c9230b1ae8462 | fd2b0d55b4dd590e1ed236dc05435ca8c3cc9c3b | /geotiff.h | 20cb89a8d6cad8b91ff64bdf163b24b39ca1a1ee | [] | no_license | eglrp/CoreDll | 0f8668ffafc616bdbf373a88fa4eb75ec3fc5d4e | a5665ce2c203b507b281dd9fce99dc596f1bcd1a | refs/heads/master | 2020-04-01T12:48:23.397189 | 2017-01-21T14:57:42 | 2017-01-21T14:57:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,504 | h | geotiff.h |
#ifndef GEO_TIFF_H
#define GEO_TIFF_H
//#include "ogr_spatialref.h"
#include <vector>
#include <string>
using namespace std;
#include "exports.h"
#include "gdal_priv.h"
//#include "ogr_spatialref.h"
//#define DLL_EXPORT _declspec(dllexport)
typedef struct struct_GeoInfo
{
double left,top; //ground coordinate of top-left corner
double minlon, maxlat; //(lon,lat) of top-left corner
double dx,dy; //resolution;
int wd,ht; //dimension of image
int nband;
int zoneNumber; //zone number
int type; //data type
const char* projectRef; //
}stGeoInfo;
DLL_EXPORT int ReadGeoFile(char* filename, stGeoInfo& geoData);
//from gdalinfo.c
DLL_EXPORT int GdalInfo(char* filePath);
//print information from image using Gdal
DLL_EXPORT int PrintImageInfo(char* pszFilename);
//retrieve the geo-information from the image file
DLL_EXPORT int GetGeoInformation(const char* pszFilename, stGeoInfo& geoInfo);
//
DLL_EXPORT GDALDataType GetDataType(const char* pszFilename);
/************************* for GEOTiff ********************************/
//read the band from the file of BYTE type
DLL_EXPORT int ReadGeoFileByte(char* filePath, int bandId, unsigned char** pBuffer, int& ht, int& wd);
DLL_EXPORT int ReadGeoFileByte(char* filePath, int bandId, double ratio, unsigned char** pBuffer, int& ht, int& wd);
DLL_EXPORT int ReadGeoFileShort(char* filePath, int bandId, short** pBuffer, int& ht, int& wd);
//read the band from the file of unsigned short type
DLL_EXPORT int ReadGeoFileUShort(char* filePath, int bandId, unsigned short** pBuffer, int& ht, int& wd);
//read the band from the file of float type
DLL_EXPORT int ReadGeoFileFloat(char* filePath, int bandId, float** pBuffer, int& ht, int& wd);
//read the band from the file of int type
DLL_EXPORT int ReadGeoFileInt(char* filePath, int bandId, int** pBuffer, int& ht, int& wd);
DLL_EXPORT int ReadGeoFileUInt(char* filePath, int bandId, unsigned int** pBuffer, int& ht, int& wd);
//template funcion
DLL_EXPORT int ReadGeoFileGeneral(char* filepath, int bandId, void* pBuffer, GDALDataType nType);
//write single band buffer into the file
DLL_EXPORT int GdalWriteImageByte(char* savePath, unsigned char* pBuffer, int ht, int wd);
DLL_EXPORT int GdalWriteByte(char* savePath, unsigned char* pBuffer, int ht, int wd, stGeoInfo geoInfo);
DLL_EXPORT int GdalWriteInt(char* savePath, int* pBuffer, int ht, int wd, stGeoInfo geoInfo);
DLL_EXPORT int GdalWriteUInt(char* savePath, unsigned int* pBuffer, int ht, int wd, stGeoInfo geoInfo);
DLL_EXPORT int GdalWriteUShort(char* savePath, unsigned short* pBuffer, int ht, int wd, stGeoInfo geoInfo);
//write r,g,b chanel to the color Tiff file
DLL_EXPORT int GdalWriteImageByteColor(char* savePath, unsigned char* r, unsigned char* g, unsigned char* b, int ht, int wd);
//write r,g,b chanel to the color Tiff file with Geoinfo
DLL_EXPORT int GdalWriteImageColor(char* savePath, unsigned char* r, unsigned char* g, unsigned char* b, int ht, int wd,
stGeoInfo geoInfo);
DLL_EXPORT int GdalWriteColorImageUShort(char* savePath,
unsigned short* r, unsigned short* g, unsigned short* b, int ht, int wd,
stGeoInfo geoInfo);
//write the float buffer into the GeoTiff file
DLL_EXPORT int GdalWriteFloat(char* savePath, float* pBuffer, int ht, int wd, stGeoInfo geoInfo);
DLL_EXPORT int GdalWriteImageUShort(char* savePath, unsigned short* pBuffer, int ht, int wd);
DLL_EXPORT int GdalWriteJpgCopy(char* savePath, unsigned char* pBuffer, int ht, int wd);
DLL_EXPORT int GdalWriteFloatLL(char* savePath, float* pBuffer, int ht, int wd,
double minlon, double maxlon, double minlax, double maxlax);
//write r,g,b channels into geotiff file
DLL_EXPORT int GdalWriteFloatLL(char* savePath,
unsigned char* r, unsigned char* g, unsigned char* b,
int ht, int wd,
double minlon, double maxlon, double minlax, double maxlax);
DLL_EXPORT void GroundToLL(double gx, double gy, double& lon, double& lat, stGeoInfo geoInfo);
DLL_EXPORT void GeoImageMosaic(char** files, int nfile);
DLL_EXPORT int GeotiffMedianFilter(char* filename);
/************************* for GEOTif ********************************/
/************************* for HDF ********************************/
DLL_EXPORT void subsets2tif(const char* fileName,const char* outfile,int* pBandIndex, int pBandCount);
//read MOD03 product
DLL_EXPORT int ReadMod03(char* filePath, double** lon, double** lat, int& ht, int& wd);
DLL_EXPORT int Mod02ToTif(char* mod02File, char* mod03File, char* outDir);
DLL_EXPORT int ReadSubDataInfo(char* filePath, vector<string>& subDataSets, vector<string>& subDataDesc);
//retrieve the subdata information from the file
DLL_EXPORT int ReadSubDataInfo(char* filePath, char** subDataDesc);
DLL_EXPORT int ReadSubData(char* subDataDesc, double** pBuffer, int* ht, int* wd, int band=1);
DLL_EXPORT int ReadSubDataFloat(char* subDataDesc, float** pBuffer, int* ht, int* wd, int band=1);
DLL_EXPORT int ReadSubDataShort(char* subDataDesc, short** pBuffer, int* ht, int* wd, int band=1);
DLL_EXPORT int ReadSubDataUShort(char* subDataDesc, unsigned short** pBuffer, int* ht, int* wd, int band=1);
DLL_EXPORT int ReadSubDataBandSum(char* subDataDesc);
DLL_EXPORT int ReadSubDataCaliPara(char* subDataDesc, vector<double>& scale, vector<double>& offset);
/************************* for HDF ********************************/
#endif
|
293827e177ae3d4b5b91223377772086bc4ea951 | 01c1fb864e70b548e016e8906bf948796fb3f651 | /src/image.h | ddb0e8d708a39f1ecbd38a50b3746f2891f6d75c | [] | no_license | TenWing/RCNN-results-GUI | ca478346bea3294d79c70e54d56d7c0ed892d393 | 9c237d6ce106f262c9afd01a2c859e3bc681d2c5 | refs/heads/master | 2021-01-21T01:43:38.035928 | 2016-06-15T11:51:01 | 2016-06-15T11:51:01 | 60,786,415 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,105 | h | image.h | #ifndef IMAGE_H
#define IMAGE_H
#include <vector>
#include <string>
/**
* @brief Represents a Bounding Box around an object (rectangular)
*/
class Bbox
{
public:
/**
* @brief Builds a bounding box
* @param xmin the x coordinate of the top-left corner
* @param ymin the y coordinate of the top-left corner
* @param width the width of the bbox
* @param height the height of the bbox
*/
Bbox(double xmin, double ymin, double width, double height);
~Bbox();
/**
* @brief gets the box surrounding the object like that : xmin ymin width height
* @return a vector of float of size 4
*/
std::vector<double> getBox();
private:
/**
* @brief the x coordinate of the top-left corner
*/
double _xmin;
/**
* @brief the y coordinate of the top-left corner
*/
double _ymin;
/**
* @brief the x coordinate of the bot-right corner
*/
double _width;
/**
* @brief the y coordinate of the bot-right corner
*/
double _height;
};
/**
* @brief An object in a picture
*/
class Object
{
public:
/**
* @brief Builds an object with his label and the bounding box around him
* @param label the name of the object
* @param confidence the confidence score of detection
* @param bbox the bounding box around the object
*/
Object(std::string label, double confidence, Bbox bbox);
~Object();
/**
* @brief getter of the Bbox of the object
* @return the Bbox of the object
*/
Bbox getBbox();
/**
* @brief getter to the label of the object
* @return a string
*/
std::string getLabel();
/**
* @brief getter to the confidence of this object in the picture
* @return a float value
*/
double getConfidence();
private:
/**
* @brief the name of the object
*/
std::string _label;
/**
* @brief the confidence score of detection
*/
double _confidence;
/**
* @brief the bounding box around the object
*/
Bbox _bbox;
};
/**
* @brief The Image class contains all the information about the objects in it etc.
*/
class Image
{
public:
/**
* @brief Builds an Image given a line divided into substrings
* @param fileName the name of the file that is the picture
*/
Image(std::string fileName);
~Image();
/**
* @brief adds an object detected to this image
* @param object th eobject added
*/
void addObject(Object object);
/**
* @brief Accessor to the file name of the picture
* @return a string giving the file name
*/
std::string getFileName();
/**
* @brief gets the objects detected in the picture
*/
std::vector<Object> getObjects();
private:
/**
* @brief the objects detected in the image
*/
std::vector<Object> _objects;
/**
* @brief the fileName of the picture
*/
std::string _fileName;
};
#endif
|
0fc2aa8f27415b5536adc85c342b0ff1af80a157 | f13d60fe0d6ac39491a34070ddc92475f6c21fb3 | /src/DFnetlist_Connectivity.cpp | d070698f21da7c62db79e203125874bb13e3727e | [] | no_license | ShabnamSheikhha/DOT2BLIF | 9a9ef8ef67c0bd960b420f0bfaefef6634c211b8 | 64eb654a887293de87d6cfe212ddbc6ec22b6e9e | refs/heads/master | 2022-12-09T04:57:48.563336 | 2020-09-14T12:55:07 | 2020-09-14T12:55:07 | 288,914,471 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,786 | cpp | DFnetlist_Connectivity.cpp | #include <algorithm>
#include <cassert>
#include <stack>
#include "../lib/DFnetlist.h"
using namespace Dataflow;
using namespace std;
void DFnetlist_Impl::DFS(bool forward, bool onlyMarked)
{
// Vector to detect the blocks that have been visited
// or have been processed.
vector<bool> visited(blocks.size());
// All the blocks are not visited, except those that are marked
ForAllBlocks(b) visited[b] = onlyMarked and not isBlockMarked(b);
// Visiting order of blocks (first: entry nodes). This is necessary
// to properly identify the back edges. DFS must start from the
// entry nodes (see theory in Compilers book)
listBlocks lBlocks;
int clock = 0;
ForAllBlocks(b) {
setDFSorder(b, -1);
if (visited[b]) continue;
if (getBlockType(b) == FUNC_ENTRY) lBlocks.push_front(b);
else lBlocks.push_back(b);
++clock;
}
// Now we start an iterative DFS
DFSorder = vector<blockID>(clock);
stack<blockID> S, listChildren;
for (blockID b: lBlocks) {
if (visited[b]) continue;
S.push(b);
visited[b] = true;
// Put the children to the pending list. The lists of children
// from different blocks are separated by an invalidDataflowID
listChildren.push(invalidDataflowID);
const setPorts& ports = getPorts(b, (forward ? OUTPUT_PORTS : INPUT_PORTS));
for (portID p: ports) {
channelID c = getConnectedChannel(p);
if (onlyMarked and not isChannelMarked(c)) continue; // Skip if the channel is not marked
blockID other_b = getBlockFromPort(getConnectedPort(p));
if (not visited[other_b]) listChildren.push(other_b);
}
while (not S.empty()) {
blockID kid = listChildren.top();
listChildren.pop();
if (kid == invalidDataflowID) {
blockID v = S.top();
S.pop();
setDFSorder(v, --clock);
} else {
if (visited[kid]) continue;
S.push(kid);
visited[kid] = true;
listChildren.push(invalidDataflowID);
const setPorts& ports = getPorts(kid, (forward ? OUTPUT_PORTS : INPUT_PORTS));
for (portID p: ports) {
channelID c = getConnectedChannel(p);
if (onlyMarked and not isChannelMarked(c)) continue; // Skip if the channel is not marked
blockID other_b = getBlockFromPort(getConnectedPort(p));
if (not visited[other_b]) listChildren.push(other_b);
}
}
}
}
assert(clock == 0);
ForAllBlocks(b) {
int i = getDFSorder(b);
assert((onlyMarked and not isBlockMarked(b)) or (i < DFSorder.size()));
if (i >= 0) DFSorder[i] = b;
}
}
void DFnetlist_Impl::calculateBackEdges()
{
ForAllChannels(c) {
blockID bb = getSrcBlock(c);
bbID src = getBasicBlock(getSrcBlock(c));
bbID dst = getBasicBlock(getDstBlock(c));
// BB ids are given in DFS order from entry
// If branch goes to its own BB or a BB with a smaller id
// it is a back edge
// TODO: determine back edges at CFG level and then apply to CDFG
if ((getBlockType(bb) == BRANCH) && src >= dst)
setBackEdge(c, true);
else
setBackEdge(c, false);
}
// Forward traversal starting from entry nodes.
// DFS();
// Check for back edges
//ForAllChannels(c) {
// int src = getDFSorder(getSrcBlock(c));
// int dst = getDFSorder(getDstBlock(c));
// if (src < 0 or dst < 0) setBackEdge(c, false);
// else setBackEdge(c, src > dst);
//}
}
|
5e21c5c2e38d64f88a66f6d2c9dfd0c35ee0ff2c | 23745dcb560ba69708ea04127012b69380bbe9c1 | /srcs/game/objects/Food.hpp | 9c2f8d3e6d9d31db6415a0cdb7ca8a15fceaeea8 | [
"Apache-2.0"
] | permissive | elivet/Nibbler | 530826413b66d6167b2591943b2a5f94419a2dae | 9e2e07d9e3fa3dc86a8e25a6db419359fa0e0e8a | refs/heads/master | 2016-08-11T08:10:14.722793 | 2015-09-28T11:01:48 | 2015-09-28T11:01:48 | 43,294,807 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 418 | hpp | Food.hpp | #ifndef FOOD_HPP
# define FOOD_HPP
# include "../../core/GameObject.hpp"
# include "../components/FoodElement.hpp"
# include "../components/PotionElement.hpp"
# include <cstdlib>
class Food : public GameObject
{
public:
// Food( void );
Food( int nbr );
~Food( void );
Food( Food const & src );
Food & operator=( Food const & rhs );
virtual void init( void );
private:
size_t _nbr;
};
#endif
|
16ab01e5bd53f75cd697ffa15098fc52507e103f | 9f520bcbde8a70e14d5870fd9a88c0989a8fcd61 | /pitzDaily/573/p | df59815255267894549a4bf469afbd19a1c38b55 | [] | no_license | asAmrita/adjoinShapOptimization | 6d47c89fb14d090941da706bd7c39004f515cfea | 079cbec87529be37f81cca3ea8b28c50b9ceb8c5 | refs/heads/master | 2020-08-06T21:32:45.429939 | 2019-10-06T09:58:20 | 2019-10-06T09:58:20 | 213,144,901 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 98,087 | p | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v1806 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "573";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
6400
(
0.149938851187
0.149941673161
0.14994971554
0.14996539847
0.149988587789
0.150019193743
0.150057214064
0.15010371223
0.150159453621
0.150225694466
0.150308251711
0.150410200137
0.1505288092
0.150664034784
0.150817743965
0.15099234243
0.151189272364
0.151408374052
0.151647679386
0.151901995149
0.152165635824
0.152439716815
0.152731230464
0.153047668846
0.153393806152
0.153769524524
0.15417137927
0.154596781706
0.155045346589
0.155517713764
0.156014345628
0.1565333844
0.157068848639
0.157614674606
0.158168197161
0.158726423414
0.159289423523
0.159863565532
0.16044758494
0.161031989428
0.161617817618
0.162218314609
0.162840366449
0.163475871366
0.164114020053
0.164747544537
0.165370945096
0.165980159382
0.166571531613
0.167141934392
0.167688938905
0.168207562783
0.168689586591
0.169124565433
0.169511246807
0.169855788092
0.170155018155
0.170399879208
0.170588762877
0.170730363685
0.170831883145
0.170898440034
0.170934439437
0.170951840577
0.170958778909
0.170951839702
0.170924300392
0.170879875764
0.170828212281
0.170775289297
0.170722646571
0.170669549315
0.17061557445
0.170564663186
0.170517304821
0.170475279752
0.170439979309
0.17041674029
0.170401828108
0.170395553622
0.149934717234
0.149937711185
0.149944994008
0.149960317448
0.149984956557
0.150016965426
0.1500554439
0.150100299786
0.150154133473
0.150220210118
0.150302421738
0.150403302699
0.150522164035
0.150658306335
0.150812198511
0.150985457142
0.151181646245
0.151401417471
0.151642096858
0.151897096763
0.152158824381
0.152430717242
0.152721514071
0.153037817103
0.153384344449
0.153760812768
0.154162945299
0.154588911852
0.155038422367
0.15551153608
0.15600821133
0.156527646915
0.157064129233
0.157610033455
0.158163684385
0.158722157808
0.159284943615
0.159859540005
0.160444691637
0.161029746187
0.161614392906
0.162215133278
0.162840858953
0.163479133736
0.164118652457
0.164753684881
0.165378639133
0.165989752097
0.166582891532
0.167153515235
0.167699201446
0.168218905387
0.168706471132
0.169143759507
0.169532039075
0.16987970112
0.170177166086
0.170418524223
0.170606753706
0.170747292314
0.170845807719
0.170911760152
0.170948029134
0.170966152455
0.170974223763
0.170968032829
0.170939121182
0.170891389604
0.17083615131
0.170779889815
0.170724316716
0.170668434588
0.170611478969
0.170557471842
0.170509104529
0.170467402247
0.170434161497
0.17041137642
0.170396807123
0.170391930842
0.149923121899
0.149928084369
0.149934656897
0.149948738407
0.149972569224
0.150008261865
0.150049968951
0.150093504177
0.150144654223
0.150209213021
0.150290621901
0.150390909587
0.150509974241
0.150646841159
0.150800779796
0.150970685513
0.15116456175
0.151389259897
0.151633085344
0.151886789545
0.152144332041
0.152410777097
0.152700325479
0.153018890002
0.153366240687
0.15374245897
0.1541457659
0.154573528901
0.155024586285
0.155498976227
0.155996436341
0.156516882907
0.157055537413
0.157601038197
0.15815332425
0.15871362155
0.159276480466
0.159850007582
0.160436286383
0.161024446395
0.161615434304
0.162220894644
0.162846264771
0.163484222199
0.164125146274
0.164762300356
0.165390333887
0.166004860784
0.166601666933
0.167176806134
0.167727194972
0.168249000927
0.168734495771
0.169175262832
0.169571638818
0.169921026109
0.170215979253
0.170455211565
0.170641625699
0.170780127346
0.170877521124
0.170941170344
0.170976804868
0.170998310766
0.171010085578
0.171003025497
0.170970742551
0.170917411565
0.170854181461
0.170789829629
0.170726733608
0.170664019749
0.170602850606
0.170546582302
0.170496470451
0.170454527894
0.170422802913
0.170401016696
0.17038751542
0.170382676287
0.149906665178
0.149911731751
0.14991726522
0.149930230173
0.14995122708
0.149986796889
0.150039655725
0.150083290761
0.150130586792
0.150192497465
0.150272590331
0.150372517905
0.150492097137
0.15062884922
0.150782713341
0.150957103739
0.151155326883
0.151377380777
0.151613101448
0.15185551536
0.152108675926
0.152378545131
0.152670430161
0.152989476072
0.153337842743
0.153715460246
0.154120599336
0.154550513144
0.155003801027
0.155479938405
0.155979440691
0.156501408961
0.157041570509
0.15759040474
0.158140018402
0.158697006886
0.159263455732
0.159837282456
0.160421310182
0.161013365366
0.161612680489
0.162224765359
0.162852915484
0.163492605261
0.164136166246
0.164776905575
0.165409301705
0.166028669392
0.166630704133
0.167211378657
0.16776686081
0.168292438918
0.168781605926
0.169228310848
0.169629317906
0.169979665622
0.170274021807
0.17051170233
0.170695902342
0.17083203909
0.170927296256
0.170989602999
0.171028173093
0.171056033348
0.171071076112
0.171061827962
0.171022803499
0.170958684607
0.170881971373
0.170804241082
0.170730212731
0.170659795844
0.170593052946
0.170530145736
0.170474775293
0.170432645408
0.170403471347
0.170381686541
0.170366959594
0.170361004353
0.149880901633
0.14988191935
0.149888726973
0.1499020529
0.149925397218
0.149958982031
0.150007346608
0.15005527933
0.150105633886
0.150168126524
0.150247213863
0.150347009813
0.15046764518
0.150609774827
0.150771137356
0.150946427862
0.151138118774
0.151347339364
0.151572102805
0.151811499739
0.152065835722
0.152336942553
0.152630193633
0.152950704262
0.153300508765
0.153679893078
0.154086982984
0.15451960111
0.154975719195
0.155454846907
0.155956374512
0.156481984194
0.157026423899
0.157572652045
0.158121069387
0.158676422673
0.159240171551
0.159815865477
0.160403537625
0.161001213341
0.161608360092
0.162227606581
0.162860510769
0.163503890801
0.164151612363
0.164797358988
0.165435516148
0.166061193291
0.166669968493
0.167257649483
0.167819931543
0.168351765572
0.168847200546
0.169300482756
0.16970638983
0.170058919427
0.170353575379
0.170590349494
0.170773018442
0.170907824011
0.171002822123
0.17106705819
0.171110621841
0.171142599813
0.171155200259
0.171143088701
0.171097766006
0.171020023643
0.170923754994
0.170825995894
0.170736106155
0.170653493701
0.170573659923
0.170498617824
0.170438810825
0.170397093416
0.170367651059
0.1703427028
0.1703280559
0.170323305605
0.14983384827
0.149833856172
0.149845177616
0.149859062123
0.149884929862
0.1499207292
0.149965922779
0.150014658928
0.1500694356
0.150134091176
0.150211840027
0.150312270705
0.15044164681
0.150592259048
0.150753071963
0.150922476638
0.151104454987
0.151304627614
0.151524579716
0.15176180914
0.152014122139
0.152285161349
0.152579972732
0.152902515327
0.153254334145
0.153635219928
0.154045050618
0.154480516772
0.154940590319
0.155423329026
0.15592940458
0.156457151118
0.157001170426
0.157551312662
0.158095889889
0.158646128458
0.159210459864
0.159789927567
0.160382833961
0.160987196866
0.161602373628
0.162229456598
0.162868826449
0.163517852374
0.164171436504
0.1648237268
0.165469138643
0.166102668394
0.166719802337
0.167316208748
0.167887312183
0.168427878623
0.168931965209
0.169393283857
0.169805266278
0.170161492107
0.170458175204
0.170696022271
0.170879513423
0.171015739468
0.171113427835
0.171182203326
0.171231835892
0.17126278754
0.171272857674
0.171254514474
0.171199099619
0.171104099104
0.170982123438
0.170856765218
0.170743218542
0.170637611034
0.170534901182
0.170447234964
0.170383887414
0.170341579381
0.170309403279
0.170284721563
0.170272461548
0.170267779894
0.149762133232
0.149767605844
0.149786281419
0.149806811475
0.149829245719
0.149865520379
0.14991270069
0.149963461039
0.150021592635
0.150088919138
0.150170706713
0.150274751168
0.150411770372
0.150561901571
0.150718307153
0.150879807974
0.151055424163
0.151253195282
0.151471216999
0.151703341473
0.151952676446
0.152224130782
0.152520273274
0.152844270455
0.153198342746
0.153583193104
0.15399411875
0.154433146966
0.154897869563
0.155387855948
0.155898070725
0.156425969323
0.156970659967
0.157515633461
0.15805883555
0.158608877725
0.15917580429
0.159760094639
0.160359212719
0.160971000134
0.161594660486
0.16223039227
0.162877766005
0.163534303784
0.164195537917
0.164856031728
0.165510318225
0.166153386295
0.166780698296
0.167387850094
0.167970101919
0.168522002707
0.16903724624
0.169508762531
0.169929105762
0.170291826204
0.170593816322
0.170836426563
0.171024506827
0.171165232189
0.171267437678
0.171340990077
0.171393150661
0.171421933484
0.171437372598
0.171413086113
0.171338564101
0.171216864371
0.171060951112
0.170897444162
0.170744616274
0.170600153518
0.17046898978
0.170369373077
0.170302497079
0.170259036378
0.170226587223
0.170207616382
0.170201091344
0.170198020265
0.149677424709
0.149688118335
0.149709553522
0.14973906673
0.149763836434
0.149801642412
0.149847568068
0.149900992988
0.149963435645
0.150028935946
0.150118752481
0.150235057205
0.150370518684
0.150517491971
0.150667201088
0.150821593926
0.15099627341
0.151194643501
0.151407790253
0.151634863406
0.151881867169
0.152153268079
0.152450582923
0.152777177947
0.153134470095
0.153522190657
0.15393734772
0.154376120937
0.154848523502
0.155348326808
0.155860060108
0.156384686261
0.156927216646
0.157469228351
0.158010522232
0.158564712924
0.15913660859
0.159726492447
0.160332413502
0.160952293726
0.161585091521
0.162230411016
0.16288725954
0.16355310797
0.164223824391
0.164894297398
0.165559238181
0.166213729867
0.166853291485
0.167473513597
0.168069549437
0.168635692281
0.169165133284
0.169650079008
0.170082601071
0.170456461959
0.170769045007
0.171021658221
0.171218081606
0.17136426294
0.171468966538
0.171542706575
0.171593305444
0.171625020321
0.171642607858
0.17162686002
0.171532128436
0.171371438463
0.171165707888
0.170943183416
0.170727959699
0.170528658439
0.17036590818
0.170253645051
0.170184654749
0.170143675619
0.170121536878
0.170114612974
0.170118229362
0.170120696078
0.149584150134
0.149597995956
0.149619843896
0.149645228378
0.149676734822
0.149722682403
0.149768915978
0.149823976008
0.149893887588
0.149964617805
0.150052359203
0.150177175213
0.150315326646
0.150456905227
0.150600830533
0.150754817441
0.150928828278
0.151124246062
0.151332814164
0.151556980007
0.151802247095
0.152072633387
0.152369525057
0.152697647887
0.153062591375
0.153451835337
0.153871620949
0.154318571229
0.154792449614
0.155293255132
0.155810750795
0.156341221093
0.156871911817
0.157408577338
0.157954116756
0.158514358261
0.159092416062
0.159688738392
0.160302095944
0.160930746915
0.161573480341
0.162229441639
0.162897214302
0.163574136352
0.164256213179
0.164938566348
0.165616130507
0.166284173318
0.166938343077
0.167574289005
0.1681871251
0.168770939527
0.169318510515
0.169821594176
0.170272146244
0.170664147987
0.170994701518
0.171263350519
0.171470172255
0.171619461728
0.171722146207
0.171792824596
0.171842891155
0.17187569825
0.171887529035
0.171879205475
0.171796133357
0.171585463857
0.171305647631
0.170991283606
0.170680017332
0.17040767345
0.170207538435
0.170082712534
0.170017542186
0.169992515664
0.169995471942
0.170010543697
0.170028432111
0.170039353746
0.149480838664
0.149496741664
0.14952218637
0.149546743939
0.149580703818
0.149627170942
0.149675422037
0.149730702126
0.149800600282
0.149887163666
0.149979780158
0.150104777692
0.150243726089
0.150381515773
0.150519857269
0.150676427508
0.150853509728
0.151043800893
0.151246855347
0.151468524889
0.151713266198
0.151983721364
0.152280576533
0.152607119202
0.152978364457
0.153376258815
0.153792375707
0.154246766229
0.154725814332
0.155231180991
0.155751446261
0.156279190653
0.156808280532
0.157341365832
0.157890478335
0.158457495225
0.159042712553
0.159646383279
0.160267896649
0.160906012283
0.161559547381
0.162227305784
0.162907486967
0.163597243858
0.164292618391
0.164988904327
0.165681281517
0.166365273997
0.167036726092
0.16769141479
0.168324530346
0.168930153481
0.169500980887
0.170028796796
0.170505776806
0.170925727296
0.171283614231
0.171574295515
0.17179107219
0.17193963684
0.172036756683
0.172102960383
0.172153377003
0.172186671437
0.172191200866
0.172161150828
0.172082865693
0.171889367462
0.171498431367
0.171034293463
0.170579848375
0.170209494272
0.169962803621
0.169829461935
0.169783642274
0.169799118518
0.169847452864
0.169897542051
0.169934428728
0.169955259899
0.149363020068
0.149378183902
0.149405820016
0.149435208248
0.149477122008
0.149518493958
0.149567342828
0.149624921018
0.14968762654
0.149782500424
0.149888430846
0.150014058141
0.150153185522
0.150291251337
0.150428647426
0.150585668065
0.150764000918
0.150951019617
0.151149913169
0.151368213383
0.151611872732
0.151883912725
0.152185517179
0.152511740869
0.152877746921
0.153288907369
0.153713453841
0.15416730428
0.154647905729
0.155147388452
0.155674949876
0.156205075182
0.156731480237
0.15726597202
0.157820054427
0.158394043206
0.158987036717
0.159598943092
0.160229435722
0.160877747262
0.16154296059
0.162223718703
0.162917846385
0.163622244675
0.164332933498
0.165045370166
0.165755009991
0.166457665571
0.167149414001
0.167826245989
0.168483622555
0.169115990078
0.169716587527
0.170277980501
0.170792891844
0.171253797709
0.171649570279
0.171968774121
0.172196292094
0.172343846969
0.172433135888
0.172490136841
0.172543016939
0.172584819657
0.172584962672
0.172518758496
0.172390342737
0.17220357213
0.171772100679
0.171073204183
0.170393122338
0.169881415187
0.169579287526
0.16945277349
0.169458585909
0.169552667017
0.169679508018
0.169782615638
0.169843083552
0.169876235014
0.149227247799
0.149239197856
0.149260986199
0.149298587185
0.14935059661
0.149392259362
0.149442237035
0.149505668958
0.149566958746
0.149658462775
0.149774601884
0.149903409935
0.150042026562
0.150181927149
0.150325802547
0.15048503084
0.150661733591
0.150845535097
0.151041799501
0.151256884847
0.151496697111
0.151766409585
0.15207707144
0.152414927147
0.152775351805
0.153186277831
0.15361952991
0.154070657831
0.154561398655
0.155066343508
0.155585276087
0.156110510034
0.156638486736
0.157180877423
0.157742062706
0.158323479499
0.15892481536
0.159545824174
0.160186251237
0.160845595215
0.161523342535
0.162218295482
0.162927967282
0.163648882549
0.164377000257
0.165107992556
0.165837633793
0.166562016679
0.16727743765
0.167980179819
0.168666235997
0.169330999332
0.169969273074
0.170575586858
0.17114342022
0.17166113824
0.172104879598
0.172467981091
0.172717007885
0.172869955029
0.172945037648
0.172970512469
0.173031208944
0.17311076942
0.173131233085
0.173033543932
0.172821084587
0.172556338858
0.172051200709
0.171073280468
0.170045569893
0.169319593378
0.168961055875
0.168883492829
0.169002154093
0.169242363344
0.169509768848
0.169692151968
0.169770373949
0.169820813872
0.149073153799
0.14908228713
0.149095463392
0.149137589016
0.149190457248
0.149239531525
0.149293363895
0.149363334306
0.14943171841
0.149522100168
0.149642527392
0.14977342371
0.149911124999
0.15004919835
0.150201702124
0.150370072214
0.150545625886
0.150726728232
0.150921526595
0.151134910387
0.151370711515
0.151633755029
0.151944421997
0.152303023512
0.152670020017
0.153069116105
0.153514091983
0.153971336409
0.154453296094
0.154962329432
0.155482841728
0.156005816079
0.156535692079
0.157085333376
0.157654949703
0.158244888759
0.158855300418
0.159486167344
0.160137570771
0.160809105997
0.16150039208
0.162210636171
0.16293738737
0.163676773193
0.164424567802
0.165176720739
0.165929415992
0.166678980578
0.167421818557
0.168154516183
0.168873896553
0.169577102245
0.170262001232
0.170926787413
0.171565496404
0.172157862079
0.172656857541
0.173119384097
0.173429271501
0.173608445612
0.173651664419
0.17356670227
0.173679459015
0.173909540847
0.174027770901
0.173894107512
0.173566181273
0.17313116718
0.172340470353
0.170931729089
0.169435179632
0.168405429825
0.168025083784
0.168061743141
0.168377433591
0.168873611722
0.169398581816
0.169690995939
0.169727671226
0.169810908013
0.148901760157
0.148912283632
0.148930359917
0.148961958026
0.149009411313
0.149063383807
0.149122205399
0.149195579152
0.149275661203
0.149368307906
0.149491980774
0.149624715784
0.149762822623
0.149899919999
0.150054354023
0.150231269817
0.150410172179
0.150592290467
0.150787270823
0.151000383626
0.151234284036
0.151491649996
0.151797061026
0.152166842362
0.152549631631
0.15294603235
0.153394256551
0.153860084058
0.15433743087
0.154843238199
0.155358060626
0.155880742682
0.15642027358
0.156979075053
0.157557771046
0.158157120773
0.158777705681
0.159419379165
0.160082481776
0.160767306507
0.161473531391
0.162200388751
0.162945673494
0.163705406494
0.1644752045
0.165251337238
0.166030492319
0.166809116843
0.167583453532
0.168350281687
0.16910749381
0.169854931677
0.170595335885
0.171332708439
0.172060489735
0.17274953014
0.17332231725
0.174087155732
0.174447348276
0.174630620389
0.174520089677
0.173831526881
0.173522233902
0.1736537012
0.173851783306
0.173883557333
0.173777460505
0.173649898385
0.172921982247
0.170473679704
0.167904961603
0.166339691399
0.166222787271
0.16667508959
0.16741664811
0.168374873613
0.169493840549
0.169894801371
0.169692276431
0.169879446327
0.148708837402
0.148720778494
0.148748465417
0.14877049245
0.148811569018
0.148866925725
0.148929781031
0.14900804434
0.149102153752
0.149196545226
0.149322308272
0.149457204287
0.149597183919
0.14973655675
0.149892547711
0.150073224928
0.15025574917
0.150441095386
0.150637922325
0.150851623868
0.151085328831
0.151340757349
0.151637268045
0.152004140918
0.152411184774
0.152815761425
0.153252034991
0.153733334859
0.154219921377
0.154709366207
0.155217347123
0.155744178976
0.156291917977
0.156860393673
0.157449301692
0.158059154603
0.158690671023
0.159344335481
0.160020383462
0.160719378289
0.161441763246
0.162186837396
0.162952329028
0.163734244888
0.164528298891
0.165331331416
0.16614068679
0.166952767418
0.167763071906
0.168568047261
0.169366984783
0.17016337865
0.170966033268
0.171786335987
0.172622059048
0.173504551911
0.173770635859
0.173974275524
0.174204000224
0.174341581742
0.174290202338
0.174040733983
0.173777382304
0.173694724374
0.173703148881
0.17358749792
0.173306625478
0.172722558626
0.171318006488
0.16932905963
0.167625138641
0.166767843424
0.166715342156
0.16716352929
0.167963185698
0.169058637984
0.170330391842
0.171061367841
0.169165255698
0.170077649623
0.14849041152
0.148501807068
0.14852837977
0.14855249685
0.148591288193
0.148648229068
0.148713306003
0.148792039629
0.14889946828
0.149003974158
0.149131635808
0.149269548784
0.149413098333
0.149557477799
0.149716765014
0.149899102288
0.150084276625
0.150273522234
0.150473180157
0.150688223721
0.150922160337
0.151177642119
0.151468241706
0.151827128822
0.152249274207
0.152671788936
0.153100294562
0.15357445585
0.154071156533
0.154565392784
0.155068510138
0.155596521315
0.156151016399
0.156729167118
0.157328836483
0.157949838357
0.158593245814
0.159259740323
0.159949965374
0.160664474649
0.161404175064
0.162168979029
0.162956584797
0.163762645646
0.164582969589
0.165415669632
0.16625949244
0.167110265963
0.167960994797
0.168807415714
0.169651384298
0.170499527877
0.171363515493
0.172259108021
0.173153139683
0.173375862189
0.173608527468
0.173838565964
0.174038994853
0.174150533095
0.174101747968
0.173886869653
0.173604955247
0.173383662027
0.173201032683
0.172929376571
0.172487738239
0.171797155271
0.170681731442
0.169232267454
0.167859195663
0.166960402442
0.166648835424
0.166857192832
0.167481896699
0.168410110887
0.169410551728
0.169981492168
0.170513346775
0.171156090125
0.148248370064
0.148259008226
0.148286705484
0.148311489222
0.148350927925
0.148408520603
0.148475398543
0.148551604736
0.148661598597
0.148781550193
0.148915966314
0.149058566498
0.149207525454
0.149360803716
0.149524228249
0.149708242316
0.149895994003
0.150089693954
0.150292822496
0.150509954721
0.150744596965
0.151000020961
0.151286820618
0.151636065923
0.152058555604
0.152508294311
0.152946124886
0.153407014318
0.153897886889
0.154393797857
0.154899676678
0.155433970518
0.155996299037
0.156584076475
0.157195012259
0.15782824775
0.158484322746
0.159164608019
0.159869990656
0.160601360417
0.16135972589
0.162145559302
0.162957167728
0.163789766334
0.164638582487
0.165503423334
0.166385703365
0.167280371409
0.16817600207
0.169067319819
0.169960139357
0.170862521014
0.171789687458
0.172694097496
0.172958019682
0.173203570493
0.17342497621
0.173621789351
0.173761930869
0.173806445894
0.173718489643
0.173499799466
0.173203101965
0.172888300476
0.172549033941
0.172117828162
0.171527517924
0.170724305601
0.169666433493
0.168387190513
0.167101448014
0.166119138989
0.165611479055
0.165577663413
0.165949768998
0.166644895544
0.167565741296
0.168722384036
0.17029082205
0.172574407169
0.147985170994
0.147994255172
0.148017750471
0.148046143598
0.148090785895
0.148149280062
0.148219554605
0.148295206427
0.148404653152
0.148534085479
0.148674762616
0.148821735264
0.148974850862
0.149140212308
0.14931136665
0.149497405464
0.149688468773
0.149888131446
0.150095842372
0.150315958751
0.150552005732
0.150807399049
0.151091510799
0.15143261522
0.151849528385
0.152316459707
0.152775271901
0.153232195033
0.153711512015
0.154203246126
0.154713523771
0.155254446481
0.155825062351
0.156422497232
0.157045331514
0.157692193824
0.158362508199
0.159057478342
0.159779241668
0.160528588316
0.161306905143
0.162115531321
0.162953268071
0.163814804322
0.164693256893
0.165591175361
0.166518179829
0.16746691035
0.168410603268
0.169347318372
0.170291647589
0.171255737158
0.172186855198
0.17247880022
0.172740982787
0.172972702753
0.173164397633
0.173305015633
0.173372435299
0.17334067144
0.173189019992
0.172917710202
0.17255196829
0.172120530611
0.171622868473
0.171024258037
0.170281302417
0.169362414031
0.168260223412
0.167030457208
0.165778604181
0.164671555081
0.163875003763
0.163435937635
0.163334767842
0.163555612712
0.164135659698
0.165270596894
0.167603223124
0.169680159544
0.147704072911
0.147711862061
0.147729864238
0.147762443975
0.147811559854
0.147870754639
0.147943764999
0.148023155958
0.148129744541
0.148264286372
0.148409258139
0.148559510236
0.148714218784
0.148886868315
0.149071465339
0.149262426737
0.149457753025
0.149664384554
0.149879337082
0.150104323215
0.15034327097
0.150598875729
0.150881272197
0.151215766045
0.151622057463
0.152087860539
0.152568778571
0.153037985906
0.153514215587
0.154002919032
0.154512303805
0.155057885122
0.155636624283
0.156242409207
0.156878148826
0.157539922941
0.158224871007
0.158936033937
0.15967568157
0.16044495664
0.161244804409
0.162077043979
0.162941841654
0.163835670544
0.164753278335
0.165696657642
0.166671217014
0.167662193036
0.168649501945
0.169641922445
0.1706483102
0.171656267261
0.171961585716
0.172223809199
0.17246360403
0.172661124719
0.172798146729
0.17286250962
0.172838951961
0.172710351923
0.172464293039
0.172100221469
0.171630213756
0.171068033089
0.170413373509
0.169647474542
0.168744694419
0.167687683173
0.166479634423
0.165159087654
0.163804702998
0.162474087419
0.161256030878
0.160222767149
0.159355200896
0.158603658241
0.157919386273
0.157183802947
0.156043079788
0.153485091396
0.147406348847
0.147413895305
0.147430343526
0.147467020956
0.147516297103
0.147574080677
0.147645451319
0.147730273904
0.147833908269
0.147971263925
0.148119764439
0.148273238385
0.14843052407
0.148605269142
0.14880144605
0.149001011831
0.149202663125
0.149415805548
0.149638940953
0.149871545271
0.150116319536
0.150373279835
0.150654731454
0.150984812799
0.151381072295
0.151839647364
0.152330172533
0.152814542932
0.153290234226
0.153777636783
0.15429292905
0.154841305793
0.15542586389
0.156042049118
0.156691345155
0.157368359146
0.158069335961
0.15879801848
0.159556835726
0.16034741288
0.161170817785
0.16202909963
0.162925525463
0.16386149612
0.164829269621
0.165817014159
0.16682746338
0.167858241752
0.16890029736
0.169967655461
0.17108589234
0.171409371761
0.171668373008
0.171908197134
0.172109277598
0.172245655946
0.172302784709
0.172270358072
0.172137201176
0.171892077362
0.171527224952
0.171041506656
0.170440067424
0.169728633645
0.168905794086
0.167960356525
0.166876820237
0.16564464801
0.164266710405
0.162765602978
0.161186826807
0.159519786961
0.157756923858
0.155929319324
0.153962194306
0.151673890652
0.148790727317
0.144979110529
0.140159248894
0.139268728587
0.147089019682
0.147096899374
0.147114174617
0.147155334073
0.147204188433
0.147259890633
0.147327308401
0.147415578373
0.147514698753
0.147653287338
0.147805407306
0.147962314875
0.14812331793
0.148301542845
0.148504659782
0.148713091328
0.148922873368
0.149143111576
0.149373341034
0.149614377992
0.149867955361
0.150128575985
0.150409610252
0.150737003637
0.151125103042
0.151574377269
0.152065704345
0.152560002468
0.153046864368
0.153535905109
0.154055448601
0.154609182881
0.155196837547
0.15581722425
0.156476973261
0.157172487671
0.157893044704
0.158641482067
0.159420569713
0.160233456143
0.161082696881
0.161971140808
0.162907672998
0.163894056916
0.164906419489
0.16592976052
0.166979501999
0.16807888472
0.16920689068
0.170428171339
0.170792602858
0.171064150171
0.171310610316
0.171514516211
0.171649973541
0.171700984987
0.171656778365
0.171508584652
0.171248255797
0.170868491392
0.170364266543
0.169734044067
0.168979172598
0.168100797548
0.167095929668
0.165955889232
0.16466879215
0.163224422063
0.161618537458
0.159854221836
0.157937620822
0.15584919925
0.153463540713
0.150677913261
0.147327783422
0.142984262043
0.136791009358
0.126931958625
0.108249800763
0.0626305339036
0.146745128299
0.146753299227
0.146773411596
0.146819649027
0.146868909226
0.146923241042
0.146988943387
0.147077751853
0.147171859378
0.147309384833
0.147464817419
0.147625146259
0.147789969615
0.147971830997
0.148179937998
0.148396629214
0.148616741629
0.148845084071
0.149081700999
0.149330550118
0.149594759987
0.149862307557
0.15014320546
0.150468789703
0.15085136492
0.151290693523
0.151776186984
0.152270028755
0.152771129601
0.153275573872
0.153797751447
0.154351537907
0.15494591761
0.155576991052
0.156241035891
0.156948627688
0.157690414978
0.158461233182
0.159264346657
0.160101704392
0.160977985692
0.161903871468
0.162892816652
0.163929544871
0.16497686366
0.166035718533
0.167153602397
0.168397842839
0.16964698518
0.170072059586
0.170380127498
0.170656435013
0.170873638398
0.171012946383
0.171061313707
0.171007787247
0.17084391537
0.17056325153
0.170160420405
0.169630843386
0.168971127785
0.168179353773
0.167254440575
0.166194342604
0.16499388058
0.163643674412
0.16213097624
0.160441620482
0.158561263556
0.156473959235
0.15415545225
0.151565771
0.148519679155
0.144738445455
0.139944612797
0.133530403081
0.124253028126
0.109694795003
0.0849792032075
0.0436980069006
0.146364989805
0.146373419053
0.146396337692
0.146447869479
0.146497443035
0.146553845315
0.146619776986
0.146707392206
0.146799855809
0.146937467658
0.147096291669
0.14725994194
0.147428420111
0.14761342511
0.147824801557
0.148047457196
0.148279927477
0.148518238734
0.148761741755
0.149017841127
0.149292505127
0.149571500938
0.149853899512
0.150176669712
0.150556165059
0.150987413325
0.151465253394
0.151954120575
0.152457740119
0.152981277782
0.153520507778
0.154078094018
0.154665645753
0.155302076498
0.155981221802
0.156700417863
0.157459973413
0.158253688304
0.159082195188
0.159947885108
0.160858340005
0.161834487266
0.162881171659
0.163961045649
0.165047308714
0.166168895303
0.167412505543
0.16897233789
0.169338293038
0.169615934743
0.169932606669
0.170181254693
0.170334153603
0.170386339609
0.170328911896
0.170153296262
0.169853873121
0.169426883805
0.168869291379
0.168178349472
0.1673515273
0.166386350851
0.165279781167
0.164027026656
0.162620156324
0.161047150094
0.159291690032
0.157333188716
0.155145832532
0.1526950536
0.149929526122
0.146766041002
0.143071656976
0.138468997821
0.132454004126
0.124445341099
0.113326961212
0.0972112134836
0.0727901322511
0.0390339323025
0.145940768253
0.145951298632
0.145975531558
0.146026896961
0.146080249767
0.14614420647
0.14621456746
0.14630427479
0.146402287077
0.146536195666
0.146697767858
0.14686478207
0.147036969904
0.147224898638
0.147438418102
0.147663334432
0.147904415617
0.148156176301
0.148409564909
0.148674405582
0.148957906154
0.149251753189
0.149543849962
0.149860791702
0.150236982637
0.150662573805
0.151133107666
0.151617288786
0.152117094418
0.152650001402
0.153208129011
0.153782074434
0.154371837832
0.155003452226
0.155686714742
0.156420829925
0.157199910921
0.158017793371
0.158872267486
0.159769554751
0.160728115823
0.161767086638
0.162869640699
0.163996853061
0.165144417555
0.16635191384
0.167601381055
0.168619644802
0.168973980162
0.169190287685
0.169434482566
0.169614024164
0.169679658122
0.169624409266
0.169442879307
0.169129729366
0.168682057773
0.168098376936
0.167377421066
0.166517579857
0.165516582159
0.164371129399
0.163076289707
0.161624591129
0.160004950779
0.158201674587
0.156193574594
0.153952811752
0.151442616602
0.148612726114
0.145391158238
0.141670635925
0.137289945741
0.131974874323
0.125151328396
0.116088888046
0.103937918131
0.0873447023591
0.0638871846063
0.0341766538805
0.145477432368
0.14549149356
0.145516002975
0.145561313846
0.145621460805
0.145693522945
0.145771249555
0.145867461726
0.145977008877
0.146106635799
0.146268223656
0.146437957398
0.146614032713
0.146805202183
0.14702125741
0.147248896307
0.147493042099
0.147756565488
0.148022905721
0.148299472739
0.14859192205
0.148900244881
0.149212037333
0.149533971497
0.149899350844
0.150317891948
0.150781063801
0.151261042379
0.151755214736
0.152288375591
0.152856384292
0.153451897788
0.154056197613
0.154686413282
0.155367172024
0.156106678734
0.156902374766
0.157746625437
0.158631625788
0.159571307019
0.16059299926
0.161701094501
0.162863926709
0.164057404464
0.165310204247
0.166576867803
0.167479400056
0.168113384809
0.168420393861
0.16866372977
0.168852140411
0.168938706301
0.168896007406
0.168716241677
0.168396201083
0.167933997113
0.167329303905
0.166582481554
0.165693517506
0.164661373685
0.16348355041
0.162155641355
0.160670749181
0.159018703662
0.157185102931
0.155150221357
0.152887710102
0.150362766536
0.147529165418
0.144324321447
0.140661401044
0.136417402254
0.131416165599
0.125406671676
0.117992288884
0.108456605703
0.0958865713911
0.0792547865222
0.0569039061417
0.0299294579457
0.144989973988
0.145004544208
0.145028153385
0.145066191175
0.14513009467
0.145205822573
0.145288797703
0.145388940236
0.145507255276
0.14564099601
0.145804584364
0.145977382952
0.146157783018
0.146352539331
0.146571654989
0.146803659682
0.147052004308
0.147324349704
0.147603618776
0.147895462509
0.148200154763
0.148520130955
0.148848393304
0.149189460462
0.149559007854
0.149968253269
0.150417125919
0.150890328697
0.151377066806
0.151904782132
0.152473844348
0.153079392276
0.153704953186
0.154346122536
0.155028791246
0.155766594942
0.156568274514
0.157434561263
0.158358431019
0.159355855793
0.160451501948
0.161632430593
0.162864721092
0.164147818098
0.16547694028
0.166542990278
0.167300664847
0.167566928253
0.16785448853
0.168067829276
0.168169201021
0.168143175552
0.16797450336
0.167656113513
0.167186961342
0.166568163361
0.165801625885
0.164889128316
0.163831411007
0.162627515286
0.16127431211
0.159766047948
0.158093791118
0.156244712681
0.154201166808
0.151939529476
0.149428677352
0.146627841508
0.143483399065
0.13992402118
0.135853499856
0.131140527724
0.125604725659
0.118998038615
0.110981720093
0.101094430903
0.088574033709
0.07251057124
0.0516358993333
0.0268388870779
0.144484435781
0.144497441259
0.144519061813
0.144554954971
0.14461460492
0.144688871976
0.144773592718
0.144873995209
0.144996489414
0.145136588593
0.145304868638
0.145481365448
0.145666449372
0.14586486911
0.14608698441
0.146323436835
0.146576383246
0.146856460157
0.147147011421
0.147453246792
0.147775589968
0.148108774191
0.148452660584
0.148803993216
0.149185737965
0.149605035394
0.150051065674
0.150510712481
0.150986504411
0.151505696597
0.152072428321
0.152676438671
0.153312218223
0.153967138573
0.154658176116
0.155401183694
0.156204603113
0.15708522155
0.158052260795
0.15911972884
0.16029503213
0.16154997864
0.16284896444
0.164143712616
0.165333641372
0.166140348896
0.166780299587
0.167019301908
0.167226469266
0.167364772537
0.167366285618
0.167216469
0.166909208211
0.166442213349
0.165817443242
0.165038566792
0.164109277696
0.163032328015
0.161808741588
0.160437218232
0.158913689805
0.157230897237
0.155377879154
0.153339299091
0.151094553053
0.148616586193
0.145870296626
0.14281031753
0.139377868469
0.135496283097
0.131064774084
0.125949995003
0.119975014157
0.112905405976
0.104432304858
0.0941527114932
0.0815787691479
0.0660367375814
0.0465226975963
0.0238090573751
0.143954461407
0.143969412861
0.143987693238
0.144026912818
0.144079234544
0.144148949978
0.144232436338
0.144331621678
0.144455252915
0.144596806575
0.144769703477
0.144949647303
0.145138595521
0.145340690604
0.145566041727
0.14580567426
0.146061472183
0.146348621249
0.146649308604
0.14696585793
0.147303353337
0.147649600073
0.148013877557
0.14838349411
0.148769895455
0.149198144453
0.149659725715
0.150118504296
0.150583001428
0.151090183632
0.151655154479
0.152259732725
0.152896035205
0.153556905174
0.154252134496
0.154999127036
0.155806337479
0.156699990985
0.157710939402
0.158854184574
0.160109595468
0.161425987199
0.162768484875
0.164116822507
0.165382799896
0.16573680549
0.165985800394
0.166320981326
0.166511309377
0.166552143481
0.166435820422
0.166151855284
0.165697828057
0.1650766664
0.164293833109
0.163355235232
0.162265886396
0.161029056192
0.159645629061
0.158113622818
0.15642781694
0.154579386721
0.15255544505
0.150338418362
0.147905193057
0.145225958337
0.142262639301
0.138966764476
0.13527655745
0.131113003213
0.126374632282
0.120930807323
0.114613400701
0.107206954028
0.0984377312668
0.0879629478884
0.0753613061587
0.0601337380662
0.0415871711835
0.0208211371558
0.143389736956
0.143405787377
0.143426287337
0.143467064486
0.143518046618
0.143585181295
0.14366660757
0.143764045011
0.143886215796
0.144025162934
0.144200737282
0.14438389065
0.144574394578
0.144780169611
0.145010036034
0.14525276826
0.145509340992
0.145799567979
0.146109486497
0.146433321524
0.146782820126
0.14714383434
0.147521149539
0.147917594726
0.14832326662
0.148760202486
0.149237791509
0.14971114498
0.150167505203
0.150660088376
0.151214637267
0.151820809767
0.152463405412
0.153130673379
0.153824295558
0.15456878283
0.155374779652
0.156277227513
0.157330821946
0.158550803847
0.159880589552
0.161216149996
0.162503916
0.163678503634
0.164413985204
0.165180569179
0.165373365312
0.16557934267
0.165691034922
0.165625040791
0.165377566281
0.164949107431
0.164342741749
0.163565496329
0.162625734219
0.161531109375
0.160287445908
0.158898072531
0.157363361745
0.155680392666
0.153842677542
0.151839867673
0.149657355593
0.147275706168
0.144669857876
0.141808029668
0.138650250499
0.135146401602
0.131233636692
0.126833034922
0.121845363463
0.11614589568
0.109578373045
0.101948462657
0.0930174341733
0.0824980531961
0.070052339511
0.0553226264369
0.0377523103503
0.0186723893681
0.14278929087
0.142803000801
0.142830321851
0.142872088356
0.142925868302
0.142993825792
0.143074151783
0.143170293392
0.143290217277
0.143424196993
0.143599780738
0.143786855456
0.143977263369
0.144183845643
0.144419802729
0.144667382882
0.144925632992
0.145213414404
0.145527360432
0.145857888313
0.146214729786
0.146592816624
0.146989564991
0.147403094488
0.14783283483
0.148284902377
0.148779923139
0.149281885067
0.149745378791
0.150223607076
0.150758565433
0.151357165369
0.152003504819
0.152683366078
0.153382402356
0.154119797966
0.154916825619
0.155817294036
0.156906809657
0.158203036909
0.159591775025
0.160973884316
0.162323464337
0.163565237465
0.164128372333
0.164357536888
0.164636809172
0.164790243808
0.164778678638
0.164580732138
0.164190308929
0.163610530767
0.162849445828
0.16191749108
0.160825088741
0.159580962252
0.158191198101
0.156658757651
0.154983202779
0.153160512975
0.151182920551
0.149038694183
0.146711804007
0.144181412613
0.141421143262
0.138398075187
0.135071405609
0.131390705337
0.127293685683
0.122703402476
0.11752485928
0.111641058267
0.104908699809
0.0971540165092
0.0881695518414
0.0777141194325
0.0655138942
0.0513046507786
0.0346260532052
0.0169356890125
0.142160082543
0.142173052519
0.142202540975
0.142245313113
0.142302184483
0.142372547465
0.142452701674
0.142548484168
0.142667896695
0.142797079648
0.142969234409
0.143160582404
0.14335242488
0.143555598423
0.143795049647
0.144048433516
0.144310277751
0.144595211505
0.144907127096
0.145240080326
0.145602554711
0.145985054913
0.146401466565
0.146835952532
0.147290693655
0.147763008139
0.148275293541
0.148813127361
0.149307381174
0.149784787734
0.150303204344
0.150880290649
0.151518560875
0.152205850159
0.15292513524
0.153664268199
0.15444604883
0.155324679114
0.156434653938
0.157791643471
0.159184134065
0.160537571541
0.161825161144
0.162782079549
0.163547763135
0.163675037572
0.163831092906
0.163893259444
0.163756639824
0.163415436404
0.162873967014
0.162140038897
0.16122550754
0.16014334569
0.158905279442
0.157520432887
0.155994631414
0.154330108435
0.152525410077
0.150575359398
0.1484709981
0.146199445888
0.14374362724
0.141081823651
0.138187015814
0.135025979565
0.131558094025
0.127733812726
0.123492747543
0.118761328731
0.113450047644
0.107450376129
0.100631610163
0.0928381666918
0.0838881254351
0.0735753804489
0.0616719501215
0.0479760912305
0.0320870770235
0.0154977065171
0.141504794854
0.141517297906
0.141545864312
0.141590475331
0.141648848113
0.141720699851
0.141800690295
0.141895298136
0.142018072634
0.142148996596
0.142311428826
0.142505117492
0.142700854697
0.142903411241
0.143137989061
0.143394179703
0.143659967116
0.143944330193
0.144254776292
0.144584130818
0.144951601968
0.145336365949
0.145752381608
0.146199674417
0.146673966316
0.147174843368
0.147710318412
0.148286219939
0.148838965786
0.149337297948
0.149852014846
0.150413577255
0.151034753609
0.151710182052
0.152438042574
0.153199710348
0.153982648557
0.154821111974
0.155909704078
0.157337182209
0.158773718053
0.160091236444
0.161311769246
0.162125048587
0.16267113751
0.162882047381
0.162961391689
0.162890378147
0.162614831998
0.162125283405
0.161430267244
0.160543400229
0.159480038855
0.158254898595
0.156880297068
0.15536516625
0.15371463176
0.151929934253
0.150008503898
0.147944055566
0.145726625063
0.14334249717
0.140773989784
0.137999067325
0.134990760296
0.131716367245
0.128136408467
0.124203293671
0.119859662851
0.11503637246
0.109650137177
0.103600921315
0.0967693167695
0.089014426535
0.0801729825649
0.0700622056637
0.0584818089538
0.0452658267138
0.0300453179685
0.0142911331998
0.140824362872
0.140836735591
0.140864811505
0.140911644744
0.140968900893
0.141039370405
0.141119349159
0.141211010117
0.141334082469
0.141471197862
0.141623567442
0.141817063875
0.142016166947
0.142222409857
0.142448805052
0.142702931913
0.142970586116
0.143255057544
0.143567962437
0.143895305698
0.144258213368
0.144649186546
0.145061544514
0.145509163079
0.14599173163
0.146506381611
0.14706265194
0.147666800987
0.148294074775
0.14885928784
0.149385924007
0.149945503099
0.150554943278
0.151224555106
0.151944066877
0.152717142582
0.153526747302
0.154351291974
0.155338633833
0.15674539678
0.158304945827
0.159746009229
0.161106539014
0.161557170409
0.161680914634
0.161920738616
0.16196408747
0.161768473374
0.161348462311
0.1607089015
0.15986256157
0.158827861627
0.157623205818
0.156264491499
0.154764043547
0.15313012454
0.15136684109
0.149474291037
0.147448796053
0.145283107952
0.142966523235
0.140484869224
0.13782034119
0.134951177043
0.131851158705
0.128488923787
0.124827060388
0.12082094308
0.116417258437
0.111552170741
0.106149106752
0.100116207493
0.0933436265316
0.0857011387074
0.0770367244824
0.0671788445124
0.0559371483139
0.043156998263
0.0284770361943
0.0133053106863
0.140119983512
0.140132432912
0.140165119949
0.140212234178
0.140264866242
0.140331980588
0.140411831294
0.140501566812
0.140616497449
0.140754901547
0.140901817341
0.141093027235
0.141293636347
0.141500900401
0.141721895693
0.141972736195
0.142237608431
0.142520954427
0.142836468239
0.143167233262
0.143521766513
0.143911255378
0.144322873844
0.144770208325
0.145251186161
0.145766472137
0.146327584964
0.146940656161
0.147608474633
0.148282579354
0.148877810081
0.149452213727
0.150062956477
0.150724994993
0.151448525079
0.152229149194
0.153064773298
0.153941755662
0.154857149827
0.156018373543
0.157509046731
0.158915244518
0.159811980402
0.160735162244
0.160817151966
0.160901896074
0.160842882308
0.160524152731
0.159959545152
0.159170358392
0.158177210394
0.157002272741
0.15566589522
0.154184462624
0.152569781294
0.150829071516
0.148965218825
0.146977140207
0.144860154036
0.142606274971
0.140204388569
0.137640285432
0.134896548263
0.131952292209
0.128782756715
0.125358736188
0.121645815205
0.117603348197
0.113183099246
0.108327444958
0.102967051451
0.097017983271
0.09037830448
0.0829245175498
0.0745083876127
0.0649570714518
0.0540714062007
0.0416815090338
0.0274065894083
0.012557968202
0.139391865914
0.139405364551
0.139442318802
0.139485417972
0.139533920882
0.13959870244
0.139678122435
0.139767129104
0.139873474278
0.140008090378
0.140149374076
0.140334049597
0.140535602529
0.140739431508
0.140955747605
0.141205884028
0.141465830203
0.141742331212
0.142057249353
0.142388580809
0.142738813074
0.143124728096
0.143530205583
0.143978076698
0.144456308865
0.144969476386
0.145520747924
0.146125050293
0.146787372846
0.147513779543
0.148239526433
0.148891921501
0.149534709831
0.150208464098
0.150936550765
0.151728809387
0.152589282008
0.153515815163
0.154487403649
0.15555463031
0.15682002097
0.158175376556
0.158871711241
0.159582381875
0.159814310044
0.159823239973
0.159619627713
0.15916069159
0.158450781404
0.157515382061
0.156382096077
0.155076238245
0.153619035016
0.152026573223
0.150309658303
0.148474202779
0.146521784071
0.144450201942
0.14225395811
0.139924615246
0.137451015277
0.134819353574
0.132013117905
0.129012904749
0.125796119576
0.122336545512
0.118603730103
0.114562096335
0.11016964327
0.10537606687
0.100120115108
0.0943259949327
0.0878987028927
0.0807183899925
0.0726339973423
0.0634590110583
0.0529648553428
0.0409314596412
0.0269193728954
0.0120992892462
0.13863768829
0.138651322102
0.138679766647
0.138722241099
0.138772607841
0.138837283112
0.138915979537
0.139003203342
0.139105128584
0.139235246136
0.139374116927
0.139544807354
0.139747843662
0.139949032147
0.140158681914
0.140406347461
0.140666406223
0.140935568067
0.141239564755
0.141566895725
0.141909893679
0.142294761407
0.142695087782
0.14312920149
0.143600982163
0.144111718888
0.14465387378
0.145242186099
0.145884872052
0.146591163373
0.147364588707
0.148148975195
0.148888498486
0.149619343105
0.150376361304
0.151186569181
0.152065053372
0.153023180099
0.154059019413
0.155223823306
0.156474822509
0.158009710327
0.158352066443
0.158415004191
0.158668335329
0.158632993264
0.158289363618
0.157681259811
0.156825900265
0.155750179657
0.15448555636
0.153059424322
0.151493059233
0.1498015771
0.147994388847
0.146075943043
0.144046526785
0.141902970532
0.139639204836
0.137246660673
0.134714517756
0.132029816041
0.129177454083
0.126140100897
0.122898033283
0.119428875515
0.11570716375
0.111703596187
0.107383769562
0.102706146159
0.097618941653
0.0920555634596
0.0859281899465
0.0791192216708
0.0714702346317
0.0627710490479
0.0527443383982
0.041076839955
0.0272144145464
0.0120619089601
0.137859405569
0.137871983577
0.137892656697
0.137935037473
0.137987834431
0.13805091236
0.138126215979
0.13821009043
0.138306959363
0.138432922742
0.13857409116
0.138729527636
0.138931166343
0.139135379193
0.139342341341
0.139576856284
0.139836902138
0.140103685903
0.14039181371
0.140713976562
0.141048130276
0.14141897886
0.141818066299
0.142235622682
0.142694547895
0.143188635213
0.143722682549
0.144296140464
0.144916655069
0.145596009419
0.146335013985
0.147143307153
0.147976997756
0.148806063676
0.149630804584
0.150485707155
0.151391098879
0.152364615565
0.153411181955
0.154618000157
0.155797424729
0.156865014653
0.157579348417
0.157431940024
0.157466312326
0.15731926835
0.156843520387
0.156088031991
0.155090030689
0.153881606492
0.152495940375
0.150961048854
0.14929749786
0.147518925092
0.145633077715
0.143642887832
0.141547455697
0.139342850601
0.137022711246
0.134578666822
0.132000606763
0.129276831286
0.126394124123
0.123337787995
0.120091659713
0.116638065966
0.112957607005
0.10902857555
0.104825748265
0.100318207577
0.0954657562108
0.0902133020706
0.0844823715885
0.0781587095501
0.0710743867968
0.0629869419501
0.0535492980664
0.0423131175673
0.028578758124
0.0126796725178
0.137061780382
0.13707469527
0.137100288809
0.137137928494
0.137186106408
0.137243774534
0.137313163277
0.137393413834
0.13748456498
0.137603269238
0.137744653621
0.137889239234
0.138080847245
0.138290993286
0.138497849874
0.138716474772
0.138972538717
0.139234842935
0.139508647924
0.139823284469
0.140152722854
0.140503916434
0.14089278553
0.141295525554
0.141740828747
0.142214855252
0.14273422843
0.143289182043
0.143887052616
0.144539409066
0.145245647027
0.146008645322
0.146833350559
0.14770189035
0.148591862418
0.149501932564
0.150449467031
0.151446409312
0.152495911603
0.153586288064
0.154667785147
0.155022966344
0.156200632025
0.156261199499
0.156174311524
0.155888231031
0.155279678607
0.154383152888
0.153249029819
0.15191693306
0.150421282648
0.148789496046
0.147040678359
0.145186594019
0.143233172979
0.141181866003
0.139030750686
0.136775377744
0.134409381907
0.13192490743
0.12931289413
0.126563274049
0.123665138614
0.120606934304
0.117376703124
0.113962305974
0.110351470986
0.10653142621
0.102487812283
0.098202493926
0.0936497623495
0.0887900774843
0.0835599704218
0.0778555998726
0.0715053594233
0.0642300299027
0.055571101684
0.0448531122758
0.0311385319612
0.0137986229201
0.136244473033
0.136256903389
0.136285114571
0.136319615023
0.136361177251
0.136414965769
0.13648037493
0.136558017684
0.136645346999
0.136754127675
0.136891927802
0.137035260215
0.137203660867
0.137415338733
0.137621310948
0.137829714151
0.138075258531
0.138334842856
0.138598830533
0.138895909377
0.139217108099
0.139551538369
0.139928176781
0.140319851141
0.140742451724
0.141200785157
0.141695193006
0.142229699329
0.142804032038
0.143425518766
0.144104333914
0.144833494295
0.145623239403
0.146471505121
0.147378767618
0.1483296609
0.149326494848
0.150374288427
0.151471960088
0.152582451095
0.153608418188
0.153813404483
0.154681672705
0.154953074122
0.154809230598
0.154367546084
0.153611612911
0.152574116951
0.151309884773
0.149863313862
0.148268820808
0.146551943525
0.144729499556
0.142811013717
0.140800522345
0.138698094901
0.136500989291
0.134204492353
0.131802511549
0.129287991544
0.126653215527
0.123890057353
0.120990268331
0.117945872755
0.114749681954
0.111395825237
0.107880089438
0.104199789971
0.100352880856
0.0963359807146
0.0921409148784
0.0877489722079
0.0831214586421
0.0781829654441
0.0727898863741
0.0666717258105
0.0592846927209
0.0496347389488
0.0358620456496
0.0150429397982
0.135407044475
0.135416661208
0.135438014262
0.135467166922
0.135510169852
0.135564835984
0.135629474522
0.135705255486
0.135788349066
0.135886749895
0.136015921933
0.136162809754
0.136310990964
0.136508763836
0.136720260807
0.1369242875
0.137148841277
0.137405854449
0.137664980832
0.137939148141
0.138250494177
0.138570843955
0.138924705928
0.139308181487
0.139704201509
0.140146331502
0.140616044263
0.141128079289
0.141677347547
0.142270248437
0.142920038734
0.143623921594
0.144388725728
0.145218901485
0.146121065196
0.147098449117
0.14814967255
0.149283866917
0.15051191941
0.151813682079
0.153256147405
0.153407222972
0.153440701883
0.153657407428
0.153393902057
0.15277126253
0.151848545226
0.150665840438
0.149277013855
0.147725776026
0.146043994548
0.144253910924
0.142369279528
0.140397100735
0.138339527902
0.136195412697
0.133961425902
0.131632845626
0.129204105069
0.126669192502
0.12402196859
0.121256486358
0.1183674242
0.115350721813
0.112204403087
0.108929424093
0.105530273515
0.102015032375
0.0983946689474
0.0946814113871
0.0908861145084
0.0870142637622
0.0830601783901
0.078996924391
0.074758171999
0.0701999451036
0.06497966611
0.0583767888189
0.0477462188497
0.0246891123621
0.134553757919
0.134561115947
0.134575743022
0.134595499932
0.134643168621
0.134699869485
0.134763934276
0.134837120262
0.134915492511
0.135004773572
0.135121785071
0.135265354554
0.13541210138
0.135581008477
0.135792083654
0.13599817781
0.136204305213
0.136447653002
0.136703288151
0.136959943359
0.137252689553
0.137564426862
0.137889878886
0.138256601085
0.138637381974
0.139050000498
0.139500273391
0.139986621416
0.140511199135
0.141077495837
0.141696530692
0.142374660151
0.143116013449
0.143928615805
0.144821279157
0.145804789424
0.146894100502
0.148097951478
0.149449762334
0.150885424601
0.152444168696
0.152809813218
0.152502912895
0.152397729361
0.151899363404
0.151074192141
0.14997862917
0.14865361008
0.147149719019
0.145506178255
0.143750052875
0.14189920699
0.13996387883
0.137948477431
0.13585342083
0.133676582858
0.131414309875
0.129062122068
0.126615202929
0.124068780425
0.12141846419
0.118660646345
0.115793110407
0.112815943126
0.109732680824
0.106551431458
0.103285622724
0.0999540807974
0.0965803267338
0.0931911482541
0.0898147460208
0.0864786181753
0.0832080655429
0.0800244824799
0.0769473540944
0.0739969720443
0.0711968698013
0.0687079391215
0.0664020961428
0.0674779664429
0.133687714742
0.133695953499
0.133713748717
0.133734627737
0.133774116824
0.133827805018
0.133889205808
0.133958273873
0.134033105243
0.134114963651
0.134216279753
0.134348104691
0.134498754007
0.13464874475
0.13483654442
0.135047402647
0.135247032531
0.135461886908
0.135713441833
0.135961790818
0.136225113936
0.136527083132
0.136835397097
0.137175060357
0.13754297649
0.137926663728
0.138349590466
0.138806759729
0.139303201516
0.139839595751
0.14042620796
0.141074041709
0.141785328222
0.142570453022
0.143444479605
0.144416369925
0.145506672931
0.146734047143
0.148164803567
0.149650745508
0.151179345953
0.151725129081
0.151264899887
0.150967426985
0.150242566972
0.149226191675
0.147975075366
0.146525281986
0.144923572261
0.143204159882
0.141388705503
0.139490440957
0.137516145919
0.135467879258
0.133344641233
0.131143651628
0.128861223528
0.126493363587
0.124036199843
0.121486349655
0.118841281734
0.116099814283
0.113262931917
0.110335005134
0.107325245185
0.10424899842
0.101128439555
0.0979923857711
0.0948752550969
0.0918154211478
0.0888535737794
0.0860314928009
0.0833929323367
0.080985673458
0.0788734192276
0.0771467562091
0.0759613984535
0.0756400027348
0.0764282679769
0.0802349077372
0.132809643698
0.132819177774
0.132840213764
0.132873360153
0.132902215922
0.132951435717
0.133009462362
0.13307430306
0.133146123782
0.133220182287
0.133305660354
0.133418094324
0.133558500623
0.133707360699
0.133865912861
0.13406688084
0.134272297467
0.134468503881
0.134698103503
0.134943610028
0.135186942973
0.135464638999
0.135762678859
0.136075323437
0.136417686059
0.136780109526
0.13716926082
0.137596721803
0.138056164032
0.13855583002
0.139106400291
0.139712233223
0.140380970057
0.141122894663
0.141955748787
0.142892876002
0.143954564799
0.145156848084
0.146596014518
0.148052830073
0.149481881599
0.150186931778
0.149611893126
0.149229596036
0.148349928444
0.147185057928
0.145813631234
0.144269020796
0.142594144753
0.140819246747
0.138961429198
0.137029908753
0.135028576077
0.132957678487
0.130815273899
0.128598322754
0.12630341509
0.123927276663
0.121467143431
0.118921127995
0.116288613342
0.113570868733
0.110772114444
0.107901075564
0.104972700837
0.102009470151
0.0990417650844
0.0961070778403
0.0932482394561
0.0905110698101
0.0879422430398
0.0855876570602
0.0834934435666
0.0817073656129
0.0802934541886
0.0793316291754
0.0789721022171
0.0794654479415
0.0810486131412
0.0843185496302
0.131925477166
0.131934507414
0.131952023154
0.13199349052
0.132026404662
0.132072164729
0.132126704773
0.132187087645
0.132254295795
0.132322019446
0.132396016323
0.132485935353
0.132606487133
0.132750258972
0.13289727341
0.133064302744
0.133268587729
0.133468164845
0.133668263339
0.133902252381
0.134140577124
0.134387580702
0.134665380903
0.134956164042
0.135269248173
0.135606206791
0.135964885866
0.136354760066
0.136777090933
0.137236351569
0.137736182634
0.138286455802
0.138895812861
0.139576135625
0.140342205431
0.141211248905
0.142204130605
0.143347759693
0.144748854369
0.146140957155
0.14748090155
0.148256206576
0.14756457444
0.147139111405
0.146181908545
0.144926183366
0.143480161538
0.141878531101
0.14016024352
0.138352934953
0.136470870654
0.134520570772
0.132504022945
0.130420425243
0.128267475681
0.126042308181
0.123742098978
0.121364504349
0.118907997924
0.116372253425
0.113758576573
0.111070667692
0.108315984559
0.105507654169
0.102666378423
0.0998215489318
0.0970109985635
0.0942792888611
0.0916749124607
0.0892469261178
0.087041871434
0.0851008007781
0.0834587430351
0.0821423233839
0.0811830491559
0.0805963649339
0.0804774333093
0.0809238353587
0.0820226367581
0.0837524758389
0.131040949388
0.131049580356
0.131066449183
0.13110659136
0.131152714373
0.131192240412
0.131240789732
0.131294961515
0.13135530691
0.131419422875
0.131485271989
0.131560031491
0.131655828471
0.131781349123
0.13192620396
0.132070509033
0.132246581713
0.132445183881
0.132634013168
0.132839634567
0.13306877639
0.133298815892
0.133547198944
0.133816448408
0.134101463873
0.134405555071
0.134732962165
0.135083495195
0.135467033933
0.135878575639
0.136319888824
0.136804862922
0.137336569125
0.137928908484
0.138591506632
0.139346037175
0.140215933633
0.141225384493
0.142452976762
0.143803805642
0.145092223156
0.145923249478
0.145098756274
0.144656965971
0.143715038582
0.142442237838
0.140974695246
0.139357111378
0.137626765231
0.135810557656
0.13392208451
0.131966899081
0.129946300957
0.127859294714
0.125703821537
0.123477607501
0.121178693825
0.118805843054
0.116358858237
0.113839003275
0.111249477742
0.108596367276
0.105890369785
0.103149082318
0.100398979336
0.0976760881289
0.0950248282987
0.0924951429982
0.0901385764767
0.0880039307864
0.086133462724
0.08455867592
0.0832984792947
0.0823512126281
0.0816993941526
0.0812608504112
0.0810704164358
0.0810057695343
0.0811965413916
0.0823545694738
0.130148740573
0.130156552894
0.130175176537
0.130204227772
0.130254615763
0.130298698302
0.130346206141
0.130395067439
0.13044848589
0.130508834752
0.130568365843
0.130634723287
0.130709129745
0.130809679699
0.130939790861
0.131083137545
0.131230870989
0.131409079527
0.131595302374
0.13177921971
0.131978421705
0.132196709434
0.132421512579
0.132661285137
0.132918138214
0.133192068384
0.133481290498
0.133792677929
0.134123752963
0.134476554036
0.134849481287
0.135254465902
0.135694002519
0.13617328448
0.136698767973
0.137285852999
0.137946685394
0.138671572959
0.139422450725
0.140444308736
0.14152146467
0.14291310859
0.142187718108
0.14179342989
0.140965993617
0.139756122149
0.138318902218
0.136721987449
0.135007035444
0.133202526282
0.131323250002
0.129375341921
0.127360517725
0.125278342078
0.123127510107
0.120906681523
0.118614977267
0.116252390917
0.113820103572
0.11132096503
0.108760011401
0.106145662331
0.103491892799
0.100820898426
0.0981649850533
0.0955665206944
0.09307558644
0.0907458056287
0.0886293428463
0.0867718701461
0.0852087055974
0.0839607780077
0.0830351412636
0.0824144764944
0.0820578386929
0.0818346414373
0.0817271390882
0.0810620312577
0.0807513941686
0.081876474292
0.129238730373
0.129243071806
0.129257455535
0.12927449193
0.12931806056
0.129377211573
0.129433993571
0.129482101689
0.12953119933
0.129586299844
0.129643924915
0.129701377145
0.129767440354
0.12984356027
0.129948056473
0.130081235697
0.130220813639
0.130370364552
0.130542612441
0.13072000438
0.13089481359
0.131081994176
0.131288418001
0.131500338165
0.131725398746
0.131965057072
0.132214467554
0.132474647525
0.132745221592
0.133027659969
0.13332330333
0.133638243157
0.133977090426
0.134332585145
0.13470739962
0.135106264986
0.135491440151
0.135807257441
0.135973078669
0.135443718516
0.136348056858
0.139054153578
0.138994228986
0.138721483987
0.138039569832
0.136934211419
0.135558084412
0.134003952584
0.132322135642
0.130543756171
0.128685293839
0.126754125939
0.124752996612
0.122682494537
0.120542392673
0.118332500908
0.116053147387
0.113705621372
0.111292485703
0.108818143553
0.106289390151
0.103716942298
0.101118153491
0.0985200353426
0.0959608379314
0.0934889655337
0.091159203014
0.0890271918785
0.087143471734
0.0855479447445
0.0842661844377
0.0833060626442
0.082662619946
0.0823089751447
0.0822353165211
0.0824484410621
0.083005998911
0.0818471746817
0.082502424172
0.0822260672245
0.128315852187
0.128314516524
0.128319732611
0.128332723557
0.128365128052
0.128424656285
0.128491550575
0.128547706005
0.128599565165
0.128652745131
0.128710701435
0.128765949883
0.128827689315
0.128892802618
0.128973113605
0.129077731465
0.129208693443
0.129342852664
0.129488179391
0.129650224158
0.129815735188
0.12997750186
0.130149866421
0.130337149323
0.130530197266
0.130727301832
0.130929836258
0.131133658846
0.131344320654
0.131556199403
0.131778436445
0.132001232581
0.132229049629
0.132460569261
0.132699415555
0.132926066881
0.133103131152
0.133167492387
0.132976924064
0.132096232226
0.132679838702
0.135121478476
0.135837556079
0.135701640009
0.135095988007
0.134065820048
0.132746231397
0.13123813765
0.129595826302
0.127850948352
0.126020427647
0.124112469507
0.122130855788
0.120077327393
0.117952855862
0.115758489027
0.113495802237
0.111167388475
0.108777155162
0.106331005862
0.103837405678
0.101309365058
0.0987678076686
0.0962448781429
0.0937849212341
0.0914420305591
0.0892746909435
0.0873390030721
0.08568208413
0.0843363667178
0.0833161521392
0.0826134157314
0.0822008154901
0.0820139105658
0.0820428180868
0.0822621642412
0.0826739924218
0.0844180043974
0.0827687464508
0.0822971561505
0.127394920248
0.127388380457
0.127387221967
0.127397513703
0.127418622247
0.127460361042
0.127523706732
0.127595059489
0.127656021574
0.127712926582
0.127770576264
0.127829305347
0.127883864765
0.127947945622
0.128014583387
0.128096586998
0.128198336813
0.1283212158
0.12844791326
0.128582994796
0.128730096028
0.12887930523
0.129025201454
0.129177126565
0.129336026222
0.12949229954
0.129644386678
0.129798417459
0.12994715349
0.130093948119
0.130228190437
0.130352660663
0.130470807732
0.13059169417
0.130717404557
0.130844347086
0.13101043495
0.131286465103
0.132026057281
0.132008688558
0.132182051705
0.132253536851
0.133039043397
0.132880973023
0.132233051586
0.131210793851
0.129921521473
0.128451597626
0.126848281398
0.125139447426
0.123340523666
0.121459700201
0.119501505184
0.117468763153
0.115363633899
0.113188401014
0.110945861497
0.108639878089
0.106275633691
0.103860469675
0.101404426714
0.0989228594277
0.09644056386
0.0939952310504
0.091637443253
0.0894265137603
0.0874234498692
0.0856831576868
0.0842477083153
0.0831414245808
0.0823693105225
0.0819129688801
0.0817302489231
0.081728741019
0.0818661528339
0.0818186188769
0.0819881075685
0.0824902818956
0.0820411686692
0.0818181292952
0.126482600052
0.126474568419
0.126471790372
0.126476792339
0.126490659452
0.126515921148
0.126564643751
0.126640937505
0.126710502313
0.126772207489
0.126830502717
0.126889470089
0.126944122572
0.126999813853
0.127062774977
0.127126939459
0.127203678114
0.12729915196
0.127413237092
0.127529244791
0.127652755888
0.127777323974
0.127907641971
0.128028661959
0.128147997638
0.128264574008
0.128374336027
0.128474301425
0.128561195624
0.1286260514
0.128668345381
0.128702693376
0.128721949163
0.128730078802
0.128727577531
0.128730431204
0.128761016579
0.128855941115
0.128265298248
0.13135079155
0.131550125394
0.130798270835
0.130667289166
0.130182186614
0.129414458378
0.128367529905
0.12709495993
0.125658817574
0.124093860043
0.122422013053
0.120656377653
0.118804769149
0.116872301632
0.11486281733
0.112779616332
0.110626176694
0.108406452585
0.106125518808
0.103789742638
0.10140784226
0.0989913402168
0.096558060661
0.0941371037062
0.091772203556
0.0895202753324
0.0874452085794
0.085609117212
0.0840637071628
0.0828436812116
0.0819631261586
0.0814169064179
0.081179726938
0.0812230298255
0.0815240201295
0.0820663411354
0.0817352102555
0.0819750609501
0.0816949854555
0.081393939605
0.0812401990648
0.125575443974
0.125572832252
0.12557056702
0.125572476319
0.12557999746
0.125595700403
0.125627595139
0.12569257818
0.125768966494
0.125835399848
0.125895551128
0.125952614766
0.126009556969
0.126060682048
0.126115723243
0.126167369895
0.126224819777
0.126299051793
0.126385217602
0.126483078082
0.126589608352
0.126692213579
0.126791318737
0.126886921539
0.126970126889
0.127045082882
0.127110775494
0.127153660443
0.127169552296
0.127155661415
0.127128840793
0.127070712913
0.126977998086
0.126850235195
0.126691728717
0.126525294267
0.126373587426
0.12634851566
0.124893266267
0.12697101138
0.128917123798
0.128211197056
0.12795645949
0.12735544909
0.12654492459
0.12550835553
0.12426641983
0.122869101607
0.121344228315
0.119709968753
0.117978029359
0.116156236187
0.114250410236
0.112265425051
0.110205678391
0.108075787623
0.105880776859
0.103626864847
0.101321496676
0.0989747189241
0.0965994434303
0.0942161867612
0.0918589204562
0.0895779722456
0.0874365891227
0.0855024405179
0.0838372710548
0.0824877422689
0.0814790330174
0.0808117662385
0.0804628686952
0.0803841236679
0.0805441088594
0.0809195291449
0.0814662461981
0.0826183002169
0.0814387225944
0.0809950569305
0.0807377875865
0.0806215113348
0.124678667154
0.124683576618
0.124683065176
0.124683787296
0.124687046992
0.124695725507
0.124716668684
0.124757999075
0.124830502013
0.124903735119
0.124967646622
0.125024918729
0.125078513343
0.12512968465
0.125172739039
0.125222228974
0.125267838105
0.125323769014
0.125385627903
0.125458381099
0.125538732412
0.125623951618
0.125692577576
0.125754065082
0.125802753729
0.125839372408
0.125854060573
0.125839861148
0.125791264881
0.125722859679
0.12561529594
0.125452522008
0.125234399867
0.124956043588
0.124621870063
0.124264018241
0.123951851888
0.124171655584
0.122240909201
0.123127876764
0.124724389481
0.124690448001
0.124807386776
0.124362972108
0.12361863624
0.122639621664
0.121447994915
0.120096000295
0.118612254438
0.117014731194
0.115315267806
0.113522344954
0.111642704231
0.109682280405
0.107646508024
0.105541072299
0.103371957683
0.101146456072
0.0988729705172
0.0965628501835
0.0942303022108
0.0918988787077
0.0896081175349
0.0874154685183
0.0853902974921
0.0836029818108
0.0821133729923
0.0809618670724
0.0801640837893
0.0797088922721
0.0795569006875
0.07963487591
0.0798721729534
0.0801290698196
0.0806515575207
0.0808056648158
0.0804375964282
0.080188685691
0.0800315693754
0.0799586272856
0.12380340619
0.123808115776
0.123808637804
0.123807474944
0.12380809121
0.123811926797
0.123825152766
0.123851336118
0.123901918889
0.123977397
0.12404823676
0.124107822821
0.124159480139
0.124206119563
0.124245656016
0.124284664453
0.124328083924
0.124363898942
0.124409138812
0.124458530564
0.124511982472
0.124567781865
0.124611328869
0.124638751022
0.124652601666
0.124648957629
0.124618715526
0.124551875483
0.124457913986
0.124321839815
0.124123692197
0.123858328336
0.123515821684
0.123085169116
0.12256315986
0.121984428694
0.121424435214
0.121453444271
0.119430869987
0.119735552414
0.120547125257
0.121042534346
0.12155514575
0.121349654556
0.120707770934
0.119801294063
0.118665625146
0.117358513313
0.115912668432
0.114348052199
0.112677618957
0.110910882036
0.109055575021
0.107118635974
0.10510641402
0.103025558225
0.100882875657
0.0986866623071
0.0964461454222
0.094173985232
0.0918855829716
0.0896080238369
0.0873872184397
0.0852881655396
0.0833857730319
0.081751521533
0.0804412243828
0.0794870793209
0.078894732045
0.0786454067454
0.078701245652
0.0790114839536
0.0794765850258
0.0795242146479
0.0797160804819
0.0796825895073
0.0795137797997
0.0793816677235
0.0792933216603
0.0792502221349
0.122948954962
0.122946675897
0.122945843636
0.122942372495
0.12294050754
0.122941473138
0.122946940954
0.122965598999
0.123001157052
0.12305996092
0.123136480243
0.123201741654
0.123254615498
0.123298732251
0.123337168557
0.123367913015
0.123396619456
0.123423860883
0.123450116802
0.123480799502
0.123508826929
0.123533392726
0.123547698015
0.123545241976
0.123525916077
0.123482119578
0.123408332755
0.123300821315
0.123150890896
0.122941141475
0.122664296836
0.122307548557
0.121855409677
0.121289084756
0.120591745706
0.119763369944
0.118758342471
0.117824852851
0.115892926852
0.11663491605
0.117737530552
0.117975411831
0.118502046812
0.118458301947
0.117894101323
0.117041973521
0.115949741848
0.114677269843
0.113260325357
0.11172110781
0.110073777176
0.108328771921
0.106494617537
0.10457904692
0.102589109265
0.100532272528
0.0984159952957
0.0962495179718
0.0940427421184
0.0918096963981
0.0895668587693
0.0873455440777
0.0851989384237
0.0831998678044
0.0814278552162
0.0799534662435
0.0788256687051
0.0780647716519
0.0776619148202
0.077586822256
0.0777975119538
0.0782312599363
0.0787850869313
0.0796783236919
0.0789345352645
0.0787375971198
0.0786167999125
0.0785478325088
0.0785052964104
0.0784783613288
0.12210738602
0.12209924523
0.122094899554
0.12209090728
0.122088176442
0.12208854668
0.122092270823
0.122101814245
0.12212991587
0.122168953229
0.122231024516
0.122302458574
0.122360817918
0.122406580625
0.122442100921
0.122469990448
0.12248766799
0.122502185639
0.122514809525
0.122524247668
0.122526426134
0.122521389223
0.122507175062
0.122476898048
0.122422414134
0.122339708089
0.122223846533
0.122069491961
0.121861208616
0.121592234338
0.121250940905
0.120822283444
0.120287892975
0.119625955228
0.118806237669
0.117780425365
0.116444360104
0.114835509526
0.113314730952
0.113461576061
0.114940251706
0.115338481967
0.115756437417
0.115773166816
0.115237704489
0.114402615656
0.113327047944
0.112070127064
0.11066773576
0.109143064457
0.10751073521
0.105781518277
0.103964249672
0.102067093319
0.10009749344
0.0980635581933
0.0959731970322
0.0938365576856
0.0916640490104
0.0894711930725
0.087275396466
0.0851131475868
0.0830458459635
0.0811541845914
0.0795210674075
0.0782141737032
0.0772735297619
0.0767050850429
0.0764825000117
0.0765562863843
0.0768547928903
0.0772921553296
0.0779841272287
0.0780161701095
0.0778170301339
0.07772729042
0.0776831205882
0.0776657107934
0.0776559880732
0.0776455724012
0.121272716402
0.121264410148
0.12125927762
0.12125904551
0.121259731049
0.121262141231
0.121266489669
0.121272538647
0.121286878685
0.121316944685
0.121353616126
0.121411862894
0.121471641174
0.121523027518
0.121559669832
0.121583936202
0.121598125769
0.121599841308
0.121595891229
0.121584272331
0.121563708417
0.121532759803
0.121490474388
0.121428342556
0.121338375136
0.121216947466
0.121058372468
0.120855769779
0.120599520919
0.120281609808
0.119889822192
0.119410327544
0.118827480427
0.118115894322
0.117225112304
0.116076926386
0.114578351404
0.112546077783
0.111897383034
0.110805275195
0.112410158861
0.113153602762
0.113403731109
0.113360562911
0.112780865498
0.111910908399
0.110815154354
0.109548492873
0.108142732959
0.106619645139
0.104992908447
0.103272660632
0.101467361566
0.0995851385657
0.0976334696649
0.0956209188783
0.0935556292852
0.0914486635653
0.0893107526545
0.0871591316781
0.0850119402621
0.0829120974274
0.0809300896497
0.0791540931834
0.0776685266115
0.0765356702172
0.0757847729621
0.0754096748186
0.0753765481403
0.0756180044761
0.0760130928696
0.0764455597956
0.0767249562528
0.0767515627307
0.0767078932334
0.0766956598319
0.0767100055784
0.0767328902229
0.0767469466055
0.0767568133897
0.120461359579
0.120453955709
0.120456105471
0.120462654251
0.120469074479
0.120474104794
0.120477990746
0.120480984019
0.120483522774
0.120501209245
0.120523500962
0.120553009816
0.120591362795
0.120646519756
0.120685988994
0.120710865432
0.12071891779
0.120713035801
0.120692460952
0.120661143353
0.120617610345
0.120561193253
0.120490148899
0.120394448345
0.120269332884
0.120110479585
0.119911262402
0.119666027614
0.119367533651
0.119009016251
0.118581339767
0.118073863301
0.117474101265
0.116752517674
0.115854314918
0.114733300149
0.113299555274
0.111105621128
0.111452771427
0.109886312472
0.110661812052
0.111533480662
0.111494090434
0.111248898177
0.110537009711
0.109574208161
0.10841795194
0.107114432473
0.105686703279
0.10415206838
0.102521509434
0.100803407375
0.0990050948922
0.0971341849826
0.0951978342681
0.0932049171699
0.09116359817
0.0890859357663
0.0869827770339
0.0848734168934
0.0827764654003
0.0807429433595
0.078853178616
0.0772020512947
0.0758729586946
0.0749187087283
0.074352759976
0.074155362305
0.0742921370658
0.0746866849576
0.0751935715531
0.0759048310777
0.075621760886
0.0755894923104
0.0755917640966
0.0756229599808
0.0756716509409
0.0757244674821
0.0757512260752
0.075772551872
0.119710114091
0.119708575184
0.11971449356
0.119722817307
0.119730679146
0.119734698961
0.119734513875
0.11973065446
0.119723399776
0.119718463272
0.119729610648
0.119746340778
0.119766295162
0.119792406981
0.119823236554
0.119846964323
0.119851865296
0.119836016112
0.119805247511
0.119753595471
0.119687452137
0.119605671743
0.119504590518
0.119375916388
0.119216375556
0.119021223727
0.11878387988
0.118499132407
0.118162935175
0.117770897938
0.117317219127
0.116794455764
0.116196605809
0.115493497861
0.114672504394
0.113701529083
0.112493060146
0.110549938558
0.111661758809
0.109860467969
0.109718013028
0.110447428475
0.109990184925
0.109411011383
0.108483340296
0.107375797488
0.106123442652
0.104759400631
0.103293878851
0.101736688468
0.10009439289
0.098372588341
0.0965768425402
0.0947138828818
0.0927902741584
0.0908151485363
0.0887965099351
0.0867475995911
0.0846791443042
0.082613004884
0.0805678862753
0.0786050866084
0.0768153033678
0.0752990975567
0.0741363610961
0.0733675907784
0.0729883200166
0.0729546679759
0.0731779725327
0.073568230958
0.074405734038
0.0744069844631
0.074369282092
0.0743852710751
0.0744251072236
0.074477959136
0.0745328035424
0.0745918651198
0.0746262133329
0.0746398237038
0.119019939683
0.119028462987
0.119033913672
0.119041130007
0.119045955932
0.11904442028
0.11903609696
0.119021902685
0.119002934619
0.118979215153
0.118966020147
0.118970914015
0.11898915974
0.118990172231
0.118996081138
0.118999257014
0.118994705707
0.118972071393
0.118928972019
0.11886120943
0.118773571054
0.118665972911
0.118533576406
0.118372411052
0.118179474916
0.117948876427
0.117675118595
0.117353265318
0.11698176438
0.116559379133
0.116081579001
0.115543128071
0.114943176296
0.114284804594
0.113593503892
0.112856446625
0.112067342214
0.110822311321
0.112346140313
0.110508407895
0.109426869038
0.109747708893
0.108781546121
0.107770095564
0.106562203575
0.105274957262
0.103903886772
0.102464629618
0.100951827051
0.0993654863565
0.0977064909071
0.0959770106561
0.0941805202541
0.0923227230604
0.0904094886647
0.0884503010657
0.0864528742811
0.0844319589969
0.0823978754485
0.0803757488554
0.07838381577
0.076496401978
0.0748145650672
0.0734427924532
0.0724542853085
0.0718768124893
0.0716964825352
0.0718556924684
0.0722119934641
0.0725604736049
0.0729869396311
0.0730727408547
0.0731072138359
0.0731512325698
0.0732042422187
0.0732579204713
0.073303476812
0.0733432146215
0.0733780651314
0.0733786737792
0.118357197364
0.118376820631
0.118388908785
0.118399642753
0.118401422547
0.118392729482
0.118374578219
0.118348803537
0.118317252385
0.118281407741
0.118243779269
0.118217641935
0.118214318438
0.118217681
0.118207016148
0.11818347055
0.118154992032
0.118116337994
0.118057321297
0.117977155605
0.117872929243
0.117736437834
0.117574810071
0.117383927263
0.117159528959
0.116895868123
0.116586752056
0.116228906614
0.115822823773
0.115367868691
0.114851855814
0.114274547725
0.113662694002
0.11305437139
0.112497886514
0.112066414249
0.111839403298
0.111647826368
0.113323455334
0.111676014316
0.109637513817
0.10921882233
0.107687288732
0.10619970556
0.104682331736
0.103208628756
0.101717876114
0.1002032982
0.0986433530589
0.0970275744258
0.0953509384868
0.0936122680243
0.0918131319166
0.0899584177833
0.0880534350479
0.0861082988129
0.0841303690367
0.0821364011765
0.0801359401905
0.0781583042911
0.0762204323526
0.0744131435651
0.0728469992484
0.0716276133058
0.0708173592891
0.0704295749488
0.0704297180939
0.0707067435827
0.0711643177029
0.0720917963332
0.0718348429348
0.0718210300896
0.0718412716874
0.0718851522856
0.0719369182335
0.0719859567481
0.0720256050711
0.0720526669976
0.0720786867423
0.0720870420432
0.117718043688
0.11774341488
0.117766461943
0.117781382308
0.117779717367
0.117764792677
0.117738458557
0.117702701758
0.117659551381
0.117611114925
0.117558355388
0.117504269605
0.117461255541
0.117438954351
0.117422008848
0.117389387465
0.117341285302
0.11727685985
0.117196477458
0.117099126247
0.11697467912
0.116818706496
0.116631263056
0.116413129626
0.116160067542
0.115863994066
0.115520134529
0.115125470455
0.114681786606
0.114174007386
0.113584810694
0.112951397867
0.112303439113
0.111694164664
0.111226014539
0.111068306885
0.111435152179
0.112704309095
0.114372746521
0.113001988071
0.110100359871
0.108512943933
0.10640851663
0.104507776508
0.102721058282
0.10109798108
0.0995166148654
0.0979456484023
0.096350320647
0.0947118876099
0.0930209053976
0.0912739645292
0.0894715750202
0.0876184223804
0.085719658627
0.0837865012233
0.0818259505859
0.0798574509664
0.0778892648188
0.0759561023977
0.0740724295691
0.0723499083241
0.070906430874
0.0698453982348
0.0692171201945
0.069021148924
0.0691757344326
0.0695196041998
0.0701279784074
0.0704458303863
0.0704646701225
0.0704912972162
0.0705272210641
0.0705753497141
0.0706268880247
0.0706745055142
0.0707133964984
0.0707394153832
0.0707607065079
0.0707768155577
0.117129084488
0.117143616008
0.117166269243
0.117174806768
0.11716779061
0.117148996788
0.117118917862
0.117076927524
0.117024869064
0.116964964749
0.116899013323
0.116828090143
0.11675535545
0.116692044844
0.116644278572
0.116605150696
0.116544109655
0.116461915404
0.11636093977
0.116237798417
0.116089901091
0.115914588335
0.115705457618
0.115462283158
0.115181374921
0.114855079299
0.114474691366
0.114040688153
0.113540465998
0.112944672312
0.112274445765
0.111558126024
0.110815948065
0.110110333632
0.109580810677
0.109468335134
0.110225788263
0.113283529154
0.115175605373
0.113558710996
0.110035802256
0.107043708954
0.104525106554
0.102454784148
0.100548946126
0.0988693386024
0.0972582655401
0.095668221272
0.094059502177
0.0924108444295
0.0907118774964
0.0889591377908
0.0871535318301
0.085300489659
0.083405634098
0.0814819036847
0.079535969477
0.0775908492768
0.0756528008339
0.073763445436
0.0719331686943
0.0702998068515
0.0689843772323
0.068084802481
0.067640250848
0.0676284919113
0.0679028017658
0.0683708498366
0.0691995933395
0.0691077492747
0.0691040425681
0.0691306356481
0.0691719711764
0.069223458781
0.0692764332756
0.0693252205535
0.0693657154371
0.0693918977117
0.0694147472656
0.0694343718516
0.116580098562
0.116579606562
0.116586143235
0.116585088651
0.11657269469
0.116549456897
0.116515075673
0.116468937455
0.116410980393
0.116341958912
0.116264343758
0.116180024348
0.116090038466
0.115998650079
0.115918282218
0.11584650812
0.115760225498
0.115664481613
0.115544805741
0.115399429342
0.115227317448
0.115029411789
0.114800839437
0.114533603104
0.114226823124
0.113866105779
0.113447214264
0.11296203074
0.112380715877
0.111702648603
0.110944401594
0.110105336578
0.109191355677
0.108250001434
0.10736420837
0.106728756424
0.106782563563
0.108405711479
0.114833119983
0.107728834842
0.107444740198
0.104254764852
0.10173483327
0.0998725339891
0.098092243602
0.0964907472066
0.0949286501633
0.0933651544519
0.0917687745513
0.0901238219088
0.0884236536444
0.0866674385459
0.084858181055
0.0830031017539
0.0811090219139
0.0791912712404
0.0772562216165
0.075331561249
0.0734205331512
0.0715736427488
0.0697950247355
0.0682548456016
0.0670710281783
0.0663365111225
0.0660763178693
0.0662053700114
0.0665412268891
0.067279651379
0.0674981398279
0.0675835493476
0.0676524777136
0.0677159690835
0.067775812344
0.0678366299969
0.0678943943285
0.0679463452353
0.0679908250856
0.0680209866833
0.0680463134383
0.0680662260847
0.116050387611
0.116042200394
0.116032276143
0.116027748502
0.116009655036
0.115978724622
0.115935555858
0.115881711512
0.115816787487
0.115740688613
0.115653007242
0.115556476505
0.115452266797
0.115340407537
0.115227789272
0.115113035326
0.115005888926
0.114885101158
0.114739641517
0.114577820307
0.114387399179
0.114168273338
0.113916021716
0.113627911208
0.113291778075
0.11289408726
0.112434536819
0.111888586577
0.111239046907
0.110484247455
0.109622262809
0.108624934378
0.107471772923
0.106157210637
0.104669969686
0.103054063795
0.101214640867
0.0987740230892
0.0929594636609
0.0976930001023
0.101407640382
0.0999935168985
0.0981210166689
0.0968260238678
0.0954056696396
0.0940041541781
0.0925559031423
0.0910547606138
0.0894901127567
0.0878586091985
0.0861611196448
0.0844015811895
0.082586479631
0.0807256491941
0.0788277803194
0.076911186587
0.0749819332623
0.0730736599079
0.0711852170059
0.0693787335231
0.0676492712479
0.0662058553461
0.0651550363223
0.0645909388247
0.0645152006
0.0647570307314
0.0652201753571
0.0660847630332
0.0660261965371
0.066109719601
0.0662034421768
0.0662906241221
0.0663691830839
0.0664421966165
0.0665080834868
0.0665652120086
0.0666127595193
0.0666514517899
0.0666821158504
0.0667033153803
0.11554406354
0.115533986846
0.11551707876
0.115507626593
0.115481557116
0.115440839211
0.11538674841
0.115320975247
0.11524495416
0.115158990458
0.115062451998
0.114954730071
0.11483589913
0.114705988483
0.114562768399
0.11441595825
0.114277188114
0.114126100801
0.113959343806
0.113776413791
0.113561251852
0.11332455863
0.113055929606
0.112742997159
0.112372079084
0.111947035524
0.111447392819
0.110847887617
0.110138909375
0.109311697397
0.10833521638
0.107154563366
0.105743535423
0.104038428834
0.102017393269
0.0996168091077
0.0965812810863
0.0917347559601
0.0897161308747
0.090674957757
0.0921011524163
0.0945228199111
0.0942489710061
0.093682311185
0.0926851925935
0.091518583974
0.0902030535554
0.0887746281205
0.0872466648885
0.0856297503165
0.0839333465708
0.0821668725911
0.0803409234193
0.0784683126708
0.0765601145676
0.074638042192
0.0727078102672
0.0708103768318
0.0689382316503
0.0671687864543
0.0654842421634
0.0641406345991
0.0632253931687
0.0628318924963
0.0628914794894
0.063218581115
0.0639893207289
0.0643987937855
0.06451336533
0.0646421477663
0.0647656442523
0.0648798377576
0.064980420172
0.0650715094901
0.0651525026442
0.0652219981753
0.0652784205521
0.0653253818504
0.0653578575063
0.0653749898298
0.115070866445
0.115061173934
0.115041454339
0.115022743485
0.114986596828
0.114934459377
0.114867961844
0.114789159012
0.114699677598
0.114600458157
0.114492300342
0.114373029218
0.114241379112
0.114095085947
0.113934276805
0.11376022859
0.113575761874
0.113392501273
0.113203761449
0.112988138285
0.112754858374
0.112503371199
0.112211696214
0.111866259415
0.111479661931
0.11103157977
0.110490000103
0.109850567468
0.109098117073
0.108196736573
0.107099007244
0.105762250591
0.10413244057
0.10213697416
0.0997697618918
0.0969186560419
0.0933530179116
0.0879828195864
0.0868563355133
0.0861888245762
0.0876880104445
0.0904669897971
0.0909954382751
0.0908622660424
0.0901476228857
0.0891528964221
0.0879397394783
0.0865674898177
0.0850655222176
0.0834547364827
0.0817515480232
0.0799701042819
0.0781249351663
0.0762317049579
0.0743042489562
0.0723678975433
0.0704280887377
0.0685345759549
0.066670856456
0.0649337726735
0.0632851223116
0.0620385830826
0.0612647557682
0.0610464880881
0.0611618250999
0.061588593687
0.0627218781572
0.0628251485799
0.0630074470282
0.0631833208901
0.0633444008682
0.0634923646636
0.0636237364376
0.0637407060712
0.0638438235093
0.0639320160675
0.064004393571
0.0640590338778
0.0640910603376
0.0640999848271
0.114632416924
0.11462444246
0.114600047314
0.114568958637
0.114522868471
0.114458015582
0.114377912724
0.114285448888
0.114182437081
0.114069660764
0.113947020836
0.113813878464
0.113667866223
0.113506944819
0.113330052412
0.113133788953
0.112916395845
0.112690499621
0.112461881127
0.112220934967
0.111970124082
0.111689695562
0.111367827116
0.111014903077
0.110620692148
0.110141091258
0.109572913489
0.108913023842
0.108118960875
0.107154052249
0.105972777666
0.104521387956
0.102733175456
0.100563618243
0.0980223211001
0.0950129599944
0.0914005809085
0.0863719650719
0.0862046818311
0.0858859842642
0.0861990171914
0.0880480689711
0.0885644346418
0.0885189068258
0.0879046097505
0.0869833992875
0.085817616692
0.0844686085713
0.0829709384884
0.0813502514538
0.0796269677881
0.077818359793
0.075942173991
0.0740164269759
0.0720580455183
0.0700960099475
0.0681359487997
0.0662383273568
0.0643754312847
0.062669438253
0.0610480360191
0.0598895143243
0.0592385755819
0.059159896351
0.0593753852008
0.0600205325806
0.0608543258498
0.061187196911
0.0614767577359
0.0617221474172
0.0619365355631
0.0621274505956
0.0623002744582
0.0624507573688
0.0625808462607
0.0626901233382
0.0627784211257
0.062841864724
0.0628811989037
0.0628948247467
0.114226868643
0.114220520429
0.114189424042
0.114148305472
0.114091254379
0.114010891853
0.113915259431
0.113808486186
0.113692319461
0.113566616431
0.113430243084
0.113281642406
0.113119039943
0.112941708825
0.112745897598
0.112526464721
0.112283986207
0.112023276111
0.111750890252
0.111473082201
0.111189852707
0.110884155787
0.110552748489
0.110199289385
0.109783842046
0.109286584711
0.108713288094
0.108041607695
0.107224878081
0.106220459131
0.104980859322
0.103459162084
0.101583991712
0.0993346735751
0.096749103356
0.0937619601765
0.0903292566323
0.0859096137104
0.0861564585842
0.0853146680855
0.0855553878574
0.0866514782363
0.0868073448233
0.0866285473544
0.0859763081007
0.0850399083081
0.0838643666941
0.0825008254387
0.0809808510525
0.0793299073287
0.077569479969
0.0757181905014
0.0737960610191
0.0718227644231
0.0698186868917
0.0678162340303
0.0658221919688
0.0639100043488
0.0620399926979
0.0603707868218
0.0587869986841
0.0577562212995
0.0572320416657
0.0570725788423
0.0572342505505
0.058904659277
0.0592335151102
0.0596030807305
0.0599495346072
0.0602599426991
0.0605399664532
0.0607863903166
0.061007366436
0.0611975575315
0.0613591410905
0.0614930880124
0.0615996604375
0.0616730445633
0.0617233312458
0.0617491292476
0.113856454162
0.11384803855
0.113813239432
0.1137684894
0.113692433067
0.113591800159
0.113478180057
0.113357339477
0.113229690372
0.113092957247
0.112944389819
0.112781398956
0.112601878733
0.112404129529
0.112184321861
0.111937151464
0.111663907409
0.111372237644
0.111066709737
0.110757316401
0.110441571264
0.110111825371
0.109773465703
0.109408888936
0.108980927277
0.108485224227
0.107915827656
0.107243331898
0.106417175816
0.105400880275
0.104150030033
0.102598692049
0.100680627177
0.0984237272877
0.0958749281692
0.0929878823771
0.0897720216348
0.0857759371105
0.0863039772213
0.0855212390459
0.085167072141
0.0857694310699
0.0855270051126
0.0851107067916
0.0843357240145
0.0833204837266
0.0820879766825
0.0806751994868
0.0791064280911
0.0774036429438
0.0755871374484
0.0736753731804
0.0716897066802
0.0696507250635
0.0675827208184
0.0655209358171
0.0634748036012
0.0615324749544
0.0596409544093
0.0580063470161
0.0564676725522
0.055666555103
0.0554817287451
0.0554849253489
0.0552122402971
0.05669527577
0.0573499953105
0.0579108987387
0.0583756468901
0.0587818531891
0.0591430909904
0.0594627696378
0.0597397041408
0.0599752374209
0.0601720631936
0.0603329080706
0.0604582673317
0.0605475585181
0.0606104486026
0.060646987682
0.113533717644
0.113514741696
0.11348176885
0.113432028488
0.113334619225
0.113221477783
0.113101237201
0.112978589268
0.112848519603
0.112704743858
0.1125428173
0.112359347699
0.112152052546
0.111919184965
0.111656248629
0.111361569856
0.11104713737
0.110725059152
0.110400082725
0.110070474387
0.109727683247
0.109381610968
0.109030525111
0.108650120124
0.108217632317
0.107728114266
0.107174864381
0.106523604853
0.105720747154
0.104724184975
0.10347205437
0.101914783712
0.100017481392
0.0978086345964
0.0953339505212
0.0925742840397
0.0895682216112
0.0859452506213
0.0865227987257
0.0858297752006
0.0850457051466
0.0851746522731
0.0845671858407
0.0838800555581
0.0829388540608
0.08180636174
0.080483732042
0.0789941757832
0.0773534594747
0.0755783645145
0.0736865515504
0.0716952424122
0.0696262730743
0.0675004561075
0.0653464845408
0.063201422721
0.0610797884188
0.0590856694228
0.0571504571245
0.0555322980733
0.0540001924211
0.0533933842559
0.0533717286774
0.0536461498148
0.0556199312738
0.055327408281
0.0557123204325
0.0562455357309
0.05678489428
0.0572957134856
0.0577495841297
0.0581524662264
0.0584964994887
0.0587844763197
0.0590206264642
0.0592102671768
0.0593547175892
0.0594638363705
0.0595384495059
0.0595834161588
0.11327136618
0.113238106199
0.113206954515
0.113153122359
0.11305028368
0.112933218313
0.112816201437
0.112696868751
0.112562329751
0.112403975434
0.112217422838
0.111999473022
0.111748712622
0.111465435175
0.111149014548
0.110805928196
0.110454590725
0.110101669909
0.109746634708
0.109385067091
0.109022969116
0.108667223299
0.108306422188
0.107920771061
0.107496916287
0.107032445645
0.106517544697
0.105900845937
0.105131417274
0.104159625276
0.102932342255
0.101427388554
0.099595854598
0.0974542349268
0.095072114754
0.0924345851387
0.0895942684635
0.0862466332165
0.0867513273064
0.0861757289556
0.0850654947389
0.0847247438927
0.0838096165305
0.0828605678813
0.0817389044465
0.0804719258603
0.0790404310706
0.0774553398566
0.0757246042021
0.0738593555076
0.0718738915109
0.0697835170643
0.0676097413376
0.0653730073964
0.0631067855685
0.0608484136662
0.0586211905233
0.0565458768724
0.0545393744506
0.0529274648074
0.0513971539129
0.0509574702722
0.0508018127812
0.0511103393317
0.052662037464
0.0530593025549
0.0537231167541
0.054444754755
0.0551408749745
0.0557864224415
0.056364469324
0.0568643666549
0.0572884108504
0.057638921089
0.0579205184119
0.0581421187863
0.0583098905716
0.058435995219
0.0585199988005
0.0585676627746
0.113058432522
0.11302071593
0.112984294456
0.112924041156
0.112819452293
0.112702879838
0.112595770925
0.112475440911
0.112326169252
0.112140943756
0.111917860739
0.111653931697
0.111349146934
0.111010424243
0.110641612286
0.110255851484
0.109867627729
0.109478066722
0.109084850278
0.108692061017
0.108313692899
0.107950325971
0.107592627658
0.10722207492
0.106829033969
0.106405774622
0.105931663095
0.105355374923
0.104630471894
0.103709155636
0.102554080609
0.101137352323
0.0993921527898
0.0973429725251
0.0950585749759
0.0925205918683
0.0897793642692
0.0865653490483
0.0869470406775
0.0865047891059
0.085158975865
0.0843260935516
0.0831560879891
0.0819833418868
0.080691467233
0.0792910987752
0.077745609491
0.0760552070375
0.0742220075303
0.0722521264073
0.0701563373904
0.0679475995407
0.0656461864213
0.0632715914264
0.060861982285
0.0584529266227
0.0560815239457
0.0538824658467
0.0517589528654
0.0501331759637
0.0486481833005
0.0485707448084
0.0485541670912
0.0486392623316
0.0501504343443
0.0507666719098
0.051603321541
0.0525443186397
0.0534570567204
0.0542777649301
0.0550008140623
0.0556179602937
0.0561349720647
0.0565580008398
0.0568913435267
0.0571496877401
0.0573452953692
0.0574882260484
0.0575829350371
0.0576313965584
0.112865499084
0.112833656975
0.112788901025
0.112709626547
0.112609656814
0.112521228494
0.112423112899
0.112290714684
0.112114324344
0.111886912469
0.111610240486
0.111284275126
0.110920095409
0.110529238705
0.110116681629
0.109695010702
0.109270073379
0.108842910333
0.108415814884
0.107998898019
0.107604644109
0.107238212504
0.106893522771
0.106550310452
0.106196918014
0.105822321481
0.105398066273
0.104876730232
0.104218394463
0.103382350574
0.10233158924
0.101027163237
0.0994006826517
0.0974714681688
0.0952910205688
0.0928289635805
0.0901090753917
0.0868101820576
0.0870486346739
0.0865992340353
0.0851948968166
0.0838633900829
0.082499304892
0.0811816685607
0.0797600697679
0.0782444744347
0.0765910877156
0.074793094092
0.0728499781515
0.0707643901579
0.0685437792542
0.0661983292599
0.0637458319214
0.0612039650879
0.0586142796022
0.0560081747483
0.0534436990406
0.0510630287165
0.0487562549349
0.0470535890122
0.0454929530747
0.0455647580485
0.045871553149
0.0482469505361
0.0478200644235
0.0483934044883
0.0493417866994
0.0505096434921
0.0517051054724
0.0527695590979
0.0536770248908
0.0544338162381
0.0550560907279
0.0555610508252
0.0559577782777
0.0562599400455
0.0564836081437
0.056641648667
0.0567483783356
0.056797422845
0.112680005485
0.11266242599
0.112618454061
0.112546275119
0.112474711985
0.112395258055
0.112279627323
0.112111908194
0.111883599686
0.111596207267
0.111262982733
0.110888077542
0.11048159279
0.110048619247
0.109596445318
0.109134382534
0.108668664106
0.108201970436
0.107737995606
0.107293439357
0.106883891888
0.106519392601
0.106197104487
0.105893831227
0.105591942419
0.105277299145
0.104916912019
0.104470462159
0.103896752453
0.103159726073
0.102236139806
0.101082614071
0.0996277199558
0.0978568796475
0.0957990966283
0.0934144101967
0.0906696216683
0.0869982008297
0.0870143285916
0.0861584039311
0.0847665088894
0.0831564707738
0.0817548448537
0.0804194869974
0.0789334280778
0.0773294794245
0.0755786937076
0.0736744065698
0.0716170653922
0.0694075935949
0.0670502431787
0.0645516781411
0.0619254938488
0.0591860835327
0.0563747834303
0.0535153488045
0.0506933577816
0.0480478995658
0.0454829666699
0.043683422028
0.041955575954
0.0419124397758
0.0423441076517
0.0441327884964
0.0445908913623
0.0455718188125
0.0468531350865
0.0483309420986
0.0498736892502
0.0512507137778
0.0523985254679
0.0533286335476
0.0540723504521
0.05466430797
0.0551278724719
0.0554792171106
0.0557354239881
0.0559076660252
0.0560252368264
0.0560788617897
0.112528419233
0.112521747919
0.112487946837
0.112436846067
0.112377210759
0.112274793572
0.112114346456
0.111894956474
0.11162134521
0.11129901427
0.110927957482
0.110510832901
0.110055256585
0.109570298019
0.109066702578
0.108553530396
0.108038038725
0.107527906017
0.107032744472
0.106567129568
0.106145848935
0.105790500473
0.10551406761
0.105270044902
0.105030133844
0.104779280624
0.104493471255
0.104132736778
0.103655577485
0.103037447317
0.102264649845
0.101279093565
0.100041085513
0.0985121080112
0.0966371171011
0.0944125783361
0.0918275859844
0.0887673348646
0.0869642554633
0.0818233683816
0.0830661944211
0.0822279801612
0.0810116649432
0.0797473319202
0.0782430970184
0.0765664515213
0.0747224306094
0.0727112673132
0.0705361889835
0.0681969848954
0.0656940598581
0.0630290953852
0.0602092674155
0.0572436473683
0.0541679328576
0.0509948171809
0.0478355404777
0.0447918200318
0.0418230146187
0.0398786811795
0.0381068624007
0.0384651560927
0.0389304178211
0.0401156519651
0.0410398332786
0.0424518517108
0.0441703187959
0.0460491502394
0.0479825604358
0.0497429703127
0.0511787615053
0.0523168264262
0.0532020627513
0.0538897155071
0.0544174713118
0.054812742724
0.0551018657661
0.0552945305632
0.0554201395689
0.0554863495364
0.112419170976
0.112414041489
0.112385452521
0.112342768214
0.112274765119
0.112132367309
0.111936591505
0.111691457762
0.111390282707
0.111031631514
0.110615209236
0.110143772011
0.109625149298
0.109072310665
0.108499107624
0.107923966512
0.107373584373
0.106849142245
0.106345156471
0.105866639274
0.105433563998
0.105089330343
0.104876377854
0.10469993618
0.104522158389
0.104336027238
0.10413117774
0.103866263082
0.103496064666
0.102997699117
0.102383397163
0.101587507503
0.100600811787
0.0993940644025
0.0978110086359
0.0957650908279
0.0932765031997
0.0900955465991
0.0864728586245
0.0798765542333
0.0815365373629
0.0815537973776
0.080528587539
0.0792942016234
0.0777550779412
0.0759914025123
0.0740428898462
0.0719182579109
0.0696215262489
0.0671494473158
0.0644963958986
0.0616563818378
0.0586269003244
0.0554083107767
0.0520246984439
0.0484799258665
0.0449044513497
0.0413103254477
0.0377252324756
0.0352532632016
0.0327620948238
0.0338308829163
0.0374775296907
0.0360270849267
0.0371128859056
0.03903065877
0.0413231701372
0.0437171758632
0.0460832763454
0.0482695522909
0.0500403123596
0.0514105233413
0.0524527091278
0.0532431027772
0.0538410668495
0.0542799163178
0.054594163087
0.0548063868592
0.0549415043343
0.0550182547355
0.112333393158
0.112323831568
0.112302849148
0.112264168002
0.112179700557
0.112010124138
0.111795218774
0.111523712985
0.111189958662
0.110789701778
0.110320256913
0.109782319125
0.109184551151
0.108543488976
0.107892116716
0.107281437511
0.106734786052
0.106220055833
0.105719410085
0.105237039362
0.104799145027
0.104453218368
0.104385216714
0.10426161343
0.104121355157
0.10398187857
0.103847032266
0.103678791252
0.103416470883
0.103013543494
0.102561331113
0.101958233656
0.101216226375
0.100395859342
0.0992678780416
0.0975973918514
0.0953845225955
0.0922795485856
0.08796789485
0.0798819769324
0.0811096549241
0.0815588547075
0.0805698390352
0.0792056173397
0.0775360629113
0.0756333402066
0.0735528964701
0.0713038897203
0.068883747148
0.0662812356095
0.0634810642714
0.0604658070772
0.0572183988153
0.0537231293819
0.0499816203935
0.045988427058
0.0418818292911
0.0376007524652
0.0334202496191
0.0303380487591
0.0261402889083
0.026789199472
0.0299083042226
0.0298671069274
0.0321998686665
0.0351957362693
0.0383513070611
0.0414082935615
0.0442714970119
0.046890156579
0.0490195804209
0.0506267772329
0.0518299792082
0.0527220615513
0.0533881439268
0.0538760360928
0.0542183315928
0.0544446657403
0.0545827148168
0.0546477993405
0.112281483841
0.112270638756
0.112248328786
0.112198283011
0.112096761101
0.111917522829
0.111685753709
0.111387899652
0.111020249619
0.110575406115
0.110047474336
0.109433745783
0.108740871039
0.108001962215
0.107284004358
0.106661626117
0.106141888846
0.105660011174
0.105184986117
0.10472488083
0.104321559769
0.104132487405
0.1039904648
0.103827899813
0.103736700932
0.103669418013
0.103606786995
0.103551962095
0.103427012371
0.10304291258
0.102778916112
0.102319661679
0.101765998786
0.101232181751
0.100829243491
0.099794716035
0.0984861110106
0.0958228020317
0.0919510207176
0.0826663171516
0.0825432901514
0.0826406593428
0.0813233108579
0.0795481837997
0.0775877013398
0.0754774486288
0.0732408453633
0.0708654429136
0.0683308617568
0.065612328378
0.0626820397188
0.0595085459388
0.0560560154585
0.0522828621029
0.048148650468
0.043605608812
0.0387204450332
0.0334016743661
0.0285636971213
0.0252656213111
0.0200127085141
0.0190446543648
0.0188174827293
0.0218431699425
0.0264983996847
0.0311579159537
0.035451866492
0.0392830351425
0.0426752108851
0.0456988391514
0.0481647496262
0.0499908097985
0.051340284434
0.0523289390997
0.05305185839
0.0535774074364
0.0539460130768
0.0541862069545
0.0543255096311
0.0543775407406
0.112256217314
0.11224527197
0.112207681435
0.112141613988
0.112038193989
0.111857098698
0.111612857632
0.111286735608
0.110885716299
0.110400663365
0.109821140008
0.109133747122
0.108339643367
0.107476966555
0.106637845658
0.105947046531
0.105458495156
0.105058752381
0.104687079952
0.104335829476
0.104121532162
0.104012819217
0.103905586952
0.103806037279
0.103726608927
0.103662595636
0.10361378439
0.103596035065
0.103537386762
0.103006770226
0.102804865498
0.102711270294
0.101982172603
0.101748175809
0.10164593556
0.101665200609
0.101584338657
0.101526593659
0.101080818615
0.0896347507348
0.0869758110661
0.084934121505
0.0825554642114
0.0801091000348
0.0777698382077
0.0754452387462
0.0730718454259
0.0705970607546
0.0679782819643
0.0651770088332
0.0621543943054
0.0588669990288
0.055262167263
0.0512715186741
0.0468039598869
0.0417268783728
0.0358967746686
0.0290047935402
0.0219134534907
0.014276112832
0.00472558174626
0.00918405927473
0.00241941925707
0.0121322485801
0.0206100230733
0.0274309465364
0.0329927415497
0.0375892720012
0.0414664117019
0.0448229089635
0.0475407087198
0.0495314455627
0.0509911172258
0.0520580553639
0.0528285432004
0.0533813620429
0.0537683343888
0.0540213244757
0.0541695813562
0.0542274438411
0.112246569884
0.112232124027
0.112174627569
0.112099244615
0.111995796944
0.111846797965
0.11160293474
0.11124625924
0.110828180581
0.110325513251
0.109713870301
0.108963386301
0.108053637984
0.107027610087
0.106162292061
0.105660869475
0.105310540995
0.104978508241
0.104645566032
0.104366712491
0.104180476778
0.104064229519
0.103953472435
0.103847104256
0.103753787449
0.103676784923
0.103608207551
0.103526247846
0.10334160772
0.103003252037
0.102767509227
0.102481436475
0.102117467652
0.101922159887
0.101833026379
0.101809885761
0.101773714498
0.101775065658
0.101894707139
0.101674781055
0.0935676784268
0.0871184774294
0.0833413928433
0.0804239362007
0.0778742443557
0.0754450156895
0.0730098871387
0.0704922342843
0.0678380802003
0.0650024839386
0.061941672158
0.0586069277945
0.0549380284402
0.0508538635781
0.0462372178527
0.0409025964511
0.0345423391063
0.026508039041
0.0157342322787
-0.00356911459122
-0.0218762443606
-0.00305813729278
0.00053604522154
0.00151243177175
0.016202391037
0.0249405660332
0.0315001553035
0.0366213551592
0.0408053495308
0.0443656583155
0.047224112579
0.0492969462448
0.0508098854567
0.0519202400152
0.0527203489968
0.0532885925859
0.0536833544764
0.0539436582519
0.0541034869063
0.0541686518705
)
;
boundaryField
{
frontAndBack
{
type empty;
}
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
}
// ************************************************************************* //
| |
f116ac3466109185e364322f4766b5d00af93c78 | 360b6bd4bd2800656b6bc08d97289f4608ff6b04 | /algorithm/1256 dp.cpp | 1ceed03ded08f74a125ef4de015166bfa6000381 | [] | no_license | dtc03012/solving | 100661541e3ea252c2c75308eb3e6fe1cb42a6b4 | aa773aafd85aa1267d9c65152ea5287e633e5193 | refs/heads/master | 2021-08-08T12:35:16.890021 | 2017-09-15T06:01:26 | 2017-09-15T06:01:26 | 110,227,919 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 652 | cpp | 1256 dp.cpp | #include <iostream>
#include <string>
#define M 1000000001
using namespace std;
int dp[222][112][112],n,m,k;
int main(void)
{
for(int e=1;e<=100;e++)
{
for(int p=0;p<=100;p++)
{
dp[e][p][0]=1;
for(int q=1;q<=e;q++) dp[e][p][q]=min(M,(p==0?0:dp[q][p-1][q])+dp[e][p][q-1]);
}
}
string tmp;
cin >> n >> m >> k;
if(dp[n][m][n]<k)
{
cout << "-1";
return 0;
}
while(n!=0&&m!=0)
{
for(int e=0;e<=n;e++)
{
if(dp[n][m][e]>=k)
{
for(int p=0;p<n-e;p++) tmp+="a";
k-=dp[n][m][e-1];
tmp+="z";
n=e;
m=m-1;
break;
}
}
}
for(int e=0;e<n;e++) tmp+="a";
for(int e=0;e<m;e++) tmp+="z";
cout << tmp;
}
|
1821e113903486032c2d17791c17f52d2080320f | 0e3cab0ba4802bf611323fb121e9d149bc121b5f | /Solutions/STUDVOTE.cpp | eeb304659515ea5f7b31c7bd5e97085d9bbe99cf | [
"MIT"
] | permissive | nikramakrishnan/codechef-solutions | e8ba0bf4def856ef0f46807726b46c72eececea9 | f7ab2199660275e972a387541ecfc24fd358e03e | refs/heads/master | 2020-06-01T23:13:27.072740 | 2017-06-16T08:10:38 | 2017-06-16T08:10:38 | 94,087,034 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 397 | cpp | STUDVOTE.cpp | #include<iostream>
using namespace std;
int main(){
ios::sync_with_stdio(false);
int t;
cin>>t;
while(t--){
int n,k,a;
cin>>n>>k;
int c[107]={0};
int finalc=0;
for(int i=1;i<=n;i++){
cin>>a;
if(a!=(i) && c[a]!=-1) c[a]++;
else if(a==i) c[i]=-1;
}
for(int i=1;i<=n;i++){
if(c[i]>=k && c[i]!=1) finalc++;
}
cout<<finalc<<endl;
}
}
|
74c0acd42d44eb2061f24291d720f12d79a05264 | 16b1f5629d580586273b7b88491289beb37eb6cd | /src/toml_settings.cpp | 3dfcdc6fa59d90c5cc6b75831fd34084c5f195fc | [
"MIT"
] | permissive | degarashi/sprinkler | b88095629ca493f168253ae6c5e4b57b6f1e52b6 | afc6301ae2c7185f514148100da63dcef94d7f00 | refs/heads/master | 2020-03-30T01:36:10.479283 | 2019-03-13T09:37:32 | 2019-03-13T09:37:32 | 150,584,179 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,268 | cpp | toml_settings.cpp | #include "toml_settings.hpp"
#include <QThread>
#include <QFileSystemWatcher>
#include <QFileInfo>
#include <QTimer>
#include <QDebug>
#include <QCoreApplication>
namespace dg {
void TomlLoader::loadToml(const QString& path) {
try {
auto table = toml::parse(path.toStdString());
emit loadSucceeded(path, std::move(table));
} catch(const std::exception& e) {
emit loadFailed(path, e.what());
}
}
namespace {
constexpr const int CheckInterval = 100;
}
TomlSettings::TomlSettings(const QString& path):
_thread(new QThread(this)),
_tomlLoader(new TomlLoader),
_watcher(new QFileSystemWatcher(this)),
_checkTimer(new QTimer(this)),
_first(true)
{
qRegisterMetaType<toml::table>("toml::table");
_thread->start();
_checkTimer->setInterval(CheckInterval);
connect(_checkTimer, &QTimer::timeout,
this, [this](){
Q_ASSERT(!_checkFile.empty());
QSet<QString> notyet;
for(auto&& cf : _checkFile) {
if(QFileInfo::exists(cf)) {
// 再度監視登録
_watcher->addPath(cf);
_loadToml(cf, false);
} else
notyet.insert(cf);
}
_checkFile.clear();
if(notyet.empty())
_checkTimer->stop();
else
_checkFile = notyet;
});
if(! _watcher->addPath(path))
throw std::runtime_error("Can't open Toml-settings file");
connect(_tomlLoader, &TomlLoader::loadSucceeded,
this, [this](const QString&, toml::table table){
std::lock_guard lk(_mutex);
_table = std::move(table);
_first = false;
qDebug() << "TomlLoader: loadSucceeded";
});
connect(_tomlLoader, &TomlLoader::loadFailed,
this, [this](const QString&, const QString& errMsg){
const auto stdstr = errMsg.toStdString();
std::lock_guard lk(_mutex);
if(_first)
throw std::runtime_error(stdstr);
_first = false;
qDebug() << "TomlLoader: loadFailed:\n" << stdstr.c_str();
});
connect(_watcher, &QFileSystemWatcher::fileChanged,
this, [this](const QString& path){
if(!QFileInfo::exists(path)) {
// 削除された場合は一定間隔で再度読み込みを試みる
_checkFile.insert(path);
_checkTimer->start();
} else {
_watcher->addPath(path);
// 新しく値を読む(Loaderに任せる)
_loadToml(path, false);
}
});
_tomlLoader->moveToThread(_thread);
// 最初のロード
_loadToml(path, true);
}
void TomlSettings::_loadToml(const QString& path, const bool wait) {
QMetaObject::invokeMethod(
_tomlLoader,
"loadToml",
Q_ARG(QString, path)
);
if(wait) {
for(;;) {
constexpr const unsigned long IntervalMS = 50;
QThread::usleep(IntervalMS * 1000);
QCoreApplication::processEvents();
if(!_first)
break;
}
}
}
toml::value TomlSettings::_value(const toml::value& val, const QString& ent) const {
return toml::find<toml::value>(val, ent.toStdString());
}
toml::value TomlSettings::value(const QString& ent) const {
std::shared_lock lk(_mutex);
toml::value ret = _table;
const QStringList lst = ent.split(".");
for(auto&& e : lst) {
ret = _value(ret, e);
}
return ret;
}
TomlSettings::~TomlSettings() {
// Loaderスレッド終了 & 待機
_thread->quit();
_thread->wait();
}
}
|
a9b00cc6713036c1db72161df386e560db33afc5 | 5849eb43c42ab5086389c573b8a449195af8d559 | /udemy-bazel/modern_cpp/01-build-with-headers/src/Calculator.cc | 53f1ab40f77d946267ae650c012d13bccc97195d | [] | no_license | macetw/tylerlearning | d64e8b9cf3c114cdef315d1d833b97c79f6dc8b9 | ad8fe1fa7b1e25e7f54fb0ed0252cbe10e977f84 | refs/heads/master | 2023-05-13T04:02:04.008020 | 2021-07-12T14:23:29 | 2021-07-12T14:23:29 | 64,959,485 | 0 | 0 | null | 2023-05-01T22:44:15 | 2016-08-04T18:51:53 | C++ | UTF-8 | C++ | false | false | 414 | cc | Calculator.cc | #include "Calculator.h"
Calculator::Calculator() {}
Calculator::~Calculator() {}
double
Calculator::plus(double left, double right)
{
return left + right;
}
double
Calculator::minus(double left, double right)
{
return left - right;
}
double
Calculator::divide(double left, double right)
{
return left / right;
}
double
Calculator::multiply(double left, double right)
{
return left * right;
}
|
b0eb47151bd0b15f0dee93b8d6642d473d7ff415 | e214329b7ae946e81d547f2d5c86494f7c9786ea | /2019_season3/dfs/947. Most Stones Removed with Same Row or Column.cpp | 0df32baef5ae040748a0490c472033a219073429 | [
"MIT"
] | permissive | wy3148/leetcode | 8cd118df2f007b3eb6037ce07cf1a8ad87ddbfef | 53bdbdcf4a8ad8f61fed2b429c9220fc89e369ca | refs/heads/master | 2021-01-22T21:07:52.917408 | 2020-02-07T04:22:38 | 2020-02-07T04:22:38 | 85,396,420 | 0 | 0 | null | 2017-03-18T11:31:08 | 2017-03-18T11:31:08 | null | UTF-8 | C++ | false | false | 2,023 | cpp | 947. Most Stones Removed with Same Row or Column.cpp |
// https://blog.csdn.net/fuxuemingzhu/article/details/84500642
// https://buptwc.com/2018/11/25/Leetcode-947-Most-Stones-Removed-with-Same-Row-or-Column/
//理解题目含义,输入是一系列的row/col 坐标点,坐标点处有石头
//
//
class Solution {
public:
int count;
//那么我们发现了一个规律,对于一个连通的图,我们始终可以删除n-1个石头,其中n是这个连通图内的石头总数
// 我们使用dfs去找到这样的图,每次答案加上这次dfs遍历的石头数减一即可
void dfs(vector<vector<int>>& stones,set<pair<int,int>>& curGraph,set<pair<int,int>>& visited, int i, int j){
for(auto& v : stones){
//联通的条件是什么
// row index or column index is equal to each other, two stones are connected then
//
if (visited.find({v[0],v[1]}) == visited.end() && (v[0] == i || v[1] == j)){
curGraph.insert({v[0],v[1]});
visited.insert({v[0],v[1]});
dfs(stones,curGraph,visited,v[0],v[1]);
}
}
}
int removeStones(vector<vector<int>>& stones) {
count = 0;
set<pair<int,int>> visited;
//dfs方式查找一个联通的图
for(auto& v : stones){
if (visited.find({v[0],v[1]}) == visited.end()){
set<pair<int,int>> curGraph;
curGraph.insert({v[0],v[1]});
visited.insert({v[0],v[1]});
dfs(stones,curGraph,visited,v[0],v[1]);
if (curGraph.size() > 1){
count += curGraph.size() - 1;
}
}
}
return count;
}
};
//[[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]]
// 这样的输入如果图画出来的 他们实际上只有一个联通图
//那么可以移除的stone就是 连通图 结点个数 - 1
//搜索联通图
//dfs 实现方法, bfs 也可以,或者是
//union find, 并查集
//union find
|
80c8fa7c07467869f0a93b15b047284a7cca7cbb | a56252fda5c9e42eff04792c6e16e413ad51ba1a | /resources/home/dnanexus/root/include/RooMinimizerFcn.h | effa8d30ded95999923043ef7399b4488ea24fb1 | [
"LGPL-2.1-or-later",
"LGPL-2.1-only",
"Apache-2.0"
] | permissive | edawson/parliament2 | 4231e692565dbecf99d09148e75c00750e6797c4 | 2632aa3484ef64c9539c4885026b705b737f6d1e | refs/heads/master | 2021-06-21T23:13:29.482239 | 2020-12-07T21:10:08 | 2020-12-07T21:10:08 | 150,246,745 | 0 | 0 | Apache-2.0 | 2019-09-11T03:22:55 | 2018-09-25T10:21:03 | Python | UTF-8 | C++ | false | false | 3,444 | h | RooMinimizerFcn.h | /*****************************************************************************
* Project: RooFit *
* Package: RooFitCore *
* @(#)root/roofitcore:$Id$
* Authors: *
* AL, Alfio Lazzaro, INFN Milan, alfio.lazzaro@mi.infn.it *
* *
* *
* Redistribution and use in source and binary forms, *
* with or without modification, are permitted according to the terms *
* listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
*****************************************************************************/
#ifndef __ROOFIT_NOROOMINIMIZER
#ifndef ROO_MINIMIZER_FCN
#define ROO_MINIMIZER_FCN
#include "Math/IFunction.h"
#include "Fit/ParameterSettings.h"
#include "Fit/FitResult.h"
#include "TMatrixDSym.h"
#include "RooAbsReal.h"
#include "RooArgList.h"
#include <iostream>
#include <fstream>
class RooMinimizer;
class RooMinimizerFcn : public ROOT::Math::IBaseFunctionMultiDim {
public:
RooMinimizerFcn(RooAbsReal *funct, RooMinimizer *context,
bool verbose = false);
RooMinimizerFcn(const RooMinimizerFcn& other);
virtual ~RooMinimizerFcn();
virtual ROOT::Math::IBaseFunctionMultiDim* Clone() const;
virtual unsigned int NDim() const { return _nDim; }
RooArgList* GetFloatParamList() { return _floatParamList; }
RooArgList* GetConstParamList() { return _constParamList; }
RooArgList* GetInitFloatParamList() { return _initFloatParamList; }
RooArgList* GetInitConstParamList() { return _initConstParamList; }
void SetEvalErrorWall(Bool_t flag) { _doEvalErrorWall = flag ; }
void SetPrintEvalErrors(Int_t numEvalErrors) { _printEvalErrors = numEvalErrors ; }
Bool_t SetLogFile(const char* inLogfile);
std::ofstream* GetLogFile() { return _logfile; }
void SetVerbose(Bool_t flag=kTRUE) { _verbose = flag ; }
Double_t& GetMaxFCN() { return _maxFCN; }
Int_t GetNumInvalidNLL() { return _numBadNLL; }
Bool_t Synchronize(std::vector<ROOT::Fit::ParameterSettings>& parameters,
Bool_t optConst, Bool_t verbose);
void BackProp(const ROOT::Fit::FitResult &results);
void ApplyCovarianceMatrix(TMatrixDSym& V);
Int_t evalCounter() const { return _evalCounter ; }
void zeroEvalCount() { _evalCounter = 0 ; }
private:
Double_t GetPdfParamVal(Int_t index);
Double_t GetPdfParamErr(Int_t index);
void SetPdfParamErr(Int_t index, Double_t value);
void ClearPdfParamAsymErr(Int_t index);
void SetPdfParamErr(Int_t index, Double_t loVal, Double_t hiVal);
inline Bool_t SetPdfParamVal(const Int_t &index, const Double_t &value) const;
virtual double DoEval(const double * x) const;
void updateFloatVec() ;
private:
mutable Int_t _evalCounter ;
RooAbsReal *_funct;
RooMinimizer *_context;
mutable double _maxFCN;
mutable int _numBadNLL;
mutable int _printEvalErrors;
Bool_t _doEvalErrorWall;
int _nDim;
std::ofstream *_logfile;
bool _verbose;
RooArgList* _floatParamList;
std::vector<RooAbsArg*> _floatParamVec ;
RooArgList* _constParamList;
RooArgList* _initFloatParamList;
RooArgList* _initConstParamList;
};
#endif
#endif
|
8c76dfcb69181d54b9646642891cab687831771f | a00426c1cb1c62ea68cf0ec4b41b641da0371b76 | /eclipse-workspace-c-c++/PoweOf2^n/src/PoweOf2^n.cpp | e544d497034878d301c36c112ebcad69abffb289 | [] | no_license | BinodKumarD/c-programs | 2d77480a87bf96f27f4e3c83f2523e8592e650cb | 61e1e1a252e3f6e186162c294f6087bad99cc8e6 | refs/heads/main | 2023-05-29T18:14:31.905045 | 2021-06-13T04:54:34 | 2021-06-13T04:54:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 726 | cpp | PoweOf2^n.cpp | //============================================================================
// Name : PoweOf2^n.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int powerOf2(int pow){
return (1<<pow);
}
bool isPowerOf2(int n){
return(n&&!(n&(n-1)));
}
int main() {
/*cout << "Enter the power to know the power of two: " << endl; // prints
int pow;
cin>>pow;
cout<<powerOf2(pow)<<endl;*/
cout << "Enter the number to know it is power of two or not: " << endl; // prints
int n;
cin>>n;
cout<<isPowerOf2(n);
return 0;
}
|
d4389b352d66f21b165c96f8556560d8562c36d5 | e96c2bbb83ce181ef9f06a1bb4592b1abb4e3d1d | /given/Chapter08/pr8-21.cpp | 72a0fa4fe1948f5d6634face9cc4db13df94c595 | [] | no_license | voidstarr/cs7b | 844d2db03ccf9a36fb9614ad30053ab9d1be22ea | bcd39a4adb07454a6c218cc202895b6b2469e9bd | refs/heads/master | 2020-12-31T00:17:23.692813 | 2017-05-16T18:27:52 | 2017-05-16T18:27:52 | 80,552,240 | 1 | 2 | null | 2017-02-14T21:30:21 | 2017-01-31T19:08:35 | C++ | UTF-8 | C++ | false | false | 1,520 | cpp | pr8-21.cpp | // This program uses a two-dimensional array. The
// data stored in the array is read in from a file.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
int main()
{
const int NUM_DIVS = 3; // Number of divisions
const int NUM_QTRS = 4; // Number of quarters
double sales[NUM_DIVS][NUM_QTRS]; // 2D array with 3 rows & 4 columns
double totalSales = 0; // Accumulates total sales
int div, qtr; // Loop counters
ifstream inputFile; // Used to read data from a file
inputFile.open("sales2.dat");
if (!inputFile)
cout << "Error opening data file.\n";
else
{
cout << fixed << showpoint << setprecision(2);
cout << "Quarterly Sales by Division\n\n";
// Nested loops are used to fill the array with quarterly
// sales figures for each division and to display the data
for (div = 0; div < NUM_DIVS; div++)
{ for (qtr = 0; qtr < NUM_QTRS; qtr++)
{
cout << "Division " << (div + 1)
<< ", Quarter " << (qtr + 1) << ": $";
inputFile >> sales[div][qtr];
cout << sales[div][qtr] << endl;
}
cout << endl; // Print blank line
}
inputFile.close();
// Nested loops are used to add all the elements
for (div = 0; div < NUM_DIVS; div++)
{ for (qtr = 0; qtr < NUM_QTRS; qtr++)
totalSales += sales[div][qtr];
}
// Display the total
cout << "The total sales for the company are: $";
cout << totalSales << endl;
}
return 0;
}
|
898d38b50a470b1623fbb69200ec4bd0a818662e | 96ffccd9e149a06e7d0b39e32a690e0c6457b411 | /Source/packagemanager.cpp | 9978d63c6c421c0c7802ae90b1f30373b1f6b0bb | [
"MIT"
] | permissive | cyberCBM/ADB_UI_QT | e1e1833807d300338e7c4d37d95239b6a1507843 | 33fef8bcc3d0b2fabdcfb4e3dbe694b45c66f886 | refs/heads/main | 2023-02-02T12:09:36.730875 | 2020-12-23T06:24:37 | 2020-12-23T06:24:37 | 300,494,710 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,172 | cpp | packagemanager.cpp | #include "packagemanager.hpp"
#include "ui_PackageManager.h"
PackageManager::PackageManager(QWidget *parent) :
QWidget(parent),
m_UI(new Ui::PackageManager)
{
m_UI->setupUi(this);
m_slModel = new QStringListModel(this);
// now add data to ui
parseData();
}
PackageManager::~PackageManager()
{
delete m_UI;
}
QString PackageManager::substring(const QString &string, int start, int end)
{
return string.mid(start, end-start);
}
QString PackageManager::removeGarbage(QString string)
{
return string.remove("package:", Qt::CaseInsensitive);
}
void PackageManager::parseData()
{
QString currentDevice = SettingManager::value(ADB_DEVICE).toString();
if(currentDevice.isEmpty())
return;
QString adbPathStr = SettingManager::value(ADB_PATH).toString();
checkADBPath(adbPathStr, this);
// start process
QString program = QString("%1/adb -s %2 shell pm list packages -3").arg(adbPathStr, currentDevice);
auto outputData = runProcess(program);
//qDebug() << outputData;
int lastIndex = 0;
// reset List
m_stringList.clear();
// parse data into list
for(int i = 0; i < outputData.size(); i++)
{
if(outputData[i] == '\n')
{
QString string = substring(QString(outputData), lastIndex, i);
string = removeGarbage(string);
lastIndex = i;
m_stringList << string;
}
}
// set model list
m_slModel->setStringList(m_stringList);
m_UI->listView->setModel(m_slModel);
}
void PackageManager::on_uninstall_clicked()
{
QString currentDevice = SettingManager::value(ADB_DEVICE).toString();
if(currentDevice.isEmpty())
return;
// prompt user if they want to keep data
QMessageBox msgBox;
msgBox.setText("Do you want to keep app data?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
QString adbPathStr = SettingManager::value(ADB_PATH).toString();
checkADBPath(adbPathStr, this);
switch (ret) {
case QMessageBox::Yes:
{
QModelIndex index = m_UI->listView->currentIndex();
QString itemText = index.data(Qt::DisplayRole).toString();
// start process
QString program = QString("%1/adb -s %2 uninstall -k %3").arg(adbPathStr, currentDevice, itemText);
runProcess(program);
parseData();
}
break;
case QMessageBox::No:
{
QModelIndex index = m_UI->listView->currentIndex();
QString itemText = index.data(Qt::DisplayRole).toString();
// start process
QString program = QString("%1/adb -s %2 uninstall %3").arg(adbPathStr, currentDevice, itemText);
runProcess(program);
parseData();
}
break;
default:
break;
}
}
void PackageManager::on_install_clicked()
{
QString currentDevice = SettingManager::value(ADB_DEVICE).toString();
if(currentDevice.isEmpty())
return;
QString adbPathStr = SettingManager::value(ADB_PATH).toString();
checkADBPath(adbPathStr, this);
QString fileName = QFileDialog::getOpenFileName(this,
tr("Any"), "~/", tr("APK Files (*.apk)"));
//qDebug() << "Selected file is: " << fileName;
// this one manages the upgrade
QString program = QString("%1/adb -s %2 install %3").arg(adbPathStr, currentDevice, fileName);
//qDebug() << "program is: " << program;
// read adb devices data to array
QByteArray output = runProcess(program);
//qDebug() << "output is: " << output;
// reinstall and downgrade
if(!output.contains("Success"))
{
QString program = QString("%1/adb -s %2 install -r -d %3").arg(adbPathStr, currentDevice, fileName);
//qDebug() << "program is: " << program;
// read adb devices data to array
auto output = runProcess(program);
//qDebug() << "output is: " << output; // if empty then need to show error
}
parseData();
}
|
d1a86bcd79e9e2286f65d343a5c0f1e779b54b9d | c012a00ce80e4f78378ba6fe79febdf14b638692 | /VirtualDiskInterop/Structures/SetVirtualDiskInfo.h | 6f7678968923ff5d80d89f1f542748f32873a529 | [] | no_license | PlumpMath/VirtualDiskInterop | 9349d9417b4c44a823eaa5a643c1ca80f0ce8eb1 | 325ae6c283b078e56715a32f092f1571f740a450 | refs/heads/master | 2021-01-19T23:13:53.185689 | 2016-06-25T14:09:24 | 2016-06-25T14:09:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,800 | h | SetVirtualDiskInfo.h | #pragma once
using namespace System;
namespace VirtualDiskInterop
{
public value class SetVirtualDiskInfoParentPathWithDepthInfo
{
public:
property unsigned long ChildDepth
{
unsigned long get()
{
return this->m_ChildDepth;
}
void set(unsigned long value)
{
this->m_ChildDepth = value;
}
}
property String^ ParentFilePath
{
String^ get()
{
return this->m_ParentFilePath;
}
void set(String^ value)
{
this->m_ParentFilePath = value;
}
}
private:
unsigned long m_ChildDepth;
String^ m_ParentFilePath;
LPWSTR m_NativeParentFilePath = NULL;
internal:
void PopulateNativeStruct(SET_VIRTUAL_DISK_INFO* info)
{
this->ReleaseNativeData();
info->ParentPathWithDepthInfo.ChildDepth = this->m_ChildDepth;
this->m_NativeParentFilePath = Helpers::AllocString(this->m_ParentFilePath);
info->ParentPathWithDepthInfo.ParentFilePath = this->m_NativeParentFilePath;
}
void ReadNativeStruct(SET_VIRTUAL_DISK_INFO* info)
{
this->m_ChildDepth = info->ParentPathWithDepthInfo.ChildDepth;
this->m_ParentFilePath = gcnew String(info->ParentPathWithDepthInfo.ParentFilePath);
this->ReleaseNativeData();
}
void ReleaseNativeData()
{
if (this->m_NativeParentFilePath)
{
LocalFree(this->m_NativeParentFilePath);
this->m_NativeParentFilePath = NULL;
}
}
};
#ifdef WIN10SUPPORT
public value class SetVirtualDiskInfoParentLocator
{
public:
property Guid LinkageId
{
Guid get()
{
return this->m_LinkageId;
}
void set(Guid value)
{
this->m_LinkageId = value;
}
}
property String^ ParentFilePath
{
String^ get()
{
return this->m_ParentFilePath;
}
void set(String^ value)
{
this->m_ParentFilePath = value;
}
}
private:
Guid m_LinkageId;
String^ m_ParentFilePath;
LPWSTR m_NativeParentFilePath = NULL;
internal:
void PopulateNativeStruct(SET_VIRTUAL_DISK_INFO* info)
{
info->ParentLocator.LinkageId = Helpers::ToGUID(this->m_LinkageId);
this->m_NativeParentFilePath = Helpers::AllocString(this->m_ParentFilePath);
info->ParentLocator.ParentFilePath = this->m_NativeParentFilePath;
}
void ReadNativeStruct(SET_VIRTUAL_DISK_INFO* info)
{
this->m_LinkageId = Helpers::FromGUID(info->ParentLocator.LinkageId);
this->m_ParentFilePath = gcnew String(info->ParentLocator.ParentFilePath);
this->ReleaseNativeData();
}
void ReleaseNativeData()
{
if (this->m_NativeParentFilePath)
{
LocalFree(this->m_NativeParentFilePath);
this->m_NativeParentFilePath = NULL;
}
}
};
#endif
public value class SetVirtualDiskInfo
{
public:
property SetVirtualDiskInfoVersions Version
{
SetVirtualDiskInfoVersions get()
{
return this->m_Version;
}
void set(SetVirtualDiskInfoVersions value)
{
this->m_Version = value;
}
}
property String^ ParentFilePath
{
String^ get()
{
return this->m_ParentFilePath;
}
void set(String^ value)
{
this->m_ParentFilePath = value;
}
}
property Guid UniqueIdentifier
{
Guid get()
{
return this->m_UniqueIdentifier;
}
void set(Guid value)
{
this->m_UniqueIdentifier = value;
}
}
property SetVirtualDiskInfoParentPathWithDepthInfo ParentPathWithDepthInfo
{
SetVirtualDiskInfoParentPathWithDepthInfo get()
{
return this->m_ParentPathWithDepthInfo;
}
void set(SetVirtualDiskInfoParentPathWithDepthInfo value)
{
this->m_ParentPathWithDepthInfo = value;
}
}
property unsigned long VhdPhysicalSectorSize
{
unsigned long get()
{
return this->m_VhdPhysicalSectorSize;
}
void set(unsigned long value)
{
this->m_VhdPhysicalSectorSize = value;
}
}
property Guid VirtualDiskId
{
Guid get()
{
return this->m_VirtualDiskId;
}
void set(Guid value)
{
this->m_VirtualDiskId = value;
}
}
#ifdef WIN10SUPPORT
property bool ChangeTrackingEnabled
{
bool get()
{
return this->m_ChangeTrackingEnabled;
}
void set(bool value)
{
this->m_ChangeTrackingEnabled = value;
}
}
property SetVirtualDiskInfoParentLocator ParentLocator
{
SetVirtualDiskInfoParentLocator get()
{
return this->m_ParentLocator;
}
void set(SetVirtualDiskInfoParentLocator value)
{
this->m_ParentLocator = value;
}
}
#endif
private:
SetVirtualDiskInfoVersions m_Version;
String^ m_ParentFilePath;
Guid m_UniqueIdentifier;
SetVirtualDiskInfoParentPathWithDepthInfo m_ParentPathWithDepthInfo;
unsigned long m_VhdPhysicalSectorSize;
Guid m_VirtualDiskId;
#ifdef WIN10SUPPORT
bool m_ChangeTrackingEnabled;
SetVirtualDiskInfoParentLocator m_ParentLocator;
#endif
LPWSTR m_NativeParentFilePath = NULL;
internal:
SET_VIRTUAL_DISK_INFO* m_NativeData = NULL;
SET_VIRTUAL_DISK_INFO* GetNative()
{
this->ReleaseNative(false);
this->m_NativeData = new SET_VIRTUAL_DISK_INFO();
this->m_NativeData->Version = (SET_VIRTUAL_DISK_INFO_VERSION)this->m_Version;
switch (this->m_Version)
{
case SetVirtualDiskInfoVersions::ParentPath:
this->m_NativeParentFilePath = Helpers::AllocString(this->m_ParentFilePath);
this->m_NativeData->ParentFilePath = this->m_NativeParentFilePath;
break;
case SetVirtualDiskInfoVersions::Identifier:
this->m_NativeData->UniqueIdentifier = Helpers::ToGUID(this->m_UniqueIdentifier);
break;
case SetVirtualDiskInfoVersions::ParentPathWithDepth:
this->m_ParentPathWithDepthInfo.PopulateNativeStruct(this->m_NativeData);
break;
case SetVirtualDiskInfoVersions::PhysicalSectorSize:
this->m_NativeData->VhdPhysicalSectorSize = this->m_VhdPhysicalSectorSize;
break;
case SetVirtualDiskInfoVersions::VirtualDiskID:
this->m_NativeData->VirtualDiskId = Helpers::ToGUID(this->m_VirtualDiskId);
break;
#ifdef WIN10SUPPORT
case SetVirtualDiskInfoVersions::ChangeTrackingState:
this->m_NativeData->ChangeTrackingEnabled = (BOOL)this->m_ChangeTrackingEnabled;
break;
case SetVirtualDiskInfoVersions::ParentLocation:
this->m_ParentLocator.PopulateNativeStruct(this->m_NativeData);
break;
#endif
}
return this->m_NativeData;
}
void ReleaseNative(bool updateData)
{
if (this->m_NativeData)
{
if (updateData)
{
this->m_NativeData->Version = (SET_VIRTUAL_DISK_INFO_VERSION)this->m_Version;
switch (this->m_Version)
{
case SetVirtualDiskInfoVersions::ParentPath:
this->m_ParentFilePath = gcnew String(this->m_NativeData->ParentFilePath);
break;
case SetVirtualDiskInfoVersions::Identifier:
this->m_UniqueIdentifier = Helpers::FromGUID(this->m_NativeData->UniqueIdentifier);
break;
case SetVirtualDiskInfoVersions::ParentPathWithDepth:
this->m_ParentPathWithDepthInfo.ReadNativeStruct(this->m_NativeData);
break;
case SetVirtualDiskInfoVersions::PhysicalSectorSize:
this->m_VhdPhysicalSectorSize = this->m_NativeData->VhdPhysicalSectorSize;
break;
case SetVirtualDiskInfoVersions::VirtualDiskID:
this->m_VirtualDiskId = Helpers::FromGUID(this->m_NativeData->VirtualDiskId);
break;
#ifdef WIN10SUPPORT
case SetVirtualDiskInfoVersions::ChangeTrackingState:
this->m_ChangeTrackingEnabled = this->m_NativeData->ChangeTrackingEnabled != 0;
break;
case SetVirtualDiskInfoVersions::ParentLocation:
this->m_ParentLocator.ReadNativeStruct(this->m_NativeData);
break;
#endif
}
}
delete this->m_NativeData;
this->m_NativeData = NULL;
}
this->m_ParentPathWithDepthInfo.ReleaseNativeData();
this->m_ParentLocator.ReleaseNativeData();
if (this->m_NativeParentFilePath)
{
LocalFree(this->m_NativeParentFilePath);
this->m_NativeParentFilePath = NULL;
}
}
};
} |
590f6046610c456c67d3a0e12ba85d860e00c97a | adb4e6b82e5f969fc46f7c58e70e49c5d53a6fe3 | /exotica_core/include/exotica_core/kinematic_element.h | 5311b2a0c8ffdb86d67d8eb9d50b584992ee69f5 | [
"BSD-3-Clause"
] | permissive | ipab-slmc/exotica | 8d9b531916f1e7422f85854597aa925091a7b7c4 | be580d162c5798d976f138cc1cd99474aef9c6fe | refs/heads/master | 2021-12-15T15:19:26.471745 | 2021-12-08T03:43:44 | 2021-12-08T03:43:44 | 44,607,894 | 144 | 55 | NOASSERTION | 2021-07-23T10:51:43 | 2015-10-20T13:24:57 | C++ | UTF-8 | C++ | false | false | 5,082 | h | kinematic_element.h | //
// Copyright (c) 2018, University of Edinburgh
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#ifndef EXOTICA_CORE_KINEMATIC_ELEMENT_H_
#define EXOTICA_CORE_KINEMATIC_ELEMENT_H_
#include <exotica_core/tools.h>
#include <geometric_shapes/shapes.h>
#include <kdl/frames.hpp>
#include <kdl/segment.hpp>
#include <stack>
namespace exotica
{
class VisualElement
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
std::string name;
shapes::ShapePtr shape = nullptr;
std::string shape_resource_path = "";
KDL::Frame frame = KDL::Frame::Identity();
Eigen::Vector3d scale = Eigen::Vector3d::Ones();
Eigen::Vector4d color = Eigen::Vector4d(1.0, 1.0, 1.0, 1.0);
};
class KinematicElement
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
KinematicElement(int _id, std::shared_ptr<KinematicElement> _parent, const KDL::Segment& _segment) : id(_id), parent(_parent), segment(_segment)
{
}
~KinematicElement()
{
// Remove from parent to avoid expired pointers
std::shared_ptr<KinematicElement> my_parent = parent.lock();
if (my_parent)
{
my_parent->RemoveExpiredChildren();
}
}
inline void UpdateClosestRobotLink()
{
std::shared_ptr<KinematicElement> element = parent.lock();
closest_robot_link = std::shared_ptr<KinematicElement>(nullptr);
while (element && element->id > 0)
{
if (element->is_robot_link)
{
closest_robot_link = element;
break;
}
element = element->parent.lock();
}
SetChildrenClosestRobotLink();
}
inline KDL::Frame GetPose(const double& x = 0.0)
{
if (is_trajectory_generated)
{
return generated_offset;
}
else
{
return segment.pose(x);
}
}
inline void RemoveExpiredChildren()
{
for (size_t i = 0; i < children.size(); ++i)
{
if (children[i].expired())
{
children.erase(children.begin() + i);
}
}
}
int id;
int control_id = -1;
bool is_controlled = false;
std::weak_ptr<KinematicElement> parent;
std::string parent_name;
std::vector<std::weak_ptr<KinematicElement>> children;
std::weak_ptr<KinematicElement> closest_robot_link = std::shared_ptr<KinematicElement>(nullptr);
KDL::Segment segment = KDL::Segment();
KDL::Frame frame = KDL::Frame::Identity();
KDL::Frame generated_offset = KDL::Frame::Identity();
bool is_trajectory_generated = false;
std::vector<double> joint_limits;
double velocity_limit = std::numeric_limits<double>::quiet_NaN();
double acceleration_limit = std::numeric_limits<double>::quiet_NaN();
shapes::ShapeConstPtr shape = nullptr;
std::string shape_resource_path = std::string();
Eigen::Vector3d scale = Eigen::Vector3d::Ones();
bool is_robot_link = false;
Eigen::Vector4d color = Eigen::Vector4d(0.5, 0.5, 0.5, 1.0);
std::vector<VisualElement> visual;
private:
inline void SetChildrenClosestRobotLink()
{
std::stack<std::shared_ptr<KinematicElement>> elements;
for (auto child : children) elements.push(child.lock());
while (!elements.empty())
{
auto parent = elements.top();
elements.pop();
parent->closest_robot_link = closest_robot_link;
for (auto child : parent->children) elements.push(child.lock());
}
}
};
} // namespace exotica
#endif // EXOTICA_CORE_KINEMATIC_ELEMENT_H_
|
fb510536075a87e9020d7bae1cd022c14622eb7b | 6570bfdb26a41d99620debec5541e789b3c613f3 | /Useful Codes for Programming/union_find.cpp | 27437390f58a84efa31cd7ce83772a462c62b92a | [] | no_license | ameet-1997/Competitive_Coding | bc30f37ae034efe7bb63f71241792fc53c323a50 | a9824430cf0458516ddd88655c1eca1f42ff3f0a | refs/heads/master | 2021-05-10T14:07:15.209770 | 2018-01-22T19:22:13 | 2018-01-22T19:22:13 | 118,500,812 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 427 | cpp | union_find.cpp | void do_union(int x,int y)
{
int find_parent(int);
int x_p,y_p;
x_p = find_parent(x);
y_p = find_parent(y);
if(x_p == y_p)
{
return;
}
if(-a[x_p] > -a[y_p])
{
a[y_p] = x_p;
}
else if(-a[x_p] < -a[y_p])
{
a[x_p] = y_p;
}
else
{
a[y_p] = x_p;
a[x_p]--;
}
}
int find_parent(int x)
{
if(a[x] < 0)
{
return x;
}
else
{
a[x] = find_parent(a[x]); //Doing path compression
return a[x];
}
}
|
d44ef254e027c57bdde75dc19bfac03293e51cd4 | ac131f6d9d705413d71b7fe9c2d4062135cc6d50 | /quickmodel.h | d182852a78aa202043c916633edf5b79408630b9 | [] | no_license | jnynas/QuickModel | 560f2ec5e200bebca2ee49ee77a2805a3b6ebfd1 | edb008948add4fce8bbdff364ddfc5ca42d54337 | refs/heads/master | 2016-08-06T00:29:27.510370 | 2012-04-25T10:08:45 | 2012-04-25T10:08:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,607 | h | quickmodel.h |
#ifndef QUICKMODEL_H
#define QUICKMODEL_H
#include <QAbstractListModel>
#include <QVariantMap>
#include <QStringList>
class QuickModel : public QAbstractListModel
{
Q_OBJECT
public:
explicit QuickModel(QObject *parent = 0);
const QList<QVariantList>& items() const;
void setItemList(const QList<QVariantList> &items);
int fieldIndex(const QString& fieldname);
void sort (const QString& field, Qt::SortOrder order = Qt::AscendingOrder );
QList<QVariantList> findItems (const QString& text, Qt::MatchFlags flags = Qt::MatchExactly, int column = 0 ) const;
Q_INVOKABLE void setFields(const QStringList &keys);
Q_INVOKABLE void append(const QVariantMap& item);
Q_INVOKABLE void insert(int pos, const QVariantMap& item);
Q_INVOKABLE void set(int pos, const QVariantMap& item);
Q_INVOKABLE QVariantMap get(int pos);
Q_INVOKABLE int count();
Q_INVOKABLE void clear();
Q_INVOKABLE void remove(int pos);
Q_INVOKABLE void setProperty(int pos, QString property, QVariant value);
Q_INVOKABLE void saveToFile(QString fileName);
Q_INVOKABLE void restoreFromFile(QString fileName);
protected:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
private:
QVariantList flatten(const QVariantMap& map);
void save(QIODevice *device);
void restore(QIODevice *device);
private:
Q_DISABLE_COPY(QuickModel)
QList<QVariantList> m_lst;
QHash<int, QByteArray> m_roleNames;
QHash<QString, int> m_rolesForKeys;
};
#endif // QUICKMODEL_H
|
42b007e63c511b442bba202942e4cfdb0d729fbf | 5bccf2d2118008c0af6a51a92a042e967e4f2abe | /Support/Modules/Geometry/Sphere3DData.h | dc5d42988b42e376ca7d8f61fa0709c41da4334d | [
"Apache-2.0"
] | permissive | graphisoft-python/DGLib | fa42fadebedcd8daaddde1e6173bd8c33545041d | 66d8717eb4422b968444614ff1c0c6c1bf50d080 | refs/heads/master | 2020-06-13T21:38:18.089834 | 2020-06-12T07:27:54 | 2020-06-12T07:27:54 | 194,795,808 | 3 | 0 | Apache-2.0 | 2020-06-12T07:27:55 | 2019-07-02T05:45:00 | C++ | UTF-8 | C++ | false | false | 637 | h | Sphere3DData.h | #if !defined (SPHERE3DDATA_H)
#define SPHERE3DDATA_H
#pragma once
#include "GeometricDefinitions.h"
#include "Vector3D.hpp"
/****************************************************************************/
/* */
/* 3D Sphere and its operations */
/* */
/****************************************************************************/
typedef struct {
Coord3D o; /* Origin */
double r; /* Radius */
} Sphere3D;
struct Sector3D;
namespace Geometry {
GEOMETRY_DLL_EXPORT bool GEOM_CALL XSphereLine3D (const Sphere3D *sp,
const Sector3D *s,
Sector3D *xs);
}
#endif
|
bbe1ea2ba56ef0401559ec0de6fa90ce225de190 | 8f50c262f89d3dc4f15f2f67eb76e686b8f808f5 | /MuonSpectrometer/MuonReconstruction/MuonRecEvent/MuonHoughPatternEvent/src/MuonHoughMathUtils.cxx | a2676790efe4effd17c4e1f4286659fcd00c1c37 | [
"Apache-2.0"
] | permissive | strigazi/athena | 2d099e6aab4a94ab8b636ae681736da4e13ac5c9 | 354f92551294f7be678aebcd7b9d67d2c4448176 | refs/heads/master | 2022-12-09T02:05:30.632208 | 2020-09-03T14:03:18 | 2020-09-03T14:03:18 | 292,587,480 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 12,137 | cxx | MuonHoughMathUtils.cxx | /*
Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
*/
#include "MuonHoughPatternEvent/MuonHoughMathUtils.h"
#include "CxxUtils/sincos.h"
#include <sstream>
#include <iostream>
#include <cassert>
#include "GaudiKernel/MsgStream.h"
#include "AthenaKernel/getMessageSvc.h"
MuonHoughMathUtils::MuonHoughMathUtils()
{
}
int MuonHoughMathUtils::sgn(double d)const
{
if (d<0) {return -1;}
// if (d==0) {return 0;} //i know, its the definition, but we dont want it
if (d>=0) {return 1;}
return 666;
}
int MuonHoughMathUtils::step(double d, double x0)const
{
MsgStream log(Athena::getMessageSvc(),"MuonHoughMathUtils::step");
if (d==x0) {if (log.level()<=MSG::WARNING) log << MSG::WARNING << "WARNING: Possible mistake in Step function" << endmsg;}
if (d<=x0) {return 0;}
if (d>x0) {return 1;}
return -1;
}
double MuonHoughMathUtils::signedDistanceToLine(double x0, double y0, double r0, double phi)const //distance from (x0,y0) to the line (r0,phi) , phi in [-Pi,Pi] ,different phi than in calculateangle() (==angle(2))
{
CxxUtils::sincos scphi(phi);
double distance = scphi.apply(x0,-y0) - r0;
return distance;
}
double MuonHoughMathUtils::distanceToLine(double x0, double y0, double r0, double phi)const
{
return std::abs(signedDistanceToLine(x0,y0,r0,phi));
}
double MuonHoughMathUtils::incrementTillAbove0(double x, double inc, double zero)const
{
while(x > inc + zero )
{x-=inc;}
while(x < zero )
{x+=inc;}
return x;
}
double MuonHoughMathUtils::angleFrom0To360(double angle)const
{
return incrementTillAbove0(angle,360.);
}
double MuonHoughMathUtils::angleFrom0To180(double angle)const
{
return incrementTillAbove0(angle,180.);
}
double MuonHoughMathUtils::angleFrom0ToPi(double angle)const
{
return incrementTillAbove0(angle,M_PI);
}
double MuonHoughMathUtils::angleFromMinusPiToPi(double angle)const
{
return incrementTillAbove0(angle,2*M_PI,-M_PI);
}
std::string MuonHoughMathUtils::intToString(int i)const
{
std::string s;
std::stringstream ss;
ss << i;
ss >> s;
return s;
}
const char * MuonHoughMathUtils::stringToChar(std::string& string)const
{
const char * constcharstar = string.data();
return constcharstar;
}
const char * MuonHoughMathUtils::intToChar(int i)const
{
std::string string = intToString(i);
const char * constcharstar = stringToChar(string);
return constcharstar;
}
double MuonHoughMathUtils::distanceToLine2D(double x0, double y0, double r0, double phi)const // distance from (x0,y0) to line (r,phi) // from mathworld.wolfram.com/Point-LineDistance2-Dimensional.html // better to use distancetoline()
{
// need two points on line:
CxxUtils::sincos scphi(phi);
double x1 = - r0 * scphi.sn; // point closest to origin
double y1 = r0 * scphi.cs;
std::vector <double> v(3); // (p1 - p0)
v[0] = x1-x0;
v[1] = y1-y0;
std::vector <double> r(3); // vector perpendicular to line
r[0] = x1;
r[1] = y1;
double distance = dotProduct(r,v)/abs(r);
return distance;
}
double MuonHoughMathUtils::distanceToLine3D(double x0,double y0,double z0, double x, double y, double z, double phi, double theta)const // from wolfram: http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
{
std::vector <double> x1(3); // x1-x0
std::vector <double> x3(3); // x2-x1 = e_r
x1[0]=x-x0;
x1[1]=y-y0;
x1[2]=z-z0;
CxxUtils::sincos scphi(phi);
CxxUtils::sincos sctheta(theta);
x3[0]= scphi.cs*sctheta.sn;
x3[1]= scphi.sn*sctheta.sn;
x3[2]= sctheta.cs;
// sqrt(x3^2) == 1; !
double distance;
std::vector<double> x4(3);
x4 = crossProduct(x3,x1);
distance = std::sqrt(dotProduct(x4,x4))/(std::sqrt(dotProduct(x3,x3)));
return distance;
}
double MuonHoughMathUtils::distanceOfLineToOrigin2D(double a, double b)const
{
return std::abs(b/(std::sqrt(a*a+1)));
}
double MuonHoughMathUtils::signedDistanceOfLineToOrigin2D(double x, double y, double phi)const
{
CxxUtils::sincos scphi(phi);
return scphi.apply(x,-y);
}
std::vector<double> MuonHoughMathUtils::shortestPointOfLineToOrigin3D(double x, double y, double z, double phi, double theta)const // actually this is the 3d-point closest to origin in xy-plane
{
std::vector <double> p(3);
double r0 = signedDistanceOfLineToOrigin2D(x,y,phi);
CxxUtils::sincos scphi(phi);
double x0 = r0*scphi.sn;
double y0 = -r0* scphi.cs;
double radius = std::sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
if ( std::abs((y-y0) - scphi.sn*radius) > std::abs((y-y0) + scphi.cs*radius) ) // also possible for x
{
radius=-radius;
}
double z0 = z - radius / std::tan(theta);
p[0]=x0;
p[1]=y0;
p[2]=z0;
return p;
}
std::vector<double> MuonHoughMathUtils::shortestPointOfLineToOrigin(double x, double y, double z, double phi, double theta)const // from wolfram: http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
{
// origin:
std::vector <double> x0(3);
x0[0]=0;
x0[1]=0;
x0[2]=0;
std::vector <double> x1(3); // x1-x0
std::vector <double> x3(3); // x2-x1
x1[0]=x-x0[0];
x1[1]=y-x0[1];
x1[2]=z-x0[2];
CxxUtils::sincos scphi(phi);
CxxUtils::sincos sctheta(theta);
x3[0]= scphi.cs*sctheta.sn;
x3[1]= scphi.sn*sctheta.sn;
x3[2]= sctheta.cs;
double time=0;
double x5=0;
x5 = dotProduct(x1,x3);
time = - x5 / (dotProduct(x3,x3));
std::vector <double> p(3);
p[0]=x1[0]+x3[0]*time;
p[1]=x1[1]+x3[1]*time;
p[2]=x1[2]+x3[2]*time;
return p;
}
bool MuonHoughMathUtils::lineThroughCylinder(double x_0, double y_0, double z_0, double phi, double theta, double r_cyl, double z_cyl)const
{
// if there is one, then track will be split
assert(r_cyl>=0);
CxxUtils::sincos scphi(phi);
CxxUtils::sincos sctheta(theta);
// 1 -- check if there is an intersection at z0=+-c0
double p_1 = z_0 - z_cyl;
double p_2 = z_0 + z_cyl;
double tantheta = sctheta.sn/sctheta.cs;
double x_1 = x_0 - p_1*scphi.cs*tantheta;
double y_1 = y_0 - p_1*scphi.sn*tantheta;
double r_1 = std::sqrt(x_1*x_1+y_1*y_1);
if (r_1<r_cyl) {return true;}
double x_2 = x_0 - p_2*scphi.cs*tantheta;
double y_2 = y_0 - p_2*scphi.sn*tantheta;
double r_2 = std::sqrt(x_2*x_2+y_2*y_2);
if (r_2<r_cyl) {return true;}
// 2 -- check if there is an intersection with the circle x^2 + y^2 = r_cyl^2 and the line y=px+q, p = tan(phi), q = y_0 - x_0 tan(phi) <--> r_cyl^2 = (px+q)^2 + x^2
double r_0 = scphi.apply(-x_0,y_0);
if (std::abs(r_0) > r_cyl) return false;
// 3 -- check if the intersection is cylinder: for -z_cyl<z<z_cyl
double s_1 = - scphi.sn * r_0;
double s_2 = scphi.cs * std::sqrt(r_cyl*r_cyl-r_0*r_0);
x_1 = s_1 + s_2;
double inv_angle = 1/(scphi.cs * tantheta);
double z_1 = z_0 + (x_1-x_0) * inv_angle;
if (std::abs(z_1) < z_cyl) return true;
x_2 = s_1 - s_2;
double z_2 = z_0 + (x_2-x_0) * inv_angle;
if (std::abs(z_2) < z_cyl) return true;
return false;
}
std::vector<double> MuonHoughMathUtils::crossProduct(std::vector <double> x, std::vector<double> y)const
{
std::vector<double> z(3);
z[0]=y[1]*x[2]-y[2]*x[1];
z[1]=y[2]*x[0]-y[0]*x[2];
z[2]=y[0]*x[1]-y[1]*x[0];
return z;
}
double MuonHoughMathUtils::dotProduct(std::vector <double> x, std::vector<double> y) const
{
double z;
z = y[0]*x[0] + y[1]*x[1] + y[2]*x[2];
return z;
}
double MuonHoughMathUtils::signedDistanceCurvedToHit(double z0, double theta, double invcurvature, double hitx, double hity , double hitz ) const
{
double hitr = std::sqrt(hitx*hitx+hity*hity);
CxxUtils::sincos sctheta(theta);
double sdistance = 100000000.;
// if angle rotation larger than Pi/2 then return large distance (formulas don't work for flip in z!)
if (sctheta.apply(hitr,hitz) < 0) return sdistance; // hitr*sctheta.sn + hitz*sctheta.cs < 0
int sign = 1;
if (hitz < 0) sign = -1;
if (std::abs(hitr/hitz)>MuonHough::tan_barrel) {
// Barrel Extrapolation
if (std::abs(sctheta.sn) > 1e-7) {
double diffr = hitr-MuonHough::radius_cylinder;
double zext = z0 + (hitr*sctheta.cs + diffr*diffr*invcurvature)/sctheta.sn;
sdistance = (zext - hitz);
}
} else {
if (std::abs(sctheta.sn) > 1e-7) {
double rext=0.;
if ( std::abs(hitz) < MuonHough::z_end) {
// Forward in Toroid
double diffz = hitz-sign*MuonHough::z_cylinder;
rext = ((hitz-z0)*sctheta.sn - diffz*diffz*invcurvature)/sctheta.cs;
} else {
// Forward OutSide EC Toroid
rext = ((hitz-z0)*sctheta.sn + (MuonHough::z_magnetic_range_squared - sign*2*hitz*(MuonHough::z_magnetic_range))*invcurvature)/sctheta.cs;
}
sdistance = (rext - hitr);
}
}
return sdistance;
}
double MuonHoughMathUtils::thetaForCurvedHit(double invcurvature, MuonHoughHit* hit) const
{
double ratio = hit->getMagneticTrackRatio()*invcurvature;
if (std::abs(ratio) < 1.) return hit->getTheta() + std::asin (ratio);
else return -1;
}
void MuonHoughMathUtils::thetasForCurvedHit(double ratio, MuonHoughHit* hit, double& theta1, double& theta2)const
{
/** returns angle for positive and negative curvature (positive first) */
if (std::abs(ratio) < 1.) {
double asin_ratio = std::asin(ratio);
theta1 = hit->getTheta() + asin_ratio;
theta2 = hit->getTheta() - asin_ratio;
}
}
void MuonHoughMathUtils::extrapolateCurvedRoad(const Amg::Vector3D& roadpos, const Amg::Vector3D& roadmom, const Amg::Vector3D& pos, Amg::Vector3D& roadpose , Amg::Vector3D& roaddire)const
{
/** Extrapolate pattern given by a roadpos and roadmom (should be perigee)
to a position in space pos
And determine extrapolated position: roadpose
and direction: roaddire
using the curved track model
*/
// m_log<< MSG::VERBOSE << "Extrapolate the road to the segment (hit)" <<endmsg;
const double theta = roadmom.theta();
const double phi = roadmom.phi();
CxxUtils::sincos scphi(phi);
CxxUtils::sincos sctheta(theta);
double tantheta = sctheta.sn/sctheta.cs;
double r0 = scphi.apply(roadpos.x(),-roadpos.y());
double charge = 1.;
if ( r0 < 0) charge = -1.;
double invcurvature = charge/roadmom.mag();
// No momentum estimate
if (roadmom.mag() < 2 ) invcurvature = 0.;
double posr = std::sqrt(pos.x()*pos.x()+pos.y()*pos.y());
double thetan = theta;
int sign = 1;
if (pos.z() < 0) sign = -1;
double xe = pos.x();
double ye = pos.y();
double ze = pos.z();
double rotationangle=0.;
if (std::abs(posr/pos.z())>MuonHough::tan_barrel) {
// Barrel Extrapolation
if ( (posr*posr-r0*r0) > 0) {
double lenr = std::sqrt(posr*posr-r0*r0);
double len = posr - fabs(r0);
double diffr = posr-MuonHough::radius_cylinder;
rotationangle = diffr*invcurvature/sctheta.sn;
xe = roadpos.x() + lenr * scphi.cs;
ye = roadpos.y() + lenr * scphi.sn;
ze = roadpos.z() + len/tantheta + diffr*rotationangle;
thetan = std::atan2(1.,1/tantheta + 2*rotationangle);
}
} else {
double lext=0., rotationangle=0.;
if ( std::abs(pos.z()) < MuonHough::z_end) {
// Forward in Toroid
double diffz = pos.z()-sign*MuonHough::z_cylinder;
rotationangle = diffz*invcurvature/sctheta.cs;
lext = (pos.z()-roadpos.z())*tantheta - diffz*rotationangle;
} else {
// Forward OutSide EC Toroid
double effcurv = invcurvature/sctheta.cs;
rotationangle = sign*(MuonHough::z_end-MuonHough::z_cylinder)*effcurv;
lext = (pos.z()-roadpos.z())*tantheta + (MuonHough::z_magnetic_range_squared - 2*sign*pos.z()*MuonHough::z_magnetic_range)*effcurv;
}
xe = roadpos.x() + lext * scphi.cs;
ye = roadpos.y() + lext * scphi.sn;
double dx = tantheta - 2*rotationangle;
if (dx !=0) thetan = std::atan2(1.,1/dx);
}
// In case direction theta is rotated for low momenta: flip direction vector
CxxUtils::sincos scthetan(thetan);
if (sctheta.cs*scthetan.cs+sctheta.sn*scthetan.sn < 0) {
roaddire = Amg::Vector3D(scthetan.sn*scphi.cs,scthetan.sn*scphi.sn,-scthetan.cs);
} else {
roaddire = Amg::Vector3D(scthetan.sn*scphi.cs,scthetan.sn*scphi.sn,scthetan.cs);
}
roadpose = Amg::Vector3D(xe,ye,ze);
}
|
f741063baa39ac4c860eb519c18fe1debffb7007 | 048fddf3e02996a50163d014987d2a1e0f852b05 | /20130727/a.cpp | febdbff4ff0a2e318a3dc999935e8c7f4b69c3c1 | [] | no_license | muhammadali493/Competitive-coding | 2a226d4214ea2a9c39dcd078d449d8791d80a033 | 0a6bb332fb2d05a4e647360a4c933e912107e581 | refs/heads/master | 2023-07-17T08:40:06.201930 | 2020-06-07T07:41:39 | 2020-06-07T07:41:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,165 | cpp | a.cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const long long oo = 1LL << 60;
const int N = 1010;
long long dp[N][N],cost[N][N];
int s[N][N];
long long X[N],Y[N];
int n,m;
void get_cost()
{
for(int i = 0; i <= n + 5; i ++)
for(int j = 0; j <= n + 5; j ++)
cost[i][j] = 0;
for(int i = 1; i <= n; i ++) {
long long sum = Y[i];
for(int j = i + 1; j <= n; j ++) {
cost[i][j] = cost[i][j - 1] + (X[j] - X[j - 1]) * sum;
sum += Y[j];
}
}
}
int main()
{
while(scanf("%d%d",&n,&m) != EOF) {
for(int i = 1; i <= n; i ++)
scanf("%lld%lld",&X[i],&Y[i]);
get_cost();
for(int i = 1; i <= n; i ++) {
s[1][i] = 0;
dp[1][i] = cost[1][i];
}
for(int i = 2; i <= m; i ++) {
for(int j = n; j >= 1; j --) {
dp[i][j] = oo;
int st,ed;
st = s[i - 1][j],ed = s[i][j + 1];
if(j == n) st = i - 1,ed = j;
for(int k = st; k <= ed; k ++)
if(dp[i][j] > dp[i - 1][k] + cost[k + 1][j]) {
dp[i][j] = dp[i - 1][k] + cost[k + 1][j];
s[i][j] = k;
}
}
}
printf("%lld\n",dp[m][n]);
}
return 0;
}
|
8eb02d7f30629330a28e1514c2378bf4bd9bfaa5 | 3927eb7aaa3cfa45ffc57f0a7a6b00417a720fea | /URI/01049-animal.cpp | 1df515e753431f221e89e87c6e947b670a44df09 | [] | no_license | jbsilva/Programming_Challenges | c2e5ee12bf3d2f17ce9b907447cd2c27d6198d7f | 889274951b1bbb048e8ea3a4843fac97ce6a95e3 | refs/heads/main | 2021-07-07T06:13:04.748780 | 2021-05-02T20:29:38 | 2021-05-02T20:29:38 | 49,593,340 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,328 | cpp | 01049-animal.cpp | // ============================================================================
//
// Filename: 01049-animal.cpp
//
// Description: URI 1049 - Animal
//
// Version: 1.0
// Created: 09/28/2012 09:27:20 AM
// Revision: none
// Compiler: g++
//
// Author: Julio Batista Silva (351202), julio(at)juliobs.com
// Company: UFSCar
//
// ============================================================================
#include <iostream>
using namespace std;
int main()
{
string n1, n2, n3;
cin >> n1 >> n2 >> n3;
if (n1 == "vertebrado")
{
if (n2 == "ave")
{
if (n3 == "carnivoro")
cout << "aguia" << endl;
else
cout << "pomba" << endl;
}
else if (n2 == "mamifero")
{
if (n3 == "onivoro")
cout << "homem" << endl;
else
cout << "vaca" << endl;
}
}
else
{
if (n2 == "inseto")
{
if (n3 == "hematofago")
cout << "pulga" << endl;
else
cout << "lagarta" << endl;
}
else if (n3 == "hematofago")
cout << "sanguessuga" << endl;
else
cout << "minhoca" << endl;
}
return 0;
}
|
fc7127fe85e3eb28442b804730b7cd22c0f31cfb | 57752bc60d0e0b4d05dcf8ded7207f5dfaf8d60e | /sources/xml_planet.cpp | bf6e26380099d9559f7158431b9b6947a37b33da | [] | no_license | anirul/BioliteDemo | 7a1590a7a822a561a5760ac77b6890608014e02f | ec0bd4af899dc1a94123f3056675660090001bd0 | refs/heads/master | 2020-04-22T10:18:05.922200 | 2014-12-21T03:08:43 | 2014-12-21T03:08:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,393 | cpp | xml_planet.cpp | /*
* Copyright (c) 2006-2010, anirul
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Calodox nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY anirul ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL anirul BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "media_collection.h"
#include "xml_misc.h"
#include "xml_planet.h"
std::string xml_planet::parsePlanet(irr::io::IXMLReaderUTF8* xml) {
bool fault = true;
std::string file("");
if (xml->getAttributeCount() > 0)
throw std::runtime_error(
"XML PARSE ERROR : there is no attributes in planet");
do {
if (xml->getNodeType() == irr::io::EXN_ELEMENT_END)
throw std::runtime_error("XML PARSE ERROR : this node has no text");
if (xml->getNodeType() == irr::io::EXN_TEXT) {
file = xml->getNodeData();
if (!file.size())
throw std::runtime_error(
"XML PARSE ERROR : planet cannot be empty");
fault = false;
break;
}
} while (xml->read());
if (fault)
throw std::runtime_error(
"XML PARSE ERROR : unexpected end of file in planet");
return file;
}
xml_planet* xml_planet::parsePlanet(
const std::string& file,
irr::scene::ISceneNode* parent,
irr::scene::ISceneManager* mgr)
{
// planet XML loading
irr::io::IXMLReaderUTF8* xml =
mgr->getFileSystem()->createXMLReaderUTF8(
getPathOfMedia(file.c_str(), "xml").c_str());
if (!xml) {
std::ostringstream oss;
oss << "ERROR : [" << file << "] not found!";
throw std::runtime_error(oss.str());
}
// parse the planet file
std::vector<irr::video::S3DVertex> vert_list;
std::vector<unsigned short> index_list;
std::string seed = "";
irr::video::SColor low;
irr::video::SColor medium;
irr::video::SColor high;
bool is_color_low = false;
bool is_color_medium = false;
bool is_color_high = false;
while (xml->read()) {
if (xml->getNodeType() == irr::io::EXN_ELEMENT) {
std::string elementName = xml->getNodeName();
// got the root planet
if (elementName == std::string("planet")) {
if (xml->getAttributeCount() != 1) throw std::runtime_error(
"XML PARSE ERROR : planet has one attribute");
for (unsigned int i = 0; i < xml->getAttributeCount(); ++i) {
std::string attrib = xml->getAttributeName(i);
if (attrib == std::string("seed")) continue;
throw std::runtime_error(
"XML PARSER ERROR : unknown attribute in planet");
}
seed = xml->getAttributeValue("seed");
}
// got a vertex
if (elementName == std::string("vertex"))
vert_list.push_back(
xml_misc::parseVertex(xml));
// got a triangle
if (elementName == std::string("triangle")) {
irr::core::vector3di vec = xml_misc::parseTriangle(xml);
index_list.push_back(vec.X);
index_list.push_back(vec.Y);
index_list.push_back(vec.Z);
}
// got a color
if (elementName == std::string("color-low")) {
if (is_color_low) throw std::runtime_error(
"XML PARSER ERROR : only one color-low per planet");
is_color_low = true;
low = xml_misc::parseColor(xml);
}
if (elementName == std::string("color-medium")) {
if (is_color_medium) throw std::runtime_error(
"XML PARSER ERROR : only one color-medium per planet");
is_color_medium = true;
medium = xml_misc::parseColor(xml);
}
if (elementName == std::string("color-high")) {
if (is_color_high) throw std::runtime_error(
"XML PARSER ERROR : only one color-high per planet");
is_color_high = true;
high = xml_misc::parseColor(xml);
}
}
// check for the closure of planet
if ((xml->getNodeType() == irr::io::EXN_ELEMENT_END) &&
(std::string(xml->getNodeName()) == std::string("planet")))
{
xml_planet* pl = new xml_planet(
parent,
mgr,
seed,
low,
medium,
high,
vert_list,
index_list);
return pl;
}
}
throw std::runtime_error("XML PARSE ERROR : unexpected end of file");
}
void xml_planet::savePlanet(
std::ostream& os,
const planet& pl)
{
os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
os << "<planet seed=\"" << pl.m_seed << "\">" << std::endl;
xml_misc::saveColor(os, pl.m_ground, 1, std::string("-low"));
xml_misc::saveColor(os, pl.m_grass, 1, std::string("-medium"));
xml_misc::saveColor(os, pl.m_high, 1, std::string("-high"));
for (unsigned int i = 0; i < pl.m_vvert.size(); ++i) {
xml_misc::saveVertex(os, pl.m_vvert[i], 1);
}
for (unsigned int i = 0; i < pl.m_vind.size(); i += 3) {
xml_misc::saveTriangle(
os,
pl.m_vind[i],
pl.m_vind[i + 1],
pl.m_vind[i + 2],
1);
}
os << "</planet>" << std::endl;
}
xml_planet::xml_planet(
irr::scene::ISceneNode* parent,
irr::scene::ISceneManager* mgr,
const std::string& seed,
const irr::video::SColor& low,
const irr::video::SColor& med,
const irr::video::SColor& high,
const std::vector<irr::video::S3DVertex>& vertices,
const std::vector<unsigned short>& indices)
: planet(parent, mgr, seed, low, med, high)
{
m_vvert.clear();
m_vind.clear();
m_vvert = vertices;
m_vind = indices;
m_seed = seed;
set_seed(hash(seed));
m_gen_done = m_gen_size;
m_normal_done = m_vvert.size();
compute_color();
}
xml_planet::~xml_planet() {}
|
901e15bf34fe3466e3c39d13386d20bf5cb34d08 | 0eff74b05b60098333ad66cf801bdd93becc9ea4 | /second/download/squid/gumtree/squid_repos_function_2734_squid-3.5.27.cpp | 5b991c17dd17128a8c62551ab73fa479be30cda5 | [] | 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 | 65 | cpp | squid_repos_function_2734_squid-3.5.27.cpp | virtual bool canDial(AsyncCall &call) { return tunnel_.valid(); } |
3872a8893fffbf6ba2a394baab2ce0e9fe6481e0 | 7a2759d38c44109463ddeb3c70e3534194861200 | /src/main.cpp | 60c9c2946ae2e1ff597a22681b99c68ffa631f16 | [
"CC-BY-3.0"
] | permissive | benoit-leveau/Ubik | 1725dc114c9b78e1dcdfc854cf3f01f1814cb72b | 71733056c1feefe12a894b4016c2f8ec1743879d | refs/heads/master | 2020-06-05T20:04:17.331877 | 2019-06-26T11:30:44 | 2019-06-26T11:30:44 | 192,533,342 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,504 | cpp | main.cpp | #include <memory>
#include "options.hpp"
#include "scene.hpp"
#include "renderer.hpp"
#include "integrator.hpp"
#include "sampler.hpp"
#include "OptionParser.h"
#include "logging.hpp"
#include "signal.hpp"
#include "adaptativesampler.hpp"
#include "fixedsampler.hpp"
int main(int argc, char**argv)
{
const std::string usage = "usage: %prog [OPTION]... [FILE]...";
const std::string version = "%prog 1.0\nCopyright (C) 2015 Benoit Leveau\n";
optparse::OptionParser parser = optparse::OptionParser()
.usage(usage)
.version(version);
optparse::OptionGroup group = optparse::OptionGroup(parser, "Global Options");
group.add_option("--width").action("store").type("int").set_default(640).help("Output width. (default: %default)");
group.add_option("--height").action("store").type("int").set_default(480).help("Output height. (default: %default)");
group.add_option("-t", "--threads").action("store").type("int").set_default(0).help("Sets the number of threads. (default: %default - use all available cores)");
group.add_option("-v", "--verbosity").action("store").type("int").set_default(3).help("Verbosity. (default: %default)");
parser.add_option_group(group);
// Add choice for Sampler + options for each sampler
char const* const samplers[] = { "fixed", "adaptative" };
parser.add_option("--sampler").choices(&samplers[0], &samplers[2]).set_default(samplers[0]).help("Sets the sampler algorithm. default: %default");
FixedSampler::createOptions(parser);
AdaptativeSampler::createOptions(parser);
// Add choice for Integrator + options for each integrator
char const* const integrators[] = { "smallpt", "pathtracer", "image" };
parser.add_option("--integrator").choices(&integrators[0], &integrators[3]).set_default(integrators[0]).help("Sets the integrator algorithm. default: %default");
// no options
// Add choice for Renderer + options for each renderer
char const* const renderers[] = { "tiled", "interactive" };
parser.add_option("--renderer").choices(&renderers[0], &renderers[2]).set_default(renderers[0]).help("Sets the renderer algorithm. default: %default");
optparse::OptionGroup group_tiled = optparse::OptionGroup(parser, "Tiled Renderer Options");
group_tiled.add_option("--show-window").action("store_true").help("Show a render window.");
group_tiled.add_option("--bucket-size").action("store").type("int").set_default(64).help("Sets the bucket size. default: %default");
char const* const modes[] = { "topleft", "topright", "bottomleft", "bottomright", "spiral" };
group_tiled.add_option("-m", "--mode").choices(&modes[0], &modes[5]).set_default("spiral").help("Sets the bucket order mode. default: %default");
group_tiled.add_option("-o", "--output").action("store").type("string");
parser.add_option_group(group_tiled);
optparse::Values& parse_options = parser.parse_args(argc, argv);
// setup ctrl-c/interruption/sigint handler
install_handler();
Logger logger(int(parse_options.get("verbosity")));
logger.log_system_info(INFO);
// render options
Options options(int(parse_options.get("width")),
int(parse_options.get("height")),
std::string(parse_options.get("sampler")),
std::string(parse_options.get("integrator")),
std::string(parse_options.get("renderer")),
bool(parse_options.get("show_window")),
int(parse_options.get("bucket_size")),
std::string(parse_options.get("mode")),
size_t(parse_options.get("min_samples")),
size_t(parse_options.get("max_samples")),
size_t(parse_options.get("samples")),
double(parse_options.get("threshold")),
int(parse_options.get("threads")),
std::string(parse_options.get("output")));
// read/construct scene
auto scene = std::make_shared<Scene>(options, logger);
scene->load();
// construct integrator
auto integrator = Integrator::create_integrator(options, scene, logger);
// construct sampler
std::shared_ptr<Sampler> sampler = nullptr;
if (options.renderer != "interactive")
sampler = Sampler::create_sampler(options, integrator, logger);
auto renderer = Renderer::create_renderer(scene, integrator, sampler, options, logger);
renderer->run();
return 0;
}
|
0484440baac42fe16d50ca1a291c2f23b1f75494 | 41b444116c8431b7e4199f78b0f27f1dc61d190f | /P1213.cpp | a354b7b4fe96a5e8ea7a39a94674136e02e36ac8 | [
"MIT"
] | permissive | lwzhenglittle/NOIP | 6caa100b1865c93837deca3283bf43e54c84462f | f256c8d706b3ac985de04a5fae77246f44ba5b23 | refs/heads/master | 2021-07-12T06:58:37.345212 | 2020-09-27T12:09:49 | 2020-09-27T12:09:49 | 207,077,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 262 | cpp | P1213.cpp | #include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
int a[5][5];
int main()
{
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
scanf("%d",&a[i][j]);
}
}
return 0;
} |
98249174dcba6f0776327a377ea1874caf3fc8b5 | 9933cc1d5223f4cb249b2de08cf8877cc616dfb1 | /Rectangle.cpp | 481299eba4e3188186ce2f2542901c1f714e1cba | [] | no_license | shaminR/Lab2 | f734f40166f2bc6a9f6615653bda1db9683db646 | 8ec510fd2d7860901778cc858fdba2d7576ea728 | refs/heads/master | 2020-08-04T01:55:44.384928 | 2019-10-04T15:39:09 | 2019-10-04T15:39:09 | 211,961,592 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 278 | cpp | Rectangle.cpp | #include "Rectangle.h"
#include <iostream>
#include <iomanip>
#include "Point.h"
#include "Square.h"
#include "Shape.h"
#include <cstring>
Rectangle::~Rectangle(){}
// int main(){
// Point p(19.0, 4.0);
// Rectangle r(p, "ur mum", 12.0, 14.0);
// r.display();
// } |
8427aaf6a113e265948812b94ce6176f80dfdab3 | 32f974a070d55053cdd72ab96dd74fba9214278e | /C++/#39_Combination Sum.cpp | 41b25a3a7011d8ad16f3504499d2397831f5e239 | [] | no_license | OjasWadhwani/Leetcode-Solutions | c0cc41396c86b2c6585ef1a86b021a4e4653a263 | 3d8a88af34adc39a75d58683d1976d6e185f75ad | refs/heads/main | 2023-04-20T12:31:52.252485 | 2021-05-20T12:02:03 | 2021-05-20T12:02:03 | 335,879,202 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 810 | cpp | #39_Combination Sum.cpp | class Solution {
public:
vector<vector<int>> combinationSum(vector<int>& candidates, int target) {
vector<vector<int>> result;
sort(candidates.begin(), candidates.end());
vector<int> tryout;
checkSum(candidates, target, 0, tryout, result);
return result;
}
private:
void checkSum(vector<int>& candidates, int target, int index, vector<int>& tryout, vector<vector<int>>& result){
if(target<0) return;
if(target==0) {result.push_back(tryout); return;}
for(int i=index; i<candidates.size(); i++){
// if(i>index && candidates[i]==candidates[i-1]) continue;
tryout.push_back(candidates[i]);
checkSum(candidates, target-candidates[i], i, tryout, result);
tryout.pop_back();
}
}
}; |
08f17b81ae63a275a630f85ea148f03c053ccf82 | 3f3c4602af10950d28c893c36e75879245d5faf7 | /A2/Triangle.cpp | 5f60505cf577eefc2efd30b091b758c9ed82534e | [] | no_license | SuperVivian/computer_graphics_assignments | 7b164f12c6593463acd93eced6e478068a047b09 | b98cac60191ba51059601fb391fc536f082fc443 | refs/heads/master | 2021-02-04T10:14:02.310955 | 2020-02-28T01:53:32 | 2020-02-28T01:53:32 | 243,654,656 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,499 | cpp | Triangle.cpp | #include "stdafx.h"
#include "Triangle.h"
Triangle::Triangle (Vec3f &a, Vec3f &b, Vec3f &c, Material *m)
{
this->a = a;
this->b = b;
this->c = c;
this->mat = m;
ab = a - b; ac = a - c; bc = b - c;
Vec3f::Cross3 (normals[0],ab,ac);
normals[1] = normals[2] = normals[0];
}
Triangle::~Triangle ()
{
}
bool Triangle::intersect (const Ray &r, Hit &h, float tmin) {
//bool intersect = false;
////Ro + t * Rd = a + B(b-a) + G(c-a)
////if B+G < 1 & B > 0 & G > 0 intersect
////用三阶行列式求解三元一次方程组
//Vec3f origin = r.getOrigin ();
//Vec3f dir = r.getDirection ();
//Vec3f ao = a - origin;
//float A = Matrix::Determinant (ab,ac,dir);
//float B = Matrix::Determinant (ao,ac,dir) / A;
//float G = Matrix::Determinant (ab,ao,dir) / A;
//float t = Matrix::Determinant (ab,ac,ao) / A;
//if (t > tmin && B>0 && G>0 && (B + G)>0 && t < h.getT () ) {
// h.set (t,mat,normal,r);
// intersect = true;
//}
//return intersect;
Vec3f R_o = r.getOrigin ();
Vec3f R_d = r.getDirection ();
Matrix3f A (this->a.x () - this->b.x (), this->a.x () - this->c.x (), R_d.x (),
this->a.y () - this->b.y (), this->a.y () - this->c.y (), R_d.y (),
this->a.z () - this->b.z (), this->a.z () - this->c.z (), R_d.z ());
Matrix3f BetaM (this->a.x () - R_o.x (), this->a.x () - this->c.x (), R_d.x (),
this->a.y () - R_o.y (), this->a.y () - this->c.y (), R_d.y (),
this->a.z () - R_o.z (), this->a.z () - this->c.z (), R_d.z ());
float beta = BetaM.determinant () / A.determinant ();
Matrix3f GammaM (this->a.x () - this->b.x (), this->a.x () - R_o.x (), R_d.x (),
this->a.y () - this->b.y (), this->a.y () - R_o.y (), R_d.y (),
this->a.z () - this->b.z (), this->a.z () - R_o.z (), R_d.z ());
float gamma = GammaM.determinant () / A.determinant ();
float alpha = 1.0f - beta - gamma;
Matrix3f tM (this->a.x () - this->b.x (), this->a.x () - this->c.x (), this->a.x () - R_o.x (),
this->a.y () - this->b.y (), this->a.y () - this->c.y (), this->a.y () - R_o.y (),
this->a.z () - this->b.z (), this->a.z () - this->c.z (), this->a.z () - R_o.z ());
float t = tM.determinant () / A.determinant ();
if (beta + gamma > 1) {
return false;
}
if (beta < 0) {
return false;
}
if (gamma < 0) {
return false;
}
if (t > tmin && t < h.getT ()) {
Vec3f newNormal =Vec3f(alpha*normals[0] + beta *normals[1] + gamma *normals[2]).Normalized();
h.set (t, this->mat, newNormal,r);
return true;
}
else {
return false;
}
}
|
16c27a526cc2911b383ac80e831ff387732aeecf | 85031cfaa11bb3c584552228e7e39a5c24f924e8 | /include/Ray.h | 4c210decf9f5bc2b41b71271d33e83f3703b47a1 | [] | no_license | Naetw/A-simple-ray-tracer | 02cc259b182c6a231ab5f5364e03f1dbb3acf4a8 | c8d1c68a3dcf09587500f5d42cd8dcc605ca87fe | refs/heads/main | 2023-02-26T06:56:41.314766 | 2021-02-03T17:51:43 | 2021-02-03T17:53:40 | 306,239,360 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,983 | h | Ray.h | #ifndef RAYTRACER_RAY_H
#define RAYTRACER_RAY_H
#include "Albedo.h"
#include "Color.h"
#include "Point3.h"
#include "Vector3.h"
#include <functional>
class HittableList;
class Ray;
class Ray {
private:
Point3 m_origin;
Vector3 m_direction;
public:
~Ray() = default;
Ray() = default;
Ray(const Point3 &origin, const Vector3 &direction)
: m_origin(origin), m_direction(direction) {}
const Point3 &origin() const { return m_origin; }
const Vector3 &direction() const { return m_direction; }
Point3 at(double factor) const;
/// Generate a color for the ray based on the `world`
///
/// If the ray doesn't hit anything, we use a default background generator
/// which generates a blend color of white and blue. Users can provide
/// their own background generator.
Color generateRayColor(
const HittableList &world, uint32_t depth,
std::function<Color(const Ray &)> generateBackgroundColor =
[](const Ray &ray) {
Color white_color(1.0, 1.0, 1.0);
Color blue_color(0.5, 0.7, 1.0);
const Vector3 &unit_direction = ray.direction().getUnitVector();
// generated color bases on coordinate y
// first, normalize y from -1.0 ~ 1.0 to 0.0 ~ 1.0
// then, when normalized y is 1.0, use blue; while 0.0, use
// white
auto t = 0.5 * (unit_direction.y() + 1.0);
// blend the white and blue
return Albedo(1.0 - t) * white_color + Albedo(t) * blue_color;
}) const;
/// Return true if m_direction is (0, 0, 0) which means that this isn't a
/// valid ray.
bool operator!() const;
public:
static Vector3 getReflectedRay(const Ray &ray, const Vector3 &normal);
static Vector3 getRefractedRay(const Ray &ray, const Vector3 &normal,
double refraction_ratio);
};
#endif
|
615f5708371670464dcfc382faef2268f14a7821 | 09c0e2dad920fe78e985c6b1b29f20a05b35641f | /Library - C++/dziennik.cpp | e5aba3f9a55ad59e8f49ac8ad8e6947ce865f3c3 | [] | no_license | mackurzawa/Library---Database | 568d0f7bbb127b9a62b44da43ff99097c07aedb6 | 6451979475a65f03bdd6512a0d1c3a685b0a3b04 | refs/heads/main | 2023-08-13T11:51:43.135896 | 2021-10-06T14:19:21 | 2021-10-06T14:19:21 | 380,740,707 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 686 | cpp | dziennik.cpp | #include"dziennik.h"
dziennik::dziennik(bool czy_pytac)
:czasopismo(czy_pytac)
{
if(czy_pytac)
{
std::cout<<"Podaj godzine o ktorej ukazuje sie dziennik:\t";
getline(std::cin, ktora_godzina);
std::cout<<"Podaj nazwe dziennika:\t";
getline(std::cin, nazwa_dziennika);
}
}
std::string dziennik::return_godzina()
{
return ktora_godzina;
}
void dziennik::change_godzina(std::string nowa_godzina)
{
ktora_godzina = nowa_godzina;
}
std::string dziennik::return_nazwa_dziennika()
{
return nazwa_dziennika;
}
void dziennik::change_nazwa_dziennika(std::string nowa_nazwa_dziennika)
{
nazwa_dziennika = nowa_nazwa_dziennika;
}
|
b2b6f263b635b2ab7633efa6986af5414638a640 | 85919b58dfe83783025b17c307406cc71a9900f5 | /src/TelegramNative.cpp | 6c7769c7192501392ff830c40acd8fcb2ab05c16 | [
"BSL-1.0"
] | permissive | Infactum/telegram-native | 96360f40623c8ae26b6125e80f3b35234453b238 | 860b5e00cbe38012d7c2e931ca004beda995bc2b | refs/heads/master | 2022-04-29T18:42:00.559421 | 2020-12-09T19:25:08 | 2020-12-09T19:25:08 | 132,420,781 | 65 | 28 | BSL-1.0 | 2020-04-04T20:31:12 | 2018-05-07T07:05:46 | C++ | UTF-8 | C++ | false | false | 10,328 | cpp | TelegramNative.cpp | #include <td/telegram/td_json_client.h>
#include <td/telegram/td_log.h>
#include <unicode/unistr.h>
#include "TelegramNative.h"
bool TelegramNative::Init(void *connection_) {
connection = static_cast<IAddInDefBase *>(connection_);
return connection != nullptr;
}
bool TelegramNative::setMemManager(void *memory_manager_) {
memory_manager = static_cast<IMemoryManager *>(memory_manager_);
return memory_manager != nullptr;
}
bool TelegramNative::RegisterExtensionAs(WCHAR_T **ext_name) {
char16_t name[] = u"TelegramNative";
if (!memory_manager || !memory_manager->AllocMemory(reinterpret_cast<void **>(ext_name), sizeof(name))) {
return false;
};
memcpy(*ext_name, name, sizeof(name));
return true;
}
long TelegramNative::FindMethod(const WCHAR_T *method_name) {
icu::UnicodeString lookup_name{method_name};
for (auto i = 0u; i < methods.size(); ++i) {
if (methods[i].toLower() == lookup_name.toLower()) {
return static_cast<long>(i);
}
}
for (auto i = 0u; i < methods_ru.size(); ++i) {
if (methods_ru[i].toLower() == lookup_name.toLower()) {
return static_cast<long>(i);
}
}
return -1;
}
const WCHAR_T *TelegramNative::GetMethodName(const long num, const long lang_alias) {
if (num > LastMethod) {
return nullptr;
}
icu::UnicodeString method_name;
switch (lang_alias) {
case 0:
method_name = methods[num];
break;
case 1:
method_name = methods_ru[num];
break;
default:
return nullptr;
}
if (method_name.isEmpty()) {
return nullptr;
}
WCHAR_T *result = nullptr;
size_t bytes = (method_name.length() + 1) * sizeof(char16_t);
if (!memory_manager || !memory_manager->AllocMemory(reinterpret_cast<void **>(&result), bytes)) {
return nullptr;
};
memcpy(result, method_name.getTerminatedBuffer(), bytes);
return result;
}
long TelegramNative::GetNParams(const long method_num) {
switch (method_num) {
case TdExecute:
case TdSend:
case SetAsyncMode:
case TdSetLogFilePath:
case TdSetLogMaxFileSize:
case TdSetLogVerbosityLevel:
return 1;
case TdReceive:
default:
return 0;
}
}
bool TelegramNative::HasRetVal(const long method_num) {
switch (method_num) {
case TdExecute:
case TdReceive:
case TdSetLogFilePath:
return true;
case TdSend:
case SetAsyncMode:
case TdSetLogMaxFileSize:
case TdSetLogVerbosityLevel:
default:
return false;
}
}
bool TelegramNative::CallAsProc(const long method_num, tVariant *params, const long array_size) {
switch (method_num) {
case TdSend: {
std::string command;
if (!parse_param(params[0], command)) {
return false;
};
td_json_client_send(telegram_client, command.c_str());
return true;
}
case SetAsyncMode: {
if (params[0].vt != VTYPE_BOOL) {
return false;
}
if (async_mode == params[0].bVal) {
return false;
}
async_mode = params[0].bVal;
if (connection && connection->GetEventBufferDepth() < buffer_depth) {
connection->SetEventBufferDepth(buffer_depth);
}
if (async_mode) {
rcv_thread = std::thread(&TelegramNative::rcv_loop, this);
} else {
if (rcv_thread.joinable()) {
rcv_thread.join();
}
}
return true;
}
case TdSetLogMaxFileSize: {
auto max_file_size = TV_I4(¶ms[0]);
td_set_log_max_file_size(max_file_size);
return true;
}
case TdSetLogVerbosityLevel: {
auto log_level = TV_I4(¶ms[0]);
td_set_log_verbosity_level(log_level);
return true;
}
default:
return false;
}
}
bool
TelegramNative::CallAsFunc(const long method_num, tVariant *ret_value, tVariant *params, const long array_size) {
switch (method_num) {
case TdExecute: {
std::string command;
if (!parse_param(params[0], command)) {
return false;
};
icu::UnicodeString result = td_json_client_execute(telegram_client, command.c_str());
return set_wstr_val(ret_value, result);
}
case TdReceive: {
std::lock_guard<std::mutex> lock(rcv_mtx);
icu::UnicodeString result = td_json_client_receive(telegram_client, rcv_timeout);
return set_wstr_val(ret_value, result);
}
case TdSetLogFilePath: {
std::string command;
if (!parse_param(params[0], command)) {
return false;
};
auto success = td_set_log_file_path(command.c_str());
TV_VT(ret_value) = VTYPE_BOOL;
ret_value->bVal = static_cast<bool>(success);
return true;
}
default:
return false;
}
}
TelegramNative::TelegramNative() {
props = {
u"EventSourceName"
};
props_ru = {
u"ИмяИсточникаСобытий"
};
methods = {
u"Send", u"Receive", u"Execute", u"SetAsyncMode",
u"SetLogFilePath", u"SetLogMaxFileSize", u"SetLogVerbosityLevel"
};
methods_ru = {
u"Отправить", u"Получить", u"Выполнить", u"УстановитьАсинхронныйРежим",
u"УстановитьФайлЖурнала", u"УстановитьМаксимальныйРазмерФайлаЖурнала", u"УстановитьУровеньДетализацииЖурнала"
};
telegram_client = td_json_client_create();
}
TelegramNative::~TelegramNative() {
async_mode = false;
if (rcv_thread.joinable()) {
rcv_thread.join();
}
td_json_client_destroy(telegram_client);
}
bool TelegramNative::parse_param(const tVariant param, std::string &out) {
switch (param.vt) {
case VTYPE_PSTR: {
out.assign(param.pstrVal, param.strLen);
break;
}
case VTYPE_PWSTR: {
icu::UnicodeString tmp{param.pwstrVal, static_cast<int32_t>(param.wstrLen)};
tmp.toUTF8String(out);
break;
}
default:
return false;
}
return true;
}
void TelegramNative::rcv_loop() {
while (async_mode) {
auto es_len = static_cast<size_t>(event_source_name.length() + 1);
auto source = new char16_t[es_len];
memcpy(source, event_source_name.getTerminatedBuffer(), sizeof(WCHAR_T) * es_len);
char16_t message[] = u"Response";
std::lock_guard<std::mutex> lock(rcv_mtx);
icu::UnicodeString response = td_json_client_receive(telegram_client, rcv_timeout);
if (response.isEmpty()) {
continue;
}
auto len = static_cast<size_t>(response.length() + 1);
auto data = new char16_t[len];
memcpy(data, response.getTerminatedBuffer(), len * sizeof(char16_t));
connection->ExternalEvent(reinterpret_cast<WCHAR_T *>(source),
reinterpret_cast<WCHAR_T *>(message),
reinterpret_cast<WCHAR_T *>(data));
delete[] source;
delete[] data;
}
}
long TelegramNative::FindProp(const WCHAR_T *prop_name) {
icu::UnicodeString lookup_name{prop_name};
for (auto i = 0u; i < props.size(); ++i) {
if (props[i].toLower() == lookup_name.toLower()) {
return static_cast<long>(i);
}
}
for (auto i = 0u; i < props_ru.size(); ++i) {
if (props_ru[i].toLower() == lookup_name.toLower()) {
return static_cast<long>(i);
}
}
return -1;
}
bool TelegramNative::GetPropVal(const long num, tVariant *value) {
switch (num) {
case EventSourceName: {
return set_wstr_val(value, event_source_name);
}
default:
return false;
}
}
bool TelegramNative::set_wstr_val(tVariant *dest, icu::UnicodeString &src) {
auto len = static_cast<uint32_t>(src.length());
TV_VT(dest) = VTYPE_PWSTR;
size_t bytes = (len + 1) * sizeof(WCHAR_T);
if (!memory_manager ||
!memory_manager->AllocMemory(reinterpret_cast<void **>(&dest->pwstrVal), bytes)) {
return false;
};
memcpy(dest->pwstrVal, src.getTerminatedBuffer(), bytes);
dest->wstrLen = len;
return true;
}
bool TelegramNative::SetPropVal(const long num, tVariant *value) {
switch (num) {
case EventSourceName:
event_source_name = icu::UnicodeString{value->pwstrVal, static_cast<int32_t>(value->wstrLen)};
return true;
default:
return false;
}
}
const WCHAR_T *TelegramNative::GetPropName(long num, long lang_alias) {
if (num > LastMethod) {
return nullptr;
}
icu::UnicodeString prop_name;
switch (lang_alias) {
case 0:
prop_name = props[num];
break;
case 1:
prop_name = props_ru[num];
break;
default:
return nullptr;
}
if (prop_name.isEmpty()) {
return nullptr;
}
WCHAR_T *result = nullptr;
size_t bytes = (prop_name.length() + 1) * sizeof(char16_t);
if (!memory_manager || !memory_manager->AllocMemory(reinterpret_cast<void **>(&result), bytes)) {
return nullptr;
};
memcpy(result, prop_name.getTerminatedBuffer(), bytes);
return result;
}
bool TelegramNative::IsPropReadable(const long lPropNum) {
switch (lPropNum) {
case EventSourceName:
return true;
default:
return false;
}
}
bool TelegramNative::IsPropWritable(const long lPropNum) {
switch (lPropNum) {
case EventSourceName:
return true;
default:
return false;
}
}
|
418328a501cb53c8b51384d725ff88cf972c1036 | 969472d8d982399871b85e8f92316251d4df5f91 | /sources/cache/DelayObject.h | f472ca2d70e677f4678f3737a677668949c38620 | [] | no_license | arun-blore/graphmc | ef02365c445b7c4f9a83973d7a7850e0e21fffee | 264e6d3fa5474a4967dd529d565c6c06939e23ee | refs/heads/master | 2020-03-10T08:58:35.437772 | 2018-05-11T09:11:09 | 2018-05-11T09:11:09 | 129,299,256 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,117 | h | DelayObject.h | #include "SimObject.h"
enum delay_state {
IDLE,
IN_PROGRESS,
COMPLETE
};
class DelayObject : public SimObject {
int delay;
int counter;
delay_state state;
public:
DelayObject (int d) {
// SimObject ();
delay = d;
counter = 0;
state = IDLE;
}
void update () {
// if counter is 0, object is free and we can restart the count
// if not, decrement the counter.
if (counter > 1) {
counter--;
} else if (counter == 1) {
counter--;
state = COMPLETE;
}
Step ();
}
bool delay_complete () {
if ((counter == 0) && (state == COMPLETE)) {
state = IDLE;
return true;
} else {
return false;
}
}
void start () {
counter = delay;
state = IN_PROGRESS;
// cout << "start: counter = " << counter << endl;
}
bool is_idle () {
return (state == IDLE);
}
void print () {
cout << "counter = " << counter << " state = " << state << endl;
}
};
|
e0bdaac079f48ab8f097588e5ae4778cd2dd756f | 390fe92ae05cd61cd5a5b44c0137c2f0cd6b63ff | /samples/opensource/sampleNMT/model/contextNMT.cpp | cfb0eb7f85001afed92c14e25319e58e4a8fe359 | [
"ISC",
"Apache-2.0",
"BSD-2-Clause",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | Artorias123/TensorRT | 7c26beee6b0cd223244cb21484adfbe7ac95b81a | 83967be94d2fac73128dce9e63ec4c9703fb245e | refs/heads/master | 2022-09-07T02:30:12.678726 | 2020-04-16T18:25:39 | 2020-04-16T19:58:54 | 267,983,361 | 1 | 0 | Apache-2.0 | 2020-05-30T00:49:39 | 2020-05-30T00:49:39 | null | UTF-8 | C++ | false | false | 1,602 | cpp | contextNMT.cpp | /*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "contextNMT.h"
#include <cassert>
#include <sstream>
namespace nmtSample
{
void Context::addToModel(nvinfer1::INetworkDefinition* network, nvinfer1::ITensor* actualInputSequenceLengths,
nvinfer1::ITensor* memoryStates, nvinfer1::ITensor* alignmentScores, nvinfer1::ITensor** contextOutput)
{
auto raggedSoftmaxLayer = network->addRaggedSoftMax(*alignmentScores, *actualInputSequenceLengths);
assert(raggedSoftmaxLayer != nullptr);
raggedSoftmaxLayer->setName("Context Ragged Softmax");
auto softmaxTensor = raggedSoftmaxLayer->getOutput(0);
assert(softmaxTensor != nullptr);
auto mmLayer = network->addMatrixMultiply(*softmaxTensor, false, *memoryStates, false);
assert(mmLayer != nullptr);
mmLayer->setName("Context Matrix Multiply");
*contextOutput = mmLayer->getOutput(0);
assert(*contextOutput != nullptr);
}
std::string Context::getInfo()
{
return "Ragged softmax + Batch GEMM";
}
} // namespace nmtSample
|
7616626ad0c868e7cb923feed7984b430f2a63cd | 0537977523fd46a4f6966be929cc4f1b308a3ff3 | /FPSStealth/Source/FPSStealth/Private/Objective.cpp | 3b1d0d73aea8f681043e48a617bfcd2f89b54409 | [] | no_license | IzabranTebras/PrototypeStealthGame | b7d4d36e09430bc8f37d05bd30edb7992f071588 | a36a59ce6ba7ec7f5259e81b925bc7e9666e25be | refs/heads/master | 2020-06-09T05:34:09.221930 | 2020-01-18T11:48:27 | 2020-01-18T11:48:27 | 193,381,239 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,269 | cpp | Objective.cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "Objective.h"
#include "Components/StaticMeshComponent.h"
#include "Components/SphereComponent.h"
#include "Kismet/GameplayStatics.h"
// Sets default values
AObjective::AObjective()
{
meshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh component"));
meshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
RootComponent = meshComp;
sphereComp = CreateDefaultSubobject<USphereComponent>(TEXT("Sphere component"));
sphereComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
sphereComp->SetCollisionResponseToAllChannels(ECR_Ignore);
sphereComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
sphereComp->SetupAttachment(meshComp);
}
// Called when the game starts or when spawned
void AObjective::BeginPlay()
{
Super::BeginPlay();
}
void AObjective::PlayEffects()
{
UGameplayStatics::SpawnEmitterAtLocation(this, PickupFX, GetActorLocation());
}
void AObjective::NotifyActorBeginOverlap(AActor * OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
AFPSStealthCharacter* myCharacter = Cast<AFPSStealthCharacter>(OtherActor);
if (myCharacter)
{
PlayEffects();
myCharacter->isCarryingObjective = true;
Destroy();
}
}
|
3b14d3ed265884aa20c7f6cd7b59c4830b27f68c | b9e4f272762d5cf871653e4b4a3aa9ad33b05117 | /C语言实验/实验七/2.cpp | 72096b99d76a984bc0e460976e3b8633fff1da31 | [] | no_license | haozx1997/C | e799cb25e1fa6c86318721834032c008764066ed | afb7657a58b86bf985c4a44bedfaf1c9cff30cf4 | refs/heads/master | 2021-07-11T23:54:17.357536 | 2017-10-12T03:42:23 | 2017-10-12T03:42:23 | 106,662,415 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 365 | cpp | 2.cpp | #include<stdio.h>
int main()
{// 输入n个整数,使用指针变量将这n个数按从小到大排序输出。
int a[10],i,j,*p,t;
for (i=0;i<10;i++)
scanf("%d",&a[i]);
p=a;
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
for (i=0;i<10;i++)
printf("%d ",*(p+i));
return 0;
}
|
7d34a52d7b033594967195b9e23f129ffeddf058 | 266bde3aa4381669803e5afe8a947a28532143b9 | /original/CircularWireConstraint.h | f9d4c3379b8795206932fc845fc2cbb8604f1d73 | [
"MIT"
] | permissive | Eddydpyl/ParticleToy | 89f92f2eeb50fb44594475522c6d129a993829e7 | 721863059a220e6dcd8150313204bd2663a5ff93 | refs/heads/master | 2021-08-19T18:17:35.257647 | 2020-03-17T17:11:20 | 2020-03-17T17:11:20 | 132,266,610 | 0 | 0 | null | 2018-06-23T11:39:02 | 2018-05-05T16:45:15 | Java | UTF-8 | C++ | false | false | 263 | h | CircularWireConstraint.h | #pragma once
#include "Particle.h"
class CircularWireConstraint {
public:
CircularWireConstraint(Particle *p, const Vec2f & center, const double radius);
void draw();
private:
Particle * const m_p;
Vec2f const m_center;
double const m_radius;
};
|
785772f64a93b609d4ca6b6107cb5613dfdea6aa | 135886ef48a7f65a4823d376e308d0a720b1f86d | /src/occa/internal/lang/modes/dpcpp.cpp | b1db5e0104ad3e71263444872687909be12c89fd | [
"MIT"
] | permissive | libocca/occa | b912a379243f7f532694dcdd54c50697cf5c838d | ef5218f32ad2444434d84be01716f14243bc174f | refs/heads/main | 2023-08-22T15:47:54.847685 | 2023-06-20T02:23:30 | 2023-06-20T02:23:30 | 38,410,417 | 372 | 104 | MIT | 2023-09-12T18:50:01 | 2015-07-02T04:03:29 | C++ | UTF-8 | C++ | false | false | 13,364 | cpp | dpcpp.cpp | #include <occa/internal/utils/string.hpp>
#include <occa/internal/lang/modes/dpcpp.hpp>
#include <occa/internal/lang/modes/okl.hpp>
#include <occa/internal/lang/modes/oklForStatement.hpp>
#include <occa/internal/lang/builtins/attributes.hpp>
#include <occa/internal/lang/builtins/types.hpp>
#include <occa/internal/lang/expr.hpp>
// #include <stringstream>
namespace occa
{
namespace lang
{
namespace okl
{
dpcppParser::dpcppParser(const occa::json &settings_)
: withLauncher(settings_),
kernel(externC),
device("SYCL_EXTERNAL", qualifierType::custom),
shared("auto", qualifierType::custom)
{
okl::addOklAttributes(*this);
}
void dpcppParser::onClear()
{
launcherClear();
}
void dpcppParser::beforePreprocessing()
{
preprocessor.addCompilerDefine("OCCA_USING_GPU", "1");
}
void dpcppParser::beforeKernelSplit()
{
// addExtensions();
// if(!success)
// return;
// updateConstToConstant();
if (!success)
return;
setFunctionQualifiers();
if (!success)
return;
setSharedQualifiers();
}
void dpcppParser::afterKernelSplit()
{
addBarriers();
if (!success)
return;
setupHeaders();
if (!success)
return;
setupAtomics();
if (!success)
return;
// Do this last!
setupKernels();
}
std::string dpcppParser::getOuterIterator(const int loopIndex)
{
return "item_.get_group(" + occa::toString(dpcppDimensionOrder(loopIndex)) + ")";
}
std::string dpcppParser::getInnerIterator(const int loopIndex)
{
return "item_.get_local_id(" + occa::toString(dpcppDimensionOrder(loopIndex)) + ")";
}
std::string dpcppParser::launchBoundsAttribute(const int innerDims[3])
{
std::stringstream ss;
ss << "[[sycl::reqd_work_group_size("
<< innerDims[2]
<< ","
<< innerDims[1]
<< ","
<< innerDims[0]
<< ")]]\n";
return ss.str();
}
// @note: As of SYCL 2020 this will need to change from `CL/sycl.hpp` to `sycl.hpp`
void dpcppParser::setupHeaders()
{
root.addFirst(
*(new directiveStatement(
&root,
directiveToken(root.source->origin, "include <CL/sycl.hpp>\n using namespace sycl;\n"))));
}
void dpcppParser::addExtensions()
{
if (!settings.has("extensions"))
{
return;
}
occa::json &extensions = settings["extensions"];
if (!extensions.isObject())
{
return;
}
// @todo: Enable dpcpp extensions
// jsonObject &extensionObj = extensions.object();
// jsonObject::iterator it = extensionObj.begin();
// while (it != extensionObj.end()) {
// const std::string &extension = it->first;
// const bool enabled = it->second;
// if (enabled) {
// root.addFirst(
// *(new pragmaStatement(
// &root,
// pragmaToken(root.source->origin,
// "OPENCL EXTENSION "+ extension + " : enable\n")
// ))
// );
// }
// ++it;
// }
}
void dpcppParser::addBarriers()
{
statementArray::from(root)
.flatFilterByStatementType(statementType::empty, "barrier")
.forEach([&](statement_t *smnt)
{
emptyStatement &emptySmnt = (emptyStatement &)*smnt;
statement_t &barrierSmnt = (*(new sourceCodeStatement(
emptySmnt.up,
emptySmnt.source,
"item_.barrier(sycl::access::fence_space::local_space);")));
emptySmnt.replaceWith(barrierSmnt);
delete &emptySmnt;
});
}
void dpcppParser::setupKernels()
{
root.children
.filterByStatementType(
statementType::functionDecl | statementType::function,
"kernel")
.forEach([&](statement_t *smnt)
{
function_t *function;
if (smnt->type() & statementType::functionDecl)
{
functionDeclStatement &k = ((functionDeclStatement &)*smnt);
function = &(k.function());
migrateLocalDecls(k);
if (!success)
return;
variable_t sycl_nditem(syclNdItem, "item_");
variable_t sycl_handler(syclHandler, "handler_");
sycl_handler.vartype.setReferenceToken(
new operatorToken(sycl_handler.source->origin, op::address));
variable_t sycl_ndrange(syclNdRange, "range_");
sycl_ndrange += pointer_t();
variable_t sycl_queue(syclQueue, "queue_");
sycl_queue += pointer_t();
function->addArgumentFirst(sycl_ndrange);
function->addArgumentFirst(sycl_queue);
lambda_t &cg_function = *(new lambda_t(capture_t::byReference));
cg_function.addArgument(sycl_handler);
lambda_t &sycl_kernel = *(new lambda_t(capture_t::byValue));
sycl_kernel.addArgument(sycl_nditem);
sycl_kernel.body->swap(k);
lambdaNode sycl_kernel_node(sycl_kernel.source, sycl_kernel);
leftUnaryOpNode sycl_ndrange_node(
sycl_ndrange.source,
op::dereference,
variableNode(sycl_ndrange.source, sycl_ndrange.clone()));
exprNodeVector parallelfor_args;
parallelfor_args.push_back(&sycl_ndrange_node);
parallelfor_args.push_back(&sycl_kernel_node);
identifierNode parallelfor_node(
new identifierToken(originSource::builtin, "parfor"),
"parallel_for");
callNode parallelfor_call_node(
parallelfor_node.token,
parallelfor_node,
parallelfor_args);
binaryOpNode cgh_parallelfor(
sycl_handler.source,
op::dot,
variableNode(sycl_handler.source, sycl_handler.clone()),
parallelfor_call_node);
cg_function.body->add(*(new expressionStatement(nullptr, cgh_parallelfor)));
lambdaNode cg_function_node(cg_function.source, cg_function);
exprNodeVector submit_args;
submit_args.push_back(&cg_function_node);
identifierNode submit_node(
new identifierToken(originSource::builtin, "qsub"),
"submit");
callNode submit_call_node(
submit_node.token,
submit_node,
submit_args);
binaryOpNode q_submit(
sycl_queue.source,
op::arrow,
variableNode(sycl_queue.source, sycl_queue.clone()),
submit_call_node);
k.addFirst(*(new expressionStatement(nullptr, q_submit)));
}
else
{
function = &(((functionStatement *)smnt)->function());
}
setKernelQualifiers(*function);
});
}
void dpcppParser::setFunctionQualifiers()
{
root.children
.filterByStatementType(statementType::functionDecl)
.forEach([&](statement_t *smnt)
{
functionDeclStatement &funcDeclSmnt = (functionDeclStatement &)*smnt;
if (funcDeclSmnt.hasAttribute("kernel"))
{
return;
}
vartype_t &vartype = funcDeclSmnt.function().returnType;
vartype.qualifiers.addFirst(vartype.origin(), device);
});
}
void dpcppParser::setSharedQualifiers()
{
statementArray::from(root).nestedForEachDeclaration(
[&](variableDeclaration &decl, declarationStatement &declSmnt)
{
variable_t &var = decl.variable();
if (var.hasAttribute("shared"))
{
auto *shared_value = new dpcppLocalMemoryNode(var.source->clone(),
var.vartype,
"item_");
decl.setValue(shared_value);
var.vartype.setType(auto_);
var.vartype.setReferenceToken(var.source);
var.vartype.arrays.clear();
}
});
}
void dpcppParser::setKernelQualifiers(function_t &function)
{
function.returnType.add(0, kernel);
for (auto arg : function.args)
{
vartype_t &type = arg->vartype;
type = type.flatten();
if (!(type.isPointerType() || type.referenceToken))
{
type.setReferenceToken(arg->source);
}
}
}
void dpcppParser::migrateLocalDecls(functionDeclStatement &kernelSmnt)
{
statementArray::from(kernelSmnt)
.nestedForEachDeclaration([&](variableDeclaration &decl, declarationStatement &declSmnt)
{
variable_t &var = decl.variable();
if (var.hasAttribute("shared"))
{
declSmnt.removeFromParent();
kernelSmnt.addFirst(declSmnt);
}
});
}
void dpcppParser::setupAtomics()
{
success &= attributes::atomic::applyCodeTransformation(
root,
transformAtomicBlockStatement,
transformAtomicBasicExpressionStatement);
}
bool dpcppParser::transformAtomicBlockStatement(blockStatement &blockSmnt)
{
bool transform_successful{true};
statementArray::from(blockSmnt)
.flatFilterByStatementType(statementType::expression)
.forEach([&](statement_t *smnt)
{
expressionStatement &exprSmnt = static_cast<expressionStatement &>(*smnt);
// if(!transformAtomicBasicExpressionStatement(exprSmnt))
// {
// transform_successful = false;
// return;
// }
transformAtomicBasicExpressionStatement(exprSmnt);
});
return transform_successful;
}
bool dpcppParser::transformAtomicBasicExpressionStatement(expressionStatement &exprSmnt)
{
expressionStatement &atomicSmnt = dynamic_cast<expressionStatement &>(exprSmnt.clone());
const opType_t &opType = expr(atomicSmnt.expr).opType();
exprNode *variable_node{nullptr};
if (opType & operatorType::unary)
{
if (opType & operatorType::leftUnary)
{
variable_node = ((leftUnaryOpNode *)atomicSmnt.expr)->value;
}
else if (opType & operatorType::rightUnary)
{
variable_node = ((rightUnaryOpNode *)atomicSmnt.expr)->value;
}
}
else if (opType & operatorType::binary)
{
binaryOpNode &binaryNode = *static_cast<binaryOpNode *>(atomicSmnt.expr);
variable_node = binaryNode.leftValue;
}
else
{
atomicSmnt.printError("Unable to transform @atomic code");
return false;
}
variable_t &atomic_var = *(variable_node->getVariable());
vartype_t atomic_type = atomic_var.vartype;
auto *atomic_ref = new dpcppAtomicNode(atomic_var.source, atomic_type, *variable_node);
atomicSmnt.replaceExprNode(variable_node, atomic_ref);
exprSmnt.replaceWith(atomicSmnt);
delete &exprSmnt;
return true;
}
} // namespace okl
} // namespace lang
} // namespace occa
|
d16426055f156939c0f601784a6f357af543b1f8 | 837295fec3fcf5710cf7151708b81aa3117e45af | /AOAPC-BACTG/Chapter 1. Algorithm Design/General Problem Solving Techniques/Exercises Intermediate/UVa_10037.cpp | 67fcd5ad0d9391156d8828c62ce3c7f3cdf23bb7 | [] | no_license | WinDaLex/Programming | 45e56a61959352a7c666560df400966b7539939a | 55e71008133bb09d99252d6281abc30641c6e7e8 | refs/heads/master | 2020-05-31T00:45:24.916502 | 2015-04-13T18:19:36 | 2015-04-13T18:19:36 | 9,115,402 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,494 | cpp | UVa_10037.cpp | // UVa 10037
// Bridge
// by A Code Rabbit
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
const int MAXN = 1002;
int N;
int t[MAXN];
int order[MAXN * 3], top;
int ans;
void pass(int p1 = 0, int p2 = 0, int p3 = 0, int p4 = 0, int p5 = 0, int p6 = 0) {
if (p1) order[top++] = p1;
if (p2) order[top++] = p2;
if (p3) order[top++] = p3;
if (p4) order[top++] = p4;
if (p5) order[top++] = p5;
if (p6) order[top++] = p6;
ans += max(p1, p2) + p3 + max(p4, p5) + p6;
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
scanf("%d", &N);
for (int i = 0; i < N; i++)
scanf("%d", &t[i]);
if (N == 1) {
printf("%d\n%d\n", t[0], t[0]);
printf("%s", T ? "\n" : "");
continue;
}
sort(t, t + N);
top = 0; ans = 0;
int a = t[0], b = t[1], idx;
for (idx = N; idx > 3; idx -= 2) {
int c = t[idx - 2], d = t[idx - 1];
if (c < b * 2 - a) pass(a, d, a, a, c, a);
else pass(a, b, a, c, d, b);
}
if (idx == 3) pass(t[0], t[2], t[0], t[0], t[1]);
else if (idx == 2) pass(t[0], t[1]);
printf("%d\n", ans);
for (int i = 0; i < N - 2; i++)
printf("%d %d\n%d\n", order[i * 3], order[i * 3 + 1], order[i * 3 + 2]);
printf("%d %d\n", order[N * 3 - 6], order[N * 3 - 5]);
printf("%s", T ? "\n" : "");
}
return 0;
}
|
ad314ee6bff8e7b33f1398e1b70facfdd36fdc1c | dd4fde948c30a3ab71a8a3d3587a649e37b04e79 | /nn.h | c5813096aaa53edfaf97bcdaa3afa0d7e5582a37 | [] | no_license | dczhu/MLP-CXX | 17ded58c69e0e6c3b096513867c2cbf80843c723 | 09cdb9365691098206f5ddcf9c371393b96cd444 | refs/heads/master | 2020-03-23T08:47:08.677304 | 2018-04-24T16:42:08 | 2018-04-24T16:42:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,636 | h | nn.h | /*
* @Author: kmrocki
* @Date: 2016-02-24 15:28:10
* @Last Modified by: kmrocki
* @Last Modified time: 2016-02-24 15:28:42
*/
#ifndef __NN_H__
#define __NN_H__
#include <layers.h>
class NN {
public:
std::deque<Layer*> layers;
const size_t batch_size;
void forward(Matrix& input_data) {
//copy inputs to the lowest point in the network
layers[0]->x = input_data;
//compute forward activations
for (size_t i = 0; i < layers.size(); i++) {
//y = f(x)
layers[i]->forward();
//x(next layer) = y(current layer)
if (i + 1 < layers.size())
layers[i + 1]->x = layers[i]->y;
}
}
void backward(Matrix t) {
//set targets at the top
layers[layers.size() - 1]->dy = t;
//propagate error backward
for (int i = layers.size() - 1; i >= 0; i--) {
layers[i]->resetGrads();
layers[i]->backward();
//dy(previous layer) = dx(current layer)
if (i > 0) {
layers[i - 1]->dy = layers[i]->dx;
}
}
}
void update(double alpha) {
//update all layers according to gradients
for (size_t i = 0; i < layers.size(); i++) {
layers[i]->applyGrads(alpha);
}
}
void train(std::deque<datapoint> data, double alpha, size_t iterations) {
//get random examples of size batch_size from data
Eigen::VectorXi random_numbers(batch_size);
size_t classes = 10;
for (size_t ii = 0; ii < iterations; ii++) {
randi(random_numbers, 0, data.size() - 1);
// [784 x batch_size]
Matrix batch = make_batch(data, random_numbers);
Matrix targets = make_targets(data, random_numbers, classes);
//forward activations
forward(batch);
double loss = cross_entropy(layers[layers.size() - 1]->y, targets);
std::cout << "[" << ii + 1 << "/" << iterations << "] Loss = " << loss << std::endl;
//backprogagation
backward(targets);
//apply changes
update(alpha);
}
}
void test(std::deque<datapoint> data) {
Eigen::VectorXi numbers(batch_size);
size_t classes = 10;
size_t correct = 0;
for (size_t ii = 0; ii < data.size(); ii += batch_size) {
linspace(numbers, ii, ii + batch_size);
Matrix batch = make_batch(data, numbers);
Matrix targets = make_targets(data, numbers, classes);
forward(batch);
correct += count_correct_predictions(layers[layers.size() - 1]->y, targets);
}
std::cout << "Test % correct = " << 100.0 * (double)correct / (double)(data.size()) << std::endl;
}
NN(size_t minibatch_size) : batch_size(minibatch_size) { }
~NN() {
for (size_t i = 0; i < layers.size(); i++) {
delete(layers[i]);
}
}
};
#endif |
d869abd8adab61d7906e08611460f76af5614be9 | b4b26850252d85454288b7493a586880eb054df1 | /ssl.cpp | cda14eb5080a76fbea7e70cb768e1af99199329c | [] | no_license | liutaozhao/sunday | af632c9be161a3488f47fbd37b377a866f3fb3f3 | b369cf0a6e55c4915c69ce012dd6ab02344f3aa2 | refs/heads/master | 2020-05-07T21:26:59.352877 | 2019-04-12T01:20:59 | 2019-04-12T01:20:59 | 180,904,946 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,158 | cpp | ssl.cpp | /*
Copyright (c) 2017 Darren Smith
ssl_examples is free software; you can redistribute it and/or modify
it under the terms of the MIT license. See LICENSE for details.
*/
#include <syslog.h>
#include <cstring>
#include "ssl.h"
/* Global SSL context */
SSL_CTX *ctx;
#define DEFAULT_BUF_SIZE 1024
#define int_error(msg) handle_error(__FILE__, __LINE__, msg)
void handle_error(const char *file, int lineno, const char *msg) {
syslog(LOG_INFO, "** %s:%i %s\n", file, lineno, msg);
exit(-1);
}
void die(const char *msg) {
perror(msg);
exit(1);
}
void print_unencrypted_data(char *buf, size_t len,char *outbuf,size_t &lenout) {
memcpy(outbuf,buf,len);
lenout = len;
syslog(LOG_INFO,"%.*s", (int)len, buf);
}
void ssl_client_init(struct ssl_client *p,
int fd,
enum ssl_mode mode)
{
memset(p, 0, sizeof(struct ssl_client));
p->fd = fd;
p->rbio = BIO_new(BIO_s_mem());
p->wbio = BIO_new(BIO_s_mem());
p->ssl = SSL_new(ctx);
if (mode == SSLMODE_SERVER)
SSL_set_accept_state(p->ssl); /* ssl server mode */
else if (mode == SSLMODE_CLIENT)
SSL_set_connect_state(p->ssl); /* ssl client mode */
SSL_set_bio(p->ssl, p->rbio, p->wbio);
p->io_on_read = print_unencrypted_data;
}
void ssl_client_cleanup(struct ssl_client *p)
{
SSL_free(p->ssl); /* free the SSL object and its BIO's */
free(p->write_buf);
free(p->encrypt_buf);
}
int ssl_client_want_write(struct ssl_client *cp) {
return (cp->write_len>0);
}
/* Obtain the return value of an SSL operation and convert into a simplified
* error code, which is easier to examine for failure. */
static enum sslstatus get_sslstatus(SSL* ssl, int n)
{
switch (SSL_get_error(ssl, n))
{
case SSL_ERROR_NONE:
return SSLSTATUS_OK;
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_READ:
return SSLSTATUS_WANT_IO;
case SSL_ERROR_ZERO_RETURN:
case SSL_ERROR_SYSCALL:
default:
return SSLSTATUS_FAIL;
}
}
/* Handle request to send unencrypted data to the SSL. All we do here is just
* queue the data into the encrypt_buf for later processing by the SSL
* object. */
void send_unencrypted_bytes(const char *buf, size_t len, struct ssl_client &client)
{
client.encrypt_buf = (char*)realloc(client.encrypt_buf, client.encrypt_len + len);
memcpy(client.encrypt_buf+client.encrypt_len, buf, len);
client.encrypt_len += len;
}
/* Queue encrypted bytes. Should only be used when the SSL object has requested a
* write operation. */
void queue_encrypted_bytes(const char *buf, size_t len, struct ssl_client &client)
{
client.write_buf = (char*)realloc(client.write_buf, client.write_len + len);
memcpy(client.write_buf+client.write_len, buf, len);
client.write_len += len;
}
enum sslstatus do_ssl_handshake(struct ssl_client &client)
{
char buf[DEFAULT_BUF_SIZE];
enum sslstatus status;
int n = SSL_do_handshake(client.ssl);
status = get_sslstatus(client.ssl, n);
/* Did SSL request to write bytes? */
if (status == SSLSTATUS_WANT_IO)
do {
n = BIO_read(client.wbio, buf, sizeof(buf));
if (n > 0)
queue_encrypted_bytes(buf, n, client);
else if (!BIO_should_retry(client.wbio))
return SSLSTATUS_FAIL;
} while (n>0);
return status;
}
/* Process SSL bytes received from the peer. The data needs to be fed into the
SSL object to be unencrypted. On success, returns 0, on SSL error -1. */
int on_read_cb(char* src, size_t len,char *bufout ,size_t &lenout,struct ssl_client &client)
{
char buf[DEFAULT_BUF_SIZE];
enum sslstatus status;
int n;
while (len > 0) {
n = BIO_write(client.rbio, src, len);
if (n<=0)
return -1; /* assume bio write failure is unrecoverable */
src += n;
len -= n;
if (!SSL_is_init_finished(client.ssl)) {
if (do_ssl_handshake(client) == SSLSTATUS_FAIL)
return -1;
if (!SSL_is_init_finished(client.ssl))
return 0;
}
/* The encrypted data is now in the input bio so now we can perform actual
* read of unencrypted data. */
do {
n = SSL_read(client.ssl, buf, sizeof(buf));
int i = 0;
if (n > 0)
{
client.io_on_read(buf, (size_t)n, bufout,lenout);
}
} while (n > 0);
status = get_sslstatus(client.ssl, n);
/* Did SSL request to write bytes? This can happen if peer has requested SSL
* renegotiation. */
if (status == SSLSTATUS_WANT_IO)
do {
n = BIO_read(client.wbio, buf, sizeof(buf));
if (n > 0)
queue_encrypted_bytes(buf, n, client);
else if (!BIO_should_retry(client.wbio))
return -1;
} while (n>0);
if (status == SSLSTATUS_FAIL)
return -1;
}
return 0;
}
/* Process outbound unencrypted data that is waiting to be encrypted. The
* waiting data resides in encrypt_buf. It needs to be passed into the SSL
* object for encryption, which in turn generates the encrypted bytes that then
* will be queued for later socket write. */
int do_encrypt(struct ssl_client &client)
{
char buf[DEFAULT_BUF_SIZE];
enum sslstatus status;
if (!SSL_is_init_finished(client.ssl))
return 0;
while (client.encrypt_len>0) {
int n = SSL_write(client.ssl, client.encrypt_buf, client.encrypt_len);
status = get_sslstatus(client.ssl, n);
if (n>0) {
/* consume the waiting bytes that have been used by SSL */
if ((size_t)n<client.encrypt_len)
memmove(client.encrypt_buf, client.encrypt_buf+n, client.encrypt_len-n);
client.encrypt_len -= n;
client.encrypt_buf = (char*)realloc(client.encrypt_buf, client.encrypt_len);
/* take the output of the SSL object and queue it for socket write */
do {
n = BIO_read(client.wbio, buf, sizeof(buf));
if (n > 0)
queue_encrypted_bytes(buf, n, client);
else if (!BIO_should_retry(client.wbio))
return -1;
} while (n>0);
}
if (status == SSLSTATUS_FAIL)
return -1;
if (n==0)
break;
}
return 0;
}
/* Read bytes from stdin and queue for later encryption. */
void do_stdin_read(struct ssl_client &client)
{
char buf[DEFAULT_BUF_SIZE];
ssize_t n = read(STDIN_FILENO, buf, sizeof(buf));
if (n>0)
send_unencrypted_bytes(buf, (size_t)n, client);
}
/* Read encrypted bytes from socket. */
int do_sock_read(struct ssl_client &client)
{
char buf[DEFAULT_BUF_SIZE];
char tmpbuf[DEFAULT_BUF_SIZE];
size_t value = 0;
ssize_t n = read(client.fd, buf, sizeof(buf));
if (n>0)
return on_read_cb(buf, (size_t)n, tmpbuf,value,client);
else
return -1;
}
/* Write encrypted bytes to the socket. */
int do_sock_write(struct ssl_client &client)
{
ssize_t n = write(client.fd, client.write_buf, client.write_len);
if (n>0) {
if ((size_t)n<client.write_len)
memmove(client.write_buf, client.write_buf+n, client.write_len-n);
client.write_len -= n;
client.write_buf = (char*)realloc(client.write_buf, client.write_len);
return 0;
}
else
return -1;
}
void ssl_init(const char * certfile, const char* keyfile)
{
syslog(LOG_INFO,"initialising SSL\n");
/* SSL library initialisation */
SSL_library_init();
OpenSSL_add_all_algorithms();
SSL_load_error_strings();
ERR_load_BIO_strings();
ERR_load_crypto_strings();
/* create the SSL server context */
ctx = SSL_CTX_new(SSLv23_method());
if (!ctx)
die("SSL_CTX_new()");
/* Load certificate and private key files, and check consistency */
if (certfile && keyfile) {
if (SSL_CTX_use_certificate_file(ctx, certfile, SSL_FILETYPE_PEM) != 1)
int_error("SSL_CTX_use_certificate_file failed");
if (SSL_CTX_use_PrivateKey_file(ctx, keyfile, SSL_FILETYPE_PEM) != 1)
int_error("SSL_CTX_use_PrivateKey_file failed");
/* Make sure the key and certificate file match. */
if (SSL_CTX_check_private_key(ctx) != 1)
int_error("SSL_CTX_check_private_key failed");
else
syslog(LOG_INFO,"certificate and private key loaded and verified\n");
}
/* Recommended to avoid SSLv2 & SSLv3 */
SSL_CTX_set_options(ctx, SSL_OP_ALL|SSL_OP_NO_SSLv2|SSL_OP_NO_SSLv3);
}
|
555c50eb3bb4fcde883d543b805880abb2d3d483 | e2e3cf2edf60eeb6dd45adaa8a58e110bdef92d9 | /Platform/zoolib/POSIX/Net_Internet_Socket.h | b567af77bd21c165b2a3f135c0da92ea25fc543b | [
"MIT"
] | permissive | zoolib/zoolib_cxx | 0ae57b83d8b3d8c688ee718b236e678b128c0ac7 | b415ef23476afdad89d61a003543570270a85844 | refs/heads/master | 2023-03-22T20:53:40.334006 | 2023-03-11T23:44:22 | 2023-03-11T23:44:22 | 3,355,296 | 17 | 5 | MIT | 2023-03-11T23:44:23 | 2012-02-04T20:54:08 | C++ | UTF-8 | C++ | false | false | 2,783 | h | Net_Internet_Socket.h | // Copyright (c) 2001 Andrew Green and Learning in Motion, Inc.
// MIT License. http://www.zoolib.org
#ifndef __ZooLib_POSIX_Net_Internet_Socket_h__
#define __ZooLib_POSIX_Net_Internet_Socket_h__ 1
#include "zconfig.h"
#include "zoolib/ZCONFIG_API.h"
#include "zoolib/ZCONFIG_SPI.h"
#include "zoolib/Net_Internet.h"
#include "zoolib/POSIX/Net_Socket.h"
#ifndef ZCONFIG_API_Avail__Net_Internet_Socket
#if ZCONFIG_API_Enabled(Net_Socket)
#define ZCONFIG_API_Avail__Net_Internet_Socket 1
#endif
#endif
#ifndef ZCONFIG_API_Avail__Net_Internet_Socket
#define ZCONFIG_API_Avail__Net_Internet_Socket 0
#endif
#ifndef ZCONFIG_API_Desired__Net_Internet_Socket
#define ZCONFIG_API_Desired__Net_Internet_Socket 1
#endif
#if ZCONFIG_API_Enabled(Net_Internet_Socket)
ZMACRO_MSVCStaticLib_Reference(Net_Internet_Socket)
#include <vector>
namespace ZooLib {
// =================================================================================================
#pragma mark - Net_TCP_Socket
namespace Net_TCP_Socket {
int sListen(ip4_addr iLocalAddress, ip_port iLocalPort);
int sListen(ip6_addr iLocalAddress, ip_port iLocalPort);
} // namespace Net_TCP_Socket
// =================================================================================================
#pragma mark - NetNameLookup_Internet_Socket
class NetNameLookup_Internet_Socket
: public NetNameLookup
{
public:
NetNameLookup_Internet_Socket(const std::string& iName, ip_port iPort, size_t iMaxAddresses);
virtual ~NetNameLookup_Internet_Socket();
// From NetNameLookup
virtual void Start();
virtual bool Finished();
virtual void Advance();
virtual ZP<NetAddress> CurrentAddress();
virtual ZP<NetName> CurrentName();
protected:
const std::string fName;
const ip_port fPort;
const size_t fCountAddressesToReturn;
bool fStarted;
size_t fCurrentIndex;
std::vector<ZP<NetAddress_Internet>> fAddresses;
};
// =================================================================================================
#pragma mark - NetListener_TCP_Socket
class NetListener_TCP_Socket
: public virtual NetListener_TCP
, public virtual NetListener_Socket
{
NetListener_TCP_Socket(int iFD, const IKnowWhatIAmDoing_t&);
public:
NetListener_TCP_Socket(ip_port iLocalPort);
NetListener_TCP_Socket(ip4_addr iLocalAddress, ip_port iLocalPort);
NetListener_TCP_Socket(ip6_addr iLocalAddress, ip_port iLocalPort);
virtual ~NetListener_TCP_Socket();
// From NetListener via NetListener_TCP
virtual ZP<NetAddress> GetAddress();
// From NetListener_TCP
virtual ip_port GetPort();
};
// =================================================================================================
} // namespace ZooLib
#endif // ZCONFIG_API_Enabled(Net_Internet_Socket)
#endif // __ZooLib_POSIX_Net_Internet_Socket_h__
|
7f77791b287469d2e0b173f68e182bd3116fbf72 | e3eecfce5fc2258c95c3205d04d8e2ae8a9875f5 | /libnd4j/include/ops/declarable/generic/parity_ops/matrix_determinant.cpp | 635e64a439a2b7f1411222f605c3b02f39b85cac | [
"Apache-2.0"
] | permissive | farizrahman4u/deeplearning4j | 585bdec78e7e8252ca63a0691102b15774e7a6dc | e0555358db5a55823ea1af78ae98a546ad64baab | refs/heads/master | 2021-06-28T19:20:38.204203 | 2019-10-02T10:16:12 | 2019-10-02T10:16:12 | 134,716,860 | 1 | 1 | Apache-2.0 | 2019-10-02T10:14:08 | 2018-05-24T13:08:06 | Java | UTF-8 | C++ | false | false | 1,991 | cpp | matrix_determinant.cpp | //
// Created by GS <sgazeos@gmail.com> at 2/26/2018
//
#include <op_boilerplate.h>
#if NOT_EXCLUDED(OP_matrix_determinant)
#include <ops/declarable/CustomOperations.h>
#include <ops/declarable/helpers/lup.h>
namespace nd4j {
namespace ops {
CUSTOM_OP_IMPL(matrix_determinant, 1, 1, false, 0, 0) {
NDArray<T>* input = INPUT_VARIABLE(0);
NDArray<T>* output = OUTPUT_VARIABLE(0);
REQUIRE_TRUE(input->rankOf() >=2, 0, "matrix_determinant: The rank of input array should not less than 2, but %i is given", input->rankOf());
REQUIRE_TRUE(input->sizeAt(-1) == input->sizeAt(-2), 0, "matrix_determinant: The last two dimmensions should be equal, but %i and %i are given", input->sizeAt(-1), input->sizeAt(-2));
return helpers::determinant(input, output);
}
DECLARE_SHAPE_FN(matrix_determinant) {
auto inShape = inputShape->at(0);
Nd4jLong* determinantShape;
int targetRank = shape::rank(inShape) - 2; // last two dimensions will be reduced to scalar
if (targetRank == 0) { // scalar only
determinantShape = shape::createScalarShapeInfo();
}
else if (targetRank == 1) { // vector
ALLOCATE(determinantShape, block.getWorkspace(), shape::shapeInfoLength(targetRank), Nd4jLong);
shape::shapeVector(shape::sizeAt(inShape, 0), determinantShape);
}
else { // only two last dimensions are excluded
ALLOCATE(determinantShape, block.getWorkspace(), shape::shapeInfoLength(targetRank), Nd4jLong);
if (shape::order(inShape) == 'c')
shape::shapeBuffer(targetRank, shape::shapeOf(inShape), determinantShape);
else
shape::shapeBufferFortran(targetRank, shape::shapeOf(inShape), determinantShape);
}
return SHAPELIST(determinantShape);
}
}
}
#endif |
1543694e8600ac4ad99bbb40b7151d81da777c5a | fff13f6097aaeb63c16879071265f5ba8c40698e | /Interpreter/tests/testing.h | 6f0c7b16447792154ed954ba63e6e066096a51f6 | [] | no_license | lefort11/model_interpret | fece5a11c39380017c9cf917e935e5cdc08f8834 | f82776a61ec98a01be305c70ad4a73d9139d4f5f | refs/heads/master | 2021-01-21T13:48:50.458384 | 2016-05-07T18:18:16 | 2016-05-07T18:18:16 | 55,521,715 | 3 | 0 | null | 2016-05-07T18:15:06 | 2016-04-05T15:56:19 | C++ | UTF-8 | C++ | false | false | 290 | h | testing.h | #pragma once
#include <assert.h>
namespace testing
{
typedef void (*TestingFunction) ();
class Test
{
public:
Test(TestingFunction testingFunction)
{
testingFunction();
}
};
#define TEST(NAME) static const testing::Test NAME = (testing::TestingFunction)[]() -> void
} |
265e51fbf922a1085986a2b808ec7736466fab26 | f07e66293cc41a9fe71fc44f765b432fd7a0997c | /selfdrive/ui/qt/widgets/drive_stats.hpp | bf4cdae000e0d71b5a3102b1aea032e8a34faf89 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | kegman/openpilot | c9ba96a72d905956f02c684e065091e023942883 | b35291c91783657a5fc83abfff012d3bb49dd89f | refs/heads/kegman-ultimate | 2022-05-22T17:07:16.656336 | 2021-10-25T13:35:28 | 2021-10-25T13:35:28 | 229,979,925 | 105 | 212 | MIT | 2022-03-13T05:47:51 | 2019-12-24T17:27:11 | C | UTF-8 | C++ | false | false | 332 | hpp | drive_stats.hpp | #pragma once
#include <QNetworkReply>
#include <QVBoxLayout>
#include <QWidget>
#include "api.hpp"
class DriveStats : public QWidget {
Q_OBJECT
public:
explicit DriveStats(QWidget* parent = 0);
private:
QVBoxLayout* vlayout;
private slots:
void parseError(QString response);
void parseResponse(QString response);
};
|
a7739693fbb1371a59a257f798a61ed977189593 | bacb7f9a49afe7cb646f68cc0bfbb1ecfdef5d3b | /actuators_system/include/actuators_system/test_board/test_board.ino | 8048857f668ce82507d870e7e5cd1ae63ae63321 | [
"MIT"
] | permissive | grvcTeam/mbzirc2020 | 7c5b7809f5e9c340bb1d2656ad3b86893650a706 | e474cee6458a3bb14f858da43349c5154b3c8cdd | refs/heads/master | 2023-01-01T21:58:05.607173 | 2020-10-21T18:32:24 | 2020-10-21T18:32:24 | 169,777,659 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,735 | ino | test_board.ino | #include "Timer.h"
#include <Servo.h>
#define SERIAL_BAUDRATE 9600
#define PERIOD_IN_MS 20
#define INI_SERVO_PWM 1500
#define PIN_PWM_0 5
#define PIN_PWM_1 6
#define PIN_PWM_2 9
#define PIN_PWM_3 10
#define PIN_PWM_4 11
#define PIN_OUT_0 12
#define PIN_IN_0 A3
#define PIN_IN_1 A2
#define PIN_IN_2 A1
#define PIN_IN_3 A0
Timer timer = Timer(PERIOD_IN_MS);
uint16_t loop_count = 0;
Servo servo[5];
uint16_t pwm[5] = {INI_SERVO_PWM, INI_SERVO_PWM, INI_SERVO_PWM, INI_SERVO_PWM, INI_SERVO_PWM};
uint16_t pwm_min[5] = { 900, 900, 900, 900, 900};
uint16_t pwm_max[5] = {2100, 2100, 2100, 2100, 2100};
void setup() {
Serial.begin(SERIAL_BAUDRATE);
Serial.setTimeout(5);
while (!Serial) { ; } // Wait for serial port to connect
pinMode(LED_BUILTIN, OUTPUT);
pinMode(PIN_OUT_0, OUTPUT);
pinMode(PIN_IN_0, INPUT_PULLUP);
pinMode(PIN_IN_1, INPUT);
pinMode(PIN_IN_2, INPUT);
pinMode(PIN_IN_3, INPUT);
servo[0].attach(PIN_PWM_0, pwm_min[0], pwm_max[0]);
servo[1].attach(PIN_PWM_1, pwm_min[1], pwm_max[1]);
servo[2].attach(PIN_PWM_2, pwm_min[2], pwm_max[2]);
servo[3].attach(PIN_PWM_3, pwm_min[3], pwm_max[3]);
servo[4].attach(PIN_PWM_4, pwm_min[4], pwm_max[4]);
timer.begin();
}
void loop() {
bool any_digital_in = digitalRead(PIN_IN_0) && digitalRead(PIN_IN_1) && digitalRead(PIN_IN_2) && digitalRead(PIN_IN_3);
digitalWrite(LED_BUILTIN, !any_digital_in);
for (int i = 0; i < 5; i++) {
if (loop_count < 100) {
pwm[i] = pwm_max[i];
} else if (loop_count < 200) {
pwm[i] = pwm_min[i];
} else {
loop_count = 0;
}
servo[i].writeMicroseconds(pwm[i]);
}
digitalWrite(PIN_OUT_0, !any_digital_in);
loop_count++;
timer.sleep();
}
|
3c417bdc5f32da648dae4584595b03626a170164 | 22b3299d268d9229fb269f9e00b90ecc4d0b49eb | /LinkedinAdapter.cpp | 392c98193a1e96cf5e36aa596a708336ecb2309b | [] | no_license | PaulKnauer/ESP8266SocialMediaFollowerCount | 0d389832c23b5be42469a053711caa010a06f8f4 | b0a5f4a16f9fa1d2b3b4002a835d29c2e280e4c3 | refs/heads/master | 2021-04-15T13:51:58.526015 | 2020-05-29T16:23:55 | 2020-05-29T16:23:55 | 126,157,446 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 242 | cpp | LinkedinAdapter.cpp | #include "LinkedinAdapter.h"
/*
*
*/
LinkedinAdapter::LinkedinAdapter(LedDisplay *display, WiFiClientSecure client) {
this->display = display;
}
/*
*
*/
void LinkedinAdapter::displayFollowerCount() {
display->showNumber(5678);
}
|
fa29d7643acdb97432039e2295899617b14a3886 | 9b2e965ff4bb0cc2f294264d229b80eb84845954 | /GameProject/GameProject/GroundPillar.h | 31f75f69c1498757011d319cdc6d7c04ea24fe0b | [] | no_license | mrwappa/GameProject-Massive-Internship-Erik | 1ef7062391a01ae917a7f8fa98e9151619328197 | e4e9f86d4a3375b4872ae60d6292d2e2b4b66ef3 | refs/heads/master | 2021-04-03T09:38:48.508846 | 2018-05-31T16:12:14 | 2018-05-31T16:12:14 | 124,645,592 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 397 | h | GroundPillar.h | #ifndef GROUNDPILLAR_H
#define GROUNDPILLAR_H
#include "Entity.h"
#define PILLARL "Sprites/Blocks/spr_pillarL.png"
#define PILLARR "Sprites/Blocks/spr_pillarR.png"
#define PILLARM "Sprites/Blocks/spr_pillarM.png"
class GroundPillar : public Entity
{
public:
GroundPillar(float aX ,float aY, int aPillar);
~GroundPillar();
enum PillarType{ Left, Middle, Right};
};
#endif // !GROUNDPILLAR_H |
92e77a430397f60892abff8b051a5007b42ebedc | 1fd513a0f907edeba6b03266adc08a716f8e8633 | /Plug-ins/FakeSMCnVclockPort/src/backend/utils.cpp | a0d63cf70c15b74b423e6f689b42ca2ed3c74f3f | [] | no_license | RehabMan/OS-X-FakeSMC-slice | cd283eec4676b345265dc466362263c7334c43dc | 52377456f81fe7a591ec091773f13a38b1e2ce4a | refs/heads/master | 2021-01-01T05:30:20.032745 | 2013-03-19T17:24:02 | 2013-03-19T17:24:02 | 8,146,721 | 13 | 8 | null | null | null | null | UTF-8 | C++ | false | false | 2,396 | cpp | utils.cpp | /* NVClock 0.8 - Linux overclocker for NVIDIA cards
*
* site: http://nvclock.sourceforge.net
*
* Copyright(C) 2001-2007 Roderick Colenbrander
*
* 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
*/
#include <IOKit/IOLib.h>
/* Convert the gpu architecture to a string using NVxx/Gxx naming */
int convert_gpu_architecture(short arch, char *buf)
{
if(!buf)
return 0;
switch(arch)
{
case 0x46:
snprintf(buf, sizeof("NV46/G72"), "NV46/G72"); /* 7300 */
break;
case 0x47:
snprintf(buf, sizeof("NV47/G70"), "NV47/G70"); /* 7800 */
break;
case 0x49:
snprintf(buf, sizeof("NV49/G71"), "NV49/G71"); /* 7900 */
break;
case 0x4b:
snprintf(buf, sizeof("NV4B/G73"), "NV4B/G73"); /* 7600 */
break;
case 0x4c: /* is this correct also a C51? */
case 0x4e:
snprintf(buf, sizeof("C51"), "C51"); /* Geforce 6x00 nForce */
break;
// sprintf(buf, "C68"); /* Geforce 70xx nForce */
case 0x50:
snprintf(buf, sizeof("NV50/G80"), "NV50/G80"); /* 8800 */
break;
case 0xa0:
snprintf(buf, sizeof("GT200"), "GT200"); /* Geforce GTX260/280 */
break;
default:
if(arch <= 0x44) /* The NV44/6200TC is the last card with only an NV name */
snprintf(buf, sizeof("NV??"), "NV%X", arch);
else /* Use Gxx for anything else */
snprintf(buf, sizeof("G??"), "G%X", arch);
}
return 1;
}
/* Convert a mask containing enabled/disabled pipelines for nv4x cards
/ to a binary string.
*/
void convert_unit_mask_to_binary(char mask, char hw_default, char *buf)
{
int i, len;
/* Count the number of pipelines on the card */
for(i=0, len=0; i<8; i++)
len += (hw_default & (1<<i)) ? 1 : 0;
for(i=0; i<len; i++)
{
buf[i] = (mask & (1<<(len-i-1))) ? '1' : '0';
}
buf[len] = 0;
}
|
76853622f6f78c0c15cf00a0f5a7af64bbaf17ba | f7b5d803225fa1fdbcc22b69d8cc083691c68f01 | /cvaddon_image_io/cvaddon_image_reader.h | 010a04d6eb20747a770b259136cf42717439df85 | [] | no_license | a40712344/cvaddon | 1b3e4b8295eaea3b819598bb7982aa1ba786cb57 | e7ebbef09b864b98cce14f0151cef643d2e6bf9d | refs/heads/master | 2020-05-20T07:18:49.379088 | 2008-12-09T03:40:11 | 2008-12-09T03:40:11 | 35,675,249 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,989 | h | cvaddon_image_reader.h | #ifndef _CVADDON_IMAGE_READER_H
#define _CVADDON_IMAGE_READER_H
// Reads images from disk into OpenCV IplImages
// Can also read a sequence of images based on an
// initial filename (like img00.png, img01.png ...etc)
//
// NOTE!: It is up to the USER to DEALLOCATE images created using
// load()!!!
//
// Assumptions:
// 1) Filename number >= 0
// 2) Image file is a type that can be loaded using cvLoadImage()
//
// Usage Example:
// ---
// const char* IMAGE_PATH = "C:/my_pics";
// const char* IMAGE_NAME = "pic000.bmp";
// CvAddonImageReader images(IMAGE_PATH, IMAGE_NAME);
//
// IplImage *img;
// cvNamedWindow("img", 1);
//
//
// while(img = images.load())
// {
// cvShowImage("img", img);
// cvReleaseImage(&img);
// images.next();
//
// char c = cvWaitKey(10);
// if(c == 'r') images.reset();
// if(c == 'x') break;
// }
// Filename parsing
#include "filename.h"
#include <string>
using std::string;
#include "highgui.h"
class CvAddonImageReader
{
public:
CvAddonImageReader(const char* path, const char* name);
~CvAddonImageReader();
IplImage* load();
inline void next() { filename.number++; }
inline bool prev()
{
filename.number--;
if(filename.number < 0) {
filename.number = 0;
return false;
}
return true;
}
// Start at the first file again
inline void reset() { filename.number = firstNum; }
inline int number() { return filename.number; }
private:
whFilename filename;
string imagePath;
int firstNum;
};
CvAddonImageReader::CvAddonImageReader(const char* path, const char* name)
: filename(string(name)), imagePath(path), firstNum(filename.number)
{
}
CvAddonImageReader::~CvAddonImageReader()
{
}
inline IplImage* CvAddonImageReader::load()
{
#ifdef _DEBUG
cerr << "Name of Image Loaded: " << (imagePath + "/" + filename.str()) << endl;
#endif
return cvLoadImage( (imagePath + "/" + filename.str()).c_str() );
}
#endif |
3918f44a7d3a293cca17de4a287ba974b3b75e54 | f3a9174535cd7e76d1c1e0f0fa1a3929751fb48d | /SDK/PVR_SteamVRInputDevice_functions.cpp | 205ee6384d54aa246784c98a7116eaec0518977f | [] | no_license | hinnie123/PavlovVRSDK | 9fcdf97e7ed2ad6c5cb485af16652a4c83266a2b | 503f8d9a6770046cc23f935f2df1f1dede4022a8 | refs/heads/master | 2020-03-31T05:30:40.125042 | 2020-01-28T20:16:11 | 2020-01-28T20:16:11 | 151,949,019 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 30,994 | cpp | PVR_SteamVRInputDevice_functions.cpp | // PavlovVR (Dumped by Hinnie) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "../SDK.hpp"
namespace SDK
{
//---------------------------------------------------------------------------
//Functions
//---------------------------------------------------------------------------
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.ShowSteamVR_ActionOrigin
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// struct FSteamVRAction SteamVRAction (Parm)
// struct FSteamVRActionSet SteamVRActionSet (Parm)
void USteamVRInputDeviceFunctionLibrary::STATIC_ShowSteamVR_ActionOrigin(const struct FSteamVRAction& SteamVRAction, const struct FSteamVRActionSet& SteamVRActionSet)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.ShowSteamVR_ActionOrigin");
USteamVRInputDeviceFunctionLibrary_ShowSteamVR_ActionOrigin_Params params;
params.SteamVRAction = SteamVRAction;
params.SteamVRActionSet = SteamVRActionSet;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.ShowAllSteamVR_ActionOrigins
// (Final, Native, Static, Public, BlueprintCallable)
void USteamVRInputDeviceFunctionLibrary::STATIC_ShowAllSteamVR_ActionOrigins()
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.ShowAllSteamVR_ActionOrigins");
USteamVRInputDeviceFunctionLibrary_ShowAllSteamVR_ActionOrigins_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.SetSteamVR_GlobalPredictedSecondsFromNow
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// float NewValue (Parm, ZeroConstructor, IsPlainOldData)
// float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
float USteamVRInputDeviceFunctionLibrary::STATIC_SetSteamVR_GlobalPredictedSecondsFromNow(float NewValue)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.SetSteamVR_GlobalPredictedSecondsFromNow");
USteamVRInputDeviceFunctionLibrary_SetSteamVR_GlobalPredictedSecondsFromNow_Params params;
params.NewValue = NewValue;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.SetPoseSource
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// bool bUseSkeletonPose (Parm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_SetPoseSource(bool bUseSkeletonPose)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.SetPoseSource");
USteamVRInputDeviceFunctionLibrary_SetPoseSource_Params params;
params.bUseSkeletonPose = bUseSkeletonPose;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.SetCurlsAndSplaysState
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// bool NewLeftHandState (Parm, ZeroConstructor, IsPlainOldData)
// bool NewRightHandState (Parm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_SetCurlsAndSplaysState(bool NewLeftHandState, bool NewRightHandState)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.SetCurlsAndSplaysState");
USteamVRInputDeviceFunctionLibrary_SetCurlsAndSplaysState_Params params;
params.NewLeftHandState = NewLeftHandState;
params.NewRightHandState = NewRightHandState;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.ResetSeatedPosition
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool USteamVRInputDeviceFunctionLibrary::STATIC_ResetSeatedPosition()
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.ResetSeatedPosition");
USteamVRInputDeviceFunctionLibrary_ResetSeatedPosition_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.PlaySteamVR_HapticFeedback
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// ESteamVRHand hand (Parm, ZeroConstructor, IsPlainOldData)
// float StartSecondsFromNow (Parm, ZeroConstructor, IsPlainOldData)
// float DurationSeconds (Parm, ZeroConstructor, IsPlainOldData)
// float Frequency (Parm, ZeroConstructor, IsPlainOldData)
// float Amplitude (Parm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_PlaySteamVR_HapticFeedback(ESteamVRHand hand, float StartSecondsFromNow, float DurationSeconds, float Frequency, float Amplitude)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.PlaySteamVR_HapticFeedback");
USteamVRInputDeviceFunctionLibrary_PlaySteamVR_HapticFeedback_Params params;
params.hand = hand;
params.StartSecondsFromNow = StartSecondsFromNow;
params.DurationSeconds = DurationSeconds;
params.Frequency = Frequency;
params.Amplitude = Amplitude;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetUserIPD
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
float USteamVRInputDeviceFunctionLibrary::STATIC_GetUserIPD()
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetUserIPD");
USteamVRInputDeviceFunctionLibrary_GetUserIPD_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_OriginTrackedDeviceInfo
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// struct FSteamVRAction SteamVRAction (Parm)
// struct FSteamVRInputOriginInfo InputOriginInfo (Parm, OutParm)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool USteamVRInputDeviceFunctionLibrary::STATIC_GetSteamVR_OriginTrackedDeviceInfo(const struct FSteamVRAction& SteamVRAction, struct FSteamVRInputOriginInfo* InputOriginInfo)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_OriginTrackedDeviceInfo");
USteamVRInputDeviceFunctionLibrary_GetSteamVR_OriginTrackedDeviceInfo_Params params;
params.SteamVRAction = SteamVRAction;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (InputOriginInfo != nullptr)
*InputOriginInfo = params.InputOriginInfo;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_OriginLocalizedName
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// struct FSteamVRAction SteamVRAction (Parm)
// TArray<ESteamVRInputStringBits> LocalizedParts (Parm, ZeroConstructor)
// struct FString OriginLocalizedName (Parm, OutParm, ZeroConstructor)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetSteamVR_OriginLocalizedName(const struct FSteamVRAction& SteamVRAction, TArray<ESteamVRInputStringBits> LocalizedParts, struct FString* OriginLocalizedName)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_OriginLocalizedName");
USteamVRInputDeviceFunctionLibrary_GetSteamVR_OriginLocalizedName_Params params;
params.SteamVRAction = SteamVRAction;
params.LocalizedParts = LocalizedParts;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (OriginLocalizedName != nullptr)
*OriginLocalizedName = params.OriginLocalizedName;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_InputBindingInfo
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// struct FSteamVRAction SteamVRActionHandle (Parm)
// TArray<struct FSteamVRInputBindingInfo> ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm)
TArray<struct FSteamVRInputBindingInfo> USteamVRInputDeviceFunctionLibrary::STATIC_GetSteamVR_InputBindingInfo(const struct FSteamVRAction& SteamVRActionHandle)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_InputBindingInfo");
USteamVRInputDeviceFunctionLibrary_GetSteamVR_InputBindingInfo_Params params;
params.SteamVRActionHandle = SteamVRActionHandle;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_HandPoseRelativeToNow
// (Final, Native, Static, Public, HasOutParms, HasDefaults, BlueprintCallable)
// Parameters:
// struct FVector Position (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FRotator Orientation (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// ESteamVRHand hand (Parm, ZeroConstructor, IsPlainOldData)
// float PredictedSecondsFromNow (Parm, ZeroConstructor, IsPlainOldData)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool USteamVRInputDeviceFunctionLibrary::STATIC_GetSteamVR_HandPoseRelativeToNow(ESteamVRHand hand, float PredictedSecondsFromNow, struct FVector* Position, struct FRotator* Orientation)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_HandPoseRelativeToNow");
USteamVRInputDeviceFunctionLibrary_GetSteamVR_HandPoseRelativeToNow_Params params;
params.hand = hand;
params.PredictedSecondsFromNow = PredictedSecondsFromNow;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (Position != nullptr)
*Position = params.Position;
if (Orientation != nullptr)
*Orientation = params.Orientation;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_GlobalPredictedSecondsFromNow
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// float ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
float USteamVRInputDeviceFunctionLibrary::STATIC_GetSteamVR_GlobalPredictedSecondsFromNow()
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_GlobalPredictedSecondsFromNow");
USteamVRInputDeviceFunctionLibrary_GetSteamVR_GlobalPredictedSecondsFromNow_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_ActionSetArray
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// TArray<struct FSteamVRActionSet> SteamVRActionSets (Parm, OutParm, ZeroConstructor)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetSteamVR_ActionSetArray(TArray<struct FSteamVRActionSet>* SteamVRActionSets)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_ActionSetArray");
USteamVRInputDeviceFunctionLibrary_GetSteamVR_ActionSetArray_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (SteamVRActionSets != nullptr)
*SteamVRActionSets = params.SteamVRActionSets;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_ActionArray
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// TArray<struct FSteamVRAction> SteamVRActions (Parm, OutParm, ZeroConstructor)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetSteamVR_ActionArray(TArray<struct FSteamVRAction>* SteamVRActions)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSteamVR_ActionArray");
USteamVRInputDeviceFunctionLibrary_GetSteamVR_ActionArray_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (SteamVRActions != nullptr)
*SteamVRActions = params.SteamVRActions;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSkeletalTransform
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// struct FSteamVRSkeletonTransform LeftHand (Parm, OutParm)
// struct FSteamVRSkeletonTransform RightHand (Parm, OutParm)
// bool bWithController (Parm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetSkeletalTransform(bool bWithController, struct FSteamVRSkeletonTransform* LeftHand, struct FSteamVRSkeletonTransform* RightHand)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSkeletalTransform");
USteamVRInputDeviceFunctionLibrary_GetSkeletalTransform_Params params;
params.bWithController = bWithController;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (LeftHand != nullptr)
*LeftHand = params.LeftHand;
if (RightHand != nullptr)
*RightHand = params.RightHand;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSkeletalState
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// bool LeftHandState (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// bool RightHandState (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetSkeletalState(bool* LeftHandState, bool* RightHandState)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetSkeletalState");
USteamVRInputDeviceFunctionLibrary_GetSkeletalState_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (LeftHandState != nullptr)
*LeftHandState = params.LeftHandState;
if (RightHandState != nullptr)
*RightHandState = params.RightHandState;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetRightHandPoseData
// (Final, Native, Static, Public, HasOutParms, HasDefaults, BlueprintCallable)
// Parameters:
// struct FVector Position (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FRotator Orientation (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FVector AngularVelocity (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FVector Velocity (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetRightHandPoseData(struct FVector* Position, struct FRotator* Orientation, struct FVector* AngularVelocity, struct FVector* Velocity)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetRightHandPoseData");
USteamVRInputDeviceFunctionLibrary_GetRightHandPoseData_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (Position != nullptr)
*Position = params.Position;
if (Orientation != nullptr)
*Orientation = params.Orientation;
if (AngularVelocity != nullptr)
*AngularVelocity = params.AngularVelocity;
if (Velocity != nullptr)
*Velocity = params.Velocity;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetPoseSource
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// bool bUsingSkeletonPose (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetPoseSource(bool* bUsingSkeletonPose)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetPoseSource");
USteamVRInputDeviceFunctionLibrary_GetPoseSource_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (bUsingSkeletonPose != nullptr)
*bUsingSkeletonPose = params.bUsingSkeletonPose;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetLeftHandPoseData
// (Final, Native, Static, Public, HasOutParms, HasDefaults, BlueprintCallable)
// Parameters:
// struct FVector Position (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FRotator Orientation (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FVector AngularVelocity (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FVector Velocity (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetLeftHandPoseData(struct FVector* Position, struct FRotator* Orientation, struct FVector* AngularVelocity, struct FVector* Velocity)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetLeftHandPoseData");
USteamVRInputDeviceFunctionLibrary_GetLeftHandPoseData_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (Position != nullptr)
*Position = params.Position;
if (Orientation != nullptr)
*Orientation = params.Orientation;
if (AngularVelocity != nullptr)
*AngularVelocity = params.AngularVelocity;
if (Velocity != nullptr)
*Velocity = params.Velocity;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetFingerCurlsAndSplays
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// EHand hand (Parm, ZeroConstructor, IsPlainOldData)
// struct FSteamVRFingerCurls FingerCurls (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FSteamVRFingerSplays FingerSplays (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// ESkeletalSummaryDataType SummaryDataType (Parm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetFingerCurlsAndSplays(EHand hand, ESkeletalSummaryDataType SummaryDataType, struct FSteamVRFingerCurls* FingerCurls, struct FSteamVRFingerSplays* FingerSplays)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetFingerCurlsAndSplays");
USteamVRInputDeviceFunctionLibrary_GetFingerCurlsAndSplays_Params params;
params.hand = hand;
params.SummaryDataType = SummaryDataType;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (FingerCurls != nullptr)
*FingerCurls = params.FingerCurls;
if (FingerSplays != nullptr)
*FingerSplays = params.FingerSplays;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetCurlsAndSplaysState
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// bool LeftHandState (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// bool RightHandState (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetCurlsAndSplaysState(bool* LeftHandState, bool* RightHandState)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetCurlsAndSplaysState");
USteamVRInputDeviceFunctionLibrary_GetCurlsAndSplaysState_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (LeftHandState != nullptr)
*LeftHandState = params.LeftHandState;
if (RightHandState != nullptr)
*RightHandState = params.RightHandState;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetControllerFidelity
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// EControllerFidelity LeftControllerFidelity (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// EControllerFidelity RightControllerFidelity (Parm, OutParm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_GetControllerFidelity(EControllerFidelity* LeftControllerFidelity, EControllerFidelity* RightControllerFidelity)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.GetControllerFidelity");
USteamVRInputDeviceFunctionLibrary_GetControllerFidelity_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (LeftControllerFidelity != nullptr)
*LeftControllerFidelity = params.LeftControllerFidelity;
if (RightControllerFidelity != nullptr)
*RightControllerFidelity = params.RightControllerFidelity;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_OriginTrackedDeviceInfo
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// struct FName ActionName (Parm, ZeroConstructor, IsPlainOldData)
// bool bResult (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FSteamVRInputOriginInfo InputOriginInfo (Parm, OutParm)
// struct FName ActionSet (Parm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_FindSteamVR_OriginTrackedDeviceInfo(const struct FName& ActionName, const struct FName& ActionSet, bool* bResult, struct FSteamVRInputOriginInfo* InputOriginInfo)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_OriginTrackedDeviceInfo");
USteamVRInputDeviceFunctionLibrary_FindSteamVR_OriginTrackedDeviceInfo_Params params;
params.ActionName = ActionName;
params.ActionSet = ActionSet;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (bResult != nullptr)
*bResult = params.bResult;
if (InputOriginInfo != nullptr)
*InputOriginInfo = params.InputOriginInfo;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_InputBindingInfo
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// struct FName ActionName (Parm, ZeroConstructor, IsPlainOldData)
// struct FName ActionSet (Parm, ZeroConstructor, IsPlainOldData)
// TArray<struct FSteamVRInputBindingInfo> ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm)
TArray<struct FSteamVRInputBindingInfo> USteamVRInputDeviceFunctionLibrary::STATIC_FindSteamVR_InputBindingInfo(const struct FName& ActionName, const struct FName& ActionSet)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_InputBindingInfo");
USteamVRInputDeviceFunctionLibrary_FindSteamVR_InputBindingInfo_Params params;
params.ActionName = ActionName;
params.ActionSet = ActionSet;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_ActionOrigin
// (Final, Native, Static, Public, BlueprintCallable)
// Parameters:
// struct FName ActionName (Parm, ZeroConstructor, IsPlainOldData)
// struct FName ActionSet (Parm, ZeroConstructor, IsPlainOldData)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool USteamVRInputDeviceFunctionLibrary::STATIC_FindSteamVR_ActionOrigin(const struct FName& ActionName, const struct FName& ActionSet)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_ActionOrigin");
USteamVRInputDeviceFunctionLibrary_FindSteamVR_ActionOrigin_Params params;
params.ActionName = ActionName;
params.ActionSet = ActionSet;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_Action
// (Final, Native, Static, Public, HasOutParms, BlueprintCallable)
// Parameters:
// struct FName ActionName (Parm, ZeroConstructor, IsPlainOldData)
// bool bResult (Parm, OutParm, ZeroConstructor, IsPlainOldData)
// struct FSteamVRAction FoundAction (Parm, OutParm)
// struct FSteamVRActionSet FoundActionSet (Parm, OutParm)
// struct FName ActionSet (Parm, ZeroConstructor, IsPlainOldData)
void USteamVRInputDeviceFunctionLibrary::STATIC_FindSteamVR_Action(const struct FName& ActionName, const struct FName& ActionSet, bool* bResult, struct FSteamVRAction* FoundAction, struct FSteamVRActionSet* FoundActionSet)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRInputDeviceFunctionLibrary.FindSteamVR_Action");
USteamVRInputDeviceFunctionLibrary_FindSteamVR_Action_Params params;
params.ActionName = ActionName;
params.ActionSet = ActionSet;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
if (bResult != nullptr)
*bResult = params.bResult;
if (FoundAction != nullptr)
*FoundAction = params.FoundAction;
if (FoundActionSet != nullptr)
*FoundActionSet = params.FoundActionSet;
}
// Function SteamVRInputDevice.SteamVRTrackingReferences.ShowTrackingReferences
// (Final, Native, Public, BlueprintCallable)
// Parameters:
// class UStaticMesh* TrackingReferenceMesh (Parm, ZeroConstructor, IsPlainOldData)
// bool ReturnValue (Parm, OutParm, ZeroConstructor, ReturnParm, IsPlainOldData)
bool USteamVRTrackingReferences::ShowTrackingReferences(class UStaticMesh* TrackingReferenceMesh)
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRTrackingReferences.ShowTrackingReferences");
USteamVRTrackingReferences_ShowTrackingReferences_Params params;
params.TrackingReferenceMesh = TrackingReferenceMesh;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
return params.ReturnValue;
}
// Function SteamVRInputDevice.SteamVRTrackingReferences.HideTrackingReferences
// (Final, Native, Public, BlueprintCallable)
void USteamVRTrackingReferences::HideTrackingReferences()
{
static auto fn = UObject::FindObject<UFunction>("Function SteamVRInputDevice.SteamVRTrackingReferences.HideTrackingReferences");
USteamVRTrackingReferences_HideTrackingReferences_Params params;
auto flags = fn->FunctionFlags;
fn->FunctionFlags |= 0x400;
UObject::ProcessEvent(fn, ¶ms);
fn->FunctionFlags = flags;
}
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
|
0827b6bd53a053f90a771197120a9b90c9cdb067 | fddab5bb9e1fc9bba86f2e572f458763655b7861 | /GameServer/src/RewardHail/OnceReward.cpp | 793df0ea351eb4e7650d5b57875e72f886f2d491 | [] | no_license | hackerlank/Test-3 | 0d6484db857ebd4649362e64fe77d33d0b125d85 | bfd5c332a09e0f6cf7a47abc89208e527bcb1ee8 | refs/heads/master | 2021-01-15T14:54:29.278366 | 2017-06-26T18:23:37 | 2017-06-26T18:23:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,318 | cpp | OnceReward.cpp | /*
* OnceReward.cpp
*
* Created on: 2015年9月16日
* Author: root
*/
#include "OnceReward.h"
#include "MessageStruct/RewardHail/RewardHail.pb.h"
#include "FileLoader/MicroRewardLoader.h"
#include "../Object/Player/Player.h"
#include "../Counter/Counter.h"
#include "../QuickMessage.h"
#include "FileLoader/TotalLoginRewardLoader.h"
#include "../Container/ContainerBase.h"
#include "../Container/ParcelMgr.h"
#include "../Attribute/AttributeCreature.h"
OnceReward::OnceReward(Player* player) : m_owner(player)
{
ReInit();
}
OnceReward::~OnceReward()
{
}
void OnceReward::ReInit()
{
m_microRewardFlag = false;
m_firstChargeRewardFlag = false;
}
void OnceReward::Release()
{
}
void OnceReward::SetInfoToDB(PlayerInfo::OnceRewardInfo& rewardInfo)
{
rewardInfo.set_microrewardflag(m_microRewardFlag);
rewardInfo.set_firstchargeoverflag(m_firstChargeRewardFlag);
}
void OnceReward::InitInfoByDB(const PlayerInfo::OnceRewardInfo& rewardInfo)
{
// 由于前端需要改动 所以暂时首充不添加在新模块
// if (!m_firstChargeRewardFlag)
// { // 首充是从别的模块移植过来 所以为了兼容旧的
// m_firstChargeRewardFlag = rewardInfo.firstchargeoverflag();
// }
m_microRewardFlag = rewardInfo.microrewardflag();
}
void OnceReward::SynRewardToClient()
{
if (NULL != m_owner)
{
RewardHail::ClientOnceReward toClient;
toClient.set_firstchargereward(m_firstChargeRewardFlag);
toClient.set_microreward(m_microRewardFlag);
QuickMessage::GetInstance()->AddSendMessage(m_owner->GetID(), m_owner->GetChannelID(), &toClient, MSG_SIM_GM2C_SYNONCEREWARD);
}
}
bool OnceReward::IsFirstChargeRmb()
{
if(m_owner->GetCounterService()->GetNumById(CHARGE_RMB_COUNT) >=1)
return true;
else
return false;
}
void OnceReward::SetFirstChargeFlag(bool flag)
{
m_firstChargeRewardFlag = flag;
m_owner->SetDataFlag(eOnceRewardInfo);
}
int OnceReward::GetFirstChargeRmbReward(RewardHail::GetReward& reward,
vector<DWORD>& goods, vector<DWORD>& num,
vector<DWORD>& strengthLvVec)
{
if(!IsFirstChargeRmb())
return eNotGetReward;
if(m_firstChargeRewardFlag)
return eHaveGetReward;
FirstChargeAw *info = TotalLoginRewardLoader::GetInstance()->GetFirstChargeAw(m_owner->getAttManage()->getValue<BYTE>(eCharProfession));
if(!info)
return eRewardHailConfigError;
int res = 0;
const GoodsInfo* ginfo=NULL;
for(uint i=0; i<info->m_totalItem.size(); ++i)
{
ginfo = GoodsLoader::GetInstance()->GetItemDataByID(info->m_totalItem[i]);
if(ginfo==NULL)
{
return eRewardHailConfigError;
}
}
vector<WORD> tempFlagsList;
tempFlagsList.resize(info->m_totalItem.size(),1);
res = m_owner->GetContainer(ePackageType)->IsBagEnought(info->m_totalItem, info->m_totalNum,tempFlagsList);
goods = info->m_totalItem;
num = info->m_totalNum;
strengthLvVec = info->m_totalLv;
if(!res)
{
SetFirstChargeFlag(true);
vector<int> vecType;
if(info->bglod >0)
{
m_owner->ChangeBindGolden(info->bglod, true);
vecType.push_back(eCharBindGolden);
m_owner->SetDataFlag(eBaseInfo);
}
if(info->money >0)
{
m_owner->ChangeMoney(info->money, true);
vecType.push_back(eCharMoney);
m_owner->SetDataFlag(eBaseInfo);
}
if(info->zhenqi >0)
{
m_owner->ChangeCurForce(info->zhenqi, true);
vecType.push_back(eCharForce);
m_owner->SetDataFlag(eBattleInfo);
}
if(vecType.size() >0)
{
m_owner->SynCharAttribute(vecType);
}
SetRewardItemInfo(reward, goods);
//统计 领取首充礼包
// this->Statistic(eStatic_PackageGift, eStaMinor_Recharge_First);
SynRewardToClient();
return 0;
}
return res;
}
void OnceReward::SetRewardItemInfo(RewardHail::GetReward& info, vector<DWORD>& goods)
{
for(uint i = 0; i < goods.size(); ++i)
{
info.add_list(goods[i]);
}
}
// 获取微端奖励值
int OnceReward::GetMicroRewardState()
{
if (m_microRewardFlag)
{
return 0;
}
if (!m_microRewardFlag && IsMicroLogin())
{
return 1;
}
return 0;
}
void OnceReward::SetMicroRewardFlag(bool flag)
{
m_microRewardFlag = flag;
m_owner->SetDataFlag(eOnceRewardInfo);
}
// 检查领取微端奖励条件
int OnceReward::CheckGetMicroReward()
{
if (m_microRewardFlag)
{
return eHaveGetReward;
}
if (!IsMicroLogin())
{ // 判断是否用微端登录过
return eNotGetReward;
}
MicroRewardInfo info;
MicroRewardLoader::GetInstance()->GetMicroReward(info);
if (info.itemID.size() <= 0 || info.itemNum.size() != info.itemID.size())
{ // 没有物品奖励
return eItemError;
}
uint index = 0;
// 检查物品信息是否正确
DWORD tmpID = 0;
DWORD tmpNum = 0;
vector<WORD> bind;
for ( ; index < info.itemID.size(); ++index)
{
tmpID = info.itemID[index];
tmpNum = info.itemNum[index];
const GoodsInfo* goodInfo = GoodsLoader::GetInstance()->GetItemDataByID(tmpID);
if (NULL == goodInfo || tmpNum <= 0)
{
return eItemError;
}
}
bind.resize(info.itemID.size(), info.isBind);
Smart_Ptr<ArticleParcelMgr> container = m_owner->GetContainer(ePackageType);
if (!container)
{
return ePlayerPackageFail;
}
int res = container->IsBagEnought(info.itemID, info.itemNum, bind);
if (0 != res)
{
return res;
}
return 0;
}
int OnceReward::GetMicroReward(RewardHail::GetReward& reward, vector<DWORD>& goods, vector<DWORD>& num,
vector<WORD>& bind)
{
int res = CheckGetMicroReward();
if (0 != res)
{
return res;
}
MicroRewardInfo info;
vector<WORD> bindFlag;
MicroRewardLoader::GetInstance()->GetMicroReward(info);
bindFlag.resize(info.itemID.size(), info.isBind);
vector<int> vecPos;
vector<DWORD> strengthLvVec;
goods = info.itemID;
num = info.itemNum;
bind = bindFlag;
SetRewardItemInfo(reward, goods);
strengthLvVec.resize(goods.size(), 0);
m_owner->GetContainer(ePackageType)->AddItem(goods, num, vecPos, bind,strengthLvVec,true,npc_fly_type);
SetMicroRewardFlag(true);
SynRewardToClient();
return 0;
}
//void OnceReward::Statistic(eStatisticMainType main_enum, eLogicRelevant fun_enum)
//{
// StatisticMgr::GetInstance()->StatisticPlayerDailyTimes(m_owner->GetMyself(), main_enum, fun_enum, 1);
//}
bool OnceReward::IsMicroLogin()
{
Smart_Ptr<CounterService>& counter = m_owner->GetCounterService();
if ((bool)counter)
{
int num = counter->GetNumById(LOGINMICRO_COUNT);
if (0 < num)
{
return true;
}
}
return false;
}
|
95f96a6bffe4d7d41913dcd991cad81068d0c3ab | f69fc5c0ab573bbc5ac8615b709d8a04f982f517 | /DX/DX/MasterShadowShader.h | 519a5a8cfea5f1459c51d3a7569f82ae5cc108b0 | [] | no_license | jmottershead94/ProceduralFun | ce26d993c9ec03cca5b48c43570462245269e272 | 1310b6dc6b85f6cceeeb17a052bfa127fae88162 | refs/heads/master | 2021-01-01T05:19:55.649972 | 2016-05-04T11:37:21 | 2016-05-04T11:37:21 | 57,328,879 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,582 | h | MasterShadowShader.h | // Jason Mottershead, 1300455.
// Master shadow shader class header file.
// This class will be responsible for multiple lighting and shadows.
// Header guard.
#ifndef _MASTERSHADOWSHADER_H_
#define _MASTERSHADOWSHADER_H_
// Includes.
#include <array>
#include "BaseShader.h"
#include "PointLight.h"
// Namespaces.
using namespace std;
using namespace DirectX;
// Master shadow shader IS A base shader, therefore inherits from it.
class MasterShadowShader : public BaseShader
{
private:
// Used for matrices and multiple lights.
struct MatrixBufferType
{
XMMATRIX world;
XMMATRIX view;
XMMATRIX projection;
XMMATRIX lightView[2];
XMMATRIX lightProjection[2];
};
// Light colours.
struct LightBufferType
{
XMFLOAT4 ambient[2];
XMFLOAT4 diffuse[2];
};
// Light position.
struct LightBufferType2
{
XMFLOAT3 position[2];
float padding[2];
};
public:
// Methods.
MasterShadowShader(ID3D11Device* device, HWND hwnd);
~MasterShadowShader();
void SetShaderParameters(ID3D11DeviceContext* deviceContext, const XMMATRIX &world, const XMMATRIX &view, const XMMATRIX &projection, ID3D11ShaderResourceView* texture, ID3D11ShaderResourceView* depthMap[2], std::array<PointLight*, 2> light);
void Render(ID3D11DeviceContext* deviceContext, int vertexCount);
private:
// Attributes.
ID3D11Buffer* m_matrixBuffer;
ID3D11SamplerState* m_sampleState;
ID3D11SamplerState* m_sampleStateClamp;
ID3D11Buffer* m_LightBuffer;
ID3D11Buffer* m_LightBuffer2;
// Methods.
void InitShader(WCHAR*, WCHAR*);
};
#endif |
3a8d3496a582d921f464406351a64d9f364caca4 | 34d67ba8f7125f3ae51d86a1c2682c065e1954cb | /examples/Ex_keypad/Ex_keypad.ino | a2d393c4bcccaaab60e7dc9687732fc7a758ae6e | [] | no_license | ThaiEasyElec/I2C_KEYPAD | a1decc4a3ad61175d9786dacf170ed47e923ca7e | e05600ab749fa4e7f1272e6c56bc4a0ba97a93e4 | refs/heads/master | 2021-05-05T12:09:20.743613 | 2017-09-25T09:44:12 | 2017-09-25T09:44:12 | 104,720,777 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 290 | ino | Ex_keypad.ino | #include "i2c_keypad.h"
I2CKEYPAD keypad;
void setup()
{
Serial.begin(9600);
keypad.begin();
keypad.set_event(PRESS); // PRESS, RELEASE, DO
keypad.keypadevent = keyevent;
}
void loop()
{
keypad.scand(100); //scan time(ms)
}
void keyevent(char key)
{
Serial.println(key);
}
|
4a0c118b321c192aa43dacb0d071ac44d6891a55 | 02d72451833ca697c1a292cd8e6fcea72232d308 | /hmiplugin/src/uicomslots/uiserialport.h | 002def059583d3880c2ece73adeb07d65b0f4f96 | [] | no_license | perminovr/vs04 | bd2fc9ac9212f3a3de514b2b96a85c48952954cd | 6c80a4ecb6a478d28fdd699e00a8648c1579583a | refs/heads/master | 2023-03-12T23:23:54.202328 | 2021-02-27T05:09:02 | 2021-02-27T05:09:02 | 342,775,021 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,005 | h | uiserialport.h | #ifndef UISERIALPORT_H
#define UISERIALPORT_H
#include <QObject>
#include <QtQml>
#include <QQmlParserStatus>
#if PLC_BUILD
# include "serialportprovider.h"
#endif
#undef Q_PROPERTY_IMPLEMENTATION
#define Q_PROPERTY_IMPLEMENTATION(type, name, getter, setter, notifier) \
public slots: void setter(type t) { if (this->m_##name != t) { this->m_##name = t; emit this->notifier(); } } \
public: type getter() const { return this->m_##name; } \
Q_SIGNAL void notifier(); \
private: type m_##name;
class UISerialPort : public QObject , public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString dev READ dev WRITE setDev NOTIFY devChanged)
Q_PROPERTY(int baudRate READ baudRate WRITE setBaudRate NOTIFY baudRateChanged)
Q_PROPERTY(int parity READ parity WRITE setParity NOTIFY parityChanged)
Q_PROPERTY(int dataBits READ dataBits WRITE setDataBits NOTIFY dataBitsChanged)
Q_PROPERTY(int stopBits READ stopBits WRITE setStopBits NOTIFY stopBitsChanged)
Q_PROPERTY(bool isComplete READ isComplete NOTIFY completed)
Q_PROPERTY_IMPLEMENTATION(QString , dev , dev , setDev , devChanged)
Q_PROPERTY_IMPLEMENTATION(int , baudRate , baudRate , setBaudRate , baudRateChanged)
Q_PROPERTY_IMPLEMENTATION(int , parity , parity , setParity , parityChanged)
Q_PROPERTY_IMPLEMENTATION(int , dataBits , dataBits , setDataBits , dataBitsChanged)
Q_PROPERTY_IMPLEMENTATION(int , stopBits , stopBits , setStopBits , stopBitsChanged)
public:
UISerialPort(QObject *parent = nullptr);
virtual ~UISerialPort();
virtual void classBegin() override;
virtual void componentComplete() override;
bool isComplete();
static void qmlRegister(const char *pkgName, int mj, int mi) {
qmlRegisterType<UISerialPort>(pkgName, mj, mi, "UISerialPort");
}
public slots:
signals:
void completed(UISerialPort *);
protected:
static QStringList openedPorts;
private slots:
private:
#if PLC_BUILD
SerialPortProvider *provider;
#endif
bool m_complete;
};
#endif // UISERIALPORT_H
|
9d2996a1a05414b6bb46e03e74519368d94c669d | 4e1190455394bb008b9299082cdbd236477e293a | /a2oj/Level 4/Jzzhu and Sequences.cpp | 82aa4b8f4dcffea9c47d49e103850f4567c68831 | [] | no_license | Leonardosu/competitive_programming | 64b62fc5a1731763a1bee0f99f9a9d7df15e9e8a | 01ce1e4f3cb4dc3c5973774287f2e32f92418987 | refs/heads/master | 2023-08-04T06:27:26.384700 | 2023-07-24T19:47:57 | 2023-07-24T19:47:57 | 202,539,762 | 4 | 6 | null | 2022-10-25T00:24:54 | 2019-08-15T12:46:33 | C++ | UTF-8 | C++ | false | false | 627 | cpp | Jzzhu and Sequences.cpp | #include "bits/stdc++.h"
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define ALL(x) x.begin(),x.end()
#define present(c, x) (c.find(x) != c.end())
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll x, y, n;
const ll mod = 1e9 + 7;
//fn = fn-1 - fn-2
cin>>x>>y>>n;
vector<ll> f = {x,y,y-x,-x,-y,x-y};
ll ans;
if(n%6 == 0)
n = 6;
else
n %= 6;
ans = f[n - 1]%mod;
if(ans < 0)
ans += mod;
cout<<ans<<"\n";
} |
f88a7054ce59b957dddd9c6c94cd8cf74a7da78a | e90ec66af04a4a550f7b81232e56e5433b3423b3 | /QCDTools/EventPick.cc | 05f506d66793853044cfde0a59e923d235333b24 | [] | no_license | susy2015/QCD | 63a26ce86ec76e178678fcdc76d55f272248e87d | 6383577117d74372ffefa8886b026a4cd3751309 | refs/heads/master | 2021-01-17T00:53:17.906839 | 2017-10-04T22:55:04 | 2017-10-04T22:55:04 | 30,090,212 | 0 | 0 | null | 2017-10-04T22:55:05 | 2015-01-30T20:51:30 | C++ | UTF-8 | C++ | false | false | 8,801 | cc | EventPick.cc | #include <map>
#include <iomanip>
#include <locale>
#include <sstream>
#include <stdlib.h>
#include "TTree.h"
#include "TFile.h"
#include "TChain.h"
#include "TString.h"
#include "TLorentzVector.h"
#include "TInterpreter.h"
#include "SusyAnaTools/Tools/samples.h"
#include "SusyAnaTools/Tools/searchBins.h"
#include "EventPick.h"
int main(int argc, char* argv[])
{
if (argc < 1)
{
std::cerr <<"Please give 1 argument " << "inputFileName " << std::endl;
std::cerr <<"Valid configurations are: " << std::endl;
std::cerr <<"./EventPick root://cmseos.fnal.gov//store/user/lpcsusyhad/Spring15_74X_Oct_2015_Ntp_v2X/QCD_HT500to700_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/QCD_HT500to700_Spring15DR74_Asympt25ns_Ntp_v2/150928_140039/0000/stopFlatNtuples_1.root" << std::endl;
return -1;
}
std::string input_str(argv[1]);
TChain *originalTree = new TChain("stopTreeMaker/AUX");
originalTree->Add(input_str.c_str());
originalTree->SetBranchStatus("*", 1);
std::shared_ptr<topTagger::type3TopTagger>type3Ptr(nullptr);
NTupleReader *tr=0;
//initialize the type3Ptr defined in the customize.h
AnaFunctions::prepareForNtupleReader();
tr = new NTupleReader(originalTree, AnaConsts::activatedBranchNames);
const std::string spec = "lostlept";
BaselineVessel *myBaselineVessel = 0;
myBaselineVessel = new BaselineVessel(*tr, spec);
if( !useNewTagger ){ myBaselineVessel->SetupTopTagger(false, "Legacy_TopTagger.cfg" ); }
else
{
if( useLegacycfg ){ myBaselineVessel->SetupTopTagger(true, "Legacy_TopTagger.cfg" ); }
else{ myBaselineVessel->SetupTopTagger(true, "TopTagger.cfg" ); }
}
//The passBaseline is registered here
tr->registerFunction(*myBaselineVessel);
//here is a little bit tricky when dealing with the slash... need to improve
//for all the MC samples
//std::string tag = input_str.substr(find_Nth(input_str,10,"/") + 1,find_Nth(input_str,11,"/")-find_Nth(input_str,10,"/")-1);
//for all the data samples
std::string tag = input_str.substr(find_Nth(input_str,10,"/") + 1,find_Nth(input_str,11,"/")-find_Nth(input_str,10,"/")-1);
std::size_t begin = input_str.find("stopFlatNtuples");
std::size_t end = input_str.find(".root");
std::string fileid = input_str.substr(begin,end);
EventInfo myEventInfo_2t_1j2j;
myEventInfo_2t_1j2j.EvtTxtName = tag + "_" + fileid + ".2t_1j2j.txt";
EventInfo myEventInfo_2t_1j3j;
myEventInfo_2t_1j3j.EvtTxtName = tag + "_" + fileid + ".2t_1j3j.txt";
EventInfo myEventInfo_2t_2j3j;
myEventInfo_2t_2j3j.EvtTxtName = tag + "_" + fileid + ".2t_2j3j.txt";
EventInfo myEventInfo_2t_1j1j;
myEventInfo_2t_1j1j.EvtTxtName = tag + "_" + fileid + ".2t_1j1j.txt";
EventInfo myEventInfo_2t_2j2j;
myEventInfo_2t_2j2j.EvtTxtName = tag + "_" + fileid + ".2t_2j2j.txt";
EventInfo myEventInfo_2t_3j3j;
myEventInfo_2t_3j3j.EvtTxtName = tag + "_" + fileid + ".2t_3j3j.txt";
while(tr->getNextEvent())
{
unsigned int run = tr->getVar<unsigned int>("run");
unsigned int lumi = tr->getVar<unsigned int>("lumi");
unsigned long long int event = tr->getVar<unsigned long long int>("event");
int ntopjets = tr->getVar<int>("nTopCandSortedCnt"+spec);
const std::map<int, std::vector<TLorentzVector>> &mtopjets = tr->getMap<int, std::vector<TLorentzVector>>("mTopJets"+spec);
std::vector<TLorentzVector> jetsLVec = tr->getVec<TLorentzVector>("jetsLVec");
std::vector<double> jetsCSV = tr->getVec<double>("recoJetsBtag_0");
bool passBaseline = (tr->getVar<bool>("passBaseline"+spec)) && (tr->getVar<bool>("passLeptVeto"+spec));
bool dit_1j2j=false, dit_1j3j=false, dit_2j3j=false, dit_1j1j=false, dit_2j2j=false, dit_3j3j=false;
if( passBaseline )
{
if(ntopjets==2)
{
std::cout << "NTops: " << ntopjets << std::endl;
bool monojet=false, dijet=false, trijet=false;
int jid=0;//from 0 to 5
std::array<double, 6> thiseta, thisphi, thispt, thiscsv;
for(auto &topit : mtopjets)
{
std::cout << "Top ID: " << topit.first << " nSubJets: " << (topit.second).size() << std::endl;
int nsubjets=(topit.second).size();
if(nsubjets==1)
{
monojet=true;
thiseta[jid]=(topit.second).at(0).Eta(); thiseta[jid+1]=0; thiseta[jid+2]=0;
thisphi[jid]=(topit.second).at(0).Phi(); thisphi[jid+1]=0; thisphi[jid+2]=0;
thispt[jid]=(topit.second).at(0).Pt(); thispt[jid+1]=0; thispt[jid+2]=0;
thiscsv[jid]=-1; thiscsv[jid+1]=-1; thiscsv[jid+2]=-1;
}
else if(nsubjets==2)
{
dijet=true;
thiseta[jid]=(topit.second).at(0).Eta(); thiseta[jid+1]=(topit.second).at(1).Eta(); thiseta[jid+2]=0;
thisphi[jid]=(topit.second).at(0).Phi(); thisphi[jid+1]=(topit.second).at(1).Phi(); thisphi[jid+2]=0;
thispt[jid]=(topit.second).at(0).Pt(); thispt[jid+1]=(topit.second).at(1).Pt(); thispt[jid+2]=0;
thiscsv[jid]=-1; thiscsv[jid+1]=-1; thiscsv[jid+2]=-1;
}
else if(nsubjets==3)
{
trijet=true;
thiseta[jid]=(topit.second).at(0).Eta(); thiseta[jid+1]=(topit.second).at(1).Eta(); thiseta[jid+2]=(topit.second).at(2).Eta();
thisphi[jid]=(topit.second).at(0).Phi(); thisphi[jid+1]=(topit.second).at(1).Phi(); thisphi[jid+2]=(topit.second).at(2).Phi();
thispt[jid]=(topit.second).at(0).Pt(); thispt[jid+1]=(topit.second).at(1).Pt(); thispt[jid+2]=(topit.second).at(2).Pt();
thiscsv[jid]=GetCSVMatch((topit.second).at(0), jetsLVec, jetsCSV); thiscsv[jid+1]=GetCSVMatch((topit.second).at(1), jetsLVec, jetsCSV); thiscsv[jid+2]=GetCSVMatch((topit.second).at(2), jetsLVec, jetsCSV);
}
else std::cout<<"Not monojet, dijet or trijet case!" << std::endl;
jid=jid+3;
}
dit_1j2j = monojet && dijet && (!trijet); dit_1j3j = monojet && (!dijet) && trijet; dit_2j3j = (!monojet) && dijet && trijet;
dit_1j1j = monojet && (!dijet) && (!trijet); dit_2j2j = (!monojet) && dijet && (!trijet); dit_3j3j = (!monojet) && (!dijet) && trijet;
if(dit_1j2j)
{
myEventInfo_2t_1j2j.run.push_back(run); myEventInfo_2t_1j2j.lumi.push_back(lumi); myEventInfo_2t_1j2j.event.push_back(event);
myEventInfo_2t_1j2j.eta.push_back(thiseta); myEventInfo_2t_1j2j.phi.push_back(thisphi); myEventInfo_2t_1j2j.pt.push_back(thispt);
myEventInfo_2t_1j2j.csv.push_back(thiscsv);
}
if(dit_1j3j)
{
myEventInfo_2t_1j3j.run.push_back(run); myEventInfo_2t_1j3j.lumi.push_back(lumi); myEventInfo_2t_1j3j.event.push_back(event);
myEventInfo_2t_1j3j.eta.push_back(thiseta); myEventInfo_2t_1j3j.phi.push_back(thisphi); myEventInfo_2t_1j3j.pt.push_back(thispt);
myEventInfo_2t_1j3j.csv.push_back(thiscsv);
}
if(dit_2j3j)
{
myEventInfo_2t_2j3j.run.push_back(run); myEventInfo_2t_2j3j.lumi.push_back(lumi); myEventInfo_2t_2j3j.event.push_back(event);
myEventInfo_2t_2j3j.eta.push_back(thiseta); myEventInfo_2t_2j3j.phi.push_back(thisphi); myEventInfo_2t_2j3j.pt.push_back(thispt);
myEventInfo_2t_2j3j.csv.push_back(thiscsv);
}
if(dit_1j1j)
{
myEventInfo_2t_1j1j.run.push_back(run); myEventInfo_2t_1j1j.lumi.push_back(lumi); myEventInfo_2t_1j1j.event.push_back(event);
myEventInfo_2t_1j1j.eta.push_back(thiseta); myEventInfo_2t_1j1j.phi.push_back(thisphi); myEventInfo_2t_1j1j.pt.push_back(thispt);
myEventInfo_2t_1j1j.csv.push_back(thiscsv);
}
if(dit_2j2j)
{
myEventInfo_2t_2j2j.run.push_back(run); myEventInfo_2t_2j2j.lumi.push_back(lumi); myEventInfo_2t_2j2j.event.push_back(event);
myEventInfo_2t_2j2j.eta.push_back(thiseta); myEventInfo_2t_2j2j.phi.push_back(thisphi); myEventInfo_2t_2j2j.pt.push_back(thispt);
myEventInfo_2t_2j2j.csv.push_back(thiscsv);
}
if(dit_3j3j)
{
myEventInfo_2t_3j3j.run.push_back(run); myEventInfo_2t_3j3j.lumi.push_back(lumi); myEventInfo_2t_3j3j.event.push_back(event);
myEventInfo_2t_3j3j.eta.push_back(thiseta); myEventInfo_2t_3j3j.phi.push_back(thisphi); myEventInfo_2t_3j3j.pt.push_back(thispt);
myEventInfo_2t_3j3j.csv.push_back(thiscsv);
}
}
else continue;
}
}
if (originalTree) delete originalTree;
std::string d = "root://cmseos.fnal.gov//store/group/lpcsusyhad/hua/Skimmed_2015Nov15";
myEventInfo_2t_1j2j.ZSxrdcp(d);
myEventInfo_2t_1j3j.ZSxrdcp(d);
myEventInfo_2t_2j3j.ZSxrdcp(d);
myEventInfo_2t_1j1j.ZSxrdcp(d);
myEventInfo_2t_2j2j.ZSxrdcp(d);
myEventInfo_2t_3j3j.ZSxrdcp(d);
return 0;
}
|
40d2b83d8acea54ac28988bfd66229f11398d172 | 5a44a41644af0721c56c6bed9040e2107521134e | /Qt_MP_app/chessboard.h | 22b5c9df393cff2ef29622b7a0511d67c3d19cd1 | [] | no_license | Shothogun/Xadrez_6000_MP | 7f4d0f57cde384486ee213acda4ed505e882027d | c75e23c597447bfe4b8354e391d274b3c5d28380 | refs/heads/master | 2020-03-20T16:03:42.213743 | 2018-07-09T00:37:09 | 2018-07-09T00:37:09 | 137,528,680 | 5 | 1 | null | 2018-07-03T19:18:32 | 2018-06-15T20:21:26 | null | UTF-8 | C++ | false | false | 1,317 | h | chessboard.h | #ifndef CHESSBOARD_H
#define CHESSBOARD_H
#include "../chesspiece.h"
#include <QGraphicsView>
#include <QWidget>
#include <QGraphicsScene>
#include <QBrush>
#include <QGraphicsSceneMouseEvent>
#include <math.h>
class ChessBoard : public QGraphicsView
{
public:
ChessBoard();
QPointF position;
QGraphicsScene * board;
bool CheckMate = false;
std::vector<QPointF> centers;
// Starts a new game
/**
* start()
*
* Descrição:
*
* Preenche o tabuleiro com as peças do jogo
*/
void start();
/**
* @brief drawPanel
* @param x
* @param y
* @param width
* @param height
* @param color
* @param opacity
*
* Descrição:
*
* Cria um painel na janela do jogo
*/
void drawPanel(int x, int y, int width, int height, QColor color, double opacity);
/**
* gameOver()
*
* Descrição:
*
* Chama a função displayGameOverWindow e define a mensagem de fim de jogo
*
*/
void gameOver();
/**
* @brief displayGameOverWindow
* @param textToDisplay
*
* Descrição:
*
* Chama a função drawPanel e cria a mensagem de fim de jogo
*/
void displayGameOverWindow(QString textToDisplay);
};
#endif // CHESSBOARD_H
|
9bb19bc15a8b17a564b9e72451b8137e62f120c0 | 8faee0b01b9afed32bb5b7ef1ab0dcbc46788b5b | /source/src/dbapi/test/dbapi_unit_test_connection.cpp | 1d520bc5668ec4157b49905495a7c62993689661 | [] | no_license | jackgopack4/pico-blast | 5fe3fa1944b727465845e1ead1a3c563b43734fb | cde1bd03900d72d0246cb58a66b41e5dc17329dd | refs/heads/master | 2021-01-14T12:31:05.676311 | 2014-05-17T19:22:05 | 2014-05-17T19:22:05 | 16,808,473 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 40,918 | cpp | dbapi_unit_test_connection.cpp | /* $Id: dbapi_unit_test_connection.cpp 399404 2013-05-14 15:05:30Z ucko $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
* National Center for Biotechnology Information
*
* This software/database is a "United States Government Work" under the
* terms of the United States Copyright Act. It was written as part of
* the author's official duties as a United States Government employee and
* thus cannot be copyrighted. This software/database is freely available
* to the public for use. The National Library of Medicine and the U.S.
* Government have not placed any restriction on its use or reproduction.
*
* Although all reasonable efforts have been taken to ensure the accuracy
* and reliability of the software and data, the NLM and the U.S.
* Government do not and cannot warrant the performance or results that
* may be obtained by using this software or data. The NLM and the U.S.
* Government disclaim all warranties, express or implied, including
* warranties of performance, merchantability or fitness for any particular
* purpose.
*
* Please cite the author in any work or product based on this material.
*
* ===========================================================================
*
* Author: Sergey Sikorskiy
*
* File Description: DBAPI unit-test
*
* ===========================================================================
*/
#include "dbapi_unit_test_pch.hpp"
#include <corelib/ncbi_system.hpp>
#include <corelib/resource_info.hpp>
#include <dbapi/driver/impl/dbapi_driver_utils.hpp>
#include <dbapi/driver/dbapi_svc_mapper.hpp>
#ifdef HAVE_LIBCONNEXT
# include <connect/ext/ncbi_crypt.h>
#endif
BEGIN_NCBI_SCOPE
///////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_Multiple_Close)
{
try {
///////////////////////
// CreateStatement
///////////////////////
// Destroy a statement before a connection get destroyed ...
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
auto_ptr<IStatement> stmt(local_conn->CreateStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt.get());
// Close a statement first ...
stmt->Close();
stmt->Close();
stmt->Close();
local_conn->Close();
local_conn->Close();
local_conn->Close();
}
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
auto_ptr<IStatement> stmt(local_conn->CreateStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt.get());
// Close a connection first ...
local_conn->Close();
local_conn->Close();
local_conn->Close();
stmt->Close();
stmt->Close();
stmt->Close();
}
// Do not destroy a statement, let it be destroyed ...
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
IStatement* stmt(local_conn->CreateStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt);
// Close a statement first ...
stmt->Close();
stmt->Close();
stmt->Close();
local_conn->Close();
local_conn->Close();
local_conn->Close();
}
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
IStatement* stmt(local_conn->CreateStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt);
// Close a connection first ...
local_conn->Close();
local_conn->Close();
local_conn->Close();
stmt->Close();
stmt->Close();
stmt->Close();
}
///////////////////////
// GetStatement
///////////////////////
// Destroy a statement before a connection get destroyed ...
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
auto_ptr<IStatement> stmt(local_conn->GetStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt.get());
// Close a statement first ...
stmt->Close();
stmt->Close();
stmt->Close();
local_conn->Close();
local_conn->Close();
local_conn->Close();
}
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
auto_ptr<IStatement> stmt(local_conn->GetStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt.get());
// Close a connection first ...
local_conn->Close();
local_conn->Close();
local_conn->Close();
stmt->Close();
stmt->Close();
stmt->Close();
}
// Do not destroy a statement, let it be destroyed ...
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
IStatement* stmt(local_conn->GetStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt);
// Close a statement first ...
stmt->Close();
stmt->Close();
stmt->Close();
local_conn->Close();
local_conn->Close();
local_conn->Close();
}
{
auto_ptr<IConnection> local_conn(
GetDS().CreateConnection(eTakeOwnership)
);
local_conn->Connect(GetArgs().GetConnParams());
IStatement* stmt(local_conn->GetStatement());
stmt->SendSql( "SELECT name FROM sysobjects" );
DumpResults(stmt);
// Close a connection first ...
local_conn->Close();
local_conn->Close();
local_conn->Close();
stmt->Close();
stmt->Close();
stmt->Close();
}
}
catch(const CException& ex) {
DBAPI_BOOST_FAIL(ex);
}
}
////////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_DropConnection)
{
string sql;
enum {
num_of_tests = 31
};
try {
CMsgHandlerGuard guard(*GetDS().GetDriverContext());
sql = "sleep 0 kill";
const unsigned orig_conn_num = GetDS().GetDriverContext()->NofConnections();
CDBSetConnParams params(
"LINK_OS_INTERNAL",
"anyone",
"allowed",
125,
GetArgs().GetConnParams()
);
for (unsigned i = 0; i < num_of_tests; ++i) {
// Start a connection scope ...
{
bool conn_killed = false;
auto_ptr<CDB_Connection> auto_conn;
auto_conn.reset(GetDS().GetDriverContext()->MakeConnection(params));
// kill connection ...
try {
auto_ptr<CDB_LangCmd> auto_stmt(auto_conn->LangCmd(sql));
auto_stmt->Send();
auto_stmt->DumpResults();
} catch (const CDB_Exception&) {
// Ignore it ...
}
try {
auto_ptr<CDB_RPCCmd> auto_stmt(auto_conn->RPC("sp_who"));
auto_stmt->Send();
auto_stmt->DumpResults();
} catch (const CDB_Exception&) {
conn_killed = true;
}
BOOST_CHECK(conn_killed);
}
BOOST_CHECK_EQUAL(
orig_conn_num,
GetDS().GetDriverContext()->NofConnections()
);
}
}
catch(const CException& ex) {
DBAPI_BOOST_FAIL(ex);
}
}
////////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_N_Connections)
{
{
enum {
eN = 5
};
auto_ptr<IConnection> auto_conns[eN + 1];
// There is already 1 connections - so +1
CDriverManager::GetInstance().SetMaxConnect(eN + 1);
for (int i = 0; i < eN; ++i) {
auto_ptr<IConnection> auto_conn(GetDS().CreateConnection(CONN_OWNERSHIP));
auto_conn->Connect(GetArgs().GetConnParams());
auto_ptr<IStatement> auto_stmt(auto_conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
auto_conns[i] = auto_conn;
}
try {
auto_conns[eN].reset(GetDS().CreateConnection(CONN_OWNERSHIP));
auto_conns[eN]->Connect(GetArgs().GetConnParams());
BOOST_FAIL("Connection above limit is created");
}
catch (CDB_Exception&) {
// exception thrown - it's ok
LOG_POST("Connection above limit is rejected - that is ok");
}
}
// This test is not supposed to be run every day.
if (false) {
enum {
eN = 50
};
auto_ptr<IConnection> auto_conns[eN];
// There are already 2 connections - so +2
CDriverManager::GetInstance().SetMaxConnect(eN + 2);
for (int i = 0; i < eN; ++i) {
auto_ptr<IConnection> auto_conn(GetDS().CreateConnection(CONN_OWNERSHIP));
auto_conn->Connect(GetArgs().GetConnParams());
auto_ptr<IStatement> auto_stmt(auto_conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
auto_conns[i] = auto_conn;
}
}
else {
GetArgs().PutMsgDisabled("Large connections amount");
}
}
////////////////////////////////////////////////////////////////////////////////
static
IDBServiceMapper*
MakeCDBUDPriorityMapper01(const IRegistry* registry)
{
TSvrRef server01(new CDBServer("MSDEV1"));
TSvrRef server02(new CDBServer("MSDEV2"));
const string service_name("TEST_SERVICE_01");
auto_ptr<CDBUDPriorityMapper> mapper(new CDBUDPriorityMapper(registry));
mapper->Add(service_name, server01);
mapper->Add(service_name, server02);
mapper->Add(service_name, server01);
mapper->Add(service_name, server01);
// mapper->Add(service_name, server01);
// mapper->Add(service_name, server01);
// mapper->Add(service_name, server01);
// mapper->Add(service_name, server01);
// mapper->Add(service_name, server01);
return mapper.release();
}
typedef IDBConnectionFactory* (*TDBConnectionFactoryFactory)
(IDBServiceMapper::TFactory svc_mapper_factory);
////////////////////////////////////////////////////////////////////////////////
static void
s_Check_Validator(TDBConnectionFactoryFactory factory,
IConnValidator& validator)
{
TSvrRef server01(new CDBServer("MSDEV2"));
const string service_name("TEST_SERVICE_01");
auto_ptr<IConnection> conn;
// Install new mapper ...
ncbi::CDbapiConnMgr::Instance().SetConnectionFactory(
factory(MakeCDBUDPriorityMapper01)
);
// Create connection ...
conn.reset(GetDS().CreateConnection(CONN_OWNERSHIP));
BOOST_CHECK(conn.get() != NULL);
// There are only 3 of server01 ...
for (int i = 0; i < 12; ++i) {
conn->ConnectValidated(
validator,
GetArgs().GetUserName(),
GetArgs().GetUserPassword(),
service_name
);
string server_name = conn->GetCDB_Connection()->ServerName();
// LOG_POST(Warning << "Connected to: " << server_name);
// server02 shouldn't be reported ...
BOOST_CHECK_EQUAL(server_name, server01->GetName());
conn->Close();
}
}
////////////////////////////////////////////////////////////////////////////////
static
IDBConnectionFactory*
CDBConnectionFactoryFactory(IDBServiceMapper::TFactory svc_mapper_factory)
{
return new CDBConnectionFactory(svc_mapper_factory);
}
///////////////////////////////////////////////////////////////////////////////
static
IDBConnectionFactory*
CDBRedispatchFactoryFactory(IDBServiceMapper::TFactory svc_mapper_factory)
{
return new CDBRedispatchFactory(svc_mapper_factory);
}
////////////////////////////////////////////////////////////////////////////////
class CValidator : public CTrivialConnValidator
{
public:
CValidator(const string& db_name,
int attr = eDefaultValidateAttr)
: CTrivialConnValidator(db_name, attr)
{
}
virtual EConnStatus ValidateException(const CDB_Exception& ex)
{
return eTempInvalidConn;
}
};
///////////////////////////////////////////////////////////////////////////////
class CValidator01 : public CTrivialConnValidator
{
public:
CValidator01(const string& db_name,
int attr = eDefaultValidateAttr)
: CTrivialConnValidator(db_name, attr)
{
}
public:
virtual IConnValidator::EConnStatus Validate(CDB_Connection& conn)
{
// Try to change a database ...
try {
conn.SetDatabaseName(GetDBName());
}
catch(const CDB_Exception&) {
// LOG_POST(Warning << "Db not accessible: " << GetDBName() <<
// ", Server name: " << conn.ServerName());
return eTempInvalidConn;
// return eInvalidConn;
}
if (GetAttr() & eCheckSysobjects) {
auto_ptr<CDB_LangCmd> set_cmd(conn.LangCmd("SELECT id FROM sysobjects"));
set_cmd->Send();
set_cmd->DumpResults();
}
// Go back to the original (master) database ...
if (GetAttr() & eRestoreDefaultDB) {
conn.SetDatabaseName("master");
}
// All exceptions are supposed to be caught and processed by
// CDBConnectionFactory ...
return eValidConn;
}
virtual EConnStatus ValidateException(const CDB_Exception& ex)
{
return eTempInvalidConn;
}
virtual string GetName(void) const
{
return "CValidator01" + GetDBName();
}
};
////////////////////////////////////////////////////////////////////////////////
class CValidator02 : public CTrivialConnValidator
{
public:
CValidator02(const string& db_name,
int attr = eDefaultValidateAttr)
: CTrivialConnValidator(db_name, attr)
{
}
public:
virtual IConnValidator::EConnStatus Validate(CDB_Connection& conn)
{
// Try to change a database ...
try {
conn.SetDatabaseName(GetDBName());
}
catch(const CDB_Exception&) {
// LOG_POST(Warning << "Db not accessible: " << GetDBName() <<
// ", Server name: " << conn.ServerName());
return eTempInvalidConn;
// return eInvalidConn;
}
if (GetAttr() & eCheckSysobjects) {
auto_ptr<CDB_LangCmd> set_cmd(conn.LangCmd("SELECT id FROM sysobjects"));
set_cmd->Send();
set_cmd->DumpResults();
}
// Go back to the original (master) database ...
if (GetAttr() & eRestoreDefaultDB) {
conn.SetDatabaseName("master");
}
// All exceptions are supposed to be caught and processed by
// CDBConnectionFactory ...
return eValidConn;
}
virtual EConnStatus ValidateException(const CDB_Exception& ex)
{
return eInvalidConn;
}
virtual string GetName(void) const
{
return "CValidator02" + GetDBName();
}
};
////////////////////////////////////////////////////////////////////////////////
static void
s_CheckConnFactory(TDBConnectionFactoryFactory factory_factory)
{
const string db_name("CppDocTest"); // This database should exist in MSDEV2, and not in MSDEV1
// CTrivialConnValidator ...
{
CTrivialConnValidator validator(db_name);
s_Check_Validator(factory_factory, validator);
}
// Same as before but with a customized validator ...
{
// Connection validator to check against DBAPI_Sample ...
CValidator validator(db_name);
s_Check_Validator(factory_factory, validator);
}
// Another customized validator ...
{
// Connection validator to check against DBAPI_Sample ...
CValidator01 validator(db_name);
s_Check_Validator(factory_factory, validator);
}
// One more ...
{
// Connection validator to check against DBAPI_Sample ...
CValidator02 validator(db_name);
s_Check_Validator(factory_factory, validator);
}
}
////////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_ConnFactory)
{
enum {num_of_tests = 128};
try {
TSvrRef server01(new CDBServer("msdev2"));
TSvrRef server02(new CDBServer("msdev1"));
TSvrRef server03(new CDBServer("mssql67"));
// Check CDBUDPriorityMapper ...
{
const string service_name("TEST_SERVICE_01");
auto_ptr<CDBUDPriorityMapper> mapper(new CDBUDPriorityMapper());
mapper->Add(service_name, server01);
mapper->Add(service_name, server02);
mapper->Add(service_name, server03);
for (int i = 0; i < num_of_tests; ++i) {
BOOST_CHECK(mapper->GetServer(service_name) == server01);
BOOST_CHECK(mapper->GetServer(service_name) == server02);
BOOST_CHECK(mapper->GetServer(service_name) == server03);
BOOST_CHECK(mapper->GetServer(service_name) != server02);
BOOST_CHECK(mapper->GetServer(service_name) != server03);
BOOST_CHECK(mapper->GetServer(service_name) != server01);
}
}
// Check CDBUDRandomMapper ...
// DBUDRandomMapper is currently brocken ...
if (false) {
const string service_name("TEST_SERVICE_02");
auto_ptr<CDBUDRandomMapper> mapper(new CDBUDRandomMapper());
mapper->Add(service_name, server01);
mapper->Add(service_name, server02);
mapper->Add(service_name, server03);
size_t num_server01 = 0;
size_t num_server02 = 0;
size_t num_server03 = 0;
for (int i = 0; i < num_of_tests; ++i) {
TSvrRef cur_server = mapper->GetServer(service_name);
if (cur_server == server01) {
++num_server01;
} else if (cur_server == server02) {
++num_server02;
} else if (cur_server == server03) {
++num_server03;
} else {
BOOST_FAIL("Unknown server.");
}
}
BOOST_CHECK_EQUAL(num_server01, num_server02);
BOOST_CHECK_EQUAL(num_server02, num_server03);
BOOST_CHECK_EQUAL(num_server03, num_server01);
}
// Check CDBConnectionFactory ...
s_CheckConnFactory(CDBConnectionFactoryFactory);
// Check CDBRedispatchFactory ...
s_CheckConnFactory(CDBRedispatchFactoryFactory);
// Future development ...
// ncbi::CDbapiConnMgr::Instance().SetConnectionFactory(
// new CDBConnectionFactory(
// mapper.release()
// )
// );
// Restore original state ...
DBLB_INSTALL_DEFAULT();
}
catch(const CException& ex) {
DBAPI_BOOST_FAIL(ex);
}
}
////////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_ConnPool)
{
const string pool_name("test_pool");
string sql;
try {
// Create pooled connection ...
{
auto_ptr<CDB_Connection> auto_conn(
GetDS().GetDriverContext()->Connect(
GetArgs().GetServerName(),
GetArgs().GetUserName(),
GetArgs().GetUserPassword(),
0,
true, // reusable
pool_name
)
);
BOOST_CHECK( auto_conn.get() != NULL );
sql = "select @@version";
auto_ptr<CDB_LangCmd> auto_stmt( auto_conn->LangCmd(sql) );
BOOST_CHECK( auto_stmt.get() != NULL );
bool rc = auto_stmt->Send();
BOOST_CHECK( rc );
auto_stmt->DumpResults();
}
// Get pooled connection ...
{
auto_ptr<CDB_Connection> auto_conn(
GetDS().GetDriverContext()->Connect(
"",
"",
"",
0,
true, // reusable
pool_name
)
);
BOOST_CHECK( auto_conn.get() != NULL );
sql = "select @@version";
auto_ptr<CDB_LangCmd> auto_stmt( auto_conn->LangCmd(sql) );
BOOST_CHECK( auto_stmt.get() != NULL );
bool rc = auto_stmt->Send();
BOOST_CHECK( rc );
auto_stmt->DumpResults();
}
}
catch(const CException& ex) {
DBAPI_BOOST_FAIL(ex);
}
}
////////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_ConnParams)
{
// Checking parser ...
if (true) {
// CDBUriConnParams ...
{
CDBUriConnParams params("dbapi:ctlib://myuser:mypswd@MAPVIEW_LOAD:1433/AlignModel?tds_version=42&client_charset=UTF8");
BOOST_CHECK_EQUAL(params.GetDriverName(), string("ctlib"));
BOOST_CHECK_EQUAL(params.GetUserName(), string("myuser"));
BOOST_CHECK_EQUAL(params.GetPassword(), string("mypswd"));
BOOST_CHECK_EQUAL(params.GetServerName(), string("MAPVIEW_LOAD"));
BOOST_CHECK_EQUAL(params.GetPort(), 1433U);
BOOST_CHECK_EQUAL(params.GetDatabaseName(), string("AlignModel"));
}
{
CDBUriConnParams params("dbapi:ftds://myuser@MAPVIEW_LOAD/AlignModel");
BOOST_CHECK_EQUAL(params.GetDriverName(), string("ftds"));
BOOST_CHECK_EQUAL(params.GetUserName(), string("myuser"));
BOOST_CHECK_EQUAL(params.GetPassword(), string("allowed"));
BOOST_CHECK_EQUAL(params.GetServerName(), string("MAPVIEW_LOAD"));
BOOST_CHECK_EQUAL(params.GetPort(), 1433U);
BOOST_CHECK_EQUAL(params.GetDatabaseName(), string("AlignModel"));
}
{
CDBUriConnParams params("dbapi://myuser@MAPVIEW_LOAD/AlignModel");
BOOST_CHECK_EQUAL(params.GetUserName(), string("myuser"));
BOOST_CHECK_EQUAL(params.GetPassword(), string("allowed"));
BOOST_CHECK_EQUAL(params.GetServerName(), string("MAPVIEW_LOAD"));
BOOST_CHECK_EQUAL(params.GetPort(), 1433U);
BOOST_CHECK_EQUAL(params.GetDatabaseName(), string("AlignModel"));
}
{
CDBUriConnParams params("dbapi://myuser:allowed@MAPVIEW_LOAD/AlignModel");
BOOST_CHECK_EQUAL(params.GetUserName(), string("myuser"));
BOOST_CHECK_EQUAL(params.GetPassword(), string("allowed"));
BOOST_CHECK_EQUAL(params.GetServerName(), string("MAPVIEW_LOAD"));
BOOST_CHECK_EQUAL(params.GetPort(), 1433U);
BOOST_CHECK_EQUAL(params.GetDatabaseName(), string("AlignModel"));
}
{
CDBUriConnParams params("dbapi://myuser:allowed@MAPVIEW_LOAD");
BOOST_CHECK_EQUAL(params.GetUserName(), string("myuser"));
BOOST_CHECK_EQUAL(params.GetPassword(), string("allowed"));
BOOST_CHECK_EQUAL(params.GetServerName(), string("MAPVIEW_LOAD"));
BOOST_CHECK_EQUAL(params.GetPort(), 1433U);
BOOST_CHECK_EQUAL(params.GetDatabaseName(), string(""));
}
// CDB_ODBC_ConnParams ..
{
CDB_ODBC_ConnParams params("Driver={SQLServer};Server=DBAPI_MS_TEST;Database=DBAPI_Sample;Uid=anyone;Pwd=allowed;");
BOOST_CHECK_EQUAL(params.GetDriverName(), string("{SQLServer}"));
BOOST_CHECK_EQUAL(params.GetUserName(), string("anyone"));
BOOST_CHECK_EQUAL(params.GetPassword(), string("allowed"));
BOOST_CHECK_EQUAL(params.GetServerName(), string("DBAPI_MS_TEST"));
BOOST_CHECK_EQUAL(params.GetPort(), 1433U);
BOOST_CHECK_EQUAL(params.GetDatabaseName(), string("DBAPI_Sample"));
}
}
// Checking ability to connect using different connection-parameter classes ...
if (true) {
// CDBUriConnParams ...
{
{
CDBUriConnParams params(
"dbapi:" + GetArgs().GetDriverName() +
"://" + GetArgs().GetUserName() +
":" + GetArgs().GetUserPassword() +
"@" + GetArgs().GetServerName()
);
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
// m_DM.DestroyDs(ds); // DO NOT destroy data source! That will
// crash application.
}
{
CDBUriConnParams params(
"dbapi:" // No driver name ...
"//" + GetArgs().GetUserName() +
":" + GetArgs().GetUserPassword() +
"@" + GetArgs().GetServerName()
);
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
// m_DM.DestroyDs(ds); // DO NOT destroy data source! That will
// crash application.
}
{
CDBUriConnParams params(
"dbapi:" // No driver name ...
"//" + GetArgs().GetUserName() +
// No password ...
"@" + GetArgs().GetServerName()
);
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
// m_DM.DestroyDs(ds); // DO NOT destroy data source! That will
// crash application.
}
}
// CDB_ODBC_ConnParams ...
{
{
CDB_ODBC_ConnParams params(
"DRIVER=" + GetArgs().GetDriverName() +
";UID=" + GetArgs().GetUserName() +
";PWD=" + GetArgs().GetUserPassword() +
";SERVER=" + GetArgs().GetServerName()
);
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
// m_DM.DestroyDs(ds); // DO NOT destroy data source! That will
// crash application.
}
{
CDB_ODBC_ConnParams params(
// No driver ...
";UID=" + GetArgs().GetUserName() +
";PWD=" + GetArgs().GetUserPassword() +
";SERVER=" + GetArgs().GetServerName()
);
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
// m_DM.DestroyDs(ds); // DO NOT destroy data source! That will
// crash application.
}
{
CDB_ODBC_ConnParams params(
// No driver ...
";UID=" + GetArgs().GetUserName() +
// No password ...
";SERVER=" + GetArgs().GetServerName()
);
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
// m_DM.DestroyDs(ds); // DO NOT destroy data source! That will
// crash application.
}
}
}
// Check CDBEnvConnParams ...
{
CDBUriConnParams uri_params("dbapi://wrong_user:wrong_pswd@wrong_server/wrong_db");
CDBEnvConnParams params(uri_params);
CNcbiEnvironment env;
env.Set("DBAPI_SERVER", GetArgs().GetServerName());
env.Set("DBAPI_DATABASE", "DBAPI_Sample");
env.Set("DBAPI_USER", GetArgs().GetUserName());
env.Set("DBAPI_PASSWORD", GetArgs().GetUserPassword());
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
env.Reset();
}
// CDBInterfacesFileConnParams ...
{
CDBUriConnParams uri_params(
"dbapi:" // No driver name ...
"//" + GetArgs().GetUserName() +
":" + GetArgs().GetUserPassword() +
"@" + GetArgs().GetServerName()
);
CDBInterfacesFileConnParams params(uri_params);
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
}
}
///////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_ConnParamsDatabase)
{
try {
const string target_db_name("DBAPI_Sample");
// Check method Connect() ...
{
auto_ptr<IConnection> conn(GetDS().CreateConnection( eTakeOwnership ));
conn->Connect(
GetArgs().GetConnParams().GetUserName(),
GetArgs().GetConnParams().GetPassword(),
GetArgs().GetConnParams().GetServerName(),
target_db_name);
auto_ptr<IStatement> auto_stmt( conn->GetStatement() );
IResultSet* rs = auto_stmt->ExecuteQuery("select db_name()");
BOOST_CHECK( rs != NULL );
BOOST_CHECK( rs->Next() );
const string db_name = rs->GetVariant(1).GetString();
BOOST_CHECK_EQUAL(db_name, target_db_name);
}
// Check method ConnectValidated() ...
{
auto_ptr<IConnection> conn(GetDS().CreateConnection( eTakeOwnership ));
CTrivialConnValidator validator(target_db_name);
conn->ConnectValidated(
validator,
GetArgs().GetConnParams().GetUserName(),
GetArgs().GetConnParams().GetPassword(),
GetArgs().GetConnParams().GetServerName(),
target_db_name);
auto_ptr<IStatement> auto_stmt( conn->GetStatement() );
IResultSet* rs = auto_stmt->ExecuteQuery("select db_name()");
BOOST_CHECK( rs != NULL );
BOOST_CHECK( rs->Next() );
const string db_name = rs->GetVariant(1).GetString();
BOOST_CHECK_EQUAL(db_name, target_db_name);
}
}
catch(const CException& ex) {
DBAPI_BOOST_FAIL(ex);
}
}
///////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(Test_CloneConnection)
{
try {
const string target_db_name("DBAPI_Sample");
// Create new connection ...
auto_ptr<IConnection> conn(GetDS().CreateConnection( CONN_OWNERSHIP ));
conn->Connect(
GetArgs().GetConnParams().GetUserName(),
GetArgs().GetConnParams().GetPassword(),
GetArgs().GetConnParams().GetServerName(),
target_db_name);
// Clone connection ...
auto_ptr<IConnection> new_conn(conn->CloneConnection(eTakeOwnership));
auto_ptr<IStatement> auto_stmt( new_conn->GetStatement() );
// Check that database was set correctly with the new connection ...
{
IResultSet* rs = auto_stmt->ExecuteQuery("select db_name()");
BOOST_CHECK( rs != NULL );
BOOST_CHECK( rs->Next() );
const string db_name = rs->GetVariant(1).GetString();
BOOST_CHECK_EQUAL(db_name, target_db_name);
}
}
catch(const CException& ex) {
DBAPI_BOOST_FAIL(ex);
}
}
class CMirrorValidator : public CTrivialConnValidator
{
public:
CMirrorValidator(const string& db_name, int attr = eDefaultValidateAttr)
: CTrivialConnValidator(db_name, attr)
{
}
virtual string GetName(void) const
{
return "CMirrorValidator";
}
};
BOOST_AUTO_TEST_CASE(Test_Mirrors)
{
CMirrorValidator validator1("DBAPI_ConnectionTest1");
CMirrorValidator validator2("DBAPI_ConnectionTestt2");
string username = "DBAPI_test";
string password = "allowed";
string server = "MSDEVVV";
// Create new connection ...
AutoPtr<IConnection> conn;
int i = 0;
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator1, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator1, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator2, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
SleepSec(11);
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator2, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator1, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
SleepSec(31);
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator1, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
SleepSec(11);
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator2, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
LOG_POST(++i << " connection");
try {
// Create new connection ...
conn = GetDS().CreateConnection( CONN_OWNERSHIP );
conn->ConnectValidated(validator2, username, password, server);
}
catch(const CException& ex) {
BOOST_ERROR(ex.what());
}
}
// For this test to work one should change kDefaultResourceInfoPath inside
// util/resource_info.cpp to appropriate test value and set
// conn_use_encrypt_data value in section dbapi to true in ini-file.
BOOST_AUTO_TEST_CASE(Test_EncryptData)
{
try {
TDbapi_ConnUseEncryptData::SetDefault(true);
CNcbiResourceInfoFile file(CNcbiResourceInfoFile::GetDefaultFileName());
string app_name = CNcbiApplication::Instance()->GetProgramDisplayName();
typedef CNcbiResourceInfo::TExtraValuesMap TExtraMap;
typedef TExtraMap::value_type TExtraPair;
{{
CNcbiResourceInfo& info = file.GetResourceInfo_NC(app_name + "/some_user@some_server", "some_passwd");
info.SetValue("allowed");
TExtraMap& extra = info.GetExtraValues_NC().GetPairs();
extra.insert(TExtraPair("username", "DBAPI_test"));
extra.insert(TExtraPair("server", "MSDEV1"));
extra.insert(TExtraPair("database", ""));
file.SaveFile();
CDBDefaultConnParams params("some_server", "some_user", "some_passwd");
params.SetDriverName(GetArgs().GetDriverName());
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
BOOST_CHECK_EQUAL(conn->GetDatabase(), "");
BOOST_CHECK_EQUAL(conn->GetCDB_Connection()->Password(), "allowed");
BOOST_CHECK_EQUAL(conn->GetCDB_Connection()->ServerName(), "MSDEV1");
BOOST_CHECK_EQUAL(conn->GetCDB_Connection()->UserName(), "DBAPI_test");
}}
{{
CNcbiResourceInfo& info = file.GetResourceInfo_NC(app_name + "/other_user@other_server:other_db", "other_passwd");
info.SetValue("some_passwd");
TExtraMap& extra = info.GetExtraValues_NC().GetPairs();
extra.insert(TExtraPair("username", "some_user"));
extra.insert(TExtraPair("server", "some_server"));
extra.insert(TExtraPair("database", ""));
file.SaveFile();
CDBDefaultConnParams params("other_server", "other_user", "other_passwd");
params.SetDatabaseName("other_db");
params.SetDriverName(GetArgs().GetDriverName());
IDataSource* ds = GetDM().MakeDs(params);
auto_ptr<IConnection> conn(ds->CreateConnection(eTakeOwnership));
conn->Connect(params);
auto_ptr<IStatement> auto_stmt(conn->GetStatement());
auto_stmt->ExecuteUpdate("SELECT @@version");
BOOST_CHECK_EQUAL(conn->GetDatabase(), "");
BOOST_CHECK_EQUAL(conn->GetCDB_Connection()->Password(), "allowed");
BOOST_CHECK_EQUAL(conn->GetCDB_Connection()->ServerName(), "MSDEV1");
BOOST_CHECK_EQUAL(conn->GetCDB_Connection()->UserName(), "DBAPI_test");
}}
}
catch (CException& ex) {
BOOST_ERROR(ex.what());
}
TDbapi_ConnUseEncryptData::SetDefault(false);
}
END_NCBI_SCOPE
|
20d8147152d63f87130e58cb081da90c0e282b89 | 9f7bc8df3f30f2ec31581d6d2eca06e332aa15b4 | /c++/Win32/MFC/BrowseFor/BrowseForMachine.cpp | 9e584b7869a0bd72e99b1452f14c87c9146caa3b | [
"MIT"
] | permissive | moodboom/Reusable | 58f518b5b81facb862bbb36015aaa00adc710e0e | 5e0a4a85834533cf3ec5bec52cd6c5b0d60df8e8 | refs/heads/master | 2023-08-22T20:06:18.210680 | 2023-08-05T20:08:36 | 2023-08-05T20:08:36 | 50,254,274 | 3 | 3 | MIT | 2023-07-12T17:29:42 | 2016-01-23T19:23:01 | C++ | WINDOWS-1252 | C++ | false | false | 1,297 | cpp | BrowseForMachine.cpp | //-------------------------------------------------------------------//
// BrowseForMachine
//
// This class provides a wrapper around SHBrowseForFolder(). That
// base in turn is used here to browse a machine.
//
// See BrowseForHelpers.*, which contains functions that you can drop
// right into your code.
//
// Copyright © 2001 A better Software.
//-------------------------------------------------------------------//
#include "stdafx.h"
#include "BrowseForMachine.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//-------------------------------------------------------------------//
// BrowseForMachine() //
//-------------------------------------------------------------------//
BrowseForMachine::BrowseForMachine(
const CString* pstrTitle,
const CWnd* pParent,
const LPITEMIDLIST pidl
) :
// Call base class.
SHBrowseWrapper(
pParent,
pidl,
pstrTitle
)
// Init vars.
{
// Set flags to browse for a machine.
SetFlags( BIF_BROWSEFORCOMPUTER | BIF_STATUSTEXT );
}
//-------------------------------------------------------------------//
// ~BrowseForMachine() //
//-------------------------------------------------------------------//
BrowseForMachine::~BrowseForMachine()
{
}
|
1e59fce1ec7e65ed006a0b42a78e6a6d18368558 | 1e59d40a86cf6d7f6b92f5e002dc21387656aec0 | /JfF/CODE-JfF-B/dev/無題30.cpp | da95079702fc21777eb9864f09401d19bf69017d | [] | no_license | Soplia/Codes | 7bb0aecfec57d8bacb33bd1765038d0cffc19e54 | 3704f55b060877f61647b7a0fcf3d2eefe7fa47e | refs/heads/master | 2020-04-20T14:06:36.386774 | 2019-02-02T23:37:21 | 2019-02-02T23:37:21 | 168,888,217 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 336 | cpp | 無題30.cpp | #include <stdio.h>
#include <assert.h>
#define N 100
char *myCpy(char *a,char *b)
{
assert(a!=NULL&&b!=NULL);
char *c=a;
while(*a++=*b++);
return c;
}
int main()
{
char a[N],b[N];
while(gets(a))
{
int i,j;
for(i=0,j=0;a[i]!=0;i++)
{
b[j++]=a[i];
b[j++]=' ';
}
b[j]=0;
puts(b);
}
}
|
75fd5f0626e4e1631b897d2eb6dba8fea511bfe6 | 581de60cd87c869f2cab5f0e9599d449aef53275 | /Coding_Helper/Coding_HelperDlg.cpp | 82addbf0634acbb7fa63b04731ab161038513b18 | [] | no_license | wlgns5721/CodingHelper | c8a54a165d4a73047febef8cdeb159aea2a3045a | 2b7274b0f42f6265da0f58864c8b4be16cb9526d | refs/heads/master | 2020-12-02T06:39:05.030405 | 2017-07-11T08:30:37 | 2017-07-11T08:30:37 | 96,870,252 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 10,592 | cpp | Coding_HelperDlg.cpp |
// Coding_HelperDlg.cpp : 구현 파일
//
#include "stdafx.h"
#include "Coding_Helper.h"
#include "Coding_HelperDlg.h"
#include "afxdialogex.h"
#include <string>
using namespace std;
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// 응용 프로그램 정보에 사용되는 CAboutDlg 대화 상자입니다.
class CAboutDlg : public CDialogEx
{
public:
CAboutDlg();
// 대화 상자 데이터입니다.
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_ABOUTBOX };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
// 구현입니다.
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()
// CCoding_HelperDlg 대화 상자
CCoding_HelperDlg::CCoding_HelperDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_CODING_HELPER_DIALOG, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pwndShow = NULL;
}
void CCoding_HelperDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TAB1, m_tab);
}
BEGIN_MESSAGE_MAP(CCoding_HelperDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_MESSAGE(MAKE_TRAY_MESSAGE, OnTrayNotification)
ON_COMMAND(ACTIVE_MESSAGE, OnActiveDialog)
ON_COMMAND(EXIT_MESSAGE, OnExitDialog)
// ON_NOTIFY(TCN_SELCHANGING, IDC_TAB1, &CCoding_HelperDlg::OnTcnSelchangingTab1)
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, &CCoding_HelperDlg::OnTcnSelchangeTab1)
END_MESSAGE_MAP()
// CCoding_HelperDlg 메시지 처리기
BOOL CCoding_HelperDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
CString tabOne = _T("매크로");
CString tabTwo = _T("사전");
CString tabThree = _T("빠른 실행");
CString tabFour = _T("변환");
m_tab.InsertItem(0, tabOne);
m_tab.InsertItem(1, tabTwo);
m_tab.InsertItem(2, tabThree);
m_tab.InsertItem(3, tabFour);
m_tab.SetCurSel(0);
// 시스템 메뉴에 "정보..." 메뉴 항목을 추가합니다.
// IDM_ABOUTBOX는 시스템 명령 범위에 있어야 합니다.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
ASSERT(bNameValid);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// 이 대화 상자의 아이콘을 설정합니다. 응용 프로그램의 주 창이 대화 상자가 아닐 경우에는
// 프레임워크가 이 작업을 자동으로 수행합니다.
SetIcon(m_hIcon, TRUE); // 큰 아이콘을 설정합니다.
SetIcon(m_hIcon, FALSE); // 작은 아이콘을 설정합니다.
// TODO: 여기에 추가 초기화 작업을 추가합니다.
CRect rect;
m_tab.GetClientRect(&rect);
m_one.Create(IDD_SUB1, &m_tab);
m_one.SetWindowPos(NULL, 5, 25, rect.Width() - 10, rect.Height() - 30, SWP_SHOWWINDOW );
m_pwndShow = &m_one;
m_two.Create(IDD_SUB2, &m_tab);
m_two.SetWindowPos(NULL, 5, 25, rect.Width() - 10, rect.Height() - 30, SWP_HIDEWINDOW);
m_three.Create(IDD_SUB3, &m_tab);
m_three.SetWindowPos(NULL, 5, 25, rect.Width() - 10, rect.Height() - 30, SWP_HIDEWINDOW);
m_four.Create(IDD_SUB4, &m_tab);
m_four.SetWindowPos(NULL, 5, 25, rect.Width() - 10, rect.Height() - 30, SWP_HIDEWINDOW);
m_one.ShowWindow(SW_SHOW);
SetDlgItemText(IDC_BTN_MSG, L"Update");
m_one.UpdateMacro();
CWinThread *pCheckFlagThread = AfxBeginThread(CheckFlagThread, this);
CloseHandle(pCheckFlagThread);
//모든 프로세스에 후킹을 거는 글로벌 후킹 수행
HookingManager hookingManager;
hookingManager.MessageHooking();
//트레이 아이콘 생성
if (!MakeTrayIcon()) {
AfxMessageBox(L"create tray icon failed");
}
return TRUE; // 포커스를 컨트롤에 설정하지 않으면 TRUE를 반환합니다.
}
void CCoding_HelperDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else if (nID == SC_CLOSE) {
ShowWindow(SW_HIDE);
}
else
{
CDialogEx::OnSysCommand(nID, lParam);
}
}
// 대화 상자에 최소화 단추를 추가할 경우 아이콘을 그리려면
// 아래 코드가 필요합니다. 문서/뷰 모델을 사용하는 MFC 응용 프로그램의 경우에는
// 프레임워크에서 이 작업을 자동으로 수행합니다.
void CCoding_HelperDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // 그리기를 위한 디바이스 컨텍스트입니다.
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// 클라이언트 사각형에서 아이콘을 가운데에 맞춥니다.
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// 아이콘을 그립니다.
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialogEx::OnPaint();
}
}
// 사용자가 최소화된 창을 끄는 동안에 커서가 표시되도록 시스템에서
// 이 함수를 호출합니다.
HCURSOR CCoding_HelperDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
BOOL CCoding_HelperDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
if (pMsg->message == WM_KEYDOWN && (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE))
return TRUE;
/*
else if (pMsg->message == WM_SYSKEYDOWN) { //ALT + 화살표 키를 눌렀을 때 다른 탭으로 넘어간다.
int nIndex;
if(pMsg->wParam==0x27)
nIndex = (m_tab.GetCurSel() + 1) % 4; //오른쪽 탭으로 넘어간다.
else if(pMsg->wParam == 0x25)
nIndex = (m_tab.GetCurSel() - 1) % 4; // 왼쪽 탭으로 넘어간다.
else
return CDialogEx::PreTranslateMessage(pMsg);
switch (nIndex) {
case 0:
m_one.ShowWindow(SW_SHOW);
m_pwndShow = &m_one;
break;
case 1:
m_two.ShowWindow(SW_SHOW);
m_pwndShow = &m_two;
break;
case 2:
m_three.ShowWindow(SW_SHOW);
m_pwndShow = &m_three;
break;
case 3:
m_four.ShowWindow(SW_SHOW);
m_pwndShow = &m_four;
break;
}
Invalidate();
return TRUE;
}*/
return CDialogEx::PreTranslateMessage(pMsg);
}
BOOL CCoding_HelperDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
return CDialogEx::OnCommand(wParam, lParam);
}
void CCoding_HelperDlg::OnTcnSelchangeTab1(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: 여기에 컨트롤 알림 처리기 코드를 추가합니다.
*pResult = 0;
if (m_pwndShow != NULL) {
m_pwndShow->ShowWindow(SW_HIDE);
m_pwndShow = NULL;
}
int nIndex = m_tab.GetCurSel();
switch (nIndex) {
case 0:
m_one.ShowWindow(SW_SHOW);
m_pwndShow = &m_one;
break;
case 1:
m_two.ShowWindow(SW_SHOW);
m_pwndShow = &m_two;
break;
case 2:
m_three.ShowWindow(SW_SHOW);
m_pwndShow = &m_three;
break;
case 3:
m_four.ShowWindow(SW_SHOW);
m_pwndShow = &m_four;
break;
}
}
LRESULT CCoding_HelperDlg::OnTrayNotification(WPARAM wParam, LPARAM lParam) {
switch (lParam) {
case WM_LBUTTONDOWN: {
ShowWindow(SW_SHOW);
SetForegroundWindow(); //최상위로
break;
}
case WM_RBUTTONDOWN: {
POINT pos;
GetCursorPos(&pos);
trayIconManager.MakePopUpMenu(GetSafeHwnd(),pos.x,pos.y);
break;
}
}
return 1;
}
void CCoding_HelperDlg::OnActiveDialog() {
ShowWindow(SW_SHOW);
SetForegroundWindow(); //최상위로
}
void CCoding_HelperDlg::OnExitDialog() {
NOTIFYICONDATA nid;
//tray icon을 지운다.
ZeroMemory(&nid, sizeof(NOTIFYICONDATA));
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = GetSafeHwnd();
nid.uFlags = NULL;
Shell_NotifyIcon(NIM_DELETE, &nid);
CDialog::OnCancel();
}
bool CCoding_HelperDlg::MakeTrayIcon() {
//트레이 아이콘 생성
NOTIFYICONDATA nid;
ZeroMemory(&nid, sizeof(nid));
nid.cbSize = sizeof(nid);
nid.uID = 0;
nid.hWnd = GetSafeHwnd();
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
nid.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
lstrcpy(nid.szTip, L"coding helper");
nid.uCallbackMessage = MAKE_TRAY_MESSAGE;
bool bRet = ::Shell_NotifyIcon(NIM_ADD, &nid); //tray icon 등록
return bRet;
}
UINT CCoding_HelperDlg::CheckFlagThread(LPVOID lParam) {
CCoding_HelperDlg* pCodingDlg = (CCoding_HelperDlg*)lParam;
MacroStruct* pMacroStruct = pCodingDlg->m_one.pMacroStruct;
HANDLE hOpenMemoryMap;
LPBYTE pOpenMemoryMap;
HookingManager hookingManager;
while (1) {
Sleep(50);
if (pMacroStruct->isPressButton == true) {
pMacroStruct->isPressButton = false;
hOpenMemoryMap = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE, NULL, L"clipboard");
pOpenMemoryMap = (LPBYTE)MapViewOfFile(hOpenMemoryMap, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (pMacroStruct->convertSwitch == true) {
pMacroStruct->convertSwitch = false;
int index = pMacroStruct->convert_index;
hookingManager.ConvertText(wcslen(pCodingDlg->m_four.convertStruct.origin_array[index]));
}
else
hookingManager.PasteClipboardText();
Sleep(100);
int dataLength = wcslen((TCHAR*)pOpenMemoryMap);
TCHAR* clipboardData = (TCHAR*)pOpenMemoryMap;
hookingManager.CopyToClipboard(clipboardData, wcslen(clipboardData));
}
else if (pMacroStruct->activateSwitch == true) {
pMacroStruct->activateSwitch = false;
CCoding_HelperDlg *pDlg = (CCoding_HelperDlg*)AfxGetMainWnd(); //static function에서 클래스 멤버 function을 호출하려면 이렇게 해야 함
pDlg->ShowWindow(SW_SHOW);
//최상위 윈도우로 설정하기. 현재 활성화된 윈도우의 쓰레드에 현재 쓰레드를 attach시켜놓아야 함
HWND hWndForeground = ::GetForegroundWindow();
HWND hWnd = pDlg->GetSafeHwnd();
DWORD Strange = ::GetWindowThreadProcessId(hWndForeground, NULL);
DWORD My = ::GetWindowThreadProcessId(pDlg->GetSafeHwnd(), NULL);
if (!::AttachThreadInput(Strange, My, TRUE))
continue;
//::SetForegroundWindow(hWnd);
::BringWindowToTop(hWnd);
if (!::AttachThreadInput(Strange, My, FALSE))
continue;
pDlg->SetForegroundWindow();
}
else if (pMacroStruct->executeSwitch == true) {
pMacroStruct->executeSwitch = false;
pCodingDlg->m_three.ExecuteFile(pMacroStruct->execute_index);
}
}
return 0;
}
|
a5dace06fb7aefbd8af1508b8aa6d244a1773652 | 33d33eb0a459f8fd5f3fbd5f3e2ff95cbb804f64 | /405.convert-a-number-to-hexadecimal.113192217.ac.cpp | 3280a16e6ecc41509738eb70c0a6d13a51c9a4c2 | [] | no_license | wszk1992/LeetCode-Survival-Notes | 7b4b7c9b1a5b7251b8053111510e2cefa06a0390 | 01f01330964f5c2269116038d0dde0370576f1e4 | refs/heads/master | 2021-01-01T17:59:32.945290 | 2017-09-15T17:57:40 | 2017-09-15T17:57:40 | 98,215,658 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 366 | cpp | 405.convert-a-number-to-hexadecimal.113192217.ac.cpp | class Solution {
public:
string toHex(int num) {
string hex;
for(int i = 0; i < 8 && num; i++) {
// cout << bitset<32>(num) << endl;
hex += (num & 15) < 10 ? (num & 15) + '0' : (num & 15) - 10 + 'a';
num >>= 4;
}
reverse(hex.begin(), hex.end());
return hex.empty() ? "0" : hex;
}
}; |
10e991b1afed9b7f24810cf3ee52bbf1525d2958 | 93343c49771b6e6f2952d03df7e62e6a4ea063bb | /HDOJ/4593_autoAC.cpp | f840f989461ca27330c3789337ec5eb97153cb19 | [] | no_license | Kiritow/OJ-Problems-Source | 5aab2c57ab5df01a520073462f5de48ad7cb5b22 | 1be36799dda7d0e60bd00448f3906b69e7c79b26 | refs/heads/master | 2022-10-21T08:55:45.581935 | 2022-09-24T06:13:47 | 2022-09-24T06:13:47 | 55,874,477 | 36 | 9 | null | 2018-07-07T00:03:15 | 2016-04-10T01:06:42 | C++ | UTF-8 | C++ | false | false | 552 | cpp | 4593_autoAC.cpp | #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 10010;
int cnt[maxn];
int main()
{
int n;
while(scanf("%d", &n) == 1)
{
memset(cnt, 0, sizeof(cnt));
int ans = -1;
for(int i = 0; i < n+1; i++)
{
int tmp;
scanf("%d", &tmp);
cnt[tmp]++;
if(cnt[tmp] >= 2)
ans = tmp;
}
printf("%d\n", ans);
}
}
|
8643539bbb9db1c5b87c935956d3e3d645e26b19 | 9c760347d5960359f1c6fae7e0c62c111e7b2703 | /topcoder/srm/601/WinterAndSnowmen.cpp | fa384f38f77de1240b5676233c4347494781aa91 | [] | no_license | md143rbh7f/competitions | 1bcfc6886c32649f8bb939f329536cec51542bb1 | f241ace5a4d098fb66519b0c2eed6c45ebf212b9 | refs/heads/master | 2020-04-06T07:12:36.891182 | 2019-01-18T04:04:16 | 2019-01-18T07:23:23 | 12,464,538 | 8 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 936 | cpp | WinterAndSnowmen.cpp | #include <algorithm>
#include <cstring>
using namespace std;
typedef long long ll;
#define range(i,a,b) for(auto i=(a);i<b;i++)
#define rep(i,n) range(i,0,n)
#define CLR(i,x) memset(i,x,sizeof(i))
#define clr(i) CLR(i,0)
#define M(x) ((x)%MOD)
#define B 11
#define MOD 1000000007
ll x[1<<B][2][2], y[1<<B][2][2];
int n, m, k;
int solve(int b)
{
clr(x);
x[0][0][0] = 1;
int p = 1<<(B - b - 1);
range(i, 1, k)
{
int i0 = i >> (b + 1), i1 = (i >> b) & 1;
rep(j, p) rep(u, 2) rep(v, 2)
{
if(i <= n) y[j^i0][u^i1][v] = M(y[j^i0][u^i1][v] + x[j][u][v]);
if(i <= m) y[j^i0][u][v^i1] = M(y[j^i0][u][v^i1] + x[j][u][v]);
}
rep(j, p) rep(u, 2) rep(v, 2)
{
x[j][u][v] = M(x[j][u][v] + y[j][u][v]);
y[j][u][v] = 0;
}
}
return x[0][0][1];
}
struct WinterAndSnowmen
{
int getNumber(int _n, int _m)
{
n = _n, m = _m, k = max(n, m) + 1;
int ans = 0;
rep(b, B) ans = M(ans + solve(b));
return ans;
}
};
|
490553fe94723548f88f18ba7a915632aa00be1f | 739529d468a861382ad670fee8cd25da3399da06 | /source/crazygaze/muc/Semaphore.cpp | e67ae8a93279fc5d95e2c468716a407160e50f98 | [
"MIT"
] | permissive | ruifig/czmuc | f63c2b2d9573d176a792dab3b58b6f13f74f5155 | c05eb3609a915f7791ffd43dc1f6d2c7d7d8569f | refs/heads/master | 2023-04-10T13:33:10.164362 | 2023-03-27T18:08:24 | 2023-03-27T18:08:24 | 94,771,414 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,210 | cpp | Semaphore.cpp | /********************************************************************
CrazyGaze (http://www.crazygaze.com)
Author : Rui Figueira
Email : rui@crazygaze.com
purpose:
*********************************************************************/
#include "czmucPCH.h"
#include "crazygaze/muc/Semaphore.h"
namespace cz
{
void cz::Semaphore::notify()
{
std::unique_lock<std::mutex> lock(m_mtx);
m_count++;
m_cv.notify_one();
}
void cz::Semaphore::wait()
{
std::unique_lock<std::mutex> lock(m_mtx);
m_cv.wait(lock, [this]() {return m_count > 0; });
m_count--;
}
bool cz::Semaphore::trywait()
{
std::unique_lock<std::mutex> lock(m_mtx);
if (m_count)
{
m_count--;
return true;
}
else
{
return false;
}
}
void ZeroSemaphore::increment()
{
std::unique_lock<std::mutex> lock(m_mtx);
m_count++;
}
void ZeroSemaphore::decrement()
{
std::unique_lock<std::mutex> lock(m_mtx);
m_count--;
m_cv.notify_all();
}
void ZeroSemaphore::wait()
{
std::unique_lock<std::mutex> lock(m_mtx);
m_cv.wait(lock, [this]()
{
return m_count == 0;
});
}
bool ZeroSemaphore::trywait()
{
std::unique_lock<std::mutex> lock(m_mtx);
if (m_count == 0)
return true;
else
return false;
}
} // namespace cz
|
c8fd4004b74c42708d5d9bfbe09017b06228683c | b39b0652150a981c9e08d63b78a5b8d57197601e | /doom_py/src/lib/boost/process/windows/executor.hpp | 1560f30793da690a92d67b3b421a72ff37abbc67 | [
"MIT"
] | permissive | jaekyeom/doom-py | 476026afd7dad6ecd47cf2633c745e3b09fa5c9c | a7d08a0f2e92b0ba4be538e182791be4c5a11a1b | refs/heads/master | 2020-03-06T18:52:38.651857 | 2018-04-05T14:28:14 | 2018-04-05T14:28:14 | 127,015,715 | 1 | 0 | MIT | 2018-03-27T16:29:10 | 2018-03-27T16:29:10 | null | UTF-8 | C++ | false | false | 3,370 | hpp | executor.hpp | // Copyright (c) 2006, 2007 Julio M. Merino Vidal
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
// Copyright (c) 2009 Boris Schaeling
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROCESS_WINDOWS_EXECUTOR_HPP
#define BOOST_PROCESS_WINDOWS_EXECUTOR_HPP
#include <boost/process/windows/child.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <Windows.h>
namespace boost { namespace process { namespace windows {
struct executor
{
executor() : exe(0), cmd_line(0), proc_attrs(0), thread_attrs(0),
inherit_handles(FALSE),
#if (_WIN32_WINNT >= 0x0600)
creation_flags(EXTENDED_STARTUPINFO_PRESENT),
#else
creation_flags(0),
#endif
env(0), work_dir(0)
#if (_WIN32_WINNT >= 0x0600)
,startup_info(startup_info_ex.StartupInfo)
#endif
{
#if (_WIN32_WINNT >= 0x0600)
ZeroMemory(&startup_info_ex, sizeof(STARTUPINFOEX));
startup_info.cb = sizeof(STARTUPINFOEX);
#else
ZeroMemory(&startup_info, sizeof(STARTUPINFO));
startup_info.cb = sizeof(STARTUPINFO);
#endif
startup_info.hStdInput = INVALID_HANDLE_VALUE;
startup_info.hStdOutput = INVALID_HANDLE_VALUE;
startup_info.hStdError = INVALID_HANDLE_VALUE;
}
struct call_on_CreateProcess_setup
{
executor &e_;
call_on_CreateProcess_setup(executor &e) : e_(e) {}
template <class Arg>
void operator()(Arg &arg) const
{
arg.on_CreateProcess_setup(e_);
}
};
struct call_on_CreateProcess_error
{
executor &e_;
call_on_CreateProcess_error(executor &e) : e_(e) {}
template <class Arg>
void operator()(Arg &arg) const
{
arg.on_CreateProcess_error(e_);
}
};
struct call_on_CreateProcess_success
{
executor &e_;
call_on_CreateProcess_success(executor &e) : e_(e) {}
template <class Arg>
void operator()(Arg &arg) const
{
arg.on_CreateProcess_success(e_);
}
};
template <class InitializerSequence>
child operator()(const InitializerSequence &seq)
{
boost::fusion::for_each(seq, call_on_CreateProcess_setup(*this));
if (!::CreateProcess(
exe,
cmd_line,
proc_attrs,
thread_attrs,
inherit_handles,
creation_flags,
env,
work_dir,
&startup_info,
&proc_info))
{
boost::fusion::for_each(seq, call_on_CreateProcess_error(*this));
}
else
{
boost::fusion::for_each(seq, call_on_CreateProcess_success(*this));
}
return child(proc_info);
}
LPCTSTR exe;
LPTSTR cmd_line;
LPSECURITY_ATTRIBUTES proc_attrs;
LPSECURITY_ATTRIBUTES thread_attrs;
BOOL inherit_handles;
DWORD creation_flags;
LPVOID env;
LPCTSTR work_dir;
#if (_WIN32_WINNT >= 0x0600)
STARTUPINFOEX startup_info_ex;
STARTUPINFO &startup_info;
#else
STARTUPINFO startup_info;
#endif
PROCESS_INFORMATION proc_info;
};
}}}
#endif
|
3f2032171a5184659bc5e7c8ef9f5e788e77ccb4 | dd6147bf9433298a64bbceb7fdccaa4cc477fba6 | /8383/Babenko/OOP/GameUI/Requests/MoveUnitRequest.h | 06cf6d64b812a74af869366d725d7914662844e7 | [] | no_license | moevm/oop | 64a89677879341a3e8e91ba6d719ab598dcabb49 | faffa7e14003b13c658ccf8853d6189b51ee30e6 | refs/heads/master | 2023-03-16T15:48:35.226647 | 2020-06-08T16:16:31 | 2020-06-08T16:16:31 | 85,785,460 | 42 | 304 | null | 2023-03-06T23:46:08 | 2017-03-22T04:37:01 | C++ | UTF-8 | C++ | false | false | 1,526 | h | MoveUnitRequest.h | #ifndef LAB2_OOP_MOVEUNITREQUEST_H
#define LAB2_OOP_MOVEUNITREQUEST_H
#include "Request.h"
class MoveUnitRequest : public Request {
private:
Point from;
Point to;
public:
MoveUnitRequest(Point from, Point to) : from(from), to(to) {}
void execute(GameInfo &gameInfo) override {
auto object = gameInfo.getField().getCell(from)->getObject();
if (object && object->getType() == ObjectType::UNIT) {
auto unit = dynamic_cast<Unit *>(object);
game::log << "[Game] Obtained unit movement request" << game::logend;
unit->move(to);
} else
game::log << "[Game] No unit is placed on this cell" << game::logend;
}
RequestMemento * getMemento() const override {
std::stringstream stream;
stream << "move unit " << from.x << " " << from.y << " " << to.x << " " << to.y << std::endl;
return new RequestMemento(stream.str());
}
};
class MoveUnitRequestHandler : public RequestHandler {
public:
bool canHandle(std::vector<std::string> &cmd) override {
return cmd.size() == 5 && cmd[0] == "unit";
}
RequestPtr handle(std::vector<std::string> &cmd) override {
if (canHandle(cmd)) {
int x1 = std::stoi(cmd[1]);
int y1 = std::stoi(cmd[2]);
int x2 = std::stoi(cmd[3]);
int y2 = std::stoi(cmd[4]);
Point from(x1, y1);
Point to(x2, y2);
return RequestPtr(new MoveUnitRequest(from, to));
}
if (next)
return next->handle(cmd);
return std::make_unique<Request>();
}
};
#endif //LAB2_OOP_MOVEUNITREQUEST_H
|
e4d77cdfab21456d2588767791511c7c8ae74e74 | 1b5c69d3d3c8c5dc4de9735b93a4d91ca7642a42 | /icpc/icpc2012b.cpp | 9f264b91593a9b5e6596b84b95a6c97d8516659a | [] | no_license | ritsuxis/kyoupro | 19059ce166d2c35f643ce52aeb13663c1acece06 | ce0a4aa0c18e19e038f29d1db586258970b35b2b | refs/heads/master | 2022-12-23T08:25:51.282513 | 2020-10-02T12:43:16 | 2020-10-02T12:43:16 | 232,855,372 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,287 | cpp | icpc2012b.cpp | #include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;
// string から int にする関数
int to_int(string a, int b){
int ans = 0;
REP(i, b){
ans += a[i] * pow(10, b - i - 1);
}
return ans;
}
int main(void){
while(true){
int aInt, b; cin >> aInt >> b;
if(aInt == 0 and b == 0) return 0;
else{
vector<int> Num(0);
Num.push_back(aInt); // 初めのぶんも追加しておかないといけない
string a = to_string(aInt);
bool find = false;
if(a.size() < b) while(a.size() != b) a.push_back('0'); // 桁数合わせ
while (true){
if(a.size() < b) while(a.size() != b) a.push_back('0'); // 桁数合わせ
whole(sort, a); // 辞書順でソートすると勝手に最小になってくれる
string aMinStr = a; // わざわざ変数入れるまででもないけどわかりやすいように
int aMin = to_int(aMinStr, b);
whole(sort, a, greater<>()); // 逆すると最大になる
string aMaxStr = a;
int aMax = to_int(aMaxStr, b);
int ans = aMax - aMin; // 保存される値
int findNum; // 見つかりました?
for(int i = 0; i <= Num.size() - 1; i++){
if(ans == Num[i]){
find = true;
findNum = i; // 見つかったときの値を覚えておかなくちゃ
}
}
if(find){
cout << findNum << " " << Num[findNum] << " " << Num.size() - findNum << endl;
break;
}
else{
Num.push_back(ans);
a = to_string(ans);
}
}
}
}
} |
41d2edd2431aca2a28ff203b1dbc2e751a3a1db2 | e753f8ab10eb6732f272217169e48ab4754295ee | /math/moab/files/patch-src_io_WriteNCDF.cpp | 8c91cad073bbef3a70f0dfbf83265d71592300d2 | [
"BSD-2-Clause"
] | permissive | DragonFlyBSD/DPorts | dd2e68f0c11a5359bf1b3e456ab21cbcd9529e1c | 4b77fb40db21fdbd8de66d1a2756ac1aad04d505 | refs/heads/master | 2023-08-12T13:54:46.709702 | 2023-07-28T09:53:12 | 2023-07-28T09:53:12 | 6,439,865 | 78 | 52 | NOASSERTION | 2023-09-02T06:27:16 | 2012-10-29T11:59:35 | null | UTF-8 | C++ | false | false | 442 | cpp | patch-src_io_WriteNCDF.cpp | --- src/io/WriteNCDF.cpp.orig 2018-11-23 06:26:09 UTC
+++ src/io/WriteNCDF.cpp
@@ -161,8 +161,8 @@ void WriteNCDF::time_and_date(char* time
strftime(date_string, TIME_STR_LEN, "%m/%d/%Y", local_time);
// Terminate with NULL character
- time_string[10] = (char)NULL;
- date_string[10] = (char)NULL;
+ time_string[10] = (char)0;
+ date_string[10] = (char)0;
}
ErrorCode WriteNCDF::write_file(const char *exodus_file_name,
|
de41ee64654255c424b8f69956c6176c8e0e2018 | bf1d5617e91b97c663394fb04f8ed38c4a05cb40 | /Power.CPP | df3125ad3958a5ce62ff444e25efbc207c3f77db | [] | no_license | devanshpahuja/codingninjasDSA | 3d16d4bc3405a07012e8c11aa1909fe6dcc1df06 | c1cab36eac2c2463174590ac0483d4f679dbeaa4 | refs/heads/main | 2022-12-30T01:51:41.598046 | 2020-10-19T12:50:08 | 2020-10-19T12:50:08 | 305,376,420 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 101 | cpp | Power.CPP | int power(int x, int n)
{int output;
if(n==0)
{
return 1;
}
output= x*power(x,n-1);
}
|
2197a911ba5fad7efea536bc60b73d380ac9f8b8 | 75ae9060b7e2f3abe537e77f43d765897dae0a48 | /source/physics/rigidbody/common/worldvolume.h | 6f38f8821375d3808fd13e4246dca7e3df4bac8b | [] | no_license | shagkur/irrlichtPS3 | edfacf2a22ad13065977dba26bc9c926bcdd4035 | e6e296420aeb79c63e796891912abb94ac90739f | refs/heads/master | 2022-11-24T03:25:46.546042 | 2020-07-20T06:38:27 | 2020-07-20T06:38:27 | 280,178,725 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,061 | h | worldvolume.h | /*
* worldvolume.h
*
* Created on: Jun 2, 2013
* Author: mike
*/
#ifndef WORLDVOLUME_H_
#define WORLDVOLUME_H_
#include "base/common.h"
#include "base/vecint3.h"
ATTRIBUTE_ALIGNED16(class) WorldVolume {
public:
Vector3 origin;
Vector3 extent;
inline void setWorldSize(const Vector3& origin_, const Vector3& extent_);
inline Vector3 localToWorldPosition(const VecInt3& localPosition);
inline VecInt3 worldToLocalPosition(const Vector3& worldPosition);
inline void worldToLocalPosition(const Vector3& worldMinPosition, const Vector3& worldMaxPosition, VecInt3& localMinPosition, VecInt3& localMaxPosition);
};
inline void WorldVolume::setWorldSize(const Vector3& origin_, const Vector3& extent_)
{
origin = origin_;
extent = extent_;
}
inline Vector3 WorldVolume::localToWorldPosition(const VecInt3& localPosition)
{
const Vector3 sz(65535.0f);
Vector3 q = divPerElem((Vector3)localPosition, sz);
return mulPerElem(q, 2.0f*extent) + origin - extent;
}
inline VecInt3 WorldVolume::worldToLocalPosition(const Vector3& worldPosition)
{
const Vector3 sz(65535.0f);
Vector3 q = divPerElem(worldPosition - origin + extent, 2.0f*extent);
q = minPerElem(maxPerElem(q, Vector3(0.0f)), Vector3(1.0f)); // clamp 0.0 - 1.0
q = mulPerElem(q, sz);
return VecInt3(q);
}
inline void WorldVolume::worldToLocalPosition(const Vector3& worldMinPosition, const Vector3& worldMaxPosition, VecInt3& localMinPosition, VecInt3& localMaxPosition)
{
const Vector3 sz(65535.0f);
Vector3 qmin = divPerElem(worldMinPosition - origin + extent, 2.0f*extent);
qmin = minPerElem(maxPerElem(qmin, Vector3(0.0f)), Vector3(1.0f)); // clamp 0.0 - 1.0
qmin = mulPerElem(qmin, sz);
Vector3 qmax = divPerElem(worldMaxPosition - origin + extent, 2.0f*extent);
qmax = minPerElem(maxPerElem(qmax, Vector3(0.0f)), Vector3(1.0f)); // clamp 0.0 - 1.0
qmax = mulPerElem(qmax, sz);
localMinPosition = VecInt3(floorf(qmin[0]), floorf(qmin[1]), floorf(qmin[2]));
localMaxPosition = VecInt3(ceilf(qmax[0]), ceilf(qmax[1]), ceilf(qmax[2]));
}
#endif /* WORLDVOLUME_H_ */
|
aabb3bfc066e6fe9204dcbb66758296c8fbd0987 | ff0e1f54c9edf6fd56c69809ad9bd0ba47f8dc56 | /Tema03-Sobrecarga_Operadores/Ejemplos/ejemplo4.cpp | 3ca7eb2d4aa10f1e0500f79b25f6cb2ea0c4ca95 | [] | no_license | BitzerAr/Acecom | db83b4818685be58dce79aa33d3355c9fc02ff67 | 43653547691cc937e870001f10fcb75d4a1df806 | refs/heads/master | 2021-06-24T22:53:43.018214 | 2017-08-25T16:38:28 | 2017-08-25T16:38:28 | 92,451,605 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 872 | cpp | ejemplo4.cpp | //Ejemplo sobrecarga operadores unitarios
#include <iostream>
using namespace std;
class Punto{
private :
double m_x, m_y, m_z;
public :
Punto(double x = 0.0, double y = 0.0, double z = 0.0) : m_x(x), m_y(y), m_z(z){}
Punto operator-() const;
bool operator! () const;
double getX(){return m_x;}
double getY(){return m_x;}
double getZ(){return m_x;}
};
Punto Punto::operator- () const{
return Punto(-m_x, -m_y, -m_z);
}
bool Punto :: operator! () const{
return ( m_x == 0.0 && m_y == 0.0 && m_z == 0.0);
}
int main(){
Punto punto(1.0,2.0,3.0);
if(!punto)
cout << "Punto ubicado en el origen "<< endl;
else
cout << "No esta en el origen" << endl;
punto = -punto;
cout << punto.getX() << endl;
Punto punto1;
if(!punto1)
cout << "Punto ubicado en el origen "<< endl;
else
cout << "No esta en el origen" << endl;
return 0;
}
|
94e465d9782a225f3a69f26ee84e03bed1860012 | c000f95fd43802ba6e473881ae689c23691a538a | /unity-samples/Temp/il2cppOutput/il2cppOutput/mscorlib_System_Security_Policy_CodeGroup2846310733.h | dcae0d069cbc2ae770ad36406b82dd6613baa58f | [] | no_license | peterappboy/appboy-unity-sdk | 4c17516a49a8147dee94629c3de6c39d14cf879b | 93dfd2e29c85f0221d6cd7b17150121b0b7109c3 | refs/heads/master | 2021-01-22T18:28:50.479281 | 2016-08-04T22:04:15 | 2016-08-04T22:04:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,582 | h | mscorlib_System_Security_Policy_CodeGroup2846310733.h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
// System.Security.Policy.PolicyStatement
struct PolicyStatement_t1206202648;
// System.Security.Policy.IMembershipCondition
struct IMembershipCondition_t590969783;
// System.String
struct String_t;
// System.Collections.ArrayList
struct ArrayList_t2121638921;
// System.Collections.Generic.Dictionary`2<System.String,System.Int32>
struct Dictionary_2_t190145395;
#include "mscorlib_System_Object837106420.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Security.Policy.CodeGroup
struct CodeGroup_t2846310733 : public Il2CppObject
{
public:
// System.Security.Policy.PolicyStatement System.Security.Policy.CodeGroup::m_policy
PolicyStatement_t1206202648 * ___m_policy_0;
// System.Security.Policy.IMembershipCondition System.Security.Policy.CodeGroup::m_membershipCondition
Il2CppObject * ___m_membershipCondition_1;
// System.String System.Security.Policy.CodeGroup::m_description
String_t* ___m_description_2;
// System.String System.Security.Policy.CodeGroup::m_name
String_t* ___m_name_3;
// System.Collections.ArrayList System.Security.Policy.CodeGroup::m_children
ArrayList_t2121638921 * ___m_children_4;
public:
inline static int32_t get_offset_of_m_policy_0() { return static_cast<int32_t>(offsetof(CodeGroup_t2846310733, ___m_policy_0)); }
inline PolicyStatement_t1206202648 * get_m_policy_0() const { return ___m_policy_0; }
inline PolicyStatement_t1206202648 ** get_address_of_m_policy_0() { return &___m_policy_0; }
inline void set_m_policy_0(PolicyStatement_t1206202648 * value)
{
___m_policy_0 = value;
Il2CppCodeGenWriteBarrier(&___m_policy_0, value);
}
inline static int32_t get_offset_of_m_membershipCondition_1() { return static_cast<int32_t>(offsetof(CodeGroup_t2846310733, ___m_membershipCondition_1)); }
inline Il2CppObject * get_m_membershipCondition_1() const { return ___m_membershipCondition_1; }
inline Il2CppObject ** get_address_of_m_membershipCondition_1() { return &___m_membershipCondition_1; }
inline void set_m_membershipCondition_1(Il2CppObject * value)
{
___m_membershipCondition_1 = value;
Il2CppCodeGenWriteBarrier(&___m_membershipCondition_1, value);
}
inline static int32_t get_offset_of_m_description_2() { return static_cast<int32_t>(offsetof(CodeGroup_t2846310733, ___m_description_2)); }
inline String_t* get_m_description_2() const { return ___m_description_2; }
inline String_t** get_address_of_m_description_2() { return &___m_description_2; }
inline void set_m_description_2(String_t* value)
{
___m_description_2 = value;
Il2CppCodeGenWriteBarrier(&___m_description_2, value);
}
inline static int32_t get_offset_of_m_name_3() { return static_cast<int32_t>(offsetof(CodeGroup_t2846310733, ___m_name_3)); }
inline String_t* get_m_name_3() const { return ___m_name_3; }
inline String_t** get_address_of_m_name_3() { return &___m_name_3; }
inline void set_m_name_3(String_t* value)
{
___m_name_3 = value;
Il2CppCodeGenWriteBarrier(&___m_name_3, value);
}
inline static int32_t get_offset_of_m_children_4() { return static_cast<int32_t>(offsetof(CodeGroup_t2846310733, ___m_children_4)); }
inline ArrayList_t2121638921 * get_m_children_4() const { return ___m_children_4; }
inline ArrayList_t2121638921 ** get_address_of_m_children_4() { return &___m_children_4; }
inline void set_m_children_4(ArrayList_t2121638921 * value)
{
___m_children_4 = value;
Il2CppCodeGenWriteBarrier(&___m_children_4, value);
}
};
struct CodeGroup_t2846310733_StaticFields
{
public:
// System.Collections.Generic.Dictionary`2<System.String,System.Int32> System.Security.Policy.CodeGroup::<>f__switch$map2A
Dictionary_2_t190145395 * ___U3CU3Ef__switchU24map2A_5;
public:
inline static int32_t get_offset_of_U3CU3Ef__switchU24map2A_5() { return static_cast<int32_t>(offsetof(CodeGroup_t2846310733_StaticFields, ___U3CU3Ef__switchU24map2A_5)); }
inline Dictionary_2_t190145395 * get_U3CU3Ef__switchU24map2A_5() const { return ___U3CU3Ef__switchU24map2A_5; }
inline Dictionary_2_t190145395 ** get_address_of_U3CU3Ef__switchU24map2A_5() { return &___U3CU3Ef__switchU24map2A_5; }
inline void set_U3CU3Ef__switchU24map2A_5(Dictionary_2_t190145395 * value)
{
___U3CU3Ef__switchU24map2A_5 = value;
Il2CppCodeGenWriteBarrier(&___U3CU3Ef__switchU24map2A_5, value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
9411b3c610aae7ed87cc8df85022ca0190b8c885 | a4ace471f3a34bfe7bd9aa57470aaa6e131012a9 | /LintCode/463_Sort-Integers/463_Sort-Integers-SelectSort.cpp | 42e1e0db8c5325ef69319eea4a0db2f306e0756f | [] | no_license | luqian2017/Algorithm | 52beca787056e8418f74d383f4ea697f5f8934b7 | 17f281fb1400f165b4c5f8bdd3e0500f6c765b45 | refs/heads/master | 2023-08-17T05:37:14.886220 | 2023-08-08T06:10:28 | 2023-08-08T06:10:28 | 143,100,735 | 1 | 3 | null | 2020-10-19T07:05:21 | 2018-08-01T03:45:48 | C++ | UTF-8 | C++ | false | false | 570 | cpp | 463_Sort-Integers-SelectSort.cpp | class Solution {
public:
/**
* @param A: an integer array
* @return: nothing
*/
void sortIntegers(vector<int> &A) {
int n = A.size();
if (n == 0) return;
for (int i = 0; i < n - 1; ++i) {
int minV = A[i];
int minIndex = i;
for (int j = i + 1; j < n; ++j) {
if (minV > A[j]) {
minV = A[j];
minIndex = j;
};
}
swap(A[i], A[minIndex]);
}
return;
}
}; |
841eb629a910f4943ed52a3bbff7ec25be8ab9a7 | edb308742ea4bf7d3ae60e487c1a2a78cd8f51cd | /theoryrecord.cpp | 88f5dbe3be71c20186116b588bf3c03ad71a2917 | [] | no_license | henriqueinonhe/ProofAssistantFramework | cba1dd32527a5050add23a2daf36bed7dcbb0b48 | cbceeef3d3c1f943a5dd290afccbfa4582dd31da | refs/heads/master | 2020-03-23T06:32:27.618466 | 2019-08-09T16:40:58 | 2019-08-09T16:40:58 | 141,214,837 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 635 | cpp | theoryrecord.cpp | #include "theoryrecord.h"
#include <QDataStream>
TheoryRecord::TheoryRecord()
{
}
TheoryRecord::TheoryRecord(const QString &name, const QString &description) :
name(name),
description(description)
{
}
QString TheoryRecord::getName() const
{
return name;
}
QString TheoryRecord::getDescription() const
{
return description;
}
QDataStream &operator <<(QDataStream &stream, const TheoryRecord &record)
{
stream << record.name << record.description;
return stream;
}
QDataStream &operator >>(QDataStream &stream, TheoryRecord &record)
{
stream >> record.name >> record.description;
return stream;
}
|
be88f72cc40902b5964744d039c72c92bd83617f | 24fa8baf88e25d9afaf2670c566b48b8d0375b8e | /BeTrains/inc/view/FormLiveboard.h | 2b0f6018a082955eeb08074ea9437ce3aabca596 | [] | no_license | iRail/BeTrains.Bada | 0490fcb832f26d1ba2747cadf72e7c3bf6275875 | 6f83b587c11f8003c61826e894a7372bc909bb5f | refs/heads/master | 2016-09-10T15:05:06.758587 | 2011-10-02T18:44:47 | 2011-10-02T18:44:47 | 1,099,831 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,235 | h | FormLiveboard.h | #ifndef _FormLiveboard_H_
#define _FormLiveboard_H_
#include <FBase.h>
#include <FUi.h>
#include "HeaderForm.h"
#include "model/LiveBoardRequest.h"
#include "view/WaitingPopup.h"
class FormLiveboard :
public HeaderForm,
public Osp::Ui::ITouchEventListener,
public ITimeChangeEventListener
{
// Construction
public:
FormLiveboard(void);
virtual ~FormLiveboard(void);
bool Initialize(void);
public:
virtual result OnInitializing(void);
virtual result OnTerminating(void);
virtual void OnActionPerformed(const Osp::Ui::Control& source, int actionId);
virtual void recalculateComponents();
void RequestRedraw (bool show=true) const;
/*
* ITouchEventListeners
*/
void OnTouchDoublePressed (const Osp::Ui::Control &source, const Osp::Graphics::Point ¤tPosition, const Osp::Ui::TouchEventInfo &touchInfo);
void OnTouchFocusIn (const Osp::Ui::Control &source, const Osp::Graphics::Point ¤tPosition, const Osp::Ui::TouchEventInfo &touchInfo);
void OnTouchFocusOut (const Osp::Ui::Control &source, const Osp::Graphics::Point ¤tPosition, const Osp::Ui::TouchEventInfo &touchInfo);
void OnTouchLongPressed (const Osp::Ui::Control &source, const Osp::Graphics::Point ¤tPosition, const Osp::Ui::TouchEventInfo &touchInfo);
void OnTouchMoved (const Osp::Ui::Control &source, const Osp::Graphics::Point ¤tPosition, const Osp::Ui::TouchEventInfo &touchInfo);
void OnTouchPressed (const Osp::Ui::Control &source, const Osp::Graphics::Point ¤tPosition, const Osp::Ui::TouchEventInfo &touchInfo);
void OnTouchReleased (const Osp::Ui::Control &source, const Osp::Graphics::Point ¤tPosition, const Osp::Ui::TouchEventInfo &touchInfo);
void OnTimeChanged(const Osp::Ui::Control& source, int hour, int minute);
void OnTimeChangeCanceled(const Osp::Ui::Control& source);
/*
* Action id's
*/
static const int SEARCH_ACTION = 301;
static const int CLEAR_ACTION = 302;
private:
/*
* Data
*/
LiveBoardRequest* liveBoardRequest;
/*
* Controls
*/
Osp::Ui::Controls::EditField* stationEditField;
Osp::Ui::Controls::EditTime* editTime;
Popup* waitingPopup;
/*
* methods
*/
void assembleComponents();
};
#endif //_FormLiveboard_H_
|
bcb5b5d45b1479ba61a538499f2a238a78e70e9e | f896ba1ef7f9f409a769fe0ee19643d7a8b5dd5a | /ZReportWizard.cpp | 7e4495aad3eed5ee0a48c80518ec8260f9bf7df3 | [] | no_license | sergshloyda/UserThreads | 11c541128b07e61035ee2475a86189fabf25daad | 861b847436740f97e138e26fe04a3b37e328add4 | refs/heads/master | 2022-08-25T14:05:08.873686 | 2020-05-19T23:57:07 | 2020-05-19T23:57:07 | 263,369,921 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,042 | cpp | ZReportWizard.cpp | // ZReportWizard.cpp : implementation file
//
#include "stdafx.h"
#include "userthreads.h"
#include "ZReportWizard.h"
#include "ZReportView.h"
#include "SalaryDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZReportWizard
extern CZReportWizard* pWizard;
IMPLEMENT_DYNAMIC(CZReportWizard, CPropertySheet)
CZReportWizard::CZReportWizard(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
}
CZReportWizard::CZReportWizard(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
Construct(pszCaption,this);
m_FStepPage.Construct (IDD_FIRSTSTEP,0);
m_SStepPage.Construct (IDD_SECONDSTEP,0);
m_TStepPage.Construct (IDD_THIRDSTEP,0);
AddPage(&m_FStepPage);
AddPage(&m_SStepPage);
AddPage(&m_TStepPage);
pWizard=this;
m_strSalerId=pszCaption;
CZReportView* pView=static_cast<CZReportView*>(pParentWnd);
pZReportDoc=pView->GetDocument ();
}
CZReportWizard::~CZReportWizard()
{
}
BEGIN_MESSAGE_MAP(CZReportWizard, CPropertySheet)
//{{AFX_MSG_MAP(CZReportWizard)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZReportWizard message handlers
BOOL CZReportWizard::OnInitDialog()
{
_RecordsetPtr pRst=NULL;
CSalaryDoc* pSalaryDoc=CSalaryDoc::GetSalaryDoc ();
TESTHR(pRst.CreateInstance (__uuidof(Recordset)));
float flCalcSalary=0.0;
CZReportDoc* pZRDoc=CZReportDoc::GetZReportDoc ();
pRst=pZRDoc->GetZReportRecordset ();
pSalaryDoc->CalculateAmountSalary(pRst,&flCalcSalary);
m_flPremia=flCalcSalary ;
pSalaryDoc->GetBaseSalary (m_strSalerId,&flCalcSalary);
m_flSalary =flCalcSalary ;
if(pRst!=NULL)
{
if(pRst->State ==adStateOpen)
pRst->Close ();
}
BOOL bResult = CPropertySheet::OnInitDialog();
return bResult;
}
|
71c02d7742df63f3ee63cffef8b374f673720253 | 5ee10e00819707a03c40ca64596360aee12a7b06 | /source/tpg_divide.cpp | 75b8d8977e7c81a84e4d1f5f92204278100e299b | [] | no_license | JayZhouzzj/TPGPP | e35a8db0155092669166ae9a1c55af7143ea7207 | 9edc290e54e130ea9c51be6147245995173fcdb4 | refs/heads/master | 2023-08-23T08:12:12.039022 | 2021-10-29T16:12:07 | 2021-10-29T16:12:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,155 | cpp | tpg_divide.cpp | #include "tpg_divide.h"
#include "tpg_memory_model.h"
bool DivideOperation::execute(int8 mode, int32 source, int8 destination,
const double* inputFeatures, double* registers,
const TpgParameters& parameters) const
{
// If we are missing the inputs and/or registers, return false.
if(registers == nullptr)
return false;
// Run a switch on the mode value.
switch(mode)
{
// If mode is 0, we perform a Register-Register calculation.
case 0:
registers[destination] /= registers[source];
return true;
// If mode is 1, we perform an Input-Register calculation.
case 1:
registers[destination] /= inputFeatures[source];
return true;
// If mode is 2, we perform a Memory-Register calculation.
case 2:
registers[destination] /= parameters.memory->read(source);
return true;
}
// If mode is broken, we return false.
return false;
}
std::string DivideOperation::toString() const
{
return std::string("div");
}
std::string DivideOperation::toStorage() const
{
return this->toString();
} |
bb8ca5e0736127ad80d58ef60bfc44b0375c4e35 | 889e092733617f5a47d70a35b9061035844835e3 | /Source Files/Source/Markable/MarkUnit.h | a6dd6798bcea489a2193c037ddc10fb2e151f620 | [] | no_license | Wyder7PL/Game | f2f305d2b3b02083c7c722a1716e54d1cfd0ebf4 | 0418f5f682b042ac854ecd312dfe426abaf8f896 | refs/heads/master | 2020-04-18T00:42:39.302551 | 2019-08-22T15:49:05 | 2019-08-22T15:49:05 | 167,087,838 | 1 | 0 | null | 2019-08-22T15:49:06 | 2019-01-23T00:14:54 | C++ | UTF-8 | C++ | false | false | 1,114 | h | MarkUnit.h | #pragma once
#include "Markable.h"
#include "MultiUnitSelection.h"
#include "../AddObject.h"
#include "../Functions.h"
class MarkUnit:public Markable
{
bool pervious;
sf::CircleShape mark;
bool ntm;///need to move?
uint32_t ntmdenycooldown;
Position Destination;
protected:
static MultiUnitSelection * MUS;
virtual void Desactivate();
bool ForcedMove();
Position ForcedDestination();
virtual uint32_t GetSkillType()=0;
virtual void QuickDeselect();
public:
MarkUnit(Position);
virtual ~MarkUnit();
virtual void Step();
virtual void draw(sf::RenderTarget & target,sf::RenderStates states) const;
static void CreateMUS(MultiUnitSelection*);
void MarkSize(float);
virtual void CreateInfo(std::list<Info>&);
void ForceDestination(Position);
};
/// /////////////////////////// ///
/// Skill type 1 << n-1 ///
/// 0 - None ///
/// 1 - Combat Only ///
/// 2 - Close Combat ///
/// 3 - Distance Combat ///
/// /////////////////////////// ///
|
4eb1f0d4a8932bdd149f9b0069ccb40ae314d135 | 0d0e78c6262417fb1dff53901c6087b29fe260a0 | /cdb/src/v20170320/model/DescribeAuditConfigResponse.cpp | df718cae3a9452a6b0b4b584d412835f2fd45ace | [
"Apache-2.0"
] | permissive | li5ch/tencentcloud-sdk-cpp | ae35ffb0c36773fd28e1b1a58d11755682ade2ee | 12ebfd75a399ee2791f6ac1220a79ce8a9faf7c4 | refs/heads/master | 2022-12-04T15:33:08.729850 | 2020-07-20T00:52:24 | 2020-07-20T00:52:24 | 281,135,686 | 1 | 0 | Apache-2.0 | 2020-07-20T14:14:47 | 2020-07-20T14:14:46 | null | UTF-8 | C++ | false | false | 3,626 | cpp | DescribeAuditConfigResponse.cpp | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <tencentcloud/cdb/v20170320/model/DescribeAuditConfigResponse.h>
#include <tencentcloud/core/utils/rapidjson/document.h>
#include <tencentcloud/core/utils/rapidjson/writer.h>
#include <tencentcloud/core/utils/rapidjson/stringbuffer.h>
using TencentCloud::CoreInternalOutcome;
using namespace TencentCloud::Cdb::V20170320::Model;
using namespace rapidjson;
using namespace std;
DescribeAuditConfigResponse::DescribeAuditConfigResponse() :
m_logExpireDayHasBeenSet(false),
m_logTypeHasBeenSet(false)
{
}
CoreInternalOutcome DescribeAuditConfigResponse::Deserialize(const string &payload)
{
Document d;
d.Parse(payload.c_str());
if (d.HasParseError() || !d.IsObject())
{
return CoreInternalOutcome(Error("response not json format"));
}
if (!d.HasMember("Response") || !d["Response"].IsObject())
{
return CoreInternalOutcome(Error("response `Response` is null or not object"));
}
Value &rsp = d["Response"];
if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString())
{
return CoreInternalOutcome(Error("response `Response.RequestId` is null or not string"));
}
string requestId(rsp["RequestId"].GetString());
SetRequestId(requestId);
if (rsp.HasMember("Error"))
{
if (!rsp["Error"].IsObject() ||
!rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() ||
!rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString())
{
return CoreInternalOutcome(Error("response `Response.Error` format error").SetRequestId(requestId));
}
string errorCode(rsp["Error"]["Code"].GetString());
string errorMsg(rsp["Error"]["Message"].GetString());
return CoreInternalOutcome(Error(errorCode, errorMsg).SetRequestId(requestId));
}
if (rsp.HasMember("LogExpireDay") && !rsp["LogExpireDay"].IsNull())
{
if (!rsp["LogExpireDay"].IsInt64())
{
return CoreInternalOutcome(Error("response `LogExpireDay` IsInt64=false incorrectly").SetRequestId(requestId));
}
m_logExpireDay = rsp["LogExpireDay"].GetInt64();
m_logExpireDayHasBeenSet = true;
}
if (rsp.HasMember("LogType") && !rsp["LogType"].IsNull())
{
if (!rsp["LogType"].IsString())
{
return CoreInternalOutcome(Error("response `LogType` IsString=false incorrectly").SetRequestId(requestId));
}
m_logType = string(rsp["LogType"].GetString());
m_logTypeHasBeenSet = true;
}
return CoreInternalOutcome(true);
}
int64_t DescribeAuditConfigResponse::GetLogExpireDay() const
{
return m_logExpireDay;
}
bool DescribeAuditConfigResponse::LogExpireDayHasBeenSet() const
{
return m_logExpireDayHasBeenSet;
}
string DescribeAuditConfigResponse::GetLogType() const
{
return m_logType;
}
bool DescribeAuditConfigResponse::LogTypeHasBeenSet() const
{
return m_logTypeHasBeenSet;
}
|
0cec3dff1091a76c8cc71983bb44b4b6765740d1 | 1b824bdebc55334514f4c387995fe3e9e899a7f1 | /src/diffusionSystem.cpp | ba6827d48df773f2801599b471dcc19e24e2edd6 | [
"MIT"
] | permissive | speth/ember | e0595f143f4f687b9a8fac93cf58099b2093b84e | cd1fbb09992e39f327d037941206f6bbb521960a | refs/heads/main | 2022-05-08T04:51:13.074965 | 2022-04-11T21:58:11 | 2022-04-11T21:58:11 | 5,696,549 | 36 | 24 | MIT | 2023-08-31T13:10:26 | 2012-09-06T02:37:52 | C++ | UTF-8 | C++ | false | false | 2,620 | cpp | diffusionSystem.cpp | #include "diffusionSystem.h"
#include <assert.h>
DiffusionSystem::DiffusionSystem()
: yInf(0)
, wallConst(0)
{
}
void DiffusionSystem::get_A(dvec& a, dvec& b, dvec& c)
{
assert(mathUtils::notnan(D));
assert(mathUtils::notnan(B));
for (size_t j=1; j<=N-2; j++) {
c1[j] = 0.5*B[j]/(dlj[j]*r[j]);
c2[j] = rphalf[j]*(D[j]+D[j+1])/hh[j];
}
assert(mathUtils::notnan(c1));
assert(mathUtils::notnan(c2));
// Left boundary value
size_t jStart;
if (grid.leftBC == BoundaryCondition::FixedValue) {
jStart = 1;
} else if (grid.leftBC == BoundaryCondition::ControlVolume) {
jStart = 1;
double c0 = B[0] * (grid.alpha + 1) * (D[0]+D[1]) / (2 * hh[0] * hh[0]);
b[0] = -c0;
c[0] = c0;
} else if (grid.leftBC == BoundaryCondition::WallFlux) {
jStart = 1;
double c0 = B[0] * (grid.alpha + 1) / hh[0];
double d = 0.5 * (D[0]+D[1]);
b[0] = - c0 * (d / hh[0] + wallConst);
c[0] = d * c0 / hh[0];
} else { // (leftBC == BoundaryCondition::ZeroGradient)
// In the case of a zero gradient boundary condition, the boundary value
// is not computed, and the value one point in is computed by substituting
// y[0] = y[1] in the finite difference formula.
jStart = 2;
b[1] = -c1[1]*c2[1];
c[1] = c1[1]*c2[1];
}
// Right boundary value
size_t jStop;
if (grid.rightBC == BoundaryCondition::FixedValue) {
jStop = N-1;
} else { // (rightBC == BoundaryCondition::ZeroGradient)
// In the case of a zero gradient boundary condition, the boundary value
// is not computed, and the value one point in is computed by substituting
// y[N-1] = y[N-2] in the finite difference formula.
jStop = N-2;
a[N-2] = c1[N-2]*c2[N-3];
b[N-2] = -c1[N-2]*c2[N-3];
}
// Intermediate points
for (size_t j=jStart; j<jStop; j++) {
a[j] = c1[j]*c2[j-1];
b[j] = -c1[j]*(c2[j-1] + c2[j]);
c[j] = c1[j]*c2[j];
}
}
void DiffusionSystem::get_k(dvec& k)
{
assert(mathUtils::notnan(splitConst));
k = splitConst;
if (grid.leftBC == BoundaryCondition::WallFlux) {
k[0] += B[0] * (grid.alpha + 1) / hh[0] * wallConst * yInf;
}
assert(mathUtils::notnan(k));
}
void DiffusionSystem::resize(size_t N_)
{
N = N_;
B.setConstant(N, NaN);
D.setConstant(N, NaN);
splitConst.setConstant(N, NaN);
c1.setConstant(N, 0);
c2.setConstant(N, 0);
}
void DiffusionSystem::resetSplitConstants()
{
splitConst.setZero(N);
}
|
27ae763b481b3bd807c2ef1b37af3f1924f79103 | a9922d559d43880009effef26ec3b6263e93f88e | /solutions/kattis/ecna15/kenken_hcz.cpp | 9f13691a776dec3ceb9ca09e2463b0e51694a8f6 | [] | no_license | buckeye-cn/ACM_ICPC_Materials | e7cc8e476de42f8b8a3559a9721b421a85a95a48 | 6d32af96030397926c8d5e354c239802d5d171db | refs/heads/master | 2023-04-26T03:02:51.341470 | 2023-04-16T10:46:17 | 2023-04-16T10:46:17 | 102,976,270 | 23 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,166 | cpp | kenken_hcz.cpp | // https://open.kattis.com/problems/kenken
#include <cstdlib>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
int n, m, t;
char op;
int r[10];
int c[10];
long pow_n[11] {1};
bool r_used[10][10];
bool c_used[10][10];
int scan_add(int i, int value) {
if (i == m) {
return value == t;
}
if (value + m - i > t || value + n * (m - i) < t) {
return 0;
}
int rr = r[i];
int cc = c[i];
int total = 0;
if (i == m - 1) {
return !r_used[rr][t - value] && !c_used[cc][t - value];
} else {
for (int k = 1; k <= n; ++k) {
if (r_used[rr][k]) continue;
if (c_used[cc][k]) continue;
r_used[rr][k] = true;
c_used[cc][k] = true;
total += scan_add(i + 1, value + k);
r_used[rr][k] = false;
c_used[cc][k] = false;
}
}
return total;
}
int scan_mul(int i, int value) {
if (i == m) {
return value == t;
}
if (value > t || value * pow_n[m - i] < t || t % value) {
return 0;
}
int rr = r[i];
int cc = c[i];
int total = 0;
for (int k = 1; k <= n; ++k) {
if (r_used[rr][k]) continue;
if (c_used[cc][k]) continue;
r_used[rr][k] = true;
c_used[cc][k] = true;
total += scan_mul(i + 1, value * k);
r_used[rr][k] = false;
c_used[cc][k] = false;
}
return total;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.precision(10);
cin >> n >> m >> t >> op;
for (int i = 0; i < m; ++i) {
cin >> r[i] >> c[i];
pow_n[i + 1] = pow_n[i] * n;
}
if (op == '+') {
cout << scan_add(0, 0) << endl;
} else if (op == '-') {
cout << max(n - t, 0) * 2 << endl;
} else if (op == '*') {
cout << scan_mul(0, 1) << endl;
} else if (op == '/') {
if (t == 1 && (r[0] == r[1] || c[0] == c[1])) {
cout << 0 << endl;
} else {
cout << max(n / t, 0) * 2 << endl;
}
}
return 0;
}
|
d1e6323f9cc539d0be4d9d7ce85bc2b813a6f15e | 57445b6c8fcaa54a179bb19c912053b1d9d9544b | /CodePractice/Type/String/Medium/LetterCombinationsPhoneNumber.h | a9ec2d732d2a4df3a6febba7946a3950fc1d2119 | [] | no_license | flashshan/CodePractice | 7c774ff88f920037791ec4dcbc4e9df96a1aad99 | c0f897381a8e3d78104ddf645d6949a82de08923 | refs/heads/master | 2021-10-10T23:01:27.671831 | 2019-01-18T16:08:14 | 2019-01-18T16:08:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,645 | h | LetterCombinationsPhoneNumber.h | #pragma once
#include "Core/CoreMinimal.h"
#include <string>
using namespace std;
/// Leetcode No.17
/*
Given a digit string, return all possible letter combinations that the number could represent.
A mapping of digit to letters (just like on the telephone buttons) is given below.
Input:Digit string "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
*/
class LetterCombinationsPhoneNumber : public ITest{
public:
virtual bool RunTest() override
{
cout << "Start test Letter Combinations of a Phone Number." << endl;
string str;
while (cin >> str)
{
if (str == "0")
break;
vector<string> res = letterCombinations(str);
Output::OutputStringArray(res);
}
cout << "End test Letter Combinations of a Phone Number." << endl << endl;
return true;
}
private:
vector<string> letterCombinations(string digits) {
count[0] = 0; count[1] = 0; count[2] = 3; count[3] = 3; count[4] = 3;
count[5] = 3; count[6] = 3; count[7] = 4; count[8] = 3; count[9] = 4;
chars[0] = ""; chars[1] = ""; chars[2] = "abc"; chars[3] = "def"; chars[4] = "ghi";
chars[5] = "jkl"; chars[6] = "mno"; chars[7] = "pqrs"; chars[8] = "tuv"; chars[9] = "wxyz";
digit = digits;
res.clear();
n = (int)digits.length();
if (n == 0)
return res;
nextChar("", 0);
return res;
}
void nextChar(string st, int temp)
{
for (int i = 0; i < count[digit[temp] - '0']; i++)
{
if (temp == n - 1)
res.push_back(st + chars[digit[temp] - '0'][i]);
else
nextChar(st + chars[digit[temp] - '0'][i], temp + 1);
}
}
int count[10];
string chars[10];
vector<string> res;
int n;
string digit;
}; |
f74a78ff9377f0b7512f50e3641696c9a9157f31 | 7504ebb7d1c738376a9da8a6c2334cfac4ca37ed | /contact.cpp | 95b1b47559882d18b4719d9a134ec91bc8fff1ab | [] | no_license | alpgurlee/Telefon-Kayit-Sistemi | 17cda1d410ea969c4497ce34a463b567331138a7 | 8c229fb1569d7249f6f54dae6143772fd6f448d4 | refs/heads/master | 2022-10-10T20:02:34.100115 | 2020-06-10T00:43:52 | 2020-06-10T00:43:52 | 271,041,147 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,249 | cpp | contact.cpp | #ifndef _contact
#define _contact
#include <string>
#include <iostream>
#include "contact.h"
using namespace std;
Contact::Contact() {
id = "";
isim = "";
soyisim = "";
cepno = "";
isno = "";
}
Contact::Contact(string id, string isim, string soyisim, string cepno, string isno) {
this->id = id;
this->isim = isim;
this->soyisim = soyisim;
this->cepno = cepno;
this->isno = isno;
}
Contact::~Contact() {
}
// Contact sınıfının getter metotları.
string Contact::getid() {
return id;
}
string Contact::getisim() {
return isim;
}
string Contact::getsoyisim() {
return soyisim;
}
string Contact::getcepno() {
return cepno;
}
string Contact::getisno() {
return isno;
}
// Contact sınıfının getter metotları.
void Contact::print_contact() { // Kişinin bilgilerini yazdırır.
cout << "ID: " << id << endl;
cout << "Adi: " << isim << endl;
cout << "Soyadi: " << soyisim << endl;
cout << "Cep Numarasi: " << cepno << endl;
cout << "Is numarasi: " << isno << endl;
cout << endl;
}
string Contact::tostring() {
return id + " " + isim + " " + soyisim + " " + cepno + " " + isno;
}
void Contact::setisim(string isim) {
this->isim = isim;
}
#endif |
99b0ff79bb5acef18b569800d6b2a55cfcedfb61 | ff006db72f9a1bf0a69fac7b931c06332a4c2793 | /ejemplo_semaforos/deleteSemPosix.cpp | 67693a2caabccc1a2c59f6adb34de80bb13f0df8 | [
"MIT"
] | permissive | cfranco92/SEMAFOROS | 07c2f145fdfd0c6e7676ca8345d86890d6cc5c8c | e8873a63843981766fba76f82cb178b01ba131b9 | refs/heads/master | 2021-08-11T23:43:26.119670 | 2017-03-27T20:01:02 | 2017-03-27T20:01:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 581 | cpp | deleteSemPosix.cpp | /*
* fichero: deleteSemPosix.cpp
*
* compilar: $ g++ -o deleteSemPosix deleteSemPosix.cpp -pthread
* ejecutar: $ ./deleteSemPosix <nombre>
*/
#include <fcntl.h>
#include <sys/stat.h>
#include <semaphore.h>
#include <cstdlib>
#include <cerrno>
#include <iostream>
using namespace std;
void usage(const char* progname) {
cerr << progname << " sem_key " << endl;
exit(1);
}
int
main(int argc, const char* argv[]) {
sem_t *sem;
if (argc != 2) {
usage(argv[0]);
}
if (sem_unlink(argv[1]) == -1) {
cerr << "Error: " << errno << endl;
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.