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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8466719e61be47cc21a89f20f2d2a2582be9c44a | 1c227f8f40f5e9d994f6df4a12a39d28d3fe1461 | /projects/GameEngine/SkyBox/src/SkyBox.cpp | ce9109c5b809a72f84c72b96749fd3a30747727b | [] | no_license | MiguelGoncalves98/Graphics-Engine | a7f40dde82eed0b33c661402f145a38e30b6b27d | 569cc26eceea6efb25649b5f493de77391f56329 | refs/heads/master | 2020-09-10T15:18:50.326052 | 2019-04-12T12:23:03 | 2019-04-12T12:23:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 609 | cpp | SkyBox.cpp | #include "SkyBox\include\SkyBox.h"
SkyBox::SkyBox(std::vector<std::string> faces)
{
this->skybox = new CubeMap(faces);
Mesh* cube = MeshManager::getInstance()->get("skyboxcube");
if (cube == nullptr) {
this->cube = MeshManager::getInstance()->create("Assets/Models/cubemap_cube.obj", "skyboxcube");
}
else {
this->cube = cube;
}
}
SkyBox::SkyBox()
{
}
SkyBox::~SkyBox()
{
delete skybox;
}
void SkyBox::setMesh(Mesh * cube)
{
this->cube = cube;
}
void SkyBox::setCubeMap(CubeMap * map)
{
this->skybox = map;
}
void SkyBox::setSkyBoxShader(Shader * shader)
{
this->skyboxShader = shader;
}
|
5cc557f3e0009913042e4f3a148aceac5aa7261e | acbc627adcb21812c5037a397ff63bd248c0922f | /CppGL/include/Model.hpp | 2084fceffbf291f5cad2cdea76162c68a014972d | [] | no_license | aktowns/CppGL | 7a8693aba2fb7f7b9aca3c6770c94e3d9b3df6e6 | e8a9e83b30bb5a532d2da697998685fa472d5ab5 | refs/heads/master | 2022-05-05T13:06:03.470347 | 2019-01-19T08:30:54 | 2019-01-19T08:30:54 | 164,308,617 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 992 | hpp | Model.hpp | #pragma once
#include <vector>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <spdlog/spdlog.h>
#include "Mesh.hpp"
#include "Shader.hpp"
#include "Logger.hpp"
#include "Model.hpp"
class Model final : public Logger {
const std::filesystem::path _path;
bool _gamma;
public:
std::vector<MeshTexture> texturesLoaded;
std::vector<Mesh> meshes;
bool gammaCorrection;
explicit Model(std::filesystem::path path, bool gamma = false);
void draw(const Shader* shader);
static std::optional<Model*> fromResource(const Resource& resource, const Console& console);
private:
void loadModel(std::filesystem::path const &path);
void processNode(aiNode *node, const aiScene *scene);
Mesh processMesh(aiMesh *mesh, const aiScene *scene);
std::vector<MeshTexture> loadMaterialTextures(aiMaterial* mat, aiTextureType type, const std::string& typeName);
glm::vec3 _minBounds;
glm::vec3 _maxBounds;
};
|
794392d8b6ee144b4c62e2d395e437fb4820e092 | 462b27319884063c8bf33d65681486d50a44dbc2 | /card/src/std.cpp | a972534ba25aacd117ea7a5d67ed7beafb2426b7 | [
"MIT"
] | permissive | nju-icpc/NJUPC16 | 144f6c941ae093816f47b57b2b41b998b7c4d701 | 871ba8cd1bc1df241f2ad7bd569068d0bf07ae9d | refs/heads/master | 2022-01-13T10:12:57.403086 | 2019-05-10T14:33:12 | 2019-05-10T14:33:12 | 181,927,081 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 924 | cpp | std.cpp | #include<bits/stdc++.h>
using namespace std;
typedef double db;
int d[105],n,a,b;
db f[105],nf[105],dp[105][105][105];
db C(int x,int y){
return f[x]*nf[y]*nf[x-y];
}
int main(){
scanf("%d%d%d",&n,&a,&b);
for (int i=1;i<=n;i++) scanf("%d",&d[i]);
f[0]=nf[0]=1;
for (int i=1;i<=n;i++) f[i]=f[i-1]*i,nf[i]=nf[i-1]/i;
db ans=0;
for (int o=1;o<=n;o++){
memset(dp,0,sizeof(dp));
dp[0][0][0]=1;
for (int i=1;i<=n;i++){
for (int j=0;j<n;j++) for (int k=0;k<=b;k++) dp[i][j][k]=dp[i-1][j][k];
if (i==o) continue;
for (int j=1;j<n;j++) for (int k=d[i];k<=b;k++) dp[i][j][k]+=dp[i-1][j-1][k-d[i]];
}
int l=max(0,a-d[o]+1),r=min(a,b-d[o]);
for (int i=r;i>=l;i--)
for (int j=0;j<n;j++)
ans+=dp[n][j][i]/C(n,j)/(n-j);
}
printf("%.12f\n",ans);
return 0;
}
|
a3bef3ad988c845b6f3d1632cfe7fc30487d4cba | 8c1ec1903c45c78147ed5046c1410bec7a56c964 | /learngl/src/MeshModel/Model.cpp | 811dbf6a917aa90983c275daafe768b4ae755206 | [
"Apache-2.0"
] | permissive | SRIHARSHA018/Opengl | e66505f7edf6f8ac7027683dd807b436cbffd141 | f66bb9ac09b02cb26b3a96d087e0728376190b41 | refs/heads/master | 2023-05-19T00:58:21.698071 | 2021-06-06T07:28:38 | 2021-06-06T07:28:38 | 287,280,198 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,206 | cpp | Model.cpp | #include "Model.h"
Model::Model(const std::string& path)
:x_path(path)
{
x_LoadModel();
}
void Model::x_LoadModel()
{
Assimp::Importer import;
const aiScene* scene = import.ReadFile(x_path, aiProcess_Triangulate | aiProcess_FlipUVs |aiProcess_JoinIdenticalVertices);
if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode)
{
std::cout << "ERROR::scene file is empty" << std::endl;
return;
}
x_directory = x_path.substr(0, x_path.find_last_of('/'));
this->x_processNode(scene->mRootNode, scene);
}
void Model::x_processNode(aiNode* node, const aiScene* scene)
{
for (unsigned int i = 0; i < node->mNumMeshes; i++)
{
aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
this->x_meshes.push_back(this->x_ProcessMesh(mesh,scene));
}
for (unsigned int i = 0; i < node->mNumChildren; i++)
{
this->x_processNode(node->mChildren[i], scene);
}
}
Mesh Model::x_ProcessMesh(aiMesh* mesh, const aiScene* scene)
{
std::vector<Vertex> vertices;
std::vector<unsigned int> indices;
std::vector<texture> textures;
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
{
Vertex vertex;
vertex.vertexPositions = glm::vec3(mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z);
vertex.vertexNormals = glm::vec3(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z);
if (mesh->mTextureCoords[0])
{
glm::vec2 vec;
vec.x = mesh->mTextureCoords[0][i].x;
vec.y = mesh->mTextureCoords[0][i].y;
vertex.TextureCoordinates = vec;
}
else
vertex.TextureCoordinates = glm::vec2(0.0f, 0.0f);
vertices.push_back(vertex);
}
for (unsigned int i = 0; i < mesh->mNumFaces; i++)
{
aiFace face = mesh->mFaces[i];
for (unsigned int j = 0; j < face.mNumIndices; j++)
{
indices.push_back(face.mIndices[j]);
}
}
if (mesh->mMaterialIndex >= 0)
{
aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
// 1. diffuse maps
std::vector<texture> diffuseMaps = x_LoadMaterialTextures(material, aiTextureType_DIFFUSE, "u_material.base.diffuse");
textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());
// 2. specular maps
std::vector<texture> specularMaps = x_LoadMaterialTextures(material, aiTextureType_SPECULAR, "u_material.base.specular");
textures.insert(textures.end(), specularMaps.begin(), specularMaps.end());
}
return Mesh(vertices, indices,textures);
}
std::vector<texture> Model::x_LoadMaterialTextures(aiMaterial* mat, aiTextureType type, std::string typeName)
{
std::vector<texture> textures;
for (unsigned int i = 0; i < mat->GetTextureCount(type); i++)
{
aiString str;
mat->GetTexture(type, i, &str);
texture texture;
texture.id = x_TextureFromFile(str.C_Str(), x_directory,0);
texture.type = typeName;
texture.path = str.C_Str();
textures.push_back(texture);
}
return textures;
}
unsigned int Model::x_TextureFromFile(const char* path, const std::string& directory, bool gamma)
{
std::string filename = std::string(path);
filename = directory + '/' + filename;
unsigned int textureID;
glGenTextures(1, &textureID);
int width, height, nrComponents;
unsigned char* data = stbi_load(filename.c_str(), &width, &height, &nrComponents, 0);
if (data)
{
GLenum format;
if (nrComponents == 1)
format = GL_RED;
else if (nrComponents == 3)
format = GL_RGB;
else if (nrComponents == 4)
format = GL_RGBA;
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
stbi_image_free(data);
}
else
{
std::cout << "Texture failed to load at path: " << path << std::endl;
stbi_image_free(data);
}
return textureID;
}
void Model::DrawModel(SJ_engine::SJ_shader::shader* obj, BasicMaterial* baseMat, StandardMaterial* standMat)
{
for (unsigned int i = 0; i < x_meshes.size(); i++)
{
x_meshes[i].DrawMesh(obj, baseMat, standMat);
}
} |
1aab94f26ce04aff520ee5dc32c56582d0a7e905 | 735c92f5033129035a8df57dfe04f9e9bd7040ec | /XMLRead-Writer/setNameParamXMLReader.h | 53c4346821d6893f7bffe97cfc58be58d80a029b | [
"MIT"
] | permissive | SethSnow/InterestingCodesForMeSets | d6a3cc303df38e4b5d3f19c392620736974f5901 | 3a19ac12964a6550a668e726fe8e766f77b79601 | refs/heads/master | 2021-03-04T23:44:45.637860 | 2020-03-09T15:57:14 | 2020-03-09T15:57:14 | 246,076,802 | 0 | 0 | MIT | 2020-03-09T15:47:03 | 2020-03-09T15:47:02 | null | GB18030 | C++ | false | false | 454 | h | setNameParamXMLReader.h | /**
* 读取命名设置的xml文件
*/
#ifndef SET_NAME_PARAM_XML_READER_H_
#define SET_NAME_PARAM_XML_READER_H_
/**
* 读取xml配置文件
*/
class SetNameParamXMLReader
{
public:
SetNameParamXMLReader();
/**
* 读取xml文件中的配置信息
* \param filePath 文件路径
* \return bool 如果读取成功返回true, 否则返回false
*/
bool readConfigFile(const char *filePath);
private:
char m_version[64];
};
#endif
|
c06edbf358b4bb9653336844786cc5e0a786bb33 | cd96760180f65a17f428cc478b0cc774bcbef5e2 | /Usaco/milk3.cpp | 8ee5ec527d66518fdb39e2ea5434061d0ae8290c | [] | no_license | ngrj93/Competitive-Programming | 1cecc5cfec39472100fdb392f341f6190cca9b0e | 477b03d388262460443a22d62ab115f1966a4191 | refs/heads/master | 2021-01-17T21:11:28.850021 | 2017-03-07T07:50:44 | 2017-03-07T07:50:44 | 84,165,218 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,431 | cpp | milk3.cpp | /*
ID: ngrj931
PROB: milk3
LANG: C++11
*/
#include<fstream>
#include<iostream>
using namespace std;
ofstream fout("milk3.out");
int max_capacity[3];
int bucket[3],total;
bool state[21][21][21];
bool ans[21];
void recurse_solve(int a,int b,int c){
state[a][b][c]=true;
if(a==0)
ans[c]=true;
if(a!=0){
int pour=max_capacity[1]-b>=a?a:max_capacity[1]-b;
if(state[a-pour][b+pour][c]==false)
recurse_solve(a-pour,b+pour,c);
pour=max_capacity[2]-c>=a?a:max_capacity[2]-c;
if(state[a-pour][b][c+pour]==false)
recurse_solve(a-pour,b,c+pour);
}
if(b!=0){
int pour=max_capacity[0]-a>=b?b:max_capacity[0]-a;
if(state[a+pour][b-pour][c]==false)
recurse_solve(a+pour,b-pour,c);
pour=max_capacity[2]-c>=b?b:max_capacity[2]-c;
if(state[a][b-pour][c+pour]==false)
recurse_solve(a,b-pour,c+pour);
}
if(c!=0){
int pour=max_capacity[1]-b>=c?c:max_capacity[1]-b;
if(state[a][b+pour][c-pour]==false)
recurse_solve(a,b+pour,c-pour);
pour=max_capacity[0]-a>=c?c:max_capacity[0]-a;
if(state[a+pour][b][c-pour]==false)
recurse_solve(a+pour,b,c-pour);
}
}
int main(){
ifstream fin("milk3.in");
fin>>max_capacity[0]>>max_capacity[1]>>max_capacity[2];
recurse_solve(0,0,max_capacity[2]);
string str="";
for(int i=0;i<21;i++){
if(ans[i])
str=str+to_string(i)+" ";
}
str=str.substr(0,str.length()-1);
fout<<str<<endl;
return 0;
}
|
05197297e8da269affea67f1c5bc042b9d44d87c | 687b8cdc4a3dfdbd941489d010a918145030a3cc | /gastpc/evtrec/Units.h | 80856fdb6bf5d900f48a36ff54d65fd67658614b | [
"BSD-3-Clause"
] | permissive | DUNE/wp1-neardetector | d103b623b6459c6b2a3d4e66bb585ff56ed45c46 | 729c30532670679b7c87131ec70b4141d04a3ede | refs/heads/master | 2021-04-19T01:22:24.246465 | 2017-03-01T18:11:05 | 2017-03-01T18:11:05 | 30,244,428 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,718 | h | Units.h | // ----------------------------------------------------------------------
// HEP coherent system of Units
//
// This file has been provided to CLHEP by Geant4 (simulation toolkit for HEP).
//
// The basic units are :
// millimeter (millimeter)
// nanosecond (nanosecond)
// Mega electron Volt (MeV)
// positron charge (eplus)
// degree Kelvin (kelvin)
// the amount of substance (mole)
// luminous intensity (candela)
// radian (radian)
// steradian (steradian)
//
// Below is a non exhaustive list of derived and pratical units
// (i.e. mostly the SI units).
// You can add your own units.
//
// The SI numerical value of the positron charge is defined here,
// as it is needed for conversion factor : positron charge = e_SI (coulomb)
//
// The others physical constants are defined in the header file :
//PhysicalConstants.h
//
// Authors: M.Maire, S.Giani
//
// History:
//
// 06.02.96 Created.
// 28.03.96 Added miscellaneous constants.
// 05.12.97 E.Tcherniaev: Redefined pascal (to avoid warnings on WinNT)
// 20.05.98 names: meter, second, gram, radian, degree
// (from Brian.Lasiuk@yale.edu (STAR)). Added luminous units.
// 05.08.98 angstrom, picobarn, microsecond, picosecond, petaelectronvolt
// 01.03.01 parsec
// 31.01.06 kilogray, milligray, microgray
// 29.04.08 use PDG 2006 value of e_SI
// 03.11.08 use PDG 2008 value of e_SI
// 19.08.15 added liter and its sub units (mma)
#ifndef GASTPC_SYSTEM_OF_UNITS_H
#define GASTPC_SYSTEM_OF_UNITS_H
namespace gastpc {
//
//
//
static const double pi = 3.14159265358979323846;
static const double twopi = 2*pi;
static const double halfpi = pi/2;
static const double pi2 = pi*pi;
//
// Length [L]
//
static const double millimeter = 1.;
static const double millimeter2 = millimeter*millimeter;
static const double millimeter3 = millimeter*millimeter*millimeter;
static const double centimeter = 10.*millimeter;
static const double centimeter2 = centimeter*centimeter;
static const double centimeter3 = centimeter*centimeter*centimeter;
static const double meter = 1000.*millimeter;
static const double meter2 = meter*meter;
static const double meter3 = meter*meter*meter;
static const double kilometer = 1000.*meter;
static const double kilometer2 = kilometer*kilometer;
static const double kilometer3 = kilometer*kilometer*kilometer;
static const double parsec = 3.0856775807e+16*meter;
static const double micrometer = 1.e-6 *meter;
static const double nanometer = 1.e-9 *meter;
static const double angstrom = 1.e-10*meter;
static const double fermi = 1.e-15*meter;
static const double barn = 1.e-28*meter2;
static const double millibarn = 1.e-3 *barn;
static const double microbarn = 1.e-6 *barn;
static const double nanobarn = 1.e-9 *barn;
static const double picobarn = 1.e-12*barn;
// symbols
static const double nm = nanometer;
static const double um = micrometer;
static const double mm = millimeter;
static const double mm2 = millimeter2;
static const double mm3 = millimeter3;
static const double cm = centimeter;
static const double cm2 = centimeter2;
static const double cm3 = centimeter3;
static const double liter = 1.e+3*cm3;
static const double L = liter;
static const double dL = 1.e-1*liter;
static const double cL = 1.e-2*liter;
static const double mL = 1.e-3*liter;
static const double m = meter;
static const double m2 = meter2;
static const double m3 = meter3;
static const double km = kilometer;
static const double km2 = kilometer2;
static const double km3 = kilometer3;
static const double pc = parsec;
//
// Angle
//
static const double radian = 1.;
static const double milliradian = 1.e-3*radian;
static const double degree = (pi/180.0)*radian;
static const double steradian = 1.;
// symbols
static const double rad = radian;
static const double mrad = milliradian;
static const double sr = steradian;
static const double deg = degree;
//
// Time [T]
//
static const double nanosecond = 1.;
static const double second = 1.e+9 *nanosecond;
static const double millisecond = 1.e-3 *second;
static const double microsecond = 1.e-6 *second;
static const double picosecond = 1.e-12*second;
static const double hertz = 1./second;
static const double kilohertz = 1.e+3*hertz;
static const double megahertz = 1.e+6*hertz;
// symbols
static const double ns = nanosecond;
static const double s = second;
static const double ms = millisecond;
//
// Electric charge [Q]
//
static const double eplus = 1. ;// positron charge
static const double e_SI = 1.602176487e-19;// positron charge in coulomb
static const double coulomb = eplus/e_SI;// coulomb = 6.24150 e+18 * eplus
//
// Energy [E]
//
static const double megaelectronvolt = 1. ;
static const double electronvolt = 1.e-6*megaelectronvolt;
static const double kiloelectronvolt = 1.e-3*megaelectronvolt;
static const double gigaelectronvolt = 1.e+3*megaelectronvolt;
static const double teraelectronvolt = 1.e+6*megaelectronvolt;
static const double petaelectronvolt = 1.e+9*megaelectronvolt;
static const double joule = electronvolt/e_SI;// joule = 6.24150 e+12 * MeV
// symbols
static const double MeV = megaelectronvolt;
static const double eV = electronvolt;
static const double keV = kiloelectronvolt;
static const double GeV = gigaelectronvolt;
static const double TeV = teraelectronvolt;
static const double PeV = petaelectronvolt;
//
// Mass [E][T^2][L^-2]
//
static const double kilogram = joule*second*second/(meter*meter);
static const double gram = 1.e-3*kilogram;
static const double milligram = 1.e-3*gram;
// symbols
static const double kg = kilogram;
static const double g = gram;
static const double mg = milligram;
//
// Power [E][T^-1]
//
static const double watt = joule/second;// watt = 6.24150 e+3 * MeV/ns
//
// Force [E][L^-1]
//
static const double newton = joule/meter;// newton = 6.24150 e+9 * MeV/mm
//
// Pressure [E][L^-3]
//
#define pascal hep_pascal // a trick to avoid warnings
static const double hep_pascal = newton/m2; // pascal = 6.24150 e+3 * MeV/mm3
static const double bar = 100000*pascal; // bar = 6.24150 e+8 * MeV/mm3
static const double atmosphere = 101325*pascal; // atm = 6.32420 e+8 * MeV/mm3
//
// Electric current [Q][T^-1]
//
static const double ampere = coulomb/second; // ampere = 6.24150 e+9 * eplus/ns
static const double milliampere = 1.e-3*ampere;
static const double microampere = 1.e-6*ampere;
static const double nanoampere = 1.e-9*ampere;
//
// Electric potential [E][Q^-1]
//
static const double megavolt = megaelectronvolt/eplus;
static const double kilovolt = 1.e-3*megavolt;
static const double volt = 1.e-6*megavolt;
//
// Electric resistance [E][T][Q^-2]
//
static const double ohm = volt/ampere;// ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
//
// Electric capacitance [Q^2][E^-1]
//
static const double farad = coulomb/volt;// farad = 6.24150e+24 * eplus/Megavolt
static const double millifarad = 1.e-3*farad;
static const double microfarad = 1.e-6*farad;
static const double nanofarad = 1.e-9*farad;
static const double picofarad = 1.e-12*farad;
//
// Magnetic Flux [T][E][Q^-1]
//
static const double weber = volt*second;// weber = 1000*megavolt*ns
//
// Magnetic Field [T][E][Q^-1][L^-2]
//
static const double tesla = volt*second/meter2;// tesla =0.001*megavolt*ns/mm2
static const double gauss = 1.e-4*tesla;
static const double kilogauss = 1.e-1*tesla;
//
// Inductance [T^2][E][Q^-2]
//
static const double henry = weber/ampere;// henry = 1.60217e-7*MeV*(ns/eplus)**2
//
// Temperature
//
static const double kelvin = 1.;
//
// Amount of substance
//
static const double mole = 1.;
//
// Activity [T^-1]
//
static const double becquerel = 1./second ;
static const double curie = 3.7e+10 * becquerel;
static const double kilobecquerel = 1.e+3*becquerel;
static const double megabecquerel = 1.e+6*becquerel;
static const double gigabecquerel = 1.e+9*becquerel;
static const double millicurie = 1.e-3*curie;
static const double microcurie = 1.e-6*curie;
static const double Bq = becquerel;
static const double kBq = kilobecquerel;
static const double MBq = megabecquerel;
static const double GBq = gigabecquerel;
static const double Ci = curie;
static const double mCi = millicurie;
static const double uCi = microcurie;
//
// Absorbed dose [L^2][T^-2]
//
static const double gray = joule/kilogram ;
static const double kilogray = 1.e+3*gray;
static const double milligray = 1.e-3*gray;
static const double microgray = 1.e-6*gray;
//
// Luminous intensity [I]
//
static const double candela = 1.;
//
// Luminous flux [I]
//
static const double lumen = candela*steradian;
//
// Illuminance [I][L^-2]
//
static const double lux = lumen/meter2;
//
// Miscellaneous
//
static const double perCent = 0.01 ;
static const double perThousand = 0.001;
static const double perMillion = 0.000001;
} // namespace gastpc
#endif /* GASTPC_SYSTEM_OF_UNITS_H */
|
9b32f81ddc7f49031a71faf6a94caa9cac5946f7 | 32a19d4c98655ff010dc54b14ebe35ca8fc6d3e8 | /headers/server.hpp | 66801d567d24e09ed7f7f885305732866f562fa1 | [
"MIT"
] | permissive | DynasticSponge/frederick2 | 977ab70d45d6f5afa692fabe8fc9da07b93f16cc | 410ad4a3ca43547d645248e13d27497e6c5b5f26 | refs/heads/master | 2022-04-27T20:19:11.497924 | 2020-05-04T18:25:55 | 2020-05-04T18:25:55 | 256,024,966 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,593 | hpp | server.hpp | //
// server.hpp
// ~~~~~~~~~~
//
// Author: Joseph Adomatis
// Copyright (c) 2020 Joseph R Adomatis (joseph dot adomatis at gmail dot com)
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef SERVER_HPP
#define SERVER_HPP
#include <future>
#include <openssl/ssl.h>
#include <string>
#include <vector>
#include "frederick2_namespace.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
#include "server_connection.hpp"
class frederick2::httpServer::httpServer
{
public:
explicit httpServer();
httpServer(const httpServer&) = delete;
httpServer& operator= (const httpServer&) = delete;
frederick2::httpServer::resource* getResourceTree();
bool runServer(std::future<void>);
void setBindAddress(const std::string&);
void setBindPort(int);
void setConnectionTimeout(size_t);
void setListenQueue(int);
void setSSLPrivateKey(const std::string&);
void setSSLPublicCert(const std::string&);
void setUseSSL(bool);
bool start();
void stop();
~httpServer();
protected:
private:
///////////////////////////////////////////////////////////////////////////////
// Friend Declarations
///////////////////////////////////////////////////////////////////////////////
friend class frederick2::httpServer::connection;
///////////////////////////////////////////////////////////////////////////////
// Private Functions
///////////////////////////////////////////////////////////////////////////////
void destroyOpenSSL();
frederick2::httpPacket::httpResponse *handleRequest(frederick2::httpPacket::httpRequest*);
void initializeOpenSSL();
frederick2::httpServer::resource *lookupResource(frederick2::httpPacket::httpRequest*);
///////////////////////////////////////////////////////////////////////////////
// Private Properties
///////////////////////////////////////////////////////////////////////////////
bool didAsyncStart;
bool hasBindAddr;
bool hasBindPort;
bool hasListenQueue;
bool hasSSLCert;
bool hasSSLKey;
bool useSSL;
bool runningWithSSL;
int bindPort;
int listenQueue;
size_t connectionTimeout;
SSL_CTX *sslContext;
std::string strBindAddr;
std::string sslCertPath;
std::string sslKeyPath;
std::future<bool> catchRunServer;
std::promise<void> killRunServer;
std::vector<std::future<bool>> childFutures;
std::vector<std::promise<void>> childPromises;
frederick2::httpServer::resource *rootResource;
};
#endif |
ff1fc24bbe46314be637c74ef9b6f5bf62d86080 | 0891020434f76cae9874afe98e671460a04bda4c | /Machine.cpp | 0bf98122de4e8ebd3ff191eac348d3258c83eae1 | [] | no_license | andrewSC/TuringSimulator | 1a6620a887e7fc3bc659de6714ebe093638700aa | f24bd9bbe8b2c0fc22c60d44262fd84d90f03be8 | refs/heads/master | 2016-09-10T00:42:41.629576 | 2012-08-11T08:27:31 | 2012-08-11T08:27:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,813 | cpp | Machine.cpp | #include <stdio.h>
#include <wchar.h>
#include <locale.h>
#include "Machine.h"
#include "ExampleConfig.h"
Machine::Machine(){}
void Machine::processTape(vector<char> tape) {//magic happens here
int currentStateIndex = 0; //we start on one so we don't fail hella fast sitting on a blank character
string currentState = "";
bool halted = false;
int iterationCounter = 1;
ExampleConfig tmConfig;
currentState = (tmConfig.getSetOfStates())[0]; //get the initial state from the example configuration
while (!halted) {
char tapeCharacter = tape[currentStateIndex];
if (currentState.compare(tmConfig.getAcceptState()) == 0) {
halted = true;
tape.push_back('\a');//a little hacky but valid
printTape(tape, iterationCounter, currentStateIndex, currentState);
} else if (currentState.compare(tmConfig.getRejectState()) == 0) {
halted = true;
tape.push_back('\a');//hax
printTape(tape, iterationCounter, currentStateIndex, currentState);
} else {
TransitionFunction* transFunc = tmConfig.getTransitionFunction(currentState, tapeCharacter);
if ( transFunc != NULL ) {//ayuup, we found the Transition function goods
printTape(tape, iterationCounter, currentStateIndex, currentState);
if ((transFunc->writeSymbol) != '\a') {//blank character's don't write ish
tape[currentStateIndex] = transFunc->writeSymbol;
}
switch (transFunc->headDirection) {
case LEFT:
currentStateIndex--; //go backwards on the tape
break;
case RIGHT:
currentStateIndex++; //go forwards on the tape
break;
}
currentState = transFunc->nextState;//hey, I just met you, and this is crazy, but can this next state be accept, maybe?
} else { // oh crap, we're here because given the current state and tape character, there are no transitions to other states. #rejected
halted = true;
printTape(tape, iterationCounter, currentStateIndex, tmConfig.getRejectState());
}
}
iterationCounter++;
}
}
void Machine::printTape(vector<char> tape, int iterationCounter, int stateIndex, string state) {
printf("%i: ", iterationCounter);
for (int i = 0; i < tape.size(); i++) {
if (i == stateIndex) {
printf("%s ", state.c_str());
} else if (tape[i] == '\a') {
cout <<"\u266c" << " "; //lolwut
} else {
printf("%c ", tape[i]);
}
}
printf("\n");
}
|
ccf4ecd2940d67cb531833d2d9bafcb439d10696 | 9af573d8ba51961af8a58ca8bdbaecdedb104f9e | /InterviewSmallProbs/pointers1.cpp | ae09abf579fc26e16c1d85987537679d1d341edc | [] | no_license | ec-enggshivam/CPPWork | 70d32d0e66fb0a871d8fb385ed798cd7642662c3 | d0516a6fd8b3f52b086909e8f6b0c7da8a1e4e7f | refs/heads/master | 2022-06-01T09:52:46.395541 | 2022-05-16T15:19:54 | 2022-05-16T15:19:54 | 211,589,692 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 324 | cpp | pointers1.cpp | #include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int x = 20, *y, *z;
// Assume address of x is 500 and
// integer is 4 byte size
y = &x;
z = y;
printf("y= %d\nz= %d\n", y,z);
*y++;
*z++;
x++;
printf("x = %d, y = %d, z = %d \n", x, y, z);
return 0;
}
|
9ab2a3ee82e0eba7492357fc7657b245a5902804 | 0e303aeb2cb77033270d23962ad13cb7ea1c7253 | /Test.cpp | 4fd136f6f128ff570c55326ae62aa0e6f5af3f42 | [] | no_license | zhra2zaid/Phonetic-search-B | 22eb8593476d426f5322900eabbf697af3548e2d | 2570cca4a14c96c1aee80d86963a472201d09345 | refs/heads/master | 2021-05-18T18:26:11.815008 | 2020-03-30T16:09:11 | 2020-03-30T16:09:11 | 251,358,803 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,704 | cpp | Test.cpp | #include "doctest.h"
#include "PhoneticFinder.hpp"
using namespace phonetic;
#include <string>
using namespace std;
TEST_CASE("Test replacement of p and b and f,also lower-case and upper-case") {
string text = "xxx happy yyy";
CHECK(find(text, "hafpy") == string("happy"));
CHECK(find(text, "hapfy") == string("happy"));
CHECK(find(text, "habby") == string("happy"));
CHECK(find(text, "hapby") == string("happy"));
CHECK(find(text, "habpy") == string("happy"));
CHECK(find(text, "Habpy") == string("happy"));
CHECK(find(text, "habpY") == string("happy"));
}
TEST_CASE("Test replacement of g and j,also lower-case and upper-case") {
string text = "xxx good jop yyy";
CHECK(find(text, "good") == string("good"));
CHECK(find(text, "gooD") == string("good"));
CHECK(find(text, "Good") == string("good"));
CHECK(find(text, "jop") == string("jop"));
CHECK(find(text, "Jop") == string("jop"));
CHECK(find(text, "jood") == string("good"));
CHECK(find(text, "gop") == string("jop"));
}
TEST_CASE("Test replacement of c and k and q,also lower-case and upper-case") {
string text = "cat queen kind";
CHECK(find(text, "cat") == string("cat"));
CHECK(find(text, "cAt") == string("cat"));
CHECK(find(text, "qat") == string("cat"));
CHECK(find(text, "kat") == string("cat"));
CHECK(find(text, "queen") == string("queen"));
CHECK(find(text, "queEn") == string("queen"));
CHECK(find(text, "qUeen") == string("queen"));
CHECK(find(text, "Queen") == string("queen"));
CHECK(find(text, "cueen") == string("queen"));
CHECK(find(text, "kueen") == string("queen"));
CHECK(find(text, "kind") == string("kind"));
CHECK(find(text, "Kind") == string("kind"));
CHECK(find(text, "kiNd") == string("kind"));
CHECK(find(text, "kinD") == string("kind"));
CHECK(find(text, "cind") == string("kind"));
CHECK(find(text, "qind") == string("kind"));
}
TEST_CASE("Test replacement of s and z,also lower-case and upper-case") {
string text = "the suspect was eating pizza"
CHECK(find(text, "suspect") == string("suspect"));
CHECK(find(text, "SuSbEcT") == string("suspect"));
CHECK(find(text, "zozbekt") == string("suspect"));
CHECK(find(text, "SUSPECT") == string("suspect"));
CHECK(find(text, "Vaz") == string("was"));
CHECK(find(text, "Was") == string("was"));
CHECK(find(text, "wAZ") == string("was"));
CHECK(find(text, "BiZza") == string("pizza"));
CHECK(find(text, "bissa") == string("pizza"));
CHECK(find(text, "PyzZa") == string("pizza"));
CHECK(find(text, "PIZZA") == string("pizza"));
}
TEST_CASE("Test replacement of d and t,also lower-case and upper-case") {
string text = "i didnt mean that";
CHECK(find(text, "didnd") == string("didnt"));
CHECK(find(text, "Didnt") == string("didnt"));
CHECK(find(text, "tidnt") == string("didnt"));
CHECK(find(text, "Tidnt") == string("didnt"));
CHECK(find(text, "that") == string("that"));
CHECK(find(text, "dhat") == string("that"));
CHECK(find(text, "Dhad") == string("that"));
CHECK(find(text, "thad") == string("that"));
CHECK(find(text, "That") == string("that"));
}
TEST_CASE("Test replacement of o and u,also lower-case and upper-case") {
string text = "I found a flower by my house";
CHECK(find(text, "found") == string("found"));
CHECK(find(text, "fuund") == string("found"));
CHECK(find(text, "fOund") == string("found"));
CHECK(find(text, "foond") == string("found"));
CHECK(find(text, "foUnd") == string("found"));
CHECK(find(text, "flower") == string("flower"));
CHECK(find(text, "fluwer") == string("flower"));
CHECK(find(text, "flOwer") == string("flower"));
CHECK(find(text, "flUwer") == string("flower"));
CHECK(find(text, "house") == string("house"));
CHECK(find(text, "hOuse") == string("house"));
CHECK(find(text, "hoUse") == string("house"));
CHECK(find(text, "huuse") == string("house"));
CHECK(find(text, "hoOse") == string("house"));
CHECK(find(text, "hoose") == string("house"));
}
TEST_CASE("Test replacement of i and y,also lower-case and upper-case") {
string text = "get fit working out at the gym";
CHECK(find(text, "gYm") == string("gym"));
CHECK(find(text, "gim") == string("gym"));
CHECK(find(text, "gym") == string("gym"));
CHECK(find(text, "gIm") == string("gym"));
CHECK(find(text, "fIt") == string("fit"));
CHECK(find(text, "fyt") == string("fit"));
CHECK(find(text, "workyng") == string("working"));
CHECK(find(text, "working") == string("working"));
CHECK(find(text, "workYng") == string("working"));
}
TEST_CASE("Test capital letters") {
string text = "Test Capital Letters";
CHECK(find(text, "test") == string("Test"));
CHECK(find(text, "TEST") == string("Test"));
CHECK(find(text, "tesT") == string("Test"));
CHECK(find(text, "capital") == string("Capital"));
CHECK(find(text, "CAPITAL") == string("Capital"));
CHECK(find(text, "CapitaL") == string("Capital"));
CHECK(find(text, "letters") == string("Letters"));
CHECK(find(text, "LETTERS") == string("Letters"));
CHECK(find(text, "letTers") == string("Letters"));
}
TEST_CASE("Test rendom letters letters") {
string text = "VvvWn GggIgjjJ cCKkgq sSzSzf fjnGdDtrtT ounuUIO IyygyuYi";
CHECK(find(text, "VVvWn") == string("VvvWn"));
CHECK(find(text, "Vvvwn") == string("VvvWn"));
CHECK(find(text, "VwvWn") == string("VvvWn"));
CHECK(find(text, "WvvWn") == string("VvvWn"));
CHECK(find(text, "GggIggjJ") == string("GggIgjjJ"));
CHECK(find(text, "GgJIgjjJ") == string("GggIgjjJ"));
CHECK(find(text, "GjgIgjjJ") == string("GggIgjjJ"));
CHECK(find(text, "cCKkgq") == string("cCKkgq"));
CHECK(find(text, "ccKkgq") == string("cCKkgq"));
CHECK(find(text, "cCckgq") == string("cCKkgq"));
CHECK(find(text, "cCKqgq") == string("cCKkgq"));
CHECK(find(text, "kCKkgq") == string("cCKkgq"));
CHECK(find(text, "sSzSzf") == string("sSzSzf"));
CHECK(find(text, "sszSzf") == string("sSzSzf"));
CHECK(find(text, "sSsSzf") == string("sSzSzf"));
CHECK(find(text, "sSzzzf") == string("sSzSzf"));
CHECK(find(text, "fjnGdDtrdT") == string("fjnGdDtrtT"));
CHECK(find(text, "fjnGdDdrtT") == string("fjnGdDtrtT"));
CHECK(find(text, "fjnGdttrtT") == string("fjnGdDtrtT"));
CHECK(find(text, "fjnGtDtrtT") == string("fjnGdDtrtT"));
CHECK(find(text, "ounoUIO") == string("ounuUIO"));
CHECK(find(text, "uunuUIO") == string("ounuUIO"));
CHECK(find(text, "ounuUIu") == string("ounuUIO"));
CHECK(find(text, "ounuoIO") == string("ounuUIO"));
} |
99ca249b03149acd59823eaa6b21143a24536ed8 | 062f9aab20421f4b0ad21daaaf653e753fe4643e | /src/Command/src/Document/Items/ConstDocumentItem/ConstDocumentItem.hpp | ca0625b184c7c236977bcabf2741a37db62f0354 | [] | no_license | UsingCoding/ood | 5b12be32af55f3b58c8ed0b02b3914db9d7cf6ef | c1703bf7e97f82413975a9ae5ea36ed17e272a89 | refs/heads/master | 2023-02-19T12:40:28.171444 | 2021-01-20T08:17:22 | 2021-01-20T08:17:22 | 293,778,942 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 577 | hpp | ConstDocumentItem.hpp | #pragma once
#include <memory>
#include "../../Elements/Image/IImage.hpp"
#include "../../Elements/Paragraph/IParagraph.hpp"
class ConstDocumentItem
{
public:
ConstDocumentItem(
std::shared_ptr<IImage> image,
std::shared_ptr<IParagraph> paragraph
)
: m_image(image), m_paragraph(paragraph) {}
std::shared_ptr<const IImage> GetImage()const;
std::shared_ptr<const IParagraph> GetParagraph()const;
virtual ~ConstDocumentItem() = default;
protected:
std::shared_ptr<IImage> m_image;
std::shared_ptr<IParagraph> m_paragraph;
};
|
b47726e8deba8978d16ebd18ff74222d69d098f0 | 5e13159827f6ddd0a3b642481a63228d480e4b1e | /chap03/exercises/ex_3.25.cpp | a3bd6543be7dbb9277bab04ad1898027ad9af225 | [] | no_license | jxzhsiwuxie/cppPrimer | d3bf9c2e4faa7d83a8634ceb5d239e745aaba288 | 99105606ff826f29d58961ab4b921da3f3311bd3 | refs/heads/master | 2022-04-26T18:17:50.858241 | 2022-03-13T06:39:25 | 2022-03-13T06:39:25 | 233,590,715 | 4 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 977 | cpp | ex_3.25.cpp | //练习3.25:3.3.3 节划分分数段的程序是使用下标运算符实现的,请利用迭代器改写程序并实现完全相同的功能。
#include <iostream>
#include <vector>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;
int main()
{
vector<unsigned> scores(11, 0);
vector<string> grades{"0~9分", "10~19分", "20~29分", "30~39分", "40~49分", "50~59分", "60~69分", "70~79分", "80~89分", "90~99分", "100分"};
unsigned grade;
cout << "输入一组 0~100 的数字:" << endl;
while (cin >> grade)
{
if (grade <= 100)
{
auto it = scores.begin() + grade / 10;
++(*it);
}
}
auto it1 = scores.cbegin(), eit1 = scores.cend();
auto it2 = grades.cbegin();
while (it1 != eit1)
{
cout << *it2 << "分段的人数有 " << *it1 << " 人。" << endl;
++it1;
++it2;
}
return 0;
}
|
b4e3fff185f4e00d8a3ae194d0e1d71eccfd0f04 | 776f5892f1395bb8d30731a60466e4c756a44c8c | /contests/acl1/acl1_a/main.cc | 8329ae44c668d034ddf20bbc3cb00ffc0d423ab9 | [] | no_license | kkishi/atcoder | fae494af4b47a9f39f05e7536e93d5c4dd21555b | f21d22095699dbf064c0d084a5ce5a09a252dc6b | refs/heads/master | 2023-08-31T18:37:13.293499 | 2023-08-27T21:33:43 | 2023-08-27T21:33:43 | 264,760,383 | 0 | 0 | null | 2023-03-10T05:24:07 | 2020-05-17T21:30:14 | C++ | UTF-8 | C++ | false | false | 483 | cc | main.cc | #include <bits/stdc++.h>
#include "atcoder.h"
#include "disjoint_set.h"
void Main() {
ints(n);
V<pair<int, int>> xy(n);
rep(i, n) {
ints(x, y);
xy[x - 1] = {y, i};
}
DisjointSet ds(n);
stack<pair<int, int>> s;
for (auto [y, i] : xy) {
int miny = y;
while (!s.empty()) {
auto [ty, ti] = s.top();
if (ty > y) break;
s.pop();
chmin(miny, ty);
ds.Union(i, ti);
}
s.push({miny, i});
}
rep(i, n) wt(ds.Size(i));
}
|
18316cf3384b75bfcb06b8555e3daed8b903bd9d | 003fb5094021351eb82c49c8eadbb6dd5b139004 | /005_KOITP/DAY07/004_CONVEXHULL.cpp | 6416be43a1ad722aeed3c64bad8c61dcb35c8b9a | [] | no_license | woongbinni/algorithm | ebdb700195ccc158f7be1ebf7af06e9913d4e8fd | a1d5c0bc8b727d4feea670ea35218e701e0ffdb4 | refs/heads/master | 2022-11-16T23:40:44.628307 | 2022-11-11T15:21:26 | 2022-11-11T15:21:26 | 32,263,313 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,581 | cpp | 004_CONVEXHULL.cpp | /********************************************************************************
## 문제
2차원 평면에 N개의 점이 주어졌을 때, 이들 중 몇 개의 점을 골라 볼록 다각형을 만드는데, 나머지 모든 점을 내부에 포함하도록 할 수 있다. 이를 볼록 껍질 (Convex Hull) 이라 한다.
N개의 점이 주어질 때 볼록껍질을 이루는 점의 개수를 구하여라. 만약 볼록껍질을 이루는 한 선분에 3개 이상의 점이 포함된 경우, 양 끝점만을 센다.
## 입력
첫 번째 줄에 점의 개수 N이 주어진다. (3 ≤ N ≤ 100,000)
두 번째 줄부터 N개의 줄에 걸쳐 각 점의 좌표를 의미하는 두 정수 x, y가 공백으로 분리되어 주어진다. (-40,000 ≤ x, y ≤ 40,000) 각 점은 모두 다른 위치에 있으며, 모든 점이 한 직선위에 있는 경우는 없다.
## 출력
첫 번째 줄에 볼록껍질을 이루는 점의 개수를 출력한다.
## 예제 입력
8
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
## 예제 출력
5
********************************************************************************/
#include <stdio.h>
#include <cstdlib>
#include <list>
#include <algorithm>
using namespace std;
typedef struct _point {
int idx;
long long x;
long long y;
} point;
int N;
point points[100001];
list<point> hull_stack;
int calc_ccw(point a, point b, point c) {
long long ccw = (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);
if (ccw > 0) return 1;
if (ccw < 0) return -1;
return 0;
}
int calc_angle(int i) {
list<point>::iterator iter = hull_stack.begin();
point c = points[i];
point b = *iter;
iter++;
point a = *iter;
return calc_ccw(a, b, c);
}
bool cmp(point b, point c) {
point a = points[0];
int ccw = calc_ccw(a, b, c);
if (ccw) {
return ccw > 0;
}
return abs((b.x - a.x) + (b.y - a.y)) < abs((c.x - a.x) + (c.y - a.y));
}
int main(void) {
scanf("%d", &N);
for (int i = 0; i < N; ++i) {
scanf("%lld%lld", &(points[i].x), &(points[i].y));
points[i].idx = i;
}
for (int i = 1; i < N; ++i) {
if (points[0].y > points[i].y || (points[0].y == points[i].y && points[0].x > points[i].x))
swap(points[0], points[i]);
}
sort(points + 1, points + N, cmp);
for (int i = 0; i < N; ++i) {
if (i < 1) {
hull_stack.push_front(points[i]);
}
else {
while (hull_stack.size() > 1 && calc_angle(i) <= 0) {
hull_stack.pop_front();
}
hull_stack.push_front(points[i]);
}
}
// while (calc_angle(0) < 0) {
// hull_stack.pop_front();
// }
printf("%lu\n", hull_stack.size());
return 0;
} |
e1a5a316faefa117300164a48a927974a9c1e00f | 28943136c1404c79260eb0b2694546885c65d5b9 | /src/Subsystems/LiftGrabber_Config.h | 9f4251ae7c9ba8e9b4f05c537388e0f83dc7341d | [] | no_license | 4329/Worlds2015-CPP | e0d26332266685e82778b775bc1bd0e1d84af195 | cf8616e9886c904c4e677242ced5eba19728c0d5 | refs/heads/master | 2021-03-12T22:15:48.615467 | 2015-04-19T05:25:06 | 2015-04-19T05:25:06 | 34,194,619 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 188 | h | LiftGrabber_Config.h | #ifndef LIFTGRABBERCONFIG_H
#define LIFTGRABBERCONFIG_H
class LiftGrabber_Config
{
public:
int LiftGrabber_PCMID;
int LiftGrabber_Solenoid;
bool LiftGrabber_ActiveIsClosed;
};
#endif
|
6acc302dfeb34cb44b2c48a39c9495b68445c27f | 8952710ed714f672413418d35f35dad5ce9c404e | /prslc/Parser.cpp | 776202b7c25d295b9165353ed72c7a98ecd1837a | [
"BSD-2-Clause"
] | permissive | fromasmtodisasm/parasol | c61f6bbfcd6416dc6a912ff7a2fa13bb780934d9 | b48ad12aa98f9e7dc35b6ee4b339420ed2010ede | refs/heads/master | 2023-04-03T12:44:18.554170 | 2021-04-15T00:18:51 | 2021-04-15T00:18:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,237 | cpp | Parser.cpp | //
// Created by ARJ on 9/5/15.
//
#include "Parser.h"
// these are all defined in prsl_grammar.c, as part of the lemon output.
void* PRSLParseAlloc(void *(*mallocProc)(size_t));
void PRSLParseFree(void *p, void (*freeProc)(void*));
void PRSLParse(void *yyp, int yymajor, PRSLToken yyminor, prsl::Parser *);
namespace prsl {
Parser::Parser() {
lemonParser = PRSLParseAlloc(malloc);
}
Parser::~Parser() {
PRSLParseFree(lemonParser, free);
}
void Parser::offerToken(PRSLToken token) {
currentToken = token;
PRSLParse(lemonParser, token.tokenType, token, this);
}
void Parser::error() {
std::cout << "Syntax error on line " << currentToken.line << ". Token type: " << currentToken.tokenType;
switch (currentToken.tokenType) {
case INT_LIT:
std::cout << " Value: " << currentToken.value.intValue;
break;
case FLOAT_LIT:
std::cout << " Value: " << currentToken.value.floatValue;
break;
case ID:
std::cout << " Value: " << getString(currentToken.value.stringIndex);
break;
default:
break;
}
std::cout << std::endl;
throw ParseError("Parse error.");
}
void Parser::success() {
std::cout << "Parse successful." << std::endl;
}
void Parser::pushAST(ast::NodeList *globals) {
this->globals = globals;
}
}
|
9e2d7bb112ccf0fc18efc0e0b5bb073d46d7eded | 642c41d3d64a5cd01c48b85f8ce9cd3fd541a6d5 | /icpc_7425.cpp | 69572da33b853b1697a318c759a8251fd472e91a | [] | no_license | YuvalFreund/CompetionalPrograming | abf1a78dfeb6f0d5ca381bc03b47b897ef193f73 | aacc2095816b5df316dc0d4c6e4c4fe74e9e58d7 | refs/heads/master | 2020-07-01T06:54:30.446637 | 2019-08-07T17:34:49 | 2019-08-07T17:34:49 | 201,081,579 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,868 | cpp | icpc_7425.cpp | #include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
typedef vector<vector<int>> vvi;
struct Point
{
int x;
int y;
Point(int x,int y):x(x),y(y){}
};
// Given three colinear points p, q, r, the function checks if
// point q lies on line segment 'pr'
bool onSegment(Point p, Point q, Point r)
{
if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) &&
q.y <= max(p.y, r.y) && q.y >= min(p.y, r.y))
return true;
return false;
}
// To find orientation of ordered triplet (p, q, r).
// The function returns following values
// 0 --> p, q and r are colinear
// 1 --> Clockwise
// 2 --> Counterclockwise
int orientation(Point p, Point q, Point r)
{
// See https://www.geeksforgeeks.org/orientation-3-ordered-points/
// for details of below formula.
int val = (q.y - p.y) * (r.x - q.x) -
(q.x - p.x) * (r.y - q.y);
if (val == 0) return 0; // colinear
return (val > 0)? 1: 2; // clock or counterclock wise
}
// The main function that returns true if line segment 'p1q1'
// and 'p2q2' intersect.
bool doIntersect(Point p1, Point q1, Point p2, Point q2)
{
// Find the four orientations needed for general and
// special cases
int o1 = orientation(p1, q1, p2);
int o2 = orientation(p1, q1, q2);
int o3 = orientation(p2, q2, p1);
int o4 = orientation(p2, q2, q1);
// General case
if (o1 != o2 && o3 != o4)
return true;
// Special Cases
// p1, q1 and p2 are colinear and p2 lies on segment p1q1
if (o1 == 0 && onSegment(p1, p2, q1)) return true;
// p1, q1 and q2 are colinear and q2 lies on segment p1q1
if (o2 == 0 && onSegment(p1, q2, q1)) return true;
// p2, q2 and p1 are colinear and p1 lies on segment p2q2
if (o3 == 0 && onSegment(p2, p1, q2)) return true;
// p2, q2 and q1 are colinear and q1 lies on segment p2q2
if (o4 == 0 && onSegment(p2, q1, q2)) return true;
return false; // Doesn't fall in any of the above cases
}
void bfs(const vvi& g, int s,vector<int> &dis) {
queue<int> q;
q.push(s);
vector<bool> visible (g.size(),false);
visible[s]=true;
dis[0]=0;
while (!q.empty()) {
int u = q.front();
q.pop();
for (int v : g[u]) {
if (!visible[v]) {
visible[v] = true;
q.push(v);
dis[v]=dis[u]+1;
}
}
}
}
bool isBipartite(vvi & graph , vector<int> &dis){
for (int i = 0; i < graph.size(); ++i) {
for(auto &x :graph[i]){
if(dis[i]%2 ==dis[x]%2) return false;
}
}
return true;
}
int main()
{
int w,p,s,x,y;
while(cin>>w>>p){
vvi graph(p);
vector<Point> wells;
vector<pair<Point,Point>> pipe;
for (int i = 0; i < w; ++i) {
cin>>x>>y;
wells.push_back(Point(x,y));
}
for (int i = 0; i < p; ++i) {
cin>>s>>x>>y;
pipe.push_back(make_pair(wells[s-1],Point(x,y)));
}
for (int i = 0; i <pipe.size() ; ++i) {
for (int j = i+1; j <pipe.size(); ++j) {
if(!(pipe[i].first.x == pipe[j].first.x && pipe[i].first.y == pipe[j].first.y)){
if(doIntersect(pipe[i].first,pipe[i].second,pipe[j].first,pipe[j].second)){
graph[i].push_back(j);
graph[j].push_back(i);
}
}
}
}
vector<int> dis(graph.size(),-1);
for (int i = 0; i < graph.size(); ++i) {
if(dis[i]==-1) bfs(graph,i,dis);
}
if(!isBipartite(graph,dis)) cout<<"impossible\n";
else cout<<"possible\n";
}
return 0;
}
/*
3 3
0 0
0 2
2 0
1 2 3
2 2 2
3 0 3
2 3
0 0
0 10
1 5 15
1 2 15
2 10 10
*/
|
139be60204009d93283945a0b9d7bfc7fb3ff918 | 8480785bf7c04987e0f97928abfe965455cc49d2 | /searching_geometry.cpp | c47372a74e44add3f9c7df8d70e794efd749d1c2 | [
"MIT"
] | permissive | yaolq/kernelsim | a4b89d98604516436a6247212cb9fdbbf340bf6c | 1e450a6e9cbec4639a6fe5163179d46db80777a7 | refs/heads/master | 2022-12-11T04:20:10.844496 | 2020-08-20T13:41:21 | 2020-08-20T13:41:21 | 285,964,786 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,631 | cpp | searching_geometry.cpp | #include "searching_geometry.h"
#include <iomanip>
std::ostream& operator<< (std::ostream &out, const octant_2D_table &tbl)
{
int dim = (int)(tbl.radius_ / tbl.cell_size_ + 0.5);
int i = 0;
int j = 0;
for (int y = dim; y >= -dim; --y) {
j = y + dim;
for (int x = -dim; x <= dim; ++x)
{
i = x + dim;
if (tbl.table_[j*(2 * dim + 1) + i] == -1)
out << std::setw(5) << ' ';
else
out << std::setw(5) << tbl.table_[j*(2 * dim + 1) + i];
}
out << std::endl;
}
return out;
}
bool octant_2D_filter::is_admissible( const Geovalue& neigh, const Geovalue& center)
{
typedef Geovalue::location_type location_type;
typedef location_type::difference_type Euclidean_vector;
//Get the directional lag for each canditate point inside the neighborhood
Euclidean_vector diff = neigh.location() - center.location();
if (diff.x()*diff.x() + diff.y()*diff.y() <= radius_exclu_*radius_exclu_)
{
return false;
}
//Get the sector number based on the lag.
int sect = oct_table_.sector(diff.x(), diff.y());
//If not sector number is found, it means that the point is not eligible to be a conditioning data
if (sect == -1)
return false;
//The candidate is found in a valid zone for the first time
//We need to store the sequence number of the conditioning data which increases as the number of
//conditioning data that already exist. The sequence number should be propagated also to the adjacent
//zones of the current zone so that the successive points would not overlap with the current zone.
//Since the list of candidate points are sorted increasingly according to their distances to the center node,
//here we don't need to maintain the list of points fallen in the same zone for comparing the closeness to the
//center node.
if(sectors_[sect] == -1){
//Record the sequence number
//Propagate the sequence no is easy in 2D situation, which are the sequence_no +/- 1
//the current zone is 24*n, then the adjacent would be 24n + 23 other than sect-1, otherwise, the adjacent zone is (sect - 1).
int adj_sect_dec = sect % 24 == 0 ? 23 + sect : sect - 1;
//The similar happens to the end of the ring for increment 1 of the sequence No.
int adj_sect_inc = (sect+1) % 24 == 0 ? sect - 23 : sect + 1;
sectors_[adj_sect_dec] = sequence_no_;
sectors_[sect] = sequence_no_; // informed_sectors_.size();//1
sectors_[adj_sect_inc] = sequence_no_;
//Store the adjacent zones that already get informed for later restoration
informed_sectors_.push_back(adj_sect_dec);
informed_sectors_.push_back(sect);
informed_sectors_.push_back(adj_sect_inc);
++ sequence_no_;
return true;
}
else{
return false;
}
//return diff*diff > lag_tol_*lag_tol_;
}
void octant_2D_filter::clear()
{
for(int i = 0; i < informed_sectors_.size(); ++ i)
{
sectors_[informed_sectors_[i]] = -1;
}
informed_sectors_.clear();
sequence_no_ = 0;
}
//Match the node from the data event to the replicate from the sample data
int octant_2D_filter::match(double x, double y, double z)
{
int sect = oct_table_.sector(x, y);
if(sect != -1)
return sectors_[sect];
return -1;
}
double octant_2D_filter::search_radius()
{
return oct_table_.radius();
}
bool search_filter::is_admissible(const Geovalue& neigh, const Geovalue& center)
{
typedef Geovalue::location_type location_type;
typedef location_type::difference_type Euclidean_vector;
//Get the directional lag for each canditate point inside the neighborhood
Euclidean_vector v = neigh.location() - center.location();
//update the admissible list of neighbor points
geoms_.push_back(v);
return true;
}
int search_filter::match(int nid, int sz, GsTLGridVector& v, std::list<matching_info>& matchings)
{
int matched = 0;
if (sz <= 0)
sz = geoms_.size();
for (int ind = 0; ind < sz; ++ind)
{
//int ind = *iter;
double l = 0;
double d = 0;
double a = 0;
for (int i = 0; i < GsTLGridVector::dimension; ++i)
{
//The reference lag
a += geoms_[ind][i] * geoms_[ind][i];
//
l += v[i] * geoms_[ind][i];
//The candidate lag
d += v[i] * v[i];
}
double la = std::sqrt(a);
//keep the inner part for the TI training
//if (la < lag_tol_)
// continue;
double l_proj = l / la;
//out of the range of the lag tolerance
if (l_proj < la - lag_tol_ || l_proj > la + lag_tol_)
{
continue;
}
double l_perp = std::sqrt(d - l_proj * l_proj);
double db = std::sqrt(d) * std::sin(angle_tol_);
double band = db <= l_perp ? db : l_perp;
//out of the range of the bandwidth
if (l_perp > band)
{
continue;
}
double dist = 0;
for (int i = 0; i < GsTLGridVector::dimension; ++i) {
//Get the distance between the candidate and the matched position
dist += (v[i] - geoms_[ind][i])*(v[i] - geoms_[ind][i]);
}
matching_info info;
info.visiting_id = matchings.size();
info.node_id = nid;
//Changed to ind + 1 to include the center node. 2020-03-22
info.matched_id = ind + 1;
info.matched_distance = dist;
//sorting the list of matchings increasingly by the distance
std::list<matching_info>::iterator iter_mat = matchings.begin();
while (iter_mat != matchings.end())
{
d = (*iter_mat).matched_distance;
if (dist <= d)
break;
++iter_mat;
}
matchings.insert(iter_mat, info);
++matched;
//sorting by the distance is done
}
return matched;
}
void search_filter::clear()
{
geoms_.clear();
} |
68e6b9a9f4cbdfefe53498051e03b8d74615a39f | d287ed8bdb566b25b5e5fed9d635cb68a3687a88 | /rmf_traffic_ros2/src/rmf_traffic_ros2/schedule/YamlLogger.cpp | 623e8e6e092d54a593622af1f2db98babbc6b23b | [
"Apache-2.0"
] | permissive | jian-dong/rmf_ros2 | 3ebff8e2ff9e059b56baa59e21da4bbd1e596bfd | 87ce942d534b24da202c77efea5daf0fce47fe25 | refs/heads/main | 2023-07-20T07:28:20.357865 | 2021-09-02T06:34:01 | 2021-09-02T06:34:01 | 404,021,430 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,854 | cpp | YamlLogger.cpp | /*
* Copyright (C) 2020 Open Source Robotics Foundation
*
* 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 <rmf_traffic_ros2/schedule/ParticipantRegistry.hpp>
#include <filesystem>
#include <fstream>
#include <mutex>
#include "internal_YamlSerialization.hpp"
namespace rmf_traffic_ros2 {
namespace schedule {
class YamlLogger::Implementation
{
public:
//===========================================================================
Implementation(std::string file_path)
: _file_path(file_path)
{
_counter = 0;
if (!std::filesystem::exists(file_path))
{
std::filesystem::create_directories(
std::filesystem::absolute(file_path).parent_path());
_initial_buffer_size = 0;
return;
}
std::lock_guard<std::mutex> file_lock(_mutex);
_buffer = YAML::LoadFile(file_path);
if (!_buffer.IsSequence())
{
//Malformatted YAML. Failing so that we don't corrupt data
throw YAML::ParserException(_buffer.Mark(),
"Malformatted file - Expected the root format of the"\
" document to be a yaml sequence");
}
_initial_buffer_size = _buffer.size();
}
//=========================================================================
void write_operation(AtomicOperation operation)
{
std::string uuid = operation.description.name()
+ operation.description.owner();
std::lock_guard<std::mutex> file_lock(_mutex);
if (operation.operation == AtomicOperation::OpType::Update)
{
auto index = _name_to_index[uuid];
AtomicOperation op {
AtomicOperation::OpType::Add,
operation.description
};
_buffer[index] = serialize(op);
}
else if (operation.operation == AtomicOperation::OpType::Add)
{
auto index = _buffer.size();
_name_to_index[uuid] = index;
_buffer.push_back(serialize(operation));
}
std::ofstream file(_file_path);
file << _buffer;
}
//===========================================================================
std::optional<AtomicOperation> read_next_record()
{
if (_counter >= _initial_buffer_size)
{
//We have reached the end of the file, restoration is complete.
return std::nullopt;
}
auto operation = atomic_operation(_buffer[_counter]);
std::string uuid = operation.description.name() +
operation.description.owner();
_name_to_index[uuid] = _counter;
++_counter;
return operation;
}
private:
YAML::Node _buffer; // used when loading the file
std::size_t _initial_buffer_size;
std::unordered_map<std::string, std::size_t> _name_to_index;
std::size_t _counter;
std::string _file_path;
std::mutex _mutex;
};
//=============================================================================
YamlLogger::YamlLogger(std::string file_path)
: _pimpl(rmf_utils::make_unique_impl<Implementation>(file_path))
{
// Do nothing
}
//=============================================================================
void YamlLogger::write_operation(AtomicOperation operation)
{
_pimpl->write_operation(operation);
}
//=============================================================================
std::optional<AtomicOperation> YamlLogger::read_next_record()
{
return _pimpl->read_next_record();
}
} // namespace schedule
} // namespace rmf_traffic_ros2
|
d895eb2d354e83e3a222eec3c1a0cc76f46c4938 | 8137a9d5cd89c18a3bc05736518bbb7202e75511 | /good/17_tools_for_larger_programs/c++_primer_4_17/c++_primer_4_17/main.cpp | 34faedb855080a714796b548dbcc952af105ba62 | [] | no_license | sunyongjie1984/cpp4 | 31db02f49ac26c3c6085c90d6d07e19ef43aa1cc | 8a1c8b881d4f0c0cc80e1fa6e322405a0e839f5e | refs/heads/master | 2021-06-15T03:16:51.554341 | 2021-02-07T08:21:19 | 2021-02-07T08:21:19 | 84,137,640 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 947 | cpp | main.cpp | #include <iostream> // standard library
#include "bookexcept.h" // user difine header
#include "Sales_item.h"
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
void process(double) { } // 这个函数是干什么的?
int main()
{
// use hypothetical bookstore exceptions
Sales_item item1;
Sales_item item2;
Sales_item sum;
// read two transactions
while (cin >> item1 >> item2)
{
try
{
sum = item1 + item2; // calculate their sum
cout << sum << endl; // use sum
}
catch (isbn_mismatch const &e) // runtime_error和logical_error都有what这个成员
{
cerr << e.what() << ": left isbn(" << e.left
<< ") right isbn(" << e.right << ")" << endl;
}
catch (...)
{
cerr << "exception unknown" << endl;
}
}
return 0;
} |
ec8cf47fb1d2d79dc3f96d467abe0a8ec6861744 | d51e6bdbcf75a9b7f8195b79a4bfe20feeb845c0 | /Skin.h | caccc67a919d2418357bde13b3d08844368b41f5 | [] | no_license | anthonytchen/LC_DPK | 8a60ef23f5978ff67374d3331e1d2ceee7c0f8aa | d0db31b703157084d7b87a0715509c041b49a34a | refs/heads/master | 2020-04-12T15:27:44.908445 | 2017-01-24T15:52:29 | 2017-01-24T15:52:29 | 32,207,143 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 5,089 | h | Skin.h | #ifndef _H_SKIN_
#define _H_SKIN_
#include "Chemical.h"
#include "Config.h"
#include "Vehicle.h"
#include "SurSebum.h"
//#include "Sebum.h"
#include "StraCorn.h"
#include "ViaEpd.h"
#include "Dermis.h"
#include "Blood.h"
struct Reaction
{
int idx_substrate, idx_product; // the index pointing to the objects in Chemical array
double Vmax, Km; // model parameters
};
struct CompIdx
{
CompType type;
Comp **pComp;
};
class Skin
{
public:
double *m_concVehicleInit; // Initial concentration in the vehicle
double m_dz_dtheta, m_x_length, m_y_length, // the skin size in the z, x (verticle)
// and y (lateral) directions
m_x_length_ve; // the depth of viable epidermis
int m_dim_vh, m_dim_sc, m_dim_ve, m_dim_de, m_dim_bd, m_dim_sb_sur, m_dim_sb_har, m_dim_all;
int m_nChem; // No. of chemical species considered
double m_Vehicle_area; // The dimensions in m_gridVehicle is for the microscopic grid used for simulation.
// The actual vehicle application area is contained here.
bool m_bInfSrc,
m_b_has_blood; // whether has blood compartment
CoordSys m_coord_sys;
struct Reaction m_React;
/* The amount of mass in individual compartments, row dominating arrangement */
int m_n_amount;
double *m_amount;
/* The compartments */
Vehicle *m_Vehicle;
Sebum *m_Sebum;
SurSebum *m_SurSebum;
StraCorn *m_StraCorn;
ViaEpd *m_ViaEpd;
Dermis *m_Dermis;
Blood *m_Blood;
// the number of compartments in each type of compartment for each chemical species
int m_nVehicle, m_nSurSebum, m_nSebum, m_nStraCorn, m_nViaEpd, m_nDermis, m_nBlood;
int m_nxComp, m_nyComp;
CompIdx **m_CompIdx; // 2D array to contain the compartment matrix
public:
Skin(void) {};
~Skin(void) {};
void Init();
void InitReaction(int, int, double, double); // initialisation for reaction parameters
void Release();
// functions to create individual compartments
// they return end-of-compartment x and y coordinates (x_end_coord, y_end_coord)
// that can be passed to subsequent compartments
void createCompMatrix(int, int);
void releaseCompMatrix();
void createVH(const Chemical*, const double*, const double*, const double*, double, double, double, double, double, bool, BdyCondStr, double *x_end_coord, double *y_end_coord); // vehicle
void createSurSB(const Chemical*, double, double, double, double, int, int, BdyCondStr, double *x_end_coord, double *y_end_coord, int, Crystal, double, double, double, double); // surface sebum
void createSB(const Chemical*, double, double, double, double, int, int, BdyCondStr, double *x_end_coord, double *y_end_coord, int); // sebum
void createSC(const Chemical*, double, double, int, int, double, BdyCondStr, double *x_end_coord, double *y_end_coord); // stratum corneum
void createVE(const Chemical*, double, double, double, double, int, int, BdyCondStr, double *x_end_coord, double *y_end_coord); // viable epidermis
void createDE(const Chemical*, double, double, double, double, int, int, bool, BdyCondStr, double *x_end_coord, double *y_end_coord); // dermis
void createBD(const double*, const double*); // blood
// functions to link compartments
int getSizeBdyRight(int, int, int);
Comp* getConcBdyRight(const double [], int, int, int, int, double*);
int getSizeBdyDown(int, int, int);
Comp* getConcBdyDown(const double [], int, int, int, int, double*);
void diffuseMoL(double t_start, double t_end); // method of lines using CVODE solver
void resetVehicle(double[], double[], double[]); // reset vehicle concentration, partition coefficient, diffusivity
void removeVehicle();
double compCompartAmount();
void compFlux_2sc(double *flux);
void compFlux_sc2down(double *flux);
//void compFlux_ve2down(double *flux);
//void compFlux_de2down(double *flux);
// Functions needed for ODE solver
int compODE_dydt (double, const double[], double []);
void compReaction(); // add reaction with diffusion
// Functions needed for SUNDIALS' CVODE solver
static int static_cvODE (double, N_Vector, N_Vector, void *);
// I/O functions
// extracting information from stratum corneum
double getSCYlen();
int getNLayerXSc() { return m_StraCorn[0].m_n_layer_x; };
int getNGridsXSc() { return m_StraCorn[0].m_nx; };
int getNGridsYSc() { return m_StraCorn[0].m_ny; };
void get1DConcSC(double *ret, int dim_ret, int idx_chem=0);
void get1DCoordSC(double *ret, int dim_ret, int idx_chem=0);
void getGridsConc(double *ret, int dim_ret, int idx_chem=0);
void getLayersAmount(double *ret, int dim_ret, int idx_chem=0);
void displayGrids();
void saveGrids(bool, const char []);
void saveAmount(bool, const char []);
void getXCoord(double *coord_x, int dim);
void getYCoord(double *coord_y, int dim);
void saveCoord(const char [], const char []);
void setScProperties(double, double, double, double);
};
#endif
|
eb9fb5d6d4b5b39dfd58478ded10dc23c8ab88ef | 59c8dfedd4811ab321cf55609c35f4385bebe85a | /SCL20110318/SCL20110318/1930.cpp | 0033f40d23bda4ef9d003dcfda17474df755c97a | [] | no_license | codemonkeyhe/code | b09ad675e8c1c144342701ce3cf2844efefd769f | 2a5b84edac46daf40b6fc89e78ae8cfadfad3678 | refs/heads/master | 2020-04-02T18:05:59.956758 | 2019-07-11T11:41:00 | 2019-07-11T11:41:00 | 154,686,677 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 471 | cpp | 1930.cpp | #include<iostream>
using namespace std;
int main(void)
{
int t;
int n;
int num[100];
int min=0;
int minI=0;
int count=0;
cin>>t;
while(t>0)
{
--t;
cin>>n;
for(int i=0;i<n;i++)
cin>>num[i];
count=0;
for(int i=0;i<n-1;i++)
{
min=num[i];
minI=i;
for(int j=i+1;j<n;j++)
if(num[j]<min){
++count;
min=num[j];
minI=j;
}
swap(num[i],num[minI]);
}
cout<<count<<endl;
}
return 0;
} |
c52bca133b39c325169a72ae32238d16892058f3 | ea1b3cfc133e38922e585be750590553d0324e22 | /inc/processv1csvmsgimpl.h | ae2d5123d9e0b76e32b956913c972bd5d8574085 | [
"MIT"
] | permissive | leroythelegend/rough_idea_project_cars_cpp | 9739c20194bfe271c4f301b70a4dcf596ad372a8 | 6c303d5fffdc0477f2a74e57aa9e556c1e0784f0 | refs/heads/master | 2021-10-09T03:38:39.274883 | 2021-10-05T10:18:41 | 2021-10-05T10:18:41 | 174,885,936 | 1 | 0 | MIT | 2021-10-05T10:14:52 | 2019-03-10T21:56:03 | C++ | UTF-8 | C++ | false | false | 574 | h | processv1csvmsgimpl.h | #pragma once
#include "processv1csvimpl.h"
namespace pcars
{
class ProcessV1CSVMSGImpl : public ProcessV1CSVImpl
{
public:
ProcessV1CSVMSGImpl();
~ProcessV1CSVMSGImpl() override = default;
void updateTelemetry(Packet::Ptr &) override;
void writeCapturedTelemetryToCSV() override;
void updateCurrentLap() override;
void reset() override;
void clearTelemetry() override;
private:
float lastlaptime_;
bool neednextpackets_;
bool needlastlaptime_;
};
} // namespace pcars
|
ffe5b96de50b4355c75d50ed239ec4698899aa41 | 1cb36c33cfb87a902ab486e13402cf72185490db | /network/main.cpp | 9d3e3856e3b9a4c01ee1de26fb66c163f415c6c6 | [] | no_license | touchvision/leetcode | e6f5938b85108e6c5b9de54a1153e7ae8e0685d1 | 0b76324ff8b93563479f2583a9615c74d2aaf3b3 | refs/heads/master | 2020-05-21T18:17:49.491796 | 2020-05-16T10:25:47 | 2020-05-16T10:25:47 | 186,130,735 | 0 | 0 | null | 2019-05-11T13:07:52 | 2019-05-11T12:33:17 | null | UTF-8 | C++ | false | false | 94 | cpp | main.cpp | #include "inode.h"
int main()
{
Inode *tmp = new Inode;
delete tmp;
return 0;
}
|
d864238bcf591d375ee95e0dd0d5a3018c4be6f2 | 0c9ec2beacfdce8779b417e2cc87f41f0b8a2fd2 | /A1139 First Contact(30).cpp | a8871ca653ca12024723d4907f201d96b3d841eb | [
"MIT"
] | permissive | Bourbon-Whiskey/PAT-A | 9ad15d1a796d7e38b4c888015627ca66283cc6b8 | 40915d7c36077ad8fa4cbfdfe06f6cb50f152813 | refs/heads/master | 2020-04-20T11:20:07.935886 | 2019-02-13T00:49:10 | 2019-02-13T00:49:10 | 168,813,298 | 8 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,744 | cpp | A1139 First Contact(30).cpp | #include<cstdio>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
#define maxn 10010
char g[maxn];//male-1;female-0;
set<int> st;
int N,M,K;
vector<int> Friend[maxn];//friend with same gender
struct Pair{
int n1,n2;
};
vector<Pair> Pa;
bool cmp(Pair a,Pair b){
if(a.n1!=b.n1){
return a.n1<b.n1;
}else{
return a.n2<b.n2;
}
}
int Tonum(char a[]){
int num;
if(a[0]=='-'){
num=(a[1]-'0')*1000+(a[2]-'0')*100+(a[3]-'0')*10+(a[4]-'0');
}else{
num=(a[0]-'0')*1000+(a[1]-'0')*100+(a[2]-'0')*10+(a[3]-'0');
g[num]=1;
}
return num;
}
void Init(){
char a[10],b[10];
int A,B;
scanf("%d%d",&N,&M);
while(M--){
scanf("%s%s",a,b);
A=Tonum(a);
B=Tonum(b);
st.insert(10000*A+B);
st.insert(10000*B+A);
if(g[A]==g[B]){
Friend[A].push_back(B);
Friend[B].push_back(A);
}
}
scanf("%d",&K);
}
int Abs(int a){
return a<0?-a:a;
}
void Check(){
int A,B;
int i,j,m,n;
Pair temp;
scanf("%d%d",&A,&B);
A=Abs(A);
B=Abs(B);
Pa.clear();
for(i=0;i<Friend[A].size();i++){
m=Friend[A][i];
for(j=0;j<Friend[B].size();j++){
n=Friend[B][j];
if(m==B||n==A){
continue;
}
if(st.find(10000*m+n)!=st.end()){
temp.n1=m;
temp.n2=n;
Pa.push_back(temp);
}
}
}
printf("%d\n",Pa.size());
sort(Pa.begin(),Pa.end(),cmp);
for(i=0;i<Pa.size();i++){
printf("%04d %04d\n",Pa[i].n1,Pa[i].n2);
}
}
int main(){
Init();
while(K--){
Check();
}
return 0;
}
|
99006b0e7ddb2bce342e86124ffa08cdf0f50e2f | 046b01be8f29a186d7385ae3d7488d1c7727057f | /PnDC/main.cpp | b24fb4cd0cbe521627c0f598ded181f5b347755b | [] | no_license | Mortano/PnDC | cfab45912a948645b9cc2d486e105ac074dc09fe | c78738bf326aaf0d03605f29b55a9db7ab41e088 | refs/heads/master | 2021-01-11T04:10:01.521203 | 2016-10-20T12:23:29 | 2016-10-20T12:23:29 | 71,239,339 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,715 | cpp | main.cpp |
#include "Sorting.h"
#include "ParallelUtil.h"
#include <vector>
#include <random>
#include <numeric>
#include <iostream>
#include <numeric>
#include <chrono>
#include "RuntimeMeasurement.h"
auto RandomNumbers(size_t count)
{
static std::random_device s_rnd;
static std::uniform_int_distribution<size_t> s_distr(0, 1000);
std::vector<size_t> ret(count, 0);
std::generate(ret.begin(), ret.end(), [&]() { return s_distr(s_rnd); });
return ret;
}
template<typename T>
std::ostream& operator<<(std::ostream& stream, const std::vector<T>& vec)
{
stream << "[";
for(size_t idx = 0; idx < vec.size(); idx++)
{
if(idx != vec.size() - 1)
{
stream << vec[idx] << ", ";
}
else
{
stream << vec[idx];
}
}
stream << "]";
stream.flush();
return stream;
}
std::ostream& operator<<(std::ostream& stream, const rt::RuntimeStats& stats)
{
stream << "\tAvg.: [" << std::chrono::duration_cast<std::chrono::milliseconds>(stats._average).count() << " ms]\n";
stream << "\tWorst: [" << std::chrono::duration_cast<std::chrono::milliseconds>(stats._worst).count() << " ms]\n";
stream << "\tBest: [" << std::chrono::duration_cast<std::chrono::milliseconds>(stats._best).count() << " ms]\n";
stream << "\tCold cache time: [" << std::chrono::duration_cast<std::chrono::milliseconds>(stats._coldCacheTime).count() << " ms]\n";
stream.flush();
return stream;
}
size_t ParallelSum(const std::vector<size_t>& numbers)
{
return ParallelDivideAndConquer(
numbers, 8,
[](const std::vector<size_t>& vec, size_t chunks)
{
using Iter_t = decltype(vec.begin());
_ASSERT(chunks > 1);
auto elementsPerChunk = vec.size() / chunks;
std::vector<std::pair<Iter_t, Iter_t>> ret;
ret.reserve(chunks);
for(size_t idx = 0; idx < chunks - 1; idx++)
{
ret.push_back(std::make_pair(vec.begin() + (idx*elementsPerChunk), vec.begin() + ((idx + 1) * elementsPerChunk)));
}
ret.push_back(std::make_pair(vec.begin() + (chunks - 1)*elementsPerChunk, vec.end()));
return ret;
},
[](auto l, auto r) { return l + r; },
[](auto elem) { return std::accumulate(elem.first, elem.second, size_t{ 0 }); });
}
int main(int argc, char** argv)
{
constexpr size_t NumberCount = 1'000'000;
constexpr size_t Iterations = 500;
std::vector<std::vector<size_t>> rndNumbers;
std::generate_n(std::back_inserter(rndNumbers), Iterations, [=]() { return RandomNumbers(NumberCount); });
task::Initialize();
//auto sequentialSortStas = rt::CollectRuntimeStats([](auto& numbers)
// {
// SequentialSort(numbers.begin(), numbers.end());
// },
// [=]() { return RandomNumbers(NumberCount); },
// Iterations);
//auto parallelSortStats = rt::CollectRuntimeStats([&](auto& numbers)
// {
// ParallelSort<8>(numbers.begin(), numbers.end());
// },
// [=]() { return RandomNumbers(NumberCount); },
// Iterations);
auto taskSystemParallelSortStats = rt::CollectRuntimeStats([&](auto& numbers)
{
TaskSystemParallelSort(numbers.begin(), numbers.end());
},
[&]() mutable { auto ret = std::move(rndNumbers.back()); rndNumbers.pop_back(); return ret; },
Iterations);
//std::cout << "######## Sequential sort stats ########\n";
//std::cout << sequentialSortStas;
//std::cout << "######## Parallel sort stats ########\n";
//std::cout << parallelSortStats;
std::cout << "######## Parallel sort with task system stats ########\n";
std::cout << taskSystemParallelSortStats;
task::Shutdown();
getchar();
return 0;
} |
813326623e9f3fa0d50f0d48dc478765f36cb3f7 | cbf2b79ba74c6d284b3433f6754d6f5d65873cc5 | /algorithms/bow/lib/bowCV.cpp | d354f3a48599ba7709c5c9483bb384c925ee1754 | [
"LicenseRef-scancode-public-domain"
] | permissive | permikomnaskaltara/CVAC | d6f579bd682cf0f84cedec356bd588dd5342db8b | 068c69aec3351130d689d4f966d0715ab1f76958 | refs/heads/master | 2020-03-30T03:04:45.065266 | 2015-02-04T17:47:02 | 2015-02-04T17:47:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 33,202 | cpp | bowCV.cpp | /******************************************************************************
* CVAC Software Disclaimer
*
* This software was developed at the Naval Postgraduate School, Monterey, CA,
* by employees of the Federal Government in the course of their official duties.
* Pursuant to title 17 Section 105 of the United States Code this software
* is not subject to copyright protection and is in the public domain. It is
* an experimental system. The Naval Postgraduate School assumes no
* responsibility whatsoever for its use by other parties, and makes
* no guarantees, expressed or implied, about its quality, reliability,
* or any other characteristic.
* We would appreciate acknowledgement and a brief notification if the software
* is used.
*
* 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 notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above 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 Naval Postgraduate School, nor the name of
* the U.S. Government, 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 NAVAL POSTGRADUATE SCHOOL (NPS) 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 NPS OR THE U.S. 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.
*****************************************************************************/
/** Bag of Words style trainer and detector.
* K Lee, 2012, matz 2013
*/
#define DLL_EXPORT
#include "bowCV.h"
using namespace std;
using namespace cvac;
const string bowCV::BOW_VOC_FILE = "VOC_FILE";
const string bowCV::BOW_SVM_FILE = "SVM_FILE";
const string bowCV::BOW_DETECTOR_NAME = "FeatureType";
const string bowCV::BOW_EXTRACTOR_NAME = "DescriptorType";
const string bowCV::BOW_MATCHER_NAME = "MatcherType";
const string bowCV::BOW_NUM_WORDS = "NumWords";
const string bowCV::BOW_CLASS_WEIGHT = "ClassWeights";
const string bowCV::BOW_OPENCV_VERSION = "OPENCV_VERSION";
const string bowCV::BOW_ONECLASS_ID = "ONE-CLASS_ID";
const string bowCV::BOW_REJECT_CLASS_STRATEGY = "RejectClassStrategy";
const string bowCV::BOW_REJECT_CLASS_AS_MULTICLASS = "multiclass";
const string bowCV::BOW_REJECT_CLASS_IGNORE_SAMPLES = "ignore";
const string bowCV::BOW_REJECT_CLASS_AS_FIRST_STAGE = "stages";
bowCV* pLib = NULL;
bowCV::bowCV(MsgLogger* _msgLog)
{
flagTrain = false;
flagName = false;
flagOneClass = false;
flagClassWeight = true;
cntCluster = -1;
mInclassIDforOneClass = 1;
mOutclassIDforOneClass = 0;
dda = NULL;
cv::initModule_nonfree(); //it should be for using SIFT or SURF.
filenameVocabulary = "logTrain_Vocabulary.xml.gz";
filenameSVM = "logTrain_svm.xml.gz";
msgLogger = _msgLog;
}
bowCV::~bowCV()
{
vFilenameTrain.clear();
vClassIDTrain.clear();
vBoundX.clear();
vBoundY.clear();
vBoundWidth.clear();
vBoundHeight.clear();
}
bool bowCV::isInitialized()
{
return flagName;
}
bool bowCV::train_initialize(const string& _detectorName,
const string& _extractorName,
const string& _matcherName,
int _nCluster,
bool _flagClassWeight,
DetectorDataArchive* _dda)
{
//_detectorName; //SURF, SIFT, FAST, STAR, MSER, GFTT, HARRIS
//_extractorName; //SURF, SIFT, OpponentSIFT, OpponentSURF
//_matcherName; //BruteForce-L1, BruteForce, FlannBased
flagClassWeight = _flagClassWeight;
flagName = false;
dda = _dda;
std::string msgout;
std::stringstream val2str;
val2str << _nCluster;
msgout = "Info: Detector: " + _detectorName
+ ", Extractor: " + _extractorName
+ ", Matcher: " + _matcherName
+ ", nWords: " + val2str.str() + ".\n";
message(msgout,MsgLogger::DEBUG);
fDetector = FeatureDetector::create(_detectorName);
// When SIFT feature is used, you may adjust its performence with the following options
// fDetector->set("nOctaveLayers",1); //smaller -> smaller features
// fDetector->set("contrastThreshold",0.1); //larger -> smaller features
// fDetector->set("edgeThreshold",18.0); //larger -> smaller features
// fDetector->set("sigma",1.9);//larger -> smaller features
dExtractor = DescriptorExtractor::create(_extractorName);
if( fDetector.empty() || dExtractor.empty() )
{
msgout = "Error: featureDetector or descExtractor was not created.\n";
message(msgout,MsgLogger::WARN);
return false;
}
else
{
dda->setProperty(BOW_DETECTOR_NAME,_detectorName);
dda->setProperty(BOW_EXTRACTOR_NAME,_extractorName);
}
cntCluster = _nCluster;
dMatcher = DescriptorMatcher::create(_matcherName);
if (dMatcher.empty())
{
msgout = "Error: descMatcher was not created.\n";
message(msgout,MsgLogger::WARN);
return false;
}
else
dda->setProperty(BOW_MATCHER_NAME,_matcherName);
bowExtractor = new BOWImgDescriptorExtractor(dExtractor,dMatcher);
vFilenameTrain.clear();
vClassIDTrain.clear();
vBoundX.clear();
vBoundY.clear();
vBoundWidth.clear();
vBoundHeight.clear();
flagName = true;
return true;
}
bool bowCV::detect_initialize( const DetectorDataArchive* _dda )
{
dda = (DetectorDataArchive*)_dda;
return detect_readTrainResult();
}
bool bowCV::detect_setParameter(const string& _detectorName,const string& _extractorName,const string& _matcherName)
{
flagName = false;
std::string msgout;
fDetector = FeatureDetector::create(_detectorName);
dExtractor = DescriptorExtractor::create(_extractorName);
if( fDetector.empty() || dExtractor.empty() )
{
msgout = "Error: featureDetector or descExtractor was not created.\n";
message(msgout,MsgLogger::WARN);
return false;
}
dMatcher = DescriptorMatcher::create(_matcherName);
if (dMatcher.empty())
{
msgout = "Error: descMatcher was not created.\n";
message(msgout,MsgLogger::WARN);
return false;
}
bowExtractor = new BOWImgDescriptorExtractor(dExtractor,dMatcher);
vFilenameTrain.clear();
vClassIDTrain.clear();
vBoundX.clear();
vBoundY.clear();
vBoundWidth.clear();
vBoundHeight.clear();
flagName = true;
return true;
}
bool bowCV::train_parseTrainList(const string& _filepathTrain,const string& _filenameTrainList)
{
std::string msgout;
_fullFilePathList = _filepathTrain + "/" + _filenameTrainList;
ifstream ifList(_fullFilePathList.c_str());
if(!ifList.is_open())
{
msgout = "Error: can't parse a train list from the file \""
+ _fullFilePathList + "\"\n";
message(msgout,MsgLogger::WARN);
return false;
}
msgout = "Checking training files...";
message(msgout,MsgLogger::DEBUG);
do
{
ifList.getline(_buf, 255);
string line(_buf);
istringstream iss(line);
iss >> _tfileName;
if (_tfileName == "#")
continue;
_fullFilePathImg = _filepathTrain + "/" + _tfileName;
string classStr;
iss >> classStr;
if(classStr.size()==0)
continue;
int _classID(atoi(classStr.c_str()));
string boxStr_x;
iss >> boxStr_x;
Rect _rect;
if(boxStr_x.size()==0)
_rect = Rect(0,0,0,0);
else
{
string boxStr_y;
iss >> boxStr_y;
string boxStr_width;
iss >> boxStr_width;
string boxStr_height;
iss >> boxStr_height;
_rect = Rect(atoi(boxStr_x.c_str()),
atoi(boxStr_y.c_str()),
atoi(boxStr_width.c_str()),
atoi(boxStr_height.c_str()));
}
_img = imread(_fullFilePathImg,CV_LOAD_IMAGE_GRAYSCALE);
if(_img.empty())
{
//ifList.close();
msgout = "Error: can't read this image file \""
+ _fullFilePathImg + "\".\n";
message(msgout,MsgLogger::WARN);
continue;
//return false;
}
train_stackTrainImage(_fullFilePathImg,_classID,_rect.x,_rect.y,_rect.width,_rect.height);
} while (!ifList.eof());
ifList.close();
std::stringstream val2str;
val2str << vFilenameTrain.size();
msgout = "The number of images for training is " + val2str.str() + ".\n";
message(msgout,MsgLogger::DEBUG);
if(vFilenameTrain.size()<1)
return false;
else
return true;
}
void bowCV::train_stackTrainImage(const string& _fullpath,const int& _classID)
{
train_stackTrainImage(_fullpath,_classID,0,0,0,0);
}
void bowCV::train_stackTrainImage(const string& _fullpath,const int& _classID,const int& _x,const int& _y,const int& _width,const int& _height)
{
vFilenameTrain.push_back(_fullpath);
vClassIDTrain.push_back(_classID);
vBoundX.push_back(_x);
vBoundY.push_back(_y);
vBoundWidth.push_back(_width);
vBoundHeight.push_back(_height);
}
bool bowCV::train_run(const string& _filepathForSavingResult,
cvac::ServiceManager *sman,
float _oneclassNu)
{
std::string msgout;
if(!flagName)
{
msgout = "Error: need to initialize detector, extractor, matcher,"
"and so on with the function train_initialize()";
message(msgout,MsgLogger::WARN);
return false;
}
if(vFilenameTrain.size() < 1)
{
msgout = "There is no training images.\n";
message(msgout,MsgLogger::WARN);
return false;
}
else
{
msgout = "Training is started.\n";
message(msgout,MsgLogger::DEBUG);
}
//////////////////////////////////////////////////////////////////////////
// START - Clustering (Most time-consuming step)
//////////////////////////////////////////////////////////////////////////
vector<int> vSkipIndex;
Mat _descriptorRepository;
Rect _rect;
for(unsigned int k=0;k<vFilenameTrain.size();k++)
{
_fullFilePathImg = vFilenameTrain[k];
_img = imread(_fullFilePathImg,CV_LOAD_IMAGE_GRAYSCALE);
if(_img.empty())//no file or not supported format
{
msgout = "The file \"" + _fullFilePathImg +
"\" has a problem (no file or not supported format). "+
"So, it will not be processed in the training.\n";
message(msgout,MsgLogger::WARN);
continue;
}
if ((sman!=NULL) && (sman->stopRequested()))
{
sman->stopCompleted();
return false;
}
if((vBoundX[k]<0) || (vBoundY[k]<0) ||
((vBoundX[k]+vBoundWidth[k])>_img.cols) ||
((vBoundY[k]+vBoundHeight[k])>_img.rows))
{
msgout = "The file \"" + _fullFilePathImg +
"\" has a problem (out of boundary). " +
"So, it will not be processed in the training.\n";
message(msgout,MsgLogger::WARN);
continue;
}
_rect = Rect(vBoundX[k],vBoundY[k],vBoundWidth[k],vBoundHeight[k]);
if((_rect.width != 0) && (_rect.height != 0))
_img = _img(_rect);
// Sometimes, opencv returns an memory-related error
// because of the large number of extracted features
try
{
fDetector->detect(_img, _keypoints);
}
catch(cv::Exception& e)
{
// limitImageSize(_img);
std::string err_str = std::string(e.what());
char sizeStr[128];
sprintf(sizeStr, "%dx%d", _img.cols, _img.rows);
msgout = "The file \"" + _fullFilePathImg +
"\" has a problem (OpenCV Error). Image size= " + sizeStr +
" So, it will not be processed in the training. Details: " +
err_str ;
message(msgout,MsgLogger::WARN);
continue;
}
if(_keypoints.size()<1) //According to the version of openCV, it may cause an exceptional error.
{
msgout = "The file \"" + _fullFilePathImg +
"\" has a problem (no feature). " +
"So, it will not be processed in the training.\n";
message(msgout,MsgLogger::WARN);
continue;
}
dExtractor->compute(_img, _keypoints, _descriptors);
try
{
_descriptorRepository.push_back(_descriptors);
}
catch(cv::Exception& e)
{
// limitImageSize(_img);
std::string err_str = std::string(e.what());
msgout = "While processing this file \"" + _fullFilePathImg +
"\", a critical error occurred (OpenCV Error). It might be caused by " +
"insufficient memory. So. This training process is stopping. Details: " +
err_str;
message(msgout,MsgLogger::ERROR);
return false;
}
std::stringstream val2str1,val2str2;
val2str1 << k+1;
val2str2 << vFilenameTrain.size();
msgout = "Progress of Feature Extraction: "
+ val2str1.str() + "/" + val2str2.str();
messageInSameline(msgout);
}
std::stringstream val2str;
val2str << _descriptorRepository.rows;
msgout = "\nTotal number of descriptors: " + val2str.str()
+ ".\nStarting clustering. This may take a long time ...\n";
message(msgout,MsgLogger::DEBUG);
if(cntCluster > _descriptorRepository.rows)
{
msgout = "Error: the number of clusters is smaller "
"than the number of descriptors\n";
message(msgout,MsgLogger::WARN);
return false;
}
BOWKMeansTrainer bowTrainer(cntCluster);
bowTrainer.add(_descriptorRepository);
//for saving the memory
_descriptorRepository.release();
mVocabulary = bowTrainer.cluster();
if(!train_writeVocabulary(_filepathForSavingResult + "/" + filenameVocabulary,mVocabulary))
return false;
//////////////////////////////////////////////////////////////////////////
// END - Clustering (Most time-consuming step)
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// START - Setup Vocabulary
//////////////////////////////////////////////////////////////////////////
msgout = "Starting vocabulary setup.\n";
message(msgout,MsgLogger::DEBUG);
bowExtractor->setVocabulary(mVocabulary);
//////////////////////////////////////////////////////////////////////////
// END - Setup Vocabulary
//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// START - Train Classifier (SVM)
//////////////////////////////////////////////////////////////////////////
msgout = "Starting training the classifier.\n";
message(msgout,MsgLogger::DEBUG);
Mat trainDescriptors; trainDescriptors.create(0,bowExtractor->descriptorSize(),bowExtractor->descriptorType());
Mat trainClass; trainClass.create(0,1,CV_32FC1);
int _classID;
std::list<int> _listClassAll;
std::list<int> _listClassUnique;
for(unsigned int k=0;k<vFilenameTrain.size();k++)
{
_fullFilePathImg = vFilenameTrain[k];
_classID = vClassIDTrain[k];
if ((sman!=NULL) && (sman->stopRequested()))
{
sman->stopCompleted();
return false;
}
_img = imread(_fullFilePathImg,CV_LOAD_IMAGE_GRAYSCALE);
if(_img.empty())
continue;
if((vBoundX[k]<0) || (vBoundY[k]<0) ||
((vBoundX[k]+vBoundWidth[k])>_img.cols) ||
((vBoundY[k]+vBoundHeight[k])>_img.rows))
continue;
_rect = Rect(vBoundX[k],vBoundY[k],vBoundWidth[k],vBoundHeight[k]);
if((_rect.width != 0) && (_rect.height != 0))
_img = _img(_rect);
try
{
fDetector->detect(_img, _keypoints);
}
catch(cv::Exception& e)
{
//limitImageSize(_img);
//std::string err_str = std::string(e.what());
continue;
}
//cout << "n_pts of " << vFilenameTrain[k] << ": " << _keypoints.size() << "\n"; fflush(stdout);
if(_keypoints.size() >= 1)
{
bowExtractor->compute(_img, _keypoints, _descriptors);
try
{
trainDescriptors.push_back(_descriptors);
}
catch(cv::Exception& e)
{
// limitImageSize(_img);
std::string err_str = std::string(e.what());
msgout = "While processing this file \"" + _fullFilePathImg +
"\", a critical error occurred (OpenCV Error). " +
"This training process will be stopped. Details: " +
err_str;
message(msgout,MsgLogger::ERROR);
return false;
}
trainClass.push_back(_classID);
_listClassAll.push_back(_classID);
}
}
_listClassUnique = _listClassAll;
_listClassUnique.sort();
_listClassUnique.unique();
//SVMTrainParamsExt svmParamsExt;
//CvSVMParams svmParams;
//CvMat class_wts_cv;
//setSVMParams( svmParams, class_wts_cv, labels, true );
//CvParamGrid c_grid, gamma_grid, p_grid, nu_grid, coef_grid, degree_grid;
//setSVMTrainAutoParams( c_grid, gamma_grid, p_grid, nu_grid, coef_grid, degree_grid );
//classifierSVM[class_].train_auto( samples_32f, labels, Mat(), Mat(), svmParams, 10, c_grid, gamma_grid, p_grid, nu_grid, coef_grid, degree_grid );
/*
//////////////////////////////////////////////////////
// Way #1 -
classifierSVM.train(trainDescriptors,trainClass);
//////////////////////////////////////////////////////
*/
//////////////////////////////////////////////////////
// Way #2
CvSVMParams param;
if(_listClassUnique.size()==1) //Just for one class
{
flagOneClass = true;
mInclassIDforOneClass = (*_listClassUnique.begin());
mOutclassIDforOneClass = (mInclassIDforOneClass==0)?1:0;
stringstream oneclassIDstream;
oneclassIDstream << mInclassIDforOneClass;
dda->setProperty(BOW_ONECLASS_ID,oneclassIDstream.str());
msgout = "BoW - One Class Classification. \n";
message(msgout,MsgLogger::DEBUG);
param.svm_type = CvSVM::ONE_CLASS;
param.nu = _oneclassNu; //empirically, this value doesn't have the effect on performance.
//param.kernel_type = CvSVM::LINEAR; //empirically, it should NOT be linear for a better performance.
classifierSVM.train(trainDescriptors,trainClass,cv::Mat(),cv::Mat(),param);
}
else
{
flagOneClass = false;
msgout = "BoW - Multiple Classes Classification. \n";
message(msgout,MsgLogger::DEBUG);
float* _classWeight = new float[_listClassUnique.size()];
int _idx = 0;
int _maxCount = -1;
for(std::list<int>::iterator _itr=_listClassUnique.begin();_itr!= _listClassUnique.end();++_itr)
{
int _count = std::count(_listClassAll.begin(),_listClassAll.end(),(*_itr));
_maxCount = (_maxCount<_count)?_count:_maxCount;
_classWeight[_idx++] = (float)_count;
}
for(unsigned int k=0;k<_listClassUnique.size();k++)
_classWeight[k] = (float)_maxCount/_classWeight[k];
// The order of classWeight is the same with the order of classID.
// If there is a list of classID = {-1,2,1}.
// Then, the order of classWeights becomes {-1,1,2}.
//param.kernel_type = CvSVM::LINEAR; //empirically, it should NOT be linear for a better performance.
if(flagClassWeight)
{
param.class_weights = new CvMat();
cvInitMatHeader(param.class_weights,1,_listClassUnique.size(),CV_32FC1,_classWeight);
}
dda->setProperty(BOW_CLASS_WEIGHT,flagClassWeight?"True":"False");
classifierSVM.train(trainDescriptors,trainClass,cv::Mat(),cv::Mat(),param);
delete [] _classWeight;
}
string tSVMPath = _filepathForSavingResult + "/" + filenameSVM;
classifierSVM.save(tSVMPath.c_str());
///////////////////////////////////////////////////////////////////////////
// END - Train Classifier (SVM)
//////////////////////////////////////////////////////////////////////////
dda->setProperty(BOW_OPENCV_VERSION,CV_VERSION);
flagTrain = true;
return true;
}
std::string bowCV::detect_run(const string& _fullfilename, int& _bestClass,int _boxX,int _boxY,int _boxWidth,int _boxHeight)
{
_bestClass = -1;
std::string msgout;
std::string msgReturn;
if(!flagName)
{
msgout = "Error: Need to initialize detector, extractor, and matcher "
"with the function detect_initialize().\n";
message(msgout,MsgLogger::WARN);
msgReturn = "Error: need appropriate initialization";
return msgReturn;
}
if(!flagTrain)
{
msgout = "Error: No training flag found. "
"Before testing, training is necessary.\n";
message(msgout,MsgLogger::WARN);
msgReturn = "Error: need appropriate initialization";
return msgReturn;
}
_img = imread(_fullfilename,CV_LOAD_IMAGE_GRAYSCALE);
if(_img.empty())//no file or not supported format
{
msgout = "The file \"" + _fullfilename +
"\" has a problem (no file or not supported format). "+
"So, it will not be processed.\n";
message(msgout,MsgLogger::WARN);
msgReturn = "Error: no file or not supported format";
return msgReturn;
}
else
{
if((_boxX<0) || (_boxY<0) ||
((_boxX+_boxWidth)>_img.cols) || ((_boxY+_boxHeight)>_img.rows))
{
msgout = "The file \"" + _fullfilename +
"\" has a problem (out of boundary). "+
"So, it will not be processed.\n";
message(msgout,MsgLogger::WARN);
msgReturn = "Error: invalid boundary info";
return msgReturn;
}
Rect tRect = Rect(_boxX,_boxY,_boxWidth,_boxHeight);
if((tRect.width != 0) && (tRect.height != 0))
_img = _img(tRect);
}
// Sometimes, opencv returns an memory-related error
// while processing an image because of the large number of
// extracted features
try
{
fDetector->detect(_img, _keypoints);
}
catch(cv::Exception& e)
{
//limitImageSize(_img);
std::string err_str = std::string(e.what());
char sizeStr[128];
sprintf(sizeStr, "%dx%d", _img.cols, _img.rows);
msgout = "The file \"" + _fullfilename +
"\" has a problem (OpenCV Error). Image size= " + sizeStr + " : "+
err_str;
message(msgout,MsgLogger::WARN);
msgReturn = "Error: opencv error";
return msgReturn;
}
if(_keypoints.size()<1) //According to the version of openCV, it may cause an exceptional error.
{
msgout = "The file \"" + _fullfilename +
"\" has a problem (no feature). "+
"So, it will not be processed.\n";
message(msgout,MsgLogger::WARN);
msgReturn = "Error: no feature";
return msgReturn;
}
bowExtractor->compute(_img, _keypoints, _descriptors);
// In the manual from OpenCV, it is written as follows:
// "If true (it is for the second argument of this function)
// and the problem is 2-class classification then the method
// returns the decision function value that is signed distance to the margin,
// else the function returns a class label (classification)
// or estimated function value (regression)."
// Since we're using it as a multi-class classification tool,
// we can safely cast to int.
float predicted = classifierSVM.predict(_descriptors);
assert( fabs( predicted-((int)predicted) ) < 0.000001 );
_bestClass = (int) predicted;
if(!flagOneClass) //For Multi-class problem
{
msgReturn = "";
return msgReturn;
//if (-1 == _bestClass) // no class found
// return false;
//else
// return true;
}
else //For one-class problem
{
if(_bestClass==1) //in class
_bestClass = mInclassIDforOneClass;
else //outlier
_bestClass = mOutclassIDforOneClass;
msgReturn = "";
return msgReturn;
}
}
bool bowCV::detect_readTrainResult()
{
std::string msgout;
string _fullpath, _inputString;
#ifdef __APPLE__
if (dda->getProperty(BOW_DETECTOR_NAME).compare("SURF") == 0)
{
msgout = "WARNING!!! SURF detector may not run well on OSX.\n";
message(msgout,MsgLogger::WARN);
}
#endif // __APPLE__
if(!detect_setParameter(dda->getProperty(BOW_DETECTOR_NAME),
dda->getProperty(BOW_EXTRACTOR_NAME),
dda->getProperty(BOW_MATCHER_NAME)))
{
msgout = "Error: need to initialize detector, extractor, matcher, "
"and so on with the function detect_initialize().\n";
message(msgout,MsgLogger::WARN);
return false;
}
// Read VOC file
_fullpath = dda->getFile(BOW_VOC_FILE);
if(detect_readVocabulary(_fullpath,mVocabulary))
{
bowExtractor->setVocabulary(mVocabulary);
}
else
return false;
// Read SVM file
_fullpath = dda->getFile(BOW_SVM_FILE);
classifierSVM.load(_fullpath.c_str());
// Read OpenCV Version
_inputString = dda->getProperty(BOW_OPENCV_VERSION);
if(!isCompatibleOpenCV(_inputString))
{
msgout = "For the training, OpenCV " + _inputString
+ " was used. But, now you are using OpenCV "
+ CV_VERSION + ". It may cause an exceptional error.\n";
message(msgout,MsgLogger::WARN);
//return false;
}
CvSVMParams tParam = classifierSVM.get_params();
if(tParam.svm_type == CvSVM::ONE_CLASS)
{
flagOneClass = true;
msgout = "BoW - One Class Classification. \n";
message(msgout,MsgLogger::DEBUG);
_inputString = dda->getProperty(BOW_ONECLASS_ID);
if(_inputString.empty())
mInclassIDforOneClass = 1; //default in-class ID of one-Class SVM
else
mInclassIDforOneClass = atoi(_inputString.c_str());
mOutclassIDforOneClass = (mInclassIDforOneClass==0)?1:0;
std::stringstream val2str1,val2str2;
val2str1 << mInclassIDforOneClass;
val2str2 << mOutclassIDforOneClass;
msgout = "In-class data will be represented by "+val2str1.str()+
", and Out-class data will be represented by "+val2str2.str()+".\n";
message(msgout,MsgLogger::DEBUG);
}
else
{
flagOneClass = false;
msgout = "BoW - Multiple Classes Classification. \n";
message(msgout,MsgLogger::DEBUG);
}
flagTrain = true;
return true;
}
bool bowCV::train_writeVocabulary(const string& _filename,const Mat& _vocabulary)
{
std::string msgout;
msgout = "Saving vocabulary.\n";
message(msgout,MsgLogger::DEBUG);
FileStorage fs( _filename, FileStorage::WRITE );
if( fs.isOpened() )
{
fs << "vocabulary" << _vocabulary;
fs.release();
return true;
}
fs.release();
msgout = "Error: in Saving vocabulary.\n";
message(msgout,MsgLogger::WARN);
return false;
}
bool bowCV::detect_readVocabulary( const string& _filename, Mat& _vocabulary )
{
std::string msgout;
msgout = "Reading vocabulary.\n";
message(msgout,MsgLogger::DEBUG);
FileStorage fs( _filename, FileStorage::READ );
if( fs.isOpened() )
{
fs["vocabulary"] >> _vocabulary;
//cout << "done" << endl;
fs.release();
return true;
}
fs.release();
msgout = "Error: in Reading vocabulary.\n";
message(msgout,MsgLogger::WARN);
return false;
}
bool bowCV::isCompatibleOpenCV(const string& _version)
{
if(_version.empty())
{
std::string msgout = "Because this training data is old version, "
"it doesn't include version information. "
"Therefore, it may cause an exceptional error "
"while processing images.\n";
message(msgout,MsgLogger::WARN);
return true;
}
string tVersionCurrent(CV_VERSION);
if(_version == "2.4.2" || _version == "2.4.3")
{
if(tVersionCurrent == "2.4.2" || tVersionCurrent == "2.4.3")
return true;
else if(tVersionCurrent == "2.4.5") //this case definitely causes error.
return false;
else
return false; //the other cases should be examined.
}
else if(_version == tVersionCurrent)
return true;
else
return false;
}
void bowCV::message(const string& _msg,
MsgLogger::Levels _levelClient)
{
//cout << _msg; fflush(stdout);
if(MsgLogger::SILENT != _levelClient)
{
msgLogger->message(_levelClient,_msg);
}
}
void bowCV::messageInSameline(const string& _msg)
{
cout << _msg << '\xd'; fflush(stdout);
}
// void bowCV::limitImageSize(Mat& _image)
// {
// return;
//
// int _row = _image.rows;
// int _col = _image.cols;
//
// int maxSizeImg = 1000;
// if(_row*_col > maxSizeImg*maxSizeImg)
// {
// double _rowRatio = (double)maxSizeImg/(double)_row;
// double _colRatio = (double)maxSizeImg/(double)_col;
//
// int _newRow = (_rowRatio<_colRatio)?(_rowRatio*_row):(_colRatio*_row);
// int _newCol = (_rowRatio<_colRatio)?(_rowRatio*_col):(_colRatio*_col);
//
// Mat imgOri = _image.clone();
// resize( imgOri, _image, Size(_newCol,_newRow),0,0,INTER_LANCZOS4);
// cout << "Iamge is resized to (" << _newCol << ", " << _newRow << ")\n";
// fflush(stdout);
// }
// }
//void bowCV::setSVMParams( CvSVMParams& svmParams, CvMat& class_wts_cv, const Mat& responses, bool balanceClasses )
//{
// int pos_ex = countNonZero(responses == 1);
// int neg_ex = countNonZero(responses == -1);
// //cout << pos_ex << " positive training samples; " << neg_ex << " negative training samples" << endl;
//
// svmParams.svm_type = CvSVM::C_SVC;
// svmParams.kernel_type = CvSVM::RBF;
// if( balanceClasses )
// {
// Mat class_wts( 2, 1, CV_32FC1 );
// // The first training sample determines the '+1' class internally, even if it is negative,
// // so store whether this is the case so that the class weights can be reversed accordingly.
// bool reversed_classes = (responses.at<float>(0) < 0.f);
// if( reversed_classes == false )
// {
// class_wts.at<float>(0) = static_cast<float>(pos_ex)/static_cast<float>(pos_ex+neg_ex); // weighting for costs of positive class + 1 (i.e. cost of false positive - larger gives greater cost)
// class_wts.at<float>(1) = static_cast<float>(neg_ex)/static_cast<float>(pos_ex+neg_ex); // weighting for costs of negative class - 1 (i.e. cost of false negative)
// }
// else
// {
// class_wts.at<float>(0) = static_cast<float>(neg_ex)/static_cast<float>(pos_ex+neg_ex);
// class_wts.at<float>(1) = static_cast<float>(pos_ex)/static_cast<float>(pos_ex+neg_ex);
// }
// class_wts_cv = class_wts;
// svmParams.class_weights = &class_wts_cv;
// }
//}
//
//void bowCV::setSVMTrainAutoParams( CvParamGrid& c_grid, CvParamGrid& gamma_grid,
// CvParamGrid& p_grid, CvParamGrid& nu_grid,
// CvParamGrid& coef_grid, CvParamGrid& degree_grid )
//{
// c_grid = CvSVM::get_default_grid(CvSVM::C);
//
// gamma_grid = CvSVM::get_default_grid(CvSVM::GAMMA);
//
// p_grid = CvSVM::get_default_grid(CvSVM::P);
// p_grid.step = 0;
//
// nu_grid = CvSVM::get_default_grid(CvSVM::NU);
// nu_grid.step = 0;
//
// coef_grid = CvSVM::get_default_grid(CvSVM::COEF);
// coef_grid.step = 0;
//
// degree_grid = CvSVM::get_default_grid(CvSVM::DEGREE);
// degree_grid.step = 0;
//}
|
8d5371d2cbb4826299abb9a04d7ed271d8e4afa1 | 28c2ef5ac0a4106f7ba7ffac80d06a315d24f7ef | /sony_remote/sony_remote.ino | dee729b00170c4f57c928ebb2b0c7607a7fa293b | [] | no_license | fabie37/Sony_RM-S325 | ee723546698dc3d3468072e0d1e85302f69163fa | 50fc34856d9b924d3b3262acffb4a0d2a0e17c2a | refs/heads/master | 2023-02-26T21:30:38.658650 | 2021-02-03T18:11:25 | 2021-02-03T18:11:25 | 335,707,968 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,471 | ino | sony_remote.ino |
// Can find this in Github: https://github.com/rocketscream/Low-Power
// If you need a reference for IR Codes: http://lirc.sourceforge.net/remotes/sony/RM-S325
#include "LowPower.h"
#include <IRremote.h>
#define VOL_UP 1153
#define VOL_DOWN 3201
#define TAPE1 3137
#define TAPE2 577
#define AUX 2945
#define CD 2625
#define TUNER 2113
#define PHONO 65
#define NUM_OF_CHANNELS 6
// Timer Indicator
int counter;
// Amp Config
int channels[NUM_OF_CHANNELS] = {TAPE1,TAPE2,AUX,CD,TUNER,PHONO};
int pos = 0;
// Pin Layout
const int WAKE_UP_PIN = 2;
const int IR_PIN = 3;
const int VOL_UP_PIN = 7;
const int VOL_DOWN_PIN = 8;
const int LEFT_MOV_PIN = 9;
const int RIGHT_MOV_PIN = 10;
// IR Lib
IRsend irsend;
void setup() {
Serial.begin(115200);
// IR Stuff
pinMode(VOL_UP_PIN, INPUT_PULLUP);
pinMode(VOL_DOWN_PIN, INPUT_PULLUP);
pinMode(RIGHT_MOV_PIN, INPUT_PULLUP);
pinMode(LEFT_MOV_PIN, INPUT_PULLUP);
pinMode(IR_PIN, OUTPUT);
// Wake up Stuff
pinMode(WAKE_UP_PIN, INPUT_PULLUP);
// TIMER STUFF -> send interrupt every aprox ~ 1sec
counter = 0;
TCCR1A = 0;
TCCR1B = 0;
TCCR1B |= (1<<CS12);
TIMSK1 |= (1<<TOIE0);
}
ISR(TIMER1_OVF_vect) {
counter++;
}
void wakeUp() {
Serial.println("Waking up");
counter = 0;
}
void keepAlive() {
counter = 0;
}
void moveRight() {
pos = (pos+1)%(NUM_OF_CHANNELS);
sendCommand(channels[pos]);
delay(100);
}
void moveLeft() {
pos = (pos-1)%(NUM_OF_CHANNELS);
pos = pos < 0 ? (NUM_OF_CHANNELS-1) : pos;
sendCommand(channels[pos]);
delay(100);
}
void sendCommand(int code) {
irsend.sendSony(code,12);
delay(10);
irsend.sendSony(code,12);
delay(10);
irsend.sendSony(code,12);
}
void loop() {
attachInterrupt(0, wakeUp, HIGH);
// If counter reaches 10 seconds, power down, else wake up
if (counter >= 10) {
LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
}
detachInterrupt(0);
// Read Digital Pins
int vol_up = digitalRead(VOL_UP_PIN);
int vol_down = digitalRead(VOL_DOWN_PIN);
int mov_right = digitalRead(RIGHT_MOV_PIN);
int mov_left = digitalRead(LEFT_MOV_PIN);
// Check status of pins and send IR command as needed
if (vol_up == LOW) {
keepAlive();
sendCommand(VOL_UP);
} else if (vol_down == LOW) {
keepAlive();
sendCommand(VOL_DOWN);
} else if (mov_right == LOW) {
keepAlive();
moveRight();
} else if (mov_left == LOW) {
keepAlive();
moveLeft();
}
}
|
54fcce36bb36d0ecaa2e1b99be75fa4329a52660 | 51be8db88a49f7bebeefddf431faff6048ac4f37 | /xpcc/src/xpcc/container/linked_list_iterator_impl.hpp | d4557530414001ae27bd0b5e4b3fd829e144a51d | [
"MIT"
] | permissive | jrahlf/3D-Non-Contact-Laser-Profilometer | 0a2cee1089efdcba780f7b8d79ba41196aa22291 | 912eb8890442f897c951594c79a8a594096bc119 | refs/heads/master | 2016-08-04T23:07:48.199953 | 2014-07-13T07:09:31 | 2014-07-13T07:09:31 | 17,915,736 | 6 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 5,877 | hpp | linked_list_iterator_impl.hpp | // coding: utf-8
// ----------------------------------------------------------------------------
/* Copyright (c) 2009, Roboterclub Aachen e.V.
* 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 Roboterclub Aachen e.V. 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 ROBOTERCLUB AACHEN E.V. ''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 ROBOTERCLUB AACHEN E.V. 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 XPCC__LINKED_LIST_HPP
#error "Don't include this file directly, use 'linked_list.hpp' instead"
#endif
// ----------------------------------------------------------------------------
// Iterators
// ----------------------------------------------------------------------------
// const iterator
template <typename T, typename Allocator>
xpcc::LinkedList<T, Allocator>::const_iterator::const_iterator() :
node(0)
{
}
template <typename T, typename Allocator>
xpcc::LinkedList<T, Allocator>::const_iterator::const_iterator(
const Node* node) :
node(node)
{
}
template <typename T, typename Allocator>
xpcc::LinkedList<T, Allocator>::const_iterator::const_iterator(
const iterator& other) :
node(other.node)
{
}
template <typename T, typename Allocator>
xpcc::LinkedList<T, Allocator>::const_iterator::const_iterator(
const const_iterator& other) :
node(other.node)
{
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::const_iterator&
xpcc::LinkedList<T, Allocator>::const_iterator::operator = (const const_iterator& other)
{
this->node = other.node;
return *this;
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::const_iterator&
xpcc::LinkedList<T, Allocator>::const_iterator::operator ++ ()
{
this->node = this->node->next;
return *this;
}
template <typename T, typename Allocator>
bool
xpcc::LinkedList<T, Allocator>::const_iterator::operator == (
const const_iterator& other) const
{
return (node == other.node);
}
template <typename T, typename Allocator>
bool
xpcc::LinkedList<T, Allocator>::const_iterator::operator != (
const const_iterator& other) const
{
return (node != other.node);
}
template <typename T, typename Allocator>
const T&
xpcc::LinkedList<T, Allocator>::const_iterator::operator * () const
{
return this->node->value;
}
template <typename T, typename Allocator>
const T*
xpcc::LinkedList<T, Allocator>::const_iterator::operator -> () const
{
return &this->node->value;
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::const_iterator
xpcc::LinkedList<T, Allocator>::begin() const
{
return const_iterator(this->front);
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::const_iterator
xpcc::LinkedList<T, Allocator>::end() const
{
return const_iterator(0);
}
// iterator
template <typename T, typename Allocator>
xpcc::LinkedList<T, Allocator>::iterator::iterator() :
node(0)
{
}
template <typename T, typename Allocator>
xpcc::LinkedList<T, Allocator>::iterator::iterator(Node* node) :
node(node)
{
}
template <typename T, typename Allocator>
xpcc::LinkedList<T, Allocator>::iterator::iterator(
const iterator& other) :
node(other.node)
{
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::iterator&
xpcc::LinkedList<T, Allocator>::iterator::operator = (const iterator& other)
{
this->node = other.node;
return *this;
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::iterator&
xpcc::LinkedList<T, Allocator>::iterator::operator ++ ()
{
this->node = this->node->next;
return *this;
}
template <typename T, typename Allocator>
bool
xpcc::LinkedList<T, Allocator>::iterator::operator == (
const iterator& other) const
{
return (node == other.node);
}
template <typename T, typename Allocator>
bool
xpcc::LinkedList<T, Allocator>::iterator::operator != (
const iterator& other) const
{
return (node != other.node);
}
template <typename T, typename Allocator>
T&
xpcc::LinkedList<T, Allocator>::iterator::operator * ()
{
return this->node->value;
}
template <typename T, typename Allocator>
T*
xpcc::LinkedList<T, Allocator>::iterator::operator -> ()
{
return &this->node->value;
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::iterator
xpcc::LinkedList<T, Allocator>::begin()
{
return iterator(this->front);
}
template <typename T, typename Allocator>
typename xpcc::LinkedList<T, Allocator>::iterator
xpcc::LinkedList<T, Allocator>::end()
{
return iterator(0);
}
|
cc6495e3b16e3a978cc2d2e3afcbdad9a35e41a6 | 5228dfaf4321d1cb27fdb971fd2dcf6db06ec9fc | /hgeSDI/hgeSDI/LineCommand.cpp | e54fd9c09c5ef3c15485137a444cba60d3595210 | [] | no_license | CBE7F1F65/b63ea6f6f9110311ba98a677c0e70afd | 991d4b7563e8a5ddcda4d9caf8121e0ae4302550 | f65c8d6d2935946c36cb55493f7e279583eca415 | refs/heads/master | 2021-01-20T10:49:49.464167 | 2013-06-03T02:25:36 | 2013-06-03T02:25:36 | 32,192,729 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,446 | cpp | LineCommand.cpp | #include "stdafx.h"
#include "Command.h"
#include "LineCommand.h"
#include "Main.h"
#include "GUICursor.h"
#include "GUICoordinate.h"
#include "RenderHelper.h"
#include "RenderTargetManager.h"
#include "ColorManager.h"
#include "GLine.h"
#include "GObjectManager.h"
LineCommand::LineCommand()
{
}
LineCommand::~LineCommand()
{
}
void LineCommand::OnProcessCommand()
{
int step = OnNormalProcessCommand(GUIC_CREATEPOINT);
int nowstep = pcommand->GetStep();
if (IsStepped())
{
if (nowstep > CSI_INIT)
{
pcommand->EnableSubCommand(
(laststep.step==CSI_RESUME)?false:true,
SSC_UNDO,
SSC_REDO,
SSC_TERMINAL,
SSC_NULL);
}
}
UpdateLastStep();
int ret = -1;
if (step == CSI_INIT)
{
pcommand->StepTo(
CSI_LINE_WANTX1,
CWP_XY_B);
}
else if (step == CSI_LINE_WANTX1)
{
ret = pcommand->ProcessPending(
CSP_LINE_XY_B, COMMPARAMFLAG_X, CWP_X_B, // Fill in Param
CSI_LINE_WANTY1, CWP_Y_B // Step to with want
);
}
else if (step == CSI_LINE_WANTY1)
{
ret = pcommand->ProcessPending(
CSP_LINE_XY_B, COMMPARAMFLAG_Y, CWP_Y_B, // Fill in Param
CSI_LINE_WANTX2, CWP_XY_N // Step to with want
);
}
else if (step == CSI_LINE_WANTX2)
{
if (!pgp->isBeginPtSet())
{
float bx, by;
pcommand->GetParamXY(CSP_LINE_XY_B, &bx, &by);
pgp->SetBeginPt(bx, by);
}
ret = pcommand->ProcessPending(
CSP_LINE_XY_N, COMMPARAMFLAG_X, CWP_X_N, // Fill in Param
CSI_LINE_WANTY2, CWP_Y_N // Step to with want
);
}
else if (step == CSI_LINE_WANTY2)
{
ret = pcommand->ProcessPending(
CSP_LINE_XY_N, COMMPARAMFLAG_Y, CWP_Y_N, // Fill in Param
CSI_FINISHCONTINUE // Step to with want
);
}
if (!ret)
{
}
else if (ret > 0)
{
// Dispatch Subcommand
DispatchNormalSubCommand(ret);
pcommand->FinishPendingSubCommand();
}
else if (ret < 0)
{
// Routine
if (step > CSI_INIT)
{
int iret = pgp->PickPoint();
if (pgp->IsPickReady(iret))
{
if (!pcommand->IsInternalProcessing())
{
int tosetpindex = CSP_LINE_XY_B;
if (step == CSI_LINE_WANTX2 || step == CSI_LINE_WANTY2)
{
tosetpindex = CSP_LINE_XY_N;
}
pcommand->SetParamX(tosetpindex, pgp->GetPickX_C());
pcommand->SetParamY(tosetpindex, pgp->GetPickY_C());
if (step < CSI_LINE_WANTX2)
{
pcommand->StepTo(
CSI_LINE_WANTX2, CWP_XY_N
);
}
else
{
pcommand->StepTo(
CSI_FINISHCONTINUE
);
}
}
}
}
else if (step == CSI_FINISHCONTINUE)
{
float nx1, ny1;
pcommand->GetParamXY(CSP_LINE_XY_N, &nx1, &ny1);
ProtectPendingFinishCommand();
CommitFrontCommand(
CCMake_C(COMM_LINE),
CCMake_F(nx1),
CCMake_F(ny1),
NULL
);
}
}
RenderToTarget();
}
void LineCommand::RenderToTarget()
{
int nstep = pcommand->GetStep();
if (nstep >= CSI_LINE_WANTX2 && nstep <= CSI_LINE_WANTY2)
{
float x1, y1;
pcommand->GetParamXY(CSP_LINE_XY_B, &x1, &y1);
float x2 = pgp->GetPickX_C();//MainInterface::getInstance().mousex;
float y2 = pgp->GetPickY_C();//MainInterface::getInstance().mousey;
HTARGET tar = RenderTargetManager::getInstance().UpdateTarget(RTID_COMMAND);
RenderHelper::getInstance().BeginRenderTar(tar);
RenderHelper::getInstance().RenderLineMeasureMark(x1, y1, x2, y2, pgm->GetActiveLayer()->getLineColor());
RenderHelper::getInstance().RenderLine(x1, y1, x2, y2, pgm->GetActiveLayer()->getLineColor());
RenderHelper::getInstance().EndRenderTar();
Command::getInstance().SetRenderTarget(tar);
}
}
void LineCommand::OnDoneCommand()
{
float xb, yb, xe, ye;
pcommand->GetParamXY(CSP_LINE_XY_B, &xb, &yb);
pcommand->GetParamXY(CSP_LINE_XY_N, &xe, &ye);
GStraightLine * line = new GBezierLine(pgm->GetActiveLayer(), PointF2D(xb, yb), PointF2D(xe, ye));
PushRevertable(
CCMake_C(COMM_I_ADDNODE, 2),
// CCMake_D((int)line),
// CCMake_D((int)(line->getParent())),
CCMake_I(line->getID()),
CCMake_I(line->getParent()->getID()),
CCMake_C(COMM_I_COMMAND, 5, 1),
CCMake_CI(COMM_I_COMM_WORKINGLAYER, workinglayerID),
CCMake_C(COMM_LINE),
CCMake_F(xb),
CCMake_F(yb),
CCMake_F(xe),
CCMake_F(ye),
CCMake_C(COMM_I_UNDO_COMMIT, 3),
CCMake_C(COMM_LINE),
CCMake_F(xb),
CCMake_F(yb),
NULL
);
} |
c70a65dc0bbe2fc186e7961005f8ed5f87bea8c5 | 82d0b25efbcdffad42f69aa3f24df4151c1be0c2 | /ebb_chp06/GPIO_my/GPIO_my.cpp | 6cd34c8798387b10933c89e46b1661755284da28 | [] | no_license | aplapada/BeagleBoneBlack | 546b7c64b250e7f211cf83e3b0721bc838d6c6df | ddecdd2fad7268aa49bce5ab06037e6b2e0ccddb | refs/heads/master | 2020-06-09T18:14:37.756716 | 2019-06-24T16:49:24 | 2019-06-24T16:49:24 | 193,482,838 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,708 | cpp | GPIO_my.cpp | #include "GPIO_my.h"
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
#include<cstdlib>
#include<cstdio>
#include<fcntl.h>
#include<unistd.h>
#include<sys/epoll.h>
#include<pthread.h>
using namespace std;
namespace eeroSpace {
GPIO::GPIO(int num){
this->num = num;
//this->
this->callbackFunction = NULL;
this->threadRunning = false;
this->debounceTime = 0;
ostringstream s;
s << "gpio" << num;
this->name = string(s.str());
this->path = GPIO_PATH + this->name + "/";
usleep(250000); // 250ms delay
}
int GPIO::write(string path, string fname, string val){
ofstream fs;
fs.open((path + fname).c_str());
if (!fs.is_open()){
perror("GPIO: write failed to open file ");
return -1;
}
fs << val;
fs.close();
return 0;
}
int GPIO::write(string path, string fname, int val){
stringstream s;
s << val;
return this->write(path,fname,s.str());
}
int GPIO::setDir(GPIO_DIR dir){
switch(dir){
case INPUT: return this->write(this->path, "direction", "in");
break;
case OUTPUT: return this->write(this->path, "direction", "out");
break;
}
return -1;
}
int GPIO::setVal(GPIO_VAL val){
switch(val){
case HIGH: return this->write(this->path, "value", "1");
break;
case LOW: return this->write(this->path, "value", "0");
break;
}
return -1;
}
int GPIO::setEdgeType(GPIO_EDGE edge){
switch(edge){
case NONE: return this->write(this->path, "edge", "none");
break;
case RISING: return this->write(this->path, "edge", "rising");
break;
case FALLING: return this->write(this->path, "edge", "falling");
break;
case BOTH: return this->write(this->path, "edge", "both");
break;
}
return -1;
}
// Blocking Poll - based on the epoll socket code in the epoll man page
int GPIO::waitForEdge(){
this->setDir(INPUT); // must be an input pin to poll its value
int fd, i, epollfd, count=0;
struct epoll_event ev;
epollfd = epoll_create(1);
if (epollfd == -1) {
perror("GPIO: Failed to create epollfd");
return -1;
}
if ((fd = open((this->path + "value").c_str(), O_RDONLY | O_NONBLOCK)) == -1) {
perror("GPIO: Failed to open file");
return -1;
}
//ev.events = read operation | edge triggered | urgent data
ev.events = EPOLLIN | EPOLLET | EPOLLPRI;
ev.data.fd = fd; // attach the file file descriptor
//Register the file descriptor on the epoll instance, see: man epoll_ctl
if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev) == -1) {
perror("GPIO: Failed to add control interface");
return -1;
}
while(count<=1){ // ignore the first trigger
i = epoll_wait(epollfd, &ev, 1, -1);
if (i==-1){
perror("GPIO: Poll Wait fail");
count=5; // terminate loop
}
else {
count++; // count the triggers up
}
}
close(fd);
if (count==5) return -1;
return 0;
}
int GPIO::waitForEdge(CallbackType callback){
this->threadRunning = true;
this->callbackFunction = callback;
// create the thread, pass the reference, address of the function and data
if(pthread_create(&this->thread, NULL, &threadedPoll, static_cast<void*>(this))){
perror("GPIO: Failed to create the poll thread");
this->threadRunning = false;
return -1;
}
return 0;
}
int GPIO::streamOpen(){
stream.open((path + "value").c_str());
return 0;
}
int GPIO::streamWrite(GPIO_VAL val){
stream << val << std::flush;
return 0;
}
int GPIO::streamClose(){
stream.close();
return 0;
}
void* threadedPoll(void *value){
GPIO *gpio = static_cast<GPIO*>(value);
while(gpio->threadRunning){
gpio->callbackFunction(gpio->waitForEdge());
usleep(gpio->debounceTime * 1000);
}
return 0;
}
GPIO::~GPIO() {
// this->unexportGPIO();
}
} // eeroSpace
|
1211921ff00c6be94a247f86918fba2ce24a36f2 | 5999c7e4067467265f0742a3d26777003f07cf23 | /src/quiz2.cpp | 8ac8b669f0fb272a898e06501d08437d9c8fb829 | [] | no_license | kminoda/adversarial_attack | 4d8c277a37d948c2f870f17118273b00ee23dec5 | 44eb5afa941597571f6cdefc67125b40e642c0be | refs/heads/master | 2020-04-07T04:42:01.091350 | 2019-06-01T10:57:11 | 2019-06-01T10:57:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,665 | cpp | quiz2.cpp | // https://teratail.com/questions/141589
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <fstream> // ifstream
#include <sstream> // stringstream
#include <string>
using namespace std;
#define MAP_HEIGHT 32
#define MAP_WIDTH 32
#include "util.cpp"
int main(){
cout << "==================start==================" << endl;
cout << " file name " << "pred\t" << "ans\t" << "T/F" << endl;
cout << "---------------------------------------" << endl;
// パラメータ取得
Matrix W1,W2,W3;
Vector b1(256),b2(256),b3(23);
tie(W1,W2,W3,b1,b2,b3) = get_params();
// ラベル取得
Vector labels(154);
labels = get_labels();
// ファイル名作成
int length = 154;
string name_list[length];
for(int i=0; i<length; i++){
name_list[i] = "./pgm/" + to_string(i+1) + ".pgm";
}
int num_correct = 0;
for(int i=0; i<length; i++){
// パラメータを用いてラベル予測
Vector x(1024),a1(256), h1(256), a2(256), h2(256), y(23);
x = matrix_to_vector(get_matrix(name_list[i]));
a1 = W1*x + b1;
h1 = ReLU(a1);
a2 = W2*h1 + b2;
h2 = ReLU(a2);
y = Softmax(W3*h2 + b3);
//y = f(x,b1,b2,b3,W1,W2,W3);
int pred = y.argmax()+1;
// 正解ラベルとともに出力。正解していたらカウントを増やす。
int label = labels[i];
if(pred==label) num_correct++;
cout << name_list[i] << ": \t" << pred << "\t" << label << "\t" << (pred==label) << endl;
}
cout << "=======================================" << endl;
cout << "accuracy = " << num_correct/1.54 << "%" << endl;
cout << "==================end==================" << endl;
}
|
7cd63756ee9418bff5f9583a573317faa86aedfa | abebe7c2bc651e45de70e7570ae87045608599db | /runtime/jit/jit.cc | 6496afd7012f64333351869a5ea52e50f7fb3007 | [
"Apache-2.0",
"NCSA"
] | permissive | Lingcc/AndroidArt | d5bd973905f206e803f4a2dc3ba67a6c9fec4997 | e28ad4b91591c226ed404a2b01104bb99bfeb28f | refs/heads/master | 2021-01-10T16:57:29.594703 | 2016-03-26T00:44:53 | 2016-03-26T00:44:53 | 36,331,295 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,028 | cc | jit.cc | /*
* Copyright 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "jit.h"
#include <dlfcn.h>
#include "art_method-inl.h"
#include "debugger.h"
#include "entrypoints/runtime_asm_entrypoints.h"
#include "interpreter/interpreter.h"
#include "jit_code_cache.h"
#include "jit_instrumentation.h"
#include "oat_file_manager.h"
#include "oat_quick_method_header.h"
#include "offline_profiling_info.h"
#include "profile_saver.h"
#include "runtime.h"
#include "runtime_options.h"
#include "stack_map.h"
#include "utils.h"
namespace art {
namespace jit {
static constexpr bool kEnableOnStackReplacement = true;
// JIT compiler
void* Jit::jit_library_handle_= nullptr;
void* Jit::jit_compiler_handle_ = nullptr;
void* (*Jit::jit_load_)(bool*) = nullptr;
void (*Jit::jit_unload_)(void*) = nullptr;
bool (*Jit::jit_compile_method_)(void*, ArtMethod*, Thread*, bool) = nullptr;
void (*Jit::jit_types_loaded_)(void*, mirror::Class**, size_t count) = nullptr;
bool Jit::generate_debug_info_ = false;
JitOptions* JitOptions::CreateFromRuntimeArguments(const RuntimeArgumentMap& options) {
auto* jit_options = new JitOptions;
jit_options->use_jit_ = options.GetOrDefault(RuntimeArgumentMap::UseJIT);
jit_options->code_cache_initial_capacity_ =
options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheInitialCapacity);
jit_options->code_cache_max_capacity_ =
options.GetOrDefault(RuntimeArgumentMap::JITCodeCacheMaxCapacity);
jit_options->dump_info_on_shutdown_ =
options.Exists(RuntimeArgumentMap::DumpJITInfoOnShutdown);
jit_options->save_profiling_info_ =
options.GetOrDefault(RuntimeArgumentMap::JITSaveProfilingInfo);
jit_options->compile_threshold_ = options.GetOrDefault(RuntimeArgumentMap::JITCompileThreshold);
if (jit_options->compile_threshold_ > std::numeric_limits<uint16_t>::max()) {
LOG(FATAL) << "Method compilation threshold is above its internal limit.";
}
if (options.Exists(RuntimeArgumentMap::JITWarmupThreshold)) {
jit_options->warmup_threshold_ = *options.Get(RuntimeArgumentMap::JITWarmupThreshold);
if (jit_options->warmup_threshold_ > std::numeric_limits<uint16_t>::max()) {
LOG(FATAL) << "Method warmup threshold is above its internal limit.";
}
} else {
jit_options->warmup_threshold_ = jit_options->compile_threshold_ / 2;
}
if (options.Exists(RuntimeArgumentMap::JITOsrThreshold)) {
jit_options->osr_threshold_ = *options.Get(RuntimeArgumentMap::JITOsrThreshold);
if (jit_options->osr_threshold_ > std::numeric_limits<uint16_t>::max()) {
LOG(FATAL) << "Method on stack replacement threshold is above its internal limit.";
}
} else {
jit_options->osr_threshold_ = jit_options->compile_threshold_ * 2;
if (jit_options->osr_threshold_ > std::numeric_limits<uint16_t>::max()) {
jit_options->osr_threshold_ = std::numeric_limits<uint16_t>::max();
}
}
return jit_options;
}
void Jit::DumpInfo(std::ostream& os) {
code_cache_->Dump(os);
cumulative_timings_.Dump(os);
MutexLock mu(Thread::Current(), lock_);
memory_use_.PrintMemoryUse(os);
}
void Jit::AddTimingLogger(const TimingLogger& logger) {
cumulative_timings_.AddLogger(logger);
}
Jit::Jit() : dump_info_on_shutdown_(false),
cumulative_timings_("JIT timings"),
memory_use_("Memory used for compilation", 16),
lock_("JIT memory use lock"),
save_profiling_info_(false) {}
Jit* Jit::Create(JitOptions* options, std::string* error_msg) {
std::unique_ptr<Jit> jit(new Jit);
jit->dump_info_on_shutdown_ = options->DumpJitInfoOnShutdown();
if (jit_compiler_handle_ == nullptr && !LoadCompiler(error_msg)) {
return nullptr;
}
jit->code_cache_.reset(JitCodeCache::Create(
options->GetCodeCacheInitialCapacity(),
options->GetCodeCacheMaxCapacity(),
jit->generate_debug_info_,
error_msg));
if (jit->GetCodeCache() == nullptr) {
return nullptr;
}
jit->save_profiling_info_ = options->GetSaveProfilingInfo();
VLOG(jit) << "JIT created with initial_capacity="
<< PrettySize(options->GetCodeCacheInitialCapacity())
<< ", max_capacity=" << PrettySize(options->GetCodeCacheMaxCapacity())
<< ", compile_threshold=" << options->GetCompileThreshold()
<< ", save_profiling_info=" << options->GetSaveProfilingInfo();
return jit.release();
}
bool Jit::LoadCompilerLibrary(std::string* error_msg) {
jit_library_handle_ = dlopen(
kIsDebugBuild ? "libartd-compiler.so" : "libart-compiler.so", RTLD_NOW);
if (jit_library_handle_ == nullptr) {
std::ostringstream oss;
oss << "JIT could not load libart-compiler.so: " << dlerror();
*error_msg = oss.str();
return false;
}
jit_load_ = reinterpret_cast<void* (*)(bool*)>(dlsym(jit_library_handle_, "jit_load"));
if (jit_load_ == nullptr) {
dlclose(jit_library_handle_);
*error_msg = "JIT couldn't find jit_load entry point";
return false;
}
jit_unload_ = reinterpret_cast<void (*)(void*)>(
dlsym(jit_library_handle_, "jit_unload"));
if (jit_unload_ == nullptr) {
dlclose(jit_library_handle_);
*error_msg = "JIT couldn't find jit_unload entry point";
return false;
}
jit_compile_method_ = reinterpret_cast<bool (*)(void*, ArtMethod*, Thread*, bool)>(
dlsym(jit_library_handle_, "jit_compile_method"));
if (jit_compile_method_ == nullptr) {
dlclose(jit_library_handle_);
*error_msg = "JIT couldn't find jit_compile_method entry point";
return false;
}
jit_types_loaded_ = reinterpret_cast<void (*)(void*, mirror::Class**, size_t)>(
dlsym(jit_library_handle_, "jit_types_loaded"));
if (jit_types_loaded_ == nullptr) {
dlclose(jit_library_handle_);
*error_msg = "JIT couldn't find jit_types_loaded entry point";
return false;
}
return true;
}
bool Jit::LoadCompiler(std::string* error_msg) {
if (jit_library_handle_ == nullptr && !LoadCompilerLibrary(error_msg)) {
return false;
}
bool will_generate_debug_symbols = false;
VLOG(jit) << "Calling JitLoad interpreter_only="
<< Runtime::Current()->GetInstrumentation()->InterpretOnly();
jit_compiler_handle_ = (jit_load_)(&will_generate_debug_symbols);
if (jit_compiler_handle_ == nullptr) {
dlclose(jit_library_handle_);
*error_msg = "JIT couldn't load compiler";
return false;
}
generate_debug_info_ = will_generate_debug_symbols;
return true;
}
bool Jit::CompileMethod(ArtMethod* method, Thread* self, bool osr) {
DCHECK(!method->IsRuntimeMethod());
// Don't compile the method if it has breakpoints.
if (Dbg::IsDebuggerActive() && Dbg::MethodHasAnyBreakpoints(method)) {
VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to breakpoint";
return false;
}
// Don't compile the method if we are supposed to be deoptimized.
instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation();
if (instrumentation->AreAllMethodsDeoptimized() || instrumentation->IsDeoptimized(method)) {
VLOG(jit) << "JIT not compiling " << PrettyMethod(method) << " due to deoptimization";
return false;
}
// If we get a request to compile a proxy method, we pass the actual Java method
// of that proxy method, as the compiler does not expect a proxy method.
ArtMethod* method_to_compile = method->GetInterfaceMethodIfProxy(sizeof(void*));
if (!code_cache_->NotifyCompilationOf(method_to_compile, self, osr)) {
return false;
}
bool success = jit_compile_method_(jit_compiler_handle_, method_to_compile, self, osr);
code_cache_->DoneCompiling(method_to_compile, self);
return success;
}
void Jit::CreateThreadPool() {
CHECK(instrumentation_cache_.get() != nullptr);
instrumentation_cache_->CreateThreadPool();
}
void Jit::DeleteThreadPool() {
if (instrumentation_cache_.get() != nullptr) {
instrumentation_cache_->DeleteThreadPool(Thread::Current());
}
}
void Jit::StartProfileSaver(const std::string& filename,
const std::vector<std::string>& code_paths,
const std::string& foreign_dex_profile_path,
const std::string& app_dir) {
if (save_profiling_info_) {
ProfileSaver::Start(filename, code_cache_.get(), code_paths, foreign_dex_profile_path, app_dir);
}
}
void Jit::StopProfileSaver() {
if (save_profiling_info_ && ProfileSaver::IsStarted()) {
ProfileSaver::Stop();
}
}
bool Jit::JitAtFirstUse() {
if (instrumentation_cache_ != nullptr) {
return instrumentation_cache_->HotMethodThreshold() == 0;
}
return false;
}
bool Jit::CanInvokeCompiledCode(ArtMethod* method) {
return code_cache_->ContainsPc(method->GetEntryPointFromQuickCompiledCode());
}
Jit::~Jit() {
DCHECK(!save_profiling_info_ || !ProfileSaver::IsStarted());
if (dump_info_on_shutdown_) {
DumpInfo(LOG(INFO));
}
DeleteThreadPool();
if (jit_compiler_handle_ != nullptr) {
jit_unload_(jit_compiler_handle_);
jit_compiler_handle_ = nullptr;
}
if (jit_library_handle_ != nullptr) {
dlclose(jit_library_handle_);
jit_library_handle_ = nullptr;
}
}
void Jit::CreateInstrumentationCache(size_t compile_threshold,
size_t warmup_threshold,
size_t osr_threshold) {
instrumentation_cache_.reset(
new jit::JitInstrumentationCache(compile_threshold, warmup_threshold, osr_threshold));
}
void Jit::NewTypeLoadedIfUsingJit(mirror::Class* type) {
jit::Jit* jit = Runtime::Current()->GetJit();
if (jit != nullptr && jit->generate_debug_info_) {
DCHECK(jit->jit_types_loaded_ != nullptr);
jit->jit_types_loaded_(jit->jit_compiler_handle_, &type, 1);
}
}
void Jit::DumpTypeInfoForLoadedTypes(ClassLinker* linker) {
struct CollectClasses : public ClassVisitor {
bool operator()(mirror::Class* klass) override {
classes_.push_back(klass);
return true;
}
std::vector<mirror::Class*> classes_;
};
if (generate_debug_info_) {
ScopedObjectAccess so(Thread::Current());
CollectClasses visitor;
linker->VisitClasses(&visitor);
jit_types_loaded_(jit_compiler_handle_, visitor.classes_.data(), visitor.classes_.size());
}
}
extern "C" void art_quick_osr_stub(void** stack,
uint32_t stack_size_in_bytes,
const uint8_t* native_pc,
JValue* result,
const char* shorty,
Thread* self);
bool Jit::MaybeDoOnStackReplacement(Thread* thread,
ArtMethod* method,
uint32_t dex_pc,
int32_t dex_pc_offset,
JValue* result) {
if (!kEnableOnStackReplacement) {
return false;
}
Jit* jit = Runtime::Current()->GetJit();
if (jit == nullptr) {
return false;
}
if (kRuntimeISA == kMips || kRuntimeISA == kMips64) {
VLOG(jit) << "OSR not supported on this platform: " << kRuntimeISA;
return false;
}
if (UNLIKELY(__builtin_frame_address(0) < thread->GetStackEnd())) {
// Don't attempt to do an OSR if we are close to the stack limit. Since
// the interpreter frames are still on stack, OSR has the potential
// to stack overflow even for a simple loop.
// b/27094810.
return false;
}
// Get the actual Java method if this method is from a proxy class. The compiler
// and the JIT code cache do not expect methods from proxy classes.
method = method->GetInterfaceMethodIfProxy(sizeof(void*));
// Cheap check if the method has been compiled already. That's an indicator that we should
// osr into it.
if (!jit->GetCodeCache()->ContainsPc(method->GetEntryPointFromQuickCompiledCode())) {
return false;
}
// Fetch some data before looking up for an OSR method. We don't want thread
// suspension once we hold an OSR method, as the JIT code cache could delete the OSR
// method while we are being suspended.
const size_t number_of_vregs = method->GetCodeItem()->registers_size_;
const char* shorty = method->GetShorty();
std::string method_name(VLOG_IS_ON(jit) ? PrettyMethod(method) : "");
void** memory = nullptr;
size_t frame_size = 0;
ShadowFrame* shadow_frame = nullptr;
const uint8_t* native_pc = nullptr;
{
ScopedAssertNoThreadSuspension sts(thread, "Holding OSR method");
const OatQuickMethodHeader* osr_method = jit->GetCodeCache()->LookupOsrMethodHeader(method);
if (osr_method == nullptr) {
// No osr method yet, just return to the interpreter.
return false;
}
CodeInfo code_info = osr_method->GetOptimizedCodeInfo();
StackMapEncoding encoding = code_info.ExtractEncoding();
// Find stack map starting at the target dex_pc.
StackMap stack_map = code_info.GetOsrStackMapForDexPc(dex_pc + dex_pc_offset, encoding);
if (!stack_map.IsValid()) {
// There is no OSR stack map for this dex pc offset. Just return to the interpreter in the
// hope that the next branch has one.
return false;
}
// We found a stack map, now fill the frame with dex register values from the interpreter's
// shadow frame.
DexRegisterMap vreg_map =
code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_vregs);
frame_size = osr_method->GetFrameSizeInBytes();
// Allocate memory to put shadow frame values. The osr stub will copy that memory to
// stack.
// Note that we could pass the shadow frame to the stub, and let it copy the values there,
// but that is engineering complexity not worth the effort for something like OSR.
memory = reinterpret_cast<void**>(malloc(frame_size));
CHECK(memory != nullptr);
memset(memory, 0, frame_size);
// Art ABI: ArtMethod is at the bottom of the stack.
memory[0] = method;
shadow_frame = thread->PopShadowFrame();
if (!vreg_map.IsValid()) {
// If we don't have a dex register map, then there are no live dex registers at
// this dex pc.
} else {
for (uint16_t vreg = 0; vreg < number_of_vregs; ++vreg) {
DexRegisterLocation::Kind location =
vreg_map.GetLocationKind(vreg, number_of_vregs, code_info, encoding);
if (location == DexRegisterLocation::Kind::kNone) {
// Dex register is dead or uninitialized.
continue;
}
if (location == DexRegisterLocation::Kind::kConstant) {
// We skip constants because the compiled code knows how to handle them.
continue;
}
DCHECK_EQ(location, DexRegisterLocation::Kind::kInStack);
int32_t vreg_value = shadow_frame->GetVReg(vreg);
int32_t slot_offset = vreg_map.GetStackOffsetInBytes(vreg,
number_of_vregs,
code_info,
encoding);
DCHECK_LT(slot_offset, static_cast<int32_t>(frame_size));
DCHECK_GT(slot_offset, 0);
(reinterpret_cast<int32_t*>(memory))[slot_offset / sizeof(int32_t)] = vreg_value;
}
}
native_pc = stack_map.GetNativePcOffset(encoding) + osr_method->GetEntryPoint();
VLOG(jit) << "Jumping to "
<< method_name
<< "@"
<< std::hex << reinterpret_cast<uintptr_t>(native_pc);
}
{
ManagedStack fragment;
thread->PushManagedStackFragment(&fragment);
(*art_quick_osr_stub)(memory,
frame_size,
native_pc,
result,
shorty,
thread);
if (UNLIKELY(thread->GetException() == Thread::GetDeoptimizationException())) {
thread->DeoptimizeWithDeoptimizationException(result);
}
thread->PopManagedStackFragment(fragment);
}
free(memory);
thread->PushShadowFrame(shadow_frame);
VLOG(jit) << "Done running OSR code for " << method_name;
return true;
}
void Jit::AddMemoryUsage(ArtMethod* method, size_t bytes) {
if (bytes > 4 * MB) {
LOG(INFO) << "Compiler allocated "
<< PrettySize(bytes)
<< " to compile "
<< PrettyMethod(method);
}
MutexLock mu(Thread::Current(), lock_);
memory_use_.AddValue(bytes);
}
} // namespace jit
} // namespace art
|
84921e0239fbfb2e45ba748453f278b87bc9a3e9 | 9b963f56e0964a88f2a45b6fe9aa371e1c1c704e | /Dynamic_Programming/2688-줄어들지않아(DP).cpp | e270cf66a428290dd86b4b5bc3ccc2fedc3e1d71 | [] | no_license | kewook55/PS-BOJ | 0d1880ac849dca3cad516204796d07d15836073a | aced5d3e2b073d4a3ef92607c159efe9936ff940 | refs/heads/master | 2022-12-15T10:59:41.845978 | 2020-09-12T05:09:45 | 2020-09-12T05:09:45 | 267,512,154 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 732 | cpp | 2688-줄어들지않아(DP).cpp | /*
cache[i][j] : i자리의 숫자에서 맨앞자리가 j일때의 줄어들지않는 수의 개수
cache[i][j] += cache[i-1][k] (j <= k) : 맨앞자리가 j라면 한자리가 적을때 j보다 큰 앞자리의 총합
*/
#include<iostream>
using namespace std;
long long cache[65][10];
int main(void) {
ios::sync_with_stdio(NULL);
cin.tie(NULL); cout.tie(NULL);
int T, N;
for (int i = 0; i <= 9; i++)cache[1][i] = 1;
for (int i = 2; i <= 64; i++) {
for (int j = 0; j <= 9; j++) {
for (int k = j; k <= 9; k++) {
cache[i][j] += cache[i - 1][k];
}
}
}
cin >> T;
while (T--) {
cin >> N;
long long ans = 0;
for (int i = 0; i <= 9; i++)ans += cache[N][i];
cout << ans << "\n";
}
return 0;
} |
cfe24f8af39fa15c0394c474f92055e90a7faba2 | 226aad88fdca9ae825cf150802ca8d080acd11d4 | /Documents/Competitive/Self/Stack/Stacks.cpp | 700e23e7246ff5cabee86ee4ed6176e89af6621e | [] | no_license | SohamHarnale/Competitive-Coding | 23a2ce68fe186ed81bc59e7ddd57bfdf4da61282 | 4b71b4daac118e3dc70084137b844155bdd6983b | refs/heads/master | 2021-01-11T22:46:12.920672 | 2017-03-01T05:43:31 | 2017-03-01T05:43:31 | 79,031,063 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,015 | cpp | Stacks.cpp | /*
* Name: Soham Harnale
* Roll No: SE202061
*/
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;
const int iSize=10;
class cStack1
{
int iTop;
char cArr[iSize];
public:
cStack1()
{
iTop=-1;
}
int isempty()
{
if(iTop==-1)
return 1;
else
return 0;
}
int isfull()
{
if(iTop==iSize-1)
return 1;
else
return 0;
}
void vPush(char a)
{
if(!isfull())
{
iTop++;
cArr[iTop]=a;
}
else
cout<<"Stack overflow !"<<endl;
}
char cPop()
{
char temp;
if(!isempty())
{
temp=cArr[iTop];
iTop--;
return temp;
}
else
{
cout<<"Stack underflow !"<<endl;
return ' ';
}
}
friend class cConvert;
};
class cStack2
{
char cAr[iSize][iSize];
int iTop;
public:
cStack2()
{
iTop=-1;
for(int i=0;i<iSize;i++)
{
for(int j=0;j<iSize;j++)
{
cAr[i][j]='\0';
}
}
}
int isempty()
{
if(iTop==-1)
return 1;
else
return 0;
}
int isfull()
{
if(iTop==iSize-1)
return 1;
else
return 0;
}
void vPush(string &p)
{
if(!isfull())
{
iTop++;
p.copy(cAr[iTop],iSize);
}
else
cout<<"Stack overflow !"<<endl;
}
string vPop()
{
if(!isempty())
{
string temp;
temp=cAr[iTop];
iTop--;
return temp;
}
else
{
cout<<"Stack underflow !"<<endl;
return '\0';
}
}
friend class cConvert;
};
class cConvert
{
char exp[iSize];
public :
void vGetdata()
{
cout<<"Enter expression in standard form : "<<endl;
cin>>exp;
}
void vDisplay()
{
cout<<exp<<endl;
}
void vinfixPost(cConvert &);
void vinfixPre(cConvert &);
void vpostInfix(cConvert &);
void vpreInfix(cConvert &);
void vpostPre(cConvert &);
void vprePost(cConvert &);
int iPrecedence(char);
void vreverse();
};
int cConvert::iPrecedence(char c)
{
if(c=='^')
return 4;
else if(c=='*' || c=='/')
return 3;
else if(c=='+' || c=='-')
return 2;
else if(c=='(')
return 1;
else
return 0;
}
void cConvert::vinfixPost(cConvert &ex)
{
cStack1 s1;
int k=0,i=0;
char tkn;
tkn=ex.exp[i];
while(tkn!='\0')
{
if(((tkn>='a') && (tkn<='z')) || ((tkn>='A') && (tkn<='Z')))
{
exp[k]=ex.exp[i];
k++;
}
else
{
if(tkn == '(')
{
s1.vPush('(');
}
else
{
if(tkn==')')
{
while((tkn=s1.cPop())!='(')
{
exp[k]=tkn;
k++;
}
}
else
{
while((!s1.isempty()) && (iPrecedence(s1.cArr[s1.iTop]))>=iPrecedence(tkn))
{
exp[k]=s1.cPop();
k++;
}
s1.vPush(tkn);
}
}
}
i++;
tkn=ex.exp[i];
}
while(!s1.isempty())
{
exp[k]=s1.cPop();
k++;
}
exp[k]='\0';
}
void cConvert::vinfixPre(cConvert &ex)
{
cStack1 s1;
int k=0,i=0;
char tkn;
ex.vreverse();
tkn=ex.exp[i];
while(tkn!='\0')
{
if(((tkn>='a') && (tkn<='z')) || ((tkn>='A') && (tkn<='Z')))
{
exp[k]=ex.exp[i];
k++;
}
else
{
if(tkn == ')')
{
s1.vPush(')');
}
else
{
if(tkn=='(')
{
while((tkn=s1.cPop())!=')')
{
exp[k]=tkn;
k++;
}
}
else
{
while((!s1.isempty()) && (iPrecedence(s1.cArr[s1.iTop]))>=iPrecedence(tkn))
{
exp[k]=s1.cPop();
k++;
}
s1.vPush(tkn);
}
}
}
i++;
tkn=ex.exp[i];
}
while(!s1.isempty())
{
exp[k]=s1.cPop();
k++;
}
exp[k]='\0';
vreverse();
}
void cConvert::vpostInfix(cConvert &ex)
{
cStack2 s;
int i=0;
string s1,s2,s3;
char tkn=ex.exp[i];
while(tkn!='\0')
{
if(((tkn>='a') && (tkn<='z')) || ((tkn >='A') && (tkn<='Z')))
{
s1=tkn;
s.vPush(s1);
}
else
{
if(s.iTop<1)
cout<<"Error-Input values are not sufficient"<<endl;
else
{
s1=s.vPop();
s2=s.vPop();
s3="("+s2+tkn+s1+")";
s.vPush(s3);
}
}
tkn=ex.exp[++i];
strcpy(exp,s.cAr[s.iTop]);
}
}
void cConvert::vpreInfix(cConvert &ex)
{
ex.vreverse();
cStack2 s;
int i=0;
string s1,s2,s3;
char tkn=ex.exp[i];
while(tkn!='\0')
{
if(((tkn>='a') && (tkn<='z')) || ((tkn>='A') && (tkn<='Z')))
{
s1=tkn;
s.vPush(s1);
}
else
{
if(s.iTop<1)
cout<<"Error-Input insufficient"<<endl;
else
{
s1=s.vPop();
s2=s.vPop();
s3="("+s1+tkn+s2+")";
s.vPush(s3);
}
}
tkn=ex.exp[++i];
strcpy(exp,s.cAr[s.iTop]);
}
}
void cConvert::vpostPre(cConvert &ex)
{
cStack2 s;
int i=0;
string s1,s2,s3;
char tkn;
tkn=ex.exp[i];
while(tkn!='\0')
{
if(((tkn>='a') && (tkn<='z')) || ((tkn>='A') && (tkn<='Z')))
{
s1=tkn;
s.vPush(s1);
}
else
{
if(s.iTop<1)
cout<<"Error-Input insufficient"<<endl;
else
{
s1=s.vPop();
s2=s.vPop();
s3=tkn+s2+s1;
s.vPush(s3);
}
}
tkn=ex.exp[++i];
strcpy(exp,s.cAr[s.iTop]);
}
while(!s.isempty() && s.iTop>0)
{
s1=s.vPop();
s2=s.vPop();
s3=s2+s1;
s.vPush(s3);
tkn=ex.exp[++i];
strcpy(exp,s.cAr[s.iTop]);
}
}
void cConvert::vprePost(cConvert &ex)
{
ex.vreverse();
cStack2 s;
int i=0;
string s1,s2,s3;
char tkn=ex.exp[i];
while(tkn!='\0')
{
if(((tkn>='a') && (tkn<='z')) || ((tkn>='A') && (tkn<='Z')))
{
s1=tkn;
s.vPush(s1);
}
else
{
if(s.iTop<1)
cout<<"Input values insufficient"<<endl;
else
{
s1=s.vPop();
s2=s.vPop();
s3=s1+s2+tkn;
s.vPush(s3);
}
}
tkn=ex.exp[++i];
strcpy(exp,s.cAr[s.iTop]);
}
tkn=ex.exp[i];
while(tkn!='\0')
{
s1=s.vPop();
s3=s3+tkn;
s.vPush(s3);
i++;
tkn=ex.exp[i];
strcpy(exp,s.cAr[s.iTop]);
}
}
void cConvert::vreverse()
{
cStack1 s1;
int i=0;
while(exp[i]!='\0')
{
s1.vPush(exp[i]);
i++;
}
i=0;
do
{
exp[i]=s1.cPop();
i++;
}while(!s1.isempty());
exp[i]='\0';
}
int main()
{
cConvert a,b;
char ans;
int choice;
do
{
cout<<"Select the stack conversion : "<<endl;
cout<<"1.Infix to Postfix"<<endl;
cout<<"2.Infix to Prefix"<<endl;
cout<<"3.Postfix to Infix"<<endl;
cout<<"4.Prefix to Infix"<<endl;
cout<<"5.Postfix to Prefix"<<endl;
cout<<"6.Prefix to Postfix"<<endl;
cin>>choice;
switch(choice)
{
case 1 :a.vGetdata();
b.vinfixPost(a);
cout<<"Conversion from infix to postfix : "<<endl;
b.vDisplay();
break;
case 2 :a.vGetdata();
b.vinfixPre(a);
cout<<"Conversion from infix to prefix : "<<endl;
b.vDisplay();
break;
case 3 :a.vGetdata();
b.vpostInfix(a);
cout<<"Conversion from postfix to infix : "<<endl;
b.vDisplay();
break;
case 4 :a.vGetdata();
b.vpreInfix(a);
cout<<"Conversion from prefix to infix : "<<endl;
b.vDisplay();
break;
case 5 :a.vGetdata();
b.vpostPre(a);
cout<<"Conversion from postfix to prefix : "<<endl;
b.vDisplay();
break;
case 6 :a.vGetdata();
b.vprePost(a);
cout<<"Conversion from prefix to postfix : "<<endl;
b.vDisplay();
break;
default:cout<<"Wrong choice ! "<<endl;
break;
}
cout<<"Do you want to continue ?(y/n)"<<endl;
cin>>ans;
}while(ans=='y');
return 0;
}
|
fba989d9df0245755e935cdadd2833e2441b6d8c | 6c0632bdc1486f4819be4a7700b0f1a3ef546e4e | /vol101/u10105/u10105.h | 081d64faad57b7f694415a898247233bdb1296c8 | [] | no_license | azakrytnoi/uva | f0f5cb51be5b92f4db5c3135309ec27c4074fd55 | 1578529a14d565acf4f59eec86c33d4ba218beb0 | refs/heads/develop | 2022-02-28T06:55:01.144635 | 2022-02-09T14:46:54 | 2022-02-09T14:46:54 | 51,453,156 | 4 | 0 | null | 2019-09-17T12:06:21 | 2016-02-10T16:17:56 | C++ | UTF-8 | C++ | false | false | 217 | h | u10105.h | #pragma once
class U10105 {
public:
static const char* libname()
{
return "u10105";
}
U10105() {}
void operator()() const;
};
#ifdef POPULATE_CACHE
populate <U10105> pu10105;
#endif
|
8e90f877c7263def6ed31dd7f761a46015cecea2 | 59bdc4eb691bff762187f05001c304a967066b95 | /tests/boundingboxtest.cpp | 95b2a73d920b143281562c174838dd01350237da | [] | no_license | David-Hickey/cpp-lib | 1d6c1880708e43a4949d97af14ebf9ca5d6d66cb | 8869fbe67cd2e6191dc37d48136610f7fd28f5fa | refs/heads/master | 2020-11-25T09:20:35.806636 | 2020-11-19T12:16:10 | 2020-11-19T12:16:10 | 228,592,871 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,605 | cpp | boundingboxtest.cpp | #include "boundingbox.hpp"
#include "arrayutils.hpp"
#include "testutils.hpp"
#include <random>
using namespace dav;
const BoundingBox bb(96, 100, 98);
const MathArray<int, 3> inside{1, 1, 1};
const MathArray<int, 3> outside_x_greater{53, 0, 0};
const MathArray<int, 3> outside_x_lesser{-57, 0, 0};
const MathArray<int, 3> outside_y_greater{0, 51, 0};
const MathArray<int, 3> outside_y_lesser{0, -51, 0};
const MathArray<int, 3> outside_z_greater{0, 0, 51};
const MathArray<int, 3> outside_z_lesser{0, 0, -52};
const MathArray<int, 3> outside{3, -51, 51};
void test_contains() {
assert(bb.in_bounds(inside), "failed contains inside");
assert(!bb.in_bounds(outside_x_greater), "failed contains outside 1");
assert(!bb.in_bounds(outside_x_lesser), "failed contains outside 2");
assert(!bb.in_bounds(outside_y_greater), "failed contains outside 3");
assert(!bb.in_bounds(outside_y_lesser), "failed contains outside 4");
assert(!bb.in_bounds(outside_z_greater), "failed contains outside 5");
assert(!bb.in_bounds(outside_z_lesser), "failed contains outside 6");
assert(!bb.in_bounds(outside), "failed contains outside 7");
}
void test_reflect() {
assert_all_eq(bb.reflect(inside), inside, "Failed reflection inside");
assert_all_eq(bb.reflect(outside_x_greater), MathArray<int, 3>{43, 0, 0}, "Failed reflection outside 1");
assert_all_eq(bb.reflect(outside_x_lesser), MathArray<int, 3>{-39, 0, 0}, "Failed reflection outside 2");
assert_all_eq(bb.reflect(outside_y_greater), MathArray<int, 3>{0, 49, 0}, "Failed reflection outside 3");
assert_all_eq(bb.reflect(outside_y_lesser), MathArray<int, 3>{0, -49, 0}, "Failed reflection outside 4");
assert_all_eq(bb.reflect(outside_z_greater), MathArray<int, 3>{0, 0, 47}, "Failed reflection outside 5");
assert_all_eq(bb.reflect(outside_z_lesser), MathArray<int, 3>{0, 0, -46}, "Failed reflection outside 6");
assert_all_eq(bb.reflect(outside), MathArray<int, 3>{3, -49, 47}, "Failed reflection outside 7");
MathArray<int, 3> copy_inside(inside);
MathArray<int, 3> copy_outside_x_greater(outside_x_greater);
MathArray<int, 3> copy_outside_x_lesser(outside_x_lesser);
MathArray<int, 3> copy_outside_y_greater(outside_y_greater);
MathArray<int, 3> copy_outside_y_lesser(outside_y_lesser);
MathArray<int, 3> copy_outside_z_greater(outside_z_greater);
MathArray<int, 3> copy_outside_z_lesser(outside_z_lesser);
MathArray<int, 3> copy_outside(outside);
assert_all_eq(bb.reflect_situ(copy_inside), inside, "Failed reflection inside situ 1");
assert_all_eq(bb.reflect_situ(copy_outside_x_greater), MathArray<int, 3>{43, 0, 0}, "Failed reflection outside 1 situ 1");
assert_all_eq(bb.reflect_situ(copy_outside_x_lesser), MathArray<int, 3>{-39, 0, 0}, "Failed reflection outside 2 situ 1");
assert_all_eq(bb.reflect_situ(copy_outside_y_greater), MathArray<int, 3>{0, 49, 0}, "Failed reflection outside 3 situ 1");
assert_all_eq(bb.reflect_situ(copy_outside_y_lesser), MathArray<int, 3>{0, -49, 0}, "Failed reflection outside 4 situ 1");
assert_all_eq(bb.reflect_situ(copy_outside_z_greater), MathArray<int, 3>{0, 0, 47}, "Failed reflection outside 5 situ 1");
assert_all_eq(bb.reflect_situ(copy_outside_z_lesser), MathArray<int, 3>{0, 0, -46}, "Failed reflection outside 6 situ 1");
assert_all_eq(bb.reflect_situ(copy_outside), MathArray<int, 3>{3, -49, 47}, "Failed reflection outside 7 situ 1");
assert_all_eq(copy_inside, inside, "Failed reflection inside situ 2");
assert_all_eq(copy_outside_x_greater, MathArray<int, 3>{43, 0, 0}, "Failed reflection outside 1 situ 2");
assert_all_eq(copy_outside_x_lesser, MathArray<int, 3>{-39, 0, 0}, "Failed reflection outside 2 situ 2");
assert_all_eq(copy_outside_y_greater, MathArray<int, 3>{0, 49, 0}, "Failed reflection outside 3 situ 2");
assert_all_eq(copy_outside_y_lesser, MathArray<int, 3>{0, -49, 0}, "Failed reflection outside 4 situ 2");
assert_all_eq(copy_outside_z_greater, MathArray<int, 3>{0, 0, 47}, "Failed reflection outside 5 situ 2");
assert_all_eq(copy_outside_z_lesser, MathArray<int, 3>{0, 0, -46}, "Failed reflection outside 6 situ 2");
assert_all_eq(copy_outside, MathArray<int, 3>{3, -49, 47}, "Failed reflection outside 7 situ 2");
assert(bb.reflect_z(inside[2]) == inside[2], "Failed scalar reflection z");
assert(bb.reflect_z(outside[2]) == 47, "Failed scalar reflection z");
assert(bb.reflect_y(inside[1]) == inside[1], "Failed scalar reflection y");
assert(bb.reflect_y(outside[1]) == -49, "Failed scalar reflection y");
assert(bb.reflect_x(inside[0]) == inside[0], "Failed scalar reflection x");
assert(bb.reflect_x(outside_x_greater[0]) == 43, "Failed scalar reflection x");
}
void test_volume() {
assert(bb.volume() == 100*98*96, "Failed volume calculation");
}
void test_getters() {
assert(bb.get_xmin() == -48, "Failed get_xmin");
assert(bb.get_xmax() == 48, "Failed get_xmax");
assert(bb.get_ymin() == -50, "Failed get_ymin");
assert(bb.get_ymax() == 50, "Failed get_ymax");
assert(bb.get_zmin() == -49, "Failed get_zmin");
assert(bb.get_zmax() == 49, "Failed get_zmax");
assert(bb.get_xsize() == 96, "Failed get_xsize");
assert(bb.get_ysize() == 100, "Failed get_ysize");
assert(bb.get_zsize() == 98, "Failed get_zsize");
}
void test_constructors() {
const BoundingBox bb1(-5, +5, -10, +10, -15, +15);
const BoundingBox bb2(10, 20, 30);
const BoundingBox bb3(bb1);
assert_all_eq(bb1.get_lower_bounds(), bb2.get_lower_bounds(), "3-argument constructor failed");
assert_all_eq(bb1.get_upper_bounds(), bb2.get_upper_bounds(), "3-argument constructor failed");
assert_all_eq(bb1.get_lower_bounds(), bb3.get_lower_bounds(), "copy constructor failed");
assert_all_eq(bb1.get_upper_bounds(), bb3.get_upper_bounds(), "copy constructor failed");
}
void test_random() {
std::random_device dev;
std::mt19937 engine(dev());
{
const BoundingBox bb(10, 20, 30);
for (size_t i = 0; i < 1000; ++i) {
const MathArray<double, 3> random_point = bb.random_point_in_bounds(engine);
assert(bb.in_bounds(random_point), "Random point in bounds was out of bounds");
}
}
{
const BoundingBox bb(1000, 10, 10);
const double area_ratio = bb.get_xsurface() / (bb.get_zsurface() + bb.get_ysurface());
double end_points = 0;
const int n = 100'000'000;
for (int i = 0; i < n; ++i) {
const auto pt = bb.random_point_on_surface(engine);
if (int(std::abs(pt[0])) == int(bb.get_xmax())) {
end_points ++;
}
}
const double injection_ratio = (end_points / n);
assert(std::abs((injection_ratio - area_ratio) / area_ratio) < 1e-2, "Failed surface injection");
}
}
void test_area() {
const BoundingBox bb(13, 17, 23);
assert(bb.get_xsurface() == 17*23);
assert(bb.get_ysurface() == 23*13);
assert(bb.get_zsurface() == 13*17);
}
void test_elementwise_filters() {
const MathArray<double, 5> a1{1, 2, 3, 4, 5 };
const MathArray<double, 5> a2{0.5, 2, 5, -1, 10};
assert_all_eq(elementwise_max(a1, a2), {1, 2, 5, 4, 10}, "Failed elementwise_max test");
assert_all_eq(elementwise_min(a1, a2), {0.5, 2, 3, -1, 5}, "Failed elementwise_max test");
}
int main() {
test_contains();
test_reflect();
test_volume();
test_getters();
test_constructors();
test_random();
test_area();
test_elementwise_filters();
}
|
f1fc668a1a9b24248815e8b04b9ca8b0a0fecbd8 | 4220eeefda7b2abbd9d6c4a1e4c867eaa1c28d09 | /include/RaZ/Physics/RigidBody.hpp | 9d96016d32cc155a8c9ba1b735a64af9fbba2a36 | [
"MIT"
] | permissive | alski2020/RaZ | 1072f08ba1765afb6a456a2c69fc9bcb79c3a741 | 522c33f5566e737df51a820352a91c99a5450603 | refs/heads/master | 2023-08-10T17:53:10.991644 | 2021-09-27T19:18:48 | 2021-09-27T19:18:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,884 | hpp | RigidBody.hpp | #pragma once
#ifndef RAZ_RIGIDBODY_HPP
#define RAZ_RIGIDBODY_HPP
#include "RaZ/Component.hpp"
#include "RaZ/Math/Vector.hpp"
namespace Raz {
class RigidBody final : public Component {
friend class PhysicsSystem;
public:
/// Creates a rigid body with given mass & bounciness.
/// \param mass Mass of the rigid body. 0 represents an infinite mass.
/// \param bounciness Coefficient of restitution (must be between 0 & 1).
constexpr RigidBody(float mass, float bounciness) noexcept : m_mass{ mass }, m_invMass{ (mass != 0.f ? 1.f / mass : 0.f) } { setBounciness(bounciness); }
constexpr float getMass() const noexcept { return m_mass; }
constexpr float getInvMass() const noexcept { return m_invMass; }
constexpr float getBounciness() const noexcept { return m_bounciness; }
constexpr const Vec3f& getForces() const noexcept { return m_forces; }
constexpr const Vec3f& getVelocity() const noexcept { return m_velocity; }
constexpr void setMass(float mass) noexcept { m_mass = mass; }
constexpr void setBounciness(float bounciness) noexcept {
assert("Error: The bounciness value must be between 0 & 1." && (bounciness >= 0.f && bounciness <= 1.f));
m_bounciness = bounciness;
}
constexpr void setVelocity(const Vec3f& velocity) noexcept { m_velocity = velocity; }
constexpr void applyForces(const Vec3f& gravity) noexcept { m_forces = m_mass * gravity; }
private:
float m_mass {}; ///< Mass of the rigid body.
float m_invMass {}; ///< Inverse mass of the rigid body.
float m_bounciness {}; ///< Coefficient of restitution, determining the amount of energy kept by the rigid body when bouncing off.
Vec3f m_forces {}; ///< Forces applied to the rigid body.
Vec3f m_velocity {}; ///< Velocity of the rigid body.
Vec3f m_oldPosition {}; ///< Previous position of the rigid body.
};
} // namespace Raz
#endif // RAZ_RIGIDBODY_HPP
|
a1f2cafa1b403631d9d8190b924040e15e748435 | c9f2ca0490cb6fa3eb2ce0e5f1e5a15870eea2f5 | /Common/MFC/BaseDlg.cpp | 5dbdb19243439713980c9605577901da1a81fcc8 | [] | no_license | afrozm/projects | 936dbf1e99e27a8ba5399ad5d6c66f450dd032c7 | 82ba1194d6db3a7662956987586375ec657a3a59 | refs/heads/master | 2021-04-18T20:12:45.481202 | 2021-01-06T09:58:23 | 2021-01-06T09:58:23 | 39,421,550 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,102 | cpp | BaseDlg.cpp | // ImageDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BaseDlg.h"
// CBaseDlg dialog
IMPLEMENT_DYNAMIC(CBaseDlg, CMFCBaseDlg)
CBaseDlg::CBaseDlg(UINT nIDTemplate, CWnd* pParent /*=NULL*/)
: CMFCBaseDlg(nIDTemplate, pParent), mControlResizer(this)
{
}
CBaseDlg::~CBaseDlg()
{
}
BOOL CBaseDlg::CreateView(CWnd* pParent /* = NULL */)
{
CWnd *pParentWnd(pParent ? pParent : m_pParentWnd);
if (m_pParentWnd != pParentWnd)
m_pParentWnd = pParentWnd;
return Create(m_lpszTemplateName, m_pParentWnd);
}
void CBaseDlg::GetClientRect2(LPRECT outClientRect) const
{
GetClientRect(outClientRect);
}
void CBaseDlg::GetClientRect2( HWND hWnd, LPRECT outClientRect )
{
if (!::SendMessage(hWnd, WM_GET_CLIENT_RECT2, (WPARAM)outClientRect, 0))
::GetClientRect(hWnd, outClientRect);
}
BEGIN_MESSAGE_MAP(CBaseDlg, CMFCBaseDlg)
ON_WM_SIZE()
ON_MESSAGE(WM_GET_CLIENT_RECT2, OnGetClientRect2)
END_MESSAGE_MAP()
// CBaseDlg message handlers
afx_msg void CBaseDlg::OnSize(UINT nType, int cx, int cy)
{
__super::OnSize(nType, cx, cy);
mControlResizer.DoReSize();
}
void CBaseDlg::AdjustWidthHeightWithParent(BOOL bAdjustWidht /* = TRUE */, BOOL bAdjustHeight /* = TRUE */)
{
CRect wr;
GetWindowRect(wr);
CRect pcr;
CWnd *pParent(m_pParentWnd ? m_pParentWnd : GetParent());
ASSERT(pParent->GetSafeHwnd() != NULL);
GetClientRect2(pParent->GetSafeHwnd(), pcr);
pParent->ScreenToClient(wr);
if (bAdjustWidht) {
wr.left = pcr.left;
wr.right = pcr.right;
}
if (bAdjustHeight) {
wr.top = pcr.top;
wr.bottom = pcr.bottom;
}
if (bAdjustWidht || bAdjustHeight)
SetWindowPos(NULL, wr.left, wr.top, wr.Width(), wr.Height(), SWP_NOZORDER);
}
void CBaseDlg::GetControlRect( int controlID, LPRECT outControlRect )
{
GetControlRect(GetDlgItem(controlID), outControlRect);
}
void CBaseDlg::GetControlRect( CWnd *pChildControl, LPRECT outControlRect )
{
ASSERT(pChildControl->GetSafeHwnd() != NULL);
pChildControl->GetWindowRect(outControlRect);
ScreenToClient(outControlRect);
}
bool CBaseDlg::SetWindowSize( int width, int height )
{
CRect wr;
GetWindowRect(wr);
if (wr.Height() != height || wr.Width() != width) {
SetWindowPos(NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
return true;
}
return false;
}
bool CBaseDlg::SetWindowPosition( int x, int y )
{
CRect cr;
GetWindowRect(cr);
CWnd *pParent(m_pParentWnd ? m_pParentWnd : GetParent());
if (pParent)
pParent->ScreenToClient(cr);
if (x != cr.left || y != cr.top) {
SetWindowPos(NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
return true;
}
return false;
}
bool CBaseDlg::SetWindowRect( LPRECT newRect )
{
if (newRect == NULL)
return false;
CRect cr, newWr(newRect);
GetWindowRect(cr);
CWnd *pParent(m_pParentWnd ? m_pParentWnd : GetParent());
if (pParent)
pParent->ScreenToClient(cr);
if (cr != newWr) {
SetWindowPos(NULL, newWr.left, newWr.top, newWr.Width(), newWr.Height(), SWP_NOZORDER);
return true;
}
return false;
}
LRESULT CBaseDlg::OnGetClientRect2( WPARAM wParam, LPARAM lParam )
{
LPRECT outRect((LPRECT)wParam);
GetClientRect2(outRect);
return TRUE;
}
|
f0abf281305918dfdc7ab7574adba13492ce3310 | 1c0e31287ed0c72223f4c4b7d55e4f871f563646 | /common/log/include/vxlLog.h | 09f2335cd02e5f7bd7d05c73cf9ba593835ed67e | [] | no_license | viccwq/cmake_module | 4a2b3411009223f3bebb435e2a0c22ad6e43e6e4 | d13c4e6faba0e975c6ceb8ec135b3847ba446162 | refs/heads/master | 2020-03-29T13:28:59.086375 | 2019-05-23T03:24:35 | 2019-05-23T03:24:35 | 149,963,872 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 3,086 | h | vxlLog.h | #ifndef __VXLLOG_H__
#define __VXLLOG_H__
#include <string>
#include <mutex>
#include "vxlLogAux.h"
#include "vxlMacros.h"
#ifdef _WIN32
#ifdef LOG_EXPORTS
#define INTERFACE_DLL __declspec(dllexport)
#else
#define INTERFACE_DLL __declspec(dllimport)
#endif
#elif defined __linux__
#define INTERFACE_CLASS __attribute__ ((visibility("default")))
#endif
#define LogTrace(fmt, ...) if((Logger::m_logLevel <= VXL_LOG_TRACE) && Logger::m_bEnableFileLog){Logger::Instance()->Log(VXL_LOG_TRACE, fmt, ##__VA_ARGS__);}
#define LogInfo(fmt, ...) if((Logger::m_logLevel <= VXL_LOG_INFO) && Logger::m_bEnableFileLog){Logger::Instance()->Log(VXL_LOG_INFO, fmt, ##__VA_ARGS__);}
#define LogWarning(fmt, ...) if((Logger::m_logLevel <= VXL_LOG_WARNING) && Logger::m_bEnableFileLog){Logger::Instance()->Log(VXL_LOG_WARNING, fmt, ##__VA_ARGS__);}
#define LogError(fmt, ...) if((Logger::m_logLevel <= VXL_LOG_ERROR) && Logger::m_bEnableFileLog){Logger::Instance()->Log(VXL_LOG_ERROR, fmt, ##__VA_ARGS__);}
#define LogFatal(fmt, ...) if((Logger::m_logLevel <= VXL_LOG_FATAL) && Logger::m_bEnableFileLog){Logger::Instance()->Log(VXL_LOG_FATAL, fmt, ##__VA_ARGS__);}
#define SetLogFileDirectory Logger::SetFileDirectory
#define SetLogFileName Logger::SetFileName
#define SetLogLevel Logger::SetLevel
#define EnableLogFile Logger::EnableFileLog
#define VXLEnableLog(logDir, logName, logLevel) \
if(NULL!=logDir){SetLogFileDirectory(logDir);} \
SetLogFileName(logName); \
SetLogLevel(logLevel); \
EnableLogFile(true);
#define VXLDisableLog() \
EnableLogFile(false);
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable:4251)
#elif defined __linux__
//
#endif
//your declarations that cause 4251
class INTERFACE_DLL Logger
{
private:
Logger();
public:
virtual ~Logger();
static Logger *Instance();
static void SetFileDirectory(IN const std::string &strFileDir, IN bool bDeleteOldDir = false);
static void SetFileName(const std::string &strFileName);
static void SetLevel(IN VXL_LOG_LEVEL logLevel);
static void EnableFileLog(IN bool bEnableFileLog);
void Log(IN VXL_LOG_LEVEL logLevel, IN const char *const format, ...);
private:
Logger(Logger const &);
Logger &operator=(Logger const &);
static bool Initialise();
static void Dispose();
static bool CreateFileDirectory(const std::string &strFileDir, bool bDeleteOldDir = false);
static void MakeLogFilePath();
static FILE *m_hLogFile;
static bool m_bSetDir;
static bool m_bCreateDir;
static std::string m_strFileDir;
static std::string m_strFileName;
static std::string m_strFilePath;
static int m_logFileCount;
static std::mutex m_mutex;
public:
static bool m_bEnableFileLog;
static VXL_LOG_LEVEL m_logLevel;
};
#ifdef _WIN32
#pragma warning(pop)
#elif defined __linux__
//
#endif
#endif
|
b2026c67c65b1d34abd74cb39306091d9e0a6ee5 | 9de6630020336a8c333a507747b9669532457eef | /src/core/code.re | f9f2c9f1679c1011e003e0ae423ea765af0fb7c8 | [
"MIT"
] | permissive | beni55/reia | 4363d234317434b371a02a9814f6117d7de711e3 | 576cbcbf5808bf26861103831b2c64ece46a44d8 | refs/heads/master | 2017-04-30T13:43:10.001579 | 2015-09-21T11:03:28 | 2015-09-21T11:03:28 | 42,861,008 | 0 | 0 | null | 2015-09-21T11:03:28 | 2015-09-21T11:01:19 | Erlang | UTF-8 | C++ | false | false | 677 | re | code.re | #
# code.re: Interface to the Reia code server
# Copyright (C)2010 Tony Arcieri
#
# Redistribution is permitted under the MIT license. See LICENSE for details.
#
module Code
def paths
[path.to_string() for path in CodeServer.call(:paths)]
end
def unshift_path(path)
res = CodeServer.call(:unshift_path, path.to_s().to_list())
[path.to_string() for path in res]
end
def push_path(path)
res = CodeServer.call(:push_path, path.to_s().to_list())
[path.to_string() for path in res]
end
def set_paths(paths)
res = CodeServer.call(:set_paths, [path.to_s().to_list() for path in paths])
[path.to_string() for path in res]
end
end |
15d63cc1ed390fbc746ed4e305e7f2c631e407bd | 911f133ff3fbfde58ee6b8d57ea8e5393f971234 | /Ch3/Exercise 3.16.cpp | 09e1f63958fb014f99fbaae624e16c8f5bf80831 | [] | no_license | xche03/CPP-Primer-5th | 5e2ba71791a405390505264778784813c2776232 | 887c236c01891bda726ef3a23ec375b53885022d | refs/heads/master | 2021-01-09T21:52:04.924093 | 2016-02-29T15:28:32 | 2016-02-29T15:28:32 | 44,064,362 | 2 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 1,444 | cpp | Exercise 3.16.cpp | /*Exercise 3.16: Write a program to print the size and contents of the
vectors from exercise 3.13. Check whether your answers to that exercise
were correct. If not, restudy ¡ì 3.3.1 (p. 97) until you understand why you
were wrong.*/
/*Exercise 3.13: How many elements are there in each of the following
vectors ? What are the values of the elements ?
(a)vector<int> v1;
(b)vector<int> v2(10);
(c)vector<int> v3(10, 42);
(d)vector<int> v4{ 10 };
(e)vector<int> v5{ 10, 42 };
(f)vector<string> v6{ 10 };
(g)vector<string> v7{ 10, "hi" };*/
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<int> v1;//0 elements
cout << "The size of v1 is " << v1.size() << endl;
vector<int> v2(10);//10 elements whose values are all 0
cout << "The size of v2 is " << v2.size() << endl;
vector<int> v3(10, 42);//10 elements whose values are all 42
cout << "The size of v3 is " << v3.size() << endl;
vector<int> v4{ 10 };//1 element whose value is 10
cout << "The size of v4 is " << v4.size() << endl;
vector<int> v5{ 10, 42 };//2 elements whose values are 10 and 42 respectively
cout << "The size of v5 is " << v5.size() << endl;
vector<string> v6{ 10 };//10 elelemts whose values are empty string.
cout << "The size of v6 is " << v6.size() << endl;
vector<string> v7{ 10, "hi" }; //10 elements whose values are "hi"
cout << "The size of v7 is " << v7.size() << endl;
system("PAUSE");
return 0;
} |
bdca2bc34dce027c5614b23910bc6b01342fbe6b | 153e38d81e9c63c311b0e97961632cbb64ff9807 | /Other/Code/DesignPattern/DesignPattern/Flyweight.h | afbf99b3124947467b3e036678a2fcee31fc4855 | [] | no_license | 0000duck/MyStudy | 0d8b02f2ad8afda6dcfc79928ddb6f6e8b41238d | d01c803177104bc5b0375309b140a3b009b7b0cb | refs/heads/master | 2023-02-25T23:28:53.360198 | 2021-02-05T08:31:31 | 2021-02-05T08:31:31 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,240 | h | Flyweight.h | #ifndef __Flyweight_H__
#define __Flyweight_H__
#include<iostream>
#include <string>
#include <vector>
using namespace std;
class Flyweight
{
public:
virtual void Operation(const string& extrinsicState){}
string GetIntrinsicState()
{
return this->_intrinsicState;
}
protected:
Flyweight(string intrinsicState)
{
this->_intrinsicState = intrinsicState;
}
private:
string _intrinsicState;
};
class ConcreteFlyweight :public Flyweight
{
public:
ConcreteFlyweight(string intrinsicState) :Flyweight(intrinsicState)
{
cout << "ConcreteFlyweight Build....."<<intrinsicState<<endl;
}
void Operation(const string& extrinsicState)
{
cout << "ConcreteFlyweight: 内 蕴["<<this->GetIntrinsicState()<<"] 外 蕴["<<extrinsicState<<"]"<<endl;
}
};
class FlyweightFactory
{
public:
Flyweight* GetFlyweight(const string& key)
{
vector<Flyweight*>::iterator it = _fly.begin();
for (; it != _fly.end(); it++)
{
//找到了,就一起用, ^_^
if ((*it)->GetIntrinsicState() == key)
{
cout << "already created by users...."<<endl;
return *it;
}
}
Flyweight* fn = new ConcreteFlyweight(key);
_fly.push_back(fn);
return fn;
}
private:
vector<Flyweight*> _fly;
};
#endif // __Flyweight_H__
|
217db1c1ce3247f37fcfac178c52b26b17c40909 | e6cd51943f682a006da8b1245e6585e453334687 | /Classes/Native/AssemblyU2DCSharp_ShowSelected503920856.h | fb64e7839b6dbf2e016f2284a523b1bf59058315 | [] | no_license | JasonRy/Seer_0.9.1 | a7495d385a6c5bcec6040ce061410d9eea4d09eb | f727a9442015b2dc03fc19d2fa68dc88ca8bfac0 | refs/heads/master | 2021-07-23T06:23:40.432032 | 2017-11-03T07:57:23 | 2017-11-03T08:53:35 | 109,366,091 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,062 | h | AssemblyU2DCSharp_ShowSelected503920856.h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
// UnityEngine.Shader
struct Shader_t3191267369;
#include "UnityEngine_UnityEngine_MonoBehaviour667441552.h"
#include "UnityEngine_UnityEngine_Color4194546905.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// ShowSelected
struct ShowSelected_t503920856 : public MonoBehaviour_t667441552
{
public:
// UnityEngine.Shader ShowSelected::selectedShader
Shader_t3191267369 * ___selectedShader_2;
// UnityEngine.Color ShowSelected::outterColor
Color_t4194546905 ___outterColor_3;
// UnityEngine.Color ShowSelected::myColor
Color_t4194546905 ___myColor_4;
// UnityEngine.Shader ShowSelected::myShader
Shader_t3191267369 * ___myShader_5;
// System.Boolean ShowSelected::Selected
bool ___Selected_6;
public:
inline static int32_t get_offset_of_selectedShader_2() { return static_cast<int32_t>(offsetof(ShowSelected_t503920856, ___selectedShader_2)); }
inline Shader_t3191267369 * get_selectedShader_2() const { return ___selectedShader_2; }
inline Shader_t3191267369 ** get_address_of_selectedShader_2() { return &___selectedShader_2; }
inline void set_selectedShader_2(Shader_t3191267369 * value)
{
___selectedShader_2 = value;
Il2CppCodeGenWriteBarrier(&___selectedShader_2, value);
}
inline static int32_t get_offset_of_outterColor_3() { return static_cast<int32_t>(offsetof(ShowSelected_t503920856, ___outterColor_3)); }
inline Color_t4194546905 get_outterColor_3() const { return ___outterColor_3; }
inline Color_t4194546905 * get_address_of_outterColor_3() { return &___outterColor_3; }
inline void set_outterColor_3(Color_t4194546905 value)
{
___outterColor_3 = value;
}
inline static int32_t get_offset_of_myColor_4() { return static_cast<int32_t>(offsetof(ShowSelected_t503920856, ___myColor_4)); }
inline Color_t4194546905 get_myColor_4() const { return ___myColor_4; }
inline Color_t4194546905 * get_address_of_myColor_4() { return &___myColor_4; }
inline void set_myColor_4(Color_t4194546905 value)
{
___myColor_4 = value;
}
inline static int32_t get_offset_of_myShader_5() { return static_cast<int32_t>(offsetof(ShowSelected_t503920856, ___myShader_5)); }
inline Shader_t3191267369 * get_myShader_5() const { return ___myShader_5; }
inline Shader_t3191267369 ** get_address_of_myShader_5() { return &___myShader_5; }
inline void set_myShader_5(Shader_t3191267369 * value)
{
___myShader_5 = value;
Il2CppCodeGenWriteBarrier(&___myShader_5, value);
}
inline static int32_t get_offset_of_Selected_6() { return static_cast<int32_t>(offsetof(ShowSelected_t503920856, ___Selected_6)); }
inline bool get_Selected_6() const { return ___Selected_6; }
inline bool* get_address_of_Selected_6() { return &___Selected_6; }
inline void set_Selected_6(bool value)
{
___Selected_6 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
|
6da582f388b50ac9db721abbbe86b9968cb08c65 | 0d4e28f7e9d961e45d32a4735ad7c1f76bbda34a | /ocs2_mpc/src/MPC_MRT_Interface.cpp | 0ef6d7fced6ed0017fa64328a66b5f5cede78528 | [
"BSD-3-Clause"
] | permissive | RoboMark9/ocs2 | a4fc0c215ccb3a86afeffe93b6a67fb0d9dd9450 | b037d819c9a02a674de9badb628b32646ce11d6a | refs/heads/main | 2023-08-29T15:20:07.117885 | 2021-10-20T13:09:37 | 2021-10-20T13:09:37 | 453,286,119 | 1 | 0 | BSD-3-Clause | 2022-01-29T03:30:28 | 2022-01-29T03:30:27 | null | UTF-8 | C++ | false | false | 8,880 | cpp | MPC_MRT_Interface.cpp | /******************************************************************************
Copyright (c) 2020, Farbod Farshidian. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************/
#include "ocs2_mpc/MPC_MRT_Interface.h"
#include <ocs2_core/control/FeedforwardController.h>
#include <ocs2_core/control/LinearController.h>
namespace ocs2 {
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
MPC_MRT_Interface::MPC_MRT_Interface(MPC_BASE& mpc) : mpc_(mpc) {
mpcTimer_.reset();
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void MPC_MRT_Interface::resetMpcNode(const TargetTrajectories& initTargetTrajectories) {
mpc_.reset();
mpc_.getSolverPtr()->getReferenceManager().setTargetTrajectories(initTargetTrajectories);
mpcTimer_.reset();
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void MPC_MRT_Interface::setCurrentObservation(const SystemObservation& currentObservation) {
std::lock_guard<std::mutex> lock(observationMutex_);
currentObservation_ = currentObservation;
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
ReferenceManagerInterface& MPC_MRT_Interface::getReferenceManager() {
return mpc_.getSolverPtr()->getReferenceManager();
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
const ReferenceManagerInterface& MPC_MRT_Interface::getReferenceManager() const {
return mpc_.getSolverPtr()->getReferenceManager();
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void MPC_MRT_Interface::advanceMpc() {
// measure the delay in running MPC
mpcTimer_.startTimer();
SystemObservation currentObservation;
{
std::lock_guard<std::mutex> lock(observationMutex_);
currentObservation = currentObservation_;
}
bool controllerIsUpdated = mpc_.run(currentObservation.time, currentObservation.state);
if (!controllerIsUpdated) {
return;
}
copyToBuffer(currentObservation);
// measure the delay for sending ROS messages
mpcTimer_.endTimer();
// check MPC delay and solution window compatibility
scalar_t timeWindow = mpc_.settings().solutionTimeWindow_;
if (mpc_.settings().solutionTimeWindow_ < 0) {
timeWindow = mpc_.getSolverPtr()->getFinalTime() - currentObservation.time;
}
if (timeWindow < 2.0 * mpcTimer_.getAverageInMilliseconds() * 1e-3) {
std::cerr << "[MPC_MRT_Interface::advanceMpc] WARNING: The solution time window might be shorter than the MPC delay!\n";
}
// measure the delay
if (mpc_.settings().debugPrint_) {
std::cerr << "\n### MPC_MRT Benchmarking";
std::cerr << "\n### Maximum : " << mpcTimer_.getMaxIntervalInMilliseconds() << "[ms].";
std::cerr << "\n### Average : " << mpcTimer_.getAverageInMilliseconds() << "[ms].";
std::cerr << "\n### Latest : " << mpcTimer_.getLastIntervalInMilliseconds() << "[ms]." << std::endl;
}
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void MPC_MRT_Interface::copyToBuffer(const SystemObservation& mpcInitObservation) {
// policy
std::unique_ptr<PrimalSolution> primalSolutionPtr(new PrimalSolution);
const scalar_t startTime = mpcInitObservation.time;
const scalar_t finalTime =
(mpc_.settings().solutionTimeWindow_ < 0) ? mpc_.getSolverPtr()->getFinalTime() : startTime + mpc_.settings().solutionTimeWindow_;
mpc_.getSolverPtr()->getPrimalSolution(finalTime, primalSolutionPtr.get());
// command
std::unique_ptr<CommandData> commandPtr(new CommandData);
commandPtr->mpcInitObservation_ = mpcInitObservation;
commandPtr->mpcTargetTrajectories_ = mpc_.getSolverPtr()->getReferenceManager().getTargetTrajectories();
// performance indices
std::unique_ptr<PerformanceIndex> performanceIndicesPtr(new PerformanceIndex);
*performanceIndicesPtr = mpc_.getSolverPtr()->getPerformanceIndeces();
this->moveToBuffer(std::move(commandPtr), std::move(primalSolutionPtr), std::move(performanceIndicesPtr));
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
void MPC_MRT_Interface::getLinearFeedbackGain(scalar_t time, matrix_t& K) {
auto controller = dynamic_cast<LinearController*>(this->getPolicy().controllerPtr_.get());
if (controller == nullptr) {
throw std::runtime_error("[MPC_MRT_Interface::getLinearFeedbackGain] Feedback gains only available with linear controller!");
}
controller->getFeedbackGain(time, K);
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
ScalarFunctionQuadraticApproximation MPC_MRT_Interface::getValueFunction(scalar_t time, const vector_t& state) const {
return mpc_.getSolverPtr()->getValueFunction(time, state);
}
/******************************************************************************************************/
/******************************************************************************************************/
/******************************************************************************************************/
vector_t MPC_MRT_Interface::getStateInputEqualityConstraintLagrangian(scalar_t time, const vector_t& state) const {
return mpc_.getSolverPtr()->getStateInputEqualityConstraintLagrangian(time, state);
}
} // namespace ocs2
|
270fb6e55f8fb4d6b76eeea84f1c83e80cb6dea2 | 535749b1e06a99b634aa16b523379b38120b9af3 | /Control/Control_2.cpp | 4a458254d7c0e72f8e4daced0c119a40120c02b4 | [] | no_license | Carapulcra/CARLOS_CASTRO | 126d299f741b584f9c4a808a4e5a0e479e3af75b | a63283bf1babf6343308a4928eb769b07e7eb601 | refs/heads/main | 2023-04-15T00:42:20.343942 | 2021-04-30T08:39:36 | 2021-04-30T08:39:36 | 352,256,659 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 233 | cpp | Control_2.cpp | #include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main() {
//Convierte de string a int
string cadena;
getline(cin, cadena);
istringstream salida(cadena);
int num;
salida >> num;
cout << num;
} |
b59007fe281b8e884551b3abded171fe779b28bc | 86e3af0b793570ed9ed85ca336e0f817975d731e | /KEMField/Source/BoundaryIntegrals/Electrostatic/Reference/src/KElectrostaticBiQuadratureRectangleIntegrator.cc | c587b36efafd85a74d02b47303dedae6a215280e | [] | no_license | accb529/Kassiopeia | 6103f211ddd246eec22496ce4afd3638f28efd9d | 4065e02e04f627c37ae306e77268edf275c4d7c8 | refs/heads/master | 2022-04-18T01:17:54.334279 | 2020-03-12T14:26:10 | 2020-03-12T14:26:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,064 | cc | KElectrostaticBiQuadratureRectangleIntegrator.cc | #include "KElectrostaticBiQuadratureRectangleIntegrator.hh"
namespace KEMField
{
// global variables
unsigned short gReField;
unsigned int gReIntNodes = 32;
double reAcommon, reBcommon;
KThreeVector reP, reP0, gReN1, gReN2;
double gReX;
double KElectrostaticBiQuadratureRectangleIntegrator::rectF1( double x )
{
gReX = x;
double ret = rectQuadGaussLegendreVarN(&KElectrostaticBiQuadratureRectangleIntegrator::rectF2,0.,reBcommon, gReIntNodes);
return ret;
}
double KElectrostaticBiQuadratureRectangleIntegrator::rectF2( double y )
{
double x = gReX;
return KElectrostaticBiQuadratureRectangleIntegrator::rectF( x, y );
}
double KElectrostaticBiQuadratureRectangleIntegrator::rectF( double x, double y )
{
double R,R3;
KThreeVector Q,QP;
Q = reP0 + x*gReN1 + y*gReN2;
QP=reP-Q;
R=QP.Magnitude();
R3=R*R*R;
// return electric potential
if( gReField==3 )
return KEMConstants::OneOverFourPiEps0/R;
// return electric field
for( unsigned short j=0;j<3;j++ ) {
if( gReField==j )
return KEMConstants::OneOverFourPiEps0/R3*QP[j];
}
return 0.;
}
double KElectrostaticBiQuadratureRectangleIntegrator::rectQuadGaussLegendreVarN( double (*f)(double), double a, double b, unsigned int n )
{
KGaussLegendreQuadrature fIntegrator;
double Integral,xmin,xmax,del, ret;
if( n<=32 )
fIntegrator(f,a,b,n,&Integral);
else
{
unsigned int imax=n/32+1;
Integral=0.;
del=(b-a)/imax;
for( unsigned int i=1; i<=imax; i++ )
{
xmin=a+del*(i-1);
xmax=xmin+del;
fIntegrator(f,xmin,xmax,32, &ret);
Integral+=ret;
}
}
return Integral;
}
double KElectrostaticBiQuadratureRectangleIntegrator::Potential(const KRectangle* source, const KPosition& P) const
{
gReField = 3;
reP = P;
reP0 = source->GetP0();
gReN1 = source->GetN1();
gReN2 = source->GetN2();
reAcommon=source->GetA();
reBcommon=source->GetB();
return rectQuadGaussLegendreVarN( &KElectrostaticBiQuadratureRectangleIntegrator::rectF1, 0., source->GetA(), gReIntNodes );
}
KThreeVector KElectrostaticBiQuadratureRectangleIntegrator::ElectricField(const KRectangle* source, const KPosition& P) const
{
double EField[3];
reP=P;
reP0=source->GetP0();
gReN1=source->GetN1();
gReN2=source->GetN2();
reAcommon=source->GetA();
reBcommon=source->GetB();
for( unsigned short j=0; j<3; j++ ) {
gReField = j;
EField[j] = rectQuadGaussLegendreVarN( &KElectrostaticBiQuadratureRectangleIntegrator::rectF1, 0., source->GetA(), gReIntNodes );
}
return KThreeVector( EField[0], EField[1], EField[2] );
}
std::pair<KThreeVector, double> KElectrostaticBiQuadratureRectangleIntegrator::ElectricFieldAndPotential(const KRectangle* source, const KPosition& P) const
{
return std::make_pair( ElectricField(source, P), Potential(source, P) );
}
double KElectrostaticBiQuadratureRectangleIntegrator::Potential(const KSymmetryGroup<KRectangle>* source, const KPosition& P) const
{
double potential = 0.;
for (KSymmetryGroup<KRectangle>::ShapeCIt it=source->begin();it!=source->end();++it)
potential += Potential(*it,P);
return potential;
}
KThreeVector KElectrostaticBiQuadratureRectangleIntegrator::ElectricField(const KSymmetryGroup<KRectangle>* source, const KPosition& P) const
{
KThreeVector electricField(0.,0.,0.);
for (KSymmetryGroup<KRectangle>::ShapeCIt it=source->begin();it!=source->end();++it)
electricField += ElectricField(*it,P);
return electricField;
}
std::pair<KThreeVector, double> KElectrostaticBiQuadratureRectangleIntegrator::ElectricFieldAndPotential(const KSymmetryGroup<KRectangle>* source, const KPosition& P) const
{
std::pair<KThreeVector, double> fieldAndPotential;
double potential( 0. );
KThreeVector electricField( 0., 0., 0. );
for( KSymmetryGroup<KRectangle>::ShapeCIt it=source->begin(); it!=source->end(); ++it ) {
fieldAndPotential = ElectricFieldAndPotential( *it, P );
electricField += fieldAndPotential.first;
potential += fieldAndPotential.second;
}
return std::make_pair( electricField, potential );
}
}
|
19c8374fb115e4a84ec248bcd977cd312ae5a202 | 8af26702121275433a72a5d02f1c67ffdcd8901a | /structs.cpp | b69dee1981cf47f5d0892d4c18c2f91cec661197 | [] | no_license | ali-musa/rpc | 1da4a4bf7b54a3e7c37af9abe927e76f74e6acc4 | 35f2103bf0a051827f83a14c1d2df33ac3e96e88 | refs/heads/master | 2021-05-06T06:48:23.298168 | 2017-12-11T18:37:10 | 2017-12-11T18:37:10 | 113,894,191 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 161 | cpp | structs.cpp | #include <string>
using namespace std;
#include "structs.idl"
int area(rectangle r) {
return r.x*r.y;
}
Person findPerson(ThreePeople tp)
{
return tp.p2;
} |
da423f18272991abd8d229f6d47f7d0e886d81c2 | 6b4e2a7f51647524db22208eb98e925d1537fb6b | /String/1278. Palindrome Partitioning III.cpp | 4eed75e6b2edf4ae3625d1f182ef583ba57d0fe5 | [] | no_license | denis-gubar/Leetcode | a099e0fd07600ae63456059753332f90ddd96542 | ad54bee10fdf59644cc762218277a2f9de9b3509 | refs/heads/master | 2023-07-21T04:25:57.949932 | 2023-07-09T12:46:24 | 2023-07-09T12:46:24 | 218,048,440 | 5 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 999 | cpp | 1278. Palindrome Partitioning III.cpp | class Solution {
public:
int calc(string const& s, int start, int end)
{
if (start >= end) return F[start][end] = 0;
int result = F[start][end];
if (result < 0)
{
if (s[start] == s[end])
result = calc(s, start + 1, end - 1);
else
result = 1 + calc(s, start + 1, end - 1);
}
return F[start][end] = result;
}
int palindromePartition(string s, int k) {
int N = s.size();
F = vector<vector<int>>(N, vector<int>(N, -1));
for(int start = 0; start <= N - 1; ++start)
for(int end = start; end < N; ++end)
calc(s, start, end);
vector<vector<int>> M(N + 1, vector<int>(k + 1, N));
M[0][1] = 0;
for (int i = 0; i < N; ++i)
for (int j = 1; j <= k; ++j)
for (int start = 0; start <= i; ++start)
if (start == i && j == 1)
M[i + 1][j] = min(M[i + 1][j], F[0][i]);
else if (start < i && j > 1)
M[i + 1][j] = min(M[i + 1][j], M[start + 1][j - 1] + F[start + 1][i]);
return M[N][k];
}
vector<vector<int>> F;
}; |
4ec315e188e28d6252acb718b71c8d09f4e270b9 | 27404e193f4fff8a538819611ab00402387fca74 | /chapter10/bankaccount.cpp | 7675ec54105aebcd0e20701d0b64bb400393543f | [] | no_license | shiyanlou/CPP-PrimerPlus | 4bde40abb4025aa59a2dee50aff3296d6651da9b | bf4de816e612fcfa6942f47460498f0c78a5eceb | refs/heads/master | 2020-08-30T18:22:06.743868 | 2019-12-30T05:57:23 | 2019-12-30T05:57:23 | 218,456,223 | 12 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 747 | cpp | bankaccount.cpp | // filename bankaccount.cpp
#include<iostream>
#include"bankaccount.h"
BankAccount::BankAccount(const std::string&client,
const std::string&num,double bal)
{
name=client;
acctnum=num;
balance=bal;
}
void BankAccount::show()const
{
using std::cout;
using std::endl;
cout<<"Client: "<<name<<endl;
cout<<"Account Number: "<<acctnum<<endl;
cout<<"Balance: "<<balance<<endl;
}
void BankAccount::deposit(double cash)
{
if(cash>=0)
balance+=cash;
else
std::cout<<"Illegal transaction attempted";
}
void BankAccount::withdraw(double cash)
{
if(cash<0)
std::cout<<"Illegal transaction attempted";
else if (cash<=balance)
balance-=cash;
else
std::cout<<"Request denied due to insufficient funds.\n";
} |
6f4a02c3ac377b44b19c888d2cf9dbc6f9f25691 | 09ecec5da451481281cd79f781656bb0dc624190 | /06 – Casts/00 – Scalar conversion/Scalar.cpp | 4fb5dab3bf5ed92e41b47e3c158e31073d9fd65d | [] | no_license | levensta/CPP-study | c5a441c14f53f5d6ee9a7083248826a6b5d26593 | a0bf2a6abc1626f9d4b77eff7bcc04bbedfa1498 | refs/heads/master | 2023-07-25T07:49:01.317675 | 2021-09-08T17:49:15 | 2021-09-08T17:49:15 | 392,414,875 | 0 | 1 | null | 2021-08-19T16:33:36 | 2021-08-03T18:22:24 | C++ | UTF-8 | C++ | false | false | 3,524 | cpp | Scalar.cpp | //
// Created by Lorent Evenstar on 8/27/21.
//
#include "Scalar.hpp"
Scalar::Scalar(std::string str) : _str(str), _sign(1), _isPoint(false) {}
Scalar::~Scalar() {}
Scalar::Scalar(const Scalar ©) {
*this = copy;
}
Scalar &Scalar::operator=(const Scalar ©) {
if (this != ©) {
this->_str = copy._str;
this->_longNum = copy._longNum;
this->_isPoint = copy._isPoint;
}
return *this;
}
void Scalar::parse() {
if (_str.empty()) {
throw std::string("EMPTY ARGUMENT");
}
if (_str.length() > 1) {
int i;
for (i = 0; std::string("\t\v\f\r\n ").find(_str[i], 0) != std::string::npos; ++i) {}
if (i == _str.length())
throw std::string("EMPTY ARGUMENT");
_str = _str.substr(i);
if (_str == "nan" || _str == "nanf") {
_longNum = NAN;
return ;
}
if (_str[i] == '-' || _str[i] == '+') {
if (!(std::isdigit(static_cast<unsigned char>(_str[i + 1]))))
throw std::string("IS NOT DIGIT");
if (_str[i] == '-')
_sign = -1;
++i;
}
_str = _str.substr(i); // вырезаем, начиная с символа ПОСЛЕ пробела и до конца строки
if (_str == "inf" || _str == "inff") {
_longNum = INFINITY * _sign;
return ;
}
if (_str.length() > 1) {
for (i = 0; i < _str.length(); ++i) {
if (_str[i] == '.') {
if (_isPoint == true || i == _str.length() - 1)
throw std::string("IS NOT DIGIT");
_isPoint = true;
}
else if (!(std::isdigit(static_cast<unsigned char>(_str[i]))))
break;
}
if (i != _str.length()) {
if (!(i + 1 == _str.length() && _str[i] == 'f' && _isPoint == true))
throw std::string("IS NOT DIGIT");
}
_longNum = atof(_str.c_str()) * _sign;
}
}
if (_str.length() == 1) {
if (_str[0] >= '0' && _str[0] <= '9')
_str[0] -= '0';
_longNum = static_cast<double>(_str[0]) * _sign;
}
// std::cout << _str << std::endl;
// std::cout << _longNum << std::endl;
}
void Scalar::toChar() {
char c;
if (std::isnan(_longNum)) {
std::cout << "char: impossible" << std::endl;
return ;
}
if (_longNum == INFINITY || _longNum == -INFINITY) {
std::cout << "char: " << _longNum << std::endl;
return ;
}
if (_longNum < CHAR_MAX && _longNum > CHAR_MIN) {
c = static_cast<char>(_longNum);
if (std::isgraph(static_cast<unsigned char>(c))) {
std::cout << "char: " << c << std::endl;
}
else {
std::cout << "char: Non displayable" << std::endl;
}
}
else {
std::cout << "char: Non displayable" << std::endl;
}
}
void Scalar::toFloat() {
float f;
f = static_cast<float>(_longNum);
int precition = 1;
if (_str.find(".") != std::string::npos && _str.length() - _str.find(".") - 1 > 0)
precition = _str.length() - _str.find(".") - 1;
if (_str[_str.length() - 1] == 'f')
precition--;
std::cout << std::fixed << std::setprecision(precition) << "float: " << f << "f" << std::endl;
}
void Scalar::toDouble() {
int precition = 1;
if (_str.find(".") != std::string::npos && _str.length() - _str.find(".") - 1 > 0)
precition = _str.length() - _str.find(".") - 1;
if (_str[_str.length() - 1] == 'f')
precition--;
std::cout << std::fixed << std::setprecision(precition) << "double: " << _longNum << std::endl;
}
void Scalar::toInt() {
if (_longNum == INFINITY || _longNum == -INFINITY) {
std::cout << "int: " << _longNum << std::endl;
return ;
}
if (_longNum < INT_FAST32_MAX && _longNum > INT32_MIN) {
std::cout << "int: " << static_cast<int>(_longNum) << std::endl;
}
else {
std::cout << "int: impossible" << std::endl;
}
} |
d61aa20bbd950fadae1e239a3d7a91d9a53aae74 | 5d497cfdf324af46c6450de4b80ddf696200dc9f | /src/main.cpp | f4599f0b3c9aff44a5f1f1a4c1bc16ec1c65fa9b | [] | no_license | Fakor/competing_salesmen | 0c372a8e3216a9c5a058805bc38692c25a551365 | e15d4cb4572799647d2d751f0ffc6606e229638d | refs/heads/master | 2020-03-22T10:14:02.640974 | 2018-07-14T20:37:56 | 2018-07-14T20:37:56 | 139,889,845 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 737 | cpp | main.cpp | #include <iostream>
#include <cstdlib>
#include <random>
#include "map.h"
#include "random_generator.h"
#include "log_tools.h"
#include "engine.h"
#include "basic_selectors.h"
int main(int argc, char **argv){
int seed;
if(argc==2){
seed=atoi(argv[1]);
}
else{
std::random_device rd;
seed=rd();
}
printf("SEED: %d\n", seed);
std::unique_ptr<RandomGenerator> generator(new RandomGenerator(20,3,2,seed));
Engine engine(std::move(generator));
engine.AddSelector(std::unique_ptr<Selector>(new RandomSelector(seed)), 0);
engine.AddSelector(std::unique_ptr<Selector>(new Closest()), 1);
engine.PerformRound();
print_cities(engine.GetCities());
print_scoreboard(engine.GetScoreboard());
return 0;
}
|
596c5b0fb9bccabd90a736395a6fa4d36ac4bcc5 | caf47e5b0907cf7e43a7b71354f834caafd86ba7 | /Competitive-Programming/Codechef/LTIME36/ASTRING.cpp | 428b39d2222e972d0b05824adc597460b9e02491 | [] | no_license | RudraNilBasu/C-CPP-Codes | f16b2ac72a0605eac6ffb65c20180baa7193b45f | 9412123da4ded00fac9b5c7ab14eae3f9727dace | refs/heads/master | 2021-03-13T01:53:05.550539 | 2018-03-31T17:54:38 | 2018-03-31T17:54:38 | 37,644,826 | 1 | 2 | null | 2019-08-26T21:00:29 | 2015-06-18T07:34:54 | C++ | UTF-8 | C++ | false | false | 707 | cpp | ASTRING.cpp | #include<stdio.h>
#include<string.h>
using namespace std;
int pos;
int n; // length of string
char search(char s[], int start,int end)
{
// returns the smallest string startng from
// index 'start' upto index 'length-end'
// store the pos of the smallest element in pos
int i;
char least='z'+1;
for(i=start;i<=(end);i++)
{
if(least>s[i])
{
least=s[i];
pos=i;
}
}
//printf("it is %c\n");
return least;
}
int main()
{
int t,i,k,m;
char s[100002];
scanf("%d",&t);
while(t--)
{
scanf("%s",s);
scanf("%d",&k);
//m=k;
n=strlen(s);
int start=0,end=k;
for(i=1;i<=k;i++)
{
printf("%c",search(s,start,n-end));
start=pos+1;
end--;
}
printf("\n");
}
return 0;
}
|
334f3db4754f9b43c5622f3cba40ee293155d6db | eb11c12d2f8ebe45b9af2b0fb5793c2c3d0b29db | /EventDispatcher.cpp | a83c6e6e00cea385c7b55d43fd822a8caa8ffca9 | [] | no_license | reduguardianu/Badass-Heroes | fda9e6fd78f1d362567e6879345c8fdfe3bd55cc | fe0a1db8f16091d7966199fa6c04e2b6cbb71903 | refs/heads/master | 2021-01-10T19:14:23.563319 | 2012-05-30T23:00:41 | 2012-05-30T23:00:41 | 3,673,588 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,126 | cpp | EventDispatcher.cpp | #include "EventDispatcher.h"
#include <iostream>
#define CALL_MEMBER_FN(object, ptrToMember) ((object)->*(ptrToMember))
void EventDispatcher::dispatchEvent(GameEventPointer event, EventDispatcher* dispatcher) {
ObserversMap::iterator it = m_observers.find(event->name());
if (it != m_observers.end()) {
Observers observers = it->second;
Observers::iterator it2 = observers.begin();
for (; it2 != observers.end(); ++it2) {
CALL_MEMBER_FN(it2->first, it2->second)(event, dispatcher);
}
}
}
void EventDispatcher::addEventListener(const std::string& event, EventDispatcher* observer, Listener listener) {
ObserversMap::iterator it = m_observers.find(event);
if (it == m_observers.end()) {
it = m_observers.insert(std::make_pair(event, Observers() )).first;
}
it->second.insert(std::make_pair(observer, listener));
}
void EventDispatcher::removeEventListener(const std::string& event, EventDispatcher* observer, Listener listener) {
ObserversMap::iterator it = m_observers.find(event);
if (it != m_observers.end()) {
it->second.erase(std::make_pair(observer, listener));
}
}
|
1e6a3b18f55fe57b91d4cc5df8c32099ab6c5ef5 | 0435915721a0b68591a5ddac4b409d78ba190977 | /SmartPointer/include/StrBlob.h | d2041c0782ee21831a7599f494b3409dd35e5215 | [] | no_license | PugnaHAN/C-Primer | 7e381b36c046fc1d178d28633b1cc19df68c06d8 | 39058fa5b01b6808e60c2a648ed7ff00b2f3a94f | refs/heads/master | 2021-06-11T00:58:41.233001 | 2016-12-14T01:56:31 | 2016-12-14T01:56:31 | 72,555,451 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,102 | h | StrBlob.h | #ifndef __STRBLOB_H__
#define __STRBLOB_H__
#include "common.h"
class StrBlobPtr;
class StrBlob
{
public:
friend class StrBlobPtr;
typedef std::vector<std::string>::size_type size_type;
StrBlob();
StrBlob(std::initializer_list<std::string> il);
size_type size() const {return data->size();}
bool empty() const {return data->empty();}
void push_back(const std::string &t);
void pop_back();
std::string& front();
std::string& back();
const std::string& front() const;
const std::string& back() const;
StrBlobPtr begin();
StrBlobPtr end();
private:
std::shared_ptr<std::vector<std::string>> data;
void check(size_type i, const std::string &msg) const;
};
class StrBlobPtr
{
public:
StrBlobPtr():curr(0) {};
StrBlobPtr(StrBlob& a, std::size_t sz = 0) : wptr(a.data), curr(sz) {};
std::string& deref() const;
StrBlobPtr& incr();
std::size_t current() const {return curr;}
private:
std::shared_ptr<std::vector<std::string>>
check(std::size_t, const std::string&) const;
std::weak_ptr<std::vector<std::string>> wptr;
std::size_t curr;
};
#endif /* __STRBLOB_H__ */
|
697158796b9c8b5e8ddd15cb05e9e73853c402db | 5cd30c7bc36af0d37e4c4c0ecd6bf3d84d1e710a | /src/PhysicsPlaneComponent.cpp | e02955c6ae3115adbb02c90e9dc1cdd36ee53c87 | [] | no_license | Dwergi/prototype-engine | 89cb8a4c90344ab046d176beff7b19468abd6d4e | 0d792ded0141b2a913200f6f1c27084d65f42627 | refs/heads/master | 2023-04-27T21:08:31.482645 | 2023-04-21T09:17:36 | 2023-04-21T09:17:36 | 31,064,734 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 195 | cpp | PhysicsPlaneComponent.cpp | //
// PhysicsPlaneComponent.cpp
// Copyright (C) Sebastian Nordgren
// September 19th 2018
//
#include "PCH.h"
#include "PhysicsPlaneComponent.h"
DD_COMPONENT_CPP( dd::PhysicsPlaneComponent ); |
95cd6db8e87e13188800d390268eefadb6e9b484 | 5521fd35f0d58715db9046ca74a3e27ceb540755 | /ad_system/serverWork.hpp | 999a2294383f55f490c832816e5684119fd215d6 | [] | no_license | qiuye2015/learning_cpp | 947b0128b5347ecf0f568f2a13085da44fcddb8e | c592684707f9e12d7a62221378e46d87d61ecfb6 | refs/heads/master | 2021-09-27T19:38:57.345313 | 2021-09-14T03:38:18 | 2021-09-14T03:38:18 | 184,173,149 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 416 | hpp | serverWork.hpp | #pragma once
#include "common/globalHelper.hpp"
#include "globalConfig.hpp"
using std::string;
namespace server {
class CServerWork: public http::CoreWorkInterface
{
public:
CServerWork(globalConfig &config);
~CServerWork();
/* http_server的回调函数 */
virtual bool Work(const string& in, string& out) override;
private:
void Init();
globalConfig &m_config;
};
}//namespace server
|
e6b8b37c1fd787f8b97534c3a11da07c1b067f56 | ae97bf946b1e5dd05be721a810fff7a8906c2742 | /test/string_view_stream_test.cpp | 23953f568c73d10a759f1d4a113e80e19f453a64 | [
"BSL-1.0"
] | permissive | tcbrindle/modern-io | 45963d801f668c1306ee6727e9772c8f1149bfc2 | 425037a0211460a5888c22125e5f839f240f3ba4 | refs/heads/master | 2020-05-22T06:52:11.527247 | 2017-06-12T23:03:34 | 2017-06-12T23:03:34 | 60,670,838 | 5 | 0 | null | 2016-07-05T13:24:22 | 2016-06-08T05:27:39 | C++ | UTF-8 | C++ | false | false | 6,282 | cpp | string_view_stream_test.cpp |
// Copyright (c) 2016 Tristan Brindle (tcbrindle at gmail dot com)
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include "catch.hpp"
#include <io/string_view_stream.hpp>
#include <io/byte_reader.hpp>
#include <array>
#include <io/io_std/string_view.hpp>
#include <vector>
const io_std::string_view test_string_view = "The quick brown fox jumped over the lazy dog";
static_assert(io::is_sync_read_stream_v<io::string_view_stream>,
"string_view_stream does not meet the SyncReadStream requirements");
static_assert(io::is_seekable_stream_v<io::string_view_stream>,
"string_view_stream does not meet the SeekableStream requirements");
TEST_CASE("string_view streams can be default constructed", "[string_view_stream]")
{
const io::string_view_stream d{};
REQUIRE(d.str() == "");
REQUIRE(d.get_position().offset_from_start() == 0);
}
TEST_CASE("string_view streams can be value constructed", "[string_view_stream]")
{
const io::string_view_stream d{test_string_view};
REQUIRE(d.str() == test_string_view);
REQUIRE(d.get_position().offset_from_start() == 0);
}
TEST_CASE("string_view streams support seeking", "[string_view_stream]")
{
io::string_view_stream d{test_string_view};
SECTION("...from start") {
REQUIRE_NOTHROW(d.seek(10, io::seek_mode::start));
REQUIRE(d.get_position().offset_from_start() == 10);
}
SECTION("...from end") {
REQUIRE_NOTHROW(d.seek(-10, io::seek_mode::end));
REQUIRE(d.get_position().offset_from_start() == test_string_view.size() - 10);
}
SECTION("...from current") {
REQUIRE_NOTHROW(d.seek(10, io::seek_mode::start));
REQUIRE_NOTHROW(d.seek(10, io::seek_mode::current));
REQUIRE(d.get_position().offset_from_start() == 20);
}
SECTION("...and throw for negative seeks") {
REQUIRE_THROWS_AS(d.seek(-10, io::seek_mode::start), std::system_error);
}
}
TEST_CASE("string_view streams can be read from", "[string_view_stream]")
{
io::string_view_stream d{test_string_view};
SECTION("...using a short static buffer") {
constexpr int buf_size = 10;
std::array<char, buf_size> buf;
std::error_code ec{};
std::size_t bytes_read = 0;
REQUIRE_NOTHROW(bytes_read = d.read_some(io::buffer(buf), ec));
REQUIRE_FALSE(ec);
REQUIRE(bytes_read == buf_size);
REQUIRE(std::equal(std::cbegin(buf),
std::cend(buf),
std::cbegin(test_string_view),
std::cbegin(test_string_view) + buf_size));
}
SECTION("...using a short static buffer (throwing)") {
constexpr int buf_size = 10;
std::array<char, buf_size> buf;
std::size_t bytes_read = 0;
REQUIRE_NOTHROW(bytes_read = d.read_some(io::buffer(buf)));
REQUIRE(bytes_read == buf_size);
REQUIRE(std::equal(std::cbegin(buf),
std::cend(buf),
std::cbegin(test_string_view),
std::cbegin(test_string_view) + buf_size));
}
SECTION("...using a long static buffer") {
std::array<char, 100> buf;
std::error_code ec{};
std::size_t bytes_read = 0;
REQUIRE_NOTHROW(bytes_read = d.read_some(io::buffer(buf), ec));
REQUIRE_FALSE(ec);
REQUIRE(bytes_read == test_string_view.size());
REQUIRE(std::equal(std::begin(buf),
std::begin(buf) + test_string_view.size(),
std::cbegin(test_string_view),
std::cend(test_string_view)));
SECTION("...and further reads result in an error") {
REQUIRE_NOTHROW(bytes_read = d.read_some(io::buffer(buf), ec));
REQUIRE(ec == io::stream_errc::eof);
REQUIRE(bytes_read == 0);
REQUIRE(std::equal(std::begin(buf),
std::begin(buf) + test_string_view.size(),
std::cbegin(test_string_view),
std::cend(test_string_view)));
}
}
SECTION("...using a long static buffer (throwing)") {
std::array<char, 100> buf;
std::size_t bytes_read = 0;
REQUIRE_NOTHROW(bytes_read = d.read_some(io::buffer(buf)));
REQUIRE(bytes_read == test_string_view.size());
REQUIRE(std::equal(std::begin(buf),
std::begin(buf) + test_string_view.size(),
std::cbegin(test_string_view),
std::cend(test_string_view)));
SECTION("...and further reads result in an error") {
REQUIRE_THROWS_AS(bytes_read = d.read_some(io::buffer(buf)),
std::system_error);
REQUIRE(bytes_read == test_string_view.size());
REQUIRE(std::equal(std::begin(buf),
std::begin(buf) + test_string_view.size(),
std::cbegin(test_string_view),
std::cend(test_string_view)));
}
}
SECTION("...using a dynamic buffer") {
std::vector<char> buf;
std::error_code ec;
std::size_t bytes_read = 0;
REQUIRE_NOTHROW(bytes_read = io::read(d, io::dynamic_buffer(buf),
io::transfer_exactly{test_string_view.size()},
ec));
REQUIRE(bytes_read == test_string_view.size());
REQUIRE(std::equal(std::cbegin(buf), std::cend(buf),
std::cbegin(test_string_view), std::cend(test_string_view)));
}
SECTION("...using a dynamic buffer (throwing)") {
std::vector<char> buf;
std::size_t bytes_read = 0;
REQUIRE_NOTHROW(bytes_read = io::read(d, io::dynamic_buffer(buf),
io::transfer_exactly{test_string_view.size()}));
REQUIRE(bytes_read == test_string_view.size());
REQUIRE(std::equal(std::cbegin(buf), std::cend(buf),
std::cbegin(test_string_view), std::cend(test_string_view)));
}
}
|
8e15a13dcad0fcee35d70888c54c49488e3c3491 | f6c069d7684fba8f591e6669815c23fbd4b2509c | /week3/nx305_hw3_q4/nx305_hw3_q4/nx305_hw3_q4.cpp | cd3e990dfbed97d5f7d2c2c68d4b2c65335291fc | [] | no_license | amu983/NYU-Bridge-to-Computer-Science | c7e108252954c22415bcefea44f0edf19e9f8dbb | c30dde58566be3dbcf8fc525667c0d39fec0f76e | refs/heads/master | 2023-03-16T14:05:51.003098 | 2019-06-26T02:39:21 | 2019-06-26T02:39:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 788 | cpp | nx305_hw3_q4.cpp | #include <iostream>
#include <string>
using namespace std;
int main() {
float input;
int method;
const int FLOOR_ROUND = 1;
const int CEILING_ROUND = 2;
const int ROUND = 3;
cout<<"Please enter a Real number: \n";
cin>>input;
cout<<"Choose your rounding method: \n1.Floor round\n2.Ceiling round\n3.Round to thte nearest whole number\n";
cin>>method;
switch(method){
case FLOOR_ROUND:
cout<<int(input)<<endl;
break;
case CEILING_ROUND:
cout<<int(input+1)<<endl;
break;
case ROUND:
if(input-int(input)<0.5)
cout<<int(input)<<endl;
else
cout<<int(input+1)<<endl;
break;
}
return 0;
}
|
090fa6980ab4d8d570a02a6cc79f3b1c23b1a024 | 1c9d3f941f3b2d2a43395765c463cea469137517 | /Verify/LC_range_kth_smallest-2.test.cpp | f3514fb1b5a5dd691cc53764fbb83d15adfba9d4 | [] | no_license | tko919/library | ab97cb246d3c65ed441097a1691fd39e9ca2afa1 | fd31658c12fd547301992a1bbdacc6818dc8d45f | refs/heads/main | 2023-06-21T22:24:50.462875 | 2023-06-14T06:19:08 | 2023-06-14T06:19:08 | 442,397,837 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,022 | cpp | LC_range_kth_smallest-2.test.cpp | #define PROBLEM "https://judge.yosupo.jp/problem/range_kth_smallest"
#include "Template/template.hpp"
#include "Utility/fastio.hpp"
#include "DataStructure/persistentrbstset.hpp"
const int LIM=201010*20*5;
using np=PRBSTset<int,LIM>::np;
FastIO io;
int main(){
int n,q;
io.read(n,q);
vector<int> a(n);
io.read(a);
vector<int> zip;
rep(i,0,n)zip.push_back(a[i]);
sort(ALL(zip));
zip.erase(unique(ALL(zip)),zip.end());
rep(i,0,n)a[i]=lower_bound(ALL(zip),a[i])-zip.begin();
PRBSTset<int,LIM> manager;
vector<np> buf(1,nullptr);
rep(i,0,n)buf.push_back(manager.insert(buf.back(),a[i]));
int L,R,k;
while(q--){
io.read(L,R,k);
int lb=0,rb=zip.size();
while(rb-lb>1){
int mid=(lb+rb)>>1;
int cnt=manager.upper_bound(buf[R],mid)-manager.upper_bound(buf[L],mid);
if(cnt<=k)lb=mid;
else rb=mid;
}
io.write(zip[lb]);
}
return 0;
} |
2a318b3a125e167480bdc519db79a55f97c87633 | 864b632662c893bca3a31f9507f1cc0f36065b7b | /parse.cpp | 7647d99cb5c528c96b0e38f5ac2f9405a8e049b4 | [] | no_license | ChufanSuki/syscc | f29d948ebc9368e13cbd77dd770f93ccc28fc74a | 1f8a7893b298b5432d479bcb5e62144165a2f727 | refs/heads/master | 2023-05-12T19:11:14.436145 | 2021-06-01T06:44:06 | 2021-06-01T06:44:06 | 370,313,413 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,201 | cpp | parse.cpp | // This file contains a recursive descent parser for C.
//
// Most functions in this file are named after the symbols they are
// supposed to read from an input token list. For example, stmt() is
// responsible for reading a statement from a token list. The function
// then construct an AST node representing a statement.
//
// Each function conceptually returns two values, an AST node and
// remaining part of the input tokens. Since C doesn't support
// multiple return values, the remaining tokens are returned to the
// caller via a pointer argument.
//
// Input tokens are represented by a linked list. Unlike many recursive
// descent parsers, we don't have the notion of the "input token stream".
// Most parsing functions don't change the global state of the parser.
// So it is very easy to lookahead arbitrary number of tokens in this
// parser.
#include <list>
#include "syscc.hpp"
// All local variable instances created during parsing are
// accumulated to this list.
static Obj *locals;
static Obj *globals;
static Type *declspec(Token **rest, Token *tok);
static Type *declarator(Token **rest, Token *tok, Type *ty);
static Node *declaration(Token **rest, Token *tok);
static Node *compound_stmt(Token **rest, Token *tok);
static Node *stmt(Token **rest, Token *tok);
static Node *expr_stmt(Token **rest, Token *tok);
static Node *expr(Token **rest, Token *tok);
static Node *assign(Token **rest, Token *tok);
static Node *equality(Token **rest, Token *tok);
static Node *relational(Token **rest, Token *tok);
static Node *add(Token **rest, Token *tok);
static Node *mul(Token **rest, Token *tok);
static Node *postfix(Token **rest, Token *tok);
static Node *unary(Token **rest, Token *tok);
static Node *primary(Token **rest, Token *tok);
// Find a local variable by name.
static Obj *find_var(Token *tok) {
for (Obj *var = locals; var; var = var->next)
if (strlen(var->name) == tok->len && !strncmp(tok->loc, var->name, tok->len)) return var;
for (Obj *var = globals; var; var = var->next)
if (strlen(var->name) == tok->len && !strncmp(tok->loc, var->name, tok->len)) return var;
return NULL;
}
static Node *new_node(NodeKind kind, Token *tok) {
Node *node = (Node *)calloc(1, sizeof(Node));
node->kind = kind;
node->tok = tok;
return node;
}
static Node *new_binary(NodeKind kind, Node *lhs, Node *rhs, Token *tok) {
Node *node = new_node(kind, tok);
node->lhs = lhs;
node->rhs = rhs;
return node;
}
static Node *new_unary(NodeKind kind, Node *expr, Token *tok) {
Node *node = new_node(kind, tok);
node->lhs = expr;
return node;
}
static Node *new_num(int val, Token *tok) {
Node *node = new_node(ND_NUM, tok);
node->val = val;
return node;
}
static Node *new_var_node(Obj *var, Token *tok) {
Node *node = new_node(ND_VAR, tok);
node->var = var;
return node;
}
static Obj *new_var(char *name, Type *ty) {
Obj *var = (Obj *)calloc(1, sizeof(Obj));
var->name = name;
var->ty = ty;
return var;
}
static Obj *new_lvar(char *name, Type *ty) {
Obj *var = new_var(name, ty);
var->is_local = true;
var->next = locals;
locals = var;
return var;
}
static Obj *new_gvar(char *name, Type *ty) {
Obj *var = new_var(name, ty);
var->next = globals;
globals = var;
return var;
}
static char *new_unique_name(void) {
static int id = 0;
return format(".L..%d", id++);
}
static Obj *new_anon_gvar(Type *ty) { return new_gvar(new_unique_name(), ty); }
static Obj *new_string_literal(char *p, Type *ty) {
Obj *var = new_anon_gvar(ty);
var->init_data = p;
return var;
}
static char *get_ident(Token *tok) {
if (tok->kind != TK_IDENT) error_tok(tok, "expected an identifier");
return strndup(tok->loc, tok->len);
}
static int get_number(Token *tok) {
if (tok->kind != TK_NUM) error_tok(tok, "expected a number");
return tok->val;
}
// declspec = "char" | "int"
static Type *declspec(Token **rest, Token *tok) {
if (equal(tok, "char")) {
*rest = tok->next;
return ty_char;
}
*rest = skip(tok, "int");
return ty_int;
}
// func-params = (param ("," param)*)? ")"
// param = declspec declarator
static Type *func_params(Token **rest, Token *tok, Type *ty) {
Type head = {};
Type *cur = &head;
while (!equal(tok, ")")) {
if (cur != &head) tok = skip(tok, ",");
Type *basety = declspec(&tok, tok);
Type *ty = declarator(&tok, tok, basety);
cur = cur->next = copy_type(ty);
}
ty = func_type(ty);
ty->params = head.next;
*rest = tok->next;
return ty;
}
// type-suffix = "(" func-params
// | "[" num "]" type-suffix
// | ε
static Type *type_suffix(Token **rest, Token *tok, Type *ty) {
if (equal(tok, "(")) return func_params(rest, tok->next, ty);
if (equal(tok, "[")) {
int sz = get_number(tok->next);
tok = skip(tok->next->next, "]");
ty = type_suffix(rest, tok, ty);
return array_of(ty, sz);
}
*rest = tok;
return ty;
}
// declarator = "*"* ident type-suffix
static Type *declarator(Token **rest, Token *tok, Type *ty) {
while (consume(&tok, tok, "*")) ty = pointer_to(ty);
if (tok->kind != TK_IDENT) error_tok(tok, "expected a variable name");
ty = type_suffix(rest, tok->next, ty);
ty->name = tok;
return ty;
}
// FIXME: "int;" passed parsing
// declaration = declspec (declarator ("=" expr)? ("," declarator ("=" expr)?)*)? ";"
static Node *declaration(Token **rest, Token *tok) {
Type *basety = declspec(&tok, tok);
Node head = {};
Node *cur = &head;
int i = 0;
while (!equal(tok, ";")) {
if (i++ > 0) tok = skip(tok, ",");
Type *ty = declarator(&tok, tok, basety);
if (find_var(ty->name)) {
char message[50];
sprintf(message, "redefinition of '%s'", get_ident(ty->name));
error_tok(tok, message);
}
Obj *var = new_lvar(get_ident(ty->name), ty);
if (!equal(tok, "=")) continue;
Node *lhs = new_var_node(var, ty->name);
Node *rhs = assign(&tok, tok->next);
Node *node = new_binary(ND_ASSIGN, lhs, rhs, tok);
cur = cur->next = new_unary(ND_EXPR_STMT, node, tok);
}
Node *node = new_node(ND_BLOCK, tok);
node->body = head.next;
*rest = tok->next;
return node;
}
// Returns true if a given token represents a type.
static bool is_typename(Token *tok) { return equal(tok, "char") || equal(tok, "int"); }
// stmt = "return" expr ";"
// | "if" "(" expr ")" stmt ("else" stmt)?
// | "for" "(" expr-stmt expr? ";" expr? ")" stmt
// | "while" "(" expr ")" stmt
// | "{" compound-stmt
// | expr-stmt
static Node *stmt(Token **rest, Token *tok) {
if (equal(tok, "return")) {
Node *node = new_node(ND_RETURN, tok);
node->lhs = expr(&tok, tok->next);
*rest = skip(tok, ";");
return node;
}
if (equal(tok, "for")) {
Node *node = new_node(ND_FOR, tok);
tok = skip(tok->next, "(");
node->init = expr_stmt(&tok, tok);
if (!equal(tok, ";")) node->cond = expr(&tok, tok);
tok = skip(tok, ";");
if (!equal(tok, ")")) node->inc = expr(&tok, tok);
tok = skip(tok, ")");
node->then = stmt(rest, tok);
return node;
}
if (equal(tok, "while")) {
Node *node = new_node(ND_FOR, tok);
tok = skip(tok->next, "(");
node->cond = expr(&tok, tok);
tok = skip(tok, ")");
node->then = stmt(rest, tok);
return node;
}
if (equal(tok, "{")) return compound_stmt(rest, tok->next);
if (equal(tok, "if")) {
Node *node = new_node(ND_IF, tok);
tok = skip(tok->next, "(");
node->cond = expr(&tok, tok);
tok = skip(tok, ")");
node->then = stmt(&tok, tok);
if (equal(tok, "else")) node->els = stmt(&tok, tok->next);
*rest = tok;
return node;
}
return expr_stmt(rest, tok);
}
// compound-stmt = (declaration | stmt)* "}"
static Node *compound_stmt(Token **rest, Token *tok) {
Node head = {};
Node *cur = &head;
while (!equal(tok, "}")) {
if (is_typename(tok))
cur = cur->next = declaration(&tok, tok);
else
cur = cur->next = stmt(&tok, tok);
add_type(cur);
}
Node *node = new_node(ND_BLOCK, tok);
node->body = head.next;
*rest = tok->next;
return node;
}
// expr-stmt = expr ";"
static Node *expr_stmt(Token **rest, Token *tok) {
if (equal(tok, ";")) {
*rest = tok->next;
return new_node(ND_BLOCK, tok);
}
Node *node = new_node(ND_EXPR_STMT, tok);
node->lhs = expr(&tok, tok);
*rest = skip(tok, ";");
return node;
}
// expr = assign
static Node *expr(Token **rest, Token *tok) { return assign(rest, tok); }
// assign = equality ("=" assign)?
static Node *assign(Token **rest, Token *tok) {
Node *node = equality(&tok, tok);
if (equal(tok, "=")) node = new_binary(ND_ASSIGN, node, assign(&tok, tok->next), tok);
*rest = tok;
return node;
}
// equality = relational ("==" relational | "!=" relational)*
static Node *equality(Token **rest, Token *tok) {
Node *node = relational(&tok, tok);
for (;;) {
Token *start = tok;
if (equal(tok, "==")) {
node = new_binary(ND_EQ, node, relational(&tok, tok->next), start);
continue;
}
if (equal(tok, "!=")) {
node = new_binary(ND_NE, node, relational(&tok, tok->next), start);
continue;
}
*rest = tok;
return node;
}
}
// relational = add ("<" add | "<=" add | ">" add | ">=" add)*
static Node *relational(Token **rest, Token *tok) {
Node *node = add(&tok, tok);
for (;;) {
Token *start = tok;
if (equal(tok, "<")) {
node = new_binary(ND_LT, node, add(&tok, tok->next), start);
continue;
}
if (equal(tok, "<=")) {
node = new_binary(ND_LE, node, add(&tok, tok->next), start);
continue;
}
if (equal(tok, ">")) {
node = new_binary(ND_LT, add(&tok, tok->next), node, start);
continue;
}
if (equal(tok, ">=")) {
node = new_binary(ND_LE, add(&tok, tok->next), node, start);
continue;
}
*rest = tok;
return node;
}
}
// In C, `+` operator is overloaded to perform the pointer arithmetic.
// If p is a pointer, p+n adds not n but sizeof(*p)*n to the value of p,
// so that p+n points to the location n elements (not bytes) ahead of p.
// In other words, we need to scale an integer value before adding to a
// pointer value. This function takes care of the scaling.
static Node *new_add(Node *lhs, Node *rhs, Token *tok) {
add_type(lhs);
add_type(rhs);
// num + num
if (is_integer(lhs->ty) && is_integer(rhs->ty)) return new_binary(ND_ADD, lhs, rhs, tok);
// error: ptr + ptr
if (lhs->ty->base && rhs->ty->base) error_tok(tok, "invalid operands");
// Canonicalize `num + ptr` to `ptr + num`.
if (!lhs->ty->base && rhs->ty->base) {
Node *tmp = lhs;
lhs = rhs;
rhs = tmp;
}
// ptr + num
rhs = new_binary(ND_MUL, rhs, new_num(lhs->ty->base->size, tok), tok);
return new_binary(ND_ADD, lhs, rhs, tok);
}
// Like `+`, `-` is overloaded for the pointer type.
static Node *new_sub(Node *lhs, Node *rhs, Token *tok) {
add_type(lhs);
add_type(rhs);
// num - num
if (is_integer(lhs->ty) && is_integer(rhs->ty)) return new_binary(ND_SUB, lhs, rhs, tok);
// ptr - num
if (lhs->ty->base && is_integer(rhs->ty)) {
rhs = new_binary(ND_MUL, rhs, new_num(lhs->ty->base->size, tok), tok);
add_type(rhs);
Node *node = new_binary(ND_SUB, lhs, rhs, tok);
node->ty = lhs->ty;
return node;
}
// ptr - ptr, which returns how many elements are between the two.
if (lhs->ty->base && rhs->ty->base) {
Node *node = new_binary(ND_SUB, lhs, rhs, tok);
node->ty = ty_int;
return new_binary(ND_DIV, node, new_num(lhs->ty->base->size, tok), tok);
}
error_tok(tok, "invalid operands");
}
// add = mul ("+" mul | "-" mul)*
static Node *add(Token **rest, Token *tok) {
Node *node = mul(&tok, tok);
for (;;) {
Token *start = tok;
if (equal(tok, "+")) {
node = new_add(node, mul(&tok, tok->next), start);
continue;
}
if (equal(tok, "-")) {
node = new_sub(node, mul(&tok, tok->next), start);
continue;
}
*rest = tok;
return node;
}
}
// mul = unary ("*" unary | "/" unary)*
static Node *mul(Token **rest, Token *tok) {
Node *node = unary(&tok, tok);
for (;;) {
Token *start = tok;
if (equal(tok, "*")) {
node = new_binary(ND_MUL, node, unary(&tok, tok->next), start);
continue;
}
if (equal(tok, "/")) {
node = new_binary(ND_DIV, node, unary(&tok, tok->next), start);
continue;
}
*rest = tok;
return node;
}
}
// unary = ("+" | "-" | "*" | "&") unary
// | postfix
static Node *unary(Token **rest, Token *tok) {
if (equal(tok, "+")) return unary(rest, tok->next);
if (equal(tok, "-")) return new_unary(ND_NEG, unary(rest, tok->next), tok);
if (equal(tok, "&")) return new_unary(ND_ADDR, unary(rest, tok->next), tok);
if (equal(tok, "*")) return new_unary(ND_DEREF, unary(rest, tok->next), tok);
return postfix(rest, tok);
}
// postfix = primary ("[" expr "]")*
static Node *postfix(Token **rest, Token *tok) {
Node *node = primary(&tok, tok);
while (equal(tok, "[")) {
// x[y] is short for *(x+y)
Token *start = tok;
Node *idx = expr(&tok, tok->next);
tok = skip(tok, "]");
node = new_unary(ND_DEREF, new_add(node, idx, start), start);
}
*rest = tok;
return node;
}
// funcall = ident "(" (assign ("," assign)*)? ")"
static Node *funcall(Token **rest, Token *tok) {
Token *start = tok;
tok = tok->next->next;
Node head = {};
Node *cur = &head;
while (!equal(tok, ")")) {
if (cur != &head) tok = skip(tok, ",");
cur = cur->next = assign(&tok, tok);
}
*rest = skip(tok, ")");
Node *node = new_node(ND_FUNCALL, start);
node->funcname = strndup(start->loc, start->len);
node->args = head.next;
return node;
}
// primary = "(" expr ")" | "sizeof" unary | num | str | ident func-args?
static Node *primary(Token **rest, Token *tok) {
if (equal(tok, "(")) {
Node *node = expr(&tok, tok->next);
*rest = skip(tok, ")");
return node;
}
if (equal(tok, "sizeof")) {
Node *node = unary(rest, tok->next);
add_type(node);
return new_num(node->ty->size, tok);
}
if (tok->kind == TK_NUM) {
Node *node = new_num(tok->val, tok);
*rest = tok->next;
return node;
}
if (tok->kind == TK_STR) {
Obj *var = new_string_literal(tok->str, tok->ty);
*rest = tok->next;
return new_var_node(var, tok);
}
if (tok->kind == TK_IDENT) {
// Function call
if (equal(tok->next, "(")) return funcall(rest, tok);
// Variable
Obj *var = find_var(tok);
if (!var) error_tok(tok, "undefined variable");
*rest = tok->next;
return new_var_node(var, tok);
}
error_tok(tok, "expected an expression");
}
static void create_param_lvars(Type *param) {
if (param) {
create_param_lvars(param->next);
new_lvar(get_ident(param->name), param);
}
}
// function-definition = declspec declarator "{" compound-stmt
static Token *function(Token *tok, Type *basety) {
Type *ty = declarator(&tok, tok, basety);
Obj *fn = new_gvar(get_ident(ty->name), ty);
fn->is_function = true;
locals = NULL;
create_param_lvars(ty->params);
fn->params = locals;
tok = skip(tok, "{");
fn->body = compound_stmt(&tok, tok);
fn->locals = locals;
return tok;
}
static Token *global_variable(Token *tok, Type *basety) {
bool first = true;
while (!consume(&tok, tok, ";")) {
if (!first) tok = skip(tok, ",");
first = false;
Type *ty = declarator(&tok, tok, basety);
new_gvar(get_ident(ty->name), ty);
}
return tok;
}
// Lookahead tokens and returns true if a given token is a start
// of a function definition or declaration.
static bool is_function(Token *tok) {
if (equal(tok, ";")) return false;
Type dummy = {};
Type *ty = declarator(&tok, tok, &dummy);
return ty->kind == TY_FUNC;
}
// program = (function-definition | global-variable)*
Obj *parse(Token *tok) {
globals = NULL;
while (tok->kind != TK_EOF) {
Type *basety = declspec(&tok, tok);
// Function
if (is_function(tok)) {
tok = function(tok, basety);
continue;
}
// Global variable
tok = global_variable(tok, basety);
}
return globals;
}
// print ast
static int ncount = 1;
static void gen_expr(Node *node, int father) {
switch (node->kind) {
case ND_NUM:
printf(" node%d [label=\"%d\"];\n", ncount++, node->val);
printf(" node%d -> node%d;\n", father, ncount - 1);
return;
case ND_NEG:
printf(" node%d [label=\"%s\"];\n", ncount++, "NEG");
printf(" node%d -> node%d;\n", father, ncount - 1);
gen_expr(node->lhs, ncount - 1);
return;
case ND_VAR:
printf(" node%d [label=\"%s\"];\n", ncount++, "VAR");
printf(" node%d -> node%d;\n", father, ncount - 1);
// gen_addr(node);
return;
case ND_DEREF:
printf(" node%d [label=\"%s\"];\n", ncount++, "DEREF");
printf(" node%d -> node%d;\n", father, ncount - 1);
gen_expr(node->lhs, ncount - 1);
return;
case ND_ADDR:
printf(" node%d [label=\"%s\"];\n", ncount++, "ADDR");
printf(" node%d -> node%d;\n", father, ncount - 1);
// gen_addr(node->lhs);
return;
case ND_ASSIGN:
printf(" node%d [label=\"%s\"];\n", ncount++, "ASSIGN");
printf(" node%d -> node%d;\n", father, ncount - 1);
// gen_addr(node->lhs, ncount);
gen_expr(node->rhs, ncount - 1);
return;
case ND_FUNCALL:
printf(" node%d [label=\"%s\"];\n", ncount++, "FUNCALL");
printf(" node%d -> node%d;\n", father, ncount - 1);
int nargs = 0;
for (Node *arg = node->args; arg; arg = arg->next) {
gen_expr(arg, ncount - 1);
nargs++;
}
return;
}
switch (node->kind) {
case ND_ADD:
printf(" node%d [label=\"%s\"]\n", ncount++, "ADD");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
case ND_SUB:
printf(" node%d [label=\"%s\"]\n", ncount++, "SUB");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
case ND_MUL:
printf(" node%d [label=\"%s\"]\n", ncount++, "MUL");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
case ND_DIV:
printf(" node%d [label=\"%s\"]\n", ncount++, "DIV");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
case ND_EQ:
printf(" node%d [label=\"%s\"]\n", ncount++, "EQ");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
case ND_NE:
printf(" node%d [label=\"%s\"]\n", ncount++, "NE");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
case ND_LT:
printf(" node%d [label=\"%s\"]\n", ncount++, "LT");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
case ND_LE:
printf(" node%d [label=\"%s\"]\n", ncount++, "LE");
printf(" node%d -> node%d\n", father, ncount - 1);
break;
}
int tmp = ncount;
gen_expr(node->rhs, ncount - 1);
gen_expr(node->lhs, tmp - 1);
}
static void gen_stmt(Node *node, int father) {
switch (node->kind) {
case ND_IF: {
printf(" node%d [label=\"%s\"]\n", ncount++, "IF");
printf(" node%d -> node%d\n", father, ncount - 1);
gen_stmt(node->then, ncount);
if (node->els) gen_stmt(node->els, ncount);
return;
}
case ND_FOR: {
if (node->init) {
printf(" node%d [label=\"%s\"]\n", ncount++, "FOR");
printf(" node%d -> node%d\n", father, ncount - 1);
} else {
printf(" node%d [label=\"%s\"]\n", ncount++, "WHILE");
printf(" node%d -> node%d\n", father, ncount - 1);
}
if (node->init) gen_stmt(node->init, ncount);
if (node->cond) {
gen_expr(node->cond, ncount);
}
gen_stmt(node->then, ncount);
if (node->inc) gen_expr(node->inc, ncount);
return;
}
case ND_BLOCK: {
printf(" node%d [label=\"%s\"];\n", ncount++, "BLOCK");
printf(" node%d -> node%d;\n", father, ncount - 1);
int tmp = ncount;
for (Node *n = node->body; n; n = n->next) gen_stmt(n, tmp - 1);
return;
}
case ND_RETURN:
printf(" node%d [label=\"%s\"];\n", ncount++, "RETURN");
printf(" node%d -> node%d;\n", father, ncount - 1);
gen_expr(node->lhs, ncount - 1);
return;
case ND_EXPR_STMT:
printf(" node%d [label=\"%s\"];\n", ncount++, "EXPR STMT");
printf(" node%d -> node%d;\n", father, ncount - 1);
gen_expr(node->lhs, ncount - 1);
return;
}
}
static Obj *current_fn;
static int current_fn_num;
void dotgen(Obj *prog) {
Obj *cur = prog;
printf(
"digraph astgraph {\n node [shape=none, fontsize=12, fontname=\"Courier\", height=.1];\n ranksep=.3;\n edge "
"[arrowsize=.5];\n");
printf(" node%d [label=\"%s\"];\n", ncount++, "prog");
for (Obj *fn = prog; fn; fn = fn->next) {
printf(" node%d [label=\"%s\"];\n", ncount++, fn->name);
printf(" node%d -> node%d;\n", 1, ncount - 1);
if (!fn->is_function) {
continue;
}
current_fn = fn;
current_fn_num = ncount - 1;
gen_stmt(fn->body, current_fn_num);
}
printf("}\n");
} |
53746fb24ce973bd3765e1d96850ba09d0808885 | cb3c83ad5c85ed82caefc1f4c6224bbf7a04424b | /djtana_data/jetsyst/jetsyst.h | fb48564210af9a0d787aec05c05ad0a9ce871537 | [] | no_license | boundino/Djetanalysis | efd7ecc25d6197986beceec541624028b6f9e4da | 3e713045f8718198713e5d177ab090f5ada07b0d | refs/heads/master | 2021-01-18T23:16:19.261958 | 2019-10-30T03:43:09 | 2019-10-30T03:43:09 | 87,100,861 | 0 | 0 | null | 2017-04-03T17:21:12 | 2017-04-03T17:21:11 | null | UTF-8 | C++ | false | false | 3,303 | h | jetsyst.h | #ifndef _DJTANA_H_
#define _DJTANA_H_
#include "prefilters.h"
#include "../includes/xjjcuti.h"
#include "../includes/xjjrootuti.h"
#include <iostream>
#include <iomanip>
#include <TMath.h>
#include <TH1F.h>
#include <TH2F.h>
#include <TLegend.h>
#include <TCanvas.h>
#include <TFile.h>
//
const int nRefBins = 2;
TString tRef[nRefBins] = {"eta", "etaref"};
const int nScale = 4;
TString nameScale[nScale] = {"ScaleP", "ScaleM", "ScaleQ", "ScaleG"};
TString legScale[nScale] = {"data-MC diff+", "data-MC diff-", "Quark jes", "Gluon jes"};
Color_t colorlist[] = {kGreen-5, kRed-9, kAzure-4, kViolet-9, kOrange-9};
TH1F* ahSignalRnorm[nRefBins][nPtBins];
TH1F* ahSignalRnormScale[nRefBins][nPtBins][nScale];
TH1F* ahSignalRsub[nPtBins];
TH1F* ahSignalRsubScale[nPtBins][nScale];
TH1F* ahDevRnormScale[nRefBins][nPtBins][nScale];
TH1F* ahDevRsubScale[nPtBins][nScale];
TH1F* ahDevRsubtotal[nPtBins];
//
int createhists(Option_t* option)
{
TString opt = option;
opt.ToLower();
if(opt=="plothist")
{
for(int i=0;i<nPtBins;i++)
{
for(int l=0;l<nRefBins;l++)
{
for(int v=0;v<nScale;v++)
{ ahDevRnormScale[l][i][v] = new TH1F(Form("hDevRnormScale_%s_%s_pt_%d",nameScale[v].Data(),tRef[l].Data(),i), ";r;", nDrBins, drBins); }
}
for(int v=0;v<nScale;v++)
{ ahDevRsubScale[i][v] = new TH1F(Form("hDevRsubScale_%s_pt_%d",nameScale[v].Data(),i), ";r;", nDrBins, drBins); }
ahDevRsubtotal[i] = new TH1F(Form("hDevRsubtotal_pt_%d",i), ";r;", nDrBins, drBins);
}
return 0;
}
std::cout<<"error: invalid option for createhists()"<<std::endl;
return 1;
}
int writehists(Option_t* option)
{
TString opt = option;
opt.ToLower();
std::cout<<"error: invalid option for writehists()"<<std::endl;
return 1;
}
int gethists(std::vector<TFile*> inf, Option_t* option)
{
TString opt = option;
opt.ToLower();
if(opt.Contains("plothist_default"))
{
for(int i=0;i<nPtBins;i++)
{
for(int l=0;l<nRefBins;l++)
{
ahSignalRnorm[l][i] = (TH1F*)inf[0]->Get(Form("hSignalRnorm_%s_pt_%d",tRef[l].Data(),i));
ahSignalRnorm[l][i]->Scale(1./ahSignalRnorm[l][i]->Integral("width"));
}
ahSignalRsub[i] = (TH1F*)inf[0]->Get(Form("hSignalRsubMe_pt_%d",i));
}
return 0;
}
if(opt.Contains("plothist_scale"))
{
for(int v=0;v<nScale;v++)
{
for(int i=0;i<nPtBins;i++)
{
for(int l=0;l<nRefBins;l++)
{
ahSignalRnormScale[l][i][v] = (TH1F*)inf[v]->Get(Form("hSignalRnorm_%s_pt_%d",tRef[l].Data(),i));
ahSignalRnormScale[l][i][v]->SetName(Form("hSignalRnorm_%s_%s_pt_%d",nameScale[v].Data(),tRef[l].Data(),i));
ahSignalRnormScale[l][i][v]->Scale(1./ahSignalRnormScale[l][i][v]->Integral("width"));
}
ahSignalRsubScale[i][v] = (TH1F*)inf[v]->Get(Form("hSignalRsubMe_pt_%d",i));
ahSignalRsubScale[i][v]->SetName(Form("hSignalRsubMe_%s_pt_%d",nameScale[v].Data(),i));
}
}
return 0;
}
std::cout<<"error: invalid option for gethists()"<<std::endl;
return 1;
}
#endif
|
2266632d6eca591c0f5395fdb42d09494ee908a6 | 0379dd91363f38d8637ff242c1ce5d3595c9b549 | /windows_10_shared_source_kit/windows_10_shared_source_kit/10_1_14354_1000/Source/network/wlan/sys/wdi/driver/NetworkHistory.cpp | c840da0cd987be6ae95ed13001bebd9a2f2567cc | [] | no_license | zhanglGitHub/windows_10_shared_source_kit | 14f25e6fff898733892d0b5cc23b2b88b04458d9 | 6784379b0023185027894efe6b97afee24ca77e0 | refs/heads/master | 2023-03-21T05:04:08.653859 | 2020-09-28T16:44:54 | 2020-09-28T16:44:54 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,116 | cpp | NetworkHistory.cpp | /*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
NetworkHistory.cpp
Abstract:
Implementation for maintaining history of networks on a port
Environment:
Kernel mode
Revision History:
--*/
#include "precomp.hpp"
#include "NetworkHistory.tmh"
//==============================================================================================
void CNetworkHistory::FindOrAddChannelEntry(
_In_ UINT32 BandId,
_In_ UINT32 Channel
)
{
ULONG leastUsage = (ULONG)-1;
ULONG replaceIndex = 0;
ULONG i;
bool bNeedsToBeSaved = true;
// If already seen outside 2.4GHz, only update if this is not 2.4GHz. This way we are using
// the scan optimization to find 5GHz APs instead of spending time on 2.4GHz
// aps
if (FoundOutside24GHz && (BandId == WDI_BAND_ID_2400))
{
// Dont save, but "reduce" others
bNeedsToBeSaved = false;
}
for (i = 0; i < WFC_CONSTANT::MaxNetworkChannelHistorySize; i++)
{
if ((ChannelHistory[i].BandId == BandId) &&
(ChannelHistory[i].ChannelNumber == Channel) &&
(ChannelHistory[i].IsValid())
)
{
// Dont increment so much that we have to deal with this never going away.
// We limit to "MaxConnectBSSChannelUsage + ConnectBSSChannelHistoryBoost".
if (bNeedsToBeSaved && // Would be false for 2.4GHz when 5GHz is found
(ChannelHistory[i].ConnectUsageCount < WFC_CONSTANT::MaxConnectBSSChannelUsage))
{
ChannelHistory[i].ConnectUsageCount += WFC_CONSTANT::ConnectBSSChannelHistoryBoost;
WFCTrace("[ChannelHint] Incrementing channel hint entry B:%d C:%d to %d", BandId, Channel,
ChannelHistory[i].ConnectUsageCount);
}
// Dont break since we want to reduce everyone else
bNeedsToBeSaved = false;
}
else if (leastUsage > ChannelHistory[i].ConnectUsageCount)
{
if ((ChannelHistory[i].ConnectUsageCount > 0) &&
!ChannelHistory[i].FoundInCandidateList)
{
// Not connected to and was not found in candidates list
ChannelHistory[i].ConnectUsageCount--;
}
// This would be a candidate to replace
leastUsage = ChannelHistory[i].ConnectUsageCount;
replaceIndex = i;
}
// No longer considered found in scan
ChannelHistory[i].FoundInCandidateList = false;
}
if (bNeedsToBeSaved && (i >= WFC_CONSTANT::MaxNetworkChannelHistorySize))
{
WFCTrace("[ChannelHint] Saved channel entry B:%d C:%d (replacing B:%d C:%d)",
BandId, Channel,
ChannelHistory[replaceIndex].BandId, ChannelHistory[replaceIndex].ChannelNumber);
// Didnt find the entry. Replace an existing one
ChannelHistory[replaceIndex].Initialize(BandId, Channel);
ChannelHistory[replaceIndex].ConnectUsageCount = WFC_CONSTANT::ConnectBSSChannelHistoryBoost;
}
}
//==============================================================================================
NDIS_STATUS CNetworkHistoryList::Initialize(
_In_ CAdapter* pAdapter,
_In_ UINT16 WfcPortId,
_In_ ULONG MaxEntryCount
)
{
NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS;
TraceEntry();
m_pAdapter = pAdapter;
m_WfcPortId = WfcPortId;
m_MaxEntryCount = MaxEntryCount;
m_pTable = new CNetworkHistory[m_MaxEntryCount];
if (m_pTable == NULL)
{
WFCError("Failed to allocate table for %d Networks", m_MaxEntryCount);
ndisStatus = NDIS_STATUS_RESOURCES;
goto exit;
}
exit:
TraceExit(ndisStatus);
return ndisStatus;
}
CNetworkHistory* CNetworkHistoryList::FindNetworkBySsid(
_In_ PDOT11_SSID pSsid
)
{
CNetworkHistory *pNetwork = NULL;
for (ULONG i = 0; i < m_MaxEntryCount; i++)
{
if (m_pTable[i].IsValid() &&
(m_pTable[i].NetworkSsid.uSSIDLength == pSsid->uSSIDLength) &&
(memcmp(m_pTable[i].NetworkSsid.ucSSID, pSsid->ucSSID,
pSsid->uSSIDLength) == 0))
{
pNetwork = &m_pTable[i];
}
}
return pNetwork;
}
__success(return == NDIS_STATUS_SUCCESS)
NDIS_STATUS CNetworkHistoryList::UpdateOrAddNetworkToTable(
_In_ PDOT11_SSID pSsid,
_Out_ CNetworkHistory **ppOutNetwork
)
{
NDIS_STATUS ndisStatus = NDIS_STATUS_SUCCESS;
CNetworkHistory *pNetwork = NULL;
pNetwork = FindNetworkBySsid(pSsid);
// Didnt find, add
if (!pNetwork)
{
ULONGLONG oldestTime = (ULONGLONG)-1;
ULONG indexToReplace = 0;
// Try to find a place to add or an entry to replace
for (ULONG i = 0; i < m_MaxEntryCount; i++)
{
if (!m_pTable[i].IsValid())
{
pNetwork = &m_pTable[i];
break;
}
else
{
// Check if this is the oldest entry (for replacing)
if (oldestTime > m_pTable[i].LastUpdateTime)
{
// This is the oldest entry so far
oldestTime = m_pTable[i].LastUpdateTime;
indexToReplace = i;
}
}
}
if (pNetwork == NULL)
{
// Replace index 0 or whichever was found as the oldest entry
pNetwork = &m_pTable[indexToReplace];
}
if (pNetwork)
{
// Set this up
pNetwork->Initialize(pSsid);
}
else
{
ndisStatus = NDIS_STATUS_RESOURCES;
}
}
if (pNetwork)
{
pNetwork->LastUpdateTime = CSystem::get_CurrentTime();
}
*ppOutNetwork = pNetwork;
return ndisStatus;
}
VOID CNetworkHistoryList::CleanupNetworkObject(
_In_ CNetworkHistory* pPeer )
{
pPeer->Cleanup();
}
// Enumerate interfaces
CNetworkHistory* CNetworkHistoryList::GetFirst(
_Out_ NETWORK_HISTORY_ENUM_CONTEXT *pEnumContext
)
{
*pEnumContext = 0;
return GetNext(pEnumContext);
}
CNetworkHistory* CNetworkHistoryList::GetNext(
_Inout_ NETWORK_HISTORY_ENUM_CONTEXT *pEnumContext
)
{
for (ULONG i = *pEnumContext; i < m_MaxEntryCount; i++)
{
if (m_pTable[i].IsValid())
{
*pEnumContext = i + 1;
return &m_pTable[i];
}
}
return NULL;
}
void CNetworkHistoryList::FlushNetworkHistory()
{
for(ULONG i = 0; i < m_MaxEntryCount; i++)
{
if (m_pTable[i].IsValid())
{
CleanupNetworkObject(&m_pTable[i]);
}
}
}
|
9efc698d6ca8829f1d0b06869b47a42517fa0be0 | 5177b68f4bed92af4a47e08ad115699647e1bd8a | /June2019/0926FlipString.cpp | af396b0b3fde73e8b1a1915cf71bce4cb2dfacab | [] | no_license | wenxinmmb/LeetcodeEveryday | a5ea3b8239b78e96defc39998beabd4c69236664 | 33129ee7098e514fcd4c9b15000d1f7cb2ec23e0 | refs/heads/master | 2021-07-07T01:13:18.248874 | 2020-09-27T02:22:21 | 2020-09-27T02:22:21 | 190,129,079 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 597 | cpp | 0926FlipString.cpp | // https://leetcode.com/problems/flip-string-to-monotone-increasing/
// TODO: can work on improving memory usage
class Solution {
public:
int minFlipsMonoIncr(string S) {
vector<int> pos; int count = 0; int length = S.size();
for(int i = 0 ; i < length; i++){
if(S[i] == '1')
{
count++;
pos.push_back(i);
}
}
int minCount = count;
for(int j = 0; j < pos.size(); j++){
minCount = min(minCount, j + (length - pos[j] - count + j));
}
return minCount;
}
}; |
85a136f39ec6f8146fd6fe07ae7a96837c1e9bc6 | d761e11c779aea4677ecf8b7cbf28e0a401f6525 | /vn/arl/src/shared/HBFQueryProcessorConfiguration.h | 1eb69a7ee3a2572bc2dfa33d9cfcdb410412c493 | [] | no_license | derrick0714/infer | e5d717a878ff51fef6c9b55c444c2448d85f5477 | 7fabf5bfc34302eab2a6d2867cb4c22a6401ca73 | refs/heads/master | 2016-09-06T10:37:16.794445 | 2014-02-12T00:09:34 | 2014-02-12T00:09:34 | 7,787,601 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 665 | h | HBFQueryProcessorConfiguration.h | #ifndef HBFQUERYPROCESSORCONFIGURATION_H
#define HBFQUERYPROCESSORCONFIGURATION_H
#include <boost/filesystem.hpp>
#include "SynappConfiguration.h"
namespace vn {
namespace arl {
namespace shared {
namespace fs = boost::filesystem;
class HBFQueryProcessorConfiguration : public SynappConfiguration {
public:
explicit HBFQueryProcessorConfiguration(const fs::path &fileName);
uint16_t maxMTU() const;
size_t maxFlows() const;
size_t threadCount() const;
private:
void setOptionsDescriptions();
void parseOptions();
uint16_t _maxMTU;
size_t _maxFlows;
size_t _threadCount;
};
} // namespace vn
} // namespace arl
} // namespace shared
#endif
|
f4e03c24ba8b2006741e4e3327c514488bbbfc81 | 204e76bdd58337565ed10414768fb012524a6691 | /Project Shadow/Project Shadow/Engine/ModuleCinematics.cpp | 2b18cf896fb9ac1dfa41dfabddf10911cdad9583 | [
"MIT"
] | permissive | NOREADMEStudios/ProjectII | 8fda8acaee6a7bc9c6beb35f93c423f6efe2da4d | f57477090629f031f8e6735b797a29cefa164368 | refs/heads/develop2 | 2018-09-17T14:03:31.562953 | 2018-06-05T20:48:15 | 2018-06-05T20:48:15 | 120,901,510 | 2 | 0 | MIT | 2018-06-05T20:48:16 | 2018-02-09T12:12:02 | C | UTF-8 | C++ | false | false | 4,003 | cpp | ModuleCinematics.cpp | #include "ModuleCinematics.h"
#include "Cinematic.h"
#include "ModuleInput.h"
#include <sstream>
#include "ModuleRender.h"
#include "ModuleAudio.h"
#include "ModuleTextures.h"
ModuleCinematics::ModuleCinematics()
{
name = "cinematics";
}
ModuleCinematics::~ModuleCinematics()
{
}
bool ModuleCinematics::Awake(pugi::xml_node & config)
{
assetsPath = ASSETS_ROOT;
assetsPath.append(config.attribute("folder").as_string());
return true;
}
bool ModuleCinematics::Start()
{
PlayVideo("Intro_video.avi", 30);
return true;
}
bool ModuleCinematics::PreUpdate()
{
return true;
}
bool ModuleCinematics::Update(float dt)
{
if (currentCinematic != nullptr) {
if (!currentCinematic->Update(dt)) {
Utils::Release(currentCinematic);
currentCinematic = nullptr;
}
}
return true;
}
bool ModuleCinematics::PostUpdate()
{
if (videoPlaying) {
GetNextFrame();
}
else if (videoEnded) {
videoEnded = false;
App->audio->PlayMusic("Assets/Audio/BGM/Character_Selection.ogg");
}
return true;
}
bool ModuleCinematics::CleanUp(pugi::xml_node &)
{
if (currentCinematic != nullptr) {
Utils::Release(currentCinematic);
currentCinematic = nullptr;
}
return true;
}
void ModuleCinematics::StartCinematic(Cinematic * c)
{
currentCinematic = c;
}
float ModuleCinematics::GetCurrentCinematicTime()
{
if (currentCinematic != nullptr)
return currentCinematic->GetDuration();
else return 0.f;
}
float ModuleCinematics::GetCurrentCinematicTimeLeft()
{
if (currentCinematic != nullptr)
return currentCinematic->GetDurationLeft();
else return 0.f;
}
iPoint ModuleCinematics::GetInitialCameraPosition()
{
if (currentCinematic != nullptr)
return currentCinematic->GetCurrentTransition()->initialFrame->cameraPosition;
else return iPoint(-1, -1);
}
bool ModuleCinematics::PlayCurrentCinematic() //No use really
{
return false;
}
bool ModuleCinematics::PlayVideo(const char* path, int framerate)
{
std::stringstream _path;
_path << assetsPath.c_str() << path;
AVIFileInit();
long res = AVIStreamOpenFromFile(&videoStream, _path.str().c_str(), streamtypeVIDEO, 0, OF_READ, nullptr);
if (res != 0) {
LOG("Error opening video stream");
return false;
}
AVISTREAMINFO psi;
AVIStreamInfo(videoStream, &psi, sizeof(psi));
videoWidth = psi.rcFrame.right - psi.rcFrame.left;
videoHeight = psi.rcFrame.bottom - psi.rcFrame.top;
videoLastFrame = AVIStreamLength(videoStream);
videoTimeLength = AVIStreamLengthTime(videoStream);
videoFrame = AVIStreamGetFrameOpen(videoStream, (LPBITMAPINFOHEADER)AVIGETFRAMEF_BESTDISPLAYFMT);
if (videoFrame == nullptr) {
LOG("Could not read the stream");
return false;
}
App->SetFramerateCap(framerate, videoLastFrame);
videoPlaying = true;
return true;
}
void ModuleCinematics::GetNextFrame()
{
LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)AVIStreamGetFrame(videoFrame, videoCurrentFrame++);
void* pixelData = (char*)lpbi + lpbi->biSize + lpbi->biClrUsed * sizeof(RGBQUAD);
SDL_Surface* surf = SDL_CreateRGBSurfaceFrom(pixelData, videoWidth, videoHeight, lpbi->biBitCount, videoWidth * 3, 0, 0, 0, 0);
if (surf == nullptr) {
LOG("Error rendering video: %s", SDL_GetError());
}
else {
SDL_Texture* tex = SDL_CreateTextureFromSurface(App->render->renderer, surf);
if (tex == nullptr) {
LOG("Error rendering video: %s", SDL_GetError());
return;
}
else {
int posX = (DEFAULT_RESOLUTION_X / 2) - (videoWidth / 2);
int posY = (DEFAULT_RESOLUTION_Y / 2) - (videoHeight / 2);
App->render->DrawQuad({ 0, 0, DEFAULT_RESOLUTION_X, DEFAULT_RESOLUTION_Y }, 0x00, 0x00, 0x00, 0xFF, 0.0f, true, false);
App->render->Blit(tex, posX, posY, nullptr, 0.0f, 180.0, true);
}
SDL_DestroyTexture(tex);
}
SDL_FreeSurface(surf);
if (videoCurrentFrame >= videoLastFrame) {
videoPlaying = false;
videoEnded = true;
videoCurrentFrame = 0;
CloseVideo();
}
}
void ModuleCinematics::CloseVideo()
{
AVIStreamGetFrameClose(videoFrame);
AVIStreamRelease(videoStream);
AVIFileExit();
} |
65ba7df1425aade5d116360461ac295be248c5af | db44e833ea7cc30cbfa0dfd260787781e830a944 | /code/main.cpp | d88a9062766afafa6330677ff48b7716301b8dce | [] | no_license | leo304git/2020ICCAD-Routing-with-Cell-Movement | 786fd4fb9ac54e0788c0b5cc1b49226916196249 | d8866f849646def3d0766b74a7d95240ca16b8da | refs/heads/main | 2023-03-25T17:28:05.054887 | 2021-03-13T08:31:34 | 2021-03-13T08:31:34 | 347,315,144 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 436 | cpp | main.cpp | #include <iostream>
#include <fstream>
#include <string>
#include "parser.h"
using namespace std;
GgridMgr* ggridParser=new GgridMgr();
int main(int argc,char **argv)
{
if(!ggridParser->readFile(argv[1])){cerr<<"error reading file?"<<endl; return 0;}
ggridParser->placement(ggridParser->getCellInsts());
//new
ggridParser->routing();
ggridParser->write_file();
cout << "good!" << endl;
return 0;
}
|
e9ccdaff488f4c166a3bed9ed9e0d8868b01f0bd | 62edb10d67374cba59db11bf9164e53275e39196 | /SpartanEditor/GameApp.cpp | 805bedb975c7125ad6cc51794ec81193fcedf55e | [] | no_license | TheMadDodger/Spartan-Engine | fc4594c3b52855281fa199f62b4b3127538b5d3b | f71d02f726f92f565a46561bb663d2fe9feede11 | refs/heads/master | 2022-08-04T11:53:14.334216 | 2022-08-01T18:45:48 | 2022-08-01T18:45:48 | 129,151,641 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,831 | cpp | GameApp.cpp | #include "stdafx.h"
#include "GameApp.h"
#include <ContentManager.h>
#include <SceneManager.h>
#include "LevelEditor.h"
#include <ApplicationStructs.h>
#include <InputManager.h>
#include <SoundManager.h>
#include <Framework.h>
#include "ComponentParameters.h"
#include "EditorWindow.h"
#include "BehaviorTreeEditor.h"
#define BEGIN_BUILDPARAMS_FUNCTION(x) template <typename T> \
inline void x(ComponentParameters<T> *pParam)
BEGIN_BUILDPARAMS_FUNCTION(Transform)
{
auto pComp = dynamic_cast<TransformComponent*>(pParam->m_pComponent);
auto pParam1 = new ComponentParam<Vector2>("Position", pComp->Position, pComp->Position);
pParam->AddParam(pParam1);
auto pParam2 = new ComponentParam<Vector3>("Rotation", pComp->Rotation, pComp->Rotation);
pParam->AddParam(pParam2);
auto pParam3 = new ComponentParam<Vector2>("Scale", pComp->Scale, pComp->Scale);
pParam->AddParam(pParam3);
}
BEGIN_BUILDPARAMS_FUNCTION(Image)
{
//auto pComp = dynamic_cast<ImageRenderComponent*>(pParam->m_pComponent);
//auto pParam1 = new ComponentStringParam("File", pComp->m_AssetFile, pComp->m_AssetFile);
//pParam->AddParam(pParam1);
}
GameTool::GameTool(const GameSettings &settings) : BaseGame(settings), m_Buffer("")
{
}
GameTool::~GameTool()
{
ComponentParameterManager::Destroy();
SDL_DestroyTexture(m_pRenderTexture);
glDeleteFramebuffers(1, &m_FBO);
glDeleteTextures(1, &m_TextureID);
}
void GameTool::Initialize(const GameContext &gameContext)
{
// Init GLEW
glewInit();
auto settings = BaseGame::GetGame()->GetGameSettings();
/*m_pRenderTexture = SDL_CreateTexture(gameContext.pRenderer->GetSDLRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, settings.Window.Width, settings.Window.Height);
if (!m_pRenderTexture)
Utilities::Debug::Log("Error when creating a RenderTexture!", Utilities::LogLevel::Error);*/
/*glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
glGenFramebuffers(1, &m_FBO);
glGenTextures(1, &m_TextureID);
glBindTexture(GL_TEXTURE_2D, m_TextureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)settings.Window.Width, (GLsizei)settings.Window.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_TextureID, 0);
glGenRenderbuffers(1, &m_RenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, m_RenderBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, (GLsizei)settings.Window.Width, (GLsizei)settings.Window.Height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_RenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);*/
glGenTextures(1, (GLuint*)&m_TextureID);
glBindTexture(GL_TEXTURE_2D, (GLuint)m_TextureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)settings.Window.Width, (GLsizei)settings.Window.Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glGenFramebuffers(1, &m_FBO);
glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, (GLuint)m_FBO, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ComponentParameterManager::GetInstance()->Register(new ComponentParameters<TransformComponent>(Transform<TransformComponent>));
ComponentParameterManager::GetInstance()->Register(new ComponentParameters<ImageRenderComponent>(Image<ImageRenderComponent>));
SceneManager::GetInstance()->AddScene(new LevelEditor());
UNREFERENCED_PARAMETER(gameContext);
GLsizei w = (GLsizei)m_GameSettings.Window.Width;
GLsizei h = (GLsizei)m_GameSettings.Window.Height;
m_GameWindowWidth = w / 2.f;
m_GameWindowHeight = h / 2.f;
EditorWindow::GetWindow<BehaviorTreeEditor>();
}
void GameTool::GameUpdate(const GameContext &gameContext)
{
UNREFERENCED_PARAMETER(gameContext);
}
void GameTool::GamePaint(const GameContext &gameContext)
{
GLsizei w = (GLsizei)m_GameSettings.Window.Width;
GLsizei h = (GLsizei)m_GameSettings.Window.Height;
float aspect = (float)w / (float)h;
// Draw scenes
glBindFramebuffer(GL_FRAMEBUFFER, m_FBO);
glViewport(0, 0, w, h);
m_GameContext.pRenderer->ClearBackground();
glEnable(GL_TEXTURE_2D);
SceneManager::GetInstance()->Draw(m_GameContext);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
//gameContext.pRenderer->RenderTexture(m_TextureID, w, h);
ImGui::SetNextWindowSize(ImVec2(m_GameWindowWidth, m_GameWindowHeight), ImGuiSetCond_FirstUseEver);
ImGui::Begin("Game Window");
//glViewport(0, 0, m_GameSettings.Window.Width, m_GameSettings.Window.Height);
//SceneManager::GetInstance()->Draw(m_GameContext);
ImVec2 pos = ImGui::GetCursorScreenPos();
float width = ImGui::GetWindowWidth();
float height = width / aspect;
ImGui::GetWindowDrawList()->AddImage(
(void *)m_TextureID, ImVec2(pos.x,
pos.y),
ImVec2(pos.x + width, pos.y + height), ImVec2(0, 1), ImVec2(1, 0));
ImGui::End();
ImGui::ShowDemoWindow();
ContentManagerWindow();
EditorWindows();
/*ImGui::Begin("My Window");
ImGui::Text("Hello, World! %d", 123);
if (ImGui::Button("Save"))
{
// Do stuff
}
ImGui::InputText("string", m_Buffer, 10, IM_ARRAYSIZE(m_Buffer));
ImGui::SliderFloat("float", &m_Slider, 0.0f, 1.0f);
ImGui::End();*/
}
bool GameTool::RootInitialize()
{
// Init GLEW
glewInit();
// Initialize SDL
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
{
Utilities::Debug::LogError("SDL Could not initialize! SDL_Error: " + string(SDL_GetError()));
return false;
}
// Use OpenGL 3.0
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
// Initialize GameContext
m_GameContext.pRenderer = new Renderer();
m_GameContext.pRenderer->Initialize(m_GameContext);
m_GameContext.pTime = new GameTime();
m_GameContext.pTime->Start();
m_GameContext.pInput = new InputManager();
m_GameContext.pSound = new SoundManager();
m_GameContext.pSound->Initialize();
m_GameContext.pParticleManager = new ParticleManager();
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplSDL2_InitForOpenGL(m_GameContext.pRenderer->GetWindow(), m_GameContext.pRenderer->GetGLContext());
ImGui_ImplOpenGL2_Init();
io.Fonts->AddFontDefault();
//io.Fonts->AddFontFromFileTTF("./EditorResources/ProggyClean.ttf", 16.f);
//io.Fonts->AddFontFromFileTTF("./EditorResources/ProggyTiny.ttf", 12.f);
//io.Fonts->AddFontFromFileTTF("./EditorResources/Karla-Regular.ttf", 16.f);
io.Fonts->Build();
ImGui::StyleColorsDark();
// Initialize Content Manager
ContentManager::GetInstance()->Initialize();
// Initialize SDL_ttf
if (TTF_Init() < 0)
{
Utilities::Debug::LogError("SDL_ttf Could not initialize! TTF_Error: " + string(TTF_GetError()));
return false;
}
// Run user defined Initialize()
Initialize(m_GameContext);
// Initialise Scenes
SceneManager::GetInstance()->Initialize(m_GameContext);
return true;
}
bool GameTool::RootGameUpdate()
{
// If a quit was called break out
if (m_bQuitGame)
return false;
// Start the timer
m_GameContext.pTime->StartFrame();
// Update InputManager
m_GameContext.pInput->Update();
// Update audio
m_GameContext.pSound->Update();
// Tick ParticleManager
m_GameContext.pParticleManager->Tick(m_GameContext);
// Inside SDL events
SDL_Event windowEvent;
if (SDL_PollEvent(&windowEvent))
{
ImGui_ImplSDL2_ProcessEvent(&windowEvent);
switch (windowEvent.type)
{
case SDL_QUIT:
return false;
case SDL_KEYUP:
m_GameContext.pInput->KeyUp(&windowEvent.key);
break;
case SDL_KEYDOWN:
m_GameContext.pInput->KeyDown(&windowEvent.key);
break;
case SDL_MOUSEMOTION:
m_GameContext.pInput->HandleMouseMotionEvent(&windowEvent.motion, m_GameSettings.Window.Height);
break;
case SDL_MOUSEBUTTONDOWN:
m_GameContext.pInput->MouseDown(&windowEvent.button);
break;
case SDL_MOUSEBUTTONUP:
m_GameContext.pInput->MouseUp(&windowEvent.button);
break;
case SDL_MOUSEWHEEL:
m_GameContext.pInput->HandleMouseScrollEvent(&windowEvent.wheel);
break;
default:
break;
}
}
// Update Scenes
SceneManager::GetInstance()->Update(m_GameContext);
// Run user defined GameUpdate()
GameUpdate(m_GameContext);
// Update the timer
m_GameContext.pTime->Update();
// AutoLogger
Utilities::Debug::UpdateAutoLogger(m_GameContext.pTime);
return true;
}
void GameTool::RootGamePaint()
{
// Clear the background
m_GameContext.pRenderer->ClearBackground();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplOpenGL2_NewFrame();
ImGui_ImplSDL2_NewFrame(m_GameContext.pRenderer->GetWindow());
ImGui::NewFrame();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
// Run user defined GamePaint()
GamePaint(m_GameContext);
reinterpret_cast<LevelEditor*>(SceneManager::GetInstance()->GetCurrentScene())->RenderGUI();
ImGui::Render();
glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData());
// Paint Particles
m_GameContext.pParticleManager->Paint(m_GameContext);
// Update window
SDL_GL_SwapWindow(m_GameContext.pRenderer->m_pWindow);
// End the frame timer
m_GameContext.pTime->EndFrame();
}
void GameTool::ContentManagerWindow()
{
ImGui::SetNextWindowSize(ImVec2((float)m_GameSettings.Window.Width, 300.f));
ImGui::SetNextWindowPos(ImVec2(0.f, (float)m_GameSettings.Window.Height - 300.f));
ImGui::Begin("Content Manager");
ImGui::End();
}
void GameTool::EditorWindows()
{
for (auto pWindow : EditorWindow::m_pActiveEditorWindows)
pWindow->RenderGUI();
}
|
00335efb1c3295b592dfe09c6857336028b4a1e4 | 4d4f6f89166e544ca9fc25b2a6d271528866d412 | /Temperaturregler/SD.ino | 4238d94e3fe61236b26c99e02a7d2c78d1252448 | [] | no_license | GruberMartin/Temperaturregler | 765fec7fa65b32d49d97517a6263e4e3e16b004d | 716b192b526d0c59457ef084ed3305e9c5ad1571 | refs/heads/master | 2020-03-10T05:56:02.125108 | 2018-06-11T07:04:11 | 2018-06-11T07:04:11 | 129,228,135 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,560 | ino | SD.ino | #include "Dynamic_Parameter_determination.h"
#include <Arduino.h>
#include "Temperature.h"
#include "PI.h"
#include <SPI.h>
#include <SD.h>
#include "Display.h"
File myFile;
String filename;
boolean writingPiParamSuccessfully = false;
boolean readingPiParamSuccessfully = false;
boolean writingSeqParamSuccessfully = false;
boolean readingSeqParamSuccessfully = false;
boolean writingAgitatorParamSuccessfully = false;
boolean readingAgitatorParamSuccessfully = false;
boolean filesAvailable = false;
String fileContent;
String tmp;
int stringCounter = 1;
int numberOfFiles = 0;
int seqNowCount = 0;
int agiNowCount = 0;
const int sdChip = 53;
int getNumberOfFiles()
{
return numberOfFiles;
}
void savePIParameters()
{
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Schreiben auf SD-Karte fehlgeschlagen");
currentState = running_PI;
}
for (int i = 0; (i < 6) && (writingPiParamSuccessfully == false); i++)
{
filename = String(String(i) + ".txt");
if (!SD.exists(filename))
{
myFile = SD.open(filename, FILE_WRITE);
if (myFile) {
myFile.print(getKpr());
myFile.print(",");
myFile.print(getTn());
myFile.print(",");
myFile.print(getTm());
myFile.print(",");
myFile.print(getT());
myFile.print(",");
myFile.print(getN());
myFile.print(",");
/* myFile.print(getSeconds());
myFile.print(",");*/
myFile.print(getKps());
myFile.print(",");
myFile.print(getStartVoltage());
myFile.print(",");
/*myFile.print(",");
myFile.print(getSetPoint());*/
// close the file:
myFile.close();
writingPiParamSuccessfully = true;
currentState = running_PI;
}
}
}
if (writingPiParamSuccessfully == false)
{
setCurrentState(running_PI);
}
}
void saveSeqParameters()
{
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Schreiben auf SD-Karte fehlgeschlagen");
current_main_state = fastCookingModeTime;
}
for (int i = 0; (i < 6) && (writingSeqParamSuccessfully == false); i++)
{
filename = "seq" + String(String(i) + ".txt");
if (!SD.exists(filename))
{
myFile = SD.open(filename, FILE_WRITE);
if (myFile) {
for (int z = 0; z < 6; z++)
{
myFile.print(getStepTime(z));
myFile.print(", ");
myFile.print(getStepTemp(z));
myFile.print(", ");
}
myFile.close();
writingSeqParamSuccessfully = true;
//currentState = running_PI;
current_main_state = startWithGivenParameters;
}
}
}
if (writingSeqParamSuccessfully == false)
{
current_main_state = fastCookingModeTime;
Serial.println("Wrtiting to seq file failed");
}
}
void saveAgitatorParameters()
{
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Schreiben auf SD-Karte fehlgeschlagen");
//current_main_state = fastCookingModeTime;
}
for (int i = 0; (i < 6) && (writingAgitatorParamSuccessfully == false); i++)
{
filename = "ag" + String(String(i) + ".txt");
if (!SD.exists(filename))
{
myFile = SD.open(filename, FILE_WRITE);
if (myFile) {
for (int z = 0; z < 6; z++)
{
myFile.print((String)getAgitatorAns(z));
myFile.print(", ");
}
myFile.close();
writingAgitatorParamSuccessfully = true;
//current_main_state = startWithGivenParameters;
}
}
}
if (writingAgitatorParamSuccessfully == false)
{
Serial.println("Wrtiting to agiator file failed");
}
}
int countNumberOfPiFiles()
{
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Keine SD-Karte erkannt, countNumberOfPiFiles");
filesAvailable = false;
}
for (int i = 0; (i < 40); i++)
{
filename = String(String(i) + ".txt");
if (SD.exists(filename))
{
numberOfFiles = numberOfFiles + 1;
}
}
// Serial.print(numberOfFiles);
// Serial.println(" Files verfuegbar");
return numberOfFiles;
}
int countNumberOfSeqFiles()
{
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Keine SD-Karte erkannt, countNumberOfSeqFiles");
filesAvailable = false;
numberOfFiles = 0;
}
numberOfFiles = 0;
for (int i = 0; (i < 40); i++)
{
filename = "seq" + String(String(i) + ".txt");
if (SD.exists(filename))
{
numberOfFiles = numberOfFiles + 1;
}
}
// Serial.print(numberOfFiles);
// Serial.println(" Files verfuegbar");
return numberOfFiles;
}
void readFile(int fileNumber)
{
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Lesen von SD-Karte fehlgeschlagen");
}
filename = String(String(fileNumber) + ".txt");
if (SD.exists(filename))
{
myFile = SD.open(filename);
if (myFile) {
//Serial.println(filename + " :");
// read from the file until there's nothing else in it:
while (myFile.available()) {
//Serial.write();
tmp = (char)myFile.read();
if (tmp != ",")
{
fileContent = fileContent + tmp;
}
else
{
switch (stringCounter)
{
case 1:
setKpr(fileContent.toFloat());
break;
case 2:
setTn(fileContent.toFloat());
break;
case 3:
setTm(fileContent.toFloat());
break;
case 4:
setT(fileContent.toFloat());
break;
case 5:
setN(fileContent.toInt());
break;
case 6:
setKps(fileContent.toFloat());
break;
case 7:
//setStartVoltageIPart(fileContent.toFloat());
break;
default:
break;
}
fileContent = "";
stringCounter += 1;
}
}
// close the file:
readingPiParamSuccessfully = true;
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("Lesen von SD-Karte fehlgeschlagen");
}
}
}
void readSeqFile(int fileNumber)
{
stringCounter = 1;
fileContent = "";
tmp = "";
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Lesen von SD-Karte fehlgeschlagen");
}
filename = "seq" + String(String(fileNumber) + ".txt");
if (SD.exists(filename))
{
myFile = SD.open(filename);
if (myFile) {
//Serial.println(filename + " :");
// read from the file until there's nothing else in it:
while (myFile.available()) {
//Serial.write();
tmp = (char)myFile.read();
if (tmp != ",")
{
fileContent = fileContent + tmp;
}
else
{
switch (stringCounter)
{
case 1:
setStempTime(seqNowCount, fileContent.toInt());
break;
case 2:
setStepTemp(seqNowCount, fileContent.toFloat());
seqNowCount += 1;
break;
case 3:
setStempTime(seqNowCount, fileContent.toInt());
break;
case 4:
setStepTemp(seqNowCount, fileContent.toFloat());
seqNowCount += 1;
break;
case 5:
setStempTime(seqNowCount, fileContent.toInt());
break;
case 6:
setStepTemp(seqNowCount, fileContent.toFloat());
seqNowCount += 1;
break;
case 7:
setStempTime(seqNowCount, fileContent.toInt());
break;
case 8:
setStepTemp(seqNowCount, fileContent.toFloat());
seqNowCount += 1;
break;
case 9:
setStempTime(seqNowCount, fileContent.toInt());
break;
case 10:
setStepTemp(seqNowCount, fileContent.toFloat());
seqNowCount += 1;
break;
case 11:
setStempTime(seqNowCount, fileContent.toInt());
break;
case 12:
setStepTemp(seqNowCount, fileContent.toFloat());
seqNowCount += 1;
break;
default:
break;
}
fileContent = "";
stringCounter += 1;
}
}
// close the file:
readingSeqParamSuccessfully = true;
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("Lesen von SD-Karte fehlgeschlagen");
}
}
}
void readAgitatorFile(int fileNumber)
{
stringCounter = 1;
fileContent = "";
tmp = "";
pinMode(SS, OUTPUT);
if (!SD.begin(sdChip)) {
//Serial.println("Lesen von SD-Karte fehlgeschlagen");
}
filename = "ag" + String(String(fileNumber) + ".txt");
if (SD.exists(filename))
{
myFile = SD.open(filename);
if (myFile) {
while (myFile.available()) {
//Serial.write();
tmp = (char)myFile.read();
if (tmp != ",")
{
fileContent = fileContent + tmp;
}
else
{
switch (stringCounter)
{
case 1:
setAgitatorAns(agiNowCount, fileContent.toInt());
agiNowCount += 1;
break;
case 2:
setAgitatorAns(agiNowCount, fileContent.toInt());
agiNowCount += 1;
break;
case 3:
setAgitatorAns(agiNowCount, fileContent.toInt());
agiNowCount += 1;
break;
case 4:
setAgitatorAns(agiNowCount, fileContent.toInt());
agiNowCount += 1;
break;
case 5:
setAgitatorAns(agiNowCount, fileContent.toInt());
agiNowCount += 1;
break;
case 6:
setAgitatorAns(agiNowCount, fileContent.toInt());
agiNowCount += 1;
break;
default:
break;
}
fileContent = "";
stringCounter += 1;
}
}
// close the file:
readingAgitatorParamSuccessfully = true;
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("Lesen von Ruehrwerkparametern fehlgeschlagen");
}
}
}
|
49a3b36f31d3793baa24f64e56f26716fb54b1c9 | e769bb7386f31ee347accee1ccbb421dfd9c42d1 | /Logistics/ContainerState.cpp | ece01d163ad5b286a9db29a5b0f23428ba234852 | [] | no_license | neytjieb1/Software-Modelling | 5cf0bbdf5411b7b6006aa02113ee493fe077f65f | 907fc4dc2f1fac9b6b0ce62e840b17a7b6604a72 | refs/heads/master | 2023-02-07T18:53:14.187438 | 2020-10-23T04:30:22 | 2020-10-23T04:30:22 | 287,204,960 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 120 | cpp | ContainerState.cpp | //
// Created by jo-anne on 2020/10/22.
//
#include "ContainerState.h"
ContainerState::~ContainerState() = default;
|
52075f030c4f1515c09920b16b8dd972cce3b794 | 23e99fbd8a3b7fefa0aca71351fa19919b604045 | /src/tempfile.hpp | f62c742d8ec19f8c05b3e50164b35728114942ca | [
"MIT"
] | permissive | ekg/seqwish | 4f5869b4fb4ca6e6f98554e5f60aa12bbe5bad3b | f44b402f0c2e02988d431d9b2e5eba9727cf93a9 | refs/heads/master | 2023-06-25T12:55:08.782413 | 2023-06-13T12:57:17 | 2023-06-13T12:57:17 | 136,945,907 | 132 | 19 | MIT | 2023-06-13T12:37:03 | 2018-06-11T15:31:26 | C++ | UTF-8 | C++ | false | false | 939 | hpp | tempfile.hpp | #pragma once
#include <string>
#include <mutex>
#include <cstdio>
#include <dirent.h>
#include <cstring>
/**
* Temporary files. Create with create() and remove with remove(). All
* temporary files will be deleted when the program exits normally or with
* std::exit(). The files will be created in a directory determined from
* environment variables, though this can be overridden with set_dir().
* The interface is thread-safe.
*/
namespace temp_file {
/// Create a temporary file starting with the given base name
std::string create(const std::string& base, const std::string& suffix);
/// Remove a temporary file
void remove(const std::string& filename);
/// Set a temp dir, overriding system defaults and environment variables.
void set_dir(const std::string& new_temp_dir);
/// Get the current temp dir
std::string get_dir();
void set_keep_temp(bool setting);
} // namespace temp_file |
efc3355eb35fbf0f57f73ba1d3669cda57dd134e | 18d5b78a8a019322f01116a2b9a21b702d4c1608 | /spline_interpolation/main.cpp | c6ccb9de63aa7b7cd7e15a14cdff39a764618053 | [] | no_license | SanyaKor/Numerical_methods | d1bebfb65125859259120fa7bf662dac6da67f11 | cdcbb6a005f281313da037f566f111494df512ab | refs/heads/master | 2022-12-21T14:07:06.709845 | 2020-09-25T13:03:21 | 2020-09-25T13:03:21 | 297,024,177 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 194 | cpp | main.cpp |
#include "spline.h"
#include "plotter.h"
int main() {
spline s(4);
s.func_x(1.5);
plotter p(1000,500,100,10);
p.n_mnogochlen(s.y,s.b,s.c,s.d,s.x);
p.init();
return 0;
}
|
be3e6d523a718188f7e2431dd8cd96251c104835 | 177cc0eefc1f07173b22c31c3be44621022c7001 | /canscope/device/usb_port_device_delegate.h | e7da070d8c16e4dd2f006c3a41e237dd71f67389 | [] | no_license | lianliuwei/device_operate | 7cfbfe1572eaa37bc89cd9e23391b65a7c9e93a6 | 8c9d40f809917e35bc7fb05c54919ba5ad59880d | refs/heads/master | 2021-01-01T15:23:24.684622 | 2013-09-30T09:56:17 | 2013-09-30T09:56:17 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 591 | h | usb_port_device_delegate.h | #pragma once
#include "canscope/device/device_delegate.h"
#include "canscope/device/usb/usb_port.h"
namespace canscope {
class UsbPortDeviceDelegate : public DeviceDelegate {
public:
UsbPortDeviceDelegate();
virtual ~UsbPortDeviceDelegate();
// implement DeviceDelegate
virtual bool WriteDevice(uint32 addr, uint8* buffer, int size);
virtual bool ReadDevice(uint32 addr, uint8* buffer, int size);
virtual bool GetDeviceInfo(DeviceInfo* device_info);
UsbPort* usb_port_ptr() {
return &usb_port;
}
UsbPort usb_port;
};
} // namespace canscope
|
0507b810fd0e29a16f3b7bbd1dbfd122101d2e20 | cdddb70908194ce21d16052b336ebaf5e203b5ab | /atlas_io/src/atlas_io/detail/RecordInfo.h | 3d29e3abf9c9e118ea115c02bb4258d9570833e4 | [
"Apache-2.0"
] | permissive | ecmwf/atlas | 4e32fe8c5b70995b5b4df96b13a2741d093c40db | aaf527db8a18fafd4f61e93169676c6834821692 | refs/heads/develop | 2023-08-31T13:25:36.339542 | 2023-08-25T10:03:21 | 2023-08-25T10:03:21 | 122,975,745 | 94 | 39 | Apache-2.0 | 2023-08-30T15:35:53 | 2018-02-26T13:44:07 | C++ | UTF-8 | C++ | false | false | 728 | h | RecordInfo.h | /*
* (C) Copyright 2020 ECMWF.
*
* This software is licensed under the terms of the Apache Licence Version 2.0
* which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
* In applying this licence, ECMWF does not waive the privileges and immunities
* granted to it by virtue of its status as an intergovernmental organisation
* nor does it submit to any jurisdiction.
*/
#pragma once
#include "atlas_io/detail/Time.h"
#include "atlas_io/detail/Version.h"
namespace atlas {
namespace io {
struct RecordInfo {
Version version_;
Time created_;
const Version& version() const { return version_; }
const Time& created() const { return created_; }
};
} // namespace io
} // namespace atlas
|
3752ba55a2212181f7693a356ffa553424599cb6 | 9f520bcbde8a70e14d5870fd9a88c0989a8fcd61 | /pitzDaily/139/p | 1b6935dbf7d2f32a1091285f43fd7d04b28c4847 | [] | 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,189 | 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 "139";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
6400
(
0.148637754537
0.148639723569
0.148645253389
0.148655686439
0.148670341276
0.148688917627
0.148711565905
0.148739437663
0.148772334146
0.148809897771
0.148857281327
0.148917103489
0.148985635026
0.149063089196
0.149151446346
0.149252798627
0.149367406405
0.14949440545
0.149632744779
0.149778199441
0.149924242421
0.150070120557
0.150220651236
0.150381948193
0.150558646124
0.150750636488
0.150954359533
0.151167543841
0.151390455895
0.151624377238
0.151870499261
0.152127727082
0.152390196698
0.152652318631
0.152912881946
0.153167639669
0.153414836444
0.153664164178
0.153915162874
0.154154737334
0.154384443649
0.154622421453
0.154878565472
0.155144414573
0.1554122149
0.155677812298
0.155937931448
0.156191501651
0.156437845666
0.156676619296
0.156908722175
0.157129217565
0.157333076237
0.157512083207
0.157668223655
0.157814209593
0.157946623633
0.158052740822
0.158130096876
0.15818650504
0.158225832491
0.158248691662
0.158257960338
0.158252837163
0.158228599822
0.158171332863
0.158076220806
0.157959136303
0.157839984431
0.157726488484
0.157617950727
0.157510305585
0.157400783062
0.157295658215
0.15719476073
0.157102114216
0.157020881147
0.156965546003
0.156928850961
0.156913220047
0.148634743709
0.148636780615
0.148641607872
0.148651816361
0.148667947187
0.148688037696
0.14871124747
0.14873762045
0.148768767137
0.148806459325
0.14885353853
0.148911973959
0.14898076867
0.149059368384
0.149148228901
0.149248288798
0.14936227096
0.149490069728
0.149630386863
0.149777623901
0.149922036501
0.150065493554
0.150214923605
0.150375338919
0.150552146683
0.150745127411
0.1509488464
0.151162474176
0.151386497406
0.151621349846
0.151867130733
0.152124545354
0.152388511925
0.152650699132
0.152911911659
0.153167086029
0.153413584608
0.153663410857
0.153915326583
0.154153570788
0.154376851425
0.154612010398
0.154875153939
0.155145338365
0.155414841716
0.155682206536
0.155943644863
0.156198755407
0.156445785948
0.156681839846
0.156908310166
0.157129068409
0.157344595976
0.157526060982
0.157683326462
0.157834985296
0.157963668376
0.158063928048
0.158140826456
0.158197268306
0.15823533505
0.158259842396
0.15827027017
0.158265758495
0.158242571848
0.158186714476
0.158090414733
0.157970818911
0.157848944225
0.157732461016
0.157620946208
0.157509905842
0.157395784455
0.157284643993
0.157181095495
0.157087759516
0.15700975663
0.156953786128
0.156916912978
0.156904282188
0.14862653583
0.14863002216
0.148634112375
0.148643429458
0.148659126539
0.148682075503
0.148708064042
0.148733752755
0.148762960662
0.148799599672
0.148846040862
0.148903783155
0.148972679935
0.149051974604
0.149141122614
0.149237832665
0.14935004688
0.149485529694
0.149630124533
0.149776449839
0.149916446405
0.150052921388
0.150199956994
0.150363222579
0.150540470037
0.150732278608
0.150937322912
0.151153104125
0.151378832515
0.15161517242
0.151861731061
0.152119971736
0.152387216361
0.152648440614
0.152907416154
0.153166702326
0.153412172088
0.153658421203
0.153910769459
0.154151110411
0.154382262004
0.154622021242
0.154879211429
0.155145793307
0.155414546846
0.155681874192
0.155944917763
0.156201993963
0.156451439918
0.156691778816
0.156922840125
0.157143885759
0.157350490437
0.157536139609
0.157706881416
0.157859843247
0.157984957482
0.158084493722
0.158161617511
0.158218614523
0.158258380478
0.158283978914
0.158294604818
0.158293522304
0.158272886723
0.158216347806
0.158120634328
0.157999039518
0.157870249969
0.157745730625
0.157625864688
0.157506056962
0.157385955287
0.157270393025
0.157162101406
0.157065969538
0.156988092543
0.15693103689
0.15689455461
0.156880924352
0.148615630451
0.148619037198
0.148621943185
0.148630470246
0.148644266713
0.148667107537
0.148701885659
0.148727420363
0.148754299926
0.148789061042
0.148834580091
0.148891948028
0.148961142263
0.149039983273
0.149129812922
0.149233920604
0.149353031419
0.149486435565
0.149623885177
0.149757396856
0.14989102213
0.150030684223
0.150179790989
0.150342596602
0.150520660291
0.150714023736
0.150921272204
0.151139497581
0.151367831303
0.151605933848
0.151855252558
0.152115217475
0.152383685785
0.152651787577
0.152906582476
0.153159310421
0.153410910711
0.153654484804
0.153896941349
0.154138416613
0.154378459763
0.154624516367
0.154881983285
0.155147704849
0.155416634206
0.155685032687
0.155950002921
0.156209478516
0.156461738526
0.156705342999
0.156939256129
0.157161943747
0.157370571699
0.157562231216
0.157736751779
0.1578896213
0.158015948727
0.158116736441
0.158194986382
0.158253424754
0.158294734364
0.158320996422
0.158334103756
0.158338983523
0.158323005614
0.158269628572
0.15817162235
0.158042680216
0.157902405986
0.15776520352
0.157634546598
0.157506768221
0.157379392266
0.15725172632
0.157130721431
0.157029752373
0.156951816106
0.156888092562
0.156843238843
0.156824516164
0.148598849541
0.148598921984
0.148602548375
0.148611301309
0.148626640938
0.148648027518
0.148678987938
0.148708093758
0.148737340473
0.148773050513
0.148818057115
0.148875354884
0.148945541828
0.149030936191
0.149130010842
0.149236535059
0.149350987428
0.14947220967
0.149597495349
0.149727430778
0.149862431396
0.150002586531
0.150152288884
0.150316124504
0.15049543285
0.1506907988
0.150900148051
0.151121601262
0.151352959466
0.151594855347
0.151846444798
0.152111759305
0.152387509422
0.152649996107
0.152904211169
0.153153347809
0.153395744748
0.153637953768
0.153881578688
0.154126386042
0.154372679953
0.154624067038
0.154883649738
0.155150217737
0.15542034802
0.155690609699
0.155958076826
0.156220488661
0.156476069371
0.156723349578
0.156960953985
0.157187159289
0.157399731321
0.157596345324
0.157774509968
0.157929624164
0.158058334166
0.158161697575
0.158242690081
0.158304085303
0.158348335421
0.158377610598
0.158395021612
0.158406527446
0.158392317187
0.158342050418
0.158244571421
0.158107877553
0.157951920859
0.157796965358
0.157651772604
0.157511070936
0.157365046404
0.157215277941
0.157080526472
0.156971554256
0.156881515004
0.156797736078
0.156743340674
0.156723171943
0.148566927706
0.148566231541
0.148573405174
0.148582160806
0.148598990112
0.148622446269
0.148650344925
0.148680447659
0.148712921123
0.148750530028
0.148794441631
0.148852985053
0.148932906692
0.1490270213
0.149126567975
0.149228388825
0.149333605718
0.149445727621
0.149567264178
0.149696072828
0.149828327774
0.149967476884
0.150118201042
0.150283832414
0.150465100779
0.150661633703
0.150874670333
0.151099183162
0.151335321827
0.151580908381
0.151838881394
0.152107672856
0.152381840372
0.152651860056
0.152898357724
0.153135794273
0.153374881215
0.153617920453
0.153864244501
0.154113111072
0.154364769822
0.154621202636
0.1548841536
0.155153056368
0.155425494476
0.155698447769
0.155969055543
0.156234990159
0.156494486695
0.156746102652
0.15698837999
0.157219560556
0.157437470409
0.157639419401
0.15782186829
0.157980600821
0.158113409883
0.158221485454
0.158307441119
0.158373838283
0.158423033094
0.158458477212
0.158485232211
0.158499575662
0.158489964143
0.158440630729
0.15834133854
0.158196270894
0.158022243748
0.157845253139
0.157679004036
0.157512516691
0.157334438144
0.157159666785
0.157007372521
0.156880430667
0.156764045227
0.156658677938
0.156594387311
0.156566226182
0.148517775053
0.148521148995
0.148534472361
0.148547909244
0.148561722261
0.148584988364
0.148615019676
0.148646032305
0.148681116256
0.148720916388
0.148768808103
0.148830562244
0.148918814951
0.149013792635
0.14910994762
0.149203932311
0.149302562457
0.149413507029
0.149535068869
0.149658488663
0.149787326598
0.149926772617
0.150078408826
0.150244843149
0.150428016181
0.150630021571
0.150843602278
0.151073040947
0.151314179913
0.151568911784
0.151832711895
0.152101568071
0.152377261404
0.152637970901
0.152879324405
0.153111920489
0.153350378471
0.153595430174
0.153845105702
0.154098176873
0.154354865374
0.154616364274
0.154883570694
0.155156029702
0.155431858995
0.155708379489
0.155982851041
0.156253003733
0.156517170038
0.156773992033
0.15702200689
0.157259368161
0.157483657346
0.157691694059
0.157879606938
0.158043838717
0.158183031623
0.158298323382
0.158391657208
0.158464825447
0.158520772247
0.158565559082
0.158601848905
0.15862003551
0.158627245604
0.158581620271
0.158474255787
0.158314467863
0.158118734253
0.157913436079
0.157712085009
0.157503818327
0.157286875379
0.157083616752
0.156904662346
0.156744994212
0.156592448394
0.156466446271
0.156391422353
0.156354417454
0.148460361156
0.148467422783
0.148483567696
0.148504451396
0.148519869445
0.148542984832
0.14857225601
0.148604807953
0.148643392585
0.148681361916
0.148736208118
0.148810166489
0.148897227719
0.148990436752
0.14907982641
0.14916641685
0.149264887055
0.149378490326
0.149495184305
0.149613562969
0.14974002513
0.149879656986
0.150032545041
0.150201697848
0.150388257818
0.150593061179
0.150812491422
0.151040286974
0.151292028685
0.151560111292
0.151823573607
0.152087479783
0.152361439128
0.152613869316
0.152847811437
0.153082522821
0.153323159527
0.153570692384
0.153823811181
0.154081222918
0.154342946529
0.154609732482
0.15488195997
0.155159039996
0.155439301825
0.155720301447
0.155999461388
0.156274666453
0.156544406647
0.156807423533
0.157062243852
0.157306865507
0.157538532298
0.157753709849
0.15794864661
0.158120581853
0.158268753067
0.15839377587
0.158496070959
0.158576257345
0.158639119916
0.158693383558
0.158739791111
0.158774088421
0.158796373661
0.158774183598
0.158660265334
0.158475861881
0.158247126075
0.15799905994
0.157745986833
0.157484011089
0.15722390502
0.156983380129
0.156764377882
0.156557906659
0.156369096848
0.156220790076
0.156134960845
0.156094279855
0.148397921419
0.148407492323
0.148424243339
0.148441172907
0.148462103097
0.148492486076
0.148520968134
0.148554485329
0.148598876813
0.148641374889
0.148693617481
0.148776141071
0.148866064042
0.148954656497
0.149038202375
0.149124604171
0.149222936996
0.149334492676
0.149446822993
0.149562659953
0.149687492127
0.14982586142
0.149978305739
0.150148848834
0.150345688254
0.150551438325
0.150777052711
0.151015551898
0.151268515186
0.151535783552
0.151806520242
0.152079204019
0.152332594274
0.152574991434
0.152810868934
0.153049078011
0.153292889543
0.153543340241
0.153799995575
0.154061907494
0.154328909614
0.154601370093
0.154879323419
0.155162000856
0.155447728546
0.155734181083
0.156018981454
0.156300237332
0.156576605042
0.156846895122
0.157109589375
0.157362492314
0.157602539267
0.157826059848
0.158029730151
0.158211612608
0.158371116815
0.15850737821
0.158618063016
0.158703243633
0.158773833336
0.158845156053
0.158914673071
0.158970385189
0.159001340543
0.159003015344
0.158914176924
0.158693561385
0.158414888353
0.15810523149
0.157781603289
0.15745566418
0.157144623008
0.156854615834
0.156580301378
0.15631865715
0.156091818274
0.155920015574
0.155819027891
0.155775031952
0.14832971219
0.148341396618
0.14836099335
0.148377842847
0.148399761762
0.148431193879
0.148460444233
0.14849406069
0.148536768364
0.148593228921
0.148650274379
0.148732783792
0.148823636823
0.148907728145
0.148985724435
0.149075000419
0.149177812458
0.149283978109
0.149391128228
0.149505081429
0.14963004259
0.149768173781
0.149920565387
0.150089326106
0.150293782487
0.150509616654
0.1507286573
0.1509786988
0.151237284207
0.151510635395
0.151783037089
0.152050640167
0.152299245923
0.152532821331
0.15276974221
0.153011763046
0.153259237365
0.15351305134
0.153773401561
0.154039923405
0.154312500686
0.154591163805
0.154875590463
0.155164805481
0.155457060423
0.155750066563
0.156041628558
0.156330112653
0.156614327595
0.156893073411
0.157164717913
0.157426859133
0.157676213611
0.157909210561
0.158123174727
0.158316858261
0.15848900379
0.15863517087
0.158748354333
0.158834915272
0.158922538936
0.159030581376
0.159141148791
0.159227211256
0.159269437944
0.15926074908
0.159182901969
0.158987690028
0.158632245271
0.158231559645
0.157818777929
0.157419013213
0.157045255219
0.15669198781
0.156347848319
0.156021452487
0.155746237932
0.155541567731
0.155413088497
0.15535568107
0.148252907605
0.14826449182
0.148285422229
0.148307104125
0.148335707956
0.148361484897
0.148390589214
0.148425958215
0.148461846474
0.148524503083
0.148593629737
0.148676744886
0.148767940313
0.148850917602
0.148927854005
0.149017225607
0.149121971268
0.149224727372
0.149328167109
0.149439398003
0.149564514516
0.149704383
0.149861704771
0.150030397457
0.150227591411
0.150461344608
0.150690228993
0.150939056909
0.151198485488
0.151461264733
0.15174455237
0.152011917573
0.152253575894
0.152485365338
0.152724680648
0.152970437326
0.153221854909
0.153479515974
0.153743855355
0.154015060258
0.154293434414
0.154578852927
0.154870562161
0.155167302085
0.155467210672
0.155768022831
0.156067716999
0.156364872793
0.156658365407
0.156946878291
0.157228563756
0.157500769183
0.157760124623
0.158003414603
0.158228753442
0.158435121142
0.158618257199
0.158764636815
0.158868733722
0.158963490318
0.159093730849
0.159271141254
0.159447404138
0.159578614603
0.159632139251
0.159591195984
0.15946322316
0.159265811887
0.158906731352
0.158387285441
0.157858241931
0.157369065686
0.156920025508
0.156491923014
0.156063145502
0.15564818064
0.155299781863
0.155041293458
0.154870984754
0.154790861693
0.148165613766
0.148174745233
0.1481900689
0.148218260248
0.148256537858
0.148280948667
0.148310186316
0.148349735813
0.148384278913
0.14844333864
0.148521738284
0.148607419213
0.148697916928
0.14878129667
0.148863873502
0.148955139264
0.149057941343
0.149157211747
0.149258275372
0.149366963327
0.149489191162
0.149626825032
0.149793963023
0.149976222981
0.150167194307
0.15040115536
0.150639531037
0.15088247811
0.151157374574
0.151427000115
0.151697970408
0.151953198378
0.152192159143
0.152431169842
0.15267474395
0.152924486005
0.153180201768
0.153442257611
0.153711118269
0.153987166245
0.154271375277
0.154564020614
0.154863916219
0.155169253654
0.155478041781
0.155788118271
0.156097631324
0.156405264068
0.156709792803
0.157009608017
0.157302444552
0.157585310884
0.157854931778
0.158108786818
0.158345684521
0.158562884087
0.158746046492
0.158873487249
0.158966630796
0.159095215933
0.15931437494
0.159607097692
0.159881199301
0.160080471582
0.160149429821
0.160063631489
0.159839200046
0.159540273206
0.159137824212
0.158544930922
0.157894358777
0.157297055833
0.156761920047
0.156257799471
0.155723627877
0.155167093283
0.154703902651
0.154373590696
0.154161331766
0.154066353639
0.148067499382
0.148074078805
0.148081106522
0.148113269566
0.148151382862
0.14818186749
0.148214213036
0.148258504548
0.148298821726
0.148356208551
0.148438548843
0.148525577256
0.148614487083
0.148694979903
0.148784831503
0.148884832046
0.148984930202
0.149081185825
0.1491808382
0.149288497169
0.149407590933
0.149539392519
0.149704740714
0.149911014699
0.150109137861
0.150327895795
0.150582067785
0.150832069805
0.151094720667
0.151369839286
0.151639881061
0.151889155668
0.152126007154
0.152370039462
0.152618876245
0.152873319839
0.153133626944
0.153400299808
0.153674387069
0.153956075147
0.154246321413
0.154546296978
0.15485507539
0.155170210502
0.155489300133
0.155810350776
0.156131760627
0.156452177836
0.156770007449
0.157083026552
0.157388229213
0.157682062747
0.157961671454
0.158225317623
0.158471773433
0.158690609847
0.158851647631
0.158945916277
0.15903665956
0.15924988157
0.159629742962
0.160098543696
0.160512328003
0.160829931794
0.160931226381
0.160762344695
0.160372641432
0.159869089064
0.159312547186
0.158629215224
0.157886703708
0.157182720892
0.156559551203
0.156013527215
0.155351850759
0.154536105681
0.153891005712
0.153491527016
0.153247219708
0.153161301331
0.147959490214
0.147967164307
0.14797928581
0.148000766354
0.148033765237
0.1480681068
0.148104433848
0.148150896497
0.148201222007
0.148259319629
0.148344163622
0.148432088556
0.148520308662
0.148599225141
0.148688986428
0.14879703461
0.148898863292
0.148995229213
0.149094715381
0.149202383373
0.14932033629
0.149447987432
0.149608415327
0.149825645232
0.150039785131
0.150255725891
0.150515391295
0.150773675357
0.151030186296
0.151303642135
0.151560567902
0.151805143178
0.15205104376
0.152301633693
0.152556204599
0.152815932717
0.153081814225
0.153353617649
0.153632688547
0.153920545977
0.154217818712
0.154525570645
0.154843610299
0.155169498853
0.155500429499
0.155834504183
0.1561704041
0.156506565853
0.156840666845
0.157169472773
0.157488560931
0.157793604459
0.158082167109
0.158353218816
0.158604242409
0.158802965024
0.158910248808
0.158960351859
0.159052711972
0.159492532006
0.16011272354
0.160848435278
0.161433366314
0.161962853336
0.162026480839
0.161642167369
0.160964389269
0.160146648839
0.159355728607
0.15860251498
0.15776210014
0.156978568875
0.15629870648
0.155845236765
0.155064232173
0.153670897455
0.152731633383
0.152332759084
0.152054894786
0.152032944416
0.147838418971
0.147846953489
0.147868111377
0.147880170152
0.147906833035
0.147942262862
0.147981796353
0.148032000031
0.14809477477
0.14815276159
0.148238444915
0.148327311263
0.148415881283
0.148496310197
0.148586783336
0.148697701582
0.148801420237
0.148899482082
0.148999945307
0.14910784148
0.149225706016
0.149352816921
0.149505715387
0.149717950557
0.149958334907
0.150182974728
0.150428918736
0.15070791199
0.150974026681
0.15122349108
0.151470537172
0.151716786003
0.151968447828
0.152225205812
0.152486180743
0.152751972926
0.153023333575
0.15330118318
0.153586143291
0.15387994618
0.154184650394
0.154501093806
0.154829054696
0.155166422815
0.155510551759
0.155859902027
0.156213408904
0.156569230481
0.156923862985
0.157271898694
0.157607075963
0.157924185868
0.158220080939
0.158492697265
0.158735998741
0.158861146788
0.158888223305
0.158938988244
0.159195817164
0.160018792692
0.160887642802
0.161945096442
0.162265298406
0.162369160015
0.162480225705
0.162288415595
0.161571041494
0.160512607159
0.159376073887
0.158269043125
0.157458758371
0.156681983645
0.155681600794
0.155890875744
0.155091553995
0.152401141004
0.151005819577
0.150858655321
0.150441114506
0.150674597702
0.147701703418
0.147709226479
0.147727855817
0.14774193654
0.147765885618
0.147802879099
0.147843866944
0.147893186315
0.147968072711
0.148034369576
0.148120035016
0.148210478882
0.14830066417
0.148385123572
0.148478008475
0.148589517689
0.148694416893
0.148794846722
0.148896973994
0.149005509774
0.149123177557
0.149251053732
0.149399925632
0.149604141288
0.14985966058
0.150100654628
0.150337467293
0.15060873011
0.150886046318
0.151138186657
0.151378230612
0.151623488008
0.151879080301
0.152141939669
0.152409238636
0.152680802512
0.152958146208
0.153241893734
0.15353340856
0.153833916443
0.154146097841
0.154471748448
0.154810540438
0.155160108353
0.155518175628
0.155884837759
0.156260297753
0.156641696455
0.157021959015
0.157392987104
0.157748681974
0.158081444009
0.158383675635
0.158649650933
0.158871773814
0.158831299602
0.158846159483
0.158955807034
0.1597226143
0.161045099532
0.16115113813
0.161526558986
0.1620299792
0.162200158493
0.162123621512
0.161728751078
0.160966070591
0.159993495879
0.158984071362
0.158020436413
0.157178535086
0.156491763381
0.156506962644
0.158148526412
0.158130235655
0.149380401438
0.147008503203
0.148917433982
0.148102271384
0.149273884767
0.147551688427
0.147558151312
0.14757686115
0.14759069597
0.147614250587
0.147651553964
0.147693467257
0.147739153256
0.147814669156
0.147895156443
0.147985761756
0.148079286743
0.148172514905
0.148264658069
0.14836032814
0.148472044477
0.148578079643
0.148681608725
0.148785929628
0.148895633355
0.149013432696
0.149141147524
0.149287362724
0.149482736417
0.149737007757
0.150006156702
0.150250985702
0.150508236403
0.15077840461
0.151028148977
0.151267532662
0.151519018231
0.151780780643
0.152049937871
0.152324005922
0.152602319781
0.152885630645
0.153175697094
0.153473693202
0.153781509223
0.15410151284
0.154436100708
0.154786253924
0.155149447461
0.155522624558
0.155908317691
0.156309826452
0.156722996515
0.157135377116
0.157536343254
0.157921833198
0.158279609321
0.158585337218
0.158801343337
0.158876523095
0.158773126467
0.1587979314
0.159183325637
0.15986005044
0.16053447918
0.161175709348
0.161387984134
0.161633183171
0.16168044078
0.161478533841
0.16102129195
0.160304168052
0.159398525283
0.158408574876
0.157427707806
0.156503708563
0.155717013083
0.155200079774
0.154776026732
0.151865283591
0.148947273743
0.150523361386
0.151327635758
0.143022839645
0.148205471418
0.147390442754
0.147395389635
0.147409819836
0.147425064831
0.147452687329
0.147489862506
0.147534043964
0.147578079222
0.147651939055
0.147740833494
0.147835790662
0.147931841838
0.148026539866
0.148128961936
0.148230952035
0.148342622182
0.148450368154
0.148558668918
0.148666041502
0.14877755621
0.148896046796
0.149023263768
0.149167281746
0.149355819651
0.149606038436
0.149892333167
0.150155589448
0.150407159942
0.150662960436
0.150906055408
0.15114737188
0.151403736732
0.151671343016
0.15194637797
0.152227431475
0.15251399989
0.152805068546
0.153101425712
0.153406551545
0.153721586802
0.154049548412
0.154394109295
0.154756307792
0.15513352082
0.155519827349
0.155923979494
0.156362988161
0.156828099282
0.1572815835
0.157719333319
0.158151533323
0.158561786705
0.158902474593
0.159089849883
0.158847280994
0.15865807606
0.158614229454
0.158969694021
0.159815772686
0.160275107225
0.160665187917
0.160841512096
0.160919535924
0.16082998623
0.160514236367
0.159963706328
0.159189255026
0.158237738809
0.157182150608
0.156096459986
0.155010667097
0.153919348634
0.15281203722
0.151557071335
0.149662216427
0.147962394675
0.147409089949
0.145345412312
0.147017418343
0.154747887127
0.1472202444
0.147224000795
0.147233464922
0.147250553993
0.147281817634
0.14731827333
0.14736387556
0.147410743062
0.147480391533
0.147573463338
0.147671072738
0.147768625007
0.147862731108
0.147969627406
0.14808361597
0.148197831198
0.148307849638
0.148421688071
0.148534826603
0.148649653487
0.148770152705
0.148896604921
0.149038782322
0.149221521316
0.149462566074
0.149745232103
0.150029763347
0.150290331727
0.150541416301
0.150780962527
0.151019107731
0.151278558706
0.151551987513
0.151829625598
0.152119185538
0.15241491495
0.152712638848
0.153016746293
0.153330073023
0.153654329009
0.153990879788
0.154343883866
0.154716781158
0.155111923374
0.155530126291
0.15597640624
0.156457333896
0.156954759421
0.157449456758
0.157957872376
0.158489508605
0.159051351436
0.159570847085
0.159984926181
0.159648982896
0.158257935095
0.158191141954
0.158778304022
0.159449368608
0.159808525505
0.160017907588
0.160078689835
0.15998842233
0.159724622514
0.159257402426
0.158579143592
0.157701340966
0.156654952316
0.155484778159
0.154233808906
0.152930730689
0.151515173961
0.14993870419
0.148180787278
0.146097109295
0.143807223763
0.142043939049
0.140944339988
0.142943364731
0.134322471597
0.147041537084
0.147044871597
0.147052697593
0.147072940607
0.147103889906
0.147137786109
0.147180490698
0.147232495665
0.147297747332
0.147392382795
0.14749190713
0.147590950748
0.147685812224
0.147792451092
0.147916334079
0.148036486987
0.148150516386
0.14826869854
0.148388297153
0.148508914416
0.148634164676
0.148760620268
0.148901011484
0.149079573417
0.149311776128
0.149587535792
0.149879814689
0.150152942954
0.150396298439
0.150632224134
0.15087725753
0.151136455538
0.151413548998
0.151699211549
0.151997839059
0.152301714132
0.152606967722
0.152919627093
0.15324195511
0.153575987647
0.153923123205
0.154287142068
0.154677652637
0.155106652169
0.155572433561
0.15605526518
0.156558872049
0.157087590169
0.157655283992
0.158287733284
0.159015739588
0.159917710979
0.160868945665
0.16258952658
0.162005693461
0.158786008018
0.157762506083
0.1585612324
0.15910315335
0.159231287815
0.159205974915
0.159066512052
0.158780516753
0.158325634131
0.157683917972
0.156847255121
0.155820248582
0.154619065135
0.153266605423
0.151782772742
0.15017734432
0.14838274562
0.146282133792
0.143820892296
0.14089899088
0.137480585519
0.133778657742
0.129299097134
0.123967698757
0.116496585674
0.146851733687
0.146854965113
0.146863201767
0.146888136186
0.146917976149
0.146948913525
0.146986516097
0.147042014596
0.147101666124
0.147196147005
0.147297680219
0.14739845022
0.147495256213
0.147603470955
0.147732427588
0.147858797288
0.147978496536
0.148101554987
0.148225894932
0.148352686882
0.148485230122
0.148613859782
0.148752248137
0.148927744309
0.149152432081
0.149420163524
0.149713553149
0.149992916319
0.150244867732
0.150477028299
0.150726256397
0.150989840301
0.151264998859
0.151548291036
0.151851725334
0.152169486771
0.152486389809
0.152809650502
0.15314086455
0.153484662941
0.153844540074
0.154224356303
0.154643962025
0.155119806745
0.155621124047
0.15612642729
0.156657268256
0.157250445556
0.157944345481
0.158742421991
0.159685367377
0.160967553462
0.161360749956
0.16152552755
0.161599918976
0.160597910791
0.158985463071
0.158707002738
0.158695864482
0.15851666843
0.158228982082
0.157850572367
0.157343921756
0.156679013931
0.15583740661
0.154808362004
0.153588721686
0.152181320781
0.150590388071
0.148813810546
0.146832853725
0.144604168199
0.141943233035
0.138658610678
0.134606123388
0.129486463243
0.122709419246
0.112467660435
0.0946224926823
0.0532783854742
0.146645389631
0.146648335916
0.146658716407
0.146689530528
0.146718737914
0.146747506897
0.146782417157
0.146837787415
0.146891695251
0.146983870194
0.147087346195
0.147189935211
0.147288903834
0.147398758413
0.147530672231
0.147662710995
0.147790319905
0.147918995655
0.148047053423
0.148179145373
0.148320146709
0.148454100832
0.148590217191
0.148762845081
0.148981981365
0.149240734143
0.149528877911
0.149802996879
0.150068030532
0.150312998596
0.150560554447
0.150821354124
0.151102767557
0.15139524848
0.151692803928
0.152014563392
0.152345296688
0.152680836942
0.153025730451
0.153380655131
0.15375180712
0.154157101514
0.154624410461
0.155142909041
0.155664727497
0.156195197917
0.15678915474
0.157509060658
0.158366779468
0.159261885209
0.160095277388
0.160731987443
0.161056261416
0.161227208887
0.161008088779
0.160150032039
0.158987144373
0.158359982315
0.157996328616
0.157575955772
0.157054565421
0.15643536483
0.155693251221
0.154799967493
0.153735108302
0.152483974689
0.151035562759
0.149380360964
0.147506074425
0.145390895553
0.142994350929
0.14024882523
0.136996174784
0.132915892762
0.127685957879
0.120850760981
0.111442167531
0.097366898774
0.0746811710128
0.0378467124571
0.146414898893
0.14641760957
0.146429966447
0.146466470861
0.146494707357
0.146524804992
0.146558815774
0.146611257368
0.146662391854
0.146753919944
0.146859644546
0.146964034482
0.147065140879
0.147176173164
0.147309168442
0.147444554355
0.147582143184
0.147717861456
0.147849816484
0.147986497764
0.148134913945
0.148278378474
0.148413594982
0.148582080234
0.148797608221
0.14904871416
0.149329829751
0.149597057772
0.149859586725
0.150122518711
0.150385158043
0.150646449966
0.150914219453
0.151209382978
0.151520653323
0.151844668963
0.15218405899
0.152531212852
0.152888974353
0.153258473479
0.153650523727
0.154097254722
0.154615663293
0.155161317787
0.155710167443
0.156299763866
0.157008350768
0.157884328213
0.158825729001
0.159537812298
0.160182301863
0.160417250733
0.160611566529
0.160588035443
0.160247470413
0.159544511127
0.158629115778
0.157829337176
0.15715622788
0.156465125843
0.155693007795
0.154823794007
0.153835342703
0.152700818711
0.151396825725
0.149903398452
0.148201610602
0.146270747387
0.144084058888
0.141602451369
0.138765836575
0.135481373332
0.13161205618
0.126844189116
0.120678786996
0.112568049106
0.101656209433
0.0863993317995
0.0641023506246
0.0338383808753
0.146153631269
0.146158321251
0.146171187635
0.146206745882
0.146237803245
0.146274707428
0.146311643056
0.146363768823
0.146419238822
0.146505651098
0.146613085591
0.146719289012
0.146822600112
0.146934565911
0.147067376692
0.147202436399
0.147345771585
0.147492179505
0.147630918779
0.147773455757
0.147927033418
0.148082685785
0.148225837812
0.148385127697
0.148597773095
0.148843380849
0.149117517097
0.149379882839
0.14963562767
0.149905750879
0.150183740252
0.150459246866
0.150725591883
0.151010179905
0.15131997661
0.151653404722
0.15200306567
0.152363211426
0.15273174233
0.153118164031
0.153547209056
0.154048858269
0.154605693991
0.155179994588
0.155777876258
0.156457996482
0.157276884012
0.158090605843
0.158933031474
0.159775802841
0.159985930586
0.160065224888
0.16005917465
0.159875283938
0.159437314457
0.158731636988
0.157841628913
0.156923204464
0.156028505576
0.155104014452
0.154101509355
0.152997363319
0.151770124579
0.150394980307
0.148847106221
0.14710221826
0.145134598118
0.142914139065
0.140402190475
0.137545624013
0.134268643413
0.130461634382
0.12596504225
0.120554089341
0.113770055866
0.104933773652
0.0932386463801
0.0776514990702
0.0562786113297
0.0296178102295
0.145866261346
0.145874760999
0.145887341339
0.145915557311
0.145953006493
0.145996876063
0.146039621172
0.146095814481
0.146160971351
0.146241133821
0.146347185834
0.146454462441
0.146560090099
0.146673234269
0.146806093202
0.146941528728
0.147084648796
0.147240254439
0.147388913274
0.147539583159
0.147698433887
0.147865729029
0.148026796312
0.148188301449
0.148386542819
0.148626245925
0.14889412361
0.149152919949
0.149401030372
0.149669778762
0.14995411857
0.150249800005
0.15052636468
0.150803650089
0.151104899258
0.151436849789
0.151794008356
0.15216911245
0.15255376031
0.152969166338
0.153450300878
0.154003522133
0.154595334685
0.15520591861
0.155864054685
0.156605608332
0.157287522922
0.157975630696
0.159138837644
0.159541717381
0.159578452424
0.159527148371
0.159372215355
0.159037689937
0.158482005055
0.157707439525
0.15676552965
0.155736664434
0.154662686504
0.153529790557
0.152309925351
0.150981225269
0.149522965279
0.147911490114
0.14612094017
0.144123496197
0.141887812271
0.139376249036
0.136540955039
0.133318417738
0.129622047226
0.125332197623
0.120282719198
0.114242259316
0.106898065171
0.0977134564411
0.08590708557
0.0705451285282
0.0503186180153
0.026110414162
0.145566429958
0.145575583256
0.145586878995
0.14560674466
0.145647997895
0.145694554219
0.145741383031
0.145799595067
0.145871382497
0.145953290329
0.146059541996
0.146168066709
0.146276301983
0.146390898255
0.146524255341
0.146661677946
0.146806310214
0.146968177167
0.147126834549
0.147289508723
0.147457440972
0.147633192955
0.147806745417
0.147984925736
0.148184113087
0.148412883015
0.148666789077
0.148921264317
0.149160413894
0.149422342107
0.149706147681
0.15000735724
0.150304972363
0.150588142446
0.150886639221
0.151208353482
0.151560994123
0.151945298395
0.152356923466
0.152815321584
0.153354284988
0.153955114126
0.154583316634
0.155231250457
0.155899919392
0.156524413167
0.157119798754
0.157646252403
0.158646462918
0.158928090831
0.158969237725
0.158836614187
0.158538069991
0.158055913463
0.157372813541
0.15649573125
0.155458435192
0.154306930405
0.153070573088
0.151749618398
0.150328883812
0.148790287547
0.147114008706
0.145276862799
0.143252123103
0.141009313699
0.138512851691
0.135719578269
0.132575217453
0.129009547453
0.124929963044
0.120213041838
0.114693589117
0.108150621984
0.100289533827
0.0907256766232
0.0789263288671
0.0641287315539
0.0453058529541
0.0232415902393
0.145258731132
0.145266237153
0.145275433452
0.145293084265
0.145329720024
0.145374316345
0.145422385738
0.145479743543
0.145553945029
0.145639895925
0.145748712153
0.145858909164
0.145969945275
0.146086038607
0.146219929043
0.146359466001
0.146505990578
0.146673021724
0.146840382695
0.147014243792
0.147197340883
0.14738216524
0.14756766085
0.14775079377
0.147958323958
0.148195176207
0.148446373447
0.148688851835
0.148917042629
0.149169304129
0.149450028108
0.149745502375
0.150050899728
0.15034460385
0.150647373283
0.150970346512
0.151315389714
0.151701537392
0.15214263058
0.152655106589
0.1532512291
0.153897749323
0.154558026302
0.155191865456
0.155810887041
0.156426716997
0.156990739861
0.157989234841
0.157914031496
0.158246010906
0.158277108686
0.158015948193
0.157562907642
0.156930121911
0.156110107301
0.155110821399
0.153955829591
0.15267385563
0.151284699379
0.149791793332
0.148186196428
0.146452942802
0.144573184672
0.142523938404
0.140277778595
0.137802371058
0.135059240341
0.132001624273
0.128571401152
0.124694971507
0.120277912737
0.115198198308
0.109297777718
0.102372364179
0.0941594644343
0.0843249457457
0.0724454003945
0.058065030374
0.0404365010419
0.0203832530046
0.144937035188
0.144946529688
0.144952108333
0.14497360247
0.145002132056
0.145041793874
0.145088344578
0.145143798953
0.145218121647
0.145303712588
0.145415080957
0.145526752495
0.145639678944
0.145757312851
0.145892208664
0.14603273774
0.146179539408
0.146351263459
0.146526397017
0.146707251899
0.146902019693
0.147094882015
0.147297537617
0.147495102671
0.147701113807
0.147942732836
0.148209323781
0.148451887897
0.148670861237
0.148909741211
0.149189927157
0.149485236373
0.149787311875
0.150084333123
0.150386242327
0.150709336639
0.151051825067
0.151441617286
0.151911880993
0.152481477715
0.153132053446
0.153814252192
0.154455062232
0.155069267418
0.155716084394
0.15638959144
0.157706073481
0.15778220505
0.157663166546
0.157646442908
0.157475947293
0.157064976193
0.156455709764
0.155667522069
0.154703211789
0.153571215437
0.152288112302
0.15087250678
0.149337315854
0.147685250348
0.145909586634
0.143997051687
0.141929432299
0.139683781531
0.137232162676
0.134541093105
0.131570423127
0.128271506656
0.124584623465
0.120435600262
0.115731558981
0.110355747467
0.104161482574
0.096965420907
0.0885406709421
0.0786113119455
0.0668478653603
0.0528962819232
0.0362071646239
0.0179110688018
0.144592327722
0.144602680874
0.144610197084
0.144633115513
0.144659644789
0.144696254552
0.144740284002
0.144793328586
0.144865477955
0.1449472419
0.145059636902
0.14517283248
0.145285425269
0.145404804944
0.145542207478
0.145683845708
0.145829222286
0.146001719813
0.146183966156
0.146368791991
0.146571834579
0.146774878926
0.146985063002
0.1472070218
0.147428287207
0.147674299444
0.14795481204
0.148212765892
0.14842354379
0.148647302419
0.148916643997
0.149214075863
0.149521840327
0.149824433396
0.150121521101
0.150439856548
0.150776602567
0.151166829944
0.151664109975
0.152287362613
0.152984518007
0.153650638805
0.154268027363
0.154887106734
0.155525549915
0.156019907926
0.157256346786
0.157271820032
0.157114679201
0.156904864734
0.156544696876
0.155978300396
0.155214994827
0.154273116888
0.153163352614
0.151895400655
0.15048136031
0.148933314702
0.14725908188
0.14545937659
0.143527582325
0.141450936745
0.139211465385
0.136786200409
0.13414695277
0.131259751238
0.128083844374
0.124570169392
0.120659252846
0.116278533716
0.111339115304
0.105732012317
0.0993240751872
0.09195399084
0.0834290925871
0.0735247639953
0.0619856800529
0.0485608131752
0.0328359317728
0.0160873363585
0.144224109217
0.144231440636
0.144245877556
0.144269185042
0.144297794783
0.144334470625
0.144376559251
0.144427442151
0.144496633057
0.144572453972
0.144683597385
0.144799274534
0.144910194363
0.145028656117
0.145170418524
0.145315170504
0.145460589517
0.145628110899
0.14581230242
0.146001352922
0.146208359992
0.146425715321
0.146651942367
0.146885342159
0.147126236496
0.147381509714
0.147674337897
0.14796348203
0.148180721087
0.148389727634
0.148637962935
0.148929685789
0.149240921165
0.149557197264
0.149858085058
0.150167784012
0.150497107571
0.150880168994
0.151397842022
0.152071132905
0.152795231039
0.153426462122
0.154034860982
0.154708649667
0.155396275094
0.156750631438
0.156409410317
0.15656551388
0.156439454991
0.156061177165
0.155508198041
0.154771753794
0.153850515157
0.152757424562
0.151504830591
0.150102558838
0.148559606933
0.146883482672
0.145078024473
0.143141653787
0.141066908783
0.138840840168
0.136445451585
0.133857796888
0.131049742957
0.1279874398
0.124630453688
0.120930508528
0.116829818912
0.112259027541
0.1071348038
0.101357228935
0.0948072205189
0.0873444764787
0.0788066739043
0.0690117208271
0.0577612859848
0.0448788632632
0.0300316459169
0.01454365463
0.143838710141
0.143845015385
0.143861399153
0.1438850786
0.143916014597
0.143954166513
0.143995023346
0.14404442658
0.144112014773
0.144181989818
0.144288787943
0.144407424729
0.144518534154
0.144631983949
0.144775920284
0.144924981233
0.14507269012
0.145234935202
0.145415111124
0.145604836558
0.145815439023
0.146034010255
0.146278320235
0.146528683132
0.146789523859
0.147058190346
0.147361548029
0.147684043802
0.147934123873
0.148140988402
0.148371873122
0.148640387094
0.14894629617
0.149271352861
0.149596161843
0.14990536678
0.150223380966
0.150586769124
0.151111060375
0.151819229161
0.152516996864
0.153139592171
0.153755545229
0.154460642873
0.15544384046
0.156319665997
0.156124525864
0.155923053801
0.155608228587
0.155073604313
0.154348910431
0.153445968474
0.152369848028
0.151131460311
0.149742202816
0.148211010316
0.146544511579
0.144746863734
0.142818764056
0.140756466003
0.138551358459
0.136190018433
0.133654355175
0.130921584537
0.127963974582
0.124748360988
0.1212354101
0.117378602833
0.113122931165
0.108403335337
0.10314295044
0.0972513080635
0.0906227665543
0.0831356306872
0.0746526794538
0.0650247260493
0.0540948215098
0.0417372859744
0.0276741823257
0.0132103593054
0.14343760946
0.143443239128
0.143458655561
0.143483819639
0.143515539792
0.143554306266
0.143594038593
0.14364106454
0.143710789654
0.143781688246
0.143877423743
0.14399715367
0.144111185545
0.144223193771
0.14436049392
0.144511112742
0.144661624038
0.144821095488
0.144998327557
0.145182900073
0.145397763414
0.145617379492
0.145857749718
0.146117989254
0.14639433256
0.146687312445
0.147006764844
0.147360628684
0.147671888442
0.147896365413
0.148122873897
0.148376039238
0.148666058698
0.148977664216
0.149312476829
0.149648241344
0.149971474617
0.150307778393
0.150799638819
0.151537762643
0.152195182577
0.15278036548
0.15338438434
0.15389306779
0.155575861024
0.155328447126
0.155348530356
0.15511682514
0.15463787545
0.153948872806
0.153067456061
0.152008568107
0.150785056038
0.149409054901
0.147890944735
0.146238227113
0.144455417731
0.142544051409
0.140502326918
0.138324629759
0.136001239112
0.133518255009
0.130857582638
0.127996824874
0.124909020689
0.121562215779
0.117918850965
0.113934951943
0.10955911569
0.104731313165
0.0993815689097
0.0934286493285
0.0867790034202
0.0793263928662
0.070952849902
0.061532522505
0.0509358353388
0.0390680393303
0.0256896719147
0.0120382498902
0.143021191499
0.143026540196
0.143041289478
0.143068477975
0.143098520775
0.143135241278
0.14317441585
0.143217630796
0.143286653684
0.14336297601
0.143447145128
0.143565448245
0.143681989388
0.143797369429
0.143924534319
0.14407198795
0.144223457071
0.14438116073
0.144559812707
0.144741749408
0.144950403979
0.145176629572
0.145411288204
0.145670321729
0.145953358657
0.146256202388
0.146591083259
0.146964337645
0.147351393221
0.147640782181
0.147870322011
0.148121937679
0.148399707752
0.148712654085
0.149036082157
0.149381854437
0.149732990516
0.150071466916
0.150477206394
0.151182367805
0.151848096913
0.152413018274
0.152991527514
0.153463593282
0.154710971965
0.154762730662
0.154585211877
0.1541966926
0.153560905936
0.152713478401
0.151677598773
0.150470860202
0.149108812341
0.147604036931
0.145965801616
0.144199940205
0.142308974938
0.140292285841
0.138146093126
0.135863286602
0.133433259396
0.130841805603
0.128071033557
0.125099218377
0.121900555227
0.118444795782
0.114696757804
0.110615687348
0.106154457878
0.101258604291
0.0958652135881
0.0899017702533
0.0832851360107
0.0759210440207
0.0677047479891
0.0585242107438
0.0482642283999
0.0368427738582
0.0240474815015
0.0110091339928
0.142590154013
0.142595336402
0.142614533226
0.142641808009
0.1426668599
0.142699872614
0.142738748782
0.142779807643
0.14283978361
0.142916511051
0.142994150332
0.143109149855
0.143226428517
0.143342247799
0.143462531966
0.143605797069
0.143753607497
0.143909138804
0.144089536146
0.144274961345
0.144473228605
0.144697380552
0.144930803726
0.145189636063
0.145470454154
0.145772716446
0.146109945847
0.146486681664
0.146904564871
0.147315406023
0.147603072912
0.147856230265
0.148134263574
0.148437678792
0.148771740033
0.149125361483
0.1494983308
0.149891930134
0.150266287999
0.150770056985
0.151482890973
0.152090353613
0.152655754051
0.154515780479
0.153794137182
0.15392765276
0.153727936985
0.153175602412
0.152378890061
0.151376302518
0.150191534965
0.148845224047
0.147353889644
0.14572958586
0.143980200104
0.14210981071
0.14011907606
0.138005577873
0.135763994619
0.133386109591
0.130860737139
0.128173631757
0.125307379747
0.122241251841
0.118950994035
0.115408548797
0.111581684185
0.107433503104
0.102921785373
0.0979981216524
0.0926068098552
0.0866835296174
0.0801539087233
0.0729322256717
0.0649209395084
0.0560122200812
0.046091806111
0.0350710602789
0.022753289613
0.0101242908878
0.142144821465
0.142150992691
0.142174377647
0.142197216567
0.142217883831
0.142248289375
0.142286524438
0.142326771372
0.142377357927
0.142449649098
0.142520873303
0.142628678842
0.142746103831
0.142857785926
0.142972482735
0.143114242052
0.14325625405
0.143404224722
0.14358371485
0.143769278234
0.143962388395
0.144182715429
0.144409743647
0.144670441966
0.144948827148
0.145250171031
0.145576790245
0.145943328876
0.146351254151
0.146807470131
0.147246170194
0.147562595441
0.147861236277
0.148170084327
0.148507646184
0.148877091711
0.149279443156
0.149707135097
0.150125976556
0.150557026973
0.151118496304
0.151691253309
0.151608362265
0.153783180429
0.153529849648
0.153223513771
0.152795044639
0.152073939537
0.151111839277
0.149952355704
0.148622770641
0.147144210796
0.145532245148
0.143797339313
0.14194553768
0.139979051479
0.13789680659
0.135694890094
0.133366822877
0.13090365805
0.128293967562
0.12552377174
0.122576443763
0.119432591015
0.116069916654
0.11246304374
0.108583278194
0.104398243981
0.0998713137674
0.094960735793
0.089618341142
0.0837877882637
0.0774022444717
0.0703816826604
0.0626303318212
0.0540348646029
0.0444675870009
0.0338077403058
0.0218565433235
0.00940591212176
0.141682808721
0.141689421608
0.141704167657
0.14172592936
0.14174817879
0.141778044932
0.14181517669
0.141853367161
0.141898852474
0.141965930555
0.14203438663
0.142127524295
0.142245363438
0.142353751508
0.142461126061
0.142599721722
0.142741554305
0.142882181851
0.143049848276
0.143231201831
0.143416815139
0.143637071462
0.143860196492
0.14410668376
0.144380061997
0.144681870434
0.145000849173
0.145352953715
0.145743705744
0.146178729686
0.146662379348
0.147140507054
0.147535125153
0.147898055721
0.148260532313
0.148645226627
0.149064823986
0.149514747981
0.14996299025
0.150439320249
0.151059550118
0.151802211485
0.153411150612
0.152708783782
0.152807028024
0.152455700209
0.151794875501
0.15088784846
0.14976064484
0.1484482991
0.14698031526
0.145377473207
0.143653483873
0.141816620545
0.139870794598
0.137816328619
0.135650585094
0.133368450011
0.130962635981
0.128423820278
0.125740662798
0.122899763342
0.119885596713
0.116680458195
0.113264423042
0.109615311043
0.105708593922
0.1015171579
0.0970107821741
0.0921551759603
0.0869103862599
0.0812283662122
0.0750494638732
0.0682976657575
0.0608748452918
0.0526541720792
0.0434801014639
0.033168691572
0.0214887477618
0.00893259266577
0.141205057075
0.141210713191
0.141217525587
0.141238922461
0.141263331596
0.141291357249
0.141324822679
0.141359512958
0.141399440976
0.141461682492
0.141531975124
0.141609081079
0.14172432517
0.14183501419
0.141939697026
0.142063918621
0.142205508922
0.14234444743
0.142495134245
0.142671749007
0.142849406733
0.143055411886
0.143279902476
0.143510252989
0.14377287982
0.144059329455
0.144374031267
0.144715365138
0.145088733753
0.1455050594
0.145959179183
0.146463834736
0.146973806934
0.14745558549
0.147895923236
0.148337692833
0.148799291137
0.149289751746
0.149794804022
0.150336618701
0.15095591621
0.151289565089
0.153575519896
0.15258619989
0.152187350259
0.151619831731
0.150734390324
0.149627691708
0.148330911189
0.146869997377
0.145270957236
0.143552181256
0.141724728931
0.139794283593
0.137762496119
0.135627873091
0.133386423429
0.131032119859
0.128557190233
0.125952258729
0.123206383753
0.120307042545
0.117240121798
0.113989952764
0.110539413811
0.106870062455
0.102962220256
0.0987948564862
0.0943451069166
0.0895872002081
0.0844905230701
0.0790164951017
0.0731136277926
0.0667100485765
0.0597033398942
0.0519458260724
0.0432395310312
0.0333041472019
0.0218537861221
0.00886199293525
0.140714950471
0.140720730896
0.140732132864
0.140748319463
0.140768294397
0.140791135348
0.140818708186
0.140849792821
0.140883801411
0.14093822518
0.141007934664
0.141073413575
0.141178037217
0.141293448492
0.141398014468
0.141505189594
0.141642443676
0.141776951513
0.141912708694
0.142082455211
0.142257081599
0.142443100261
0.142658682659
0.142875913345
0.143127847996
0.143396639977
0.143701523245
0.144028905967
0.14438574043
0.144784003968
0.145219149537
0.145689212014
0.146199890154
0.146734116811
0.147262808511
0.147788305039
0.148335354184
0.148920011355
0.149556168482
0.150223488914
0.150949213415
0.151508763664
0.152467260054
0.15213587914
0.151485686367
0.15065688175
0.149571092694
0.14827849922
0.146818747612
0.145217905422
0.143497484924
0.141672256151
0.139750288286
0.137734644031
0.135624824384
0.133417725466
0.131108264679
0.128689795557
0.126154361026
0.123492826486
0.120694928518
0.117749299167
0.114643528438
0.111364329778
0.107897818378
0.104229854472
0.100346311338
0.096233095353
0.0918756970732
0.0872580785426
0.082360559911
0.0771563284809
0.071605438603
0.0656448537127
0.0591716896862
0.0520152486684
0.0439081823093
0.0344000053402
0.02306046855
0.00908765131938
0.140211782534
0.140216909582
0.140230546083
0.140243324729
0.140256980421
0.140276076077
0.140299592145
0.14032793631
0.140358024789
0.140402037819
0.140467401285
0.1405311279
0.140612296796
0.140727846705
0.140830690652
0.140927345014
0.14105359375
0.141185189735
0.141311527753
0.141463314158
0.141630373125
0.141800248151
0.142005370133
0.142214309381
0.14244505381
0.142702220449
0.142985529627
0.143297883418
0.143638377259
0.144013331701
0.144433543065
0.144886292502
0.145381404471
0.145914715865
0.146489387825
0.147091900162
0.147734343508
0.148435845565
0.149224093766
0.150065454875
0.151006796997
0.152773268884
0.151704252882
0.151381150526
0.150647228376
0.149583237858
0.1482976776
0.146831663936
0.145220905915
0.143491418911
0.141660660685
0.139739276817
0.137732149775
0.13563984613
0.133459972054
0.131188105658
0.128818373363
0.126343801953
0.123756530735
0.121047929797
0.118208666469
0.11522877641
0.112097828181
0.108805250758
0.105340831517
0.10169528131
0.0978606859102
0.0938306140548
0.0895997196677
0.0851626829709
0.0805123016471
0.0756365593208
0.070513425014
0.0651011566107
0.0593205491721
0.0530140712992
0.0458721299478
0.0371961149651
0.0259156822209
0.00950914267768
0.139694615786
0.139697215333
0.139704397717
0.139712109792
0.139726696587
0.139746084599
0.139768261418
0.139794306078
0.139819995359
0.139853191125
0.13990941207
0.139975928588
0.140036362669
0.140137662368
0.140244719456
0.140336814315
0.140441100559
0.140569902545
0.140692033569
0.140819883128
0.140977851067
0.141134814265
0.141317811471
0.141521944465
0.141726839656
0.141972136882
0.142234124686
0.142530154901
0.142852282793
0.143206515653
0.143608520838
0.144051061198
0.144540461681
0.14507994295
0.145677410773
0.146339686051
0.14706858436
0.147878204718
0.148768361214
0.149636923745
0.149973020546
0.152140827236
0.151315343516
0.150571317861
0.149628453404
0.148370226973
0.146902300806
0.145278108955
0.14353203199
0.141687865311
0.139759237223
0.137752815626
0.135670387821
0.133510284432
0.131268560515
0.128939823769
0.126517728421
0.123995264991
0.121364930222
0.11861884031
0.115748818243
0.112746531374
0.109603783531
0.10631304744
0.102868203633
0.0992653174399
0.0955031928388
0.0915834713215
0.0875101763758
0.0832887415427
0.0789246311397
0.0744220351618
0.0697815772743
0.064997774391
0.0600537344144
0.0549021150385
0.0494131575261
0.0430900077679
0.0344828048316
0.016988501708
0.13916618501
0.139166752873
0.139167583333
0.139166554454
0.139185130231
0.139205712412
0.139226652636
0.139249590062
0.139270350076
0.139294164369
0.139337915756
0.139400011223
0.13945831246
0.139530823891
0.139636087091
0.139729425355
0.139814672152
0.13992936648
0.140047844444
0.140158078958
0.140297575298
0.140447384611
0.140601484526
0.140790676137
0.140983726415
0.14120111682
0.14144865091
0.141724256529
0.142028674011
0.142365268776
0.142746490165
0.143177288797
0.143660930574
0.144205492513
0.144821785989
0.145524110367
0.146334983631
0.14726970332
0.148328207925
0.149433532498
0.149702721828
0.150733918091
0.150475904144
0.149609029856
0.14844432112
0.147004754582
0.145374088491
0.143610134238
0.141746563864
0.139803511829
0.137790677231
0.135711091831
0.133563761805
0.131345139959
0.129050120474
0.126672706472
0.124206403956
0.121644446702
0.118979936062
0.116205955178
0.113315691119
0.110302654337
0.107161137569
0.103886989983
0.100478604476
0.0969378376357
0.0932705097563
0.0894862572847
0.0855977699334
0.0816196777642
0.077567551391
0.0734582413663
0.0693114932689
0.0651557636338
0.0610456650473
0.0570821103633
0.0534653454886
0.0504423414077
0.0486468977046
0.0493870769822
0.138628026142
0.138629192571
0.138632446522
0.138632412904
0.138643116939
0.138660402865
0.13867831941
0.138696771379
0.138713818548
0.138730231069
0.138758234721
0.138808231896
0.138869150048
0.13892217744
0.139003934057
0.139100381543
0.139178625029
0.139263743348
0.139377801783
0.139479847347
0.139588393047
0.139729154928
0.139866926812
0.140029719604
0.14021357005
0.140403446757
0.140627227978
0.140878462271
0.141162349665
0.141477865967
0.141837044939
0.142252407867
0.142724007475
0.143264015967
0.143893772767
0.144627725028
0.145503491024
0.146585078008
0.147961572801
0.149844706616
0.15107785339
0.150090230867
0.149581161968
0.148512027999
0.147107626454
0.145481660762
0.143703045312
0.141819460566
0.139858208075
0.137833778048
0.135751623347
0.133611559821
0.1314103151
0.129142933057
0.126803573184
0.124386009762
0.121883916717
0.119291041147
0.116601320067
0.113809013528
0.110908868566
0.10789644933
0.104768805862
0.101525530715
0.0981699781697
0.0947101906343
0.091159113689
0.0875338266347
0.0838541302285
0.0801406756787
0.0764137766057
0.0726947290608
0.0690084665069
0.0653962591551
0.0619437017169
0.0588225350492
0.0564012147339
0.0551189559531
0.0553216922238
0.0545391972055
0.138080253757
0.138082281926
0.138087907954
0.138098501442
0.138099022284
0.138111726167
0.138125977188
0.13813991209
0.138153748075
0.138162554581
0.138174958052
0.138205934881
0.13825581231
0.138306320869
0.138358947753
0.138444397742
0.13852639288
0.138592086567
0.138682922262
0.138781204059
0.13886911999
0.138984831564
0.139113237378
0.139248736027
0.139408021743
0.13958028643
0.139772954251
0.140000263877
0.140253155893
0.140540706524
0.140876785539
0.141264764063
0.141712690719
0.1422331895
0.142852554424
0.14359432229
0.144502636535
0.145649363865
0.147176426772
0.149419944203
0.150345090201
0.149361932982
0.148458339779
0.147123876721
0.145535220079
0.143763467449
0.141869815146
0.139895062173
0.137860069566
0.135774011669
0.133638733317
0.131451673363
0.129208047767
0.126902090919
0.124527700877
0.122078800065
0.119549537434
0.116934426346
0.114228458418
0.111427268367
0.108527356663
0.105526561118
0.102424998545
0.0992264459519
0.09593974085
0.0925795431188
0.0891659307923
0.0857226376943
0.0822745216725
0.0788442397532
0.0754503324224
0.0721077345734
0.0688305583
0.0656448609018
0.062628502566
0.0599620510983
0.0580525254612
0.0569676232076
0.0566220651959
0.0595642738725
0.137527426185
0.137528802777
0.137530814561
0.137547777553
0.137551290116
0.137560286573
0.137570736622
0.137580008866
0.137589031312
0.137591658298
0.137592962871
0.13760185286
0.137632060869
0.137676085362
0.137716113086
0.137767567208
0.13784635738
0.137913440746
0.13797261832
0.138058042045
0.138140385429
0.13822309304
0.138330703646
0.138444467366
0.13857499803
0.138724191169
0.138889625264
0.139083281852
0.139306150528
0.139563910022
0.139859889371
0.140206819793
0.140615510351
0.141100758851
0.141684373227
0.142393435385
0.143260315098
0.144357931164
0.145784616536
0.14767458196
0.148615315291
0.147691952979
0.146827156898
0.145374991997
0.143684030453
0.141826155844
0.139862463814
0.137830644363
0.135748308474
0.133621523946
0.131449949138
0.129229768945
0.126955578997
0.124621468164
0.122221556062
0.11975027983
0.117202546588
0.114573869859
0.111860494235
0.109059618067
0.1061696839
0.103191046193
0.100127259424
0.0969868342358
0.0937847376068
0.0905427698742
0.0872882125983
0.0840507221038
0.0808583160019
0.0777318026797
0.0746818310116
0.0717076512419
0.0687931576381
0.0659212525624
0.0631617525434
0.0607322317099
0.0590137334993
0.0577542366586
0.0573772708902
0.0592525405268
0.136974109875
0.136974951955
0.136976113605
0.136990963901
0.137005123152
0.137007900311
0.13701229639
0.137015289309
0.137017328547
0.137016101046
0.13700922752
0.137003102952
0.137008992425
0.137034173106
0.137069725696
0.137097562145
0.13714715218
0.137209992226
0.137255716861
0.137310421664
0.137381593534
0.137445793062
0.137522009706
0.137613502178
0.137715523825
0.137832108976
0.137968969903
0.138126367009
0.138318283291
0.13853827154
0.138788164846
0.139088336407
0.139441367186
0.139865989012
0.140375628428
0.141002662623
0.141771286972
0.142731413763
0.143944257706
0.145352201833
0.14648141767
0.145533960388
0.144731142324
0.143270661359
0.141558535829
0.139672114069
0.137682723422
0.135627649598
0.133523905905
0.131376779958
0.129185357047
0.126945702666
0.124652642137
0.122300737294
0.119884776209
0.117400037347
0.114842436271
0.112208688605
0.109496467293
0.106704704657
0.103833970293
0.10088739797
0.0978724287155
0.094802969659
0.0917008915705
0.088595758751
0.0855222711471
0.0825156560762
0.0796060918103
0.0768102135491
0.0741286651829
0.0715367514268
0.068965474259
0.0663338108505
0.0637073996535
0.0612567470864
0.0595146863648
0.0590432175566
0.0599513334363
0.0606674878587
0.136414308665
0.136414415908
0.136417066416
0.136421958744
0.136438787569
0.136444034112
0.136446230872
0.136443508814
0.136438362161
0.136432641932
0.136418982246
0.136403955882
0.13638811206
0.136388365382
0.136407515434
0.136431182312
0.136450964008
0.136490983509
0.136530609312
0.136560790199
0.136598939438
0.136648947067
0.136698980001
0.136758595814
0.136830893006
0.136917188654
0.137016237985
0.13713838216
0.137282214289
0.137452108351
0.137646831881
0.137884345465
0.138169360447
0.138510736226
0.138920652622
0.139425313558
0.140049287615
0.140761789274
0.141627177579
0.142249865063
0.143746548538
0.142975084501
0.14226464714
0.140863505874
0.139192648875
0.137324124637
0.135345277578
0.133295497447
0.131192961485
0.129043719908
0.126847501265
0.124601136087
0.122300329297
0.119940602207
0.117517765342
0.115028204057
0.112469041896
0.109838361978
0.107135405753
0.104360987973
0.101517970776
0.0986125511231
0.0956565700381
0.0926700985932
0.089682736372
0.0867324353478
0.08386149213
0.0811106543616
0.078512079964
0.0760795119429
0.0738096562769
0.071651793108
0.0694830590503
0.0672173629542
0.0648301472625
0.0618121017954
0.0606517966898
0.0618372900057
0.0622299900112
0.0625468434839
0.135840118005
0.135837452332
0.13583665446
0.135831316596
0.135841431395
0.135857682217
0.135865612744
0.135860617434
0.135850168227
0.135837994851
0.135820810509
0.135795701384
0.135770136626
0.135745311289
0.135737934997
0.135748361816
0.135756266753
0.135765124653
0.135786936371
0.13580638607
0.13581619846
0.135831177464
0.135859333785
0.135887417983
0.135924907345
0.135974925223
0.136034029683
0.136105700299
0.136191510301
0.136296363457
0.1364226738
0.136583773327
0.13679241019
0.137042421888
0.137344882946
0.137729374748
0.138164795036
0.138613068031
0.13904541937
0.138723326965
0.140553056198
0.140188815899
0.139589282515
0.13825269304
0.136644302559
0.134818418713
0.132873366827
0.130849304056
0.128765544534
0.126629202332
0.124441157672
0.122199469944
0.119901104859
0.117542845643
0.115121761865
0.112635529702
0.110082623003
0.107462611881
0.104776406554
0.102026818282
0.0992191382096
0.0963629118325
0.0934749506739
0.0905822969617
0.0877230761362
0.0849440408202
0.0822949614495
0.0798214495351
0.0775566644753
0.0755131351961
0.073691220037
0.0720200532528
0.070423904721
0.0690092350416
0.0675090174114
0.0640158809715
0.0646423261204
0.0645434795098
0.0644993707304
0.064521492731
0.135254984616
0.135247995896
0.135239863674
0.135231286308
0.135231811639
0.135246960914
0.135260757482
0.135259903285
0.135249345605
0.135232985169
0.135213300297
0.135183503159
0.135151115983
0.135112977668
0.135080301098
0.135060371082
0.135055136744
0.135044334261
0.135035747184
0.135034786745
0.135029986083
0.135014319474
0.135003067339
0.135001654141
0.1350027151
0.13500568888
0.135014899416
0.135027786498
0.13505438415
0.135089948879
0.135152411028
0.135232448682
0.135342968558
0.135489376888
0.135688459596
0.135938064166
0.136230094681
0.13659316862
0.137082165613
0.137089312912
0.137637455161
0.137388445049
0.136837412764
0.135524933994
0.133967454756
0.132190364582
0.130291220329
0.128306010281
0.126253709708
0.124141966338
0.121972776327
0.119745545728
0.117458641425
0.115110245675
0.112698803451
0.110223384206
0.107683891125
0.105081453233
0.102418702222
0.0997005190086
0.0969347111021
0.0941344467208
0.0913220958639
0.0885324598421
0.0858128117719
0.0832188109768
0.0808071842473
0.0786272793157
0.0767109671386
0.0750673981067
0.0736842916914
0.0724554271423
0.0714905929412
0.0708427449616
0.0688944888328
0.0710064003724
0.0680137226764
0.0669483686784
0.0664459552492
0.066259776196
0.134669599698
0.134658789654
0.134645728496
0.134635023604
0.134626125661
0.13462632438
0.13463545377
0.134643689744
0.134637473973
0.13462100549
0.134597597423
0.13456735075
0.134525049181
0.134482253582
0.134432540853
0.134387796093
0.134351103525
0.134323408196
0.134290798452
0.134257985912
0.134228201441
0.134193403545
0.134148913727
0.134105551499
0.134065781937
0.134021707615
0.133974147027
0.133933563933
0.133894010356
0.133865944331
0.133840185196
0.133823227332
0.133823587953
0.133859415384
0.133936508186
0.134038868272
0.134201145212
0.134440705047
0.134846825389
0.135472044333
0.135315316277
0.134648442644
0.134022511253
0.132706855014
0.131191735792
0.129465655027
0.127619538137
0.125681824136
0.123670010353
0.121591733452
0.11944992686
0.117245291584
0.114977592987
0.112646428698
0.110251639961
0.107793717492
0.10527401148
0.102695234362
0.100061739308
0.0973805056902
0.0946618782825
0.0919228981863
0.0891920610063
0.0865125894478
0.0839411690669
0.081541928081
0.0793775152985
0.0774997867289
0.0759398630112
0.0747063639254
0.073759737074
0.0729523711461
0.0724216256983
0.0714749471608
0.0713202970256
0.0707430672111
0.0692440056682
0.0683148773005
0.0677773402809
0.0675346450259
0.13408834813
0.134076658954
0.13406244885
0.134047496514
0.134032558385
0.134019130698
0.134015647577
0.134024921638
0.134021991177
0.134005847111
0.133979242228
0.133944927424
0.133898493097
0.133844120071
0.133786496019
0.133720388521
0.13365530322
0.133596705885
0.133544466916
0.133485505757
0.133425131911
0.133357468298
0.133288974291
0.13320586814
0.133117986797
0.133025400185
0.132927622266
0.132824374331
0.132716462376
0.132598436525
0.132471665359
0.132361651281
0.132260054556
0.132172567318
0.132090963017
0.132015863279
0.131955879821
0.13191458931
0.131905803797
0.131845871527
0.132461660306
0.131738773561
0.131094993005
0.129796358413
0.128332403348
0.126663235846
0.124875954506
0.122991819594
0.121026912304
0.118988679266
0.116880875275
0.114705404296
0.112463359046
0.110155700027
0.107783617425
0.105348992009
0.102854583438
0.100304665686
0.0977052624826
0.0950654322292
0.092398008649
0.0897241253917
0.087078936577
0.0845145183631
0.0820967191535
0.0798968143057
0.0779810616604
0.076400954383
0.0751858551605
0.0743464207867
0.0738414819336
0.0736558111462
0.0738777612736
0.0723045622502
0.0732869596065
0.0712576312046
0.0699538917759
0.0690938694636
0.0685823392055
0.0683468700394
0.133508684777
0.133501067143
0.133487154777
0.133469612811
0.133449350384
0.133427885874
0.133410575167
0.133409070254
0.133407706329
0.133391394159
0.133362156203
0.133321909397
0.133272511911
0.133209246236
0.133139440065
0.133056471282
0.132968176335
0.132883020632
0.132797774201
0.132712623534
0.132625321286
0.132526245774
0.132416809571
0.132297694205
0.132162287962
0.132016520012
0.131862782334
0.131689922398
0.131497700992
0.131286049894
0.131084617541
0.130872032593
0.130648561075
0.13041195118
0.130153342744
0.129871777783
0.12957325637
0.129276735834
0.12898471879
0.12863621961
0.129328898432
0.128675672119
0.128072334966
0.126811705487
0.125407952248
0.123801085677
0.122076808519
0.120250275573
0.118336627033
0.116343121001
0.114274269254
0.112133077413
0.109921867865
0.10764287776
0.105298557793
0.102892107882
0.100427610986
0.097910845285
0.0953493996255
0.0927543601371
0.0901409223199
0.087534542748
0.0849775246572
0.0825310026313
0.0802691826485
0.078268387526
0.0765950538733
0.0752955716407
0.0743910966761
0.0738760898163
0.0736930252901
0.0739163955747
0.074380159522
0.0747129335436
0.0730330166812
0.0712914980944
0.0701609911565
0.0694244197758
0.0689734952065
0.0687650965232
0.132934392197
0.132932149781
0.132919381603
0.132900651842
0.132876671235
0.132849131582
0.132822647867
0.132802270844
0.132794783912
0.132779172418
0.132748227474
0.13270324038
0.132645958691
0.132577194125
0.132491312202
0.132399624223
0.132293947585
0.132185183799
0.132068601922
0.131951632377
0.13182960314
0.13170059539
0.131548376971
0.131383114742
0.131199752228
0.131001300827
0.130780304957
0.130532853212
0.130256593611
0.129978236057
0.129678370891
0.129343143504
0.128981667662
0.128587719483
0.128156135408
0.127686202081
0.127209665546
0.126702006472
0.126195847993
0.125580057367
0.126206875419
0.125555152176
0.124990766934
0.123777037772
0.122438115679
0.12089655722
0.119237499483
0.117470765571
0.115610998848
0.11366530396
0.111638896833
0.109535776007
0.107359385039
0.105113139461
0.102800643824
0.100426324117
0.0979954671331
0.0955152697312
0.0929947379506
0.0904469105309
0.0878891603319
0.0853515460845
0.0828840220373
0.0805567615436
0.0784510948582
0.0766458222844
0.0752039219917
0.0741629404178
0.0735317435419
0.0732809892182
0.0733380178239
0.0736957192128
0.0737767357204
0.0750975075841
0.0726197681054
0.0710525507437
0.0700468798516
0.0694312968018
0.0690700260758
0.068899022728
0.132373521314
0.132370966878
0.132358754966
0.132338351707
0.132311903744
0.132280134868
0.132246917938
0.132213962759
0.132188545052
0.132170242415
0.132139211901
0.13209056845
0.132026095821
0.13194724126
0.131851985337
0.131744779238
0.131629092842
0.131494387436
0.131354347573
0.131205284556
0.13104676708
0.130877460345
0.130686232028
0.130471915608
0.130238353451
0.129982090692
0.129696089273
0.129373677167
0.129033008408
0.128662223659
0.128244035883
0.127784446587
0.127280707988
0.126728841375
0.126125012182
0.125484290422
0.12482701212
0.124124406079
0.123324541584
0.122383393681
0.123051964407
0.122404372719
0.12187643654
0.120713954549
0.119441477011
0.11796600776
0.116372520484
0.114666160736
0.112861410927
0.110965235618
0.10898348858
0.106921040327
0.104782338572
0.102571877969
0.100294304971
0.0979551773264
0.095560843114
0.0931198257984
0.0906423606474
0.0881433722011
0.0856421736181
0.0831738379991
0.0807965130501
0.0785892098504
0.0766388151624
0.0750237958644
0.0738001112821
0.0729929956731
0.0725951549229
0.0725622339101
0.0728663181665
0.0734380671809
0.0733841560403
0.0732134652939
0.0717163401578
0.0705613550934
0.069754144256
0.06925471866
0.0689724234695
0.0688491042723
0.131825423263
0.131817960828
0.131804584858
0.131782187483
0.131753376206
0.131718698402
0.131678953937
0.131639160079
0.131600944036
0.13156798496
0.131535555007
0.131485059845
0.13141531465
0.131327875575
0.131224206765
0.131102669324
0.130966610034
0.130815267767
0.130649085004
0.130472773033
0.130279427853
0.130066306073
0.129831114492
0.129570503029
0.129285548302
0.128968929454
0.12861567867
0.128227618274
0.127801409127
0.127322102187
0.126791322655
0.126204405771
0.12555999673
0.124854398363
0.124087791045
0.123283259932
0.122412152851
0.121451747146
0.120323992773
0.119177522765
0.119873575813
0.119247281319
0.118754180617
0.117642798241
0.116435219151
0.115024556026
0.113495372521
0.111848580879
0.110098709948
0.108252568064
0.106316570108
0.104296326977
0.102197168197
0.10002456836
0.0977841084113
0.0954823941725
0.093126686305
0.0907267520106
0.0882938429175
0.0858447335815
0.083400408181
0.0810015793317
0.0787152035706
0.0766287687389
0.0748329051616
0.0734028969541
0.0723846722979
0.0717887628824
0.0715877061905
0.0717130533373
0.0720984007847
0.0725485747884
0.073621240884
0.0721791339371
0.0709202915682
0.0700171902994
0.0693889972727
0.0689972366271
0.0687802427783
0.068651860833
0.131285015541
0.13127357089
0.131257500899
0.131234190011
0.131204012704
0.131167896444
0.131125685606
0.131078319798
0.131032937342
0.13098386351
0.13093777483
0.130885106739
0.130812509389
0.130719104819
0.130605573228
0.130472994985
0.130319164897
0.130148141319
0.129959993944
0.129753869567
0.129524144315
0.129270041248
0.12899061729
0.128684109541
0.128343958983
0.127964584581
0.127542359425
0.127076010785
0.126553144505
0.125973516231
0.125330814273
0.124620825163
0.123839730876
0.122988588304
0.122068472068
0.121074030157
0.119967964721
0.118722816153
0.117449451716
0.116096059637
0.116736121043
0.116107977997
0.11564229734
0.114579926933
0.113434108404
0.112085705081
0.110618433091
0.10902934191
0.107333153033
0.105536519232
0.103646352932
0.101668880708
0.0996101905479
0.0974766405329
0.0952746431928
0.0930117915204
0.0906961109846
0.0883385634937
0.0859511842456
0.083552627342
0.0811652465562
0.0788363174279
0.0766422828171
0.0746785931624
0.0730376560337
0.0717887174221
0.0709646807479
0.0705602577707
0.0705353593962
0.0708286006573
0.0713438259106
0.0716687379996
0.0718876140988
0.0709037829837
0.0700574381122
0.0694202500986
0.0689752599723
0.0686962675645
0.0685385128152
0.0684752499264
0.130748822415
0.130737229856
0.130720218048
0.130698586711
0.130669686683
0.130633794796
0.130590663389
0.130539628988
0.130483535728
0.130425801557
0.130360017811
0.130293909174
0.130215250682
0.130117796104
0.129996607768
0.12985245453
0.129685684186
0.12949435728
0.129281997087
0.129045635735
0.128783087887
0.128490001074
0.128167494442
0.127809927087
0.127411543954
0.126968313766
0.126472529155
0.125920459948
0.125306568511
0.124626589191
0.123872185647
0.123037983632
0.122125237997
0.121131332549
0.120040164339
0.118829973813
0.117521870311
0.116093354772
0.11469472295
0.112991759826
0.113622930548
0.112990555794
0.112550272002
0.111537394936
0.110450691048
0.109161545022
0.107753061579
0.106218990774
0.104574402588
0.102825834596
0.100980668242
0.099045642159
0.0970274911419
0.0949333629512
0.0927704055543
0.0905471637071
0.0882722884365
0.0859579394511
0.0836166898394
0.0812691989538
0.0789388482617
0.0766807684677
0.0745815229352
0.0727437662502
0.0712596162666
0.0701897864238
0.0695520853899
0.0693231920414
0.0694409011732
0.0698164976095
0.070339771395
0.0711720936042
0.0705222641693
0.0698003975413
0.0692220710155
0.0687957251528
0.068520327116
0.0683593730524
0.0682716398225
0.0682582475301
0.130227993915
0.130217003639
0.1302039746
0.130185742727
0.13015943672
0.130124089705
0.130079436328
0.130025068554
0.129960212632
0.129892497875
0.129814416524
0.129726463662
0.129628759623
0.129525434827
0.129396881342
0.129243222784
0.129061645418
0.128852966967
0.128615785127
0.128350872119
0.128054340242
0.127723738799
0.127356031545
0.126945096976
0.126488372698
0.125979079706
0.125409741163
0.124775141281
0.124069707247
0.123289336347
0.122425828505
0.121473919748
0.120431312267
0.119283397886
0.117996880543
0.116601555557
0.115107720962
0.113456547699
0.111793918422
0.10980804294
0.110501819225
0.109900461213
0.109490016284
0.108527397661
0.107496885744
0.106263367491
0.104909826518
0.10342737195
0.101831526215
0.100128759403
0.0983269174763
0.0964331780381
0.0944548327537
0.0923997347365
0.0902756783014
0.0880921535965
0.0858583057233
0.0835875666483
0.0812927887542
0.0789968959483
0.0767239039819
0.0745385444543
0.0725379552643
0.0708307562565
0.0695059690723
0.0686129849409
0.0681560385372
0.0681018476569
0.0683606916612
0.0687915062515
0.0693597761756
0.0695448716921
0.0691637944051
0.0687388554749
0.06838850295
0.0681404002562
0.0679994733681
0.0679471159994
0.0679143773433
0.0679123488379
0.129745669817
0.129737983479
0.129726788578
0.129708799383
0.129682364081
0.129645350039
0.129597097499
0.129537268767
0.129465272628
0.129382576208
0.129294754996
0.129194372771
0.129081438805
0.128954786479
0.128811176555
0.128645903825
0.128450300946
0.128222625129
0.127964355032
0.127669658614
0.127340054716
0.126970992313
0.126558041755
0.126093674429
0.125577914203
0.125004223226
0.124361562803
0.123644803673
0.122850221596
0.121972439287
0.121002020667
0.119928767023
0.118750190591
0.117421592942
0.1159516708
0.114364000713
0.112611554664
0.110683085396
0.108819458472
0.106715241141
0.107419652909
0.106861445847
0.106479598391
0.105563747592
0.104584472808
0.103401820627
0.102098550743
0.100663617749
0.099112965736
0.0974529997906
0.095692029886
0.0938376265613
0.0918975834125
0.0898803906181
0.0877944146067
0.0856501142838
0.0834570029228
0.0812299454357
0.0789817920696
0.0767381634476
0.0745232390523
0.0724136834813
0.0705174404835
0.068947489756
0.0677861383024
0.0670669028779
0.0667770455591
0.066870501766
0.0672500641855
0.0677948906954
0.0684769392783
0.0682363843273
0.0679844249093
0.0677354582655
0.0675427852081
0.067413616474
0.0673362691052
0.0673469802057
0.0673731836469
0.0673698125184
0.129302460705
0.129300114846
0.129287954371
0.129268424311
0.129239248936
0.129198004073
0.129143958253
0.129076884955
0.128996505462
0.128901711014
0.128798930903
0.128688765408
0.128568366797
0.128420518267
0.128256010693
0.12806846579
0.127854154102
0.127608225421
0.127327101814
0.127004797028
0.126642524703
0.12623553139
0.12577503207
0.125258239001
0.124684828637
0.124045555312
0.123332177495
0.12253666474
0.121655255514
0.120683691579
0.119607486884
0.118408921101
0.117065933289
0.115556722187
0.113906573203
0.112084424353
0.110114545622
0.107971449172
0.106020599563
0.103770014747
0.104430116508
0.103897221848
0.103535448492
0.102659127452
0.10172417587
0.100586581742
0.0993281891383
0.0979360893986
0.0964264909872
0.0948056817771
0.0930824217581
0.0912646519106
0.0893606553683
0.0873795164877
0.0853301256187
0.0832239656821
0.0810707948394
0.0788871674981
0.0766856080115
0.0744950609458
0.0723392603884
0.0703098031358
0.0685252238081
0.0671009175269
0.0661100228468
0.0655716684003
0.0654514900672
0.0656326746954
0.0659819231712
0.066841467528
0.0670101933835
0.0669543341653
0.0668471369413
0.0667371413655
0.0666527619516
0.0665929455985
0.0665447792876
0.0665348819281
0.0665762020004
0.066517512558
0.128878233145
0.128881283566
0.128872131573
0.128853747144
0.12882204019
0.128775935872
0.128715458935
0.128640817866
0.128552022086
0.128448730862
0.128330967707
0.128203120425
0.128067086617
0.127912947602
0.127730668676
0.12751904028
0.127280180838
0.127010656177
0.126702514674
0.126354384765
0.125961930607
0.125513130987
0.125008155678
0.124441521893
0.123812338445
0.123112640823
0.122329972877
0.121459223681
0.120497632956
0.119437499263
0.118245537991
0.116896294624
0.115390633429
0.113722320147
0.111878915325
0.109874754909
0.107729555979
0.105387394077
0.103361312308
0.100933146988
0.101544921306
0.101018849026
0.100667825286
0.0998230875406
0.0989248615203
0.0978260571653
0.0966067383506
0.095252356686
0.0937791908651
0.0921933347495
0.0905039731726
0.0887194114462
0.0868484580165
0.0849007781068
0.0828857792057
0.0808160580494
0.0787014956649
0.0765607008113
0.0744054690177
0.0722689102015
0.0701734622245
0.0682293754231
0.0665644898972
0.0652931776124
0.0644764548181
0.0641241653186
0.0641952448899
0.0645645797154
0.0650408090619
0.0655327748433
0.0657005567919
0.0657436155829
0.065741484748
0.0657298494156
0.0657206967765
0.06571241236
0.0657003969536
0.0656826846202
0.0657064330478
0.0657020719665
0.128470593451
0.128475980076
0.12847197024
0.128455167268
0.128421009364
0.128370925767
0.128305337919
0.12822445788
0.128128301147
0.128016723573
0.127888842727
0.127744445329
0.12758663621
0.127415028127
0.127219836899
0.126992691487
0.126731863192
0.126434514585
0.126098755848
0.125722080362
0.125293977262
0.124809130475
0.124262757015
0.123649843314
0.122968580333
0.122208659098
0.121361664688
0.120419908771
0.119382502632
0.118219851764
0.116881841887
0.115392674186
0.113744537547
0.111914454912
0.109906194927
0.107744646425
0.105401133457
0.102891064308
0.100821299625
0.0982022062645
0.098762241395
0.0982283428443
0.0978810651773
0.0970617287509
0.0961933646057
0.0951273662144
0.093941307499
0.092619291593
0.0911775447269
0.0896219303146
0.0879620373973
0.0862065433472
0.08436486417
0.0824472604801
0.0804637081775
0.0784280410888
0.076350152969
0.0742511933217
0.0721417167908
0.0700600808994
0.0680262575356
0.0661736213026
0.064636256055
0.0635235338826
0.0628841022356
0.0627052397343
0.062859053712
0.0632421059028
0.0642502431052
0.0643293860548
0.0644776795983
0.0645802887133
0.0646491824795
0.0647049246163
0.0647495033043
0.0647824887023
0.0648027475342
0.0647998103406
0.0648210084193
0.0648552551269
0.128093036083
0.128092620193
0.128087797778
0.12806714703
0.128029780656
0.127977356848
0.127909403404
0.1278247419
0.127723184189
0.127604518667
0.127468110065
0.127312827926
0.127137691354
0.126943817252
0.126729114245
0.12648866482
0.126208039774
0.125886865986
0.125524283776
0.125114584831
0.12465196231
0.124130943338
0.123544342544
0.122887436536
0.12215563275
0.12134049644
0.120428128283
0.119418962891
0.118291578405
0.116989836073
0.115529999114
0.113923507515
0.112136323663
0.110157052343
0.108007158269
0.105660658529
0.103170268904
0.100542065618
0.0983895712642
0.0955416543197
0.0960694791033
0.0955215370658
0.0951747250719
0.0943782936931
0.0935350067696
0.0924967565603
0.0913384326892
0.0900433035045
0.0886275875773
0.0870969836727
0.0854614928185
0.083730181288
0.0819131942443
0.080021419681
0.0780655248044
0.0760607320857
0.0740168693279
0.0719582620934
0.0698935794205
0.0678678601763
0.065897162944
0.0641431964443
0.0627403066762
0.0617888465459
0.0613304482409
0.0613322006346
0.0616118518495
0.062036708537
0.0627603104902
0.06306205116
0.0632732074299
0.0634357607166
0.0635545209736
0.0636549603097
0.0637362061762
0.0637992742655
0.063843549308
0.0638523141916
0.0638841968741
0.0639374208991
0.127740243932
0.127732295149
0.127719104052
0.127693115869
0.127652991572
0.127598505029
0.127528471705
0.127441515562
0.127336529323
0.127212542818
0.127069107597
0.126905255908
0.126719483741
0.126509701564
0.126277154411
0.126015515647
0.125710565814
0.125368651252
0.124979514817
0.124538688693
0.12404145929
0.123483919704
0.122859588641
0.122158710998
0.121379036169
0.1205035462
0.119527320104
0.118438818728
0.117192727109
0.115785116018
0.114231442363
0.112511185491
0.110593878585
0.108478462567
0.106157227739
0.103652395915
0.10106166876
0.0982739487885
0.0960182686269
0.0929351526887
0.0934443909057
0.0928896124322
0.0925470717762
0.0917757627441
0.0909552128227
0.0899405391991
0.0888046038085
0.0875306615446
0.0861351227504
0.0846236944135
0.0830068284252
0.0812939978208
0.0794962234268
0.0776250519682
0.0756920470348
0.0737139774792
0.0717005893495
0.0696801804587
0.0676587485536
0.0656899973235
0.0637844316109
0.0621382542316
0.060878812355
0.0600979969195
0.0598124356788
0.0598741774604
0.0601761822157
0.0613455575335
0.0615534527093
0.0618489583104
0.0621015874885
0.0623038360507
0.0624555838256
0.062584122191
0.0626887212
0.0627718639812
0.0628376678694
0.0628662516878
0.0629044040568
0.0629542218656
0.127402015755
0.127390490917
0.127369639385
0.127341880312
0.127299247265
0.12724154
0.12716787784
0.127077651154
0.126969272763
0.126841350601
0.126692240506
0.126521191913
0.126326462605
0.126105578707
0.125856153984
0.125568625486
0.125246632623
0.124881093122
0.124462096604
0.123993455394
0.123465652349
0.122873540478
0.122208398196
0.121465673732
0.120632679628
0.119694444046
0.118650419704
0.117471086229
0.116134777561
0.114642832087
0.112999831573
0.111164793361
0.109110332296
0.106833596945
0.104341133807
0.101730560541
0.0989939551893
0.0960665897043
0.0935980381108
0.0902522768542
0.090847109602
0.0903332043677
0.0900053925061
0.0892617419233
0.088461584727
0.0874659979061
0.0863466863059
0.0850877267948
0.0837058880808
0.0822070776718
0.0806022438324
0.0789012735884
0.077116218518
0.0752592958221
0.0733432587964
0.0713865476681
0.0693988981952
0.0674134936397
0.0654326896308
0.0635216112696
0.0616831235205
0.0601544428938
0.0590489474739
0.058462455486
0.0583854270484
0.0585671125824
0.0588512043975
0.0597644143731
0.0602447911762
0.0606253729877
0.0609391357389
0.0611816531087
0.0613670858908
0.0615184479909
0.0616408278332
0.061736160263
0.0618085318318
0.0618659618644
0.0619181777775
0.0619672461911
0.127081228906
0.127069056541
0.127045749256
0.127016222903
0.126970511356
0.12690912887
0.1268313755
0.12673658063
0.126623807917
0.126491447231
0.126337613234
0.126160281988
0.125956978224
0.125724719023
0.125458716291
0.125157008704
0.124815951936
0.1244227513
0.123980824343
0.123485531577
0.122921786678
0.122294631299
0.121594575293
0.120806170671
0.119912179721
0.118918581157
0.117807368949
0.116547021551
0.115131087329
0.113566438579
0.111826121607
0.109853981361
0.107657292827
0.105222613285
0.102621456047
0.0998712936062
0.0969136569242
0.0937713667862
0.0910103000231
0.0876600573138
0.0883249635107
0.0878831578993
0.0875712320271
0.0868498184468
0.0860639820631
0.0850812757652
0.0839718566327
0.0827209555698
0.0813456181681
0.0798520619825
0.0782517544927
0.0765549925201
0.0747750109004
0.0729246777868
0.0710183305875
0.069076126306
0.0671079860014
0.0651528761776
0.0632082141145
0.0613540331158
0.0595823091483
0.0581795649667
0.0572402034886
0.056851011037
0.0568762856857
0.0571204758941
0.0583229677369
0.0586422736365
0.0590718237704
0.059470252486
0.0598143066491
0.0600981694823
0.0603178082525
0.0604973834723
0.0606451753976
0.0607633391939
0.0608523753913
0.0609293952138
0.0609832212924
0.061014552812
0.126783141147
0.126771435024
0.126747859716
0.126715176722
0.12666605434
0.126600901089
0.126519049457
0.126419865672
0.12630240243
0.126165235385
0.126006619698
0.125823488044
0.125612875369
0.125370846153
0.125093668176
0.124777550115
0.124414948555
0.124001704943
0.123535915654
0.123005020682
0.122413137948
0.121757907655
0.121013188122
0.120166343114
0.119229848775
0.118185101693
0.116996039267
0.115666140056
0.114190392081
0.112539875507
0.110675872246
0.108586653264
0.106267122696
0.103723498977
0.100994437991
0.0980321087067
0.094835834614
0.0914218868962
0.0886481130172
0.0854206642185
0.0859940896422
0.0855785061696
0.0852655870829
0.0845531761121
0.0837718892987
0.0827942762167
0.0816871813982
0.0804367729762
0.0790600611573
0.0775635810532
0.0759593155435
0.0742579702333
0.0724741077503
0.0706211986322
0.0687156818327
0.066779369848
0.0648227961466
0.0628915179546
0.0609763862504
0.0591759556252
0.0574643262071
0.0561883382016
0.0554274326608
0.055252305462
0.0554001685345
0.0558224071286
0.0565013092481
0.0572673730793
0.0578480206436
0.0583302408734
0.0587247133715
0.0590558996672
0.0593202104007
0.0595352169654
0.0597145754676
0.0598615021929
0.0599798604852
0.0600672371508
0.0601133264118
0.0601108799587
0.12650895114
0.126498192459
0.126473563998
0.12643684472
0.126385041029
0.12631622181
0.126230454662
0.126127379443
0.126006059311
0.125864900899
0.12570161949
0.12551333848
0.125296048863
0.125045691974
0.124758244407
0.12442754585
0.124047240808
0.123614004401
0.123120517833
0.122562198466
0.121943275677
0.121244903177
0.120449388464
0.119568866949
0.118593802484
0.117477791582
0.116226076857
0.114844221336
0.11329217992
0.111549454445
0.109592645877
0.107400573478
0.104969123512
0.102312734621
0.0994252431809
0.0962774659381
0.0929000526941
0.0893403910813
0.08670542711
0.0834520763442
0.08388102485
0.0834270502046
0.0830937016774
0.0823785371058
0.0815922828051
0.0806119426871
0.0794994256736
0.0782415820575
0.0768550731823
0.0753467185572
0.0737289939987
0.0720130326075
0.0702148513369
0.0683484544608
0.0664330433212
0.06449189393
0.0625369929584
0.060621310536
0.0587278930367
0.0569779928278
0.0553163137733
0.0541613065755
0.0535553698602
0.0534869803209
0.053695027038
0.0546942930236
0.0553837816948
0.056057271137
0.0566851163496
0.057224131232
0.057674026169
0.0580506211409
0.0583681872983
0.0586240149359
0.0588348092605
0.0590049212402
0.0591400667958
0.0592329685267
0.0592896013997
0.0592969452192
0.126257996812
0.126248204128
0.126221679947
0.126182286288
0.12612792125
0.126054735311
0.125964884625
0.125858477901
0.125734505818
0.125590835069
0.12542448213
0.125231854662
0.12500882949
0.124751237933
0.124453125222
0.124107222943
0.123708721416
0.123254128025
0.122737213208
0.122152403712
0.12149710913
0.120758489576
0.119932553751
0.11902256359
0.117988583889
0.116810139202
0.115510490382
0.114073973831
0.112456415314
0.110630393087
0.108573675646
0.106286115509
0.103757974872
0.100982028941
0.0979594273795
0.0946724432396
0.0911868129913
0.0876035382493
0.0849912518196
0.0815561861435
0.0819157465565
0.0814086599388
0.0810495323108
0.0803279007692
0.0795304827124
0.0785407609263
0.0774153961922
0.0761420308032
0.0747368500973
0.0732069378425
0.071565211445
0.0698232662303
0.0679986515372
0.0661058261427
0.0641675490528
0.0622081842685
0.0602425649436
0.0583318720165
0.0564511224391
0.0547502186679
0.0531359773909
0.0521272480964
0.0516759802878
0.0515946985596
0.0518848490313
0.0530635218049
0.0540114438637
0.0548158254904
0.0555278334969
0.0561356333558
0.0566560423099
0.0570862399173
0.057453672525
0.0577512279998
0.0579934547908
0.0581874619744
0.05833800115
0.0584323626973
0.0585011165628
0.0585366881936
0.126031644265
0.126021486419
0.125994340316
0.125954994031
0.125894995687
0.125816110765
0.125722260244
0.125614054045
0.125489745533
0.125345990313
0.125178706638
0.124983446075
0.124755517165
0.124489796145
0.124179587546
0.123817355911
0.123398531261
0.122920308938
0.122378189901
0.121770781671
0.121088493931
0.120318557011
0.119464320303
0.118511290604
0.117423098745
0.116199957951
0.114854877439
0.113361364215
0.111669685767
0.109768806339
0.107644723099
0.105260743559
0.102610763872
0.0997314053383
0.0965993583688
0.0932084423676
0.0896765966362
0.086110002498
0.083321906168
0.0796276857776
0.0800313477946
0.0795085929524
0.0791308526931
0.0784046990482
0.0775926802646
0.0765879181926
0.0754425611255
0.0741454210038
0.0727122490216
0.0711503819056
0.0694730584633
0.0676923531804
0.0658273212522
0.063892791292
0.0619159549987
0.0599216319373
0.0579296117051
0.0560097849146
0.0541291612527
0.0524710083201
0.0508999774407
0.0500903804299
0.049859697449
0.0498616305632
0.0501956461529
0.0516638393287
0.0526544766079
0.0535791500388
0.0543814342941
0.0550649499606
0.0556523221192
0.0561503125497
0.0565625091163
0.0568988848611
0.0571695694064
0.0573842163902
0.0575457818043
0.0576538185945
0.0577351416549
0.0577873179227
0.125835549701
0.125822013621
0.125796448917
0.125756539732
0.12569018818
0.125609318921
0.12551652088
0.125411790155
0.125291044336
0.12514909489
0.124980829464
0.124781158395
0.124544941546
0.124266568086
0.123938392043
0.123553337551
0.12311136974
0.122612874065
0.122052700924
0.121422092916
0.12071064957
0.119917048706
0.119035324586
0.118038472261
0.116903510068
0.115634277689
0.114243769854
0.112705466934
0.110967904876
0.10900659533
0.106777941259
0.104271328568
0.101539148284
0.0985730373571
0.0953204197469
0.091870615265
0.088304272464
0.0846647845879
0.0816410506588
0.0777902307915
0.0782410854275
0.0777361173808
0.0773464972439
0.0766173602745
0.0757876200411
0.0747621416286
0.073589522768
0.0722600534126
0.0707891015796
0.0691841992842
0.0674586625899
0.0656249823682
0.0637035128536
0.0617093728301
0.0596750159213
0.057624744312
0.0555864126038
0.0536388545707
0.0517416373232
0.0501142459191
0.048570941494
0.0479537265226
0.0477971320847
0.0479535638296
0.0495515341899
0.0504040863179
0.0514000321569
0.0523668051573
0.0532394856057
0.0540151778012
0.0546651436143
0.0552238901606
0.0556841490763
0.0560576572903
0.0563543420351
0.0565863111581
0.0567549617095
0.0568851717135
0.056976268022
0.057039804929
0.125675176872
0.125657046713
0.125632933446
0.125593009602
0.125526484744
0.125447157177
0.125359435314
0.125260307962
0.1251422829
0.124998886881
0.124824754357
0.12461469862
0.12436360245
0.124066198874
0.123716358515
0.123310982974
0.12285180931
0.122336434894
0.121756981955
0.121101321157
0.120364190065
0.119543936745
0.118627219116
0.117591310721
0.116421779898
0.115127246095
0.113713577453
0.112132943683
0.110335391712
0.108283519384
0.105944111972
0.103363019174
0.10056108393
0.097463878351
0.0941170180173
0.0906338539825
0.0870309093297
0.0833084706148
0.0800747475425
0.0761133923312
0.0765883917671
0.076114064975
0.0757131390946
0.074978841228
0.0741266842853
0.0730738216224
0.0718661177605
0.0704953734693
0.0689764431195
0.0673168684292
0.0655296147015
0.0636273556731
0.0616312637149
0.0595566875312
0.057441936603
0.0553094454778
0.0531993958886
0.051198759068
0.0492618840541
0.0476554233289
0.0461519843151
0.0457447748497
0.0455479062919
0.045875751057
0.0470440372628
0.0486271499494
0.0499599844748
0.0511133807772
0.0521036887022
0.0529639908707
0.0537017633565
0.0543161801954
0.0548261390224
0.0552399934066
0.0555644202303
0.0558141428179
0.0559978047081
0.0561394346934
0.056233753356
0.056291899936
0.125545597059
0.125525668669
0.125500572246
0.125459732548
0.125394581627
0.125318867748
0.125239113339
0.125143798962
0.125023978417
0.124873643705
0.124688382162
0.124463392367
0.124194436225
0.123878307076
0.12351014427
0.123088736446
0.122614150376
0.122080357298
0.121478075022
0.12079958811
0.12004205385
0.119197585318
0.118251662034
0.117186076409
0.115994150754
0.114682289548
0.113236421668
0.111605667848
0.109740559891
0.107603512514
0.105192926295
0.102548130584
0.0996365553373
0.0964257827295
0.0930305567309
0.0895192850079
0.0858869883359
0.0820834746086
0.0786719375006
0.0746350538517
0.0751131326293
0.0746691861788
0.0742513136505
0.073504752278
0.072622893549
0.0715344663661
0.0702831329949
0.0688619029868
0.0672846565871
0.0655585476162
0.0636955321282
0.061707942166
0.0596168807793
0.0574378109171
0.0552149196266
0.0529673345916
0.0507534675944
0.0486646324589
0.0466508606993
0.0450430471967
0.0435957987593
0.0434514842444
0.0433162284448
0.0439352337191
0.0457245448272
0.0471576411263
0.0485720759532
0.0498721917874
0.0510094906308
0.0519626969872
0.0527737710354
0.0534494563382
0.0540083324739
0.0544630053409
0.0548156985944
0.0550863597702
0.0552910196635
0.0554415609959
0.0555429937062
0.0555936895387
0.125432777909
0.125414806609
0.12538758582
0.125341053925
0.12528109573
0.125219814515
0.125147297144
0.12505038303
0.124922815787
0.1247596123
0.124558331827
0.12431513684
0.124028824372
0.12369764055
0.123316770639
0.122883758691
0.122394703365
0.12184296016
0.121221170095
0.120523873642
0.119746357929
0.118880169497
0.117911860246
0.116826788916
0.115616576139
0.114281110013
0.112796783012
0.111111989137
0.109188570918
0.106995300122
0.104526526645
0.101797074918
0.0987724507894
0.0954884722027
0.0920663751502
0.0885291556123
0.0848690468642
0.0810411167993
0.0774376519526
0.0733817081521
0.0738537347029
0.0734295487039
0.0729815980508
0.0722104233973
0.0712890991518
0.070155730816
0.068851831052
0.0673710922757
0.0657256077209
0.0639214999597
0.0619688248104
0.0598786638051
0.0576706394963
0.0553598672561
0.0529950257754
0.0505905735572
0.0482315200427
0.0460076632188
0.0438697466204
0.042225759755
0.0407608001545
0.0406898996766
0.0407478453378
0.0426951226929
0.0440505699977
0.0456529058996
0.0471967436233
0.048635135892
0.0499245543491
0.0510132120211
0.0519099903371
0.0526463191501
0.0532506127673
0.0537466122432
0.0541371706033
0.0544343614495
0.0546563579701
0.054811997191
0.0549224796191
0.0549668396193
0.125330484124
0.125318723262
0.125292847786
0.125251695929
0.125206552696
0.125152110476
0.125074647858
0.124966378341
0.124822741739
0.124642309076
0.124426582068
0.124172151872
0.123876425269
0.123535245676
0.123144095377
0.122698969528
0.12219501715
0.121626216497
0.120986823461
0.120272696119
0.119478254675
0.118593968357
0.117606051836
0.116502808343
0.115277745138
0.113921202182
0.112401809038
0.110674846989
0.10869838925
0.106442587164
0.103916496747
0.101120006029
0.0980024712555
0.0946613876436
0.0912195343165
0.087664375309
0.0839869845819
0.0801237020043
0.0764325378115
0.0724519070401
0.0728513611576
0.0724148922029
0.0719183357084
0.0711077352923
0.0701364699241
0.0689487180212
0.0675836306132
0.0660352153489
0.0643127595153
0.0624204670363
0.0603653983983
0.0581560904426
0.0558088519231
0.0533374472023
0.0507913218724
0.0481782988711
0.0456171174761
0.0431852644247
0.040865527541
0.0391983109306
0.0377056245387
0.0375853697685
0.0378510643224
0.0393797314466
0.0417990479997
0.0439070222402
0.0457741735453
0.047422558065
0.0488711147309
0.0501034590317
0.0511117802001
0.0519219979979
0.052572643598
0.0531015681463
0.0535274569141
0.0538565474848
0.0541004402481
0.0542579285613
0.0543739279597
0.054420760665
0.125249537099
0.12524329803
0.125222792423
0.125192731266
0.125154712996
0.125093044011
0.125000288942
0.124876071586
0.124720890723
0.124533209893
0.124310068724
0.12404782525
0.123743073828
0.123391745677
0.122989248307
0.122530803547
0.122011886178
0.121427674065
0.120774185685
0.120047022072
0.119238332259
0.118338676769
0.117337290084
0.116223530879
0.114985947407
0.113607854612
0.112057864938
0.110291319966
0.108265780794
0.105965543252
0.103393913978
0.100509393625
0.0973113685704
0.0939458680288
0.0904865333533
0.0869274224818
0.0832650955651
0.0794437908176
0.0757591993747
0.0717238707918
0.072080561528
0.071629284872
0.071071769861
0.0702068191299
0.0691750029559
0.0679238329919
0.0664896864752
0.0648668901639
0.0630607983354
0.0610724771529
0.0589046109469
0.0565614515449
0.0540539051537
0.0513930182781
0.0486239777863
0.0457475868317
0.0429148365294
0.0401554249923
0.0375273754417
0.0358109230112
0.0344038220088
0.0346194617243
0.0350953142236
0.037606374508
0.0398732386144
0.0421963360476
0.0443408912925
0.0462491697681
0.0478910427506
0.0492674627698
0.0503922333757
0.0512881105845
0.05199160472
0.0525542491871
0.0530018741484
0.0533488732752
0.053614700583
0.0537873939031
0.0539026396148
0.0539653541049
0.125192388893
0.125187674354
0.125170546463
0.125145903914
0.125106348632
0.125030892231
0.124927373363
0.124797072538
0.124636204142
0.12444188343
0.124210995661
0.123940084631
0.123625539538
0.123263223762
0.122847975621
0.122375882549
0.121846071061
0.121254281751
0.120592976628
0.119855391715
0.119034607813
0.118123087698
0.117112195519
0.115990039542
0.114740260872
0.11334257034
0.111767111249
0.109968857444
0.107906652368
0.105567214652
0.10294015639
0.0999759633879
0.0967205922862
0.0933300333448
0.0898538264284
0.0862995409148
0.0826842684407
0.0790120689791
0.0753778941921
0.071221471819
0.0715410559181
0.0710896201602
0.0704625340912
0.0695219888626
0.0684141718469
0.0670893645317
0.0655790392861
0.0638773087723
0.0619841239638
0.0598956897258
0.0576084533898
0.055119847449
0.0524323549241
0.0495513582045
0.0465127247934
0.0433176058471
0.0401455426012
0.0369340883308
0.0338495019937
0.03181811676
0.0299697499346
0.0308783767761
0.0339813303015
0.0350902744032
0.037564206124
0.0403003216384
0.0428478696388
0.0450821305109
0.0469734674154
0.048520619623
0.0497634419836
0.0507487630036
0.0515100634931
0.0521061944071
0.0525804419838
0.0529426832479
0.0532159401277
0.0534043890093
0.0535254820615
0.0535993552583
0.125149561664
0.125143628184
0.125130929365
0.125108987698
0.125064064041
0.124979388792
0.124871236547
0.124735098309
0.124567760276
0.124366222121
0.124127239938
0.123847208439
0.123522418208
0.123148606414
0.122722472998
0.122244093524
0.121711456197
0.12111550147
0.120447050671
0.119699759286
0.118868205502
0.117947045789
0.116929886016
0.115802817434
0.114543199147
0.113128909042
0.111534027747
0.109714545588
0.107624745188
0.105246305297
0.10256585614
0.0995296409429
0.0962212729242
0.0928022794725
0.0892982720775
0.0857337780627
0.0821559896387
0.0786346070848
0.0753422920605
0.0712539084801
0.0713658522423
0.0708556460447
0.0701241165557
0.0690675593472
0.0678575186055
0.0664470023423
0.0648556447053
0.0630744158387
0.0610958661509
0.0589093417061
0.0565029612337
0.0538640434027
0.0509816039857
0.0478470694417
0.0444752957387
0.0408695408492
0.0372273731031
0.0334387205687
0.0300215431231
0.0278049060732
0.0247272462369
0.0253604898686
0.0284895444349
0.0313138155909
0.0346694216675
0.0381232191849
0.0412749796698
0.0439404460826
0.0461280198849
0.0478713125876
0.049237595146
0.0503059814172
0.0511259504909
0.0517517849812
0.0522487163505
0.0526362743349
0.0529225606383
0.0531179486106
0.0532375618459
0.0532970323949
0.125123851037
0.125118228145
0.125106165315
0.125080354629
0.125029447067
0.124941975283
0.124829897052
0.124687997652
0.124514225514
0.124305573105
0.124058886903
0.123770354556
0.123436004655
0.123053396956
0.122622110174
0.122142208647
0.121609185139
0.121010660756
0.120336017807
0.119580494301
0.11873969826
0.117810314047
0.116790732242
0.115664648384
0.114398845326
0.11296901758
0.111359943574
0.109533008668
0.107422640926
0.105003930292
0.102272054806
0.0991750387363
0.0958205116766
0.0923588509497
0.0888006007183
0.0851804981215
0.0815777196163
0.0782697793112
0.0758496202069
0.07213576198
0.071816299431
0.0709924483806
0.0700530941382
0.0688292456448
0.0674915591206
0.0659895510185
0.0643204278608
0.0624671852711
0.0604134844463
0.0581407320213
0.0556277206093
0.0528494330548
0.0497765125954
0.0463741663887
0.0426122020809
0.0384538244249
0.0340167419441
0.0292015717895
0.0253164593008
0.023270107044
0.0197058939933
0.0193474693801
0.0230180823898
0.0271608727276
0.0316371607594
0.0359286415895
0.0397536687685
0.0429076240245
0.0454181231813
0.0473532048597
0.048828506855
0.0499637175985
0.0508321477256
0.0514917953845
0.0520014788462
0.0523997684423
0.0526988000188
0.0529044442532
0.0530228187878
0.0530658506983
0.12511162443
0.125106417419
0.125088846526
0.12505730379
0.125006668081
0.124918856274
0.124803989392
0.124655826101
0.12447594113
0.124261848617
0.124010345711
0.123716063972
0.123375115754
0.122985906117
0.122549269109
0.122068961431
0.12153886752
0.120939534722
0.120260323183
0.119499269797
0.118649668773
0.117712893847
0.116700221128
0.11558599254
0.114315483808
0.112867470446
0.111242519165
0.10940849627
0.107296412808
0.10485241133
0.102068404622
0.0989274268152
0.0955333998438
0.0920176389303
0.0883726212994
0.0846071014669
0.0807368119761
0.0769826784946
0.0760208426813
0.0748302778647
0.0730180420647
0.0713834480719
0.0701287525814
0.0687396105257
0.06728624508
0.0657094990809
0.0639818608667
0.0620766781246
0.0599698757302
0.0576362913909
0.055047146517
0.0521668877909
0.0489491619919
0.0453303669404
0.0412230363198
0.0364942905027
0.0310098339042
0.0244327856915
0.0179335739148
0.0108175831513
0.00338416696283
0.0104359289756
0.0159024035576
0.0226539901865
0.0287393424497
0.0339982661276
0.0384874684644
0.0420991621666
0.0448953006195
0.0470140269213
0.0485589936881
0.0497143409704
0.0506149366362
0.051308359654
0.0518354522566
0.0522399912732
0.0525443255711
0.0527549786173
0.0528828999764
0.0529344237976
0.125107136
0.12510061333
0.125075408449
0.125040601149
0.124989573108
0.124914119417
0.124800466376
0.124644820985
0.124462214405
0.124247021626
0.123992923913
0.123693358513
0.123344089563
0.122945081474
0.122501884669
0.122025577947
0.121506898024
0.120913713673
0.120231136604
0.119465156899
0.118613382281
0.117676987643
0.116662822128
0.115547173176
0.114275868008
0.112819798369
0.1111851835
0.109347027674
0.107230090125
0.104768717858
0.101963227941
0.0988024827627
0.0953803018033
0.0918210778812
0.0880918404956
0.0841731529565
0.0796573431395
0.0776561686179
0.0763743016676
0.0745393996842
0.0737928815557
0.0717149564212
0.070192086248
0.0687170201233
0.067209454425
0.0655997750877
0.063847297744
0.0619204755105
0.0597917397556
0.0574330587479
0.0548123744401
0.0518894933497
0.0486103346844
0.0448973663018
0.0406331074337
0.0356231076512
0.0295344962087
0.0216287079574
0.0106962756894
-0.0103151409332
-0.0290774000069
-0.0144957653215
0.00700006801846
0.0184231853885
0.0265908075399
0.0327468375127
0.0377173777188
0.0416369420913
0.0446316564128
0.0468835922394
0.048456124318
0.049595576208
0.0504982158125
0.0512113694927
0.0517530592437
0.052161263801
0.052465862357
0.0526809240682
0.0528211515935
0.0528813179149
)
;
boundaryField
{
frontAndBack
{
type empty;
}
upperWall
{
type zeroGradient;
}
lowerWall
{
type zeroGradient;
}
inlet
{
type zeroGradient;
}
outlet
{
type fixedValue;
value uniform 0;
}
}
// ************************************************************************* //
| |
8d3001b0ce627a970955c790b4f7fda311d12670 | 768316ed72470715e641fda62a9166b610b27350 | /03-CodeChef-Medium/983--Mixtures.cpp | 609dd1058522024cbddd036a754c1c3f25e78145 | [] | no_license | dhnesh12/codechef-solutions | 41113bb5922156888d9e57fdc35df89246e194f7 | 55bc7a69f76306bc0c3694180195c149cf951fb6 | refs/heads/master | 2023-03-31T15:42:04.649785 | 2021-04-06T05:38:38 | 2021-04-06T05:38:38 | 355,063,355 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 619 | cpp | 983--Mixtures.cpp | #include<bits/stdc++.h>
using namespace std;
int arr[1000];
int dp[1001][1001];
int s(int a,int b)
{
int sum=0;
for(int i=a;i<=b;i++)
{
sum=(sum+arr[i])%100;;
}
return sum%100;
}
int solve(int i,int j)
{
if(i==j)
{
dp[i][j]=0;
return 0;
}
if(dp[i][j]!=-1)
return dp[i][j];
int ans=INT_MAX;
for(int k=i;k<j;k++)
{
ans=min(ans,solve(i,k)+solve(k+1,j)+s(i,k)*s(k+1,j));
}
dp[i][j]=ans;
return dp[i][j];
}
int main()
{
int n;
while(cin>>n)
{
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
memset(dp,-1,sizeof(dp));
cout<<solve(0,n-1)<<endl;
}
}
|
37938bf822e03c9a3de1e1f7cd85f47a05cd0c06 | 945df24a29a2e2be59252c1c90cd5f6c171ca463 | /初级算法/帕斯卡三角形.cpp | a20b1f6239156657a6744195fbcf73fef05b3de5 | [] | no_license | Ye1in/LeetCode | f1e9afe55bedfc709b583329b9e4d195cb095668 | 4d76367cafb1760e0b0a6613c3901d00db2f6055 | refs/heads/master | 2020-03-23T09:05:04.247174 | 2018-07-30T07:43:55 | 2018-07-30T07:43:55 | 141,366,275 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 960 | cpp | 帕斯卡三角形.cpp | #include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <set>
#include <assert.h>
#include <queue>
#include <math.h>
using namespace std;
// 给定一个非负整数 numRows,生成杨辉三角的前 numRows 行。
// 在杨辉三角中,每个数是它左上方和右上方的数的和。
// 示例:
// 输入: 5
// 输出:
// [
// [1],
// [1,1],
// [1,2,1],
// [1,3,3,1],
// [1,4,6,4,1]
// ]
class Solution
{
public:
vector<vector<int>> generate(int numRows)
{
vector<vector<int>> vv{};
for (int i = 0; i < numRows; ++i)
{
vector<int> v(i + 1, 0);
v.front() = 1;
v.back() = 1;
for (int j = 1; j < i; ++j)
v[j] = vv[i - 1][j - 1] + vv[i - 1][j];
vv.push_back(v);
}
return vv;
}
};
|
ba2c162c2b053d7eb4241c1103a1e5d45d2b5ded | c466c3d68e8330ce0c1527739c3919b55099da9f | /include/sets.h | 5f098e27341142ecb917e0e56d071d8ccc7c9dab | [] | no_license | pingyuan162/AMG_Methods | ef314f044593697dd30eb0598a9dd69d0825b6f1 | ec40fbb0b73dd26c0fad31b34cde9df07c87fb8c | refs/heads/master | 2021-05-25T12:58:15.088861 | 2017-06-20T14:10:29 | 2017-06-20T14:10:29 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,916 | h | sets.h | /**
* @file sets.h
* @author Laura Melas <laura.melas@mail.polimi.it>
* @date 2017
*
* This file is part of project "AMG Methods".
*
* @brief AMG methods for conforming and discontinuous Galerkin finite element discretizations of the Poisson problem.
*
*/
#ifndef SETS_INCLUDED
#define SETS_INCLUDED
#include "common.h"
/** @class sets
* @brief This class performs some properties and utilities of mathematical sets.
*
*
*/
class sets
{
public:
/**
* @brief Constructor (defaulted)
*
*/
sets()=default;
/**
* @brief Constructor
* @param[in] dim: cardinality of the set
*
*/
sets(const size_t& dim);
/**
* @brief Copy constructor
* @param[in] A: set to be copied
*
*/
sets(const sets& A);
/**
* @brief Destructor (defaulted)
*
*/
~sets(){}
/**
* @brief Definition of operator [], writing version
* @param[in] n: access position to an element of the set
* @param[out] set[n]: write element in the choosen position of the set
*
*/
inline int& operator[](const size_t& n){
if (n >= _set.size())
{
throw out_of_range("Index out of range.");
}
return _set[n];
}
/**
* @brief Definition of operator [], reading version
* @param[in] n: access position to an element of the set
* @param[out] set[n]: read element in the choosen position of the set
*
*/
inline const int& operator[](const size_t& n) const{
if (n >= _set.size())
{
throw out_of_range("Index out of range.");
}
return _set[n];
}
/**
* @brief Add an element in the set
* @param[in] s: element to be added
*
*/
void addElement(const int& s);
/**
* @brief Delete an element in the set
* @param[in] s: element to be deleted
*
*/
void deleteElement(const int& s);
/**
* @brief Check if an element is in the set
* @param[in] s: element to be found
* @param[out] 0,1 : 1 if s is in the set, 0 otherwise
*
*/
bool isMember(const int& s);
/**
* @brief Check if a set is empty
* @param[out] 0,1 : 1 if the set is empty, 0 otherwise
*
*/
bool isEmpty();
/**
* @brief Find the position of an element in the set
* @param[in] s: element to be found
* @param[out] d : position of the element
*
*/
int find_pos_set(const int& s);
/**
* @brief Cardinality of the set
*
*/
int cardinality();
/**
* @brief Union between two sets
* @param[out] U : union set between A and B
* @param[in] A,B : two sets
*
*/
static sets union_set(sets& A,sets& B);
/**
* @brief Difference between two sets
* @param[out] D : difference set between A and B (D=A-B)
* @param[in] A,B : two sets
*
*/
static sets diff_set(sets& A,sets& B);
/**
* @brief Intersection between two sets
* @param[out] I : intersection set between A and B
* @param[in] A,B : two sets
*
*/
static sets inter_set(sets& A,sets& B);
/**
* @brief Reorder the set
*
*/
void sort_set();
/**
* @brief Delete all element of the set
*
*/
void clear_set();
private:
vector<int> _set; /**< @brief definition of set */
};
#endif // SETS_INCLUDED
|
9596549c87af40cce96d77440ed286a2a6bc885a | b306f8a994ef88dc53b696ed6236759d750af051 | /Bison x86 Assembler Source/main.cpp | 2399cc17eebbe15e5ae279a5d1f195aee135b6be | [
"MIT"
] | permissive | kpatel122/Bison-x86-Assembler | b1a17e85a2852d7b03d4e72e28cfc3f3ebd35497 | 34d997306a5bf483ee3633126565017d1e2a5f92 | refs/heads/master | 2020-03-26T23:46:50.170294 | 2018-08-21T13:20:27 | 2018-08-21T13:20:27 | 145,566,662 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,328 | cpp | main.cpp | #include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include "token.h"
#include "instructions.h"
#include "file.h"
#include "log.h"
#include "String.h"
#include "lexer.h"
#include "functions.h"
#include "symbol.h"
#include "strings.h"
#include "label.h"
#include "script.h"
#include "parser.h"
#include "ASMParser.h"
#define ASM_FILE_IN "bspLoad.basm"
#define BXE_FILE_OUT "exes\\bspLoad.bxe"
CInstrTable instrTable;
void AddAllInstructions();
void PrintToken(int tok);
int numInvalidTokens = 0;
void main()
{
int instrIndex =0;
AddAllInstructions();
CLog log;
log.Init("log.txt");
/*
char *t = "\" abc \"";
char *k = (char*)malloc((sizeof(char)) * strlen(t));
strcpy(k,t);
cout<<"k before: "<<k<<"\n";
CStringInfo::RemoveStringQuotes(k);
cout<<"k After: "<<k<<"\n";
*/
CLexer lexer;
ASMParser parser;
lexer.InitLogFile(&log);
parser.InitLogFile(&log);
lexer.LoadASMFile(ASM_FILE_IN);
lexer.PrepFile();
lexer.AssignInstrTable(&instrTable);
parser.AssignLexer(&lexer);
char *lex;
int tok;
/*
cout<<"LEXEMES" <<"\n\n";
while(!(lexer.IsFileFinished()))
{
tok = lexer.GetNextToken();
lex = (char*)lexer.GetLexeme();
if(tok!=TOKEN_TYPE_NEWLINE)
{
cout <<"Lexeme: " <<lex<< " Token: "; PrintToken(tok); cout<<"\n";
}
else
{
cout<<"Token: "; PrintToken(tok); cout<<"\n";
}
}
*/
parser.Parse();
cout <<"\nlex errors: "<<numInvalidTokens<<" parse errors: "<<parser.GetErrors()<<endl;
parser.log->Msg("\nlex errors: %d parse errors: %d ",numInvalidTokens,parser.GetErrors() );
parser.PrintStats();
if (parser.GetErrors()==0)
{
parser.WriteASMFile(BXE_FILE_OUT);
}
cout<<"\npress any key then enter to quit."<<endl;
/*
to stop this demo from being just a flash on the screen in release mode
get some dummy input when everythings finished
*/
char dummy[10];
cin>>dummy;
}
/*
TOKEN_TYPE_QUOTE,
TOKEN_TYPE_NEWLINE,
*/
void PrintToken(int tok)
{
switch (tok)
{
case TOKEN_TYPE_NEWLINE:
{
cout<<"TOKEN_TYPE_NEWLINE";
}break;
case TOKEN_TYPE_INT:
{
cout<<"TOKEN_TYPE_INT";
}break;
case TOKEN_TYPE_FLOAT:
{
cout<<"TOKEN_TYPE_FLOAT";
}break;
case TOKEN_TYPE_STRING:
{
cout<<"TOKEN_TYPE_STRING";
}break;
case TOKEN_TYPE_IDENT:
{
cout<<"TOKEN_TYPE_IDENT";
}break;
case TOKEN_TYPE_COLON:
{
cout<<"TOKEN_TYPE_COLON";
}break;
case TOKEN_TYPE_OPEN_BRACKET:
{
cout<<"TOKEN_TYPE_OPEN_BRACKET";
}break;
case TOKEN_TYPE_CLOSE_BRACKET:
{
cout<<"TOKEN_TYPE_CLOSE_BRACKET";
}break;
case TOKEN_TYPE_COMMA:
{
cout<<"TOKEN_TYPE_COMMA";
}break;
case TOKEN_TYPE_OPEN_BRACE:
{
cout<<"TOKEN_TYPE_OPEN_BRACE";
}break;
case TOKEN_TYPE_CLOSE_BRACE:
{
cout<<"TOKEN_TYPE_CLOSE_BRACE";
}break;
case TOKEN_TYPE_INSTR:
{
cout<<"TOKEN_TYPE_INSTR";
}break;
case TOKEN_TYPE_SETSTACKSIZE:
{
cout<<"TOKEN_TYPE_SETSTACKSIZE";
}break;
case TOKEN_TYPE_VAR:
{
cout<<"TOKEN_TYPE_VAR";
}break;
case TOKEN_TYPE_FUNC:
{
cout<<"TOKEN_TYPE_FUNC";
}break;
case TOKEN_TYPE_PARAM:
{
cout<<"TOKEN_TYPE_PARAM";
}break;
case TOKEN_TYPE_INVALID:
{
cout<<"*************Tis is bad************";
numInvalidTokens++;
}break;
case TOKEN_TYPE_REG_RETVAL:
{
cout<<"TOKEN_TYPE_REG_RETVAL";
}break;
default:
cout<<"This really shouldnt happen";
}
}
void AddAllInstructions()
{
int instrIndex = 0;
instrIndex = instrTable.AddInstr("MOV",INSTR_MOV,2);
instrTable.SetInstrOp(instrIndex,0,OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp(instrIndex,1,OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrIndex = instrTable.AddInstr("ADD", INSTR_ADD, 2 );
instrTable.SetInstrOp(instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp(instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Sub Destination, Source
instrIndex = instrTable.AddInstr( "SUB", INSTR_SUB, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
////////////////////////////////////////////////////////////////////////////////
// Mul Destination, Source
instrIndex = instrTable.AddInstr ( "MUL", INSTR_MUL, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Div Destination, Source
instrIndex = instrTable.AddInstr ( "DIV", INSTR_DIV, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Mod Destination, Source
instrIndex = instrTable.AddInstr ( "MOD", INSTR_MOD, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Exp Destination, Source
instrIndex = instrTable.AddInstr ( "EXP", INSTR_EXP, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Neg Destination
instrIndex = instrTable.AddInstr ( "NEG", INSTR_NEG, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Inc Destination
instrIndex = instrTable.AddInstr ( "INC", INSTR_INC, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Dec Destination
instrIndex = instrTable.AddInstr ( "DEC", INSTR_DEC, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// ---- Bitwise
// And Destination, Source
instrIndex = instrTable.AddInstr ( "AND", INSTR_AND, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Or Destination, Source
instrIndex = instrTable.AddInstr ( "OR", INSTR_OR, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// XOr Destination, Source
instrIndex = instrTable.AddInstr ( "XOR", INSTR_XOR, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Not Destination
instrIndex = instrTable.AddInstr ( "NOT", INSTR_NOT, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// ShL Destination, Source
instrIndex = instrTable.AddInstr ( "SHL", INSTR_SHL, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// ShR Destination, Source
instrIndex = instrTable.AddInstr ( "SHR", INSTR_SHR, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// ---- String Manipulation
// Concat String0, String1
instrIndex = instrTable.AddInstr ( "CONCAT", INSTR_CONCAT, 2 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG |
OP_FLAG_TYPE_STRING );
// GetChar Destination, Source, Index
instrIndex = instrTable.AddInstr ( "GETCHAR", INSTR_GETCHAR, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG |
OP_FLAG_TYPE_STRING );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG |
OP_FLAG_TYPE_INT );
// SetChar Destination, Index, Source
instrIndex = instrTable.AddInstr ( "SETCHAR", INSTR_SETCHAR, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG |
OP_FLAG_TYPE_INT );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG |
OP_FLAG_TYPE_STRING );
// ---- Conditional Branching
// Jmp Label
instrIndex = instrTable.AddInstr ( "JMP", INSTR_JMP, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_LINE_LABEL );
// JE Op0, Op1, Label
instrIndex = instrTable.AddInstr ( "JE", INSTR_JE, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_LINE_LABEL );
// JNE Op0, Op1, Label
instrIndex = instrTable.AddInstr ( "JNE", INSTR_JNE, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_LINE_LABEL );
// JG Op0, Op1, Label
instrIndex = instrTable.AddInstr ( "JG", INSTR_JG, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_LINE_LABEL );
// JL Op0, Op1, Label
instrIndex = instrTable.AddInstr ( "JL", INSTR_JL, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_LINE_LABEL );
// JGE Op0, Op1, Label
instrIndex = instrTable.AddInstr ( "JGE", INSTR_JGE, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_LINE_LABEL );
// JLE Op0, Op1, Label
instrIndex = instrTable.AddInstr ( "JLE", INSTR_JLE, 3 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 1, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
instrTable.SetInstrOp( instrIndex, 2, OP_FLAG_TYPE_LINE_LABEL );
// ---- The Stack Interface
// Push Source
instrIndex = instrTable.AddInstr ( "PUSH", INSTR_PUSH, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Pop Destination
instrIndex = instrTable.AddInstr ( "POP", INSTR_POP, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// ---- The Function Interface
// Call FunctionName
instrIndex = instrTable.AddInstr ( "CALL", INSTR_CALL, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_FUNC_NAME );
// Ret
instrIndex = instrTable.AddInstr ( "RET", INSTR_RET, 0 );
// CallHost FunctionName
instrIndex = instrTable.AddInstr ( "CALLHOST", INSTR_CALLHOST, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_HOST_API_CALL );
// ---- Miscellaneous
// Pause Duration
instrIndex = instrTable.AddInstr ( "PAUSE", INSTR_PAUSE, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
// Exit Code
instrIndex = instrTable.AddInstr ( "EXIT", INSTR_EXIT, 1 );
instrTable.SetInstrOp( instrIndex, 0, OP_FLAG_TYPE_INT |
OP_FLAG_TYPE_FLOAT |
OP_FLAG_TYPE_STRING |
OP_FLAG_TYPE_MEM_REF |
OP_FLAG_TYPE_REG );
} |
7784006568100a22967fa8d7c3047a5c5b3b7df4 | 1187b42bd08c1be389272dce452406e57ed78f64 | /sapfor/experts/Sapfor_2017/_src/DynamicAnalysis/createParallelRegions.h | 6b6f864e58166909631da3ec09dd8ee640aa7ad7 | [] | no_license | koldeen/Sapfor2 | 2b784a12400bdeb919a6e7a6c3df54ec94d7f86b | 6ab55f3ed3ef4d741dc3fa291aaf4fb15111df7d | refs/heads/master | 2023-05-28T06:26:54.435944 | 2021-03-18T07:19:45 | 2021-03-18T07:19:45 | 371,909,819 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 816 | h | createParallelRegions.h | #pragma once
#include "../Utils/utils.h"
#include "./gcov_info.h"
#include "../CreateInterTree/CreateInterTree.h"
#include "../GraphCall/graph_calls.h"
#include <map>
#include <vector>
struct SpfRegion
{
int id;
double time;
SgStatement *start;
SgStatement *end;
SpfRegion(int id_, int time_, SgStatement *start_, SgStatement *end_) :
id(id_), time(time_), start(start_), end(end_) {}
SpfRegion& operator+=(const SpfRegion &rg)
{
if (this != &rg)
{
end = rg.end;
time += rg.time;
}
return *this;
}
};
void createParallelRegions(SgProject *project, SpfInterval *mainInterval, const std::map<std::string, std::map<int, Gcov_info>> &gCovInfo, const std::map<std::string, std::vector<FuncInfo*>> &funcInfo); |
4c623ebae639a39b9c1568e412726162fed1e4ed | 4833b1a4333c4063ee24d6f01047dc831488b4ef | /DirectXNet/pch.h | 8922c1112b6713e3086c681f61b663ccf3571071 | [] | no_license | SansyHuman/DirectXNet | 96278a2c5ad827368b1e4fdf9d4b29ab4ed63504 | d30b550a5d06e3d9de0a76aa865b145827240d06 | refs/heads/master | 2023-08-18T14:58:19.120992 | 2021-10-15T02:31:40 | 2021-10-15T02:31:40 | 403,059,162 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,196 | h | pch.h | // pch.h: 미리 컴파일된 헤더 파일입니다.
// 아래 나열된 파일은 한 번만 컴파일되었으며, 향후 빌드에 대한 빌드 성능을 향상합니다.
// 코드 컴파일 및 여러 코드 검색 기능을 포함하여 IntelliSense 성능에도 영향을 미칩니다.
// 그러나 여기에 나열된 파일은 빌드 간 업데이트되는 경우 모두 다시 컴파일됩니다.
// 여기에 자주 업데이트할 파일을 추가하지 마세요. 그러면 성능이 저하됩니다.
#ifndef PCH_H
#define PCH_H
// 여기에 미리 컴파일하려는 헤더 추가
#include <Windows.h>
#include <msclr/marshal.h>
#include <msclr/auto_handle.h>
#include <vector>
#include <cstring>
#include <dxgi1_6.h>
#include <dxgidebug.h>
#include <d3dcompiler.h>
#include <d3d12.h>
#include <DirectXMath.h>
#include <DirectXPackedVector.h>
#include <dcommon.h>
#include <d2d1_3.h>
#include <d2d1helper.h>
#include <d2d1_1helper.h>
#include <d2d1_2helper.h>
#include <d2d1_3helper.h>
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) if(p != __nullptr) { p->Release(); p = __nullptr; }
#endif
#ifndef CAST_TO
#define CAST_TO(obj, to) *((to ## *)&(obj))
#endif
#endif //PCH_H
|
3df439c96ac3fd6c540fed7742f47c8e654f659b | 59c21d66282df06f3cd28c14cbd962bb894911ad | /10370.cpp | d61d1a16a75e97792eaeab30aec65749d209acf9 | [] | no_license | sha443/UVa | c9fabca12d0f31dcd5753f6add5028cb41e94ff8 | 45c20c8fb809c13b72706d20b9fc7795de57926e | refs/heads/master | 2021-09-24T09:44:28.724123 | 2018-07-14T14:10:33 | 2018-07-14T14:10:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 518 | cpp | 10370.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t,n;
cin>>t;
for(int i=1;i<=t;i++)
{
int S[1001];
double sum = 0,avg;
cin>>n;
for(int j=0;j<n;j++)
{
cin>>S[j];
sum+=S[j];
}
avg = sum/n;
int above =0;
for(int j=0;j<n;j++)
{
if(S[j]>avg)
{
above++;
}
}
printf("%.3lf%%\n", (double) above / (double) n*100.0);
}
}
|
33f33060814647396cc06eb3e92fb1715237aade | 5a245a7fd8205a7937b8d4d318a74c19c676a7d1 | /transaction.cpp | addf7b7d1529256274c6a85f3adff351ea616d3c | [] | no_license | marekprog/personal_budget | 9a655a7a15c5410461de52abc8f741d2fe843b0a | e941fc33f022cabc9bf9740574a3bb6a88699699 | refs/heads/master | 2020-05-21T06:09:36.085933 | 2019-05-23T15:16:44 | 2019-05-23T15:16:44 | 185,938,104 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 264 | cpp | transaction.cpp | #include "transaction.h"
Transaction::Transaction()
{
}
void Transaction::printMap()
{
cout<<endl;
for (auto const& x : itemList)
{
cout << x.first // string (key)
<< ". "
<< x.second // string's value
<< endl ;
}
}
|
2759d96472ad1c5428c6975591cfe8e54b5d80e9 | e542522d4bcddbe88a66879a7183a73c1bbdbb17 | /Codeforces/Rounds/Div3/702/G/solve.cpp | 7e6b3c646388880c11426020c54281bd742c453a | [] | no_license | ishank-katiyar/Competitive-programming | 1103792f0196284cf24ef3f24bd243d18536f2f6 | 5240227828d5e94e2587d5d2fd69fa242d9d44ef | refs/heads/master | 2023-06-21T17:30:48.855410 | 2021-08-13T14:51:53 | 2021-08-13T14:51:53 | 367,391,580 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,633 | cpp | solve.cpp | #include <bits/stdc++.h>
using namespace std;
string to_string(string s) {
return '"' + s + '"';
}
string to_string(const char* ch) {
return to_string((string)ch);
}
string to_string(char ch) {
return (string)"'" + ch + (string)"'";
}
string to_string(bool b) {
return (b ? "true" : "false");
}
template<class A, class B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template<class A>
string to_string(A a) {
string res = "{";
bool first = true;
for(const auto& x: a) {
if(first == false) res += ", ";
first = false;
res += to_string(x);
}
res += "}";
return res;
}
void debug() {cerr << "]\n";}
template<class H, class... T>
void debug(H head, T... tail) {
cerr << to_string(head) << " ";
debug(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << " ] = ["; debug(__VA_ARGS__);
#else
#define debug(...)
#endif
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int64_t n, m;
cin >> n >> m;
vector <int64_t> a (n);
int64_t sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum += a[i];
}
vector <pair<int64_t, int64_t>> pre (n);
pre[0].first = a[0];
pre[0].second = 1;
for (int i = 1; i < n; i++) {
pre[i].first += pre[i - 1].first + a[i];
pre[i].second = i + 1;
}
sort (pre.begin(), pre.end(), [](const pair <int64_t, int64_t> A, const pair <int64_t, int64_t> B) -> bool {
if (A.first != B.first) return A.first < B.first;
return A.second < B.second;
});
vector<int64_t> sufindex (n);
sufindex[n - 1] = pre[n - 1].second;
for (int i = n - 2; i >= 0; i--) {
sufindex[i] = min (sufindex[i + 1], pre[i].second);
}
vector<int64_t> pp (n);
for (int i = 0; i < n; i++) {
pp[i] = pre[i].first;
}
debug (pre, pp);
for (int i = 0; i < m; i++) {
int64_t x;
cin >> x;
if (x > pp.back()) {
int64_t ans = 0;
if (sum > 0) {
x -= pp[n - 1];
int64_t moves = (x / sum) + (x % sum != 0);
ans += moves * n;
x += pp[n - 1];
x -= moves * sum;
assert (x <= pp[n - 1]);
if (x > 0) {
int64_t idx = static_cast <int64_t> (lower_bound (pp.begin(), pp.end(), x) - pp.begin());
debug (idx);
assert (idx != n);
ans += sufindex[idx] - 1;
} else {
ans -= 1;
}
} else {
ans = -1;
}
cout << ans << ' ';
} else {
int64_t idx = static_cast <int64_t> (lower_bound (pp.begin(), pp.end(), x) - pp.begin());
assert (idx != n);
cout << sufindex[idx] - 1 << ' ';
}
}
cout << '\n';
}
return 0;
}
|
faf3edd7632e6bab258ed54c7a33fafaf10a2006 | 594ecd45a7f7696d89facb84e2ad3d5d5460be11 | /AStarWithJps.cpp | 1a09e1ce5160c7802e64a55843ab23e3c73f563f | [] | no_license | Angel69Devil/AStarWithJps | 1824d2ca12dc5eb0ec1a481c85f495ae29cb1df0 | 4904b0002e99eb9925a1b1db9154abb14294e3f1 | refs/heads/master | 2020-06-22T03:10:29.035946 | 2014-04-03T03:10:34 | 2014-04-03T03:41:56 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,664 | cpp | AStarWithJps.cpp | #include "AStarWithJps.h"
#include <cmath>
#include <algorithm>
#include <cassert>
//jps算法,主要减少了A*的open表的长度。参见:
//http://users.cecs.anu.edu.au/~dharabor/data/papers/harabor-grastien-aaai11.pdf
//原作者官网:http://harablog.wordpress.com/2011/09/07/jump-point-search/
//中文版解释:http://plusplus7.com/lemonbag/jpsstudy
//英文版解释,推荐:http://zerowidth.com/2013/05/05/jump-point-search-explained.html
//Lua源代码参考:https://github.com/Yonaba/Jumper
void AStarWithJps::expandSuccessors(const NodeSavingF* node){
findNeighbours(node);
//查找跳点
for(std::vector<NodeSavingF*>::reverse_iterator it = ret.rbegin(); it != ret.rend(); ++it){
bool skip = false;
NodeSavingF* neighbour = *it;
NodeSavingF* jumpNode = jump(neighbour, node, m_end);
if(jumpNode){
insertNodeToOpen(jumpNode, node);
}
}
}
void AStarWithJps::findNeighbours(const NodeSavingF* node){
if(node->getParent() == NULL){//没有父节点,一般来说,只可能是因为,本node为start节点
AStar::expandSuccessors(node);//那么,使用父类的expandSuccessors就可以了
}
const int x = node->getX();
const int y = node->getY();//缓存自己的坐标。
const int ddx = x - node->getParent()->getX();
assert(std::abs(ddx) <= 1);
const int dx = ddx;//; / std::max(std::abs(ddx), 1);//我们的程序中,邻居总是跟它的父节点相差『1,1』。
const int ddy = y - node->getParent()->getY();
assert(std::abs(ddy) <= 1);
const int dy = ddy;
assert(dx != 0 || dy != 0);//邻居
if(dx != 0 && dy != 0){//斜线方向
//自然邻居
bool walkY = addNeighbours_Diagonal_Natural(x, y+dy);
bool walkX = addNeighbours_Diagonal_Natural(x+dx, y);
if(walkX || walkY){
ret.push_back(m_map->getNode(x+dx, y+dy));//原算法这里没有判断有没有阻挡。不知道为什么。
//addNeighbours_Diagonal_DiagonalNatural(x+dx, y+dy);这是我认为的,需要判断阻挡的操作。先注释掉。以后看看有没有用
}
//强制邻居
addNeighbours_Diagonal_Force(x-dx, y, x-dx, y+dy, walkY);
addNeighbours_Diagonal_Force(x, y-dy, x+dx, y-dy, walkY);
}
else{
if(dx != 0){//x方向
//自然邻居
addNeighbours_Directional_Natural(x + dx, y);
//看看有没有强制邻居。
addNeighbours_Directional_Force(x, y+1, x+dx, y+1);
addNeighbours_Directional_Force(x, y-1, x+dx, y-1);
}
else{//y方向
assert(dy != 0);
//自然邻居
addNeighbours_Directional_Natural(x, y + dy);
//看看有没有强制邻居。
addNeighbours_Directional_Force(x+1, y, x+1, y+dy);
addNeighbours_Directional_Force(x-1, y, x-1, y+dy);
}
}
}
NodeSavingF* AStarWithJps::jump(NodeSavingF* node, const NodeSavingF* parent, const NodeSavingF* endNode) const
{
if( node == NULL || node->isBlock())//如果本节点不存在或者是阻挡点,就不能跳
return NULL;
const int x = node->getX();
const int y = node->getY();//缓存自己的坐标。
const int dx = x - node->getParent()->getX();
const int dy = y - node->getParent()->getY();
/*if(!m_map->isWalkableAt(x,y){//再开头已经判断过了
return NULL;
}*/
if(node == endNode){//等于终止节点,停止搜索
return node;
}
if(dx != 0 && dy != 0){//斜向
//本节点是跳点,如果左右方向邻居是强制邻居(至少一个是就可以了)
if(m_map->isWalkableAt(x-dx, y+dy) && !m_map->isWalkableAt(x-dx, y)
|| m_map->isWalkableAt(x+dx, y-dy) && !m_map->isWalkableAt(x, y-dy)
){
return node;
}
}
else{
if(dx != 0){//x方向:
//上下2个邻居有一个是强制邻居,则此节点为跳点
if(m_map->isWalkableAt(x+dx, y+1) && !m_map->isWalkableAt(x, y+1)
|| m_map->isWalkableAt(x+dx, y-1) && !m_map->isWalkableAt(x, y-1)
){
return node;
}
}
else{//y方向:
//左右2个邻居有一个是强制邻居,则此节点为跳点
if(m_map->isWalkableAt(x+1, y+dy) && !m_map->isWalkableAt(x+1, y)
|| m_map->isWalkableAt(x-1, y+dy) && !m_map->isWalkableAt(x-1, y)
){
return node;
}
}
}
//斜向的话还需要递归检查直向节点是不是跳点
if(dx != 0 && dy != 0){//斜向
if(jump(m_map->getNode(x+dx, y), node, endNode) != NULL){
return node;//注意,返回的不是递归搜索到的点,而是自己
}
if(jump(m_map->getNode(x, y+dy), node, endNode) != NULL){
return node;//注意,返回的不是递归搜索到的点,而是自己
}
}
//递归斜向搜索
if(m_map->isWalkableAt(x+dx, y) || m_map->isWalkableAt(x, y+dy)){
return jump(m_map->getNode(x+dx, y+dy), node, endNode);
}
//什么也没有找到,返回错误。
return NULL;
} |
2a11f31fcf2381bba78ca6a0574493d7033fb933 | 4d8f7b7fe6e4b8f8bc772339bd187960d3e01e2b | /tutorials/week08/starter/unit_testing/ex02/mock/rangermocklaser.h | 0ed84594a6171506d2c89e10b73463b402522f3c | [] | no_license | ajalsingh/PFMS-A2020 | 1dd2c18691ac48867d07d062114b49b029c7004b | e52a5e1677b6d0c5b309dbeec8e125c0ac19d857 | refs/heads/master | 2023-05-29T04:08:48.327745 | 2021-06-08T08:04:16 | 2021-06-08T08:04:16 | 275,065,349 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 808 | h | rangermocklaser.h | #ifndef RANGERMOCKLASER_H
#define RANGERMOCKLASER_H
#include "../../rangerinterface.h"
#include "../../laser.h"
#include <vector>
class RangerMockLaser: public Laser
{
public:
RangerMockLaser();
//First three are for ares, offset, fov - last is for mock data
RangerMockLaser(unsigned int fov, unsigned int ares, int offset, std::vector<double> mockData);
unsigned int getAngularResolution(void);
int getOffset(void);
unsigned int getFieldOfView(void);
bool setAngularResolution(unsigned int);
bool setOffset(int);
bool setFieldOfView(unsigned int);
SensingMethod getSensingMethod(void);
std::vector<double> generateData();
protected:
unsigned int fieldOfView_;
unsigned int angularResolution_;
int offset_;
std::vector<double> mockData_;
};
#endif // RANGERMOCKLASER_H
|
cbb37830890c629d7091c16898e4e720f0820179 | 2cd26645822de84bfd5dfcfbc19f8cca4e25f2b5 | /Projects/ColonyAI/src/water.cpp | cdc00e467cd57c93f0d1cad43fd6c3dfde6d92cf | [] | no_license | P14141609/FYP_ColonyAI | dfc15737b30b90066caaeadde2babee4bef1f454 | dfd65ffcf1615b28b06b7e1dff02d6bc8012f9cb | refs/heads/master | 2021-03-22T00:33:48.411761 | 2017-04-02T15:00:37 | 2017-04-02T15:00:37 | 72,354,078 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 922 | cpp | water.cpp | /**
@file water.cpp
*/
// Imports
#include "water.h"
// Constructor
Water::Water(std::shared_ptr<Environment> pEnv, const sf::Vector2f kPosition, const float kfRadius)
{
// Defines the ObjectType
m_type = WATER;
// Sets member values to corresponding input
m_pEnvironment = pEnv;
m_position = kPosition;
m_fRadius = kfRadius;
}
// Void: Called to draw the Rock
void Water::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
// Declares new CircleShape to draw
sf::CircleShape circle;
// Sets the origin to the center of the circle
circle.setOrigin(sf::Vector2f(m_fRadius, m_fRadius));
// Sets the circle pos to position member
circle.setPosition(sf::Vector2f(m_position));
// Sets the circle radius to radius member
circle.setRadius(m_fRadius);
// Sets circle colour: Grey RGB for rock
circle.setFillColor(sf::Color(0, 0, 255, 255));
// Draws circle to target
target.draw(circle);
} |
b3a9030873fcbee957a49addd279cdc8cba18791 | f5dddb977c183033d4b846a923bd065c59cb8a4a | /trifal/trifal/main.cpp | c7a114ede2f5eb275554a7884d4e4b2698bf5e7a | [] | no_license | Luffky/clrs | da54871efc048f60e7867c41604adf33a01d0621 | da2158cd703a59d8cb55f148326fae0f3aad871e | refs/heads/master | 2021-08-11T19:14:31.212857 | 2017-11-14T03:09:08 | 2017-11-14T03:09:08 | 110,629,889 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 880 | cpp | main.cpp | //
// main.cpp
// trifal
//
// Created by 伏开宇 on 2017/4/7.
// Copyright © 2017年 伏开宇. All rights reserved.
//
#include <iostream>
#include <math.h>
using namespace std;
#define N 6;
#define M 3;
int total = 0;
bool isprime(int a)
{
for(int i=2;i<=sqrt(a);i++)
if(a%i==0) return false;
return true;
}
void s(int x, int t, int z, int* a){
if(x <= N){
if(t != M){
if(x != N)
s(x + 1, t + 1, z + a[x], a);
}
else if(!isprime(z)){
if(x != N)
s(x + 1, t, z - a[x - 1] + a[x], a);
}
else{
if(x != N)
s(x + 1, t, z - a[x - 1] + a[x], a);
total++;
cout<<z<<endl;
}
}
}
int main(int argc, const char * argv[]) {
// insert code here...
std::cout << "Hello, World!\n";
return 0;
}
|
8464d3aa83e9987c1417a5e3dbbfe3f42ccef31b | 2e4fa9d9071171d740a2c50a14cf41244ab31f12 | /solutions/0009. Palindrome Number.cpp | 30d2875c3b78c083e4b7d284441f3072a89f19cf | [] | no_license | SakibulMowla/leetcode-solutions | d846046af8d520a62cf8e67726df3ff8e0ea9c8f | afc39f5bc04d8436a2c6d4d8dde22802989660d2 | refs/heads/master | 2023-06-09T01:33:49.422869 | 2023-05-25T18:03:06 | 2023-05-25T18:03:06 | 168,779,500 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 380 | cpp | 0009. Palindrome Number.cpp | class Solution {
public:
bool isPalindrome(int x) {
if (x < 0 || (x % 10 == 0 && x != 0)) {
return false;
}
int revertedHalf = 0;
while (x > revertedHalf) {
revertedHalf = revertedHalf * 10 + (x % 10);
x /= 10;
}
return x == revertedHalf || x == revertedHalf / 10;
}
};
|
eb14d6b301e7d232863c63d1380b9ced3e2fd3d5 | c71b6f51eb3ce04d37f414e49c8a59b32d58e3b9 | /kick_19_C1YP.cpp | 3703528bfce00521a1326bed956f3949bee24643 | [] | no_license | yashica-patodia/Google-Kickstart | b1c18dd8315c6ff6ed68f35f5c9d8f8c3096b1f5 | 3afee8316ae809a29d5ce127061df7e814e69257 | refs/heads/master | 2022-07-19T12:47:49.939785 | 2020-05-23T04:54:30 | 2020-05-23T04:54:30 | 255,468,325 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 705 | cpp | kick_19_C1YP.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
int temp=t;
int n,r,c,sr,sc;
while(t--)
{
cin>>n>>r>>c>>sr>>sc;
string s;
cin>>s;
sr=sr-1;
sc=sc-1;
bool vis[r+1][c+1];
memset(vis,0,sizeof(vis));
vis[sr][sc]=1;
int i;
for(i=0;i<s.length();i++)
{
if(s[i]=='N')
{
while(vis[sr-1][sc]!=0)
sr--;
sr--;
vis[sr][sc]=1;
}
if(s[i]=='S')
{
while(vis[sr+1][sc]!=0)
sr++;
sr++;
vis[sr][sc]=1;
}
if(s[i]=='E')
{
while(vis[sr][sc+1]!=0)
sc++;
sc++;
vis[sr][sc]=1;
}
if(s[i]=='W')
{
while(vis[sr][sc-1]!=0)
sc--;
sc--;
vis[sr][sc]=1;
}
}
cout<<"Case #"<<temp-t<<": "<<sr+1<<" "<<sc+1<<endl;
}
} |
fef214932fd5d3def659291ee9e6828e68e811d1 | ff3e7df8793966b070419c80131040196c8abe1c | /AI Protoss/ExampleAIModule/Assimilator.cpp | fb5bcd7301c87d59eaf95acd77434f8597f78fb9 | [] | no_license | antoineDelmotte/sc-bw_stmn-ai | 6e87e22840fbb48e0b9516ed121760f093aeab2b | 6a3cc7f179a24a9e6a78858f78ac9fcce8277af4 | refs/heads/master | 2020-06-23T07:11:23.174269 | 2017-05-15T16:04:41 | 2017-05-15T16:04:41 | 74,662,591 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 443 | cpp | Assimilator.cpp | #include "Assimilator.h"
#include <BWAPI.h>
#include "Master.h"
std::vector<Assimilator*> Assimilator::Assimilators;
Assimilator::Assimilator(BWAPI::Unit u) : StarcraftUnit(u)
{
}
Assimilator::~Assimilator()
{
}
void Assimilator::Update()
{
if (m_unit->isBeingConstructed())
return;
if (!m_unit->exists())
{
Assimilator::Assimilators.erase(std::find(Assimilator::Assimilators.begin(), Assimilator::Assimilators.end(), this));
}
}
|
95dfe8ae7407d9a43786d622a1df6d0e50a789a4 | a8f2b90b92ec5c38b0607a2b7e8e96eb86800be1 | /include/pyfbsdk/pyfbfilereference.h | 2fbb4a4e512074b7c01827b2bdc549d87019c096 | [] | no_license | VRTRIX/VRTRIXGlove_MotionBuilder_Plugin | 27703a15bd68460095034c7b50d6078c8dad2ad8 | 8acee1c8d6786e9d580f55d8e2e2d41283274257 | refs/heads/master | 2023-05-01T03:00:17.419854 | 2021-11-25T08:05:13 | 2021-11-25T08:05:13 | 204,840,760 | 6 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,203 | h | pyfbfilereference.h | #ifndef pyfbfilereference_h__
#define pyfbfilereference_h__
/**************************************************************************
Copyright 2010 Autodesk, Inc.
All rights reserved.
Use of this software is subject to the terms of the Autodesk license agreement
provided at the time of installation or download, or which otherwise accompanies
this software in either electronic or hard copy form.
**************************************************************************/
#include <kaydaradef.h>
#ifndef PYSDK_DLL
/** \def PYSDK_DLL
* Be sure that PYSDK_DLL is defined only once...
*/
#define PYSDK_DLL K_DLLIMPORT
#endif
#include "pyfbarraytemplate.h"
#include "pyfbnamespace.h"
#include "pyfbstringlist.h"
// =======================================================================================
// FBFileReference
// =======================================================================================
void FBFileReference_Init();
class PYSDK_DLL FBFileReference_Wrapper : public FBNamespace_Wrapper {
public:
FBFileReference* mFBFileReference;
public:
FBFileReference_Wrapper( FBComponent* pFBComponent ) : FBNamespace_Wrapper( pFBComponent ) { mFBFileReference = (FBFileReference*)pFBComponent; }
FBFileReference_Wrapper( const char* pName, FBNamespace_Wrapper* pParentNS ) : FBNamespace_Wrapper( new FBFileReference( pName, pParentNS ? pParentNS->mFBNamespace : NULL)) { mFBFileReference = (FBFileReference*)mFBComponent; }
virtual ~FBFileReference_Wrapper() {}
void FBDelete() { mFBFileReference->FBDelete(); }
bool BakeRefEditToFile(const char* pFilePath) { return mFBFileReference->BakeRefEditToFile(pFilePath); }
void RevertRefEdit(FBPlug_Wrapper* pPlug = NULL, FBPlugModificationFlag pModificationFlag = kFBAllModifiedMask) { mFBFileReference->RevertRefEdit( pPlug ? pPlug->mFBPlug : NULL, pModificationFlag); }
void ApplyRefEditPyScriptFromFile( const char* pRefEditPyScriptFilePath ) { return mFBFileReference->ApplyRefEditPyScriptFromFile( pRefEditPyScriptFilePath ); }
void ApplyRefEditPyScriptFromString( const char* pRefEditPyScript ) { return mFBFileReference->ApplyRefEditPyScriptFromString( pRefEditPyScript ); }
bool DuplicateFileRef(FBStringList_Wrapper& pDstNameSpaceList, bool pWithRefEdit = false) { return mFBFileReference->DuplicateFileRef( *(pDstNameSpaceList.mFBStringList), pWithRefEdit);}
const char* GetRefEdit( const char* pFilePath = NULL) { return mFBFileReference->GetRefEdit(pFilePath); }
bool ClearRefEdit(const char* pFilePath) { return mFBFileReference->ClearRefEdit(pFilePath); }
bool ClearAllRefEdit() { return mFBFileReference->ClearAllRefEdit(); }
bool SwapReferenceFilePath(const char* pFilePath, bool pApplyAvailableRefEdit = true, bool pMergeCurrentRefEdit = true) { return mFBFileReference->SwapReferenceFilePath(pFilePath, pApplyAvailableRefEdit, pMergeCurrentRefEdit); }
void GetRefFileList(FBStringList_Wrapper& pRefFileList) const { mFBFileReference->GetRefFileList(*(pRefFileList.mFBStringList)); }
DECLARE_ORSDK_PROPERTY_PYTHON_ACCESS(ReferenceFilePath, const char*)
DECLARE_ORSDK_PROPERTY_PYTHON_ACCESS(IsLoaded, bool)
};
#endif // pyfbset_h__ |
c0673c6abff2a289e50a2466ed1aa13423750a6b | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /services/service_manager/tests/shutdown/shutdown_unittest.cc | 205efe339a1a9432336418564c6e460f053b27c2 | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 4,762 | cc | shutdown_unittest.cc | // Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <vector>
#include "base/no_destructor.h"
#include "base/run_loop.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/manifest.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_receiver.h"
#include "services/service_manager/public/cpp/test/test_service_manager.h"
#include "services/service_manager/public/mojom/constants.mojom.h"
#include "services/service_manager/tests/shutdown/shutdown.test-mojom.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace service_manager {
namespace {
const char kTestServiceName[] = "shutdown_unittest";
const char kShutdownServiceName[] = "shutdown_service";
const char kShutdownClientName[] = "shutdown_client";
const char kClientControllerCapability[] = "client_controller";
const char kShutdownServiceCapability[] = "shutdown_service";
const std::vector<Manifest>& GetTestManifests() {
static base::NoDestructor<std::vector<Manifest>> manifests{
{ManifestBuilder()
.WithServiceName(kShutdownClientName)
.WithOptions(ManifestOptionsBuilder()
.WithExecutionMode(
Manifest::ExecutionMode::kStandaloneExecutable)
.WithSandboxType("none")
.Build())
.ExposeCapability(
kClientControllerCapability,
Manifest::InterfaceList<mojom::ShutdownTestClientController>())
.RequireCapability(kShutdownServiceName, kShutdownServiceCapability)
.RequireCapability(mojom::kServiceName,
"service_manager:service_manager")
.Build(),
ManifestBuilder()
.WithServiceName(kShutdownServiceName)
.WithOptions(ManifestOptionsBuilder()
.WithExecutionMode(
Manifest::ExecutionMode::kStandaloneExecutable)
.WithSandboxType("none")
.Build())
.ExposeCapability(
kShutdownServiceCapability,
Manifest::InterfaceList<mojom::ShutdownTestService>())
.RequireCapability(mojom::kServiceName,
"service_manager:service_manager")
.Build(),
ManifestBuilder()
.WithServiceName(kTestServiceName)
.RequireCapability(kShutdownServiceName, kShutdownServiceCapability)
.RequireCapability(mojom::kServiceName,
"service_manager:service_manager")
.RequireCapability(kShutdownClientName, kClientControllerCapability)
.Build()}};
return *manifests;
}
class ShutdownTest : public testing::Test {
public:
ShutdownTest()
: test_service_manager_(GetTestManifests()),
test_service_receiver_(
&test_service_,
test_service_manager_.RegisterTestInstance(kTestServiceName)) {}
ShutdownTest(const ShutdownTest&) = delete;
ShutdownTest& operator=(const ShutdownTest&) = delete;
~ShutdownTest() override = default;
Connector* connector() { return test_service_receiver_.GetConnector(); }
private:
base::test::TaskEnvironment task_environment_;
TestServiceManager test_service_manager_;
Service test_service_;
ServiceReceiver test_service_receiver_;
};
TEST_F(ShutdownTest, ConnectRace) {
// This test exercises a number of potential shutdown races that can lead to
// client deadlock if any of various parts of the EDK or service manager are
// not
// working as intended.
mojo::Remote<mojom::ShutdownTestClientController> control;
connector()->Connect(kShutdownClientName,
control.BindNewPipeAndPassReceiver());
// Connect to shutdown_service and immediately request that it shut down.
mojo::Remote<mojom::ShutdownTestService> service;
connector()->Connect(kShutdownServiceName,
service.BindNewPipeAndPassReceiver());
service->ShutDown();
// Tell shutdown_client to connect to an interface on shutdown_service and
// then block waiting for the interface pipe to signal something. If anything
// goes wrong, its pipe won't signal and the client process will hang without
// responding to this request.
base::RunLoop loop;
control->ConnectAndWait(loop.QuitClosure());
loop.Run();
}
} // namespace
} // namespace service_manager
|
731e3f18c317e658c23d3db6fd522ebaaab767ad | 6d1fd68e4554fb8bc17533aa70e1bcb624a81c3d | /src/blackfox/modules/physics/components/BFRigidBodyComponent.h | e32733fdbd7b39dd36d55dadba3fc643722a2d7a | [
"MIT"
] | permissive | RLefrancoise/BlackFox | c3a303c734ae804baeeaa70d2c791bb442e5bba6 | 7814c58dca5c11cb9a80f42d4ed5f43ea7745875 | refs/heads/master | 2021-07-06T18:31:04.224033 | 2020-12-02T00:06:31 | 2020-12-02T00:06:31 | 220,683,087 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,596 | h | BFRigidBodyComponent.h | #pragma once
#include "BFComponent.h"
#include "BFDegree.h"
#include "BFVector2.h"
#include "Box2D/Dynamics/b2Body.h"
#include "Box2D/Dynamics/b2Fixture.h"
namespace BlackFox::Systems
{
class BFPhysicsSystem;
}
namespace BlackFox::Components
{
struct BLACKFOX_EXPORT BFRigidBodyComponent final: IBFComponent
{
friend class Systems::BFPhysicsSystem;
BF_COMPONENT(BFRigidBodyComponent, "RigidBody")
BFRigidBodyComponent();
~BFRigidBodyComponent() override = default;
BFRigidBodyComponent(const BFRigidBodyComponent& rb) = delete;
BFRigidBodyComponent& operator=(const BFRigidBodyComponent&) = delete;
BFRigidBodyComponent(BFRigidBodyComponent&& rb) noexcept = default;
BFRigidBodyComponent& operator=(BFRigidBodyComponent&& rb) noexcept = default;
/// The body type: static, kinematic, or dynamic.
/// Note: if a dynamic body would have zero mass, the mass is set to one.
b2BodyType type;
/// The linear velocity of the body's origin in world co-ordinates.
BFVector2f linearVelocity;
/// The angular velocity of the body.
float32 angularVelocity;
/// Linear damping is use to reduce the linear velocity. The damping parameter
/// can be larger than 1.0f but the damping effect becomes sensitive to the
/// time step when the damping parameter is large.
/// Units are 1/time
float32 linearDamping;
/// Angular damping is use to reduce the angular velocity. The damping parameter
/// can be larger than 1.0f but the damping effect becomes sensitive to the
/// time step when the damping parameter is large.
/// Units are 1/time
float32 angularDamping;
/// Set this flag to false if this body should never fall asleep. Note that
/// this increases CPU usage.
bool allowSleep;
/// Is this body initially awake or sleeping?
bool awake;
/// Should this body be prevented from rotating? Useful for characters.
bool fixedRotation;
/// Is this a fast moving body that should be prevented from tunneling through
/// other moving bodies? Note that all bodies are prevented from tunneling through
/// kinematic and static bodies. This setting is only considered on dynamic bodies.
/// @warning You should use this flag sparingly since it increases processing time.
bool bullet;
/// Does this body start out active?
bool active;
/// Scale the gravity applied to this body.
float32 gravityScale;
private:
void bodyDef(b2BodyDef* def) const;
void synchronizeBody(b2Vec2 position, const BFDegree& angle);
void synchronizeWithBody();
bool m_isInitialized;
b2Body* m_body;
};
}
|
b5cde931c88af3a17ef02fd50c479d330cf5bf7b | 1d04e4012e26da7ccfe822aef5bc9c3676ddf2d7 | /SFML_Test/MainMenu.h | dff4e6c087c154339f3ec098b0fc97a15777433c | [] | no_license | GmBeHappy/First-Mission-in-new-home | 7f7cdf06136ceac38bd695e59e1fe354db97a7b5 | 550b475e3a2600d3b8e1e5baca52189a4879b74a | refs/heads/master | 2023-01-30T10:12:00.072238 | 2020-12-16T02:14:44 | 2020-12-16T02:14:44 | 309,473,440 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 995 | h | MainMenu.h | #pragma once
#include <SFML\Graphics.hpp>
#include<SFML/System.hpp>
#include "Background.h"
//#include "Plane.h"
#include <fstream>
#include <iostream>
class MainMenu
{
private:
//Plane* leaderboard;
sf::Texture* menuBackgroung;
sf::Font* font;
sf::Text* playBtn;
sf::Text* scoreBtn;
sf::Text* exitBtn;
sf::Text* howtoBtn;
Background* background;
sf::RenderWindow* window;
sf::Mouse* mouse;
sf::Text* name;
sf::RectangleShape textBox;
sf::RectangleShape shape;
sf::Text* header;
sf::Text* content;
sf::Texture* howtoTexture;
sf::Sprite* sprite;
void initialTexture();
void initialFont();
void initialText();
void initialNameInput();
void initialReadScore();
void initialHowto();
public:
MainMenu(sf::RenderWindow* window, sf::Mouse* mouse);
virtual ~MainMenu();
sf::Text* nameInput;
bool isPlay=false;
bool isNameInput = false;
bool isFinishNameInput = false;
bool toggleLeaderboard = false;
bool toggleHowTo = false;
void update();
void render();
};
|
40905e93b17d6143a5db192c208d62aba582eb4e | 6d088ec295b33db11e378212d42d40d5a190c54c | /contrib/oxl/mvl/Homg.h | 901346490faa3599977d535d71df1e569636a674 | [] | no_license | vxl/vxl | 29dffd5011f21a67e14c1bcbd5388fdbbc101b29 | 594ebed3d5fb6d0930d5758630113e044fee00bc | refs/heads/master | 2023-08-31T03:56:24.286486 | 2023-08-29T17:53:12 | 2023-08-29T17:53:12 | 9,819,799 | 224 | 126 | null | 2023-09-14T15:52:32 | 2013-05-02T18:32:27 | C++ | UTF-8 | C++ | false | false | 1,011 | h | Homg.h | // This is oxl/mvl/Homg.h
#ifndef Homg_h_
#define Homg_h_
//:
// \file
// \brief Private base class for homogeneous vectors
//
// This is the private base class for homogeneous vectors. It provides the
// get/set interface, and also a static variable Homg::infinity which is used
// throughout when returning infinite nonhomogeneous values.
//
// \author
// Paul Beardsley, 29.03.96
// Oxford University, UK
//
// \verbatim
// Modifications:
// 210297 AWF Switched to fixed-length vectors for speed.
// \endverbatim
//-------------------------------------------------------------------------------
class Homg
{
public:
//: Standard placeholder for methods that wish to return infinity.
static double infinity;
//: The tolerance used in "near zero" tests in the Homg subclasses.
static double infinitesimal_tol;
//: Static method to set the default tolerance used for infinitesimal checks.
// The default is 1e-12.
static void set_infinitesimal_tol(double tol);
};
#endif // Homg_h_
|
cf0222fa997f75767ec12d0b257d282aa0c16807 | c54cf70b840410501ff5cafdf2a57e49f67e0e47 | /BasicXMLGUI/ArgStringList.h | 7b17abb38e0e6ec57e6c9adeeee056fe0b86aed1 | [] | no_license | BlazesRus/NodeTreeGUI | 51728596f3ff97f5b933c8d284d0d987a65afb9a | 0e0a4b45c6e5c6ac715ea99c8c88288e49b80dff | refs/heads/master | 2021-08-28T12:47:36.061063 | 2021-08-16T21:45:36 | 2021-08-16T21:45:36 | 240,399,412 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,861 | h | ArgStringList.h | // ***********************************************************************
// Code Created by James Michael Armstrong (https://github.com/BlazesRus)
// ***********************************************************************
#pragma once
#ifndef ArgStringList_IncludeGuard
#define ArgStringList_IncludeGuard
#include <string>
#include <vector>
class ArgValue
{
private:
ArgValue()
{
}
public:
std::string Value;
LONG ArgPos;
explicit operator std::string()
{
return Value;
}
ArgValue(std::string value)
{
Value = value;
ArgPos = 0;
}
ArgValue(CString value)
{
Value = value;
ArgPos = 0;
}
};
class ArgStringList : public std::vector<ArgValue>
{
public:
LONG ArgStart;
ArgStringList()
{
ArgStart = 0;
}
void Add(std::string Value)
{
this->push_back(Value);
}
/// <summary>
/// Loads the arguments.
/// </summary>
/// <param name="Content">The content.</param>
void LoadArgs(const std::string& Content)
{
std::string CurrentElement = "";
for (char const& CurrentChar : Content)
{
if (CurrentElement == "")
{
if (CurrentChar != '\n' && CurrentChar != ' ' && CurrentChar != '\t')
{
CurrentElement = CurrentChar;
}
}
else
{
if (CurrentChar != '\n' && CurrentChar != ' ' && CurrentChar != '\t')
{
CurrentElement += CurrentChar;
}
else if (CurrentChar != ',')
{
push_back(CurrentElement);
CurrentElement = "";
}
}
}
}
/// <summary>
/// Initializes a new instance of the <see cref="ArgStringList"/> class.(Loads the arguments detected inside the string)
/// </summary>
/// <param name="Content">The content.</param>
ArgStringList(std::string Content) : ArgStringList()
{
ArgStart = 0;
LoadArgs(Content);
}
/// <summary>
/// Implements the operator std::string operator.
/// </summary>
/// <returns>The result of the operator.</returns>
explicit operator std::string()
{
std::string ConvertedString = "\"";
for (vector<ArgValue>::iterator Arg = this->begin(), StartIndex = Arg, EndIndex = this->end(); Arg != EndIndex; ++Arg)
{
if (Arg != StartIndex)
{
ConvertedString += ",";
}
ConvertedString += (std::string) * Arg;
}
ConvertedString += "\"";
return ConvertedString;
}
};
#endif |
9bc4ef947026d5b3a7fa9d91a3371cb6feb18bb8 | 24b48bbf173884f943cdbba78d2f544ae69bb89a | /src/pathplanner/genericsamplers.cpp | 2c19a347e21b34234dc8855394df23f2548e90e5 | [] | no_license | drodri/MRCore | 854a869595fa685c09cfe3be7f1ace290ce3b739 | 91710f2ba6a9967e4c637f566fdca38f28374220 | refs/heads/master | 2016-08-05T10:20:27.820811 | 2013-07-22T15:13:41 | 2013-07-24T10:18:43 | 3,554,360 | 5 | 4 | null | 2013-07-23T10:19:00 | 2012-02-26T19:56:52 | C++ | UTF-8 | C++ | false | false | 6,207 | cpp | genericsamplers.cpp | /**********************************************************************
*
* This code is part of the MRcore project
* Author: Miguel Hernando Gutierrez
*
*
*************************************************************************/
#include "genericsamplers.h"
Sampler::Sampler(Vector2D minim, Vector2D range){
vector<double> m(2),r(2);
m[0]=minim.x;m[1]=minim.y;
r[0]=range.x;r[1]=range.y;
configureSampler(m,r);
}
Sampler::Sampler(Vector3D minim, Vector3D range){
vector<double> m(3),r(3);
m[0]=minim.x;m[1]=minim.y;m[2]=minim.z;
r[0]=range.x;r[1]=range.y;r[2]=range.z;
configureSampler(m,r);
}
Sampler::Sampler(BoundingBox &box){
vector<double> m(3),r(3);
Vector3D minim=box.getMinVertex();
Vector3D range=box.getMaxVertex()-minim;
m[0]=minim.x;m[1]=minim.y;m[2]=minim.z;
r[0]=range.x;r[1]=range.y;r[2]=range.z;
configureSampler(m,r);
}
void Sampler::setWorld(World *world)
{
vector<double> m(3),r(3);
BoundingBox box=world->getBoundingBox();
//hago lo mismo que en el constructor anterior
Vector3D minim=box.getMinVertex();
Vector3D range=box.getMaxVertex()-minim;
m[0]=minim.x;m[1]=minim.y;m[2]=minim.z;
r[0]=range.x;r[1]=range.y;r[2]=range.z;
configureSampler(m,r);
}
Sampler::Sampler(World *world){
setWorld(world);
}
Sampler::Sampler(RobotSim *robot){
//grados de libertad y max y min de cada articulacion
int n=robot->getNumJoints();
vector<double> m(n),r(n);
double val;
for(int i=0;i<n;i++){robot->getJointLimits(i,val,m[i]);r[i]=val-m[i];}
configureSampler(m,r);
}
void Sampler::configureSampler( vector<double> _min, vector<double> _range ){
if(_min.size()!=_range.size())return;
dimension=(int)_min.size();
min=_min; range=_range; sample=min;
normalizedSample=new double[dimension];
}
const Sample &Sampler::computeSample(){
for(int i=0;i<dimension;i++)sample[i]=min[i]+normalizedSample[i]*range[i];
return sample;
}
////RANDOM SAMPLER: example of how to construct a simple n dimensional sampler
Sample RandomSampler::getNextSample()
{
for(int i=0;i<getDimension();i++)
normalizedSample[i]=(double) rand() / (double) RAND_MAX;
return computeSample();
}
double Sampler::sampleGaussian(double mean,double cov)
{
double med=0;
for(int i=0;i<12;i++)
med+=rand()/(float)RAND_MAX;
med-=6;//standard
double x=mean+med*sqrt(cov)/6;
return x;
}
double Sampler::sampleGaussian(int n,double mean,double cov)
{
double med=0;
for(int i=0;i<n;i++)
med+=rand()/(float)RAND_MAX;
med-=(n/2);//standard
double x=mean+2*med*sqrt(cov)/n;
return x;
}
//UNIFORMSAMPLER
void UniformSampler::initializeL()
{
int n=getDimension(),i,j;
iteration=0;
if(n>8*sizeof(int)-1)
return; //MIKE, this exception is not supported in g++4.4 throw exception("Uniform Sampler: dimension too high");
L_n=1<<n;
L=new double *[L_n];
for(int i=0;i<L_n;i++)L[i]=new double[n];
//computation is based on the aTd Matrix of Rossell (2007 Int Journal Robot Systems)
//T is an N*N char matrix (0,1)
typedef unsigned char bit;
bit **T=new bit *[n];
bit *aux=new bit[n];
for(i=0;i<n;i++){T[i]=new bit[n];}
//la construyo por columnas
for(j=0;j<n;j++)
for(i=0;i<n;i++)
{
if(i==j)T[i][j]=1;
if(i<j)T[i][j]=0;
if((i>j)&&(j!=0)){
int k=(i-j-1)/(j);
if(k%2==0)T[i][j]=0;
else T[i][j]=1;
}
if(j==0)T[i][j]=1;
}
//obtengo los valores de L
for(i=0;i<L_n;i++){
//representacion bit a bit
for(j=0;j<n;j++)if(i&(0x1<<j))aux[j]=1;else aux[j]=0;
for(int k=0;k<n;k++){
int val=0;
if(n==2)val=L_2[i][k];
else if(n==3)val=L_3[i][k];
else if(n==6)val=L_6[i][k];
else for(int l=0;l<n;l++)val+=T[k][l]*aux[l];
L[i][k]=0.5*(val%2);
}
}
//al terminar hay que eliminar T y aux
for(i=0;i<n;i++)delete [] T[i];
delete [] aux;
}
//RECURSIVE METHOD - 2003 IEEE ICRA Lindermann
Sample UniformSampler::getNextNormalizedSample(int n, Sample base, double factor)
{
int i;
Sample sample=base;
int index=n%L_n;
int nextN=n/L_n;
for(i=0;i<getDimension();i++)sample[i]=sample[i]+L[index][i]*factor;
if(nextN==0) //return sample+Vector2D(factor/4,factor/4);
{
for(i=0;i<getDimension();i++)sample[i]=sample[i]+factor/4; //Shukarev Correction
return sample;
}
else return getNextNormalizedSample(nextN,sample,factor/2.0);
}
UniformSampler::~UniformSampler(){
if(L==0)return;
for(int i=0;i<L_n;i++)delete [] L[i];
}
Sample UniformSampler::getNextSample()
{
Sample seed(getDimension());
for(int i=0;i<getDimension();i++)seed[i]=0.0;
Sample aux=getNextNormalizedSample(iteration, seed, 1.0);
iteration++;
for(int j=0;j<getDimension();j++)
normalizedSample[j]=aux[j];
return computeSample();
}
//static values
double UniformSampler::L_2[4][2]={{0,0},{1,1},{1,0},{0,1}};
double UniformSampler::L_3[8][3]={{0,0,0},{1,1,1},{0,1,0},{1,0,1},{0,0,1},{1,1,0},{0,1,1},{1,0,0}};
double UniformSampler::L_6[64][6]={
{0,0,0,0,0,0}, {1,1,1,1,1,1}, {0,1,0,1,1,1}, {1,0,1,0,0,0}, {0,0,1,1,1,1}, {1,1,0,0,0,0}, {0,1,1,0,0,0}, {1,0,0,1,1,1},
{0,0,0,1,0,1}, {1,1,1,0,1,0}, {0,1,0,0,1,0}, {1,0,1,1,0,1}, {0,0,1,0,1,0}, {1,1,0,1,0,1}, {0,1,1,1,0,1}, {1,0,0,0,1,0},
{0,0,0,0,1,1}, {1,1,1,1,0,0}, {0,1,0,1,0,0}, {1,0,1,0,1,1}, {0,0,1,1,0,0}, {1,1,0,0,1,1}, {0,1,1,0,1,1}, {1,0,0,1,0,0},
{0,0,0,1,1,0}, {1,1,1,0,0,1}, {0,1,0,0,0,1}, {1,0,1,1,1,0}, {0,0,1,0,0,1}, {1,1,0,1,1,0}, {0,1,1,1,1,0}, {1,0,0,0,0,1},
{0,0,0,0,0,1}, {1,1,1,1,1,0}, {0,1,0,1,1,0}, {1,0,1,0,0,1}, {0,0,1,1,1,0}, {1,1,0,0,0,1}, {0,1,1,0,0,1}, {1,0,0,1,1,0},
{0,0,0,1,0,0}, {1,1,1,0,1,1}, {0,1,0,0,1,1}, {1,0,1,1,0,0}, {0,0,1,0,1,1}, {1,1,0,1,0,0}, {0,1,1,1,0,0}, {1,0,0,0,1,1},
{0,0,0,0,1,0}, {1,1,1,1,0,1}, {0,1,0,1,0,1}, {1,0,1,0,1,0}, {0,0,1,1,0,1}, {1,1,0,0,1,0}, {0,1,1,0,1,0}, {1,0,0,1,0,1},
{0,0,0,1,1,1}, {1,1,1,0,0,0}, {0,1,0,0,0,0}, {1,0,1,1,1,1}, {0,0,1,0,0,0}, {1,1,0,1,1,1}, {0,1,1,1,1,1}, {1,0,0,0,0,0}};
//////GAUSSIAN SAMPLER
Sample GaussianSampler::getNextSample()
{
int number=iteration;
double cellsize=0.5F, cov;
while(number>0){
number/=L_n;
cellsize/=2;
}
if(iteration==0)cellsize=0.25;
cov=cellsize*cellsize;
UniformSampler::getNextSample();
for(int j=0;j<getDimension();j++)
normalizedSample[j]=sampleGaussian(6,normalizedSample[j],cov);
return computeSample();
} |
b79afa838d3e3398049621c2a0baeea8b58fc121 | 3249744f6a1da68f7028571a8e7c960891606f4f | /JustCompiler/JustCompiler.Tests/FirstAndFollowTest.cpp | cf0898e280360913b357a93da00a591baf52304e | [] | no_license | maxtyutmanov/sstu-labs | 69d03989beb27efc81275a8a1184fd0665d3b4b7 | 393868c891f4476895d11dcb5b99e8dc44488196 | refs/heads/master | 2016-08-09T20:22:49.080564 | 2012-04-20T07:39:07 | 2012-04-20T07:39:07 | 48,426,643 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,681 | cpp | FirstAndFollowTest.cpp | #include <boost/test/auto_unit_test.hpp>
#include <FirstFunction.h>
#include <FollowFunction.h>
#include <Terminal.h>
#include <NonTerminal.h>
#include <FirstNFollowFactory.h>
#include <TokenTag.h>
#include <ParserTable.h>
#include <NonTerminalTag.h>
#include "TestGrammarFactory.h"
using namespace JustCompiler::SyntacticAnalyzer::ContextFreeGrammar;
using namespace JustCompiler::ParserGrammar;
using namespace JustCompiler::Tests;
struct ArithmeticExprFNFFixture {
virtual ~ArithmeticExprFNFFixture() {}
ArithmeticExprFNFFixture() {
exprGrammar = TestGrammarFactory::CreateExpressionsGrammar();
}
Grammar exprGrammar;
};
BOOST_FIXTURE_TEST_SUITE( FirstNFollowExpressionGrammarSuite, ArithmeticExprFNFFixture )
BOOST_AUTO_TEST_CASE( FirstFunctionTest ) {
SymbolString str1;
str1.push_back(PTerminal(new Terminal(1)));
str1.push_back(PNonTerminal(new NonTerminal(1)));
SymbolString str2;
str2.push_back(PTerminal(new Terminal(1)));
str2.push_back(PTerminal(new Terminal(1)));
FirstFunction first;
first(str1).push_back(PTerminal(new Terminal(2)));
first(str1).push_back(PTerminal(new Terminal(3)));
first(str2).push_back(PTerminal(new Terminal(2)));
BOOST_CHECK(first(str1).size() == 2);
BOOST_CHECK(first(str2).size() == 1);
}
BOOST_AUTO_TEST_CASE( FollowFunctionTest ) {
PNonTerminal s1(new NonTerminal(1));
PNonTerminal s2(new NonTerminal(2));
FollowFunction follow;
follow(s1).push_back(PTerminal(new Terminal(2)));
follow(s1).push_back(PTerminal(new Terminal(3)));
follow(s2).push_back(PTerminal(new Terminal(2)));
BOOST_CHECK(follow(s1).size() == 2);
BOOST_CHECK(follow(s2).size() == 1);
}
BOOST_AUTO_TEST_CASE( FirstFunction_ArithmeticExpressions ) {
PFirstFunction pFirst = FirstNFollowFactory::GetFirst(exprGrammar);
FirstFunction& first = *pFirst;
TerminalSet f_E = first(exprGrammar.N("E"));
BOOST_ASSERT(f_E.size() == 2);
BOOST_CHECK(f_E.Contains(TokenTag::OpeningRoundBracket));
BOOST_CHECK(f_E.Contains(TokenTag::Identifier));
TerminalSet f_T = first(exprGrammar.N("T"));
BOOST_ASSERT(f_T.size() == 2);
BOOST_CHECK(f_T.Contains(TokenTag::OpeningRoundBracket));
BOOST_CHECK(f_T.Contains(TokenTag::Identifier));
TerminalSet f_F = first(exprGrammar.N("F"));
BOOST_ASSERT(f_F.size() == 2);
BOOST_CHECK(f_F.Contains(TokenTag::OpeningRoundBracket));
BOOST_CHECK(f_F.Contains(TokenTag::Identifier));
TerminalSet f_E1 = first(exprGrammar.N("E1"));
BOOST_ASSERT(f_E1.size() == 3);
BOOST_CHECK(f_E1.Contains(TokenTag::Plus));
BOOST_CHECK(f_E1.Contains(SpecialTokenTag::Empty));
BOOST_CHECK(f_E1.Contains(TokenTag::Minus));
TerminalSet f_T1 = first(exprGrammar.N("T1"));
BOOST_ASSERT(f_T1.size() == 3);
BOOST_CHECK(f_T1.Contains(TokenTag::Asterisk));
BOOST_CHECK(f_T1.Contains(TokenTag::Slash));
BOOST_CHECK(f_T1.Contains(SpecialTokenTag::Empty));
}
BOOST_AUTO_TEST_CASE( FollowFunction_ArithmeticExpressions ) {
PFirstFunction pFirst = FirstNFollowFactory::GetFirst(exprGrammar);
PFollowFunction pFollow = FirstNFollowFactory::GetFollow(exprGrammar, pFirst);
FollowFunction& follow = *pFollow;
TerminalSet f_E = follow(exprGrammar.N("E"));
BOOST_ASSERT(f_E.size() == 2);
BOOST_CHECK(f_E.Contains(TokenTag::ClosingRoundBracket));
BOOST_CHECK(f_E.Contains(SpecialTokenTag::Eof));
TerminalSet f_E1 = follow(exprGrammar.N("E1"));
BOOST_ASSERT(f_E1.size() == 2);
BOOST_CHECK(f_E1.Contains(TokenTag::ClosingRoundBracket));
BOOST_CHECK(f_E1.Contains(SpecialTokenTag::Eof));
TerminalSet f_T = follow(exprGrammar.N("T"));
BOOST_ASSERT(f_T.size() == 4);
BOOST_CHECK(f_T.Contains(TokenTag::Plus));
BOOST_CHECK(f_T.Contains(TokenTag::Minus));
BOOST_CHECK(f_T.Contains(TokenTag::ClosingRoundBracket));
BOOST_CHECK(f_T.Contains(SpecialTokenTag::Eof));
TerminalSet f_T1 = follow(exprGrammar.N("T1"));
BOOST_ASSERT(f_T1.size() == 4);
BOOST_CHECK(f_T1.Contains(TokenTag::Plus));
BOOST_CHECK(f_T1.Contains(TokenTag::Minus));
BOOST_CHECK(f_T1.Contains(TokenTag::ClosingRoundBracket));
BOOST_CHECK(f_T1.Contains(SpecialTokenTag::Eof));
TerminalSet f_F = follow(exprGrammar.N("F"));
BOOST_ASSERT(f_F.size() == 6);
BOOST_CHECK(f_F.Contains(TokenTag::Plus));
BOOST_CHECK(f_F.Contains(TokenTag::Minus));
BOOST_CHECK(f_F.Contains(TokenTag::Asterisk));
BOOST_CHECK(f_F.Contains(TokenTag::Slash));
BOOST_CHECK(f_F.Contains(TokenTag::ClosingRoundBracket));
BOOST_CHECK(f_F.Contains(SpecialTokenTag::Eof));
}
BOOST_AUTO_TEST_CASE( ParserTable_ArithmeticExpressions ) {
PFirstFunction pFirst = FirstNFollowFactory::GetFirst(exprGrammar);
PFollowFunction pFollow = FirstNFollowFactory::GetFollow(exprGrammar, pFirst);
ParserTable parserTable(exprGrammar, *pFirst, *pFollow);
const Production* p1 = parserTable.GetEntry(exprGrammar.N("E")->GetTag(), TokenTag::Identifier).GetProduction();
BOOST_ASSERT(p1 != NULL);
BOOST_CHECK(p1->Left()->GetTag() == NonTerminalTag::Expression);
BOOST_ASSERT(p1->Right().size() == 2);
BOOST_CHECK(*p1->Right()[0] == *PNonTerminal(new NonTerminal(NonTerminalTag::Term)));
BOOST_CHECK(*p1->Right()[1] == *PNonTerminal(new NonTerminal(NonTerminalTag::ExpressionStroke)));
const Production* p2 = parserTable.GetEntry(exprGrammar.N("E")->GetTag(), TokenTag::OpeningRoundBracket).GetProduction();
BOOST_ASSERT(p2 != NULL);
BOOST_CHECK(p2->Left()->GetTag() == NonTerminalTag::Expression);
BOOST_ASSERT(p2->Right().size() == 2);
BOOST_CHECK(*p2->Right()[0] == *PNonTerminal(new NonTerminal(NonTerminalTag::Term)));
BOOST_CHECK(*p2->Right()[1] == *PNonTerminal(new NonTerminal(NonTerminalTag::ExpressionStroke)));
const Production* p3 = parserTable.GetEntry(exprGrammar.N("E1")->GetTag(), TokenTag::Plus).GetProduction();
BOOST_ASSERT(p3 != NULL);
BOOST_CHECK(p3->Left()->GetTag() == NonTerminalTag::ExpressionStroke);
BOOST_ASSERT(p3->Right().size() == 3);
BOOST_CHECK(*p3->Right()[0] == *PTerminal(new Terminal(TokenTag::Plus)));
BOOST_CHECK(*p3->Right()[1] == *PNonTerminal(new NonTerminal(NonTerminalTag::Term)));
BOOST_CHECK(*p3->Right()[2] == *PNonTerminal(new NonTerminal(NonTerminalTag::ExpressionStroke)));
const Production* p4 = parserTable.GetEntry(exprGrammar.N("E1")->GetTag(), TokenTag::ClosingRoundBracket).GetProduction();
BOOST_ASSERT(p4 != NULL);
BOOST_CHECK(p4->Left()->GetTag() == NonTerminalTag::ExpressionStroke);
BOOST_ASSERT(p4->Right().size() == 1);
BOOST_CHECK(*p4->Right()[0] == *PTerminal(new Terminal(SpecialTokenTag::Empty)));
const Production* p5 = parserTable.GetEntry(exprGrammar.N("E1")->GetTag(), SpecialTokenTag::Eof).GetProduction();
BOOST_ASSERT(p5 != NULL);
BOOST_CHECK(p5->Left()->GetTag() == NonTerminalTag::ExpressionStroke);
BOOST_ASSERT(p5->Right().size() == 1);
BOOST_CHECK(*p5->Right()[0] == *PTerminal(new Terminal(SpecialTokenTag::Empty)));
const Production* p6 = parserTable.GetEntry(exprGrammar.N("T")->GetTag(), TokenTag::Identifier).GetProduction();
BOOST_ASSERT(p6 != NULL);
BOOST_CHECK(p6->Left()->GetTag() == NonTerminalTag::Term);
BOOST_ASSERT(p6->Right().size() == 2);
BOOST_CHECK(*p6->Right()[0] == *PNonTerminal(new NonTerminal(NonTerminalTag::Factor)));
BOOST_CHECK(*p6->Right()[1] == *PNonTerminal(new NonTerminal(NonTerminalTag::TermStroke)));
const Production* p7 = parserTable.GetEntry(exprGrammar.N("T")->GetTag(), TokenTag::OpeningRoundBracket).GetProduction();
BOOST_ASSERT(p7 != NULL);
BOOST_CHECK(p7->Left()->GetTag() == NonTerminalTag::Term);
BOOST_ASSERT(p7->Right().size() == 2);
BOOST_CHECK(*p7->Right()[0] == *PNonTerminal(new NonTerminal(NonTerminalTag::Factor)));
BOOST_CHECK(*p7->Right()[1] == *PNonTerminal(new NonTerminal(NonTerminalTag::TermStroke)));
const Production* p8 = parserTable.GetEntry(exprGrammar.N("T1")->GetTag(), TokenTag::Plus).GetProduction();
BOOST_ASSERT(p8 != NULL);
BOOST_CHECK(p8->Left()->GetTag() == NonTerminalTag::TermStroke);
BOOST_ASSERT(p8->Right().size() == 1);
BOOST_CHECK(*p8->Right()[0] == *PTerminal(new Terminal(SpecialTokenTag::Empty)));
const Production* p9 = parserTable.GetEntry(exprGrammar.N("T1")->GetTag(), TokenTag::Asterisk).GetProduction();
BOOST_ASSERT(p9 != NULL);
BOOST_CHECK(p9->Left()->GetTag() == NonTerminalTag::TermStroke);
BOOST_ASSERT(p9->Right().size() == 3);
BOOST_CHECK(*p9->Right()[0] == *PTerminal(new Terminal(TokenTag::Asterisk)));
BOOST_CHECK(*p9->Right()[1] == *PNonTerminal(new NonTerminal(NonTerminalTag::Factor)));
BOOST_CHECK(*p9->Right()[2] == *PNonTerminal(new NonTerminal(NonTerminalTag::TermStroke)));
const Production* p10 = parserTable.GetEntry(exprGrammar.N("T1")->GetTag(), TokenTag::ClosingRoundBracket).GetProduction();
BOOST_ASSERT(p10 != NULL);
BOOST_CHECK(p10->Left()->GetTag() == NonTerminalTag::TermStroke);
BOOST_ASSERT(p10->Right().size() == 1);
BOOST_CHECK(*p10->Right()[0] == *PTerminal(new Terminal(SpecialTokenTag::Empty)));
const Production* p11 = parserTable.GetEntry(exprGrammar.N("T1")->GetTag(), SpecialTokenTag::Eof).GetProduction();
BOOST_ASSERT(p11 != NULL);
BOOST_CHECK(p11->Left()->GetTag() == NonTerminalTag::TermStroke);
BOOST_ASSERT(p11->Right().size() == 1);
BOOST_CHECK(*p11->Right()[0] == *PTerminal(new Terminal(SpecialTokenTag::Empty)));
const Production* p12 = parserTable.GetEntry(exprGrammar.N("F")->GetTag(), TokenTag::Identifier).GetProduction();
BOOST_ASSERT(p12 != NULL);
BOOST_CHECK(p12->Left()->GetTag() == NonTerminalTag::Factor);
BOOST_ASSERT(p12->Right().size() == 1);
BOOST_CHECK(*p12->Right()[0] == *PTerminal(new Terminal(TokenTag::Identifier)));
const Production* p13 = parserTable.GetEntry(exprGrammar.N("F")->GetTag(), TokenTag::OpeningRoundBracket).GetProduction();
BOOST_CHECK(p13->Left()->GetTag() == NonTerminalTag::Factor);
BOOST_ASSERT(p13->Right().size() == 3);
BOOST_CHECK(*p13->Right()[0] == *PTerminal(new Terminal(TokenTag::OpeningRoundBracket)));
BOOST_CHECK(*p13->Right()[1] == *PNonTerminal(new NonTerminal(NonTerminalTag::Expression)));
BOOST_CHECK(*p13->Right()[2] == *PTerminal(new Terminal(TokenTag::ClosingRoundBracket)));
}
BOOST_AUTO_TEST_SUITE_END() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.