blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
f68170af43f2d4c0e1e4bb88ec002d9e6307ea14
afd2087e80478010d9df66e78280f75e1ff17d45
/test/mobile/lightweight_dispatch/test_codegen_unboxing.cpp
1b879118b5b864baf09f2d6451c361b7a9816c9c
[ "BSD-3-Clause", "BSD-2-Clause", "LicenseRef-scancode-secret-labs-2011", "LicenseRef-scancode-generic-cla", "BSL-1.0", "Apache-2.0" ]
permissive
pytorch/pytorch
7521ac50c47d18b916ae47a6592c4646c2cb69b5
a6f7dd4707ac116c0f5fb5f44f42429f38d23ab4
refs/heads/main
2023-08-03T05:05:02.822937
2023-08-03T00:40:33
2023-08-03T04:14:52
65,600,975
77,092
24,610
NOASSERTION
2023-09-14T21:58:39
2016-08-13T05:26:41
Python
UTF-8
C++
false
false
7,227
cpp
#include <gtest/gtest.h> #include <test/cpp/jit/test_utils.h> #include <torch/torch.h> #include <torch/csrc/jit/api/module.h> #include <torch/csrc/jit/frontend/resolver.h> #include <torch/csrc/jit/mobile/import.h> #include <torch/csrc/jit/mobile/module.h> // Cover codegen'd unboxing logic for these types: //'Device', //'Device?', //'Dimname', //'Dimname[1]', //'Dimname[]', //'Dimname[]?', //'Generator?', //'Layout?', //'MemoryFormat', //'MemoryFormat?', //'Scalar', //'Scalar?', //'ScalarType', //'ScalarType?', //'Scalar[]', //'Storage', //'Stream', //'Tensor', //'Tensor(a!)', //'Tensor(a!)[]', //'Tensor(a)', //'Tensor(b!)', //'Tensor(c!)', //'Tensor(d!)', //'Tensor?', //'Tensor?[]', //'Tensor[]', //'bool', //'bool?', //'bool[2]', //'bool[3]', //'bool[4]', //'float', //'float?', //'float[]?', //'int', //'int?', //'int[1]', //'int[1]?', //'int[2]', //'int[2]?', //'int[3]', //'int[4]', //'int[5]', //'int[6]', //'int[]', //'int[]?', //'str', //'str?' namespace torch { namespace jit { namespace mobile { // covers int[], ScalarType?, Layout?, Device?, bool? TEST(LiteInterpreterTest, Ones) { // Load check in model: ModelWithDTypeDeviceLayoutPinMemory.ptl auto testModelFile = "ModelWithDTypeDeviceLayoutPinMemory.ptl"; // class ModelWithDTypeDeviceLayoutPinMemory(torch.nn.Module): // def forward(self, x: int): // a = torch.ones([3, x], dtype=torch.int64, layout=torch.strided, device="cpu") // return a Module bc = _load_for_mobile(testModelFile); std::vector<c10::IValue> input{c10::IValue(4)}; const auto result = bc.forward(input); ASSERT_EQ(result.toTensor().size(0), 3); ASSERT_EQ(result.toTensor().size(1), 4); } TEST(LiteInterpreterTest, Index) { // Load check in model: ModelWithTensorOptional.ptl auto testModelFile = "ModelWithTensorOptional.ptl"; // class ModelWithTensorOptional(torch.nn.Module): // def forward(self, index): // a = torch.zeros(2, 2) // a[0][1] = 1 // a[1][0] = 2 // a[1][1] = 3 // return a[index] Module bc = _load_for_mobile(testModelFile); int64_t ind_1 = 0; const auto result_1 = bc.forward({at::tensor(ind_1)}); at::Tensor expected = at::empty({1, 2}, c10::TensorOptions(c10::ScalarType::Float)); expected[0][0] = 0; expected[0][1] = 1; AT_ASSERT(result_1.toTensor().equal(expected)); } TEST(LiteInterpreterTest, Gradient) { // Load check in model: ModelWithScalarList.ptl auto testModelFile = "ModelWithScalarList.ptl"; // class ModelWithScalarList(torch.nn.Module): // def forward(self, a: int): // values = torch.tensor([4., 1., 1., 16.], ) // if a == 0: // return torch.gradient(values, spacing=torch.scalar_tensor(2., dtype=torch.float64)) // elif a == 1: // return torch.gradient(values, spacing=[torch.tensor(1.).item()]) Module bc = _load_for_mobile(testModelFile); const auto result_1 = bc.forward({0}); at::Tensor expected_1 = at::tensor({-1.5, -0.75, 3.75, 7.5}, c10::TensorOptions(c10::ScalarType::Float)); AT_ASSERT(result_1.toList().get(0).toTensor().equal(expected_1)); const auto result_2 = bc.forward({1}); at::Tensor expected_2 = at::tensor({-3.0, -1.5, 7.5, 15.0}, c10::TensorOptions(c10::ScalarType::Float)); AT_ASSERT(result_2.toList().get(0).toTensor().equal(expected_2)); } TEST(LiteInterpreterTest, Upsample) { // Load check in model: ModelWithFloatList.ptl auto testModelFile = "ModelWithFloatList.ptl"; // model = torch.nn.Upsample(scale_factor=(2.0,), mode="linear") Module bc = _load_for_mobile(testModelFile); const auto result_1 = bc.forward({at::ones({1, 2, 3})}); at::Tensor expected_1 = at::ones({1, 2, 6}, c10::TensorOptions(c10::ScalarType::Float)); AT_ASSERT(result_1.toTensor().equal(expected_1)); } TEST(LiteInterpreterTest, IndexTensor) { // Load check in model: ModelWithListOfOptionalTensors.ptl auto testModelFile = "ModelWithListOfOptionalTensors.ptl"; // class ModelWithListOfOptionalTensors(torch.nn.Module): // def forward(self, index): // values = torch.tensor([4., 1., 1., 16.], ) // return values[[index, torch.tensor(0)]] Module bc = _load_for_mobile(testModelFile); const auto result_1 = bc.forward({at::tensor({1}, c10::TensorOptions(c10::ScalarType::Long))}); at::Tensor expected_1 = at::tensor({1.}, c10::TensorOptions(c10::ScalarType::Float)); AT_ASSERT(result_1.toTensor().equal(expected_1)); } TEST(LiteInterpreterTest, Conv2d) { // Load check in model: ModelWithArrayOfInt.ptl auto testModelFile = "ModelWithArrayOfInt.ptl"; // model = torch.nn.Conv2d(1, 2, (2, 2), stride=(1, 1), padding=(1, 1)) Module bc = _load_for_mobile(testModelFile); const auto result_1 = bc.forward({at::ones({1, 1, 1, 1})}); ASSERT_EQ(result_1.toTensor().sizes(), c10::IntArrayRef ({1,2,2,2})); } TEST(LiteInterpreterTest, AddTensor) { // Load check in model: ModelWithTensors.ptl auto testModelFile = "ModelWithTensors.ptl"; // class ModelWithTensors(torch.nn.Module): // def forward(self, a): // values = torch.ones(size=[2, 3], names=['N', 'C']) // values[0][0] = a[0] // return values Module bc = _load_for_mobile(testModelFile); const auto result_1 = bc.forward({at::tensor({1, 2, 3}, c10::TensorOptions(c10::ScalarType::Long))}); at::Tensor expected_1 = at::tensor({2, 3, 4}, c10::TensorOptions(c10::ScalarType::Long)); AT_ASSERT(result_1.toTensor().equal(expected_1)); } TEST(LiteInterpreterTest, DivideTensor) { // Load check in model: ModelWithStringOptional.ptl auto testModelFile = "ModelWithStringOptional.ptl"; // class ModelWithStringOptional(torch.nn.Module): // def forward(self, b): // a = torch.tensor(3, dtype=torch.int64) // out = torch.empty(size=[1], dtype=torch.float) // torch.div(b, a, out=out) // return [torch.div(b, a, rounding_mode='trunc'), out] Module bc = _load_for_mobile(testModelFile); const auto result_1 = bc.forward({at::tensor({-12}, c10::TensorOptions(c10::ScalarType::Long))}); at::Tensor expected_1 = at::tensor({-4}, c10::TensorOptions(c10::ScalarType::Long)); at::Tensor expected_2 = at::tensor({-4.}, c10::TensorOptions(c10::ScalarType::Float)); AT_ASSERT(result_1.toList().get(0).toTensor().equal(expected_1)); AT_ASSERT(result_1.toList().get(1).toTensor().equal(expected_2)); } TEST(LiteInterpreterTest, MultipleOps) { // Load check in model: ModelWithMultipleOps.ptl auto testModelFile = "ModelWithMultipleOps.ptl"; // class ModelWithMultipleOps(torch.nn.Module): // def __init__(self): // super().__init__() // self.ops = torch.nn.Sequential( // torch.nn.ReLU(), // torch.nn.Flatten(), // ) // // def forward(self, x): // x[1] = -2 // return self.ops(x) Module bc = _load_for_mobile(testModelFile); auto b = at::ones({2, 2, 2, 2}); const auto result = bc.forward({b}); at::Tensor expected = torch::tensor({{1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0}}, c10::TensorOptions(c10::ScalarType::Float)); AT_ASSERT(result.toTensor().equal(expected)); } } // namespace mobile } // namespace jit } // namespace torch
[ "pytorchmergebot@users.noreply.github.com" ]
pytorchmergebot@users.noreply.github.com
4d0151bb90f84fb12a8feb061bcbcb5d55d3adf5
4763e7411bfbac0b3be8698e6ab42d16be749529
/cardscene.h
caa29cecda5a90b717e2ef6b06f7b12b8c80cf1d
[]
no_license
kouyk/DDZ
8732403c34d974b77c3bd8b04605e047f9515b4f
86ac5aaebd3bc0e0e009a2e13ab787a172bc34b5
refs/heads/master
2022-12-15T03:58:33.452926
2020-09-13T06:33:31
2020-09-13T06:33:31
293,142,174
1
0
null
null
null
null
UTF-8
C++
false
false
444
h
#ifndef CARDSCENE_H #define CARDSCENE_H #include <QObject> #include <QGraphicsScene> #include <QGraphicsSceneMouseEvent> #include <QDebug> #include "card.h" #include "carditem.h" class CardScene : public QGraphicsScene { Q_OBJECT public: using QGraphicsScene::QGraphicsScene; void mousePressEvent(QGraphicsSceneMouseEvent *event) override; signals: void chosen(DDZ::CardType ctype, bool selected); }; #endif // CARDSCENE_H
[ "skykinetic@stevenkou.xyz" ]
skykinetic@stevenkou.xyz
7a3dfa404204a92f473221232423a781a0ffc231
f4cb77a12afbc2c2d0590737f94f9c0913868916
/LTexture.cpp
43e1d20560456c56820ad0b0f8861ee6dc406abd
[]
no_license
ReebaAslam/StellarDefense
f4e03fa7412c1e0535e22460877566939818d6eb
62f2ded2b2964314cdab97b3424706077e800e6c
refs/heads/master
2020-03-12T23:46:22.811489
2018-07-18T13:27:02
2018-07-18T13:27:02
130,873,440
0
0
null
null
null
null
UTF-8
C++
false
false
2,453
cpp
#include"LTexture.h" LTexture::LTexture() { this->texture=nullptr; this->width=0; this->height=0; } LTexture::~LTexture() { Free(); } bool LTexture::LoadFromFile(string path, SDL_Renderer* gRenderer, bool flagColorKey, Uint8 redColorKey, Uint8 greenColorKey, Uint8 blueColorKey) { SDL_Surface* loadedSurface=nullptr; SDL_Texture* newTexture=nullptr; loadedSurface=IMG_Load(path.c_str()); if(loadedSurface==nullptr) { cout<< "Unable to load image from "<< path<< ". SDL_image error"<< IMG_GetError()<<endl; } else { //SDL_SetColorKey(loadedSurface, flagColorKey, SDL_MapRGB(loadedSurface->format, 255, 255, 255)); SDL_SetColorKey(loadedSurface, flagColorKey, SDL_MapRGB(loadedSurface->format, redColorKey, greenColorKey, blueColorKey)); //SDL_SetColorKey(loadedSurface, flagColorKey, SDL_MapRGB(loadedSurface->format, 255, 255, 255)); //SDL_SetColorKey(loadedSurface, flagColorKey, SDL_MapRGB(loadedSurface->format, 0, 0, 0)); newTexture=SDL_CreateTextureFromSurface(gRenderer, loadedSurface); if(newTexture!=nullptr) { this->width=loadedSurface->w; this->height=loadedSurface->h; } else { cout<< "Unable to create texture from surface from "<<path<< ". SDL_image error"<< IMG_GetError()<<endl; } SDL_FreeSurface(loadedSurface); } this->texture=newTexture; return this->texture!=nullptr; } void LTexture::RenderTexture(int x, int y, SDL_Renderer* gRenderer, SDL_Rect* clip, SDL_RendererFlip flip, double angle, SDL_Point* center) { SDL_Rect rectCoordinates={x, y, this->width, this->height}; if(clip!=nullptr) { rectCoordinates.w=clip->w; rectCoordinates.h=clip->h; } SDL_RenderCopyEx(gRenderer, texture, clip, &rectCoordinates, angle, center, flip); //SDL_RenderPresent(gRenderer); } void LTexture::Free() { if(texture!=nullptr) { SDL_DestroyTexture(texture); texture=nullptr; width=0; height=0; } } int LTexture::GetWidth() { return width; } int LTexture::GetHeight() { return height; } void LTexture::setBlendMode( SDL_BlendMode blending ) { //Set blending function SDL_SetTextureBlendMode( texture, blending ); } void LTexture::setAlpha( Uint8 alpha ) { //Modulate texture alpha SDL_SetTextureAlphaMod( texture, alpha ); }
[ "ra02528@st.habib.edu.pk" ]
ra02528@st.habib.edu.pk
0f264fb79da9608af3377742dcb113fe83884725
03f037d0f6371856ede958f0c9d02771d5402baf
/graphics/VTK-7.0.0/IO/Xdmf2/vtkXdmfReaderInternal.h
c90e5d289fb32e7a80af95fc34c41c18e1c24a1f
[ "BSD-3-Clause" ]
permissive
hlzz/dotfiles
b22dc2dc5a9086353ed6dfeee884f7f0a9ddb1eb
0591f71230c919c827ba569099eb3b75897e163e
refs/heads/master
2021-01-10T10:06:31.018179
2016-09-27T08:13:18
2016-09-27T08:13:18
55,040,954
4
0
null
null
null
null
UTF-8
C++
false
false
11,602
h
/*========================================================================= Program: Visualization Toolkit Module: vtkXdmfReaderInternal.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkXdmfReaderInternal -- private class(es) used by vtkXdmfReader // .SECTION Description // VTK-HeaderTest-Exclude: vtkXdmfReaderInternal.h #ifndef vtkXdmfReaderInternal_h #define vtkXdmfReaderInternal_h // NAMING CONVENTION ********************************************************* // * all member variables of the type XdmfXml* begin with XML eg. XMLNode // * all non-member variables of the type XdmfXml* begin with xml eg. xmlNode // * all member variables of the type XdmfElement (and subclasses) begin with // XMF eg. XMFGrid // * all non-member variables of the type XdmfElement (and subclasses) begin // with xmf eg. xmfGrid // *************************************************************************** #include "vtkMutableDirectedGraph.h" #include "vtkSILBuilder.h" #include "XdmfArray.h" #include "XdmfAttribute.h" #include "XdmfDOM.h" //? #include "XdmfDataDesc.h" //? #include "XdmfDataItem.h" #include "XdmfGrid.h" //? #include "XdmfTopology.h" //? #include "XdmfGeometry.h" //? #include "XdmfTime.h" //? #include "XdmfSet.h" #include <string> #include <vector> #include <set> #include <map> #include <vtksys/SystemTools.hxx> #include <cassert> #include <functional> #include <algorithm> #include <sstream> class vtkXdmfDomain; class VTKIOXDMF2_EXPORT vtkXdmfDocument { public: //--------------------------------------------------------------------------- // Description: // Parse an xmf file (or string). Both these methods use caching hence calling // these methods repeatedly with the same argument will NOT result in // re-parsing of the xmf. bool Parse(const char*xmffilename); bool ParseString(const char* xmfdata, size_t length); //--------------------------------------------------------------------------- // Description: // Returns the names for available domains. const std::vector<std::string>& GetDomains() { return this->Domains; } //--------------------------------------------------------------------------- // Description: // Set the active domain. This will result in processing of the domain xmf if // the selected domain is different from the active one. bool SetActiveDomain(const char* domainname); bool SetActiveDomain(int index); //--------------------------------------------------------------------------- // Description: // Returns the active domain. vtkXdmfDomain* GetActiveDomain() { return this->ActiveDomain; } //--------------------------------------------------------------------------- // Description: // Constructor/Destructor vtkXdmfDocument(); ~vtkXdmfDocument(); private: // Populates the list of domains. void UpdateDomains(); private: int ActiveDomainIndex; xdmf2::XdmfDOM XMLDOM; vtkXdmfDomain* ActiveDomain; std::vector<std::string> Domains; char* LastReadContents; size_t LastReadContentsLength; std::string LastReadFilename; }; // I don't use vtkDataArraySelection since it's very slow when it comes to large // number of arrays. class vtkXdmfArraySelection : public std::map<std::string, bool> { public: void Merge(const vtkXdmfArraySelection& other) { vtkXdmfArraySelection::const_iterator iter = other.begin(); for (; iter != other.end(); ++iter) { (*this)[iter->first] = iter->second; } } void AddArray(const char* name, bool status=true) { (*this)[name] = status; } bool ArrayIsEnabled(const char* name) { vtkXdmfArraySelection::iterator iter = this->find(name); if (iter != this->end()) { return iter->second; } // don't know anything about this array, enable it by default. return true; } bool HasArray(const char* name) { vtkXdmfArraySelection::iterator iter = this->find(name); return (iter != this->end()); } int GetArraySetting(const char* name) { return this->ArrayIsEnabled(name)? 1 : 0; } void SetArrayStatus(const char* name, bool status) { this->AddArray(name, status); } const char* GetArrayName(int index) { int cc=0; for (vtkXdmfArraySelection::iterator iter = this->begin(); iter != this->end(); ++iter) { if (cc==index) { return iter->first.c_str(); } cc++; } return NULL; } int GetNumberOfArrays() { return static_cast<int>(this->size()); } }; //*************************************************************************** class VTKIOXDMF2_EXPORT vtkXdmfDomain { private: XdmfInt64 NumberOfGrids; xdmf2::XdmfGrid* XMFGrids; XdmfXmlNode XMLDomain; xdmf2::XdmfDOM* XMLDOM; unsigned int GridsOverflowCounter; // these are node indices used when building the SIL. vtkIdType SILBlocksRoot; std::map<std::string, vtkIdType> GridCenteredAttrbuteRoots; std::map<vtkIdType, std::map<XdmfInt64, vtkIdType> > GridCenteredAttrbuteValues; vtkSILBuilder* SILBuilder; vtkMutableDirectedGraph* SIL; vtkXdmfArraySelection* PointArrays; vtkXdmfArraySelection* CellArrays; vtkXdmfArraySelection* Grids; vtkXdmfArraySelection* Sets; std::map<XdmfFloat64, int> TimeSteps; //< Only discrete timesteps are currently // supported. std::map<int, XdmfFloat64> TimeStepsRev; public: //--------------------------------------------------------------------------- // does not take ownership of the DOM, however the xmlDom must exist as long // as the instance is in use. vtkXdmfDomain(xdmf2::XdmfDOM* xmlDom, int domain_index); //--------------------------------------------------------------------------- // Description: // After instantiating, check that the domain is valid. If this returns false, // it means that the specified domain could not be located. bool IsValid() { return (this->XMLDomain != 0); } //--------------------------------------------------------------------------- vtkGraph* GetSIL() { return this->SIL; } //--------------------------------------------------------------------------- // Description: // Returns the number of top-level grids present in this domain. XdmfInt64 GetNumberOfGrids() { return this->NumberOfGrids; } //--------------------------------------------------------------------------- // Description: // Provides access to a top-level grid from this domain. xdmf2::XdmfGrid* GetGrid(XdmfInt64 cc); //--------------------------------------------------------------------------- // Description: // Returns the VTK data type need for this domain. If the domain has only 1 // grid, then a vtkDataSet-type is returned, otherwise a vtkMultiBlockDataSet // is required. // Returns -1 on error. int GetVTKDataType(); //--------------------------------------------------------------------------- // Description: // Returns the timesteps. const std::map<XdmfFloat64, int>& GetTimeSteps() { return this->TimeSteps; } const std::map<int,XdmfFloat64>& GetTimeStepsRev() { return this->TimeStepsRev; } //--------------------------------------------------------------------------- // Description: // Given a time value, returns the index. int GetIndexForTime(double time); //--------------------------------------------------------------------------- // Description: // Returns the time value at the given index. XdmfFloat64 GetTimeForIndex(int index) { std::map<int, XdmfFloat64>::iterator iter = this->TimeStepsRev.find(index); return (iter != this->TimeStepsRev.end()) ? iter->second : 0.0; } //--------------------------------------------------------------------------- // Description: // If xmfGrid is a temporal collection, returns the child-grid matching the // requested time. xdmf2::XdmfGrid* GetGrid(xdmf2::XdmfGrid* xmfGrid, double time); //--------------------------------------------------------------------------- // Description: // Returns true if the grids is a structured dataset. bool IsStructured(xdmf2::XdmfGrid*); //--------------------------------------------------------------------------- // Description: // Returns the whole extents for the dataset if the grid if IsStructured() // returns true for the given grid. Returns true if the extents are valid. // NOTE: returned extents are always (0, dimx-1, 0, dimy-1, 0, dimz-1). bool GetWholeExtent(xdmf2::XdmfGrid*, int extents[6]); //--------------------------------------------------------------------------- // Description: // Returns the spacing and origin for the grid if the grid topology == // XDMF_2DCORECTMESH or XDMF_3DCORECTMESH i.e. image data. Returns true if // the extents are valid. bool GetOriginAndSpacing(xdmf2::XdmfGrid*, double origin[3], double spacing[3]); //--------------------------------------------------------------------------- ~vtkXdmfDomain(); // Returns VTK data type based on grid type and topology. // Returns -1 on error. int GetVTKDataType(xdmf2::XdmfGrid* xmfGrid); // Returns the dimensionality (or rank) of the topology for the given grid. // Returns -1 is the xmfGrid is not a uniform i.e. is a collection or a tree. static int GetDataDimensionality(xdmf2::XdmfGrid* xmfGrid); vtkXdmfArraySelection* GetPointArraySelection() { return this->PointArrays; } vtkXdmfArraySelection* GetCellArraySelection() { return this->CellArrays; } vtkXdmfArraySelection* GetGridSelection() { return this->Grids; } vtkXdmfArraySelection* GetSetsSelection() { return this->Sets; } private: // Description: // There are a few meta-information that we need to collect from the domain // * number of data-arrays so that the user can choose which to load. // * grid-structure so that the user can choose the hierarchy // * time information so that reader can report the number of timesteps // available. // This does another book-keeping task of ensuring that all grids have valid // names. If a grid is not named, then we make up a name. // TODO: We can use GRID centered attributes to create hierarchies in the SIL. void CollectMetaData(); // Used by CollectMetaData(). void CollectMetaData(xdmf2::XdmfGrid* xmfGrid, vtkIdType silParent); // Used by CollectMetaData(). void CollectNonLeafMetaData(xdmf2::XdmfGrid* xmfGrid, vtkIdType silParent); // Used by CollectMetaData(). void CollectLeafMetaData(xdmf2::XdmfGrid* xmfGrid, vtkIdType silParent); // Description: // Use this to add an association with the grid attribute with the node for // the grid in the SIL if applicable. Returns true if the attribute was added. bool UpdateGridAttributeInSIL( xdmf2::XdmfAttribute* xmfAttribute, vtkIdType gridSILId); }; #endif
[ "shentianweipku@gmail.com" ]
shentianweipku@gmail.com
93d1da9e62fda469eb270ca4337299ddda8e505d
a2424f0c80a06446c8c9c32ac1e2d63bd7aa1d6b
/Source/EditorLib/Settings/SettingsPage.cpp
ff7df3c2e1b94100d04634212be6b5fff9bb9886
[ "MIT" ]
permissive
caniouff/TexGraph
6a30852866c7c3a4a278f94bbd65195951badd64
8fe72cea1afcf5e235c810003bf4ee062bb3fc13
refs/heads/master
2020-06-26T01:28:15.637110
2019-01-27T01:00:43
2019-01-27T01:00:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,247
cpp
#include "SettingsPage.h" #include "Settings.h" SettingsPage::SettingsPage(const QString& pageName, const QString& pageTip, Settings* owner) : owner_(owner), pageName_(pageName), pageTip_(pageTip) { } void SettingsPage::InitializeSetting(SettingValue* setting) { push_back(setting); } SettingValue* SettingsPage::Get(const QString& key) { for (auto setting : *this) if (setting->name_.compare(key) == 0) return setting; return 0x0; } void SettingsPage::SetValue(const QString& key, QVariant value) { auto val = Get(key); val->value_ = value; val->Notify(); } void SettingsPage::Save(QXmlStreamWriter* writer) { writer->writeStartElement("page"); writer->writeAttribute("name", GetName()); for (auto property : *this) { writer->writeStartElement("property"); writer->writeAttribute("name", property->name_); writer->writeStartElement("value"); // Apparently Qt doesn't do anything sensible like delimiting with standard illegal characters, even though ASCII control characters exist for this purpose. if (property->defaultValue_.type() == QVariant::StringList) { for (auto str : property->value_.toStringList()) { writer->writeStartElement("val"); writer->writeCharacters(str); writer->writeEndElement(); } } else writer->writeCharacters(property->value_.toString()); writer->writeEndElement(); writer->writeEndElement(); } writer->writeEndElement(); } void SettingsPage::Restore(QDomElement* parentElement) { if (parentElement && !parentElement->isNull()) { QDomElement child = parentElement->firstChildElement("property"); while (!child.isNull()) { QString propertyName = child.attribute("name"); if (auto foundProperty = Get(propertyName)) { QDomElement value = child.firstChildElement("value"); if (!value.isNull()) { if (foundProperty->defaultValue_.type() == QVariant::StringList) { QDomElement row = value.firstChildElement("val"); QStringList vals; while (!row.isNull()) { vals.push_back(row.text()); row = row.nextSiblingElement("val"); } foundProperty->value_ = QVariant(vals); foundProperty->Notify(); } else { foundProperty->value_ = QVariant(value.text()); foundProperty->Notify(); } } value = child.firstChildElement("options"); if (!value.isNull()) foundProperty->options_ = QVariant(value.text()); } child = child.nextSiblingElement("property"); } } }
[ "jonathan@jsandusky.com" ]
jonathan@jsandusky.com
f42bfdeb6b5b712e17a6a2398643bb74014c28e4
1f74553b050b88a3484f6d3d93fa09f8aaa9a826
/Homework/bai110_sodep3.cpp
9ae8a1eff7e2e395ed4c061a93049680cd45b3eb
[]
no_license
dattocngan/THCS2_PTIT
2e970942ee28a87b0c66d31667185b1c1e58e340
edbf6b944a0f3cf0065b02c49ed83b7c39c1526a
refs/heads/main
2023-04-29T06:36:45.770537
2021-05-19T16:35:24
2021-05-19T16:35:24
345,918,636
0
0
null
null
null
null
UTF-8
C++
false
false
624
cpp
#include<stdio.h> #include<math.h> #include<string.h> int checkPrime(int n){ if( n <= 1 ) return 0; if( n == 2 ) return 1; int i; for( i = 2 ; i <= sqrt(n) ; i++ ){ if( n % i == 0 ) return 0; } return 1; } int isThuanNghich(char a[]) { for ( int i = 0; i < (strlen(a)/2); i++) { if (a[i] != a[(strlen(a) - i - 1)]) { return 0; } if(checkPrime(a[i]-'0') != 1 ) return 0; } return 1; } int main(){ int t; scanf("%d",&t); getchar(); while(t--){ char a[500]; gets(a); if( isThuanNghich(a) == 1 ){ printf("YES\n"); }else printf("NO\n"); } return 0; }
[ "dattocngan@gmail.com" ]
dattocngan@gmail.com
ef737c1a21f61859e10a6e1064f39dd83f269a6f
b8499de1a793500b47f36e85828f997e3954e570
/v2_3/build/Android/Debug/app/src/main/include/Uno.Net.Sockets.SocketFlags.h
70a040c46d898f49675d0ca70369662029417c82
[]
no_license
shrivaibhav/boysinbits
37ccb707340a14f31bd57ea92b7b7ddc4859e989
04bb707691587b253abaac064317715adb9a9fe5
refs/heads/master
2020-03-24T05:22:21.998732
2018-07-26T20:06:00
2018-07-26T20:06:00
142,485,250
0
0
null
2018-07-26T20:03:22
2018-07-26T19:30:12
C++
UTF-8
C++
false
false
381
h
// This file was generated based on C:/Users/Vaibhav/AppData/Local/Fusetools/Packages/Uno.Net.Sockets/1.9.0/Socket.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Int.h> namespace g{ namespace Uno{ namespace Net{ namespace Sockets{ // public enum SocketFlags :45 uEnumType* SocketFlags_typeof(); }}}} // ::g::Uno::Net::Sockets
[ "shubhamanandoist@gmail.com" ]
shubhamanandoist@gmail.com
51f31467690e0d5dfcb999715714cd5b184af6bf
5b7fae00e72e87c434a7b2b4ece5ffc034f2022f
/base_style/main.cpp
bba6369551c6c82b7ec077e32050bfbb34ea89c6
[]
no_license
Acnologiak/mesh_generation
78548fa3ae177e638a13fdb3a18ded4375c700e3
620973d3a37b9cd116d14119cc768ad67f36e44e
refs/heads/master
2020-09-03T09:49:33.270854
2019-11-11T06:55:24
2019-11-11T06:55:24
219,439,177
0
0
null
null
null
null
UTF-8
C++
false
false
864
cpp
#include <iostream> #include "mesh_generation.h" #include "file_obj.h" int main() { figure fig; glm::ivec3 size_block(33, 33, 33), side(0, 0, 0), size(3, 3, 4); mesh_generation m_g(size_block); { std::chrono::time_point<std::chrono::system_clock> begin; std::chrono::time_point<std::chrono::system_clock> end; int second, milliseconds; begin = std::chrono::system_clock::now(); m_g.gen_mesh_thr(&fig, side, size, std::thread::hardware_concurrency()); end = std::chrono::system_clock::now(); second = std::chrono::duration_cast<std::chrono::seconds> (end - begin).count(); milliseconds = std::chrono::duration_cast<std::chrono::milliseconds> (end - begin).count() - second * 1000; std::cout << second << " " << milliseconds << std::endl; } { file_obj test(&fig, "test.obj"); test.write_file(); } system("pause"); return 0; }
[ "holodenko.a.m@gmail.com" ]
holodenko.a.m@gmail.com
76d294f930b8c96f12117333d559153eeb6b2727
38b9daafe39f937b39eefc30501939fd47f7e668
/tutorials/2WayCouplingOceanWave3D/EvalResults180628-Eta/97.4/uniform/time
870adf519b5a2e6e4c0165f9643f497c1cf0876b
[]
no_license
rubynuaa/2-way-coupling
3a292840d9f56255f38c5e31c6b30fcb52d9e1cf
a820b57dd2cac1170b937f8411bc861392d8fbaa
refs/heads/master
2020-04-08T18:49:53.047796
2018-08-29T14:22:18
2018-08-29T14:22:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,006
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 3.0.1 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "97.4/uniform"; object time; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // value 97.4000000000000057; name "97.4"; index 13141; deltaT 0.00689655; deltaT0 0.00689655; // ************************************************************************* //
[ "abenaz15@etudiant.mines-nantes.fr" ]
abenaz15@etudiant.mines-nantes.fr
5ad5805ea37a37428df777c3574c6f552f19d3ff
64178ab5958c36c4582e69b6689359f169dc6f0d
/vscode/wg/sdk/UMutableCharacter.hpp
cbd630bfde873e66e4ac74bebf22317efb90f935
[]
no_license
c-ber/cber
47bc1362f180c9e8f0638e40bf716d8ec582e074
3cb5c85abd8a6be09e0283d136c87761925072de
refs/heads/master
2023-06-07T20:07:44.813723
2023-02-28T07:43:29
2023-02-28T07:43:29
40,457,301
5
5
null
2023-05-30T19:14:51
2015-08-10T01:37:22
C++
UTF-8
C++
false
false
3,079
hpp
#pragma once #include "UCharacter.hpp" #include "EGender.hpp" #ifdef _MSC_VER #pragma pack(push, 1) #endif namespace PUBGSDK { struct alignas(1) UMutableCharacter // Size: 0x8C0 : public UCharacter // Size: 0x870 { private: typedef UMutableCharacter t_struct; typedef ExternalPtr<t_struct> t_structHelper; public: static ExternalPtr<struct UClass> StaticClass() { static ExternalPtr<struct UClass> ptr; if(!ptr) ptr = UObject::FindClassFast(1870); // id32("Class TslGame.MutableCharacter") return ptr; } uint8_t UnknownData870[0x20]; TEnumAsByte<enum EGender> Gender; /* Ofs: 0x890 Size: 0x1 - EnumProperty TslGame.MutableCharacter.Gender */ uint8_t UnknownData891[0x7]; ExternalPtr<struct UCustomizableObjectInstance> CustomizableObjectInstance; /* Ofs: 0x898 Size: 0x8 - ObjectProperty TslGame.MutableCharacter.CustomizableObjectInstance */ ExternalPtr<struct UTslCustomizableSkeletalComponent> CustomizableSkeletalComponent; /* Ofs: 0x8A0 Size: 0x8 - ObjectProperty TslGame.MutableCharacter.CustomizableSkeletalComponent */ TArray<uint8_t> InstanceDescriptor; /* Ofs: 0x8A8 Size: 0x10 - ArrayProperty TslGame.MutableCharacter.InstanceDescriptor */ uint8_t UnknownData8B8[0x8]; inline bool SetGender(t_structHelper inst, TEnumAsByte<enum EGender> value) { inst.WriteOffset(0x890, value); } inline bool SetCustomizableObjectInstance(t_structHelper inst, ExternalPtr<struct UCustomizableObjectInstance> value) { inst.WriteOffset(0x898, value); } inline bool SetCustomizableSkeletalComponent(t_structHelper inst, ExternalPtr<struct UTslCustomizableSkeletalComponent> value) { inst.WriteOffset(0x8A0, value); } inline bool SetInstanceDescriptor(t_structHelper inst, TArray<uint8_t> value) { inst.WriteOffset(0x8A8, value); } }; #ifdef VALIDATE_SDK namespace Validation{ auto constexpr sizeofUMutableCharacter = sizeof(UMutableCharacter); // 2240 static_assert(sizeof(UMutableCharacter) == 0x8C0, "Size of UMutableCharacter is not correct."); auto constexpr UMutableCharacter_Gender_Offset = offsetof(UMutableCharacter, Gender); static_assert(UMutableCharacter_Gender_Offset == 0x890, "UMutableCharacter::Gender offset is not 890"); auto constexpr UMutableCharacter_CustomizableObjectInstance_Offset = offsetof(UMutableCharacter, CustomizableObjectInstance); static_assert(UMutableCharacter_CustomizableObjectInstance_Offset == 0x898, "UMutableCharacter::CustomizableObjectInstance offset is not 898"); auto constexpr UMutableCharacter_CustomizableSkeletalComponent_Offset = offsetof(UMutableCharacter, CustomizableSkeletalComponent); static_assert(UMutableCharacter_CustomizableSkeletalComponent_Offset == 0x8a0, "UMutableCharacter::CustomizableSkeletalComponent offset is not 8a0"); auto constexpr UMutableCharacter_InstanceDescriptor_Offset = offsetof(UMutableCharacter, InstanceDescriptor); static_assert(UMutableCharacter_InstanceDescriptor_Offset == 0x8a8, "UMutableCharacter::InstanceDescriptor offset is not 8a8"); } #endif } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "1395329153@qq.com" ]
1395329153@qq.com
c0a6e6118f7c9384103f0c118852d3320522582f
25981f4c71a24a92cd4af7a676ce2861e5ff4d2c
/2_1.cpp
55d58835d51946d0099be54ce91e8be5925fb9b5
[]
no_license
AndrewBrzeczyszczykiewicz/Zadannnnie
3848183a5fe20b52c8fa662bc9bc32d6cd2a4032
634add4feceac6b199c78f5201d6a1317bc0066a
refs/heads/master
2023-02-02T16:32:48.748914
2020-12-13T16:04:26
2020-12-13T16:04:26
293,879,062
0
0
null
null
null
null
UTF-8
C++
false
false
328
cpp
#include <iostream> using namespace std; int main() { int Nline, Mcol, i, j; cout<< "Введите высоту, затем ширину прямоугольника \n"; cin>> Nline; cin>> Mcol; for (i=0; i<Nline; i++) { cout<<endl; for (j=0; j<Mcol; j++) { cout<< "*"; } } }
[ "noreply@github.com" ]
noreply@github.com
3553afdd708a901069e5f4156ff2376ddc5988b3
bd5db5d1cc687f038c731d5a98eafe031bc76a53
/FPSGame/Private/FPSObjectiveActor.cpp
eb671504a972ba0e74d9cec64e4df4e8a04fcce4
[]
no_license
NotoriousENG/UE4-StealthGame
b97ec773e55a7528a774e53cfdd5e9c56be28452
a12fbe7db97c1eeafd414a2109cb7947af70073f
refs/heads/master
2023-02-21T19:23:45.438525
2021-01-25T18:26:38
2021-01-25T18:26:38
332,838,618
0
0
null
null
null
null
UTF-8
C++
false
false
1,369
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "FPSObjectiveActor.h" #include "FPSCharacter.h" #include "Components/SphereComponent.h" #include "Kismet/GameplayStatics.h" // Sets default values AFPSObjectiveActor::AFPSObjectiveActor() { MeshComp = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MeshComp")); MeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision); RootComponent = MeshComp; SphereComp = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp")); SphereComp->SetCollisionEnabled(ECollisionEnabled::QueryOnly); SphereComp->SetCollisionResponseToAllChannels(ECR_Ignore); SphereComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap); SphereComp->SetupAttachment(MeshComp); SetReplicates(true); } // Called when the game starts or when spawned void AFPSObjectiveActor::BeginPlay() { Super::BeginPlay(); PlayEffects(); } void AFPSObjectiveActor::PlayEffects() { UGameplayStatics::SpawnEmitterAtLocation(this, PickupFX, GetActorLocation()); } void AFPSObjectiveActor::NotifyActorBeginOverlap(AActor* OtherActor) { Super::NotifyActorBeginOverlap(OtherActor); PlayEffects(); if (GetLocalRole() == ROLE_Authority) { AFPSCharacter* MyCharacter = Cast<AFPSCharacter>(OtherActor); if (MyCharacter) { MyCharacter->bIsCarryingObjective = true; Destroy(); } } }
[ "michaeljoconnell@ufl.edu" ]
michaeljoconnell@ufl.edu
b3423c5976a2900f48003620f6ffb81814781ec0
1b38cd64ed07c050bf155d3c533bffaed2548a00
/include/Camera.hpp
17503d0863e688617c04114456d420b3660d50dd
[]
no_license
charkops/simpleStlViewer
d5abe01a3fc83c60c79a0c56dccb2ae4efaefaaa
ad2a6d9f96a830876ed4b0af6b90198b4b67c0f9
refs/heads/master
2022-10-26T06:01:06.338301
2020-06-19T14:25:15
2020-06-19T14:25:15
272,636,450
0
0
null
null
null
null
UTF-8
C++
false
false
4,353
hpp
#ifndef CAMERA_H #define CAMERA_H #include <glad/glad.h> #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <vector> // Defines several possible options for camera movement. Used as abstraction to stay away from window-system specific input methods enum Camera_Movement { FORWARD, BACKWARD, LEFT, RIGHT }; // Default camera values const float YAW = -90.0f; const float PITCH = 0.0f; const float SPEED = 2.0f; const float SENSITIVITY = 0.1f; const float ZOOM = 45.0f; // An abstract camera class that processes input and calculates the corresponding Euler Angles, Vectors and Matrices for use in OpenGL class Camera { public: // camera Attributes glm::vec3 Position; glm::vec3 Front; glm::vec3 Up; glm::vec3 Right; glm::vec3 WorldUp; // euler Angles float Yaw; float Pitch; // camera options float MovementSpeed; float MouseSensitivity; float Zoom; // constructor with vectors Camera(glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 up = glm::vec3(0.0f, 1.0f, 0.0f), float yaw = YAW, float pitch = PITCH) : Front(glm::vec3(0.0f, 0.0f, -1.0f)), MovementSpeed(SPEED), MouseSensitivity(SENSITIVITY), Zoom(ZOOM) { Position = position; WorldUp = up; Yaw = yaw; Pitch = pitch; updateCameraVectors(); } // constructor with scalar values Camera(float posX, float posY, float posZ, float upX, float upY, float upZ, float yaw, float pitch) : Front(glm::vec3(0.0f, 0.0f, -1.0f)), MovementSpeed(SPEED), MouseSensitivity(SENSITIVITY), Zoom(ZOOM) { Position = glm::vec3(posX, posY, posZ); WorldUp = glm::vec3(upX, upY, upZ); Yaw = yaw; Pitch = pitch; updateCameraVectors(); } // returns the view matrix calculated using Euler Angles and the LookAt Matrix glm::mat4 GetViewMatrix() { return glm::lookAt(Position, Position + Front, Up); } // processes input received from any keyboard-like input system. Accepts input parameter in the form of camera defined ENUM (to abstract it from windowing systems) void ProcessKeyboard(Camera_Movement direction, float deltaTime) { float velocity = MovementSpeed * deltaTime; if (direction == FORWARD) Position += Front * velocity; if (direction == BACKWARD) Position -= Front * velocity; if (direction == LEFT) Position -= Right * velocity; if (direction == RIGHT) Position += Right * velocity; } // processes input received from a mouse input system. Expects the offset value in both the x and y direction. void ProcessMouseMovement(float xoffset, float yoffset, GLboolean constrainPitch = true) { xoffset *= MouseSensitivity; yoffset *= MouseSensitivity; Yaw += xoffset; Pitch += yoffset; // make sure that when pitch is out of bounds, screen doesn't get flipped if (constrainPitch) { if (Pitch > 89.0f) Pitch = 89.0f; if (Pitch < -89.0f) Pitch = -89.0f; } // update Front, Right and Up Vectors using the updated Euler angles updateCameraVectors(); } // processes input received from a mouse scroll-wheel event. Only requires input on the vertical wheel-axis void ProcessMouseScroll(float yoffset) { Zoom -= (float)yoffset; // if (Zoom < 1.0f) // Zoom = 1.0f; // if (Zoom > 45.0f) // Zoom = 45.0f; } private: // calculates the front vector from the Camera's (updated) Euler Angles void updateCameraVectors() { // calculate the new Front vector glm::vec3 front; front.x = cos(glm::radians(Yaw)) * cos(glm::radians(Pitch)); front.y = sin(glm::radians(Pitch)); front.z = sin(glm::radians(Yaw)) * cos(glm::radians(Pitch)); Front = glm::normalize(front); // also re-calculate the Right and Up vector Right = glm::normalize(glm::cross(Front, WorldUp)); // normalize the vectors, because their length gets closer to 0 the more you look up or down which results in slower movement. Up = glm::normalize(glm::cross(Right, Front)); } }; #endif
[ "charis.kopsacheilis@gmail.com" ]
charis.kopsacheilis@gmail.com
0b843fcc8947a00075d35c365e0ba4165cce7526
1e7989f683dbdbdc7e505f18b37c095b83ce422a
/06.cpp
1289ea1966ff529683cb45ddef1833c0f27edc6f
[]
no_license
Anthony-Phimmasone/cpp-HackerRank
9033a3c0106116a42dd7c80e84c40a9226a7ac6b
08d7078e00b769f236914c8afd40f6563614cb81
refs/heads/master
2020-05-15T13:48:27.202316
2019-04-20T15:36:23
2019-04-20T15:36:23
182,313,891
0
0
null
null
null
null
UTF-8
C++
false
false
563
cpp
#include <iostream> #include <cstdio> using namespace std; int max_of_four(int max, int a, int b, int c, int d) { if(a >= b && a >= c && a >= d) { max = a; } else if (b >= a && b >= c && b >= d) { max = b; } else if (c >= a && c >= b && c >= d) { max = c; } else { max = d; } return max; } int main() { int max; int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d); int ans = max_of_four(max, a, b, c, d); printf("%d", ans); return 0; }
[ "noreply@github.com" ]
noreply@github.com
833534e776cf12de52013b510a099e3f63c9825f
aa0954ce546dd96b2e9899acef37269ea5bcc43c
/adalight.ino
156c8b6c338cc81b7ef0df120ce8f6159d6d5ab1
[]
no_license
siam28/adalight
62fa7508d8686549fe263b491b35c18f881e9bd5
15e66000109b88095a3501b4b4fef9c1495be70b
refs/heads/master
2021-01-10T03:49:14.599396
2015-10-20T06:43:54
2015-10-20T06:43:54
44,586,962
0
1
null
null
null
null
UTF-8
C++
false
false
2,115
ino
#include <FastLED.h> #define NUM_LEDS 180 #define DATA_PIN 6 #define SERIALRATE 500000 #define BLACK_THRESHOLD 0 #define BLACK CRGB(0,0,0) #define CALIBRATION_TEMPERATURE TypicalLEDStrip // Color correction #define MAX_BRIGHTNESS 95 // 0-255 // Adalight sends a "Magic Word" (defined in /etc/boblight.conf) before sending the pixel data uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i; CRGB leds[NUM_LEDS]; CRGB incomes[NUM_LEDS]; void setup() { FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); FastLED.setBrightness( MAX_BRIGHTNESS ); //FastLED.setTemperature( CALIBRATION_TEMPERATURE ); //FastLED.setDither(0); //set_max_power_in_volts_and_milliamps(5, 15000); // initial RGB flash // LEDS.showColor(CRGB(255, 0, 0)); // delay(500); // LEDS.showColor(CRGB(0, 255, 0)); // delay(500); // LEDS.showColor(CRGB(0, 0, 255)); // delay(500); // LEDS.showColor(CRGB(0, 0, 0)); Serial.begin(SERIALRATE); Serial.print("Ada\n"); // Send "Magic Word" string to host } void loop() { // wait for first byte of Magic Word for (i = 0; i < sizeof prefix; ++i) { waitLoop: while (!Serial.available()); if (prefix[i] == Serial.read()) continue; i = 0; goto waitLoop; } // Hi, Lo, Checksum while (!Serial.available()); hi = Serial.read(); while (!Serial.available()); lo = Serial.read(); while (!Serial.available()); chk = Serial.read(); // if checksum does not match go back to wait if (chk != (hi ^ lo ^ 0x55)) { i = 0; goto waitLoop; } Serial.readBytes((char*)incomes, NUM_LEDS * 3); for (i = 0; i < NUM_LEDS; i++) { CRGB *led = leds + i; CRGB *income = incomes + i; if ( (*income).getAverageLight() < BLACK_THRESHOLD ) { *led = BLACK; } else { //(*led).nscale8_video(127); // 50% from previous //(*income).nscale8_video(127); // 50% from current //(*led) += (*income); (*led) = (*income); } } // shows new values FastLED.show(); //show_at_max_brightness_for_power(); /// drain the serial buffer while (Serial.available() > 0) { Serial.read(); } }
[ "siam.aumi@gmail" ]
siam.aumi@gmail
a613a7fb0344702decf8f0dbdba55f280281f30e
b7382e00b9a2b75cf4b3429034149bf267237063
/1689-minPartitons/main.cpp
5f9e4d0bf88e30e0092e315827b9920dc3b5d968
[]
no_license
vicentgg/Myleetcode
4a6ed736cb5b7d14411d8feb0d3be7d048445e8e
f5ab8f90a8efdd99a6f6fda4d37f1b2af020eb36
refs/heads/main
2023-07-19T10:05:45.280138
2021-08-25T14:33:39
2021-08-25T14:33:39
345,052,209
0
0
null
null
null
null
UTF-8
C++
false
false
683
cpp
#include<iostream> using namespace std; /* 如果一个十进制数字不含任何前导零,且每一位上的数字不是 0 就是 1 , 那么该数字就是一个 十-二进制数 。例如,101 和 1100 都是 十-二进制数,而 112 和 3001 不是。 给你一个表示十进制整数的字符串 n ,返回和为 n 的 十-二进制数 的最少数目。 思路:就是找到哪位的数字最大 并返回 */ class Solution { public: int minPartitons(string n) { int temp; temp = n[0]; for(int i = 1; i < n.length(); i ++) { if(n[i] > temp) temp = n[i]; } return temp-48; } }; int main(void) { }
[ "1342514547@qq.com" ]
1342514547@qq.com
2acf98391717fc19bc6646c39fcaa0a161b1fddd
f74028841acf63f4dd400c03b99277bd893081d3
/Lab2 files/command_line_v1.cpp
2db9d7fcb65451202f1991a972516bc4bf8a8dc5
[]
no_license
RelicBL/CS202
78ad095a82bbe3310329ccaea0f9d9dbdf673a01
014d40bde7c2e49b4b34f6aeaa53045f4647d1e0
refs/heads/master
2021-03-03T06:31:51.515274
2020-03-10T07:26:39
2020-03-10T07:26:39
245,938,878
0
0
null
null
null
null
UTF-8
C++
false
false
1,298
cpp
/* ----------------------------------------------------------------------------- FILE NAME: command_line_v1.cpp DESCRIPTION: Program that will be turned in for Lab2 USAGE: Test programs for reading command_line parameters COMPILER: GNU g++ compiler on Linux NOTES: Command_line program demonstration MODIFICATION HISTORY: Author Date Version --------------- ---------- -------------- Brandon Lieng 2020-02-11 1.0 Original version ----------------------------------------------------------------------------- */ #include <iostream> using namespace std; /* ----------------------------------------------------------------------------- FUNCTION: main() DESCRIPTION: The program's entry point RETURNS: 0 NOTES: int argc // Number of parameters on the command line char *argv[] // An array of pointer to C-strings ------------------------------------------------------------------------------- */ int main(int argc, char *argv[]) { cout << endl; for (int i = 0; i < argc; ++i) { // cout << "Command line parameter " << i << " = " << argv[i] << endl; printf("Command line parameter %d = %s \n",i, argv[i]); } cout << endl; return 0; // 0=success }
[ "RelicBL" ]
RelicBL
3262a6a3500f735a534e9e3e30777d10990395a5
394ef4ef657268024073e358c9b709966cc0f2d8
/C++ programs/Representation of a tree in the form of a string.cpp
1eff1a354e63e9fcc03eaaa9ca6dd29afadb67df
[]
no_license
svdhiren/DSA-practice
111573b98eecfd1ad908056ceca512855d21c191
b62c2546f0d1d6e5221ffbc2294469e821e11829
refs/heads/master
2023-06-20T02:11:20.808767
2021-07-17T13:52:30
2021-07-17T13:52:30
386,659,313
0
0
null
null
null
null
UTF-8
C++
false
false
1,012
cpp
#include<iostream> using namespace std; struct btnode { char data; btnode* lc; btnode* rc; }; typedef struct btnode* BTPTR; BTPTR create(char ar[], int n){ static int i=0; if(i==n || ar[i]=='.') { return NULL; } BTPTR T= new btnode; T->data=ar[i]; T->lc=T->rc=NULL; i++; T->lc=create(ar, n); i++; T->rc=create(ar, n); return T; } void print(BTPTR t){ if(t==NULL) return; cout<<t->data<<" "; print(t->lc); print(t->rc); } string s=""; void printstr(BTPTR T){ if(T==NULL) return; s+=T->data; if(T->lc==NULL && T->rc == NULL) return; s+='('; printstr(T->lc); s+=')'; if(T->rc !=NULL){ s+='('; printstr(T->rc); s+=')'; } } int main() { BTPTR root= new btnode; root=NULL; char a[50]; int size; cout<<"Enter the size of the expression: "; cin>>size; cout<<"\nEnter preorder serialization expression: "; for(int i=0; i<size; i++) cin>>a[i]; root=create(a, size); cout<<"\nThe preorder is: \n"; print(root); printstr(root); cout<<"\n"<<s; return 0; }
[ "svdhiren2000@gmail.com" ]
svdhiren2000@gmail.com
4fa21944320618aa686983d8445fb1492be9343d
41d9e15172b427069dda6d53ae46f220e8df880c
/thrsafe.h
160a046839239497d68a54678890e9e997da4364
[]
no_license
okfynr/multithreading
2f1d8666d1cd434da3a107a1d325b07581121b56
0cae41b7bb5696a3949c2f78bd05d57fa38ff25c
refs/heads/master
2020-04-24T17:16:39.511411
2019-03-06T21:48:23
2019-03-06T21:48:23
172,141,029
0
0
null
null
null
null
UTF-8
C++
false
false
1,128
h
#ifndef THRSAFE_H #define THRSAFE_H #include <vector> #include <mutex> template <typename T> class thrsafe_vector { private: std::vector<T> data; mutable std::mutex m; public: thrsafe_vector(){} thrsafe_vector(const thrsafe_vector & other) { std::lock_guard<std::mutex> lock(other.m); data = other.data; } thrsafe_vector(thrsafe_vector && other) = delete; thrsafe_vector & operator=(const thrsafe_vector &) = delete; void push_back(T value) { std::lock_guard<std::mutex> lock(m); data.push_back(value); } const thrsafe_vector & operator[](size_t num) const { std::lock_guard<std::mutex> lock(m); return data[num]; } std::vector<T> get_vector() { std::lock_guard<std::mutex> lock(m); return data; } void operator()(); void operator[](size_t); void resize(); }; template <typename T> class matrix { private: thrsafe_vector<thrsafe_vector<T>> data; mutable std::mutex m; public: matrix() {} matrix & operator=(const matrix &) = delete; void operator()(); void swap(); void row(); void rows(); void resize(); void setZero(); void cols(); void col(); //?? }; #endif // THRSAFE_H
[ "okfynr@yandex.ru" ]
okfynr@yandex.ru
b09988df72dd72fd1f880ce84fae7d83df4aa429
e9fb747b45e478c1c58a1f7317bfe770500d8bd7
/embedded/Action.h
308ed27d52b1d868c1a93d531eb2f137a75f3be7
[]
no_license
yaworsw/fake-species-costumes
18a3cfeb5b210b28e99881cba8a30a7f7a36aec7
c9ff541d7cacd450fef4ebdcb539f2b6292c3217
refs/heads/master
2020-09-09T17:16:55.682013
2016-08-27T05:13:03
2016-08-27T05:13:03
66,513,490
1
0
null
null
null
null
UTF-8
C++
false
false
107
h
#ifndef ACTION_H #define ACTION_H class Action { public: virtual bool tick() = 0; }; #endif //ACTION_H
[ "will.yaworsky@gmail.com" ]
will.yaworsky@gmail.com
da4cd5e34fac770867a5519afcdd2844b53c1394
bb7c26963a6ee931c33e08d25c282053db3d1e45
/Game/src/Map.cpp
e5071c1787240dd69515b7f5e96ce5343adefa85
[]
no_license
EKISUKE/GitHubTest
bf85afea50f41ccbd1df6f7cba09de7528932a63
961ad6edebcb0ef289b602482b6b8f90ce63b8fa
refs/heads/master
2021-01-21T10:12:55.452091
2015-07-18T10:40:27
2015-07-18T10:40:27
39,287,618
0
0
null
2015-07-18T14:26:36
2015-07-18T05:18:16
Logos
SHIFT_JIS
C++
false
false
20,593
cpp
//----------------------------------------------------------------------------- //! //! @file Map.cpp //! @brief マップ既定 //! @author YukiIshigaki //! //----------------------------------------------------------------------------- #include "Library.h" //----------------------------------------------------------------------------- //! コンストラクタ //----------------------------------------------------------------------------- Map::Map() : _pAssetMapModel(nullptr) , _pTaskMapModel (nullptr) { // モデル初期化 SAFE_NEW(_pAssetMapModel); // 地面モデルの読み込み //if(!_pAssetMapModel->load("../Model/Map/TestMap/testMapTransReset.x")){ if (!_pAssetMapModel->load("../Model/Map/TestMap/testMapAdjustment.x")){ //if (!_pAssetMapModel->load("../Model/Map/TestMap/testMap.x")){ //if(_model->load( "../Model/Map/Ground/ground_high.mqo", 1.0f ) == false){ //if(_model->load( "../Model/Map/Ground/ground_big.mqo", 1.0f ) == false){ //if(_model->load( "../Model/Map/Ground/Map.mqo", 1.0f ) == false){ //MessageBox(NULL, L"マップモデルの読み込みに失敗しました", L"エラー", MB_OK); GM_ASSERT(false, "マップモデルの読み込みに失敗しました"); } SAFE_NEW(_pTaskMapModel); _pTaskMapModel->setModel(_pAssetMapModel); _pTaskMapModel->setScale(5.0f); _pTaskMapModel->init(); // リピート数設定 AssetModelX::Frame* pGroundFrame = _pAssetMapModel->searchFrame("Ground"); s32 texRepeat = 10; if( pGroundFrame ) { pGroundFrame->setTexRepeat(texRepeat); } // スケール値設定 f32 minX = _pAssetMapModel->getMinX(); f32 maxX = _pAssetMapModel->getMaxX(); f32 minY = _pAssetMapModel->getMinY(); f32 maxY = _pAssetMapModel->getMaxY(); f32 minZ = _pAssetMapModel->getMinZ(); f32 maxZ = _pAssetMapModel->getMaxZ(); ICasCaded()->setMinMax(minX, maxX, minY, maxY, minZ, maxZ); //---- 当たり判定モデル読み込み //if( !ISystemCollision()->loadXfile(_pTestMapTask) ) if( !GmSystemCollision()->loadLandScaleWithFrame(pGroundFrame, _pTaskMapModel) ) { GM_ASSERT( false, "ランドスケープ読み込み失敗" ); } // 城のフレーム取得 AssetModelX::Frame* castle = _pAssetMapModel->searchFrame("castle"); // 城クラス初期化 _castle = new Castle(castle); string frameName = "Wall"; AssetModelX::Frame* wall = _pAssetMapModel->searchFrame(frameName.c_str()); _myWall = new CastleWall(wall); //// 城壁クラス初期化 //for( u32 i=0; i<WALL_MAX; ++i ) //{ // string frameName = "wall"; // AssetModelX::Frame* wall = _assetMapModel->searchFrame(frameName.c_str()); // _myWall[i] = new CastleWall(wall); //} // 初期化 Initialize(); } //----------------------------------------------------------------------------- //! デストラクタ //----------------------------------------------------------------------------- Map::~Map() { SAFE_DELETE(_pAssetMapModel); SAFE_DELETE(_pTaskMapModel); SAFE_DELETE(_castle); /*for( u32 i=0; i<WALL_MAX; ++i ) { SAFE_DELETE(_myWall[i]); }*/ SAFE_DELETE(_myWall); } //----------------------------------------------------------------------------- //! 初期化 //----------------------------------------------------------------------------- bool Map::Initialize() { // 城の初期化 _castle->Initialize(); //// 城壁の初期化 //for( s32 i=0; i<WALL_MAX; ++i ) //{ // _myWall[i]->Initialize(); //} _myWall->Initialize(); // 当たり判定設定 ICastleCol()->setCastleCol(_castle, _myWall); return true; } //----------------------------------------------------------------------------- //! 更新 //----------------------------------------------------------------------------- void Map::Update() { _pTaskMapModel->update(); // 城の更新 _castle->Update(); //// 城壁の更新 //for( s32 i=0; i<WALL_MAX; ++i ) //{ // _myWall[i]->Update(); //} _myWall->Update(); } //----------------------------------------------------------------------------- //! 描画 //----------------------------------------------------------------------------- void Map::Render(bool isShadow) { Matrix offsetMatrix = Matrix::translate(_position); _pTaskMapModel->setWorldMatrix(offsetMatrix); _pTaskMapModel->render(isShadow); } //----------------------------------------------------------------------------- //! デバッグ描画 //----------------------------------------------------------------------------- void Map::debugRender() { //---- デバッグ描画 _castle->debugRender(); _myWall->debugRender(); } //============================================================================= // 城壁クラスの実装 //============================================================================= //----------------------------------------------------------------------------- //! コンストラクタ //----------------------------------------------------------------------------- CastleWall::CastleWall(AssetModelX::Frame* wall) : _myStatus(nullptr) , _isCrash (false) { _wallModel = wall; // 当たり判定用AABB f32 minX = _wallModel->getMinX(); f32 maxX = _wallModel->getMaxX(); f32 minY = _wallModel->getMinY(); f32 maxY = _wallModel->getMaxY(); f32 minZ = _wallModel->getMinZ(); f32 maxZ = _wallModel->getMaxZ(); Vector3 maxVec(maxX, maxY, maxZ); Vector3 minVec(minX, minY, minZ); _colAABB.setEmpty(); _colAABB.expand(maxVec); _colAABB.expand(minVec); SAFE_NEW(_myStatus); } //----------------------------------------------------------------------------- //! デストラクタ //----------------------------------------------------------------------------- CastleWall::~CastleWall() { SAFE_DELETE(_myStatus); } //----------------------------------------------------------------------------- //! 初期化 //----------------------------------------------------------------------------- bool CastleWall::Initialize() { //// HPの初期化 //Status::Param param; //_myStatus->setParam; //// ゲージのサイズを設定 //_myStatus->setGaugeScale(10.0f, 20.0f); //// つぶされた城壁を戻す処理 _drawPosition = Vector3(-3.646f, 47.134f, 9.408f); _wallModel->setOffset(_drawPosition); // 描画フラグもどす _wallModel->setRender(true); _myStatus->setStatus(1500, 1500); _isCrash = false; _isDamage = false; return true; } //----------------------------------------------------------------------------- //! 更新 //----------------------------------------------------------------------------- void CastleWall::Update() { // 体力がなくなったら if( !_myStatus->_isActive ){ // 崩れる Crash(); } if(_isDamage){ Controller* currentController = GmControlMan()->getController(1); CameraBase* currentCamera = GmCameraMan()->getCurrentCamera(); static s32 count; count++; if( count >= 10 ){ count = 0; _isDamage = false; // 元の位置で描画 _wallModel->setOffset(_drawPosition); currentController->DisableVibration(); // currentCamera->Disablevibration(); }else{ f32 vib = LinearInterpolation(1.0f, 0.0f, (f32)_myStatus->_hp, (f32)_myStatus->_hpMax); if( vib > 1.0f ){ vib = 1.0f; } currentController->EnableVibration(vib, vib); // カメラぶれするとスカイボックスがくずれる(スカイボックスはカメラの位置をもとにしてるため) // currentCamera->Enablevibration(vib); Vibration(); } } } //----------------------------------------------------------------------------- //! デバッグ描画 //----------------------------------------------------------------------------- void CastleWall::debugRender() { drawAABB( _colAABB, Vector4(1.0f, 1.0f, 1.0f, 1.0f) ); } //----------------------------------------------------------------------------- //! 壁が崩れる //----------------------------------------------------------------------------- void CastleWall::Crash() { if( _drawPosition._y >= -100.0f ) { // 崩れる音再生 ISEManager()->playMusic(SESoundPlayerManager::SE_CRASH); _isDamage = true; _drawPosition._y -= 0.4f * Global::deltaTime; _wallModel->setOffset(_drawPosition); static f32 maxX = _colAABB._max._x; static f32 minX = _colAABB._min._x; static f32 maxZ = _colAABB._max._z; static f32 minZ = _colAABB._min._z; for( s32 i=0; i<10; ++i) { Vector3 pos = Vector3(0,0,0); s32 random = rand() % 4; if( random == 0 ){ pos._x = minX; pos._y = _drawPosition._y - 200.0f; pos._z = _drawPosition._x + (f32)(rand() % (s32)(maxZ * 2) - maxZ); }else if( random == 1 ){ pos._x = maxX; pos._y = _drawPosition._y - 200.0f; pos._z = _drawPosition._x + (f32)(rand() % (s32)(maxZ * 2) - maxZ); }else if( random == 2 ) { pos._x = _drawPosition._x + (f32)(rand() % (s32)(maxX * 2) - maxX); pos._y = _drawPosition._y - 200.0f; pos._z = minZ; }else if( random == 3 ) { pos._x = _drawPosition._x + (f32)(rand() % (s32)(maxX * 2) - maxX); pos._y = _drawPosition._y - 200.0f; pos._z = maxZ; } Vector3 mov = Vector3(0.0f, 0.01f, 0.0f); mov._x *= (rand() % 50) / 100.0f; mov._y = (rand() % 100) / 100.0f; mov._z *= (rand() % 50) / 100.0f; f32 rot = ( rand() % 20 ) / 20.0f; Radian angVel = Radian( ( rand() % 10 ) / 100.0f ); // パーティクル生成 IParticleMan()->generateParticle(pos, mov, Vector3(1.0f, 1.0f, 0.0f), Radian(rot), 100, 0, angVel, ParticleManager::PARTICLE_SMOKE); } }else if( !_isCrash ) { ISEManager()->stopMusic(SESoundPlayerManager::SE_CRASH); // 描画フラグもどす _wallModel->setRender(false); _isCrash = true; } } //----------------------------------------------------------------------------- //! ぶれ //----------------------------------------------------------------------------- void CastleWall::Vibration() { static Vector3 offset; offset._x = ( rand() % 32768 ) * (1.0f / 32768.0f); offset._y = ( rand() % 32768 ) * (1.0f / 32768.0f); offset._z = ( rand() % 32768 ) * (1.0f / 32768.0f); static f32 vibrationPower = 1.0f; Vector3 drawPos = _drawPosition + offset * vibrationPower; _wallModel->setOffset(drawPos); } //----------------------------------------------------------------------------- //! ダメージ //----------------------------------------------------------------------------- void CastleWall::Damage(u32 damage) { _myStatus->damage(damage); _isDamage = true; } //============================================================================= // 城クラスの実装 //============================================================================= //----------------------------------------------------------------------------- //! コンストラクタ //----------------------------------------------------------------------------- Castle::Castle(AssetModelX::Frame* castle) : _isCrash (false) , _myStatus(nullptr) { // 城モデル初期化 _castleModel = castle; // 当たり判定用AABB f32 minX = _castleModel->getMinX(); f32 maxX = _castleModel->getMaxX(); f32 minY = _castleModel->getMinY(); f32 maxY = _castleModel->getMaxY(); f32 minZ = _castleModel->getMinZ(); f32 maxZ = _castleModel->getMaxZ(); Vector3 maxVec(maxX, maxY, maxZ); Vector3 minVec(minX, minY, minZ); _colAABB.setEmpty(); _colAABB.expand(maxVec); _colAABB.expand(minVec); SAFE_NEW(_myStatus); } //----------------------------------------------------------------------------- //! デストラクタ //----------------------------------------------------------------------------- Castle::~Castle() { SAFE_DELETE(_myStatus); } //----------------------------------------------------------------------------- //! 初期化 //----------------------------------------------------------------------------- bool Castle::Initialize() { _drawPosition = Vector3(14.373f, 0.0f, 12.589f); _castleModel->setOffset(_drawPosition); // 描画フラグ戻す _castleModel->setRender(true); _myStatus->setStatus(3000, 3000); _isCrash = false; _isDamage = false; return true; } //----------------------------------------------------------------------------- //! 更新 //----------------------------------------------------------------------------- void Castle::Update() { // 体力がなくなったら if( !_myStatus->_isActive ) { // 崩れる Crash(); } if(_isDamage){ Controller* currentController = GmControlMan()->getController(1); CameraBase* currentCamera = GmCameraMan()->getCurrentCamera(); static s32 count; count++; if( count >= 10 ){ count = 0; _isDamage = false; // 元の位置で描画 _castleModel->setOffset(_drawPosition); currentController->DisableVibration(); // currentCamera->Disablevibration(); }else{ f32 vib = LinearInterpolation(1.0f, 0.0f, (f32)_myStatus->_hp, (f32)_myStatus->_hpMax); if( vib > 1.0f ){ vib = 1.0f; } currentController->EnableVibration(vib, vib); // currentCamera->Enablevibration(vib); Vibration(); } } } //----------------------------------------------------------------------------- //! デバッグ描画 //----------------------------------------------------------------------------- void Castle::debugRender() { drawAABB( _colAABB, Vector4(1.0f, 1.0f, 1.0f, 1.0f) ); } //----------------------------------------------------------------------------- //! 壁が崩れる //----------------------------------------------------------------------------- void Castle::Crash() { if( _drawPosition._y >= -150.0f ) { // 崩れる音再生 ISEManager()->playMusic(SESoundPlayerManager::SE_CRASH); _isDamage = true; _drawPosition._y -= 0.5f * Global::deltaTime; _castleModel->setOffset(_drawPosition); static f32 maxX = _colAABB._max._x; static f32 minX = _colAABB._min._x; static f32 maxZ = _colAABB._max._z; static f32 minZ = _colAABB._min._z; for( s32 i=0; i<10; ++i) { Vector3 pos = Vector3(0,0,0); // ランダムで四辺のどこに出すか決定 s32 random = rand() % 4; if( random == 0 ){ pos._x = minX; pos._y = _drawPosition._y - 200.0f; pos._z = _drawPosition._x + (f32)(rand() % (s32)(maxZ * 2) - maxZ); }else if( random == 1 ){ pos._x = maxX; pos._y = _drawPosition._y - 200.0f; pos._z = _drawPosition._x + (f32)(rand() % (s32)(maxZ * 2) - maxZ); }else if( random == 2 ) { pos._x = _drawPosition._x + (f32)(rand() % (s32)(maxX * 2) - maxX); pos._y = _drawPosition._y - 200.0f; pos._z = minZ; }else if( random == 3 ) { pos._x = _drawPosition._x + (f32)(rand() % (s32)(maxX * 2) - maxX); pos._y = _drawPosition._y - 200.0f; pos._z = maxZ; } Vector3 mov = Vector3(0.0f, 0.01f, 0.0f); mov._x *= (rand() % 50) / 100.0f; mov._y = (rand() % 100) / 100.0f; mov._z *= (rand() % 50) / 100.0f; f32 rot = ( rand() % 20 ) / 20.0f; Radian angVel = Radian( ( rand() % 10 ) / 100.0f ); // パーティクル生成 IParticleMan()->generateParticle(pos, mov, Vector3(1.0f, 1.0f, 0.0f), Radian(rot), 100, 0, angVel, ParticleManager::PARTICLE_SMOKE); } }else if( !_isCrash ){ ISEManager()->stopMusic(SESoundPlayerManager::SE_CRASH); _castleModel->setRender(false); _isCrash = true; } } //----------------------------------------------------------------------------- //! ぶれ //----------------------------------------------------------------------------- void Castle::Vibration() { static Vector3 offset; offset._x = ( rand() % 32768 ) * (1.0f / 32768.0f); offset._y = ( rand() % 32768 ) * (1.0f / 32768.0f); offset._z = ( rand() % 32768 ) * (1.0f / 32768.0f); static f32 vibrationPower = 1.0f; Vector3 drawPos = _drawPosition + offset * vibrationPower; _castleModel->setOffset(drawPos); } //----------------------------------------------------------------------------- //! ダメージ //----------------------------------------------------------------------------- void Castle::Damage(u32 damage) { _myStatus->damage(damage); _isDamage = true; } //============================================================================= // 城、城壁あたり判定管理クラスの実装 //============================================================================= //----------------------------------------------------------------------------- //! 攻撃衝突判定とダメージ //! @param [in] attackAABB 判定する攻撃AABB //! @param [in] damage 当たったものに与えるダメージ量 //----------------------------------------------------------------------------- void CastleCollisionManager::hitAttackAndDamage(AABB& attackAABB, Vector3&offset, u32 damage) { // 実際使う当たり判定 AABB hitAABB; hitAABB._max = attackAABB._max + offset; hitAABB._min = attackAABB._min + offset; // 城壁が壊れていなければ if( !_castleWall->isCrash() ) { // AABB vs AABB 当たり判定 if( AABBCollision::isHit(_castleWall->getAABB(), hitAABB ) ){ _castleWall->Damage(damage); return; } } // 城がアクティブかどうか if( !_castle->isCrash() ) { // AABB vs AABB 当たり判定 if( AABBCollision::isHit(_castle->getAABB(), hitAABB ) ){ _castle->Damage(damage); return; } } } //----------------------------------------------------------------------------- //! 外に出れないようにするための関数 //----------------------------------------------------------------------------- void CastleCollisionManager::hitOutRange(Vector3& position) { if( position._x >= 3600.0f ){ position._x = 3600.0f; } if( position._x <= -3600.0f ){ position._x = -3600.0f; } if( position._z >= 3600.0f ) { position._z = 3600.0f; } if( position._z <= -3600.0f ) { position._z = -3600.0f; } } //----------------------------------------------------------------------------- //! 城オブジェクト(城壁など)の近くかどうか(XButton表示用) //! @param [in] colAABB 当たり判定用AABB //! @param [in] offset AABBの座標 //! @param [in] addBouns 追加当たり判定 //! @return true:近い false:遠い //----------------------------------------------------------------------------- bool CastleCollisionManager::isNearCastleObject(AABB& aabb, Vector3& offset, f32 addBounds) { // 実際使う当たり判定 AABB hitAABB; hitAABB._max = aabb._max + offset; hitAABB._min = aabb._min + offset; // 城壁が壊れていなければ if( !_castleWall->isCrash() ) { AABB wallAABB = _castleWall->getAABB(); // 大きめの当たり判定にする wallAABB._max += addBounds; wallAABB._min -= addBounds; // AABB vs AABB 当たり判定 if( AABBCollision::isHit(wallAABB, hitAABB) ){ return true; } } // 城がアクティブかどうか if( !_castle->isCrash() ) { AABB castleAABB = _castle->getAABB(); // 大きめの当たり判定にする castleAABB._max += addBounds; castleAABB._min -= addBounds; // AABB vs AABB 当たり判定 if( AABBCollision::isHit(castleAABB, hitAABB) ){ return true; } } return false; } //----------------------------------------------------------------------------- //! 現在アクティブな当たり判定と当たっているどうか //----------------------------------------------------------------------------- Vector3 CastleCollisionManager::getSinkVal(AABB& aabb, bool& hitGround, Vector3& offset) { Vector3 sink; // 実際使う当たり判定 AABB hitAABB; hitAABB._max = aabb._max + offset; hitAABB._min = aabb._min + offset; // 城壁が壊れていなければ if( !_castleWall->isCrash() ) { // AABB vs AABB 当たり判定 sink = AABBCollision::getSinkVal(_castleWall->getAABB(), hitAABB); if( sink != Vector3(0,0,0) ){ hitGround = true; return sink; } } // 城がアクティブかどうか if( !_castle->isCrash() ) { // AABB vs AABB 当たり判定 sink = AABBCollision::getSinkVal(_castle->getAABB(), hitAABB); if( sink != Vector3(0,0,0) ){ hitGround = true; return sink; } } hitGround = false; return sink; } //----------------------------------------------------------------------------- //! 城と城壁の当たり判定設定 //----------------------------------------------------------------------------- void CastleCollisionManager::setCastleCol(Castle* colCastle, CastleWall* colCastleWall) { _castle = colCastle; _castleWall = colCastleWall; } //============================================================================= // END OF FILE //=============================================================================
[ "yuuki622800@yahoo.co.jp" ]
yuuki622800@yahoo.co.jp
2f026240744caf3568de2fa21d25281ee62b5e01
f53256b25a8717b18c8b400d19b08720c306aa40
/_Packages/_Maths/RxR/T_RxR_N3.cpp
c2cc21857cc09d634829ab21879cd7e45ead1a3a
[ "MIT" ]
permissive
HulinCedric/cpp-course
0650c6d0ba69817de8fb0e5a78704628758ff084
6bf3572208ae77ae8fb4022a40281f34bbbf4724
refs/heads/main
2023-05-13T00:22:07.853565
2021-06-03T07:51:26
2021-06-03T07:51:26
372,604,574
0
0
null
null
null
null
UTF-8
C++
false
false
2,349
cpp
// // IUT de Nice / Departement informatique / Module APO-C++ // Annee 2008_2009 - Package _Maths // // Classe RxR - Tests unitaires des operateurs =, == et != // (Cas nominaux) // // Auteur : A. Thuaire // #include "RxR.h" #include "T:\_Tests\Tests\Tests.h" void main () { Tests::Begin("_Maths.RxR", "2.0.0"); Tests::Design("Controle des operateurs (Premiere partie)", 3); Tests::Case("Premiere forme de l'operateur ="); { RxR z1(4,-7.1), z2(11, 9.81), z; z=z1; Tests::Unit(4.0, z.abscisse()); Tests::Unit(-7.1, z.ordonnee()); z=z2; Tests::Unit(11.0, z.abscisse()); Tests::Unit(9.81, z.ordonnee()); } Tests::Case("Seconde forme de l'operateur ="); { RxR z; z=12.5; Tests::Unit(12.5, z.abscisse()); Tests::Unit(0.0, z.ordonnee()); z=-4.2; Tests::Unit(-4.2, z.abscisse()); Tests::Unit(0.0, z.ordonnee()); } Tests::Case("Premiere forme de l'operateur =="); { RxR z1(0,-11), z2(2.5, 0.5), z; z=z1; Tests::Unit(true, z==z1); Tests::Unit(false, z==z2); z=z2; Tests::Unit(true, z==z2); Tests::Unit(false, z1==z2); } Tests::Case("Seconde forme de l'operateur =="); { RxR z1(-11.5, 0), z2(2.5, 0), z; z=z1; Tests::Unit(true, z==-11.5); Tests::Unit(false, z==z2); z=z2; Tests::Unit(true, z==2.5); Tests::Unit(false, z1==z2); } Tests::Case("Premiere forme de l'operateur !="); { RxR z1(1,0), z2(-0.5, 4.125), z; z=z1; Tests::Unit(false, z!=z1); Tests::Unit(true, z!=z2); z=z2; Tests::Unit(false, z!=z2); Tests::Unit(true, z1!=z2); } Tests::Case("Seconde forme de l'operateur !="); { RxR z1(1,0), z2(-0.5, 0), z; z=z1; Tests::Unit(false, z!=1); Tests::Unit(true, z!=z2); z=z2; Tests::Unit(false, z!=-0.5); Tests::Unit(true, z1!=z2); } Tests::End(); }
[ "hulin.cedric@gmail.com" ]
hulin.cedric@gmail.com
bcb3d45f2572f3f2e0c305e3d67884349326cdbd
53e7a48f8ee7eeff369c53d85566357df19fe9ad
/samples/gisVbo/src/GameCanvas.h
4d38257bbe369288b963c17de87eab6bf40fdc61
[ "Apache-2.0" ]
permissive
Yavuz1234567890/GlistEngine
4d7e3603e1c20b656150be96a3d676c05a722590
c57f0ead74ec4b584f1a6eac61e3c6d05eb41ba6
refs/heads/main
2023-07-01T14:08:15.874924
2021-08-12T00:05:56
2021-08-12T00:05:56
335,730,734
2
0
Apache-2.0
2021-02-03T19:21:48
2021-02-03T19:21:47
null
UTF-8
C++
false
false
806
h
/* * GameCanvas.h * * Created on: May 6, 2020 * Author: noyan */ #ifndef GAMECANVAS_H_ #define GAMECANVAS_H_ #include "gBaseCanvas.h" #include "gVbo.h" #include "gPlane.h" #include "gLight.h" class GameCanvas : public gBaseCanvas { public: GameCanvas(gBaseApp *root); virtual ~GameCanvas(); void setup(); void update(); void draw(); void keyPressed(int key); void keyReleased(int key); void mouseMoved(int x, int y ); void mouseDragged(int x, int y, int button); void mousePressed(int x, int y, int button); void mouseReleased(int x, int y, int button); void mouseEntered(); void mouseExited(); void showNotify(); void hideNotify(); private: gVbo vbo1, vbo2; float vertices[9]; unsigned int indices[3]; gVertex verts2[3]; gLight light; }; #endif /* GAMECANVAS_H_ */
[ "noyan.culum@gamelab.istanbul" ]
noyan.culum@gamelab.istanbul
295a22dd45074366df219fc564c2692d198053da
20b38046cf1e8412b8ea9e99f2f4a5534a7fba69
/April/12.cpp
58a2dedd7f7792478d3af0e1507e1935716f0f72
[]
no_license
sahil9001/LeetCode
814695e93a8d7068feab18db1f22c9c600679f23
cd609555d0aeecad80a306641328e52a4c35c30d
refs/heads/master
2023-06-02T14:17:47.861926
2021-06-23T10:47:53
2021-06-23T10:47:53
347,085,693
0
0
null
null
null
null
UTF-8
C++
false
false
382
cpp
class Solution { public: vector<int> constructArray(int n, int k) { vector <int> ret; for(int i = 1, j = n; i <= j; ){ if(k > 1){ ret.push_back(k % 2 ? i : j); if(k % 2 == 1){ i++; }else j--; k--; } else { ret.push_back(i++); } } return ret; } };
[ "noreply@github.com" ]
noreply@github.com
584dc108eae544b693d42ccf2763d5c139ff78dd
641fa8341d8c436ad24945bcbf8e7d7d1dd7dbb2
/services/ui/ws/window_finder.cc
90c11688eddc5a3101596b8b64e766b133bcfb01
[ "BSD-3-Clause" ]
permissive
massnetwork/mass-browser
7de0dfc541cbac00ffa7308541394bac1e945b76
67526da9358734698c067b7775be491423884339
refs/heads/master
2022-12-07T09:01:31.027715
2017-01-19T14:29:18
2017-01-19T14:29:18
73,799,690
4
4
BSD-3-Clause
2022-11-26T11:53:23
2016-11-15T09:49:29
null
UTF-8
C++
false
false
2,829
cc
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "services/ui/ws/window_finder.h" #include "base/containers/adapters.h" #include "services/ui/ws/server_window.h" #include "services/ui/ws/server_window_compositor_frame_sink_manager.h" #include "services/ui/ws/server_window_delegate.h" #include "services/ui/ws/window_coordinate_conversions.h" #include "ui/gfx/geometry/point.h" #include "ui/gfx/geometry/point_f.h" #include "ui/gfx/transform.h" namespace ui { namespace ws { bool IsValidWindowForEvents(ServerWindow* window) { ServerWindowCompositorFrameSinkManager* compositor_frame_sink_manager = window->compositor_frame_sink_manager(); // Valid windows have at least one of the two surface types. Only an underlay // is valid as we assume the window manager will likely get the event in this // case. return compositor_frame_sink_manager && (compositor_frame_sink_manager->HasCompositorFrameSinkOfType( mojom::CompositorFrameSinkType::DEFAULT) || compositor_frame_sink_manager->HasCompositorFrameSinkOfType( mojom::CompositorFrameSinkType::UNDERLAY)); } ServerWindow* FindDeepestVisibleWindowForEvents(ServerWindow* window, gfx::Point* location) { if (!window->can_accept_events()) return nullptr; const ServerWindow::Windows& children = window->children(); for (ServerWindow* child : base::Reversed(children)) { if (!child->visible() || !child->can_accept_events()) continue; // TODO(sky): support transform. gfx::Point child_location(location->x() - child->bounds().x(), location->y() - child->bounds().y()); gfx::Rect child_bounds(child->bounds().size()); child_bounds.Inset(-child->extended_hit_test_region().left(), -child->extended_hit_test_region().top(), -child->extended_hit_test_region().right(), -child->extended_hit_test_region().bottom()); if (!child_bounds.Contains(child_location)) continue; if (child->hit_test_mask() && !child->hit_test_mask()->Contains(child_location)) continue; *location = child_location; ServerWindow* result = FindDeepestVisibleWindowForEvents(child, location); if (IsValidWindowForEvents(result)) return result; } return window; } gfx::Transform GetTransformToWindow(ServerWindow* window) { gfx::Transform transform; ServerWindow* current = window; while (current->parent()) { transform.Translate(-current->bounds().x(), -current->bounds().y()); current = current->parent(); } return transform; } } // namespace ws } // namespace ui
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com
c1a8ca760d6432e0c90103601f03340a2b0ab144
c13c36506bbd3f860af20953587bc0822fccd30e
/Sorozatok/feladat.cpp
e355bdb12d85b77ecdc7c441ec38412670835c7b
[]
no_license
lezsakdomi/elte-mester-data
8bf2a7e695bfba41a3ee0bbaff20d85159b96d93
1a663fd54bcc9c430a03ebbe21b47c838e11e8ab
refs/heads/master
2022-09-01T13:03:42.141927
2019-08-06T00:20:49
2019-08-06T00:20:49
121,674,384
2
2
null
null
null
null
UTF-8
C++
false
false
1,513
cpp
#include <iostream> #define maxN 100001 using namespace std; int main(){ int m,n,x,u1,u3,u4; int K[maxN]; cin>>m; for(int t=0;t<m;t++){ n=0; u1=0; for(;;){ cin>>x; if (x==0) break; K[++n]=x; if(x==1) u1=n; } if (u1==0){ cout<<"Igen"<<endl; continue; } u4=0; u3=0; bool van2=false,van3=false,van4=false; bool van43=false, van32=false, van23=false; for(int i=u1-1;i>0; i--){ switch (K[i]){ case 1: break; case 2: van2=true; if(u3>0) van23=true; if(u3==0 && u4>0) van32=true; break; case 3: van3=true; if(u4==0) van43=true; if (u4>0 && u3==0) u3=i; break; case 4: van4=true; if(u4==0) u4=i; break; } } if(!van2 || !van3 || !van4){ cout<<"Igen"<<endl; continue; } if(van23){//van 2-3-4 minta cout<<"Nem"<<endl; continue; } if(van32 && van43){//van 3-2-4-3 minta van4=false; for(int l=u1+1;l<=n;l++) if(K[l]==4) van4=true; if (van4) cout<<"Nem"<<endl; else cout<<"Igen"<<endl; }else{ cout<<"Igen"<<endl; } }//for m return 0; }
[ "lezsakdomi1@gmail.com" ]
lezsakdomi1@gmail.com
47328fc247850a04ac13159bd424502fb99f39c7
ebacc5b1b457b08eac119e43c030281c98343aeb
/ABCBank/BankServer/CMD/QueryHistoryBill.cpp
592365383bfc9954c42e5d50e414824bc5d04a12
[]
no_license
deardeng/learning
e9993eece3ed22891f2e54df7c8cf19bf1ce89f4
338d6431cb2d64b25b3d28bbdd3e47984f422ba2
refs/heads/master
2020-05-17T13:12:43.808391
2016-02-11T16:24:09
2016-02-11T16:24:09
19,692,141
1
1
null
null
null
null
GB18030
C++
false
false
2,799
cpp
#include "QueryHistoryBill.h" #include "../DAL/BankService.h" #include "../../Public/Logging.h" #include "../../Public/JUtil.h" #include "../../Public/JinStream.h" #include "../../Public/JOutStream.h" using namespace PUBLIC; using namespace CMD; using namespace DAL; void QueryHistoryBill :: Execute(BankSession& session){ JInStream jis(session.GetRequestPack()->buf, session.GetRequestPack()->head.len); uint16 cmd = session.GetCmd(); uint32 page; jis >> page; char begin_date[11] = {0}; jis.ReadBytes(begin_date, 10); char end_date[11] = {0}; jis.ReadBytes(end_date, 10); BankService dao; int16 error_code = 0; char error_msg[31] = {0}; list<TransDetail> details; int ret = dao.QueryHistoryBill(details, page, begin_date, end_date); if(ret == 6) { error_code = 6; strcpy_s(error_msg, "没有找到数据"); LOG_INFO << error_msg; } else if(ret == -1) { error_code = -1; strcpy_s(error_msg, "数据库错误"); LOG_INFO << error_msg; } if(error_code == 0) { LOG_INFO << "查找成功"; uint16 cnt = static_cast<uint16>(details.size()); uint16 seq = 0; list<TransDetail>::const_iterator it; for(it=details.begin(); it!=details.end(); ++it) { JOutStream jos; jos << cmd; size_t lengthPos = jos.Length(); jos.Skip(2); jos << cnt << seq << error_code; seq++; jos.WriteBytes(error_msg, 30); jos.WriteBytes(it->trans_date.c_str(), 19); jos.WriteBytes(it->account_id.c_str(), 6); jos.WriteBytes(it->other_account_id.c_str(), 6); string money = Convert::DoubleToString(it->money); jos << money; jos << it->abstract_name; string balance = Convert::DoubleToString(it->balance); jos << balance; jos << it->total; size_t tailPos = jos.Length(); jos.Reposition(lengthPos); jos << (uint16)(tailPos + 8 -sizeof(ResponseHead)); jos.Reposition(tailPos); unsigned char hash[16]; MD5 md5; md5.MD5Make(hash, (unsigned char const*)jos.Data(), jos.Length()); for(int i=0; i<8; ++i) { hash[i] = hash[i] ^ hash[i+8]; hash[i] = hash[i] ^ ((cmd >> (i%2)) & 0xff); } jos.WriteBytes(hash, 8); session.Send(jos.Data(), jos.Length()); } } else { JOutStream jos; uint16 cnt = 0; uint16 seq = 0; jos << cmd; size_t lengthPos = jos.Length(); jos.Skip(2); jos << cnt << seq << error_code; jos.WriteBytes(error_msg, 30); size_t tailPos = jos.Length(); jos.Reposition(lengthPos); jos << (uint16)(tailPos + 8 - sizeof(ResponseHead)); jos.Reposition(tailPos); unsigned char hash[16]; MD5 md5; md5.MD5Make(hash, (unsigned char const*)jos.Data(), jos.Length()); for(int i=0; i<8; ++i) { hash[i] = hash[i] ^ hash[i+8]; hash[i] = hash[i] ^ ((cmd >> (i%2)) & 0xff); } jos.WriteBytes(hash, 8); session.Send(jos.Data(), jos.Length()); } }
[ "565620795@qq.com" ]
565620795@qq.com
c9f787207ccabc0079d512890c620c72c5244f41
cbf7a7854c61a420358948e79314b8f1b7415247
/bkt/Pb16.h
f5f5f47bed8627227a1389d5c3233325cbd19fd4
[]
no_license
steopeicristianioan/backtracking
9f07b1e494c4de332d748bc22a03d91aa825f698
440b384e2214f3e10e6b8d63a1946a950d907c8a
refs/heads/main
2023-08-29T11:54:10.389935
2021-10-11T14:51:22
2021-10-11T14:51:22
415,010,568
0
0
null
null
null
null
UTF-8
C++
false
false
819
h
#include <iostream> #include <fstream> using namespace std; class Pb16 { public: int n, v[11]{}, maxi = INT_MIN, mini = INT_MAX; int x[11]{}, a[11]{}, p[11]{}, ct = 0; void afis() { int aux = 0; for (int i = 1; i <= n; i++) { if (v[i] == mini || v[i] == maxi) cout << v[i] << " "; else cout << a[x[++aux]] << " "; } cout << '\n'; } void back(int k) { for (int i = 1; i <= ct; i++) if (!p[i]) { p[i] = 1; x[k] = i; if (k == ct) afis(); else if (k < ct) back(k + 1); p[i] = 0; } } void solve() { ifstream fin("fin.txt"); fin >> n; for (int i = 1; i <= n; i++) { fin >> v[i]; if (v[i] > maxi) maxi = v[i]; if (v[i] < mini) mini = v[i]; } for (int i = 1; i <= n; i++) if (v[i] != maxi && v[i] != mini) a[++ct] = v[i]; back(1); } };
[ "steopeicristianioan@gmail.com" ]
steopeicristianioan@gmail.com
820a9f5c5881ef0b23c9390927899231a98e1d2e
cd9b68f6c4e965f4b5fa9e5355896d1a9ae84f99
/src/functions.h
b0c0f064c9f088115a233082498523fa842783a4
[]
no_license
CamxxCore/ExtendedCameraSettings
d6debe349b65bc0bb56a1eaab9c3d68454526439
848d297bb258ef9ca2a0413814b06a684dd7aaee
refs/heads/master
2023-06-22T17:07:54.011283
2023-06-21T17:53:31
2023-06-21T17:53:31
71,194,810
22
8
null
2023-06-21T21:12:46
2016-10-18T01:05:44
C++
UTF-8
C++
false
false
39,919
h
#pragma once #pragma region vehicle hash map static std::map<DWORD, std::string> vehiclehash_map = { { 0x3D8FA25C, "ninef" }, { 0xA8E38B01, "ninef2" }, { 0xEB70965F, "blista" }, { 0x94204D89, "asea" }, { 0x9441D8D5, "asea2" }, { 0x1F3D44B5, "boattrailer" }, { 0xD577C962, "bus" }, { 0xB8081009, "armytanker" }, { 0xA7FF33F5, "armytrailer" }, { 0x9E6B14D6, "armytrailer2" }, { 0xEF2295C9, "suntrap" }, { 0x84718D34, "coach" }, { 0x4C80EB0E, "airbus" }, { 0x8E9254FB, "asterope" }, { 0x5D0AAC8F, "airtug" }, { 0x45D56ADA, "ambulance" }, { 0xCEEA3F4B, "barracks" }, { 0x4008EABB, "barracks2" }, { 0xCFCA3668, "baller" }, { 0x8852855, "baller2" }, { 0x32B29A4B, "bjxl" }, { 0xC1E908D2, "banshee" }, { 0x7A61B330, "benson" }, { 0x432AA566, "bfinjection" }, { 0x32B91AE8, "biff" }, { 0x8125BCF9, "blazer" }, { 0xFD231729, "blazer2" }, { 0xB44F0582, "blazer3" }, { 0xFEFD644F, "bison" }, { 0x7B8297C5, "bison2" }, { 0x67B3F020, "bison3" }, { 0x898ECCEA, "boxville" }, { 0xF21B33BE, "boxville2" }, { 0x7405E08, "boxville3" }, { 0x3FC5D440, "bobcatxl" }, { 0xAA699BB6, "bodhi2" }, { 0xD756460C, "buccaneer" }, { 0xEDD516C6, "buffalo" }, { 0x2BEC3CBE, "buffalo2" }, { 0x7074F39D, "bulldozer" }, { 0x9AE6DDA1, "bullet" }, { 0xF7004C86, "blimp" }, { 0xAFBB2CA4, "burrito" }, { 0xC9E8FF76, "burrito2" }, { 0x98171BD3, "burrito3" }, { 0x353B561D, "burrito4" }, { 0x437CF2A0, "burrito5" }, { 0x779F23AA, "cavalcade" }, { 0xD0EB2BE5, "cavalcade2" }, { 0x1B38E955, "policet" }, { 0x97FA4F36, "gburrito" }, { 0xC6C3242D, "cablecar" }, { 0x44623884, "caddy" }, { 0xDFF0594C, "caddy2" }, { 0x6FD95F68, "camper" }, { 0x7B8AB45F, "carbonizzare" }, { 0xB1D95DA0, "cheetah" }, { 0xC1AE4D16, "comet2" }, { 0x13B57D8A, "cogcabrio" }, { 0x67BC037, "coquette" }, { 0xC3FBA120, "cutter" }, { 0xA3FC0F4D, "gresley" }, { 0xBC993509, "dilettante" }, { 0x64430650, "dilettante2" }, { 0x9CF21E0F, "dune" }, { 0x1FD824AF, "dune2" }, { 0x239E390, "hotknife" }, { 0x698521E3, "dloader" }, { 0x462FE277, "dubsta" }, { 0xE882E5F6, "dubsta2" }, { 0x810369E2, "dump" }, { 0x9A5B1DCC, "rubble" }, { 0xCB44B1CA, "docktug" }, { 0x4CE68AC, "dominator" }, { 0xD7278283, "emperor" }, { 0x8FC3AADC, "emperor2" }, { 0xB5FCF74E, "emperor3" }, { 0xB2FE5CF9, "entityxf" }, { 0xFFB15B5E, "exemplar" }, { 0xDE3D9D22, "elegy2" }, { 0xDCBCBE48, "f620" }, { 0x432EA949, "fbi" }, { 0x9DC66994, "fbi2" }, { 0xE8A8BDA8, "felon" }, { 0xFAAD85EE, "felon2" }, { 0x8911B9F5, "feltzer2" }, { 0x73920F8E, "firetruk" }, { 0x50B0215A, "flatbed" }, { 0x58E49664, "forklift" }, { 0xBC32A33B, "fq2" }, { 0x1DC0BA53, "fusilade" }, { 0x71CB2FFB, "fugitive" }, { 0x7836CE2F, "futo" }, { 0x9628879C, "granger" }, { 0x94B395C5, "gauntlet" }, { 0x34B7390F, "habanero" }, { 0x5A82F9AE, "hauler" }, { 0x1A7FCEFA, "handler" }, { 0x18F25AC7, "infernus" }, { 0xB3206692, "ingot" }, { 0x34DD8AA1, "intruder" }, { 0xB9CB3B69, "issi2" }, { 0xDAC67112, "jackal" }, { 0xF8D48E7A, "journey" }, { 0x3EAB5555, "jb700" }, { 0x206D1B68, "khamelion" }, { 0x4BA4E8DC, "landstalker" }, { 0x1BF8D381, "lguard" }, { 0x81634188, "manana" }, { 0x36848602, "mesa" }, { 0xD36A4B44, "mesa2" }, { 0x84F42E51, "mesa3" }, { 0x132D5A1A, "crusader" }, { 0xED7EADA4, "minivan" }, { 0xD138A6BB, "mixer" }, { 0x1C534995, "mixer2" }, { 0xE62B361B, "monroe" }, { 0x6A4BD8F6, "mower" }, { 0x35ED670B, "mule" }, { 0xC1632BEB, "mule2" }, { 0x506434F6, "oracle" }, { 0xE18195B2, "oracle2" }, { 0x21EEE87D, "packer" }, { 0xCFCFEB3B, "patriot" }, { 0x885F3671, "pbus" }, { 0xE9805550, "penumbra" }, { 0x6D19CCBC, "peyote" }, { 0x809AA4CB, "phantom" }, { 0x831A21D5, "phoenix" }, { 0x59E0FBF3, "picador" }, { 0x7DE35E7D, "pounder" }, { 0x79FBB0C5, "police" }, { 0x8A63C7B9, "police4" }, { 0x9F05F101, "police2" }, { 0x71FA16EA, "police3" }, { 0xA46462F7, "policeold1" }, { 0x95F4C618, "policeold2" }, { 0xF8DE29A8, "pony" }, { 0x38408341, "pony2" }, { 0xA988D3A2, "prairie" }, { 0x2C33B46E, "pranger" }, { 0x8FB66F9B, "premier" }, { 0xBB6B404F, "primo" }, { 0x153E1B0A, "proptrailer" }, { 0x6210CBB0, "rancherxl" }, { 0x7341576B, "rancherxl2" }, { 0x8CB29A14, "rapidgt" }, { 0x679450AF, "rapidgt2" }, { 0x9D96B45B, "radi" }, { 0xD83C13CE, "ratloader" }, { 0xB802DD46, "rebel" }, { 0xFF22D208, "regina" }, { 0x8612B64B, "rebel2" }, { 0xBE819C63, "rentalbus" }, { 0xF26CEFF9, "ruiner" }, { 0x4543B74D, "rumpo" }, { 0x961AFEF7, "rumpo2" }, { 0x2EA68690, "rhino" }, { 0xB822A1AA, "riot" }, { 0xCD935EF9, "ripley" }, { 0x7F5C91F1, "rocoto" }, { 0x2560B2FC, "romero" }, { 0x9B909C94, "sabregt" }, { 0xDC434E51, "sadler" }, { 0x2BC345D1, "sadler2" }, { 0xB9210FD0, "sandking" }, { 0x3AF8C345, "sandking2" }, { 0xB52B5113, "schafter2" }, { 0xD37B7976, "schwarzer" }, { 0x9A9FD3DF, "scrap" }, { 0x48CECED3, "seminole" }, { 0x50732C82, "sentinel" }, { 0x3412AE2D, "sentinel2" }, { 0xBD1B39C3, "zion" }, { 0xB8E2AE18, "zion2" }, { 0x4FB1A214, "serrano" }, { 0x9BAA707C, "sheriff" }, { 0x72935408, "sheriff2" }, { 0xCFB3870C, "speedo" }, { 0x2B6DC64A, "speedo2" }, { 0xA7EDE74D, "stanier" }, { 0x5C23AF9B, "stinger" }, { 0x82E499FA, "stingergt" }, { 0x6827CF72, "stockade" }, { 0xF337AB36, "stockade3" }, { 0x66B4FC45, "stratum" }, { 0x39DA2754, "sultan" }, { 0x42F2ED16, "superd" }, { 0x16E478C1, "surano" }, { 0x29B0DA97, "surfer" }, { 0xB1D80E06, "surfer2" }, { 0x8F0E3594, "surge" }, { 0x744CA80D, "taco" }, { 0xC3DDFDCE, "tailgater" }, { 0xC703DB5F, "taxi" }, { 0x72435A19, "trash" }, { 0x61D6BA8C, "tractor" }, { 0x843B73DE, "tractor2" }, { 0x562A97BD, "tractor3" }, { 0x3CC7F596, "graintrailer" }, { 0xE82AE656, "baletrailer" }, { 0x2E19879, "tiptruck" }, { 0xC7824E5E, "tiptruck2" }, { 0x1BB290BC, "tornado" }, { 0x5B42A5C4, "tornado2" }, { 0x690A4153, "tornado3" }, { 0x86CF7CDD, "tornado4" }, { 0x73B1C3CB, "tourbus" }, { 0xB12314E0, "towtruck" }, { 0xE5A2D6C6, "towtruck2" }, { 0x1ED0A534, "utillitruck" }, { 0x34E6BF6B, "utillitruck2" }, { 0x7F2153DF, "utillitruck3" }, { 0x1F3766E3, "voodoo2" }, { 0x69F06B57, "washington" }, { 0x8B13F083, "stretch" }, { 0x3E5F6B8, "youga" }, { 0x2D3BD401, "ztype" }, { 0x2EF89E46, "sanchez" }, { 0xA960B13E, "sanchez2" }, { 0xF4E1AA15, "scorcher" }, { 0x4339CD69, "tribike" }, { 0xB67597EC, "tribike2" }, { 0xE823FB48, "tribike3" }, { 0xCE23D3BF, "fixter" }, { 0x1ABA13B5, "cruiser" }, { 0x43779C54, "bmx" }, { 0xFDEFAEC3, "policeb" }, { 0x63ABADE7, "akuma" }, { 0xABB0C0, "carbonrs" }, { 0x806B9CC3, "bagger" }, { 0xF9300CC5, "bati" }, { 0xCADD5D2D, "bati2" }, { 0xCABD11E8, "ruffian" }, { 0x77934CEE, "daemon" }, { 0x9C669788, "double" }, { 0xC9CEAF06, "pcj" }, { 0xF79A00F7, "vader" }, { 0xCEC6B9B7, "vigero" }, { 0x350D1AB, "faggio2" }, { 0x11F76C14, "hexer" }, { 0x31F0B376, "annihilator" }, { 0x2F03547B, "buzzard" }, { 0x2C75F0DD, "buzzard2" }, { 0xFCFCB68B, "cargobob" }, { 0x60A7EA10, "cargobob2" }, { 0x53174EEF, "cargobob3" }, { 0x3E48BF23, "skylift" }, { 0x1517D4D9, "polmav" }, { 0x9D0450CA, "maverick" }, { 0xDA288376, "nemesis" }, { 0x2C634FBD, "frogger" }, { 0x742E9AC0, "frogger2" }, { 0xD9927FE3, "cuban800" }, { 0x39D6779E, "duster" }, { 0x81794C70, "stunt" }, { 0x97E55D11, "mammatus" }, { 0x3F119114, "jet" }, { 0xB79C1BF5, "shamal" }, { 0x250B0C5E, "luxor" }, { 0x761E2AD3, "titan" }, { 0xB39B0AE6, "lazer" }, { 0x15F27762, "cargoplane" }, { 0x17DF5EC2, "squalo" }, { 0xC1CE1183, "marquis" }, { 0x3D961290, "dinghy" }, { 0x107F392C, "dinghy2" }, { 0x33581161, "jetmax" }, { 0xE2E7D4AB, "predator" }, { 0x1149422F, "tropic" }, { 0xC2974024, "seashark" }, { 0xDB4388E4, "seashark2" }, { 0x2DFF622F, "submersible" }, { 0xCBB2BE0E, "trailers" }, { 0xA1DA3C91, "trailers2" }, { 0x8548036D, "trailers3" }, { 0x967620BE, "tvtrailer" }, { 0x174CB172, "raketrailer" }, { 0xD46F4737, "tanker" }, { 0x782A236D, "trailerlogs" }, { 0x7BE032C6, "tr2" }, { 0x6A59902D, "tr3" }, { 0x7CAB34D0, "tr4" }, { 0xAF62F6B2, "trflat" }, { 0x2A72BEAB, "trailersmall" }, { 0x9C429B6A, "velum" }, { 0xB779A091, "adder" }, { 0x9F4B77BE, "voltic" }, { 0x142E0DC3, "vacca" }, { 0xEB298297, "bifta" }, { 0xDC60D2B, "speeder" }, { 0x58B3979C, "paradise" }, { 0x5852838, "kalahari" }, { 0xB2A716A3, "jester" }, { 0x185484E1, "turismor" }, { 0x4FF77E37, "vestra" }, { 0x2DB8D1AA, "alpha" }, { 0x1D06D681, "huntley" }, { 0x6D6F8F43, "thrust" }, { 0xF77ADE32, "massacro" }, { 0xDA5819A3, "massacro2" }, { 0xAC5DF515, "zentorno" }, { 0xB820ED5E, "blade" }, { 0x47A6BC1, "glendale" }, { 0xE644E480, "panto" }, { 0x404B6381, "pigalle" }, { 0x51D83328, "warrener" }, { 0x322CF98F, "rhapsody" }, { 0xB6410173, "dubsta3" }, { 0xCD93A7DB, "monster" }, { 0x2C509634, "sovereign" }, { 0xF683EACA, "innovation" }, { 0x4B6C568A, "hakuchou" }, { 0xBF1691E0, "furoregt" }, { 0x9D80F93, "miljet" }, { 0x3C4E2113, "coquette2" }, { 0x6FF6914, "btype" }, { 0xE2C013E, "buffalo3" }, { 0xC96B73D9, "dominator2" }, { 0x14D22159, "gauntlet2" }, { 0x49863E9C, "marshall" }, { 0x2B26F456, "dukes" }, { 0xEC8F7094, "dukes2" }, { 0x72A4C31E, "stalion" }, { 0xE80F67EE, "stalion2" }, { 0x3DEE5EDA, "blista2" }, { 0xDCBC1C3B, "blista3" }, { 0xCA495705, "dodo" }, { 0xC07107EE, "submersible2" }, { 0x39D6E83F, "hydra" }, { 0x9114EADA, "insurgent" }, { 0x7B7E56F0, "insurgent2" }, { 0x83051506, "technical" }, { 0xFB133A17, "savage" }, { 0xA09E15FD, "valkyrie" }, { 0xAE2BFE94, "kuruma" }, { 0x187D938D, "kuruma2" }, { 0xBE0E6126, "jester2" }, { 0x3822BDFE, "casco" }, { 0x403820E8, "velum2" }, { 0x825A9F4C, "guardian" }, { 0x6882FA73, "enduro" }, { 0x26321E67, "lectro" }, { 0x2B7F9DE3, "slamvan" }, { 0x31ADBBFC, "slamvan2" }, { 0xDCE1D9F7, "ratloader2" }, { 0x4019CB4C, "swift2" }, { 0xB79F589E, "luxor2" }, { 0xA29D6D10, "feltzer3" }, { 0x767164D6, "osiris" }, { 0xE2504942, "virgo" }, { 0x5E4327C8, "windsor" }, { 0x6CBD1D6D, "besra" }, { 0xEBC24DF2, "swift" }, { 0xDB6B4924, "blimp2" }, { 0xAF599F01, "vindicator" }, { 0x3FD5AA2F, "toro" }, { 0x6322B39A, "t20" }, { 0x2EC385FE, "coquette3" }, { 0x14D69010, "chino" }, { 0xA7CE1BC5, "brawler" }, { 0xC397F748, "buccaneer2" }, { 0xAED64A63, "chino2" }, { 0x81A9CDDF, "faction" }, { 0x95466BDB, "faction2" }, { 0x1F52A43F, "moonbeam" }, { 0x710A2B9B, "moonbeam2" }, { 0x86618EDA, "primo2" }, { 0x779B4F2D, "voodoo" }, { 0x7B47A6A7, "lurcher" }, { 0xCE6B35A4, "btype2" }, { 0x6FF0F727, "baller3" }, { 0x25CBE2E2, "baller4" }, { 0x1C09CF5E, "baller5" }, { 0x27B4E6B0, "baller6" }, { 0x78BC1A3C, "cargobob4" }, { 0x360A438E, "cog55" }, { 0x29FCD3E4, "cog552" }, { 0x86FE0B60, "cognoscenti" }, { 0xDBF2D57A, "cognoscenti2" }, { 0x33B47F96, "dinghy4" }, { 0xF92AEC4D, "limo2" }, { 0x9CFFFC56, "mamba" }, { 0x8C2BD0DC, "nightshade" }, { 0xA774B5A6, "schafter3" }, { 0x58CF185C, "schafter4" }, { 0xCB0E7CD9, "schafter5" }, { 0x72934BE4, "schafter6" }, { 0xED762D49, "seashark3" }, { 0x1A144F2A, "speeder2" }, { 0x2A54C47D, "supervolito" }, { 0x9C5E5644, "supervolito2" }, { 0x362CAC6D, "toro2" }, { 0x56590FE9, "tropic2" }, { 0x5BFA5C4B, "valkyrie2" }, { 0x41B77FA4, "verlierer2" }, { 0x39F9C898, "tampa" }, { 0x25C5AF13, "banshee2" }, { 0xEE6024BC, "sultanrs" } }; #pragma endregion #pragma region ped hash map static std::map<DWORD, std::string> pedhash_map = { { 0xD7114C9, "player_zero" }, { 0x9B22DBAF, "player_one" }, { 0x9B810FA2, "player_two" }, { 0xCE5FF074, "a_c_boar" }, { 0xA8683715, "a_c_chimp" }, { 0xFCFA9E1E, "a_c_cow" }, { 0x644AC75E, "a_c_coyote" }, { 0xD86B5A95, "a_c_deer" }, { 0x2FD800B7, "a_c_fish" }, { 0x6AF51FAF, "a_c_hen" }, { 0x573201B8, "a_c_cat_01" }, { 0xAAB71F62, "a_c_chickenhawk" }, { 0x56E29962, "a_c_cormorant" }, { 0x18012A9F, "a_c_crow" }, { 0x8BBAB455, "a_c_dolphin" }, { 0x471BE4B2, "a_c_humpback" }, { 0x8D8AC8B9, "a_c_killerwhale" }, { 0x6A20728, "a_c_pigeon" }, { 0xD3939DFD, "a_c_seagull" }, { 0x3C831724, "a_c_sharkhammer" }, { 0xB11BAB56, "a_c_pig" }, { 0xC3B52966, "a_c_rat" }, { 0xC2D06F53, "a_c_rhesus" }, { 0x14EC17EA, "a_c_chop" }, { 0x4E8F95A2, "a_c_husky" }, { 0x1250D7BA, "a_c_mtlion" }, { 0x349F33E1, "a_c_retriever" }, { 0x6C3F072, "a_c_sharktiger" }, { 0x431FC24C, "a_c_shepherd" }, { 0x64611296, "s_m_m_movalien_01" }, { 0x303638A7, "a_f_m_beach_01" }, { 0xBE086EFD, "a_f_m_bevhills_01" }, { 0xA039335F, "a_f_m_bevhills_02" }, { 0x3BD99114, "a_f_m_bodybuild_01" }, { 0x1FC37DBC, "a_f_m_business_02" }, { 0x654AD86E, "a_f_m_downtown_01" }, { 0x9D3DCB7A, "a_f_m_eastsa_01" }, { 0x63C8D891, "a_f_m_eastsa_02" }, { 0xFAB48BCB, "a_f_m_fatbla_01" }, { 0xB5CF80E4, "a_f_m_fatcult_01" }, { 0x38BAD33B, "a_f_m_fatwhite_01" }, { 0x52C824DE, "a_f_m_ktown_01" }, { 0x41018151, "a_f_m_ktown_02" }, { 0x169BD1E1, "a_f_m_prolhost_01" }, { 0xDE0E0969, "a_f_m_salton_01" }, { 0xB097523B, "a_f_m_skidrow_01" }, { 0xCDE955D2, "a_f_m_soucentmc_01" }, { 0x745855A1, "a_f_m_soucent_01" }, { 0xF322D338, "a_f_m_soucent_02" }, { 0x505603B9, "a_f_m_tourist_01" }, { 0x8CA0C266, "a_f_m_trampbeac_01" }, { 0x48F96F5B, "a_f_m_tramp_01" }, { 0x61C81C85, "a_f_o_genstreet_01" }, { 0xBAD7BB80, "a_f_o_indian_01" }, { 0x47CF5E96, "a_f_o_ktown_01" }, { 0xCCFF7D8A, "a_f_o_salton_01" }, { 0x3DFA1830, "a_f_o_soucent_01" }, { 0xA56DE716, "a_f_o_soucent_02" }, { 0xC79F6928, "a_f_y_beach_01" }, { 0x445AC854, "a_f_y_bevhills_01" }, { 0x5C2CF7F8, "a_f_y_bevhills_02" }, { 0x20C8012F, "a_f_y_bevhills_03" }, { 0x36DF2D5D, "a_f_y_bevhills_04" }, { 0x2799EFD8, "a_f_y_business_01" }, { 0x31430342, "a_f_y_business_02" }, { 0xAE86FDB4, "a_f_y_business_03" }, { 0xB7C61032, "a_f_y_business_04" }, { 0xF5B0079D, "a_f_y_eastsa_01" }, { 0x438A4AE, "a_f_y_eastsa_02" }, { 0x51C03FA4, "a_f_y_eastsa_03" }, { 0x689C2A80, "a_f_y_epsilon_01" }, { 0x457C64FB, "a_f_y_fitness_01" }, { 0x13C4818C, "a_f_y_fitness_02" }, { 0x2F4AEC3E, "a_f_y_genhot_01" }, { 0x7DD8FB58, "a_f_y_golfer_01" }, { 0x30830813, "a_f_y_hiker_01" }, { 0x1475B827, "a_f_y_hippie_01" }, { 0x8247D331, "a_f_y_hipster_01" }, { 0x97F5FE8D, "a_f_y_hipster_02" }, { 0xA5BA9A16, "a_f_y_hipster_03" }, { 0x199881DC, "a_f_y_hipster_04" }, { 0x92D9CC1, "a_f_y_indian_01" }, { 0xDB134533, "a_f_y_juggalo_01" }, { 0xC7496729, "a_f_y_runner_01" }, { 0x3F789426, "a_f_y_rurmeth_01" }, { 0xDB5EC400, "a_f_y_scdressy_01" }, { 0x695FE666, "a_f_y_skater_01" }, { 0x2C641D7A, "a_f_y_soucent_01" }, { 0x5A8EF9CF, "a_f_y_soucent_02" }, { 0x87B25415, "a_f_y_soucent_03" }, { 0x550C79C6, "a_f_y_tennis_01" }, { 0x9CF26183, "a_f_y_topless_01" }, { 0x563B8570, "a_f_y_tourist_01" }, { 0x9123FB40, "a_f_y_tourist_02" }, { 0x19F41F65, "a_f_y_vinewood_01" }, { 0xDAB6A0EB, "a_f_y_vinewood_02" }, { 0x379DDAB8, "a_f_y_vinewood_03" }, { 0xFAE46146, "a_f_y_vinewood_04" }, { 0xC41B062E, "a_f_y_yoga_01" }, { 0x5442C66B, "a_m_m_acult_01" }, { 0xD172497E, "a_m_m_afriamer_01" }, { 0x403DB4FD, "a_m_m_beach_01" }, { 0x787FA588, "a_m_m_beach_02" }, { 0x54DBEE1F, "a_m_m_bevhills_01" }, { 0x3FB5C3D3, "a_m_m_bevhills_02" }, { 0x7E6A64B7, "a_m_m_business_01" }, { 0xF9A6F53F, "a_m_m_eastsa_01" }, { 0x7DD91AC, "a_m_m_eastsa_02" }, { 0x94562DD7, "a_m_m_farmer_01" }, { 0x61D201B3, "a_m_m_fatlatin_01" }, { 0x6DD569F, "a_m_m_genfat_01" }, { 0x13AEF042, "a_m_m_genfat_02" }, { 0xA9EB0E42, "a_m_m_golfer_01" }, { 0x6BD9B68C, "a_m_m_hasjew_01" }, { 0x6C9B2849, "a_m_m_hillbilly_01" }, { 0x7B0E452F, "a_m_m_hillbilly_02" }, { 0xDDCAAA2C, "a_m_m_indian_01" }, { 0xD15D7E71, "a_m_m_ktown_01" }, { 0x2FDE6EB7, "a_m_m_malibu_01" }, { 0xDD817EAD, "a_m_m_mexcntry_01" }, { 0xB25D16B2, "a_m_m_mexlabor_01" }, { 0x681BD012, "a_m_m_og_boss_01" }, { 0xECCA8C15, "a_m_m_paparazzi_01" }, { 0xA9D9B69E, "a_m_m_polynesian_01" }, { 0x9712C38F, "a_m_m_prolhost_01" }, { 0x3BAD4184, "a_m_m_rurmeth_01" }, { 0x4F2E038A, "a_m_m_salton_01" }, { 0x60F4A717, "a_m_m_salton_02" }, { 0xB28C4A45, "a_m_m_salton_03" }, { 0x964511B7, "a_m_m_salton_04" }, { 0xD9D7588C, "a_m_m_skater_01" }, { 0x1EEA6BD, "a_m_m_skidrow_01" }, { 0xB8D69E3, "a_m_m_socenlat_01" }, { 0x6857C9B7, "a_m_m_soucent_01" }, { 0x9F6D37E1, "a_m_m_soucent_02" }, { 0x8BD990BA, "a_m_m_soucent_03" }, { 0xC2FBFEFE, "a_m_m_soucent_04" }, { 0xC2A87702, "a_m_m_stlat_02" }, { 0x546A5344, "a_m_m_tennis_01" }, { 0xC89F0184, "a_m_m_tourist_01" }, { 0x53B57EB0, "a_m_m_trampbeac_01" }, { 0x1EC93FD0, "a_m_m_tramp_01" }, { 0xE0E69974, "a_m_m_tranvest_01" }, { 0xF70EC5C4, "a_m_m_tranvest_02" }, { 0x55446010, "a_m_o_acult_01" }, { 0x4BA14CCA, "a_m_o_acult_02" }, { 0x8427D398, "a_m_o_beach_01" }, { 0xAD54E7A8, "a_m_o_genstreet_01" }, { 0x1536D95A, "a_m_o_ktown_01" }, { 0x20208E4D, "a_m_o_salton_01" }, { 0x2AD8921B, "a_m_o_soucent_01" }, { 0x4086BD77, "a_m_o_soucent_02" }, { 0xE32D8D0, "a_m_o_soucent_03" }, { 0x174D4245, "a_m_o_tramp_01" }, { 0xB564882B, "a_m_y_acult_01" }, { 0x80E59F2E, "a_m_y_acult_02" }, { 0x7E0961B8, "a_m_y_beachvesp_01" }, { 0xCA56FA52, "a_m_y_beachvesp_02" }, { 0xD1FEB884, "a_m_y_beach_01" }, { 0x23C7DC11, "a_m_y_beach_02" }, { 0xE7A963D9, "a_m_y_beach_03" }, { 0x76284640, "a_m_y_bevhills_01" }, { 0x668BA707, "a_m_y_bevhills_02" }, { 0x379F9596, "a_m_y_breakdance_01" }, { 0x9AD32FE9, "a_m_y_busicas_01" }, { 0xC99F21C4, "a_m_y_business_01" }, { 0xB3B3F5E6, "a_m_y_business_02" }, { 0xA1435105, "a_m_y_business_03" }, { 0xFDC653C7, "a_m_y_cyclist_01" }, { 0xFF3E88AB, "a_m_y_dhill_01" }, { 0x2DADF4AA, "a_m_y_downtown_01" }, { 0xA4471173, "a_m_y_eastsa_01" }, { 0x168775F6, "a_m_y_eastsa_02" }, { 0x77D41A3E, "a_m_y_epsilon_01" }, { 0xAA82FF9B, "a_m_y_epsilon_02" }, { 0xD1CCE036, "a_m_y_gay_01" }, { 0xA5720781, "a_m_y_gay_02" }, { 0x9877EF71, "a_m_y_genstreet_01" }, { 0x3521A8D2, "a_m_y_genstreet_02" }, { 0xD71FE131, "a_m_y_golfer_01" }, { 0xE16D8F01, "a_m_y_hasjew_01" }, { 0x50F73C0C, "a_m_y_hiker_01" }, { 0x7D03E617, "a_m_y_hippy_01" }, { 0x2307A353, "a_m_y_hipster_01" }, { 0x14D506EE, "a_m_y_hipster_02" }, { 0x4E4179C6, "a_m_y_hipster_03" }, { 0x2A22FBCE, "a_m_y_indian_01" }, { 0x2DB7EEF3, "a_m_y_jetski_01" }, { 0x91CA3E2C, "a_m_y_juggalo_01" }, { 0x1AF6542C, "a_m_y_ktown_01" }, { 0x297FF13F, "a_m_y_ktown_02" }, { 0x132C1A8E, "a_m_y_latino_01" }, { 0x696BE0A9, "a_m_y_methhead_01" }, { 0x3053E555, "a_m_y_mexthug_01" }, { 0x64FDEA7D, "a_m_y_motox_01" }, { 0x77AC8FDA, "a_m_y_motox_02" }, { 0x4B652906, "a_m_y_musclbeac_01" }, { 0xC923247C, "a_m_y_musclbeac_02" }, { 0x8384FC9F, "a_m_y_polynesian_01" }, { 0xF561A4C6, "a_m_y_roadcyc_01" }, { 0x25305EEE, "a_m_y_runner_01" }, { 0x843D9D0F, "a_m_y_runner_02" }, { 0xD7606C30, "a_m_y_salton_01" }, { 0xC1C46677, "a_m_y_skater_01" }, { 0xAFFAC2E4, "a_m_y_skater_02" }, { 0xE716BDCB, "a_m_y_soucent_01" }, { 0xACA3C8CA, "a_m_y_soucent_02" }, { 0xC3F0F764, "a_m_y_soucent_03" }, { 0x8A3703F1, "a_m_y_soucent_04" }, { 0xCF92ADE9, "a_m_y_stbla_01" }, { 0x98C7404F, "a_m_y_stbla_02" }, { 0x8674D5FC, "a_m_y_stlat_01" }, { 0x2418C430, "a_m_y_stwhi_01" }, { 0x36C6E98C, "a_m_y_stwhi_02" }, { 0xB7292F0C, "a_m_y_sunbathe_01" }, { 0xEAC2C7EE, "a_m_y_surfer_01" }, { 0xC19377E7, "a_m_y_vindouche_01" }, { 0x4B64199D, "a_m_y_vinewood_01" }, { 0x5D15BD00, "a_m_y_vinewood_02" }, { 0x1FDF4294, "a_m_y_vinewood_03" }, { 0x31C9E669, "a_m_y_vinewood_04" }, { 0xAB0A7155, "a_m_y_yoga_01" }, { 0x855E36A3, "u_m_y_proldriver_01" }, { 0x3C438CD2, "u_m_y_rsranger_01" }, { 0x6AF4185D, "u_m_y_sbike" }, { 0x9194CE03, "u_m_y_staggrm_01" }, { 0x94AE2B8C, "u_m_y_tattoo_01" }, { 0x89768941, "csb_abigail" }, { 0x703F106, "csb_anita" }, { 0xA5C787B6, "csb_anton" }, { 0xABEF0004, "csb_ballasog" }, { 0x82BF7EA1, "csb_bride" }, { 0x8CDCC057, "csb_burgerdrug" }, { 0x4430687, "csb_car3guy1" }, { 0x1383A508, "csb_car3guy2" }, { 0xA347CA8A, "csb_chef" }, { 0xA8C22996, "csb_chin_goon" }, { 0xCAE9E5D5, "csb_cletus" }, { 0x9AB35F63, "csb_cop" }, { 0xA44F6F8B, "csb_customer" }, { 0xB58D2529, "csb_denise_friend" }, { 0x1BCC157B, "csb_fos_rep" }, { 0xA28E71D7, "csb_g" }, { 0x7AAB19D2, "csb_groom" }, { 0xE8594E22, "csb_grove_str_dlr" }, { 0xEC9E8F1C, "csb_hao" }, { 0x6F139B54, "csb_hugh" }, { 0xE3420BDB, "csb_imran" }, { 0xC2005A40, "csb_janitor" }, { 0xBCC475CB, "csb_maude" }, { 0x613E626C, "csb_mweather" }, { 0xC0DB04CF, "csb_ortega" }, { 0xF41F399B, "csb_oscar" }, { 0x2F4AFE35, "csb_porndudes" }, { 0x8A8298FA, "csb_porndudes_p" }, { 0xF00B49DB, "csb_prologuedriver" }, { 0x7FA2F024, "csb_prolsec" }, { 0xC2800DBE, "csb_ramp_gang" }, { 0x858C94B8, "csb_ramp_hic" }, { 0x21F58BB4, "csb_ramp_hipster" }, { 0x616C97B9, "csb_ramp_marine" }, { 0xF64ED7D0, "csb_ramp_mex" }, { 0x2E420A24, "csb_reporter" }, { 0xAA64168C, "csb_roccopelosi" }, { 0x8BE12CEC, "csb_screen_writer" }, { 0xAEEA76B5, "csb_stripper_01" }, { 0x81441B71, "csb_stripper_02" }, { 0x6343DD19, "csb_tonya" }, { 0xDE2937F3, "csb_trafficwarden" }, { 0x95EF18E3, "cs_amandatownley" }, { 0xE7565327, "cs_andreas" }, { 0x26C3D079, "cs_ashley" }, { 0x9760192E, "cs_bankman" }, { 0x69591CF7, "cs_barry" }, { 0x7B846512, "cs_barry_p" }, { 0xB46EC356, "cs_beverly" }, { 0x908D8694, "cs_beverly_p" }, { 0xEFE5AFE6, "cs_brad" }, { 0x7228AF60, "cs_bradcadaver" }, { 0x8CCE790F, "cs_carbuyer" }, { 0xEA969C40, "cs_casey" }, { 0x30DB9D7B, "cs_chengsr" }, { 0xC1F380E6, "cs_chrisformage" }, { 0xDBCB9834, "cs_clay" }, { 0xCE81655, "cs_dale" }, { 0x8587248C, "cs_davenorton" }, { 0xECD04FE9, "cs_debra" }, { 0x6F802738, "cs_denise" }, { 0x2F016D02, "cs_devin" }, { 0x4772AF42, "cs_dom" }, { 0x3C60A153, "cs_dreyfuss" }, { 0xA3A35C2F, "cs_drfriedlander" }, { 0x47035EC1, "cs_fabien" }, { 0x585C0B52, "cs_fbisuit_01" }, { 0x62547E7, "cs_floyd" }, { 0xF9513F1, "cs_guadalope" }, { 0xC314F727, "cs_gurk" }, { 0x5B44892C, "cs_hunter" }, { 0x3034F9E2, "cs_janet" }, { 0x4440A804, "cs_jewelass" }, { 0x39677BD, "cs_jimmyboston" }, { 0xB8CC92B4, "cs_jimmydisanto" }, { 0xF09D5E29, "cs_joeminuteman" }, { 0xFA8AB881, "cs_johnnyklebitz" }, { 0x459762CA, "cs_josef" }, { 0x450EEF9D, "cs_josh" }, { 0x45463A0D, "cs_lamardavis" }, { 0x38951A1B, "cs_lazlow" }, { 0xB594F5C3, "cs_lestercrest" }, { 0x72551375, "cs_lifeinvad_01" }, { 0x5816C61A, "cs_magenta" }, { 0xFBB374CA, "cs_manuel" }, { 0x574DE134, "cs_marnie" }, { 0x43595670, "cs_martinmadrazo" }, { 0x998C7AD, "cs_maryann" }, { 0x70AEB9C8, "cs_michelle" }, { 0xB76A330F, "cs_milton" }, { 0x45918E44, "cs_molly" }, { 0x4BBA84D9, "cs_movpremf_01" }, { 0x8D67EE7D, "cs_movpremmale" }, { 0xC3CC9A75, "cs_mrk" }, { 0xCBFDA3CF, "cs_mrsphillips" }, { 0x4F921E6E, "cs_mrs_thornhill" }, { 0x4EFEB1F0, "cs_natalia" }, { 0x7896DA94, "cs_nervousron" }, { 0xE1479C0B, "cs_nigel" }, { 0x1EEC7BDC, "cs_old_man1a" }, { 0x98F9E770, "cs_old_man2" }, { 0x8B70B405, "cs_omega" }, { 0xAD340F5A, "cs_orleans" }, { 0x6B38B8F8, "cs_paper" }, { 0xCE787988, "cs_paper_p" }, { 0xDF8B1301, "cs_patricia" }, { 0x4D6DE57E, "cs_priest" }, { 0x1E9314A2, "cs_prolsec_02" }, { 0x46521A32, "cs_russiandrunk" }, { 0xC0937202, "cs_siemonyetarian" }, { 0xF6D1E04E, "cs_solomon" }, { 0xA4E0A1FE, "cs_stevehains" }, { 0x893D6805, "cs_stretch" }, { 0x42FE5370, "cs_tanisha" }, { 0x8864083D, "cs_taocheng" }, { 0x53536529, "cs_taostranslator" }, { 0x5C26040A, "cs_tenniscoach" }, { 0x3A5201C5, "cs_terry" }, { 0x69E8ABC3, "cs_tom" }, { 0x8C0FD4E2, "cs_tomepsilon" }, { 0x609B130, "cs_tracydisanto" }, { 0xD266D9D6, "cs_wade" }, { 0xEAACAAF0, "cs_zimbor" }, { 0x158C439C, "g_f_y_ballas_01" }, { 0x4E0CE5D3, "g_f_y_families_01" }, { 0xFD5537DE, "g_f_y_lost_01" }, { 0x5AA42C21, "g_f_y_vagos_01" }, { 0xF1E823A2, "g_m_m_armboss_01" }, { 0xFDA94268, "g_m_m_armgoon_01" }, { 0xE7714013, "g_m_m_armlieut_01" }, { 0xF6157D8F, "g_m_m_chemwork_01" }, { 0x9D679EF6, "g_m_m_chemwork_01_p" }, { 0xB9DD0300, "g_m_m_chiboss_01" }, { 0x99478ECD, "g_m_m_chiboss_01_p" }, { 0x106D9A99, "g_m_m_chicold_01" }, { 0xD6CB60B2, "g_m_m_chicold_01_p" }, { 0x7E4F763F, "g_m_m_chigoon_01" }, { 0xF0B79FE1, "g_m_m_chigoon_01_p" }, { 0xFF71F826, "g_m_m_chigoon_02" }, { 0x352A026F, "g_m_m_korboss_01" }, { 0x5761F4AD, "g_m_m_mexboss_01" }, { 0x4914D813, "g_m_m_mexboss_02" }, { 0xC54E878A, "g_m_y_armgoon_02" }, { 0x68709618, "g_m_y_azteca_01" }, { 0xF42EE883, "g_m_y_ballaeast_01" }, { 0x231AF63F, "g_m_y_ballaorig_01" }, { 0x23B88069, "g_m_y_ballasout_01" }, { 0xE83B93B7, "g_m_y_famca_01" }, { 0xDB729238, "g_m_y_famdnf_01" }, { 0x84302B09, "g_m_y_famfor_01" }, { 0x247502A9, "g_m_y_korean_01" }, { 0x8FEDD989, "g_m_y_korean_02" }, { 0x7CCBE17A, "g_m_y_korlieut_01" }, { 0x4F46D607, "g_m_y_lost_01" }, { 0x3D843282, "g_m_y_lost_02" }, { 0x32B11CDC, "g_m_y_lost_03" }, { 0xBDDD5546, "g_m_y_mexgang_01" }, { 0x26EF3426, "g_m_y_mexgoon_01" }, { 0x31A3498E, "g_m_y_mexgoon_02" }, { 0x964D12DC, "g_m_y_mexgoon_03" }, { 0x3A9C818D, "g_m_y_mexgoon_03_p" }, { 0x4F3FBA06, "g_m_y_pologoon_01" }, { 0x925F7838, "g_m_y_pologoon_01_p" }, { 0xA2E86156, "g_m_y_pologoon_02" }, { 0x59279E8B, "g_m_y_pologoon_02_p" }, { 0x905CE0CA, "g_m_y_salvaboss_01" }, { 0x278C8CB7, "g_m_y_salvagoon_01" }, { 0x3273A285, "g_m_y_salvagoon_02" }, { 0x3B8C510, "g_m_y_salvagoon_03" }, { 0x70C720B0, "g_m_y_salvagoon_03_p" }, { 0xFD1C49BB, "g_m_y_strpunk_01" }, { 0xDA1EAC6, "g_m_y_strpunk_02" }, { 0x3B474ADF, "hc_driver" }, { 0xB881AEE, "hc_gunman" }, { 0x99BB00F8, "hc_hacker" }, { 0x400AEC41, "ig_abigail" }, { 0x6D1E15F7, "ig_amandatownley" }, { 0x47E4EEA0, "ig_andreas" }, { 0x7EF440DB, "ig_ashley" }, { 0xA70B4A92, "ig_ballasog" }, { 0x909D9E7F, "ig_bankman" }, { 0x2F8845A3, "ig_barry" }, { 0x6BE09789, "ig_barry_p" }, { 0x5746CD96, "ig_bestmen" }, { 0xBDA21E5C, "ig_beverly" }, { 0xD2318967, "ig_beverly_p" }, { 0xBDBB4922, "ig_brad" }, { 0x6162EC47, "ig_bride" }, { 0x84F9E937, "ig_car3guy1" }, { 0x75C34ACA, "ig_car3guy2" }, { 0xE0FA2554, "ig_casey" }, { 0x49EADBF6, "ig_chef" }, { 0xAAE4EA7B, "ig_chengsr" }, { 0x286E54A7, "ig_chrisformage" }, { 0x6CCFE08A, "ig_clay" }, { 0x9D0087A8, "ig_claypain" }, { 0xE6631195, "ig_cletus" }, { 0x467415E9, "ig_dale" }, { 0x15CD4C33, "ig_davenorton" }, { 0x820B33BD, "ig_denise" }, { 0x7461A0B0, "ig_devin" }, { 0x9C2DB088, "ig_dom" }, { 0xDA890932, "ig_dreyfuss" }, { 0xCBFC0DF5, "ig_drfriedlander" }, { 0xD090C350, "ig_fabien" }, { 0x3AE4A33B, "ig_fbisuit_01" }, { 0xB1B196B2, "ig_floyd" }, { 0xFECE8B85, "ig_groom" }, { 0x65978363, "ig_hao" }, { 0xCE1324DE, "ig_hunter" }, { 0xD6D9C49, "ig_janet" }, { 0x7A32EE74, "ig_jay_norris" }, { 0xF5D26BB, "ig_jewelass" }, { 0xEDA0082D, "ig_jimmyboston" }, { 0x570462B9, "ig_jimmydisanto" }, { 0xBE204C9B, "ig_joeminuteman" }, { 0x87CA80AE, "ig_johnnyklebitz" }, { 0xE11A9FB4, "ig_josef" }, { 0x799E9EEE, "ig_josh" }, { 0x5B3BD90D, "ig_kerrymcintosh" }, { 0x65B93076, "ig_lamardavis" }, { 0xDFE443E5, "ig_lazlow" }, { 0x4DA6E849, "ig_lestercrest" }, { 0x5389A93C, "ig_lifeinvad_01" }, { 0x27BD51D4, "ig_lifeinvad_02" }, { 0xFCDC910A, "ig_magenta" }, { 0xFD418E10, "ig_manuel" }, { 0x188232D0, "ig_marnie" }, { 0xA36F9806, "ig_maryann" }, { 0x3BE8287E, "ig_maude" }, { 0xBF9672F4, "ig_michelle" }, { 0xCB3059B2, "ig_milton" }, { 0xAF03DDE1, "ig_molly" }, { 0xEDDCAB6D, "ig_mrk" }, { 0x3862EEA8, "ig_mrsphillips" }, { 0x1E04A96B, "ig_mrs_thornhill" }, { 0xDE17DD3B, "ig_natalia" }, { 0xBD006AF1, "ig_nervousron" }, { 0xC8B7167D, "ig_nigel" }, { 0x719D27F4, "ig_old_man1a" }, { 0xEF154C47, "ig_old_man2" }, { 0x60E6A7D8, "ig_omega" }, { 0x2DC6D3E7, "ig_oneil" }, { 0x61D4C771, "ig_orleans" }, { 0x26A562B7, "ig_ortega" }, { 0x999B00C6, "ig_paper" }, { 0xC56E118C, "ig_patricia" }, { 0x6437E77D, "ig_priest" }, { 0x27B3AD75, "ig_prolsec_02" }, { 0xE52E126C, "ig_ramp_gang" }, { 0x45753032, "ig_ramp_hic" }, { 0xDEEF9F6E, "ig_ramp_hipster" }, { 0xE6AC74A4, "ig_ramp_mex" }, { 0xD5BA52FF, "ig_roccopelosi" }, { 0x3D0A5EB1, "ig_russiandrunk" }, { 0xFFE63677, "ig_screen_writer" }, { 0x4C7B2F05, "ig_siemonyetarian" }, { 0x86BDFE26, "ig_solomon" }, { 0x382121C8, "ig_stevehains" }, { 0x36984358, "ig_stretch" }, { 0xE793C8E8, "ig_talina" }, { 0xD810489, "ig_tanisha" }, { 0xDC5C5EA5, "ig_taocheng" }, { 0x7C851464, "ig_taostranslator" }, { 0x21D46437, "ig_taostranslator_p" }, { 0xA23B5F57, "ig_tenniscoach" }, { 0x67000B94, "ig_terry" }, { 0xCD777AAA, "ig_tomepsilon" }, { 0xCAC85344, "ig_tonya" }, { 0xDE352A35, "ig_tracydisanto" }, { 0x5719786D, "ig_trafficwarden" }, { 0x5265F707, "ig_tylerdix" }, { 0x92991B72, "ig_wade" }, { 0xB34D6F5, "ig_zimbor" }, { 0x73DEA88B, "mp_f_deadhooker" }, { 0x9C9EFFD8, "mp_f_freemode_01" }, { 0xD128FF9D, "mp_f_misty_01" }, { 0x2970A494, "mp_f_stripperlite" }, { 0x6C9DD7C9, "mp_g_m_pros_01" }, { 0x45F92D79, "mp_headtargets" }, { 0xC0F371B7, "mp_m_claude_01" }, { 0x45348DBB, "mp_m_exarmy_01" }, { 0x33A464E5, "mp_m_famdd_01" }, { 0x5CDEF405, "mp_m_fibsec_01" }, { 0x705E61F2, "mp_m_freemode_01" }, { 0x38430167, "mp_m_marston_01" }, { 0xEEDACFC9, "mp_m_niko_01" }, { 0x18CE57D0, "mp_m_shopkeep_01" }, { 0xCDEF5408, "mp_s_m_armoured_01" }, { 0x163B875B, "s_f_m_fembarber" }, { 0xE093C5C6, "s_f_m_maid_01" }, { 0xAE47E4B0, "s_f_m_shop_high" }, { 0x312B5BC0, "s_f_m_sweatshop_01" }, { 0x5D71A46F, "s_f_y_airhostess_01" }, { 0x780C01BD, "s_f_y_bartender_01" }, { 0x4A8E5536, "s_f_y_baywatch_01" }, { 0x15F8700D, "s_f_y_cop_01" }, { 0x69F46BF3, "s_f_y_factory_01" }, { 0x28ABF95, "s_f_y_hooker_01" }, { 0x14C3E407, "s_f_y_hooker_02" }, { 0x31640AC, "s_f_y_hooker_03" }, { 0xD55B2BF5, "s_f_y_migrant_01" }, { 0x2300C816, "s_f_y_movprem_01" }, { 0x9FC7F637, "s_f_y_ranger_01" }, { 0xAB594AB6, "s_f_y_scrubs_01" }, { 0x4161D042, "s_f_y_sheriff_01" }, { 0xA96E2604, "s_f_y_shop_low" }, { 0x3EECBA5D, "s_f_y_shop_mid" }, { 0x5C14EDFA, "s_f_y_stripperlite" }, { 0x52580019, "s_f_y_stripper_01" }, { 0x6E0FB794, "s_f_y_stripper_02" }, { 0x8502B6B2, "s_f_y_sweatshop_01" }, { 0xDE9A30A, "s_m_m_ammucountry" }, { 0x95C76ECD, "s_m_m_armoured_01" }, { 0x63858A4A, "s_m_m_armoured_02" }, { 0x40EABE3, "s_m_m_autoshop_01" }, { 0xF06B849D, "s_m_m_autoshop_02" }, { 0x9FD4292D, "s_m_m_bouncer_01" }, { 0x2EFEAFD5, "s_m_m_chemsec_01" }, { 0x625D6958, "s_m_m_ciasec_01" }, { 0x1A021B83, "s_m_m_cntrybar_01" }, { 0x14D7B4E0, "s_m_m_dockwork_01" }, { 0xD47303AC, "s_m_m_doctor_01" }, { 0xEDBC7546, "s_m_m_fiboffice_01" }, { 0x26F067AD, "s_m_m_fiboffice_02" }, { 0xA956BD9E, "s_m_m_gaffer_01" }, { 0x49EA5685, "s_m_m_gardener_01" }, { 0x1880ED06, "s_m_m_gentransport" }, { 0x418DFF92, "s_m_m_hairdress_01" }, { 0xF161D212, "s_m_m_highsec_01" }, { 0x2930C1AB, "s_m_m_highsec_02" }, { 0xA96BD9EC, "s_m_m_janitor" }, { 0x9E80D2CE, "s_m_m_lathandy_01" }, { 0xDE0077FD, "s_m_m_lifeinvad_01" }, { 0xDB9C0997, "s_m_m_linecook" }, { 0x765AAAE4, "s_m_m_lsmetro_01" }, { 0x7EA4FFA6, "s_m_m_mariachi_01" }, { 0xF2DAA2ED, "s_m_m_marine_01" }, { 0xF0259D83, "s_m_m_marine_02" }, { 0xED0CE4C6, "s_m_m_migrant_01" }, { 0xAC4B4506, "u_m_y_zombie_01" }, { 0xD85E6D28, "s_m_m_movprem_01" }, { 0xE7B31432, "s_m_m_movspace_01" }, { 0xB353629E, "s_m_m_paramedic_01" }, { 0xE75B4B1C, "s_m_m_pilot_01" }, { 0xF63DE8E1, "s_m_m_pilot_02" }, { 0x62599034, "s_m_m_postal_01" }, { 0x7367324F, "s_m_m_postal_02" }, { 0x56C96FC6, "s_m_m_prisguard_01" }, { 0x4117D39B, "s_m_m_scientist_01" }, { 0xD768B228, "s_m_m_security_01" }, { 0x1AE8BB58, "s_m_m_snowcop_01" }, { 0x795AC7A8, "s_m_m_strperf_01" }, { 0x1C0077FB, "s_m_m_strpreach_01" }, { 0xCE9113A9, "s_m_m_strvend_01" }, { 0x59511A6C, "s_m_m_trucker_01" }, { 0x9FC37F22, "s_m_m_ups_01" }, { 0xD0BDE116, "s_m_m_ups_02" }, { 0xAD9EF1BB, "s_m_o_busker_01" }, { 0x62018559, "s_m_y_airworker" }, { 0x9E08633D, "s_m_y_ammucity_01" }, { 0x62CC28E2, "s_m_y_armymech_01" }, { 0xB2273D4E, "s_m_y_autopsy_01" }, { 0xE5A11106, "s_m_y_barman_01" }, { 0xB4A6862, "s_m_y_baywatch_01" }, { 0xB3F3EE34, "s_m_y_blackops_01" }, { 0x7A05FA59, "s_m_y_blackops_02" }, { 0xD8F9CD47, "s_m_y_busboy_01" }, { 0xF977CEB, "s_m_y_chef_01" }, { 0x4498DDE, "s_m_y_clown_01" }, { 0xD7DA9E99, "s_m_y_construct_01" }, { 0xC5FEFADE, "s_m_y_construct_02" }, { 0x5E3DA4A4, "s_m_y_cop_01" }, { 0xE497BBEF, "s_m_y_dealer_01" }, { 0x9B557274, "s_m_y_devinsec_01" }, { 0x867639D1, "s_m_y_dockwork_01" }, { 0x22911304, "s_m_y_doorman_01" }, { 0x75D30A91, "s_m_y_dwservice_01" }, { 0xF5908A06, "s_m_y_dwservice_02" }, { 0x4163A158, "s_m_y_factory_01" }, { 0xB6B1EDA8, "s_m_y_fireman_01" }, { 0xEE75A00F, "s_m_y_garbage" }, { 0x309E7DEA, "s_m_y_grip_01" }, { 0x739B1EF5, "s_m_y_hwaycop_01" }, { 0x65793043, "s_m_y_marine_01" }, { 0x58D696FE, "s_m_y_marine_02" }, { 0x72C0CAD2, "s_m_y_marine_03" }, { 0x3CDCA742, "s_m_y_mime" }, { 0x48114518, "s_m_y_pestcont_01" }, { 0xAB300C07, "s_m_y_pilot_01" }, { 0x5F2113A1, "s_m_y_prismuscl_01" }, { 0xB1BB9B59, "s_m_y_prisoner_01" }, { 0xEF7135AE, "s_m_y_ranger_01" }, { 0xC05E1399, "s_m_y_robber_01" }, { 0xB144F9B9, "s_m_y_sheriff_01" }, { 0x6E122C06, "s_m_y_shop_mask" }, { 0x927F2323, "s_m_y_strvend_01" }, { 0x8D8F1B10, "s_m_y_swat_01" }, { 0xCA0050E9, "s_m_y_uscg_01" }, { 0x3B96F23E, "s_m_y_valet_01" }, { 0xAD4C724C, "s_m_y_waiter_01" }, { 0x550D8D9D, "s_m_y_winclean_01" }, { 0x441405EC, "s_m_y_xmech_01" }, { 0xBE20FA04, "s_m_y_xmech_02" }, { 0x2E140314, "u_f_m_corpse_01" }, { 0x414FA27B, "u_f_m_miranda" }, { 0xA20899E7, "u_f_m_promourn_01" }, { 0x35578634, "u_f_o_moviestar" }, { 0xC512DD23, "u_f_o_prolhost_01" }, { 0xFA389D4F, "u_f_y_bikerchic" }, { 0xB6AA85CE, "u_f_y_comjane" }, { 0x9C70109D, "u_f_y_corpse_01" }, { 0xD9C72F8, "u_f_y_corpse_02" }, { 0x969B6DFE, "u_f_y_hotposh_01" }, { 0xF0D4BE2E, "u_f_y_jewelass_01" }, { 0x5DCA2528, "u_f_y_mistress" }, { 0x23E9A09E, "u_f_y_poppymich" }, { 0xD2E3A284, "u_f_y_princess" }, { 0x5B81D86C, "u_f_y_spyactress" }, { 0xF0EC56E2, "u_m_m_aldinapoli" }, { 0xC306D6F5, "u_m_m_bankman" }, { 0x76474545, "u_m_m_bikehire_01" }, { 0x342333D3, "u_m_m_fibarchitect" }, { 0x2B6E1BB6, "u_m_m_filmdirector" }, { 0x45BB1666, "u_m_m_glenstank_01" }, { 0xC454BCBB, "u_m_m_griff_01" }, { 0xCE2CB751, "u_m_m_jesus_01" }, { 0xACCCBDB6, "u_m_m_jewelsec_01" }, { 0xE6CC3CDC, "u_m_m_jewelthief" }, { 0x1C95CB0B, "u_m_m_markfost" }, { 0x81F74DE7, "u_m_m_partytarget" }, { 0x709220C7, "u_m_m_prolsec_01" }, { 0xCE96030B, "u_m_m_promourn_01" }, { 0x60D5D6DA, "u_m_m_rivalpap" }, { 0xAC0EA5D8, "u_m_m_spyactor" }, { 0x90769A8F, "u_m_m_willyfist" }, { 0x46E39E63, "u_m_o_finguru_01" }, { 0x9A1E5E52, "u_m_o_taphillbilly" }, { 0x6A8F1F9B, "u_m_o_tramp_01" }, { 0xF0AC2626, "u_m_y_abner" }, { 0xCF623A2C, "u_m_y_antonb" }, { 0xDA116E7E, "u_m_y_babyd" }, { 0x5244247D, "u_m_y_baygor" }, { 0x8B7D3766, "u_m_y_burgerdrug_01" }, { 0x24604B2B, "u_m_y_chip" }, { 0x2D0EFCEB, "u_m_y_cyclist_01" }, { 0x85B9C668, "u_m_y_fibmugger_01" }, { 0xC6B49A2F, "u_m_y_guido_01" }, { 0xB3229752, "u_m_y_gunvend_01" }, { 0xF041880B, "u_m_y_hippie_01" }, { 0x348065F5, "u_m_y_imporage" }, { 0x7DC3908F, "u_m_y_justin" }, { 0xC8BB1E52, "u_m_y_mani" }, { 0x4705974A, "u_m_y_militarybum" }, { 0x5048B328, "u_m_y_paparazzi" }, { 0x36E70600, "u_m_y_party_01" }, { 0xDC59940D, "u_m_y_pogo_01" }, { 0x7B9B4BC0, "u_m_y_prisoner_01" }, { 0xC4B715D2, "ig_benny" }, { 0x841BA933, "ig_g" }, { 0xF9FD068C, "ig_vagspeak" }, { 0xC4A617BD, "mp_m_g_vagfun_01" }, { 0xC85F0A88, "mp_m_boatstaff_01" }, { 0x3293B9CE, "mp_f_boatstaff_01" } }; #pragma endregion inline void getVehicleModelName(DWORD vehicleHash, std::string& str) { auto it = vehiclehash_map.find(vehicleHash); if (it != vehiclehash_map.end()) str = it->second; else str = std::to_string(vehicleHash); } inline void getPedModelName(DWORD pedHash, std::string& str) { auto it = pedhash_map.find(pedHash); if (it != pedhash_map.end()) str = it->second; else str = std::to_string(pedHash); } inline void notifyAboveMap(char* message) { UI::_SET_NOTIFICATION_TEXT_ENTRY("STRING"); UI::_ADD_TEXT_COMPONENT_STRING(message); UI::_DRAW_NOTIFICATION(0, 0); } inline void showSubtitle(const char * msg, int duration = 5000) { UI::_SET_TEXT_ENTRY_2("CELL_EMAIL_BCON"); const unsigned int maxStringLength = 99; char subStr[maxStringLength]; for (unsigned int i = 0; i < strlen(msg) + 1; i += maxStringLength) { memcpy_s(subStr, sizeof(subStr), &msg[i], min(maxStringLength - 1, strlen(msg) + 1 - i)); subStr[maxStringLength - 1] = '\0'; UI::_ADD_TEXT_COMPONENT_STRING(subStr); } UI::_DRAW_SUBTITLE_TIMED(duration, 1); }
[ "camberry@telus.net" ]
camberry@telus.net
d42ee98ed0f70a31b1dcb61e5c32bff7f335da25
04251e142abab46720229970dab4f7060456d361
/lib/rosetta/source/src/protocols/stepwise/screener/BaseBinMapUpdater.hh
020bcaa87079191160ff8afb3dc046fa29282d9a
[]
no_license
sailfish009/binding_affinity_calculator
216257449a627d196709f9743ca58d8764043f12
7af9ce221519e373aa823dadc2005de7a377670d
refs/heads/master
2022-12-29T11:15:45.164881
2020-10-22T09:35:32
2020-10-22T09:35:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,870
hh
// -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*- // vi: set ts=2 noet: // // (c) Copyright Rosetta Commons Member Institutions. // (c) This file is part of the Rosetta software suite and is made available under license. // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons. // (c) For more information, see http://www.rosettacommons.org. Questions about this can be // (c) addressed to University of Washington CoMotion, email: license@uw.edu. /// @file protocols/stepwise/screener/BaseBinMapUpdater.hh /// @brief /// @details /// @author Rhiju Das, rhiju@stanford.edu #ifndef INCLUDED_protocols_stepwise_screener_BaseBinMapUpdater_HH #define INCLUDED_protocols_stepwise_screener_BaseBinMapUpdater_HH #include <protocols/stepwise/screener/StepWiseScreener.hh> #include <protocols/stepwise/screener/BaseBinMapUpdater.fwd.hh> #include <protocols/stepwise/modeler/rna/rigid_body/FloatingBaseClasses.hh> #include <utility/vector1.fwd.hh> namespace protocols { namespace stepwise { namespace screener { class BaseBinMapUpdater: public StepWiseScreener { public: //constructor BaseBinMapUpdater( protocols::stepwise::modeler::rna::rigid_body::BaseBinMap & base_bin_map ); //destructor ~BaseBinMapUpdater() override; public: void get_update( sampler::StepWiseSamplerOP sampler ) override; std::string name() const override { return "BaseBinMapUpdater"; } StepWiseScreenerType type() const override { return BASE_BIN_MAP; } private: void update_base_bin_map( protocols::stepwise::modeler::rna::rigid_body::BaseBin const & base_bin ); void update_base_bin_map( utility::vector1< core::Real > const & rigid_body_values ); private: protocols::stepwise::modeler::rna::rigid_body::BaseBinMap & base_bin_map_; }; } //screener } //stepwise } //protocols #endif
[ "lzhangbk@connect.ust.hk" ]
lzhangbk@connect.ust.hk
8330a284876338f2bbf693116bdc812335e86907
2db32ec16dbbe8d40e79023b3e8790d6f46d37c5
/May Challenge/Maximum Product of Words Lengths.cpp
3c70f2a19d0545e343f8d2085575ed96457390cc
[]
no_license
yasht5/LeetCode-Monthly-Challenge
336d02f68ae459a432736a38b408c6f06810c058
5baa16f2e98ea8a41155e39a42d9ee5b0fdb35b8
refs/heads/master
2023-06-25T02:43:46.885806
2021-07-26T16:07:35
2021-07-26T16:07:35
338,580,125
0
0
null
null
null
null
UTF-8
C++
false
false
712
cpp
class Solution { public: int maxProduct(vector<string>& words) { int n = words.size(); if(n==0 || n<2) { return 0; } vector<int> v(n, 0); for(int i=0;i<n;i++) { for(char c : words[i]) { v[i] = v[i] | (1<<(c-'a')); } } int res = 0; for(int i=0;i<n-1;i++) { for(int j = i+1; j<n;j++) { if((v[i] & v[j]) == 0) { int x = words[i].size() * words[j].size(); res = max(res, x); } } } return res; } };
[ "noreply@github.com" ]
noreply@github.com
f1efb2de3275979c852b0e4240b4d35ae98b0c46
1ae555d3088dc123836060371fc520bf0ff13e52
/others/GoogleCode/GCJ2020/round1C/c.cpp
231ff7051fa7e710fb0283a8cf8ada242d7a3f71
[]
no_license
knagakura/procon
a87b9a1717674aeb5ee3da0301d465e95c758fde
c6ac49dbaaa908ff13cb0d9af439efe5439ec691
refs/heads/master
2022-01-31T19:46:33.535685
2022-01-23T11:59:02
2022-01-23T11:59:02
161,764,993
0
0
null
null
null
null
UTF-8
C++
false
false
4,070
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i, N) for(int i=0;i<int(N);++i) #define rep1(i, N) for(int i=1;i<int(N);++i) #define all(a) (a).begin(),(a).end() #define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; } #define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; } #define dump(x) cerr<<#x<<": "<<x<<endl; #define bit(k) (1LL<<(k)) typedef long long ll; typedef pair<int, int> i_i; typedef pair<ll, ll> l_l; template<class T> using vec = vector<T>; template<class T> using vvec = vector<vec<T>>; template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "{" << p.first << ", " << p.second << "}"; return os; } template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = (ll) 1e9; const ll INFLL = (ll) 1e18 + 1; const ll MOD = (ll) 1e9 + 7; const double PI = acos(-1.0); /* const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; const string dir = "DRUL"; */ void Case(int i) { cout << "Case #" << i << ": "; } int N, D; vector<ll> A; void input() { //N個のカット、D人 cin >> N >> D; A.clear(); A.resize(N); rep(i, N) { cin >> A[i]; } sort(all(A)); } void solve_d2() { if (N == 1) { cout << 1 << endl; return; } // N >= D map<ll, ll> map; rep(i, N)map[A[i]]++; for (auto p: map) { if (p.second >= D) { cout << 0 << endl; return; } } cout << 1 << endl; } void solve_d3() { if (N == 1) { cout << 2 << endl; return; } if (N == 2) { if (2 * A[0] == A[1]) { cout << 1 << endl; return; } cout << 2 << endl; return; } //N>=3 map<ll, ll> map; rep(i, N)map[A[i]]++; ll maxcnt = 0; ll maxa = A[0]; for (auto p: map) { if (chmax(maxcnt, p.second)) { maxa = p.first; } } if (maxcnt >= 3) { cout << 0 << endl; return; } if (maxcnt == 2) { rep(i, N) { rep(j, N) { if (2 * A[i] == A[j]) { cout << 1 << endl; return; } } } if (maxa == A.back()) { cout << 2 << endl; } else { cout << 1 << endl; } } if (maxcnt == 1) { rep(i, N) { rep(j, N) { if (2 * A[i] == A[j]) { cout << 1 << endl; return; } } } cout << 2 << endl; } } void solve_small() { ll ans = INFLL; map<ll, ll> map; rep(i, N)map[A[i]]++; rep(i,N){ ll tmpD = D; //すでにできてる分を引く tmpD -= map[A[i]]; if(tmpD <= 0){ chmin(ans, 0LL); continue; } if(N >= D && N-1-i < D)break; ll X = A[i]; ll res = 0; for(ll j = 1; X*bit(j) <= A.back(); j++){ //これ以上省略しても意味がないとき if(tmpD < bit(j))break; //if(map[X*bit(j)] == 0)continue; ll cnt = min(map[X*bit(j)], tmpD / bit(j)); res += (bit(j) - 1) * cnt; tmpD -= cnt * bit(j); } res += tmpD; chmin(ans, res); } cout << ans << endl; } void solve_large() { cout << 0 << endl; } void solve() { input(); //if (D == 2)solve_d2(); //else if (D == 3)solve_d3(); //else solve_small(); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int t; cin >> t; rep(i, t) { Case(i + 1); solve(); } }
[ "knagakura@bs.s.u-tokyo.ac.jp" ]
knagakura@bs.s.u-tokyo.ac.jp
195585cad01ef71a2b08080be4b0ae08bc8401d4
2b4194aa57d72432c7895d39ebc4fb511f3193df
/AsyncSSDP.cpp
97826f36cb549f66d76b961fb115f67a11c9e22a
[]
no_license
fngstudios/AsyncSSDP
2ae19acd7305049ccbd8f162ec048443777469e1
613473692684298774846cf8f66d503889770123
refs/heads/master
2021-01-12T05:47:02.747621
2017-01-09T03:28:42
2017-01-09T03:28:42
77,197,614
1
0
null
null
null
null
UTF-8
C++
false
false
13,973
cpp
/* ESP8266 Simple Service Discovery Copyright (c) 2015 Hristo Gochkov Original (Arduino) version by Filippo Sallemi, July 23, 2014. Can be found at: https://github.com/nomadnt/uSSDP License (MIT license): Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #define LWIP_OPEN_SRC #include <functional> #include "AsyncSSDP.h" #include "WiFiUdp.h" #include "debug.h" #include <FS.h> extern "C" { #include "osapi.h" #include "ets_sys.h" #include "user_interface.h" } #include "lwip/opt.h" #include "lwip/udp.h" #include "lwip/inet.h" #include "lwip/igmp.h" #include "lwip/mem.h" #include "include/UdpContext.h" // #define DEBUG_SSDP Serial #define SSDP_INTERVAL 1200 #define SSDP_PORT 1900 #define SSDP_METHOD_SIZE 10 #define SSDP_URI_SIZE 2 #define SSDP_BUFFER_SIZE 64 #define SSDP_MULTICAST_TTL 2 static const IPAddress SSDP_MULTICAST_ADDR(239, 255, 255, 250); static const char* _ssdp_response_template = "HTTP/1.1 200 OK\r\n" "EXT:\r\n"; static const char* _ssdp_notify_template = "NOTIFY * HTTP/1.1\r\n" "HOST: 239.255.255.250:1900\r\n" "NTS: ssdp:alive\r\n"; static const char* _ssdp_packet_template = "%s" // _ssdp_response_template / _ssdp_notify_template "CACHE-CONTROL: max-age=%u\r\n" // SSDP_INTERVAL "SERVER: Arduino/1.0 UPNP/1.1 %s/%s\r\n" // _modelName, _modelNumber "USN: uuid:%s\r\n" // _uuid "%s: %s\r\n" // "NT" or "ST", _deviceType "LOCATION: http://%u.%u.%u.%u:%u/%s\r\n" // WiFi.localIP(), _port, _schemaURL "\r\n"; static const char* _ssdp_schema_template = "HTTP/1.1 200 OK\r\n" "Content-Type: text/xml\r\n" "Connection: close\r\n" "Access-Control-Allow-Origin: *\r\n" "\r\n" "<?xml version=\"1.0\"?>" "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">" "<specVersion>" "<major>1</major>" "<minor>0</minor>" "</specVersion>" "<URLBase>http://%u.%u.%u.%u:%u/</URLBase>" // WiFi.localIP(), _port "<device>" "<deviceType>%s</deviceType>" "<friendlyName>%s</friendlyName>" "<presentationURL>%s</presentationURL>" "<serialNumber>%s</serialNumber>" "<modelName>%s</modelName>" "<modelNumber>%s</modelNumber>" "<modelURL>%s</modelURL>" "<manufacturer>%s</manufacturer>" "<manufacturerURL>%s</manufacturerURL>" "<UDN>uuid:%s</UDN>" "</device>" "</root>\r\n" "\r\n"; static const char* _ssdp_schema_file_template = "<?xml version=\"1.0\"?>" "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">" "<specVersion>" "<major>1</major>" "<minor>0</minor>" "</specVersion>" "<URLBase>http://%u.%u.%u.%u:%u/</URLBase>" // WiFi.localIP(), _port "<device>" "<deviceType>%s</deviceType>" "<friendlyName>%s</friendlyName>" "<presentationURL>%s</presentationURL>" "<serialNumber>%s</serialNumber>" "<modelName>%s</modelName>" "<modelNumber>%s</modelNumber>" "<modelURL>%s</modelURL>" "<manufacturer>%s</manufacturer>" "<manufacturerURL>%s</manufacturerURL>" "<UDN>uuid:%s</UDN>" "</device>" "<iconList>" "<icon>" "<mimetype>image/png</mimetype>" "<height>48</height>" "<width>48</width>" "<depth>32</depth>" "<url>icon48.png</url>" "</icon>" "<icon>" "<mimetype>image/png</mimetype>" "<height>128</height>" "<width>128</width>" "<depth>32</depth>" "<url>icon128.png</url>" "</icon>" "</iconList>" "</root>\r\n" "\r\n"; struct SSDPTimer { ETSTimer timer; }; SSDPClass::SSDPClass() : _server(0), _timer(new SSDPTimer), _port(80), _ttl(SSDP_MULTICAST_TTL), _respondToPort(0), _pending(false), _delay(0), _process_time(0), _notify_time(0) { _uuid[0] = '\0'; _modelNumber[0] = '\0'; sprintf(_deviceType, "urn:schemas-upnp-org:device:Basic:1"); _friendlyName[0] = '\0'; _presentationURL[0] = '\0'; _serialNumber[0] = '\0'; _modelName[0] = '\0'; _modelURL[0] = '\0'; _manufacturer[0] = '\0'; _manufacturerURL[0] = '\0'; sprintf(_schemaURL, "ssdp/schema.xml"); } SSDPClass::~SSDPClass(){ delete _timer; } bool SSDPClass::begin(){ _pending = false; uint32_t chipId = ESP.getChipId(); sprintf(_uuid, "38323636-4558-4dda-9188-cda0e6%02x%02x%02x", (uint16_t) ((chipId >> 16) & 0xff), (uint16_t) ((chipId >> 8) & 0xff), (uint16_t) chipId & 0xff ); #ifdef DEBUG_SSDP DEBUG_SSDP.printf("SSDP UUID: %s\n", (char *)_uuid); #endif if (_server) { _server->unref(); _server = 0; } _server = new UdpContext; _server->ref(); ip_addr_t ifaddr; ifaddr.addr = WiFi.localIP(); ip_addr_t multicast_addr; multicast_addr.addr = (uint32_t) SSDP_MULTICAST_ADDR; if (igmp_joingroup(&ifaddr, &multicast_addr) != ERR_OK ) { DEBUGV("SSDP failed to join igmp group"); return false; } if (!_server->listen(*IP_ADDR_ANY, SSDP_PORT)) { return false; } _server->setMulticastInterface(ifaddr); _server->setMulticastTTL(_ttl); _server->onRx(std::bind(&SSDPClass::_update, this)); if (!_server->connect(multicast_addr, SSDP_PORT)) { return false; } _startTimer(); return true; } void SSDPClass::_send(ssdp_method_t method, char* st, char *usn){ char buffer[1460]; uint32_t ip = WiFi.localIP(); ip_addr_t remoteAddr; uint16_t remotePort; if(method == NONE) { remoteAddr.addr = _respondToAddr; remotePort = _respondToPort; #ifdef DEBUG_SSDP DEBUG_SSDP.print("Sending Response to "); #endif } else { remoteAddr.addr = SSDP_MULTICAST_ADDR; remotePort = SSDP_PORT; #ifdef DEBUG_SSDP DEBUG_SSDP.println("Sending Notify to "); #endif } #ifdef DEBUG_SSDP DEBUG_SSDP.print(IPAddress(remoteAddr.addr)); DEBUG_SSDP.print(":"); DEBUG_SSDP.println(remotePort); #endif // ::upnp:rootdevice int len = snprintf(buffer, sizeof(buffer), _ssdp_packet_template, (method == NONE)?_ssdp_response_template:_ssdp_notify_template, SSDP_INTERVAL, _modelName, _modelNumber, usn, (method == NONE)?"ST":"NT", st, IP2STR(&ip), _port, _schemaURL ); _server->append(buffer, len); _server->send(&remoteAddr, remotePort); } void SSDPClass::schema(WiFiClient client){ uint32_t ip = WiFi.localIP(); client.printf(_ssdp_schema_template, IP2STR(&ip), _port, _deviceType, _friendlyName, _presentationURL, _serialNumber, _modelName, _modelNumber, _modelURL, _manufacturer, _manufacturerURL, _uuid ); } void SSDPClass::_update(){ if(!_pending && _server->next()) { ssdp_method_t method = NONE; _respondToAddr = _server->getRemoteAddress(); _respondToPort = _server->getRemotePort(); typedef enum {METHOD, URI, PROTO, KEY, VALUE, ABORT} states; states state = METHOD; typedef enum {START, MAN, ST, MX} headers; headers header = START; uint8_t cursor = 0; uint8_t cr = 0; char buffer[SSDP_BUFFER_SIZE] = {0}; while(_server->getSize() > 0){ char c = _server->read(); (c == '\r' || c == '\n') ? cr++ : cr = 0; switch(state){ case METHOD: if(c == ' '){ if(strcmp(buffer, "M-SEARCH") == 0) method = SEARCH; else if(strcmp(buffer, "NOTIFY") == 0) method = NOTIFY; if(method == NONE) state = ABORT; else state = URI; cursor = 0; } else if(cursor < SSDP_METHOD_SIZE - 1){ buffer[cursor++] = c; buffer[cursor] = '\0'; } break; case URI: if(c == ' '){ if(strcmp(buffer, "*")) state = ABORT; else state = PROTO; cursor = 0; } else if(cursor < SSDP_URI_SIZE - 1){ buffer[cursor++] = c; buffer[cursor] = '\0'; } break; case PROTO: if(cr == 2){ state = KEY; cursor = 0; } break; case KEY: if(cr == 4){ _pending = true; _process_time = millis(); } else if(c == ' '){ cursor = 0; state = VALUE; } else if(c != '\r' && c != '\n' && c != ':' && cursor < SSDP_BUFFER_SIZE - 1){ buffer[cursor++] = c; buffer[cursor] = '\0'; } break; case VALUE: if(cr == 2){ switch(header){ case START: break; case MAN: #ifdef DEBUG_SSDP DEBUG_SSDP.printf("MAN: %s\n", (char *)buffer); #endif break; case ST: if(strcmp(buffer, "ssdp:all")){ state = ABORT; #ifdef DEBUG_SSDP DEBUG_SSDP.printf("REJECT: %s\n", (char *)buffer); #endif } char uuid_buffer[100]; sprintf(uuid_buffer, "uuid:%s", _uuid); // if the search type matches our type, we should respond instead of ABORT if((strcmp(buffer, "upnp:rootdevice") == 0) || (strcmp(buffer, uuid_buffer) == 0)) { // DEBUG_SSDP.printf("ACCEPT: %s\n", (char *)buffer); _pending = true; _process_time = millis(); state = KEY; } break; case MX: _delay = random(0, atoi(buffer)) * 1000L; break; } if(state != ABORT){ state = KEY; header = START; cursor = 0; } } else if(c != '\r' && c != '\n'){ if(header == START){ if(strncmp(buffer, "MA", 2) == 0) header = MAN; else if(strcmp(buffer, "ST") == 0) header = ST; else if(strcmp(buffer, "MX") == 0) header = MX; } if(cursor < SSDP_BUFFER_SIZE - 1){ buffer[cursor++] = c; buffer[cursor] = '\0'; } } break; case ABORT: _pending = false; _delay = 0; break; } } } if(_pending && (millis() - _process_time) > _delay){ _pending = false; _delay = 0; char st[64]; char usn[64]; sprintf(usn, "%s::%s",_uuid, "upnp:rootdevice"); _send(NONE, "upnp:rootdevice", usn); sprintf(st, "uuid:%s", _uuid); _send(NONE, st, _uuid); sprintf(usn, "%s::%s",_uuid, _deviceType); _send(NONE, _deviceType, usn); } else if(_notify_time == 0 || (millis() - _notify_time) > (SSDP_INTERVAL * 1000L)){ _notify_time = millis(); _send(NOTIFY, _deviceType, _uuid); } if (_pending) { while (_server->next()) _server->flush(); } } uint8_t SSDPClass::checkSchemaFile(){ if (SPIFFS.exists("/description.xml")) { return 1; }else{ return 0; } } void SSDPClass::updateSchemaFile(){ File schema = SPIFFS.open("/description.xml", "w"); uint32_t ip = WiFi.localIP(); uint32_t chipId = ESP.getChipId(); sprintf(_uuid, "38323636-4558-4dda-9188-cda0e6%02x%02x%02x", (uint16_t) ((chipId >> 16) & 0xff), (uint16_t) ((chipId >> 8) & 0xff), (uint16_t) chipId & 0xff ); schema.printf(_ssdp_schema_file_template, IP2STR(&ip), _port, _deviceType, _friendlyName, _presentationURL, _serialNumber, _modelName, _modelNumber, _modelURL, _manufacturer, _manufacturerURL, _uuid ); schema.close(); } void SSDPClass::setSchemaURL(const char *url){ strlcpy(_schemaURL, url, sizeof(_schemaURL)); } void SSDPClass::setHTTPPort(uint16_t port){ _port = port; } void SSDPClass::setDeviceType(const char *deviceType){ strlcpy(_deviceType, deviceType, sizeof(_deviceType)); } void SSDPClass::setName(const char *name){ strlcpy(_friendlyName, name, sizeof(_friendlyName)); } void SSDPClass::setURL(const char *url){ strlcpy(_presentationURL, url, sizeof(_presentationURL)); } void SSDPClass::setSerialNumber(const char *serialNumber){ strlcpy(_serialNumber, serialNumber, sizeof(_serialNumber)); } void SSDPClass::setSerialNumber(const uint32_t serialNumber){ snprintf(_serialNumber, sizeof(uint32_t)*2+1, "%08X", serialNumber); } void SSDPClass::setModelName(const char *name){ strlcpy(_modelName, name, sizeof(_modelName)); } void SSDPClass::setModelNumber(const char *num){ strlcpy(_modelNumber, num, sizeof(_modelNumber)); } void SSDPClass::setModelURL(const char *url){ strlcpy(_modelURL, url, sizeof(_modelURL)); } void SSDPClass::setManufacturer(const char *name){ strlcpy(_manufacturer, name, sizeof(_manufacturer)); } void SSDPClass::setManufacturerURL(const char *url){ strlcpy(_manufacturerURL, url, sizeof(_manufacturerURL)); } void SSDPClass::setTTL(const uint8_t ttl){ _ttl = ttl; } void SSDPClass::_onTimerStatic(SSDPClass* self) { self->_update(); } void SSDPClass::_startTimer() { ETSTimer* tm = &(_timer->timer); const int interval = 1000; os_timer_disarm(tm); os_timer_setfn(tm, reinterpret_cast<ETSTimerFunc*>(&SSDPClass::_onTimerStatic), reinterpret_cast<void*>(this)); os_timer_arm(tm, interval, 1 /* repeat */); } SSDPClass SSDP;
[ "ezequielpedace@gmail.com" ]
ezequielpedace@gmail.com
b788c6b05daeab0d7eb9f9d6093f3ef95438a1d9
7a811197fcfb0904080b07dc02f0db09ca2aba7c
/Source/Engine/Graphics/RenderTexture2D/D3D11/D3D11RenderTexture2D.h
44dce427ca516a7070437583666c4549aa2b8f64
[]
no_license
dbowler92/D3D11Engine
3af8abdd883bdf3930ffbe227c3e45906d871d87
1391d6353932aed3380b23e9828203f4cb7cca85
refs/heads/master
2020-11-30T04:56:26.986818
2017-08-12T19:15:06
2017-08-12T19:15:06
96,707,671
0
1
null
null
null
null
UTF-8
C++
false
false
1,323
h
//D3D11RenderTexture2D.h //Created 14/07/17 //Created By Daniel Bowler // //Represents a 2D Texture that we can render in to. #pragma once //Parent #include <Core/CoreObject/CoreObject.h> //Manages a Texture2D object #include <Graphics/Texture2D/Texture2D.h> namespace EngineAPI { namespace Graphics { namespace Platform { class D3D11RenderTexture2D : public EngineAPI::Core::CoreObject { public: D3D11RenderTexture2D() {}; virtual ~D3D11RenderTexture2D() = 0 {}; //Inits the render texture bool InitRenderTexture2D(EngineAPI::Graphics::GraphicsDevice* device, uint32_t textureWidth, uint32_t textureHeight, uint32_t msaaSampleCount = 1, ResourceFormat textureFormat = RESOURCE_FORMAT_R8G8B8A8_UNORM, ResourceUsage textureUsage = RESOURCE_USAGE_DEFAULT, ResourceCPUAccessFlag textureCpuAccess = (ResourceCPUAccessFlag)0, ResourceBindFlag textureBindFlag = RESOURCE_BIND_RENDER_TARGET_BIT, std::string debugName = std::string("")); //Shutsdown the render texture virtual void Shutdown() override; public: //Gets the actual texture object EngineAPI::Graphics::Texture2D* GetTexture2D() { return &renderTexture2D; }; protected: //The actual GPU Texture object EngineAPI::Graphics::Texture2D renderTexture2D; }; } }; };
[ "dbowler1192@gmail.com" ]
dbowler1192@gmail.com
e970188b6c46b33f6949e6966af98454a0f3aab4
7f1f2d028a0faa297617a4e2070714891df11688
/practice/1202ex/string2.h
2fa0e1e28a5ba31b4a1c6361e982c1e0209c7809
[]
no_license
mallius/CppPrimerPlus
3487058a82d74ef0dd0c51b19c9f082b89c0c3f3
2a1ca08b4cdda542bb5cda35c8c5cfd903f969eb
refs/heads/master
2021-01-01T04:12:16.783696
2018-03-08T13:49:17
2018-03-08T13:49:17
58,808,717
0
0
null
null
null
null
UTF-8
C++
false
false
1,036
h
#include <iostream> using std::ostream; using std::istream; #ifndef STRING2_H_ #define STRING2_H_ class String { private: char *str; int len; static int num_strings; static const int CINLIM = 80; public: String(const char *s); String(); String(const String &); ~String(); int length()const{ return len; } // 新加 void Stringlow(); // 字符串转换为小写 void Stringup(); // 字符串转换为大写 int StringCount(char ch); // ch在字符串中的个数 String & operator+(const String & s); // 拼接字符串 String & operator=(const String &); String & operator=(const char *); char & operator[] (int i); const char & operator[] (int i)const; friend bool operator<(const String &st, const String &st2); friend bool operator>(const String &st1, const String &st2); friend bool operator==(const String &st1, const String &st2); friend ostream & operator<<(ostream &os, const String &st); friend istream & operator>>(istream &is, const String &st); static int HowMany(); }; #endif
[ "mallius@qq.com" ]
mallius@qq.com
08601b01b79f7e7517834be03bb0f5ddd9f93846
a93bb0f268cf5e2de2dd745c86a160ca60fada86
/源代码/Thirdparty/UGC/inc/SdbPlusEngine/UGSdbPlusDatasetVector.h
877e317147d4a3c148afda2197b16ff7bf89fc42
[ "Apache-2.0" ]
permissive
15831944/Fdo_SuperMap
ea22b74ecfc5f983f2decefe4c2cf29007b85bf6
3d4309d0f45fa63abcde188825a997077dd444f4
refs/heads/master
2021-05-29T09:57:19.433966
2015-05-22T09:03:56
2015-05-22T09:03:56
null
0
0
null
null
null
null
GB18030
C++
false
false
15,782
h
// SmDataset.h: interface for the UGSdbPlusDatasetVector class. // ////////////////////////////////////////////////////////////////////// #if !defined(AFX_SDBDATASET49_H__017098AB_099E_11D3_92D2_0080C8EE62D1__INCLUDED_) #define AFX_SDBDATASET49_H__017098AB_099E_11D3_92D2_0080C8EE62D1__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "Base/ugdefs.h" #include "Algorithm/UGQTreeManager.h" #include "Engine/UGDatasetVector.h" #include "UGRTree.h" namespace UGC{ class UGFolder; class UGFileLogical; class UGSdbPlusDataSource; class UGSdbPlusRecordset; class SDBPLUSENGINE_API UGSdbPlusDatasetVector : public UGDatasetVector { friend class UGSdbPlusDataSource; friend class UGSdbPlusRecordset; friend class UGSdbPlusRecordsetSequence; public: UGSdbPlusDatasetVector(); UGSdbPlusDatasetVector(UGDataSource *pDataSource); virtual ~UGSdbPlusDatasetVector(); public: UGbool Open(); //打开Dataset void Close(); //关闭Dataset UGbool IsOpen() const; //Dataset是否打开 UGbool Truncate(); //删除表中的所有数据 UGbool Rename(const UGString& strNewName); //数据集重命名 UGbool SaveInfo(); //数据集信息存盘 //空间索引 virtual UGbool BuildSpatialIndex(UGSpatialIndexInfo &spatial); //! \brief 根据当前索引状态重建索引 //! \param *pDataset [in]。 //! \return //! \remarks //! \attention virtual UGbool ReBuildSpatialIndex(); //! \brief 脏数据的空间索引更新 //! \param *pDataset [in]。 //! \return 。 //! \remarks 。 //! \attention 。 virtual UGbool UpdateSpatialIndex(); virtual UGbool DropSpatialIndex(); virtual UGbool IsSpatialIndexDirty(); //空间索引是否"脏",是否需要重建空间索引 virtual UGint GetDirtyRecordCount(); //返回空间索引脏的记录的数目,为是否需要重建空间索引提供参考 //属性字段索引 virtual UGbool CreateIndex(const UGString &strFieldNameList,const UGString & strIndexName); virtual UGbool DropIndex(const UGString & strIndexName); //数据集属性 // UGbool HasGeometry(); //判断是否为空间数据数据集 UGbool CanUpdate(); //判断数据集是否可以Update /// \brief 判断当前数据集是否有执行指定操作的能力 virtual UGbool HasAbility(UGEngAbility dwEngAbility); UGTime GetDateLastUpdated(); //返回最后更新日期 UGTime GetDateCreated(); //返回创建日期 UGString GetTableName(); //数据集查询 UGRecordset* Query(const UGQueryDef &querydef); //执行查询操作 UGRecordset* QueryWithBounds(const UGRect2D &rc2Bounds, UGQueryDef::QueryOption nOptions = UGQueryDef::Geometry, UGQueryDef::QueryMode nMode = UGQueryDef::FuzzyQuery); UGRecordset* QueryWithIDs(UGint *pIDs,UGint nCount, UGQueryDef::QueryOption nOptions = UGQueryDef::Both , UGQueryDef::QueryMode nMode = UGQueryDef::GeneralQuery); //! \brief 空间查询 //! \param pGeo 面对象[in] //! \param aryInnerIDs [out] //! \param aryMaybeIDs [out] //! \param aryOuterIDs [out] //! \param nOption [in] //! 0x00000001 内部 //! 0x00000002 Maybe //! 0x00000004 外部 //! \return 成功 //! \remarks 范围精确空间查询 virtual UGbool SpatialQuery(UGGeoRegion *pGeo, UGArray<UGint> &aryInnerIDs, UGMaybeItems &aryMaybeIDs, UGArray<UGint> &aryOuterIDs, SpatialQueryOption nOption); //创建字段 UGbool CreateFields(const UGFieldInfos &fieldInfos); //创建字段集 UGbool CreateField(const UGFieldInfo &fieldInfo); //创建字段 UGbool CreateField(const UGString &strName, UGFieldInfo::FieldType nType, UGint lSize, UGint lAttributes = 0); //创建字段 //删除 UGbool DeleteField(const UGString &strName); //删除指定名字的字段 UGbool DeleteField(UGint nIndex); //删除指定序号的字段 //字段信息 UGint GetFieldCount(); //字段数 UGbool GetFieldInfos(UGFieldInfos &fieldInfos,UGbool bSystemFieldExcluded = false/*,UGQueryDef::FIOptions fiOptions = UGQueryDef::fiCustom*/); //收集所有字段的信息 UGbool GetFieldInfo(const UGString &strName, UGFieldInfo &fieldInfo/*,UGQueryDef::FIOptions fiOptions = UGQueryDef::fiCustom*/); //收集指定名字字段的信息 UGbool GetFieldInfo(UGint nIndex, UGFieldInfo &fieldInfo/*,UGQueryDef::FIOptions fiOptions = UGQueryDef::fiCustom*/); //收集指定序号字段的信息 virtual UGbool SetFieldInfo(const UGString &strName, const UGFieldInfo &fieldInfo); //设置字段信息,CDaoFieldInfo里定义的属性无法设置,只能在创建时候指定,其他的属性可以设定 virtual UGbool SetFieldInfo(UGint nIndex, const UGFieldInfo &fieldInfo); //设置第nIndex字段信息,同上 virtual UGString GetFieldNameBySign(UGDatasetVector::FieldSign nSign); //设置特殊字段标识 virtual UGbool SetFieldSign(const UGString& strFieldName,UGDatasetVector::FieldSign nSign); //统计字段值,根据字段类型,返回一个变量。nMode是统计类型。 virtual UGVariant Statistic(const UGString& strField,UGStatisticMode nMode); //边界 UGbool ComputeBounds(); //计算数据集Bounds //数据集选项,如时序数据集等。 virtual UGbool RegisterOption(UGint dwOption); virtual UGbool UnRegisterOption(UGint dwOption); virtual UGbool IsSupport(UGEngAction dwEngAction); //注册/反注册时序数据集 UGbool RegisterSequence(); UGbool UnRegisterSequence(); public: virtual UGbool RefreshInfo(); virtual UGRecordset* QueryWithLibTileID(UGint nLibTileID, UGArray<UGString> & arFields, UGdouble dGranule); //! 通过矩形范围查询图幅序号 virtual UGbool GetLibTileIDs(const UGRect2D& rc2Bounds, UGArray<UGint>& arLibTileIDs); //! 得到一个图幅的信息 virtual UGbool GetLibTileInfo(UGint nTileID,UGRect2D& rc2TileBounds, UGint& nRecCount,UGint& nVersion); virtual UGbool CheckOut(); virtual UGbool CheckIn(UGbool bKeepCheckedOut); virtual UGbool UndoCheckOut(UGbool bKeepCheckedOut); virtual UGbool UpdateField(const UGString& strFieldName, const UGVariant& varValue,const UGString& strFilter = ""); //! 通过表达式更新字段值 virtual UGbool UpdateFieldEx(const UGString& strFieldName, const UGString& strExpress,const UGString& strFilter = ""); //! 复制字段值,strSrcField和 //! strDestField必须都存在且字段类型匹配 virtual UGbool CopyField(const UGString& strSrcField,const UGString& strDestField); //! R树操作函数 virtual UGint LoadRTreeLeaf(UGint nID, UGStream &stream); virtual UGbool StoreRTreeLeaf(UGint nID,UGStream &stream); virtual UGbool HasGeometry() const; //! 计算字段单值个数 virtual UGint CalculateUniqueValues(const UGString &strFieldName, UGArray<UGVariant>& varKeys); //! 真正的SQL查询记录个数,更新Register表 virtual UGbool ComputeRecCount(); //! 获取最大空间对象的字节大小 virtual UGint GetMaxGeoSize(); //! 设置最大空间对象的字节大小 virtual UGbool SetMaxGeoSize(UGint nMaxGeoSize); //! 时序数据的注册时间 virtual UGTime GetRegistSequenceTime(); //! 时序数据的最新更新时间 virtual UGTime GetLUSequenceTime(); //! 通过ID数组删除数据集中的记录 virtual UGbool DeleteRecords(const UGint* pIDs,UGint nCount); //! 追加记录 virtual UGbool Append(UGRecordset* pSrcRecordset, UGbool bShowProgress = TRUE,UGString strTileName = ""); virtual UGbool Resample(UGdouble dTolerance, UGbool bShowProgress=TRUE); //! 返回记录集个数 virtual UGint GetRecordsetCount(); //! 返回指定索引的数据集指针 virtual UGRecordset* GetRecordsetAt(UGint nIndex); //! 通过索引释放记录集 virtual UGbool ReleaseRecordset(UGint nIndex); //! 通过引用释放记录集 virtual UGbool ReleaseRecordset(UGRecordset *pRecordset); //! 是否每个对象有自己的风格 virtual UGbool HasStyle(); //! 设置是否每个对象有自己的风格 virtual void SetFlag(UGint nOption,UGbool bHas); //! 判断字段名是否有效 virtual UGbool IsAvailableFieldName(const UGString& strFieldName); //! 得到图库索引图的名字 virtual UGString GetMiniatureDtName(); //! 获取数据集描述信息 virtual UGString GetDescription() const; //! 设置数据集描述信息 virtual void SetDescription(const UGString& strDesc); public: //根据父类的要求,实现动态分段需要的三个函数 /*! \brief 删除动态事件 * \return 删除事件成功返回TRUE,有任何错误返回FALSE * \note 删除动态事件要做两件事: 1、从SmEventProperty表中删除相关纪录 2、从tabular事件表中删除几何对象字段.(如点事件删除smx,smy) */ UGbool DeleteEvent(); /*! \brief 创建动态事件的几何对象,要求在子类中实现 * \return * \note 关键在于调用 CGeoLineM::GetCoordinateAtM 得到动态点 和 CGeoLineM::GetSubCurveAtM 得到动态线 */ UGbool BuildEventGeometry(); /*! \brief 保存动态事件属性到数据库中 * \return * \note 在子类中实现。把CSmEventProperty中的数据存储起来 共有11个数据 1、UGString m_strEventRouteIDFieldName; /// 事件表中RouteID字段名 2、EventType m_nEventType; /// 事件类型 3、UGString m_strFromMeasureFieldName; /// 线事件的起始Measure字段 4、UGString m_strToMeasureFieldName; /// 线事件的终止Measure字段 5、UGString m_strMeasureFieldName; /// 点事件的Measure 6、UGint m_nEventMeasureUnit; /// Measure单位 7、UGString m_strEventTableName; 8、UGString m_strRouteDataSourceAlias; /// Route数据集所在的数据源别名 9、UGString m_strRouteDtName; /// Route数据集名称 10、UGString m_strRouteIDFieldName; /// RouteID字段 11、UGString m_strOffsetField; /// 数据定位偏移字段 */ UGbool SaveEvent(); protected: //call by buildeventgeometry; UGbool BuildPointEventGeometry(); UGbool BuildLineEventGeometry(); protected: UGFolder *m_pFolderDataset; // 数据集的Folder CDaoTableDef *m_pTableDef; // 数据集的属性数据的Table UGFileLogical *m_pFileInfo; // 存放数据集信息,任何数据集都有 UGFileLogical *m_pFileMetadata; // 存放数据集元数据,任何数据集都有 UGFileLogical *m_pFileGeometry; // 存放空间数据,Tabular数据集无含义 UGFileLogical *m_pFileTree; // 存放空间数据的R树索引以及Q树索引 UGFileLogical *m_pFileIndex; // 存放空间数据的对象ID和位置的对应关系 UGQTreeManager m_QTreeIndex; // 四叉树索引 //CSmRTree m_RTreeIndex; // R树索引 UGRTree m_RTreeIndex; // R树索引 UGbool m_bCached; //是否已放入Cache的标志 UGString m_strDescription; protected: UGint m_nNextID; UGint m_nEncryptionKey[2]; //保留字 protected: //对象ID和对象在Geometry文件中的位置对应表。 UGint *m_pIndexTable; // 数据库索引,具体结构为m_pIndexTable[xxx][2] // [0]存放记录ID,-1代表该记录已被删除; // [1]存放记录在Geometry文件中的位置; UGint m_nIndexAllCount; // 索引的记录数,包括已被标志为删除的索引记录 UGint m_nIndexValidCount; // 索引的记录数,不包括已被标志为删除的索引记录 void AddNewIDandPos(UGint& nID,UGint nGeoPos); //新增加ID和Pos void GetIDandGeoPos(UGint nIndex,UGint& nID,UGint& nGeoPos); //得到ID和Pos UGint GetIDByIndex(UGint nIndex); //根据nIndex得到ID void SetIDByIndex(UGint nIndex,UGint nID); //设置ID UGint GetGeoPosByID(UGint nID); //根据ID得到Pos void SetGeoPosByID(UGint nID,UGint nGeoPos); //根据ID设置Pos UGint GetGeoPosByIndex(UGint nIndex); //根据位置(nIndex)得到Pos void SetGeoPosByIndex(UGint nIndex,UGint nGeoPos); //根据index设置Pos void DeleteIDandPos(UGint nID); //删除某个ID UGint IdToIndexPos(UGint nID); //查找ID对应的记录在Dataset索引中的序号 protected: //field info of all table. /// \brief add new record of fieldinfo UGbool InsertField(const UGString& strTable,const UGString& strFieldName,const UGString& strCaption); UGbool InsertField(const UGFieldInfo& fieldInfo); /// \brief delete a record of fieldinfo UGbool DeleteField(const UGString& strTable,const UGString& strFieldName); /// \brief get field's info,such as caption, domain,updatable UGbool GetFieldInfo(const UGString& strTable,const UGString& strFieldName,UGFieldInfo& fieldInfo); UGbool GetFieldCaption(const UGString& strTable,const UGString& strFieldName,UGString& strCaption); /// \brief alter field info. UGbool SetFieldCaption(const UGString& strTable,const UGString& strFieldName,UGFieldInfo& fieldInfo); UGbool SetFieldCaption(const UGString& strTable,const UGString& strFieldName,const UGString& strCaption); protected: //元数据描述管理 UGint GetMetadataDescCount(); //返回元数据描述个数 UGbool GetMetadataDesc(UGint nIndex, UGString &strTitle, UGString &strContent); //返回元数据描述 UGint AddMetadataDesc(UGString strTitle, UGString strContent); //追加元数据描述字符串在已有的元数据描述字符串后面,返回添加到的位置 void ClearMetadataDesc(); //清除原有的元数据描述 UGbool DeleteMetadataDesc(UGint nIndex); //删除指定的元数据描述 protected: //method //strName Dataset名字 //nType Dataste类型 //nOptions Dataste Options,参见SmDatasource.h //dwStgmOpt storage and stream create mode //stgDataset 父Storage,普通数据集是m_stgDatasets,Node和TINVertex数据集是当前m_stgDataset //pDatasetParent父数据集,普通数据集是NULL,Node和TINVertex数据集是当前数据集 //5.0新增,坐标存储模式,目前支持encNone,encWORD,encDWORD UGbool Create(UGString strName, UGDataset::DatasetType nType,UGint nOptions, UGFolder *stgDataset, UGSdbPlusDatasetVector *pDatasetParent, UGDataCodec::CodecType nEncType=UGDataCodec::encNONE); //stgDataset 父Storage,普通数据集是m_stgDatasets,Node和TINVertex数据集是当前m_stgDataset //bCached Cache标志 UGbool OpenEx(UGFolder *stgDataset,UGbool bCached); //打开数据集 UGbool IsValidDataset(); //判断是否合法Dataset //以下函数提供给Spatial Index使用 UGbool InitialSpatialIndex(); //初始化Spatial Index UGbool SaveSpatialIndex(); //Save Spatial Index to m_stmIndex UGbool LoadSpatialIndex(); //Load Spatial Index from m_stmIndex void Encrypt(UGString& strPassword); //数据加密 //修复坏掉的数据 UGbool RepairEx(UGint& nGeometryCount,UGint& nRecordCount); //检查空间数据与属性数据是否一一对应,并且删除缺失空间数据的属性数据,缺失属性数据的空间数据则补上。 UGbool Repair(); //空间数据与属性数据不一致是的修复,调用修复之前,数据集名,datasetinfo,stgDataset等已经打开。 UGbool RepairNoProperty(); //属性表丢失后的修复。 /* //UGString strFileName, 得到的文本文件的路径和名字 //UGint &nDatasetN, //要向SQL Server数据集设置的空间信息 //UGString strTerminate = "--$" //用以间隔字节段的间隔符 UGbool Export2Txt(UGString strFileName,double &dGridSize, UGint &nDatasetW, UGint &nDatasetN,UGint &nDatasetE,UGint &nDatasetS, UGString strTerminate = "--$"); UGbool ExportSqlPlusText(UGString strFileName,UGint & nRecordCount, UGRect2D &rc2Bounds, UGString strTerminate = "--$"); UGbool ExportSybaseText(UGString strFileName,UGint & nRecordCount, UGRect2D &rc2Bounds,UGString strTerminate = "--$"); */ static UGbool InitVariant(COleVariant& var,short nType); }; } #endif // !defined(AFX_SDBDATASET49_H__017098AB_099E_11D3_92D2_0080C8EE62D1__INCLUDED_)
[ "huanliang26@126.com" ]
huanliang26@126.com
0013bcf4bad86569e521c76b540e9a34871303fd
846daf82b52c77efa76151960f833bee856412f4
/system/ulib/fidl/message_buffer.cpp
9e95c945d9a57692955db0cd31ffd304b609c41c
[ "BSD-3-Clause", "MIT" ]
permissive
whycoding126/zircon
c3823f9147618cf3b851de339aed4cb29de1f5a3
d3b50545174a11eb9a4807473d380f19e5bacb25
refs/heads/master
2020-03-09T11:19:23.685555
2018-04-09T02:23:03
2018-04-09T03:21:07
128,759,128
1
0
null
2018-04-09T11:07:49
2018-04-09T11:07:48
null
UTF-8
C++
false
false
1,285
cpp
// Copyright 2018 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <lib/fidl/cpp/message_buffer.h> #include <stdlib.h> namespace fidl { namespace { uint32_t GetPadding(uint32_t offset) { constexpr uint32_t kMask = alignof(zx_handle_t) - 1; return offset & kMask; } size_t GetAllocSize(uint32_t bytes_capacity, uint32_t handles_capacity) { return bytes_capacity + GetPadding(bytes_capacity) + sizeof(zx_handle_t) * handles_capacity; } } // namespace MessageBuffer::MessageBuffer(uint32_t bytes_capacity, uint32_t handles_capacity) : buffer_(static_cast<uint8_t*>( malloc(GetAllocSize(bytes_capacity, handles_capacity)))), bytes_capacity_(bytes_capacity), handles_capacity_(handles_capacity) { } MessageBuffer::~MessageBuffer() { free(buffer_); } zx_handle_t* MessageBuffer::handles() const { return reinterpret_cast<zx_handle_t*>( buffer_ + bytes_capacity_ + GetPadding(bytes_capacity_)); } Message MessageBuffer::CreateEmptyMessage() { return Message(BytePart(bytes(), bytes_capacity()), HandlePart(handles(), handles_capacity())); } } // namespace fidl
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
6cbfcd6672d9a747025fc2077317349c6452e49b
7df578885d6377d6ab17109dc327549c3e698b6c
/Trees/Print a Binary Tree in Vertical Order.cpp
9d2827b114504e05e69563fcc93e9bb2c32daf70
[]
no_license
jainamandelhi/Geeks-For-Geeks-Solutions
b102dc8801760f2723e3c0783ebd134853f988d2
1851f3ab38ddde85b14c13a7834f5391e9780e65
refs/heads/master
2020-03-24T06:45:30.783081
2019-08-17T13:55:47
2019-08-17T13:55:47
142,540,641
0
0
null
null
null
null
UTF-8
C++
false
false
627
cpp
void verticalOrder(Node *root) { map<int,vector<int> >m; map<int,vector<int> > :: iterator itr; queue<pair<Node*,int> >q; q.push(make_pair(root,0)); while(!q.empty()) { Node *temp=q.front().first; int se=q.front().second; q.pop(); m[se].push_back(temp->data); if(temp->left) q.push(make_pair(temp->left,se-1)); if(temp->right) q.push(make_pair(temp->right,se+1)); } for(itr=m.begin();itr!=m.end();itr++) { for(int i=0;i<itr->second.size();i++) cout<<itr->second[i]<<" "; } //Your code here }
[ "jainamandelhi@gmail.com" ]
jainamandelhi@gmail.com
4f6e9f42cfda937224585e4f193bad92f65acd5f
97d49551345d812a3aef32edf1203cf6f6a9858d
/folly/container/test/F14SetTest.cpp
da81189aff7bde663f4671c92f793296b08dd693
[ "Apache-2.0" ]
permissive
a731062834/folly
151e2147b107cf5f9302cd077df28b9d13f16f11
201b8040581936a77b01e27ea6b6d692c8ceec4c
refs/heads/master
2020-03-28T10:25:35.593672
2018-09-10T01:43:41
2018-09-10T01:53:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
30,714
cpp
/* * Copyright 2017-present Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <folly/container/F14Set.h> #include <unordered_map> #include <folly/Conv.h> #include <folly/FBString.h> #include <folly/container/test/F14TestUtil.h> #include <folly/portability/GTest.h> template <template <typename, typename, typename, typename> class TSet> void testCustomSwap() { using std::swap; TSet< int, folly::f14::DefaultHasher<int>, folly::f14::DefaultKeyEqual<int>, folly::f14::SwapTrackingAlloc<int>> m0, m1; folly::f14::resetTracking(); swap(m0, m1); EXPECT_EQ( 0, folly::f14::Tracked<0>::counts.dist(folly::f14::Counts{0, 0, 0, 0})); } TEST(F14Set, customSwap) { testCustomSwap<folly::F14ValueSet>(); testCustomSwap<folly::F14NodeSet>(); testCustomSwap<folly::F14VectorSet>(); testCustomSwap<folly::F14FastSet>(); } namespace { template < template <typename, typename, typename, typename> class TSet, typename K> void runAllocatedMemorySizeTest() { using namespace folly::f14; using namespace folly::f14::detail; using A = SwapTrackingAlloc<K>; resetTracking(); { TSet<K, DefaultHasher<K>, DefaultKeyEqual<K>, A> s; // if F14 intrinsics are not available then we fall back to using // std::unordered_set underneath, but in that case the allocation // info is only best effort bool preciseAllocInfo = getF14IntrinsicsMode() != F14IntrinsicsMode::None; if (preciseAllocInfo) { EXPECT_EQ(testAllocatedMemorySize, 0); EXPECT_EQ(s.getAllocatedMemorySize(), 0); } auto emptySetAllocatedMemorySize = testAllocatedMemorySize; auto emptySetAllocatedBlockCount = testAllocatedBlockCount; for (size_t i = 0; i < 1000; ++i) { s.insert(folly::to<K>(i)); s.erase(folly::to<K>(i / 10 + 2)); if (preciseAllocInfo) { EXPECT_EQ(testAllocatedMemorySize, s.getAllocatedMemorySize()); } EXPECT_GE(s.getAllocatedMemorySize(), sizeof(K) * s.size()); std::size_t size = 0; std::size_t count = 0; s.visitAllocationClasses([&](std::size_t, std::size_t) mutable {}); s.visitAllocationClasses([&](std::size_t bytes, std::size_t n) { size += bytes * n; count += n; }); if (preciseAllocInfo) { EXPECT_EQ(testAllocatedMemorySize, size); EXPECT_EQ(testAllocatedBlockCount, count); } } s = decltype(s){}; EXPECT_EQ(testAllocatedMemorySize, emptySetAllocatedMemorySize); EXPECT_EQ(testAllocatedBlockCount, emptySetAllocatedBlockCount); s.reserve(5); EXPECT_GT(testAllocatedMemorySize, emptySetAllocatedMemorySize); s = {}; EXPECT_GT(testAllocatedMemorySize, emptySetAllocatedMemorySize); } EXPECT_EQ(testAllocatedMemorySize, 0); EXPECT_EQ(testAllocatedBlockCount, 0); } template <typename K> void runAllocatedMemorySizeTests() { runAllocatedMemorySizeTest<folly::F14ValueSet, K>(); runAllocatedMemorySizeTest<folly::F14NodeSet, K>(); runAllocatedMemorySizeTest<folly::F14VectorSet, K>(); runAllocatedMemorySizeTest<folly::F14FastSet, K>(); } } // namespace TEST(F14Set, getAllocatedMemorySize) { runAllocatedMemorySizeTests<bool>(); runAllocatedMemorySizeTests<int>(); runAllocatedMemorySizeTests<long>(); runAllocatedMemorySizeTests<double>(); runAllocatedMemorySizeTests<std::string>(); runAllocatedMemorySizeTests<folly::fbstring>(); } template <typename S> void runVisitContiguousRangesTest(int n) { S set; for (int i = 0; i < n; ++i) { set.insert(i); set.erase(i / 2); } std::unordered_map<uintptr_t, bool> visited; for (auto& entry : set) { visited[reinterpret_cast<uintptr_t>(&entry)] = false; } set.visitContiguousRanges([&](auto b, auto e) { for (auto i = b; i != e; ++i) { auto iter = visited.find(reinterpret_cast<uintptr_t>(i)); ASSERT_TRUE(iter != visited.end()); EXPECT_FALSE(iter->second); iter->second = true; } }); // ensure no entries were skipped for (auto& e : visited) { EXPECT_TRUE(e.second); } } template <typename S> void runVisitContiguousRangesTest() { runVisitContiguousRangesTest<S>(0); // empty runVisitContiguousRangesTest<S>(5); // single chunk runVisitContiguousRangesTest<S>(1000); // many chunks } TEST(F14ValueSet, visitContiguousRanges) { runVisitContiguousRangesTest<folly::F14ValueSet<int>>(); } TEST(F14NodeSet, visitContiguousRanges) { runVisitContiguousRangesTest<folly::F14NodeSet<int>>(); } TEST(F14VectorSet, visitContiguousRanges) { runVisitContiguousRangesTest<folly::F14VectorSet<int>>(); } TEST(F14FastSet, visitContiguousRanges) { runVisitContiguousRangesTest<folly::F14FastSet<int>>(); } /////////////////////////////////// #if FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE /////////////////////////////////// #include <chrono> #include <random> #include <string> #include <unordered_set> #include <folly/Range.h> using namespace folly; using namespace folly::f14; using namespace folly::string_piece_literals; namespace { std::string s(char const* p) { return p; } } // namespace template <typename T> void runSimple() { T h; EXPECT_EQ(h.size(), 0); h.insert(s("abc")); EXPECT_TRUE(h.find(s("def")) == h.end()); EXPECT_FALSE(h.find(s("abc")) == h.end()); h.insert(s("ghi")); EXPECT_EQ(h.size(), 2); h.erase(h.find(s("abc"))); EXPECT_EQ(h.size(), 1); T h2(std::move(h)); EXPECT_EQ(h.size(), 0); EXPECT_TRUE(h.begin() == h.end()); EXPECT_EQ(h2.size(), 1); EXPECT_TRUE(h2.find(s("abc")) == h2.end()); EXPECT_EQ(*h2.begin(), s("ghi")); { auto i = h2.begin(); EXPECT_FALSE(i == h2.end()); ++i; EXPECT_TRUE(i == h2.end()); } T h3; h3.insert(s("xxx")); h3.insert(s("yyy")); h3 = std::move(h2); EXPECT_EQ(h2.size(), 0); EXPECT_EQ(h3.size(), 1); EXPECT_TRUE(h3.find(s("xxx")) == h3.end()); for (uint64_t i = 0; i < 1000; ++i) { h.insert(std::move(to<std::string>(i * i * i))); EXPECT_EQ(h.size(), i + 1); } { using std::swap; swap(h, h2); } for (uint64_t i = 0; i < 1000; ++i) { EXPECT_TRUE(h2.find(to<std::string>(i * i * i)) != h2.end()); EXPECT_EQ(*h2.find(to<std::string>(i * i * i)), to<std::string>(i * i * i)); EXPECT_TRUE(h2.find(to<std::string>(i * i * i + 2)) == h2.end()); } T h4{h2}; EXPECT_EQ(h2.size(), 1000); EXPECT_EQ(h4.size(), 1000); T h5{std::move(h2)}; T h6; h6 = h4; T h7 = h4; T h8({s("abc"), s("def")}); T h9({s("abd"), s("def")}); EXPECT_EQ(h8.size(), 2); EXPECT_EQ(h8.count(s("abc")), 1); EXPECT_EQ(h8.count(s("xyz")), 0); EXPECT_TRUE(h7 != h8); EXPECT_TRUE(h8 != h9); h8 = std::move(h7); // h2 and h7 are moved from, h4, h5, h6, and h8 should be identical EXPECT_TRUE(h4 == h8); EXPECT_TRUE(h2.empty()); EXPECT_TRUE(h7.empty()); for (uint64_t i = 0; i < 1000; ++i) { auto k = to<std::string>(i * i * i); EXPECT_EQ(h4.count(k), 1); EXPECT_EQ(h5.count(k), 1); EXPECT_EQ(h6.count(k), 1); EXPECT_EQ(h8.count(k), 1); } h8.clear(); h8.emplace(s("abc")); EXPECT_GT(h8.bucket_count(), 1); h8 = {}; EXPECT_GT(h8.bucket_count(), 1); h9 = {s("abc"), s("def")}; EXPECT_TRUE(h8.empty()); EXPECT_EQ(h9.size(), 2); auto expectH8 = [&](T& ref) { EXPECT_EQ(&ref, &h8); }; expectH8((h8 = h2)); expectH8((h8 = std::move(h2))); expectH8((h8 = {})); F14TableStats::compute(h); F14TableStats::compute(h2); F14TableStats::compute(h3); F14TableStats::compute(h4); F14TableStats::compute(h5); F14TableStats::compute(h6); F14TableStats::compute(h7); F14TableStats::compute(h8); } template <typename T> void runRehash() { unsigned n = 10000; T h; for (unsigned i = 0; i < n; ++i) { h.insert(to<std::string>(i)); } EXPECT_EQ(h.size(), n); F14TableStats::compute(h); } // T should be a set of uint64_t template <typename T> void runRandom() { using R = std::unordered_set<uint64_t>; std::mt19937_64 gen(0); std::uniform_int_distribution<> pctDist(0, 100); std::uniform_int_distribution<uint64_t> bitsBitsDist(1, 6); T t0; T t1; R r0; R r1; for (std::size_t reps = 0; reps < 100000; ++reps) { // discardBits will be from 0 to 62 auto discardBits = (uint64_t{1} << bitsBitsDist(gen)) - 2; auto k = gen() >> discardBits; auto pct = pctDist(gen); EXPECT_EQ(t0.size(), r0.size()); if (pct < 15) { // insert auto t = t0.insert(k); auto r = r0.insert(k); EXPECT_EQ(t.second, r.second); EXPECT_EQ(*t.first, *r.first); } else if (pct < 25) { // emplace auto t = t0.emplace(k); auto r = r0.emplace(k); EXPECT_EQ(t.second, r.second); EXPECT_EQ(*t.first, *r.first); } else if (pct < 30) { // bulk insert t0.insert(t1.begin(), t1.end()); r0.insert(r1.begin(), r1.end()); } else if (pct < 40) { // erase by key auto t = t0.erase(k); auto r = r0.erase(k); EXPECT_EQ(t, r); } else if (pct < 47) { // erase by iterator if (t0.size() > 0) { auto r = r0.find(k); if (r == r0.end()) { r = r0.begin(); } k = *r; auto t = t0.find(k); t = t0.erase(t); if (t != t0.end()) { EXPECT_NE(*t, k); } r = r0.erase(r); if (r != r0.end()) { EXPECT_NE(*r, k); } } } else if (pct < 50) { // bulk erase if (t0.size() > 0) { auto r = r0.find(k); if (r == r0.end()) { r = r0.begin(); } k = *r; auto t = t0.find(k); auto firstt = t; auto lastt = ++t; t = t0.erase(firstt, lastt); if (t != t0.end()) { EXPECT_NE(*t, k); } auto firstr = r; auto lastr = ++r; r = r0.erase(firstr, lastr); if (r != r0.end()) { EXPECT_NE(*r, k); } } } else if (pct < 58) { // find auto t = t0.find(k); auto r = r0.find(k); EXPECT_EQ((t == t0.end()), (r == r0.end())); if (t != t0.end() && r != r0.end()) { EXPECT_EQ(*t, *r); } EXPECT_EQ(t0.count(k), r0.count(k)); } else if (pct < 60) { // equal_range auto t = t0.equal_range(k); auto r = r0.equal_range(k); EXPECT_EQ((t.first == t.second), (r.first == r.second)); if (t.first != t.second && r.first != r.second) { EXPECT_EQ(*t.first, *r.first); t.first++; r.first++; EXPECT_TRUE(t.first == t.second); EXPECT_TRUE(r.first == r.second); } } else if (pct < 65) { // iterate uint64_t t = 0; for (auto& e : t0) { t += e + 1000; } uint64_t r = 0; for (auto& e : r0) { r += e + 1000; } EXPECT_EQ(t, r); } else if (pct < 69) { // swap using std::swap; swap(t0, t1); swap(r0, r1); } else if (pct < 70) { // swap t0.swap(t1); r0.swap(r1); } else if (pct < 72) { // default construct t0.~T(); new (&t0) T(); r0.~R(); new (&r0) R(); } else if (pct < 74) { // default construct with capacity std::size_t capacity = k & 0xffff; t0.~T(); new (&t0) T(capacity); r0.~R(); new (&r0) R(capacity); } else if (pct < 80) { // bulk iterator construct t0.~T(); new (&t0) T(r1.begin(), r1.end()); r0.~R(); new (&r0) R(r1.begin(), r1.end()); } else if (pct < 82) { // initializer list construct auto k2 = gen() >> discardBits; t0.~T(); new (&t0) T({k, k, k2}); r0.~R(); new (&r0) R({k, k, k2}); } else if (pct < 88) { // copy construct t0.~T(); new (&t0) T(t1); r0.~R(); new (&r0) R(r1); } else if (pct < 90) { // move construct t0.~T(); new (&t0) T(std::move(t1)); r0.~R(); new (&r0) R(std::move(r1)); } else if (pct < 94) { // copy assign t0 = t1; r0 = r1; } else if (pct < 96) { // move assign t0 = std::move(t1); r0 = std::move(r1); } else if (pct < 98) { // operator== EXPECT_EQ((t0 == t1), (r0 == r1)); } else if (pct < 99) { // clear t0.computeStats(); t0.clear(); r0.clear(); } else if (pct < 100) { // reserve auto scale = std::uniform_int_distribution<>(0, 8)(gen); auto delta = std::uniform_int_distribution<>(-2, 2)(gen); std::ptrdiff_t target = (t0.size() * scale) / 4 + delta; if (target >= 0) { t0.reserve(static_cast<std::size_t>(target)); r0.reserve(static_cast<std::size_t>(target)); } } } } TEST(F14ValueSet, simple) { runSimple<F14ValueSet<std::string>>(); } TEST(F14NodeSet, simple) { runSimple<F14NodeSet<std::string>>(); } TEST(F14VectorSet, simple) { runSimple<F14VectorSet<std::string>>(); } TEST(F14FastSet, simple) { // F14FastSet inherits from a conditional typedef. Verify it compiles. runRandom<F14FastSet<uint64_t>>(); runSimple<F14FastSet<std::string>>(); } TEST(F14Set, ContainerSize) { { folly::F14ValueSet<int> set; set.insert(10); EXPECT_EQ(sizeof(set), 4 * sizeof(void*)); if (alignof(folly::max_align_t) == 16) { // chunks will be allocated as 2 max_align_t-s EXPECT_EQ(set.getAllocatedMemorySize(), 32); } else { // chunks will be allocated using aligned_malloc with the true size EXPECT_EQ(set.getAllocatedMemorySize(), 24); } } { folly::F14NodeSet<int> set; set.insert(10); EXPECT_EQ(sizeof(set), 4 * sizeof(void*)); if (alignof(folly::max_align_t) == 16) { // chunks will be allocated as 2 max_align_t-s EXPECT_EQ(set.getAllocatedMemorySize(), 36); } else { // chunks will be allocated using aligned_malloc with the true size EXPECT_EQ(set.getAllocatedMemorySize(), 20 + 2 * sizeof(void*)); } } { folly::F14VectorSet<int> set; set.insert(10); EXPECT_EQ(sizeof(set), 8 + 2 * sizeof(void*)); EXPECT_EQ(set.getAllocatedMemorySize(), 32); } } TEST(F14VectorMap, reverse_iterator) { using TSet = F14VectorSet<uint64_t>; auto populate = [](TSet& h, uint64_t lo, uint64_t hi) { for (auto i = lo; i < hi; ++i) { h.insert(i); } }; auto verify = [](TSet const& h, uint64_t lo, uint64_t hi) { auto loIt = h.find(lo); EXPECT_NE(h.end(), loIt); uint64_t val = lo; for (auto rit = h.riter(loIt); rit != h.rend(); ++rit) { EXPECT_EQ(val, *rit); TSet::const_iterator it = h.iter(rit); EXPECT_EQ(val, *it); val++; } EXPECT_EQ(hi, val); }; TSet h; size_t prevSize = 0; size_t newSize = 1; // verify iteration order across rehashes, copies, and moves while (newSize < 10'000) { populate(h, prevSize, newSize); verify(h, 0, newSize); verify(h, newSize / 2, newSize); TSet h2{h}; verify(h2, 0, newSize); h = std::move(h2); verify(h, 0, newSize); prevSize = newSize; newSize *= 10; } } TEST(F14ValueSet, rehash) { runRehash<F14ValueSet<std::string>>(); } TEST(F14NodeSet, rehash) { runRehash<F14NodeSet<std::string>>(); } TEST(F14VectorSet, rehash) { runRehash<F14VectorSet<std::string>>(); } TEST(F14ValueSet, random) { runRandom<F14ValueSet<uint64_t>>(); } TEST(F14NodeSet, random) { runRandom<F14NodeSet<uint64_t>>(); } TEST(F14VectorSet, random) { runRandom<F14VectorSet<uint64_t>>(); } TEST(F14ValueSet, grow_stats) { F14ValueSet<uint64_t> h; for (unsigned i = 1; i <= 3072; ++i) { h.insert(i); } // F14ValueSet just before rehash F14TableStats::compute(h); h.insert(0); // F14ValueSet just after rehash F14TableStats::compute(h); } TEST(F14ValueSet, steady_state_stats) { // 10k keys, 14% probability of insert, 90% chance of erase, so the // table should converge to 1400 size without triggering the rehash // that would occur at 1536. F14ValueSet<uint64_t> h; std::mt19937 gen(0); std::uniform_int_distribution<> dist(0, 10000); for (std::size_t i = 0; i < 100000; ++i) { auto key = dist(gen); if (dist(gen) < 1400) { h.insert(key); } else { h.erase(key); } if (((i + 1) % 10000) == 0) { auto stats = F14TableStats::compute(h); // Verify that average miss probe length is bounded despite continued // erase + reuse. p99 of the average across 10M random steps is 4.69, // average is 2.96. EXPECT_LT(f14::expectedProbe(stats.missProbeLengthHisto), 10.0); } } // F14ValueSet at steady state F14TableStats::compute(h); } // S should be a set of Tracked<0>. F should take a set // and a key_type const& or key_type&& and cause it to be inserted template <typename S, typename F> void runInsertCases(std::string const& /* name */, F const& insertFunc) { static_assert(std::is_same<typename S::value_type, Tracked<0>>::value, ""); { typename S::value_type k{0}; S s; resetTracking(); insertFunc(s, k); // fresh key, value_type const& -> // copy is expected EXPECT_EQ(Tracked<0>::counts.dist(Counts{1, 0, 0, 0}), 0); } { typename S::value_type k{0}; S s; resetTracking(); insertFunc(s, std::move(k)); // fresh key, value_type&& -> // move is expected EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 1, 0, 0}), 0); } } struct DoInsert { template <typename M, typename P> void operator()(M& m, P&& p) const { m.insert(std::forward<P>(p)); } }; struct DoEmplace1 { template <typename M, typename P> void operator()(M& m, P&& p) const { m.emplace(std::forward<P>(p)); } }; template <typename S> void runInsertAndEmplace() { { typename S::value_type k1{0}; typename S::value_type k2{0}; S s; resetTracking(); EXPECT_TRUE(s.insert(k1).second); // copy is expected on successful insert EXPECT_EQ(Tracked<0>::counts.dist(Counts{1, 0, 0, 0}), 0); resetTracking(); EXPECT_FALSE(s.insert(k2).second); // no copies or moves on failing insert EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 0, 0, 0}), 0); } { typename S::value_type k1{0}; typename S::value_type k2{0}; S s; resetTracking(); EXPECT_TRUE(s.insert(std::move(k1)).second); // move is expected on successful insert EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 1, 0, 0}), 0); resetTracking(); EXPECT_FALSE(s.insert(std::move(k2)).second); // no copies or moves on failing insert EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 0, 0, 0}), 0); } { typename S::value_type k1{0}; typename S::value_type k2{0}; uint64_t k3 = 0; uint64_t k4 = 10; S s; resetTracking(); EXPECT_TRUE(s.emplace(k1).second); // copy is expected on successful emplace EXPECT_EQ(Tracked<0>::counts.dist(Counts{1, 0, 0, 0}), 0); resetTracking(); EXPECT_FALSE(s.emplace(k2).second); // no copies or moves on failing emplace with value_type EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 0, 0, 0}), 0); resetTracking(); EXPECT_FALSE(s.emplace(k3).second); // copy convert expected for failing emplace with wrong type EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 0, 1, 0}), 0); resetTracking(); EXPECT_TRUE(s.emplace(k4).second); // copy convert + move expected for successful emplace with wrong type EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 1, 1, 0}), 0); } { typename S::value_type k1{0}; typename S::value_type k2{0}; uint64_t k3 = 0; uint64_t k4 = 10; S s; resetTracking(); EXPECT_TRUE(s.emplace(std::move(k1)).second); // move is expected on successful emplace EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 1, 0, 0}), 0); resetTracking(); EXPECT_FALSE(s.emplace(std::move(k2)).second); // no copies or moves on failing emplace with value_type EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 0, 0, 0}), 0); resetTracking(); EXPECT_FALSE(s.emplace(std::move(k3)).second); // move convert expected for failing emplace with wrong type EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 0, 0, 1}), 0); resetTracking(); EXPECT_TRUE(s.emplace(std::move(k4)).second); // move convert + move expected for successful emplace with wrong type EXPECT_EQ(Tracked<0>::counts.dist(Counts{0, 1, 0, 1}), 0); } // Calling the default pair constructor via emplace is valid, but not // very useful in real life. Verify that it works. S s; typename S::value_type k; EXPECT_EQ(s.count(k), 0); s.emplace(); EXPECT_EQ(s.count(k), 1); s.emplace(); EXPECT_EQ(s.count(k), 1); } TEST(F14ValueSet, destructuring) { runInsertAndEmplace<F14ValueSet<Tracked<0>>>(); } TEST(F14NodeSet, destructuring) { runInsertAndEmplace<F14NodeSet<Tracked<0>>>(); } TEST(F14VectorSet, destructuring) { runInsertAndEmplace<F14VectorSet<Tracked<0>>>(); } TEST(F14ValueSet, maxSize) { F14ValueSet<int> s; EXPECT_EQ( s.max_size(), std::numeric_limits<std::size_t>::max() / sizeof(int)); } TEST(F14NodeSet, maxSize) { F14NodeSet<int> s; EXPECT_EQ( s.max_size(), std::numeric_limits<std::size_t>::max() / sizeof(int)); } TEST(F14VectorSet, maxSize) { F14VectorSet<int> s; EXPECT_EQ( s.max_size(), std::min( std::size_t{std::numeric_limits<uint32_t>::max()}, std::numeric_limits<std::size_t>::max() / sizeof(int))); } template <typename S> void runMoveOnlyTest() { S t0; t0.emplace(10); t0.insert(20); S t1{std::move(t0)}; EXPECT_TRUE(t0.empty()); S t2; EXPECT_TRUE(t2.empty()); t2 = std::move(t1); EXPECT_EQ(t2.size(), 2); } TEST(F14ValueSet, moveOnly) { runMoveOnlyTest<F14ValueSet<f14::MoveOnlyTestInt>>(); } TEST(F14NodeSet, moveOnly) { runMoveOnlyTest<F14NodeSet<f14::MoveOnlyTestInt>>(); } TEST(F14VectorSet, moveOnly) { runMoveOnlyTest<F14VectorSet<f14::MoveOnlyTestInt>>(); } TEST(F14FastSet, moveOnly) { runMoveOnlyTest<F14FastSet<f14::MoveOnlyTestInt>>(); } template <typename S> void runEraseIntoTest() { S t0; S t1; auto insertIntoT0 = [&t0](auto&& value) { EXPECT_FALSE(value.destroyed); t0.emplace(std::move(value)); }; auto insertIntoT0Mut = [&](typename S::value_type&& value) mutable { insertIntoT0(std::move(value)); }; t0.insert(10); t1.insert(20); t1.eraseInto(t1.begin(), insertIntoT0); EXPECT_TRUE(t1.empty()); EXPECT_EQ(t0.size(), 2); EXPECT_TRUE(t0.find(10) != t0.end()); EXPECT_TRUE(t0.find(20) != t0.end()); t1.insert(20); t1.insert(30); t1.insert(40); t1.eraseInto(t1.begin(), t1.end(), insertIntoT0Mut); EXPECT_TRUE(t1.empty()); EXPECT_EQ(t0.size(), 4); EXPECT_TRUE(t0.find(30) != t0.end()); EXPECT_TRUE(t0.find(40) != t0.end()); t1.insert(50); size_t erased = t1.eraseInto(*t1.find(50), insertIntoT0); EXPECT_EQ(erased, 1); EXPECT_TRUE(t1.empty()); EXPECT_EQ(t0.size(), 5); EXPECT_TRUE(t0.find(50) != t0.end()); typename S::value_type key{60}; erased = t1.eraseInto(key, insertIntoT0Mut); EXPECT_EQ(erased, 0); EXPECT_EQ(t0.size(), 5); } TEST(F14ValueSet, eraseInto) { runEraseIntoTest<F14ValueSet<f14::MoveOnlyTestInt>>(); } TEST(F14NodeSet, eraseInto) { runEraseIntoTest<F14NodeSet<f14::MoveOnlyTestInt>>(); } TEST(F14VectorSet, eraseInto) { runEraseIntoTest<F14VectorSet<f14::MoveOnlyTestInt>>(); } TEST(F14FastSet, eraseInto) { runEraseIntoTest<F14FastSet<f14::MoveOnlyTestInt>>(); } TEST(F14ValueSet, heterogeneous) { // note: std::string is implicitly convertible to but not from StringPiece using Hasher = folly::transparent<folly::hasher<folly::StringPiece>>; using KeyEqual = folly::transparent<std::equal_to<folly::StringPiece>>; constexpr auto hello = "hello"_sp; constexpr auto buddy = "buddy"_sp; constexpr auto world = "world"_sp; F14ValueSet<std::string, Hasher, KeyEqual> set; set.emplace(hello); set.emplace(world); auto checks = [hello, buddy](auto& ref) { // count EXPECT_EQ(0, ref.count(buddy)); EXPECT_EQ(1, ref.count(hello)); // find EXPECT_TRUE(ref.end() == ref.find(buddy)); EXPECT_EQ(hello, *ref.find(hello)); // prehash + find EXPECT_TRUE(ref.end() == ref.find(ref.prehash(buddy), buddy)); EXPECT_EQ(hello, *ref.find(ref.prehash(hello), hello)); // equal_range EXPECT_TRUE(std::make_pair(ref.end(), ref.end()) == ref.equal_range(buddy)); EXPECT_TRUE( std::make_pair(ref.find(hello), ++ref.find(hello)) == ref.equal_range(hello)); }; checks(set); checks(folly::as_const(set)); } template <typename S> void runStatefulFunctorTest() { bool ranHasher = false; bool ranEqual = false; bool ranAlloc = false; bool ranDealloc = false; auto hasher = [&](int x) { ranHasher = true; return x; }; auto equal = [&](int x, int y) { ranEqual = true; return x == y; }; auto alloc = [&](std::size_t n) { ranAlloc = true; return std::malloc(n); }; auto dealloc = [&](void* p, std::size_t) { ranDealloc = true; std::free(p); }; { S set(0, hasher, equal, {alloc, dealloc}); set.insert(10); set.insert(10); EXPECT_EQ(set.size(), 1); S set2(set); S set3(std::move(set)); set = set2; set2.clear(); set2 = std::move(set3); } EXPECT_TRUE(ranHasher); EXPECT_TRUE(ranEqual); EXPECT_TRUE(ranAlloc); EXPECT_TRUE(ranDealloc); } TEST(F14ValueSet, statefulFunctors) { runStatefulFunctorTest<F14ValueSet< int, GenericHasher<int>, GenericEqual<int>, GenericAlloc<int>>>(); } TEST(F14NodeSet, statefulFunctors) { runStatefulFunctorTest<F14NodeSet< int, GenericHasher<int>, GenericEqual<int>, GenericAlloc<int>>>(); } TEST(F14VectorSet, statefulFunctors) { runStatefulFunctorTest<F14VectorSet< int, GenericHasher<int>, GenericEqual<int>, GenericAlloc<int>>>(); } TEST(F14FastSet, statefulFunctors) { runStatefulFunctorTest<F14FastSet< int, GenericHasher<int>, GenericEqual<int>, GenericAlloc<int>>>(); } template <typename S> void runHeterogeneousInsertTest() { S set; resetTracking(); EXPECT_EQ(set.count(10), 0); EXPECT_EQ(Tracked<1>::counts.dist(Counts{0, 0, 0, 0}), 0) << Tracked<1>::counts; resetTracking(); set.insert(10); EXPECT_EQ(Tracked<1>::counts.dist(Counts{0, 0, 0, 1}), 0) << Tracked<1>::counts; resetTracking(); int k = 10; std::vector<int> v({10}); set.insert(10); set.insert(k); set.insert(v.begin(), v.end()); set.insert( std::make_move_iterator(v.begin()), std::make_move_iterator(v.end())); set.emplace(10); set.emplace(k); EXPECT_EQ(Tracked<1>::counts.dist(Counts{0, 0, 0, 0}), 0) << Tracked<1>::counts; resetTracking(); set.erase(20); EXPECT_EQ(set.size(), 1); EXPECT_EQ(Tracked<1>::counts.dist(Counts{0, 0, 0, 0}), 0) << Tracked<1>::counts; resetTracking(); set.erase(10); EXPECT_EQ(set.size(), 0); EXPECT_EQ(Tracked<1>::counts.dist(Counts{0, 0, 0, 0}), 0) << Tracked<1>::counts; set.insert(10); resetTracking(); set.eraseInto(10, [](auto&&) {}); EXPECT_EQ(Tracked<1>::counts.dist(Counts{0, 0, 0, 0}), 0) << Tracked<1>::counts; } template <typename S> void runHeterogeneousInsertStringTest() { S set; StringPiece k{"foo"}; std::vector<StringPiece> v{k}; set.insert(k); set.insert("foo"); set.insert(StringPiece{"foo"}); set.insert(v.begin(), v.end()); set.insert( std::make_move_iterator(v.begin()), std::make_move_iterator(v.end())); set.emplace(); set.emplace(k); set.emplace("foo"); set.emplace(StringPiece("foo")); set.erase(""); set.erase(k); set.erase(StringPiece{"foo"}); EXPECT_TRUE(set.empty()); } TEST(F14ValueSet, heterogeneousInsert) { runHeterogeneousInsertTest<F14ValueSet< Tracked<1>, TransparentTrackedHash<1>, TransparentTrackedEqual<1>>>(); runHeterogeneousInsertStringTest<F14ValueSet< std::string, transparent<hasher<StringPiece>>, transparent<DefaultKeyEqual<StringPiece>>>>(); } TEST(F14NodeSet, heterogeneousInsert) { runHeterogeneousInsertTest<F14NodeSet< Tracked<1>, TransparentTrackedHash<1>, TransparentTrackedEqual<1>>>(); runHeterogeneousInsertStringTest<F14NodeSet< std::string, transparent<hasher<StringPiece>>, transparent<DefaultKeyEqual<StringPiece>>>>(); } TEST(F14VectorSet, heterogeneousInsert) { runHeterogeneousInsertTest<F14VectorSet< Tracked<1>, TransparentTrackedHash<1>, TransparentTrackedEqual<1>>>(); runHeterogeneousInsertStringTest<F14VectorSet< std::string, transparent<hasher<StringPiece>>, transparent<DefaultKeyEqual<StringPiece>>>>(); } TEST(F14FastSet, heterogeneousInsert) { runHeterogeneousInsertTest<F14FastSet< Tracked<1>, TransparentTrackedHash<1>, TransparentTrackedEqual<1>>>(); runHeterogeneousInsertStringTest<F14FastSet< std::string, transparent<hasher<StringPiece>>, transparent<DefaultKeyEqual<StringPiece>>>>(); } namespace { struct CharArrayHasher { template <std::size_t N> std::size_t operator()(std::array<char, N> const& value) const { return folly::Hash{}( StringPiece{value.data(), &value.data()[value.size()]}); } }; template < template <typename, typename, typename, typename> class S, std::size_t N> struct RunAllValueSizeTests { void operator()() const { using Key = std::array<char, N>; static_assert(sizeof(Key) == N, ""); S<Key, CharArrayHasher, std::equal_to<Key>, std::allocator<Key>> set; for (int i = 0; i < 100; ++i) { Key key{{static_cast<char>(i)}}; set.insert(key); } while (!set.empty()) { set.erase(set.begin()); } RunAllValueSizeTests<S, N - 1>{}(); } }; template <template <typename, typename, typename, typename> class S> struct RunAllValueSizeTests<S, 0> { void operator()() const {} }; } // namespace TEST(F14ValueSet, valueSize) { RunAllValueSizeTests<F14ValueSet, 32>{}(); } /////////////////////////////////// #endif // FOLLY_F14_VECTOR_INTRINSICS_AVAILABLE ///////////////////////////////////
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
d9ec3159fdcc70dcf4784c46f5034a61abb2b6fb
d99e3a8b8a442062df49c031b13c900fc14aed2b
/11sourcebk/marketadmin/MemberTypeDiscount.h
10f02beeb717bd560e920930337957138f1c2c8a
[]
no_license
pengge/jiaocai_new
1ce79aaded807285c61625e590777bfdb5ce208b
982bcc7ee55cc1fc3860ced9305271e9fb9571d6
refs/heads/master
2022-01-31T03:53:58.434184
2016-11-12T12:02:03
2016-11-12T12:02:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,270
h
//--------------------------------------------------------------------------- #ifndef MemberTypeDiscountH #define MemberTypeDiscountH //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> #include "RzButton.hpp" #include "RzPanel.hpp" #include <ExtCtrls.hpp> #include <ImgList.hpp> #include "RzDBGrid.hpp" #include "RzEdit.hpp" #include "RzLabel.hpp" #include "RzRadChk.hpp" #include <ComCtrls.hpp> #include <DBGrids.hpp> #include <Grids.hpp> #include <Mask.hpp> #include <Menus.hpp> #include <ADODB.hpp> #include <DB.hpp> #include <Buttons.hpp> //--------------------------------------------------------------------------- class TfrmMemberDiscount : public TForm { __published: // IDE-managed Components TRzToolbar *RzToolbar1; TRzToolButton *BtnExit; TRzToolButton *BtnSave; TImageList *ImageList1; TPopupMenu *pm; TMenuItem *N1; TMenuItem *N3; TMenuItem *N2; TMenuItem *N4; TPopupMenu *pm1; TMenuItem *N5; TPopupMenu *PopupMenu; TMenuItem *N6; TMenuItem *Ndelete; TRzGroupBox *rgbdiscountplan; TRzLabel *lblCatalog; TRzEdit *edtCatalog; TDBGrid *DBGrid1; TRzGroupBox *rgbdiscountview; TRzDBGrid *dbgdiscount; TGroupBox *GroupBox1; TLabel *Label1; TComboBox *cbstorage; TLabel *Label5; TComboBox *cbmembertype; TDataSource *ds1; TADOQuery *aq; TDataSource *ds2; TADOQuery *querydetail; TADOQuery *query; TRzToolButton *BtnAlignBottom; TGroupBox *GroupBox2; TLabel *Label4; TLabel *Label9; TLabel *Label2; TLabel *Label3; TEdit *eddiscount; TDateTimePicker *dtpstart; TDateTimePicker *dtpend; TLabel *Label6; TEdit *edprice; void __fastcall edtCatalogKeyPress(TObject *Sender, wchar_t &Key); void __fastcall BtnSaveClick(TObject *Sender); void __fastcall DBGrid1CellClick(TColumn *Column); void __fastcall N1Click(TObject *Sender); void __fastcall N3Click(TObject *Sender); void __fastcall N2Click(TObject *Sender); void __fastcall N4Click(TObject *Sender); void __fastcall N5Click(TObject *Sender); void __fastcall NdeleteClick(TObject *Sender); void __fastcall N6Click(TObject *Sender); void __fastcall BtnExitClick(TObject *Sender); void __fastcall FormClose(TObject *Sender, TCloseAction &Action); void __fastcall eddiscountKeyPress(TObject *Sender, wchar_t &Key); void __fastcall BtnAlignBottomClick(TObject *Sender); void __fastcall FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall cbstorageSelect(TObject *Sender); void __fastcall edpriceKeyPress(TObject *Sender, wchar_t &Key); void __fastcall dbgdiscountCellClick(TColumn *Column); void __fastcall lblCatalogMouseDown(TObject *Sender, TMouseButton Button, TShiftState Shift, int X, int Y); private: // User declarations int m_catalogSearchMode; int fstgid; public: // User declarations __fastcall TfrmMemberDiscount(TComponent* Owner,TADOConnection* con,int stgid); void ChangeCatalogSearchMode(); void Query(); void __fastcall disable(); void excuit(); bool modify; }; //--------------------------------------------------------------------------- extern PACKAGE TfrmMemberDiscount *frmMemberDiscount; //--------------------------------------------------------------------------- #endif
[ "legendbin@gmail.com" ]
legendbin@gmail.com
8f1aa337b52b3c32c4dc991a2314ba03e36898a5
e03f7defc91c8fe93355512d0438072b3542bace
/HemingModelingTool/stdafx.cpp
176a4a38b0ffe90ef3714d1dcbdf10a79b346174
[]
no_license
xunter/ma_heming_modeling_tool
993794c8ea3a3af6b14497b5fd1f7e731120bad7
a255157f13ca4e4c5a5b58efddf387cef5dae4eb
refs/heads/master
2021-01-23T19:45:21.496603
2013-06-23T23:47:33
2013-06-23T23:47:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
297
cpp
// stdafx.cpp : source file that includes just the standard includes // HemingModelingTool.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "xunter@list.ru" ]
xunter@list.ru
a8e603902b62802894e5401d7001a59f0549b4f7
97ea00a99b4fabf471e8f89e972c8ca134442586
/ios/UnityExport/Classes/Native/netstandard.cpp
1db4ab434f5db44bc963a5404b5604fc0c920126
[ "MIT" ]
permissive
Projet-Industriel-2020-PYM-APP/app_pym
1c79d50b6f8c83cd7eba643c85dc8ccfa28feeb2
4acacc02e361ddb440633f711c16608a814bcbe3
refs/heads/develop
2021-03-20T01:57:44.417183
2020-06-24T17:25:28
2020-06-24T17:25:28
247,163,643
1
0
MIT
2020-06-26T11:31:39
2020-03-13T21:21:33
C++
UTF-8
C++
false
false
954
cpp
#include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <cstring> #include <string.h> #include <stdio.h> #include <cmath> #include <limits> #include <assert.h> #include <stdint.h> #include "codegen/il2cpp-codegen.h" #include "il2cpp-object-internals.h" IL2CPP_EXTERN_C_BEGIN IL2CPP_EXTERN_C_END #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // <Module> struct U3CModuleU3E_tCE4B768174CDE0294B05DD8ED59A7763FF34E99B { public: public: }; // System.Object struct Il2CppArrayBounds; // System.Array #ifdef __clang__ #pragma clang diagnostic pop #endif #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "noreply@github.com" ]
noreply@github.com
2b4f4474bfb5c91933e0a8085b1cefa6e6d959c0
b9640203124ec76d4b8b17f68285303faab577bf
/fmesher/src/fmesher.cc
e5592f6ce1d8312cac190504563f948bd69c90e1
[]
no_license
HughParsonage/R-INLA-mirror
dec80a626659ea3b8773ba5a69b6892cd937ebd7
59798933294c06157c14b2edc348d4fe1848771d
refs/heads/master
2021-04-15T15:51:57.062420
2018-03-20T11:58:06
2018-03-20T11:58:06
126,698,129
1
0
null
null
null
null
UTF-8
C++
false
false
42,982
cc
#include <algorithm> #include <cmath> #include <cstddef> #include <cstdlib> #include <fstream> #include <iostream> #include <sstream> #include <string> #include <vector> #include "fmesher.hh" #ifndef WHEREAMI #define WHEREAMI __FILE__ << "(" << __LINE__ << ")\t" #endif #ifndef LOG_ #define LOG_(msg) cout << WHEREAMI << msg; #endif #ifndef LOG #ifdef DEBUG #define LOG(msg) LOG_(msg) #else #define LOG(msg) #endif #endif using std::ios; using std::ifstream; using std::ofstream; using std::string; using std::cin; using std::cout; using std::endl; using fmesh::Dart; using fmesh::DartPair; using fmesh::DartList; using fmesh::Int3; using fmesh::Int3Raw; using fmesh::IOHelper; using fmesh::IOHelperM; using fmesh::IOHelperSM; using fmesh::Matrix; using fmesh::Matrix3double; using fmesh::MatrixC; using fmesh::Mesh; using fmesh::MeshC; using fmesh::Point; using fmesh::PointRaw; using fmesh::SparseMatrix; using fmesh::Vector3; using fmesh::constrMetaT; using fmesh::constrT; using fmesh::constrListT; using fmesh::vertexListT; using fmesh::TriangleLocator; const bool useVT = true; const bool useTTi = true; bool useX11 = false; const bool useX11text = false; double x11_delay_factor = 1.0; double x11_zoom[4]; MatrixC matrices; template <class T> void print_M(string filename, const Matrix<T>& M, fmesh::IOMatrixtype matrixt = fmesh::IOMatrixtype_general) { M.save(filename,matrixt); } template <class T> void print_SM(string filename, const SparseMatrix<T>& M, fmesh::IOMatrixtype matrixt = fmesh::IOMatrixtype_general) { M.save(filename,matrixt); } template <class T> void print_M_old(string filename, const Matrix<T>& M, fmesh::IOMatrixtype matrixt = fmesh::IOMatrixtype_general) { M.save_ascii_2009(filename,matrixt); } template <class T> void print_SM_old(string filename, const SparseMatrix<T>& M, fmesh::IOMatrixtype matrixt = fmesh::IOMatrixtype_general) { M.save_ascii_2009(filename,matrixt); } void map_points_to_mesh(const Mesh& M, const Matrix<double>& points, Matrix<int>& point2T, Matrix<double>& point2bary) { int t; Point s; Point b; int the_dimensions[] = {0,1}; std::vector<int> dimensions(the_dimensions, the_dimensions + sizeof(the_dimensions) / sizeof(int) ); TriangleLocator locator(&M, dimensions, true); for (size_t i=0; i<points.rows(); i++) { s[0] = points[i][0]; s[1] = points[i][1]; s[2] = points[i][2]; t = locator.locate(s); if (t>=0) { /* Point located. */ M.barycentric(Dart(M,t),s,b); /* Coordinates relative to canonical vertex ordering. */ point2T(i,0) = t; point2bary(i,0) = b[0]; point2bary(i,1) = b[1]; point2bary(i,2) = b[2]; } else { /* Point not found. */ point2T(i,0) = -1; } } } void map_points_to_mesh_convex(const Mesh& M, const Matrix<double>& points, Matrix<int>& point2T, Matrix<double>& point2bary) { Dart d0(M); Dart d; Point s; Point b; for (size_t i=0; i<points.rows(); i++) { s[0] = points[i][0]; s[1] = points[i][1]; s[2] = points[i][2]; d = M.locate_point(Dart(M),s); if (!d.isnull()) { /* Point located. */ M.barycentric(Dart(M,d.t()),s,b); /* Coordinates relative to canonical vertex ordering. */ point2T(i,0) = d.t(); point2bary(i,0) = b[0]; point2bary(i,1) = b[1]; point2bary(i,2) = b[2]; d0 = d; /* Bet on the next point being close. */ } else { /* Point not found. */ point2T(i,0) = -1; } } } void filter_locations_slow(Matrix<double>& S, Matrix<int>& idx, double cutoff) { size_t dim = S.cols(); size_t idx_next = 0; typedef std::list< std::pair<int, Point> > excludedT; excludedT excluded; LOG("Filtering locations." << endl); /* Extract "unique" points. */ double dist; Point s = Point(0.0, 0.0, 0.0); Point diff = Point(0.0, 0.0, 0.0); for (size_t v=0; v<S.rows(); v++) { bool was_excluded = false; for (size_t d=0; d<dim; d++) s[d] = S[v][d]; for (size_t v_try=0; v_try<idx_next; v_try++) { for (size_t d=0; d<dim; d++) diff[d] = S[v_try][d]-s[d]; if (diff.length() <= cutoff) { was_excluded = true; excluded.push_back(excludedT::value_type(v,s)); idx(v,0) = v_try; break; } } if (!was_excluded) { for (size_t d=0; d<dim; d++) S(idx_next,d) = s[d]; idx(v,0) = idx_next; idx_next++; } } LOG("All vertices handled." << endl); /* Remove excess storage. */ S.rows(idx_next); LOG("Excess storage removed." << endl); LOG("Identifying nearest points." << endl); /* Identify nearest nodes for excluded locations. */ for (excludedT::const_iterator i=excluded.begin(); i != excluded.end(); i++) { size_t v = (*i).first; for (size_t d=0; d<dim; d++) s[d] = (*i).second[d]; double nearest_dist = -1.0; int nearest_idx = -1; for (size_t v_try=0; v_try<S.rows(); v_try++) { for (size_t d=0; d<dim; d++) diff[d] = S[v_try][d]-s[d]; dist = diff.length(); if ((nearest_idx<0) || (dist<nearest_dist)) { nearest_idx = v_try; nearest_dist = dist; } } if (idx(v,0) != nearest_idx) { LOG("Excluded vertex " << v << " remapped from " << idx(v,0) << " to " << nearest_idx << "." << endl); } idx(v,0) = nearest_idx; } LOG("Done identifying nearest points." << endl); } template<typename T> std::ostream& operator<< (std::ostream& out, const std::vector<T> v) { int last = v.size() - 1; out << "["; for(int i = 0; i < last; i++) out << v[i] << ", "; out << v[last] << "]"; return out; } class NNLocator { std::multimap<double, size_t> search_map_; Matrix<double> const * S_; int _dim; public: NNLocator(Matrix<double> * S, int dim) : search_map_(), S_(S), _dim(dim) {} public: double distance2(double const * point, int v) { double diff; double dist = 0.0; for (int d=0; d < _dim; ++d) { diff = point[d]-(*S_)[v][d]; dist += diff*diff; } return dist; }; double distance(double const * point, int v) { return std::sqrt(distance2(point, v)); }; typedef std::multimap<double, size_t>::value_type value_type; typedef std::multimap<double, size_t>::iterator iterator; typedef std::multimap<double, size_t>::const_iterator const_iterator; typedef std::multimap<double, size_t>::reverse_iterator reverse_iterator; typedef std::multimap<double, size_t>::const_reverse_iterator const_reverse_iterator; iterator insert(int idx) { return search_map_.insert(value_type((*S_)[idx][0], idx)); }; iterator insert(iterator position, int idx) { return search_map_.insert(position, value_type((*S_)[idx][0], idx)); }; iterator begin() { return search_map_.begin(); }; iterator end() { return search_map_.end(); }; // Find nearest neighbour, optionally with distance <= bound iterator find_nn_bounded(double const * point, bool have_bound, double distance2_bound) { iterator iter, start; double dist; bool found = false; // true if we've found at least one neighbour. double shortest_dist = -1.0; iterator found_iter(search_map_.end()); // pointer to the closest // found neighbour size_t const size = search_map_.size(); if (size == 0) { return search_map_.end(); } else if (size == 1) { found_iter = search_map_.begin(); if (have_bound && distance2(point, found_iter->second) > distance2_bound) { return search_map_.end(); } return found_iter; } start = search_map_.lower_bound(point[0]); // Handle boundary case: // If max < point, then lower=end and upper=end, so we need to // skip the forward part and only run backward. bool forward = (start != found_iter); bool outside_bound = false; iter = start; while ((forward && iter != search_map_.end()) || (!forward && iter != search_map_.begin())) { if (!forward) { --iter; } if (found || have_bound) { // Check upper bound first dist = iter->first - point[0]; if ((forward && dist > 0.0) || (!forward && dist < 0.0)) { dist = dist*dist; if ((found && (dist >= shortest_dist)) || (have_bound && (dist > distance2_bound))) { outside_bound = true; } } } if (!outside_bound) { dist = distance2(point, iter->second); LOG("distance2 = " << dist << endl); LOG("found = " << found << ", shortest_dist = " << shortest_dist << endl); LOG("have_bound = " << have_bound << ", distance2_bound = " << distance2_bound << endl); if ((!found || (dist < shortest_dist)) && (!have_bound || (dist <= distance2_bound))) { found = true; found_iter = iter; shortest_dist = dist; LOG("shortest updated" << endl); } else { LOG("no action" << endl); } } if (forward) { ++iter; } if ((iter == search_map_.end()) || (forward && outside_bound)) { outside_bound = false; forward = false; iter = start; LOG("reverse" << endl); } else if (!forward && outside_bound) { break; } } LOG("Finished. found = " << found << endl); return found_iter; }; iterator operator() (double const * point) { return find_nn_bounded(point, false, 0.0); }; iterator operator() (double const * point, double cutoff) { return find_nn_bounded(point, true, cutoff*cutoff); }; }; void filter_locations(Matrix<double>& S, Matrix<int>& idx, double cutoff) { int const dim = S.cols(); int const Nv = S.rows(); NNLocator nnl(&S, dim); int incl_next = 0; int excl_next = Nv-1; std::vector<int> remap(Nv); // New node ordering; included first, // then excluded. LOG("Filtering locations." << endl); for (size_t v=0; v < Nv; v++) { remap[v] = -1; } NNLocator::iterator nniter; LOG("Identify 'unique' points." << endl); for (size_t v=0; v < Nv; v++) { nniter = nnl(S[v], cutoff); if (nniter != nnl.end()) { // Exclude node remap[excl_next] = v; idx(v,0) = excl_next; --excl_next; } else { // Include node nnl.insert(nniter, v); // Hint position nniter remap[incl_next] = v; idx(v,0) = incl_next; ++incl_next; } } LOG("All vertices handled." << endl); LOG("Identifying nearest points for excluded locations." << endl); for (size_t v=Nv; v > incl_next;) { --v; nniter = nnl(S[remap[v]]); if (nniter == nnl.end()) { cout << "Internal error: No nearest neighbour found." << endl; } idx(remap[v],0) = idx(nniter->second,0); LOG("Excluded vertex " << remap[v] << " remapped to " << idx(remap[v],0) << "." << endl); } LOG("Done identifying nearest points." << endl); LOG("Compactify storage from " << Nv << " to " << incl_next << endl); for (size_t v=0; v < incl_next; ++v) { // In-place overwrite allowed since remapping of included nodes // was order preserving. If no filtering done, no need to copy data. if (v != remap[v]) { for (size_t d=0; d<dim; d++) S(v,d) = S[remap[v]][d]; } } LOG("Compactify storage done." << endl); /* Remove excess storage. */ LOG("Remove excess storage." << endl); S.rows(incl_next); LOG("Excess storage removed." << endl); } void invalidate_unused_vertex_indices(const Mesh& M, Matrix<int>& idx) { for (size_t v=0; v<idx.rows(); v++) { if ((idx(v,0)>=0) && ((idx(v,0) >= M.nV()) || (M.VT(idx(v,0))==-1))) { idx(v,0) = -1; } } } void remap_vertex_indices(const Matrix<int>& idx, Matrix<int>& matrix) { LOG("Remapping vertex indices for an index matrix." << endl); LOG("Index size: " << idx.rows() << ", " << idx.cols() << endl); LOG("Matrix size: " << matrix.rows() << ", " << matrix.cols() << endl); for (size_t i=0; i<matrix.rows(); i++) { for (size_t j=0; j<matrix.cols(); j++) { matrix(i,j) = idx[matrix[i][j]][0]; } } LOG("Done." << endl); } void remap_vertex_indices(const Matrix<int>& idx, constrListT& segm) { LOG("Remapping vertex indices constraint segments." << endl); LOG("Index size: " << idx.rows() << ", " << idx.cols() << endl); LOG("Segment size: " << segm.size() << endl); for (constrListT::iterator i=segm.begin(); i != segm.end(); i++) { (*i).first.first = idx[(*i).first.first][0]; (*i).first.second = idx[(*i).first.second][0]; } LOG("Done." << endl); } void prepare_cdt_input(const Matrix<int>& segm0, const Matrix<int>& segmgrp, constrListT& cdt_segm) { int grp = 0; // Init with default group. if (segm0.cols()==1) { int v0 = -1; int v1 = -1; for (size_t i=0; i < segm0.rows(); i++) { v0 = v1; v1 = segm0[i][0]; if (i<segmgrp.rows()) // Update group index, if available grp = segmgrp[i][0]; if ((v0>=0) && (v1>=0)) { cdt_segm.push_back(constrT(v0,v1,grp)); } } } else if (segm0.cols()==2) { int v0 = -1; int v1 = -1; for (size_t i=0; i < segm0.rows(); i++) { v0 = segm0[i][0]; v1 = segm0[i][1]; if (i<segmgrp.rows()) // Update group index, if available grp = segmgrp[i][0]; if ((v0>=0) && (v1>=0)) { cdt_segm.push_back(constrT(v0,v1,grp)); } } } } /* loc0: nloc0-by-3 idx0: nidx0-by-2 loc1: nloc1-by-2 idx1: nidx1-by-2 triangle1: nidx1-by-1 bary1: nidx1-by-3, idx1[i,0] coordinates within triangle1[i] bary2: nidx1-by-3, idx1[i,1] coordinates within triangle1[i] origin1: nidx1-by-1 */ void split_line_segments_on_triangles(const Mesh& M, const Matrix<double>& loc0, const Matrix<int>& idx0, Matrix<double>& loc1, Matrix<int>& idx1, Matrix<int>& triangle1, Matrix<double>& bary1, Matrix<double>& bary2, Matrix<int>& origin1) { LOG("Mesh M=" << M << endl); LOG("Mesh M.TT=" << M.TT() << endl); LOG("Split line segments into subsegments on triangles." << endl); LOG("Point size: " << loc0.rows() << ", " << loc0.cols() << endl); LOG("Index size: " << idx0.rows() << ", " << idx0.cols() << endl); Matrix<int>* loc_in_tri = new Matrix<int>(loc0.rows(), 1); Matrix<double>* bary_in_tri = new Matrix<double>(loc0.rows(), 3); DartList dart_trace; map_points_to_mesh(M, loc0, *loc_in_tri, *bary_in_tri); /* Initialize output structures. */ loc1.rows(0); idx1.rows(0); triangle1.rows(0); bary1.rows(0); bary2.rows(0); origin1.rows(0); int i_loc_curr = -1; int i_idx_curr = -1; LOG("Number of lines to split: " << idx0.rows() << std::endl); for (size_t i=0; i < idx0.rows(); ++i) { LOG("Split line nr " << i << ": (" << idx0[i][0] << ", " << idx0[i][1] << ")" << std::endl); Dart d(M, (*loc_in_tri)[idx0[i][0]][0]); Point s0(loc0[idx0[i][0]]); Point s1(loc0[idx0[i][1]]); LOG("Tracing path between points" << std::endl); LOG("s0=" << s0 << std::endl); LOG("s1=" << s1 << std::endl); LOG("Starting dart " << d << endl); dart_trace.clear(); DartPair endpoints(M.trace_path(s0, s1, d, &dart_trace)); LOG("Trace:" << endl << dart_trace << std::endl) Point b1; Point b2; Point s_curr(s0); Point s_next(s0); /* Initialise the first sub-segment */ /* Add the first point */ ++i_loc_curr; for (size_t di=0; di<3; di++) { loc1(i_loc_curr,di) = s_next[di]; } /* Middle sub-segments */ for (DartList::const_iterator dti(dart_trace.begin()); dti != dart_trace.end(); ++dti) { LOG("Making middle subsegment, split on" << endl << " " << *dti << std::endl); s_curr = s_next; LOG("Line to split:" << endl << " " << s_curr << endl << " " << s1 << endl); LOG("Edge to split on:" << endl << " " << M.S((*dti).v()) << endl << " " << M.S((*dti).vo()) << endl); M.edgeIntersection(s_curr, s1, M.S((*dti).v()), M.S((*dti).vo()), s_next); LOG("Split result = " << s_next << endl); M.barycentric(*dti, s_curr, b1); M.barycentric(*dti, s_next, b2); // ++i_idx_curr; idx1(i_idx_curr, 0) = i_loc_curr; ++i_loc_curr; idx1(i_idx_curr, 1) = i_loc_curr; for (size_t di=0; di<3; di++) { loc1(i_loc_curr, di) = s_next[di]; bary1(i_idx_curr, di) = b1[di]; bary2(i_idx_curr, di) = b2[di]; } origin1(i_idx_curr, 0) = i; triangle1(i_idx_curr, 0) = (*dti).t(); } /* Final sub-segment, or both points in the same triangle */ if (!endpoints.second.isnull()) { LOG("Making final subsegment." << std::endl); s_curr = s_next; s_next = s1; if (dart_trace.size() == 0) { LOG("Staying in initial triangle." << std::endl); M.barycentric(endpoints.first, s_curr, b1); M.barycentric(endpoints.first, s_next, b2); } else { LOG("Moving to final triangle." << std::endl); M.barycentric(endpoints.second, s_curr, b1); M.barycentric(endpoints.second, s_next, b2); } // ++i_idx_curr; idx1(i_idx_curr, 0) = i_loc_curr; ++i_loc_curr; idx1(i_idx_curr, 1) = i_loc_curr; for (size_t di=0; di<3; di++) { loc1(i_loc_curr, di) = s_next[di]; bary1(i_idx_curr, di) = b1[di]; bary2(i_idx_curr, di) = b2[di]; } origin1(i_idx_curr, 0) = i; triangle1(i_idx_curr, 0) = endpoints.second.t(); } } delete bary_in_tri; delete loc_in_tri; LOG("Done." << endl); } int main(int argc, char* argv[]) { gengetopt_args_info args_info; struct cmdline_params params; LOG("checkpoint 1." << std::endl); cmdline_init(&args_info); cmdline_params_init(&params); LOG("checkpoint 2." << std::endl); /* call the command line parser */ if (cmdline_ext(argc, argv, &args_info, &params) != 0) { cmdline_free(&args_info); return 1; } LOG("checkpoint 3." << std::endl); /* Read an optional config file, but don't override given options */ if (args_info.config_given) { params.initialize = 0; params.override = 0; /* Call the config file parser */ if (cmdline_config_file(args_info.config_arg, &args_info, &params) != 0) { cmdline_free(&args_info); return 1; } } LOG("checkpoint 4." << std::endl); if (args_info.dump_config_given) cmdline_dump(stdout,&args_info); std::vector<string> input_s0_names; string input_tv0_name = "-"; LOG("checkpoint 5." << std::endl); if (args_info.input_given>0) input_s0_names.push_back(string(args_info.input_arg[0])); if (args_info.input_given>1) input_tv0_name = string(args_info.input_arg[1]); for (size_t i=2; i < args_info.input_given; i++) { input_s0_names.push_back(string(args_info.input_arg[i])); } LOG("checkpoint 6." << std::endl); std::vector<string> quality_names; for (size_t i=0; i < args_info.quality_given; i++) { quality_names.push_back(string(args_info.quality_arg[i])); } LOG("checkpoint 7." << std::endl); std::vector<string> boundary_names; std::vector<string> boundarygrp_names; for (size_t i=0; i < args_info.boundary_given; i++) { boundary_names.push_back(string(args_info.boundary_arg[i])); if (i<args_info.boundarygrp_given) boundarygrp_names.push_back(string(args_info.boundarygrp_arg[i])); else boundarygrp_names.push_back(boundary_names[i]+"grp"); } LOG("checkpoint 8." << std::endl); std::vector<string> interior_names; std::vector<string> interiorgrp_names; for (size_t i=0; i < args_info.interior_given; i++) { interior_names.push_back(string(args_info.interior_arg[i])); if (i<args_info.interiorgrp_given) interiorgrp_names.push_back(string(args_info.interiorgrp_arg[i])); else interiorgrp_names.push_back(interior_names[i]+"grp"); } LOG("checkpoint 9." << std::endl); std::vector<string> aniso_names; for (size_t i=0; i < args_info.aniso_given; i++) { aniso_names.push_back(string(args_info.aniso_arg[i])); } std::vector<string> splitlines_names; for (size_t i=0; i < args_info.splitlines_given; i++) { splitlines_names.push_back(string(args_info.splitlines_arg[i])); } double cutoff = 1.0e-12; if (args_info.cutoff_given>0) cutoff = args_info.cutoff_arg; double sphere_tolerance = 1.0e-7; if (args_info.spheretolerance_given>0) sphere_tolerance = args_info.spheretolerance_arg; int cet_sides = 8; double cet_margin = -0.1; if (args_info.cet_given>0) cet_sides = args_info.cet_arg[0]; if (args_info.cet_given>1) cet_margin = args_info.cet_arg[1]; double rcdt_min_angle = 21; double rcdt_big_limit_auto_default = -1.0; Matrix<double> rcdt_big_limit_defaults; rcdt_big_limit_defaults(0,0) = -0.5; for (size_t i=1; (i+2 < args_info.input_given); i++) { rcdt_big_limit_defaults(i,0) = -0.5; } if ((args_info.rcdt_given>0) && (args_info.rcdt_arg[0] != 0)) rcdt_min_angle = args_info.rcdt_arg[0]; if (args_info.rcdt_given>1) rcdt_big_limit_auto_default = args_info.rcdt_arg[1]; for (size_t i=0; (i+2 < args_info.rcdt_given); i++) { rcdt_big_limit_defaults(i,0) = args_info.rcdt_arg[i+2]; } int rcdt_max_n0 = -1; int rcdt_max_n1 = -1; if (args_info.max_n0_given > 0) rcdt_max_n0 = args_info.max_n0_arg; if (args_info.max_n1_given > 0) rcdt_max_n1 = args_info.max_n1_arg; useX11 = (args_info.x11_given>0) && (args_info.x11_arg>=0); x11_delay_factor = args_info.x11_arg; if (args_info.x11_zoom_given==4) { for (size_t i=0; i<4; i++) x11_zoom[i] = args_info.x11_zoom_arg[i]; } else if (args_info.x11_zoom_given==3) { double xmid = args_info.x11_zoom_arg[0]; double ymid = args_info.x11_zoom_arg[1]; double margin = args_info.x11_zoom_arg[2]; x11_zoom[0] = xmid-margin; x11_zoom[1] = xmid+margin; x11_zoom[2] = ymid-margin; x11_zoom[3] = ymid+margin; } /* cout << "CET given:\t" << args_info.cet_given << endl; cout << "RCDT given:\t" << args_info.rcdt_given << " " << args_info.rcdt_min << " " << args_info.rcdt_max << " " << args_info.rcdt_arg[0] << " " << endl; if (args_info.boundary_given) { cout << "Boundary given:\t" << args_info.boundary_given << " " << args_info.boundary_arg << " " << &(args_info.boundary_arg[0]) << " " // << string(args_info.boundary_arg[0]) << " " << endl; } cout << "X11 given:\t" << args_info.x11_given << " " << args_info.x11_arg << " " << endl; cout << "CET sides:\t" << cet_sides << endl; cout << "CET margin:\t" << cet_margin << endl; cout << "RCDT mininmum angle:\t" << rcdt_min_angle << endl; cout << "RCDT maximum edge length:\t" << rcdt_big_limit << endl; cout << "RCDT maximum edge lengths:\t" << rcdt_big_limits << endl; cout << "RCDT maximum n0:\t" << rcdt_max_n0 << endl; cout << "RCDT maximum n1:\t" << rcdt_max_n1 << endl; cout << "X11 delay factor:\t" << x11_delay_factor << endl; */ LOG("IOprefix init." << std::endl); string iprefix("-"); string oprefix("-"); if (args_info.inputs_num>0) { iprefix = string(args_info.inputs[0]); } if (iprefix != "-") { oprefix = iprefix; } if (args_info.inputs_num>1) { oprefix = string(args_info.inputs[1]); } if ((iprefix=="-") && (args_info.ic_given==0)) { /* Nowhere to read general input! May be OK, if the input is available in raw format. */ if (args_info.ir_given==0) { /* No input available. May be OK. */ } } if ((oprefix=="-") && (args_info.oc_given==0)) { /* Nowhere to place output! OK; might just want to see the algorithm at work with --x11. */ } LOG("matrix IO init." << std::endl); matrices.io(((args_info.io_arg == io_arg_ba) || (args_info.io_arg == io_arg_bb)), ((args_info.io_arg == io_arg_ab) || (args_info.io_arg == io_arg_bb))); matrices.input_prefix(iprefix); matrices.output_prefix(oprefix); for (size_t i=0; i<args_info.ic_given; ++i) { matrices.input_file(string(args_info.ic_arg[i])); } if (args_info.oc_given>0) { matrices.output_file(string(args_info.oc_arg)); } for (size_t i=0; i+2<args_info.ir_given; i=i+3) { matrices.input_raw(string(args_info.ir_arg[i]), string(args_info.ir_arg[i+1]), string(args_info.ir_arg[i+2])); } LOG("matrix IO inited." << std::endl); for (size_t i=0; i<input_s0_names.size(); i++) { if (!matrices.load(input_s0_names[i]).active) { cout << "Matrix "+input_s0_names[i]+" not found." << endl; } } LOG("s0 input read." << std::endl); if ((args_info.globe_given>0) && (args_info.globe_arg>0)) { input_s0_names.push_back(string(".globe")); matrices.attach(".globe", (Matrix<double>*)fmesh::make_globe_points(args_info.globe_arg), true); LOG("globe points added." << std::endl); } for (size_t i=0; i<quality_names.size(); i++) { if (quality_names[i] != "-") if (!matrices.load(quality_names[i]).active) { cout << "Matrix "+quality_names[i]+" not found." << endl; quality_names[i] = "-"; } } LOG("quality input read." << std::endl); LOG("iS0" << std::endl); if (input_s0_names.size()==0) { input_s0_names.push_back(string("s0")); matrices.attach(string("s0"), new Matrix<double>(3), true); } Matrix<double>& iS0 = matrices.DD(input_s0_names[0]); Matrix<double>* Quality0_ = new Matrix<double>(); Matrix<double>& Quality0 = *Quality0_; /* Join the location matrices */ for (size_t i=0; i < input_s0_names.size(); i++) { Matrix<double>& S0_extra = matrices.DD(input_s0_names[i]); if (i>0) /* i=0 is already taken care of above. */ iS0.append(S0_extra); if ((i < quality_names.size()) && (quality_names[i] != "-")) { int rows = S0_extra.rows(); Matrix<double>& quality_extra = matrices.DD(quality_names[i]); if (i<rcdt_big_limit_defaults.rows()) for (int r=quality_extra.rows(); r<rows; r++) quality_extra(r,0) = rcdt_big_limit_defaults[i][0]; else for (int r=quality_extra.rows(); r<rows; r++) quality_extra(r,0) = rcdt_big_limit_defaults[0][0]; quality_extra.rows(rows); /* Make sure we have the right number of rows */ Quality0.append(quality_extra); } else if (i<size_t(rcdt_big_limit_defaults.rows())) { int rows = S0_extra.rows(); Matrix<double> quality_extra(rows,1); for (int r=0; r<rows; r++) quality_extra(r,0) = rcdt_big_limit_defaults[i][0]; Quality0.append(quality_extra); } else { int rows = S0_extra.rows(); Matrix<double> quality_extra(rows,1); for (int r=0; r<rows; r++) quality_extra(r,0) = rcdt_big_limit_defaults[0][0]; Quality0.append(quality_extra); } } /* OK to overwrite any old quality0 */ matrices.attach(string("quality0"),Quality0_,true); LOG("TV0" << std::endl); Matrix<int>* TV0 = NULL; if (input_tv0_name != "-") { if (!matrices.load(input_tv0_name).active) { cout << "Matrix "+input_tv0_name+" not found." << endl; } else { TV0 = &(matrices.DI(input_tv0_name)); } } for (size_t i=0; i<boundary_names.size(); i++) { if (!matrices.load(boundary_names[i]).active) { cout << "Matrix "+boundary_names[i]+" not found." << endl; } if (!matrices.load(boundarygrp_names[i]).active) { // cout << "Matrix "+boundarygrp_names[i]+" not found. Creating." << endl; matrices.attach(boundarygrp_names[i],new Matrix<int>(1),true); matrices.DI(boundarygrp_names[i])(0,0) = i+1; } } for (size_t i=0; i<interior_names.size(); i++) { if (!matrices.load(interior_names[i]).active) { cout << "Matrix "+interior_names[i]+" not found." << endl; } if (!matrices.load(interiorgrp_names[i]).active) { cout << "Matrix "+interiorgrp_names[i]+" not found. Creating." << endl; matrices.attach(interiorgrp_names[i],new Matrix<int>(1),true); matrices.DI(interiorgrp_names[i])(0,0) = i+1; } } for (size_t i=0; i<aniso_names.size(); i++) { if (!matrices.load(aniso_names[i]).active) { cout << "Matrix "+aniso_names[i]+" not found." << endl; } } for (size_t i=0; i<splitlines_names.size(); i++) { if (!matrices.load(splitlines_names[i]).active) { cout << "Matrix "+splitlines_names[i]+" not found." << endl; } } constrListT cdt_boundary; for (size_t i=0; i<boundary_names.size(); i++) { Matrix<int>& boundary0 = matrices.DI(boundary_names[i]); Matrix<int>& boundarygrp = matrices.DI(boundarygrp_names[i]); prepare_cdt_input(boundary0,boundarygrp,cdt_boundary); } constrListT cdt_interior; for (size_t i=0; i<interior_names.size(); i++) { Matrix<int>& interior0 = matrices.DI(interior_names[i]); Matrix<int>& interiorgrp = matrices.DI(interiorgrp_names[i]); prepare_cdt_input(interior0,interiorgrp,cdt_interior); } /* Prepare to filter out points at distance not greater than 'cutoff' */ matrices.attach("idx", new Matrix<int>(iS0.rows(),1), true); matrices.output("idx"); Matrix<int>& idx = matrices.DI("idx").clear(); /* Only filter if "smorg" option inactive */ if (args_info.smorg_given==0) { filter_locations(iS0, idx, cutoff); /* Remap vertex inputreferences */ if (TV0) remap_vertex_indices(idx, *TV0); remap_vertex_indices(idx, cdt_boundary); remap_vertex_indices(idx, cdt_interior); } else { for (size_t v=0; v < iS0.rows(); v++) { idx(v,0) = v; } } Mesh M(Mesh::Mtype_plane,0,useVT,useTTi); LOG("checkpoint 10." << std::endl); bool issphere = false; bool isflat = false; if ((iS0.rows()>0) && (iS0.cols()<2)) { /* 1D data. Not implemented */ LOG_("1D data not implemented." << std::endl); return 0; } else if (iS0.rows()>0) { Matrix3double S0(iS0); /* Make sure we have a Nx3 matrix. */ M.S_append(S0); size_t nV = iS0.rows(); isflat = (std::abs(M.S(0)[2]) < 1.0e-10); double radius = M.S(0).length(); issphere = true; for (size_t i=1; i<M.nV(); i++) { isflat = (isflat && (std::abs(M.S(i)[2]) < 1.0e-10)); issphere = (issphere && (std::abs(M.S(i).length()-radius) < sphere_tolerance)); } if (!isflat) { if (issphere) { M.type(Mesh::Mtype_sphere); } else { M.type(Mesh::Mtype_manifold); } } M.setX11VBigLimit(M.nV()); if (TV0) { M.TV_set(*TV0); } matrices.attach(string("s"),&M.S(),false); matrices.attach("tv",&M.TV(),false); matrices.output("s").output("tv"); Point mini(M.S(0)); Point maxi(M.S(0)); for (size_t v=1; v<M.nV(); v++) for (size_t i=0; i<3; i++) { mini[i] = (M.S(v)[i] < mini[i] ? M.S(v)[i] : mini[i]); maxi[i] = (M.S(v)[i] > maxi[i] ? M.S(v)[i] : maxi[i]); } Point sz; fmesh::Vec::diff(sz,maxi,mini); /* double diam; diam = (sz[1] < sz[0] ? (sz[2] < sz[0] ? sz[0] : sz[2]) : (sz[2] < sz[1] ? sz[1] : sz[2])); */ if (useX11) { if (issphere) { if (args_info.x11_zoom_given==0) { x11_zoom[0] = -1.1; x11_zoom[1] = 1.1; x11_zoom[2] = -1.1; x11_zoom[3] = 1.1; } M.useX11(true,useX11text,500,500, x11_zoom[0],x11_zoom[1],x11_zoom[2],x11_zoom[3]); } else { double w0 = maxi[0]-mini[0]; double w1 = maxi[1]-mini[1]; double w = (w0 > w1 ? w0 : w1); if (args_info.x11_zoom_given==0) { x11_zoom[0] = mini[0]-w*0.2; x11_zoom[1] = maxi[0]+w*0.2; x11_zoom[2] = mini[1]-w*0.2; x11_zoom[3] = maxi[1]+w*0.2; } M.useX11(true,useX11text,500,500, x11_zoom[0],x11_zoom[1],x11_zoom[2],x11_zoom[3]); } M.setX11delay(x11_delay_factor/M.nV()); } if (args_info.smorg_given>0) { LOG("Calculating smorg output." << std::endl) MeshC MC(&M); MC.setOptions(MC.getOptions()|MeshC::Option_offcenter_steiner); /* Calculate and collect output. */ matrices.attach("segm.bnd.idx",new Matrix<int>(2), true,fmesh::IOMatrixtype_general); matrices.attach("segm.bnd.grp",new Matrix<int>(1), true,fmesh::IOMatrixtype_general); MC.segments(true, &matrices.DI("segm.bnd.idx"), &matrices.DI("segm.bnd.grp")); matrices.output("segm.bnd.idx").output("segm.bnd.grp"); matrices.attach("segm.int.idx",new Matrix<int>(2), true,fmesh::IOMatrixtype_general); matrices.attach("segm.int.grp",new Matrix<int>(1), true,fmesh::IOMatrixtype_general); MC.segments(false, &matrices.DI("segm.int.idx"), &matrices.DI("segm.int.grp")); matrices.output("segm.int.idx").output("segm.int.grp"); } else { /* Not smorg. Build mesh. */ MeshC MC(&M); MC.setOptions(MC.getOptions()|MeshC::Option_offcenter_steiner); if (!isflat && !issphere) { if (M.nT()==0) { LOG_("Points not in the plane or on a sphere, and triangulation empty." << std::endl); } /* Remove everything outside the boundary segments, if any. */ MC.PruneExterior(); invalidate_unused_vertex_indices(M, idx); /* Nothing more to do here. Cannot refine non R2/S2 meshes. */ } else { /* If we don't already have a triangulation, we must create one. */ if (M.nT()==0) { MC.CET(cet_sides,cet_margin); } /* It is more robust to add the constraints before the rest of the nodes are added. This allows points to fall onto constraint segments, subdividing them as needed. */ if (cdt_boundary.size()>0) MC.CDTBoundary(cdt_boundary); if (cdt_interior.size()>0) MC.CDTInterior(cdt_interior); /* Add the rest of the nodes. */ vertexListT vertices; for (size_t v=0;v<nV;v++) vertices.push_back(v); MC.DT(vertices); /* Remove everything outside the boundary segments, if any. */ MC.PruneExterior(); invalidate_unused_vertex_indices(M, idx); if (args_info.rcdt_given) { /* Calculate the RCDT: */ MC.RCDT(rcdt_min_angle,rcdt_big_limit_auto_default, Quality0.raw(),Quality0.rows(), rcdt_max_n0, rcdt_max_n1); LOG(MC << endl); } /* Done constructing the triangulation. */ } /* Calculate and collect output. */ matrices.attach("segm.bnd.idx",new Matrix<int>(2), true,fmesh::IOMatrixtype_general); matrices.attach("segm.bnd.grp",new Matrix<int>(1), true,fmesh::IOMatrixtype_general); MC.segments(true, &matrices.DI("segm.bnd.idx"), &matrices.DI("segm.bnd.grp")); matrices.output("segm.bnd.idx").output("segm.bnd.grp"); matrices.attach("segm.int.idx",new Matrix<int>(2), true,fmesh::IOMatrixtype_general); matrices.attach("segm.int.grp",new Matrix<int>(1), true,fmesh::IOMatrixtype_general); MC.segments(false, &matrices.DI("segm.int.idx"), &matrices.DI("segm.int.grp")); matrices.output("segm.int.idx").output("segm.int.grp"); } matrices.attach("tt",&M.TT(),false); M.useVT(true); matrices.attach("vt",&M.VT(),false); M.useTTi(true); matrices.attach("tti",&M.TTi(),false); matrices.attach("vv",new SparseMatrix<int>(M.VV()), true,fmesh::IOMatrixtype_symmetric); matrices.output("tt").output("tti").output("vt").output("vv"); } LOG("Manifold output." << std::endl) /* Output the manifold type. */ matrices.attach("manifold", new Matrix<int>(1), true, fmesh::IOMatrixtype_general); Matrix<int>& manifold = matrices.DI("manifold"); manifold(0,0) = M.type(); matrices.output("manifold"); if (issphere) { LOG("issphere output." << std::endl) int sph0_order_max = args_info.sph0_arg; int sph_order_max = args_info.sph_arg; if (sph0_order_max >= 0) { LOG("sph0 output." << std::endl) matrices.attach(string("sph0"), new Matrix<double>(spherical_harmonics(M.S(), sph0_order_max, true)), true); matrices.matrixtype("sph0",fmesh::IOMatrixtype_general); matrices.output("sph0"); } if (sph_order_max >= 0) { LOG("sph output." << std::endl) matrices.attach(string("sph"), new Matrix<double>(spherical_harmonics(M.S(), sph_order_max, false)), true); matrices.matrixtype("sph",fmesh::IOMatrixtype_general); matrices.output("sph"); } if (args_info.bspline_given>0) { LOG("bspline output." << std::endl) int bspline_n = 2; int bspline_degree = 1; bool bspline_uniform_knot_angles = true; if (args_info.bspline_given>0) bspline_n = args_info.bspline_arg[0]; if (args_info.bspline_given>1) bspline_degree = args_info.bspline_arg[1]; if (args_info.bspline_given>2) bspline_uniform_knot_angles = (args_info.bspline_arg[2]>0); matrices.attach(string("bspline"), new Matrix<double>(spherical_bsplines(M.S(), bspline_n, bspline_degree, bspline_uniform_knot_angles)), true); matrices.matrixtype("bspline",fmesh::IOMatrixtype_general); matrices.output("bspline"); } } if (args_info.points2mesh_given>0) { LOG("points2mesh output." << std::endl); if (!isflat && !issphere) { LOG_("Cannot calculate points2mesh mapping for non R2/S2 manifolds" << std::endl); } else { string points2mesh_name(args_info.points2mesh_arg); if (!matrices.load(points2mesh_name).active) { cout << "Matrix "+points2mesh_name+" not found." << std::endl; } Matrix<double>& points2mesh = matrices.DD(points2mesh_name); size_t points_n = points2mesh.rows(); Matrix<int>& points2mesh_t = matrices.attach(string("p2m.t"), new Matrix<int>(points_n,1), true); Matrix<double>& points2mesh_b = matrices.attach(string("p2m.b"), new Matrix<double>(points_n,3), true); matrices.matrixtype("p2m.t",fmesh::IOMatrixtype_general); matrices.matrixtype("p2m.b",fmesh::IOMatrixtype_general); matrices.output("p2m.t").output("p2m.b"); map_points_to_mesh(M,points2mesh,points2mesh_t,points2mesh_b); } } int fem_order_max = args_info.fem_arg; if (fem_order_max>=0) { LOG("fem output." << std::endl) SparseMatrix<double>& C0 = matrices.SD("c0").clear(); SparseMatrix<double>& C1 = matrices.SD("c1").clear(); SparseMatrix<double>& B1 = matrices.SD("b1").clear(); SparseMatrix<double>& G = matrices.SD("g1").clear(); SparseMatrix<double>& K = matrices.SD("k1").clear(); /* K1=G1-B1, K2=K1*inv(C0)*K1, ... */ Matrix<double>& Tareas = matrices.DD("ta").clear(); M.calcQblocks(C0,C1,G,B1,Tareas); matrices.attach(string("va"),new Matrix<double>(diag(C0)),true); K = G-B1; matrices.matrixtype("c0",fmesh::IOMatrixtype_diagonal); matrices.matrixtype("c1",fmesh::IOMatrixtype_symmetric); matrices.matrixtype("b1",fmesh::IOMatrixtype_general); matrices.matrixtype("g1",fmesh::IOMatrixtype_symmetric); matrices.matrixtype("k1",fmesh::IOMatrixtype_general); matrices.output("c0"); matrices.output("c1"); matrices.output("b1"); matrices.output("g1"); matrices.output("k1"); matrices.output("va"); matrices.output("ta"); SparseMatrix<double> C0inv = inverse(C0,true); SparseMatrix<double> tmp = G*C0inv; SparseMatrix<double>* a; SparseMatrix<double>* b = &G; for (size_t i=1; int(i) < fem_order_max; i++) { std::stringstream ss; ss << i+1; std::string Gname = "g"+ss.str(); a = b; b = &(matrices.SD(Gname).clear()); *b = tmp*(*a); matrices.matrixtype(Gname,fmesh::IOMatrixtype_symmetric); matrices.output(Gname); } tmp = C0inv*K; b = &K; for (size_t i=1; int(i) < fem_order_max; i++) { std::stringstream ss; ss << i+1; std::string Kname = "k"+ss.str(); a = b; b = &(matrices.SD(Kname).clear()); *b = (*a)*tmp; matrices.matrixtype(Kname,fmesh::IOMatrixtype_general); matrices.output(Kname); } if (aniso_names.size()>0) { SparseMatrix<double>& Gani = matrices.SD("g1aniso").clear(); M.calcQblocksAni(Gani, matrices.DD(aniso_names[0]), matrices.DD(aniso_names[1])); matrices.output("g1aniso"); SparseMatrix<double> tmp = Gani*C0inv; SparseMatrix<double>* a; SparseMatrix<double>* b = &Gani; for (size_t i=1; int(i) < fem_order_max; i++) { std::stringstream ss; ss << i+1; std::string Gname = "g"+ss.str()+"aniso"; a = b; b = &(matrices.SD(Gname).clear()); *b = tmp*(*a); matrices.matrixtype(Gname,fmesh::IOMatrixtype_symmetric); matrices.output(Gname); } } } if (args_info.grad_given>0) { SparseMatrix<double>* D[3]; M.calcGradientMatrices(D); matrices.attach("dx", D[0], true); matrices.attach("dy", D[1], true); matrices.attach("dz", D[2], true); matrices.matrixtype("dx",fmesh::IOMatrixtype_general); matrices.matrixtype("dy",fmesh::IOMatrixtype_general); matrices.matrixtype("dz",fmesh::IOMatrixtype_general); matrices.output("dx").output("dy").output("dz"); } if (splitlines_names.size()>0) { Matrix<double>& splitlocinput_raw = matrices.DD(splitlines_names[0]); /* Make sure we have a Nx3 matrix. */ Matrix3double splitlocinput(splitlocinput_raw); Matrix<double>* splitloc1 = new Matrix<double>(3); Matrix<int>* splitidx1 = new Matrix<int>(1); Matrix<int>* splittriangle1 = new Matrix<int>(1); Matrix<double>* splitbary1 = new Matrix<double>(3); Matrix<double>* splitbary2 = new Matrix<double>(3); Matrix<int>* splitorigin1 = new Matrix<int>(1); split_line_segments_on_triangles(M, splitlocinput, matrices.DI(splitlines_names[1]), *splitloc1, *splitidx1, *splittriangle1, *splitbary1, *splitbary2, *splitorigin1); /* Now it's ok to overwrite potential input split* matrices. */ matrices.attach("split.loc", splitloc1, true); matrices.attach("split.idx", splitidx1, true); matrices.attach("split.t", splittriangle1, true); matrices.attach("split.b1", splitbary1, true); matrices.attach("split.b2", splitbary2, true); matrices.attach("split.origin", splitorigin1, true); matrices.output("split.loc").output("split.idx"); matrices.output("split.b1").output("split.b2"); matrices.output("split.t").output("split.origin"); } for (size_t i=0; i<args_info.collect_given; i++) { string matrix_name = string(args_info.collect_arg[i]); if (!(matrix_name=="-") & !(matrix_name=="--")) { if (!matrices.activate(matrix_name)) { if (!matrices.load(matrix_name).active) { cout << "Matrix "+matrix_name+" not found." << endl; } else { cout << "Matrix "+matrix_name+" activated." << endl; } } else { cout << "Matrix "+matrix_name+" active." << endl; } } matrices.output(matrix_name); } matrices.save(); cmdline_free(&args_info); return 0; }
[ "haavard.rue@kaust.edu.sa" ]
haavard.rue@kaust.edu.sa
ebd1ec027f1e9ad3d475b402ba510716fada62ce
f1d5880d80f720b238cb0427a8700df032a8ac2e
/gas_meter1.ino
dfc97b94556f5d041c966adef28f825d4b2aa166
[]
no_license
xriser/gas_meter
e39fcba0fb7f0c37679f9b970334e8efc5073245
b97403e22f42cdb00f892447f1ebbfb1c2cddf86
refs/heads/master
2020-12-30T15:42:17.894196
2017-05-17T14:51:06
2017-05-17T14:51:06
91,166,925
1
0
null
null
null
null
UTF-8
C++
false
false
3,647
ino
extern "C" { #include "user_interface.h" } // Include the libraries we need #include <OneWire.h> #include <ESP8266WiFi.h> #include <ESP8266HTTPClient.h> #include <DallasTemperature.h> const char *INFLUXDB_HOST = "host"; const uint16_t INFLUXDB_PORT = 8086; const char *DATABASE = "db"; const char *DB_USER = ""; const char *DB_PASSWORD = ""; #define ONE_WIRE_BUS 4 // Data wire is plugged into port 2 on the Arduino OneWire oneWire(ONE_WIRE_BUS); // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) DallasTemperature sensors(&oneWire); // Pass our oneWire reference to Dallas Temperature. DeviceAddress insideThermometer = {0x28, 0xFA, 0xAB, 0x8C, 0x06, 0x00, 0x00, 0xFA}; int Led = 15; // Definition LED Interface int SENSOR = 2; // Define the Hall magnetic sensor interface int val;// Defines a numeric variable val int hall_state = 0; int count = 0; #define GLED 13 #define GLED_ON digitalWrite(GLED, 1) #define GLED_OFF digitalWrite(GLED, 0) const char* ssid = "ssid"; const char* password = "pass"; WiFiServer server(80); void setup() { pinMode(GLED, OUTPUT); pinMode(Led, OUTPUT); // Definition LED as output interface pinMode(SENSOR, INPUT); // Defined the Hall magnetic sensor as output interface sensors.setResolution(insideThermometer, 11); // start serial port Serial.begin(115200); Serial.printf("Connecting to %s ", ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(" connected"); Serial.println(WiFi.localIP()); // Start the server server.begin(); Serial.println("Server started"); // Print the IP address Serial.println(WiFi.localIP()); } void loop() { count++; if (count >= 2) { GLED_OFF; } sensors.requestTemperatures(); // Send the command to get temperatures // We use the function ByIndex, and as an example get the temperature from the first sensor only. Serial.println("Temperature for the device 1 (index 0) is: "); float tempC = sensors.getTempCByIndex(0); Serial.print("Temp C: "); Serial.println(tempC); val = digitalRead(SENSOR); // The digital interface is assigned a value of 3 to read val if ((val == LOW) and (hall_state == 0)) // When the Hall sensor detects a signal , flash led and send data { hall_state = 1; digitalWrite(Led, HIGH); Serial.println("Detect state change to LOW"); //send data here HTTPClient http; //Declare object of class HTTPClient http.begin("http://" + String(INFLUXDB_HOST) + ":" + String(INFLUXDB_PORT) + "/write?db=" + String(DATABASE)); //Specify request destination http.addHeader("Content-Type", "text/plain"); //Specify content-type header int httpCode = http.POST("gas,host=home,region=ua value=1"); //Send the request String payload = http.getString(); //Get the response payload Serial.println(httpCode); //Print HTTP return code Serial.println(payload); //Print request response payload http.end(); //Close connection } if ((val == HIGH) and (hall_state == 1)) //When Hall sensor release signal { digitalWrite(Led, LOW); hall_state = 0; } WiFiClient client = server.available(); String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\n "; s += "temp: "; s += tempC; s += "C</html>\n"; // Send the response to the client client.print(s); Serial.println(); Serial.println(count); if (count > 10) { GLED_ON; Serial.println("GLED ON"); count = 0; } delay(1000); }
[ "noreply@github.com" ]
noreply@github.com
17bbbfa155477d952eb52c89ec515a5c95273ac2
2ef0b5ace4e77b3fbfb7ca75eef3aef4decb5013
/remoting/host/mac/host_service_main.cc
61ea34e5deb7c1eaec18eb948d07486b87407c0c
[ "BSD-3-Clause" ]
permissive
davgit/chromium
309fb3749c1f9dcc24d38993fb69623c2d3235bf
f98299a83f66926792ef5f127a3f451325817df6
refs/heads/master
2022-12-27T21:13:08.716205
2019-10-23T15:14:07
2019-10-23T15:14:07
217,097,003
1
0
BSD-3-Clause
2019-10-23T15:55:35
2019-10-23T15:55:34
null
UTF-8
C++
false
false
12,454
cc
// Copyright 2019 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <signal.h> #include <unistd.h> #include <iostream> #include <string> #include "base/at_exit.h" #include "base/bind.h" #include "base/command_line.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/logging.h" #include "base/mac/mac_util.h" #include "base/no_destructor.h" #include "base/path_service.h" #include "base/process/launch.h" #include "base/process/process.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringize_macros.h" #include "base/threading/platform_thread.h" #include "base/time/time.h" #include "remoting/base/logging.h" #include "remoting/host/host_exit_codes.h" #include "remoting/host/logging.h" #include "remoting/host/mac/constants_mac.h" #include "remoting/host/username.h" using namespace remoting; namespace remoting { namespace { constexpr char kSwitchDisable[] = "disable"; constexpr char kSwitchEnable[] = "enable"; constexpr char kSwitchSaveConfig[] = "save-config"; constexpr char kSwitchHostVersion[] = "host-version"; constexpr char kSwitchHostRunFromLaunchd[] = "run-from-launchd"; constexpr char kHostExeFileName[] = "remoting_me2me_host"; // The exit code returned by 'wait' when a process is terminated by SIGTERM. constexpr int kSigtermExitCode = 128 + SIGTERM; // Constants controlling the host process relaunch throttling. constexpr base::TimeDelta kMinimumRelaunchInterval = base::TimeDelta::FromMinutes(1); constexpr int kMaximumHostFailures = 10; // Exit code 126 is defined by Posix to mean "Command found, but not // executable", and is returned if the process cannot be launched due to // parental control. constexpr int kPermissionDeniedParentalControl = 126; // This executable works as a proxy between launchd and the host. Signals of // interest to the host must be forwarded. constexpr int kSignalList[] = { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGABRT, SIGEMT, SIGFPE, SIGBUS, SIGSEGV, SIGSYS, SIGPIPE, SIGALRM, SIGTERM, SIGURG, SIGTSTP, SIGCONT, SIGTTIN, SIGTTOU, SIGIO, SIGXCPU, SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH, SIGINFO, SIGUSR1, SIGUSR2}; // Current host PID used to forward signals. 0 if host is not running. static base::ProcessId g_host_pid = 0; void HandleSignal(int signum) { if (g_host_pid) { // All other signals are forwarded to host then ignored except SIGTERM. // launchd sends SIGTERM when service is being stopped so both the host and // the host service need to terminate. HOST_LOG << "Forwarding signal " << signum << " to host process " << g_host_pid; kill(g_host_pid, signum); if (signum == SIGTERM) { HOST_LOG << "Host service is terminating upon reception of SIGTERM"; exit(kSigtermExitCode); } } else { HOST_LOG << "Signal " << signum << " will not be forwarded since host is not running."; exit(128 + signum); } } void RegisterSignalHandler() { struct sigaction action = {}; sigfillset(&action.sa_mask); action.sa_flags = 0; action.sa_handler = &HandleSignal; for (int signum : kSignalList) { if (sigaction(signum, &action, nullptr) == -1) { PLOG(DFATAL) << "Failed to register signal handler for signal " << signum; } } } class HostService { public: HostService(); ~HostService(); bool Disable(); bool Enable(); bool WriteStdinToConfig(); int RunHost(); void PrintHostVersion(); void PrintPid(); private: int RunHostFromOldScript(); base::FilePath old_host_helper_file_; base::FilePath enabled_file_; base::FilePath config_file_; base::FilePath host_exe_file_; }; HostService::HostService() { old_host_helper_file_ = base::FilePath(kOldHostHelperScriptPath); enabled_file_ = base::FilePath(kHostEnabledPath); config_file_ = base::FilePath(kHostConfigFilePath); base::FilePath host_service_dir; base::PathService::Get(base::DIR_EXE, &host_service_dir); host_exe_file_ = host_service_dir.AppendASCII(kHostExeFileName); } HostService::~HostService() = default; int HostService::RunHost() { // Mojave users updating from an older host likely have already granted a11y // permission to the old script. In this case we always delegate RunHost to // the old script so that they don't need to grant permission to a new app. if (base::mac::IsOS10_14() && base::PathExists(old_host_helper_file_)) { HOST_LOG << "RunHost will be delegated to the old host script."; return RunHostFromOldScript(); } // Run the config-upgrade tool, but only if running as root, as normal users // don't have permission to write the config file. if (geteuid() == 0) { HOST_LOG << "Attempting to upgrade token"; base::CommandLine cmdline(host_exe_file_); cmdline.AppendSwitch("upgrade-token"); cmdline.AppendSwitchPath("host-config", config_file_); std::string output; base::GetAppOutputAndError(cmdline, &output); if (!output.empty()) { HOST_LOG << "Message from host --upgrade-token: " << output; } } int host_failure_count = 0; base::TimeTicks host_start_time; while (true) { if (!base::PathExists(enabled_file_)) { HOST_LOG << "Daemon is disabled."; return 0; } // If this is not the first time the host has run, make sure we don't // relaunch it too soon. if (!host_start_time.is_null()) { base::TimeDelta host_lifetime = base::TimeTicks::Now() - host_start_time; HOST_LOG << "Host ran for " << host_lifetime; if (host_lifetime < kMinimumRelaunchInterval) { // If the host didn't run for very long, assume it crashed. Relaunch // only after a suitable delay and increase the failure count. host_failure_count++; LOG(WARNING) << "Host failure count " << host_failure_count << "/" << kMaximumHostFailures; if (host_failure_count >= kMaximumHostFailures) { LOG(ERROR) << "Too many host failures. Giving up."; return 1; } base::TimeDelta relaunch_in = kMinimumRelaunchInterval - host_lifetime; HOST_LOG << "Relaunching in " << relaunch_in; base::PlatformThread::Sleep(relaunch_in); } else { // If the host ran for long enough, reset the crash counter. host_failure_count = 0; } } host_start_time = base::TimeTicks::Now(); base::CommandLine cmdline(host_exe_file_); cmdline.AppendSwitchPath("host-config", config_file_); std::string ssh_auth_sockname = "/tmp/chromoting." + GetUsername() + ".ssh_auth_sock"; cmdline.AppendSwitchASCII("ssh-auth-sockname", ssh_auth_sockname); base::Process process = base::LaunchProcess(cmdline, base::LaunchOptions()); if (!process.IsValid()) { LOG(ERROR) << "Failed to launch host process for unknown reason."; return 1; } g_host_pid = process.Pid(); int exit_code; process.WaitForExit(&exit_code); g_host_pid = 0; const char* exit_code_string_ptr = ExitCodeToStringUnchecked(exit_code); std::string exit_code_string = exit_code_string_ptr ? (std::string(exit_code_string_ptr) + " (" + base::NumberToString(exit_code) + ")") : base::NumberToString(exit_code); if (exit_code == 0 || exit_code == kSigtermExitCode || exit_code == kPermissionDeniedParentalControl || (exit_code >= kMinPermanentErrorExitCode && exit_code <= kMaxPermanentErrorExitCode)) { HOST_LOG << "Host returned permanent exit code " << exit_code_string << " at " << base::Time::Now(); if (exit_code == kInvalidHostIdExitCode || exit_code == kHostDeletedExitCode) { // The host was taken off-line remotely. To prevent the host being // restarted when the login context changes, try to delete the "enabled" // file. Since this requires root privileges, this is only possible when // this executable is launched in the "login" context. In the "aqua" // context, just exit and try again next time. HOST_LOG << "Host deleted - disabling"; Disable(); } return exit_code; } // Ignore non-permanent error-code and launch host again. Stop handling // signals temporarily in case the executable has to sleep to throttle host // relaunches. While throttling, there is no host process to which to // forward the signal, so the default behaviour should be restored. HOST_LOG << "Host returned non-permanent exit code " << exit_code_string << " at " << base::Time::Now(); } return 0; } bool HostService::Disable() { return base::DeleteFile(enabled_file_, false); } bool HostService::Enable() { // Ensure the config file is private whilst being written. base::DeleteFile(config_file_, false); if (!WriteStdinToConfig()) { return false; } if (!base::SetPosixFilePermissions(config_file_, 0600)) { LOG(ERROR) << "Failed to set posix permission"; return false; } // Ensure the config is readable by the user registering the host. // We don't seem to have API for adding Mac ACL entry for file. This code just // uses the chmod binary to do so. base::CommandLine chmod_cmd(base::FilePath("/bin/chmod")); chmod_cmd.AppendArg("+a"); chmod_cmd.AppendArg(GetUsername() + ":allow:read"); chmod_cmd.AppendArgPath(config_file_); std::string output; if (!base::GetAppOutputAndError(chmod_cmd, &output)) { LOG(ERROR) << "Failed to chmod file " << config_file_; return false; } if (!output.empty()) { HOST_LOG << "Message from chmod: " << output; } if (base::WriteFile(enabled_file_, nullptr, 0) < 0) { LOG(ERROR) << "Failed to write enabled file"; return false; } return true; } bool HostService::WriteStdinToConfig() { // Reads from stdin and writes it to the config file. std::istreambuf_iterator<char> begin(std::cin); std::istreambuf_iterator<char> end; std::string config(begin, end); if (base::WriteFile(config_file_, config.data(), config.size()) != static_cast<int>(config.size())) { LOG(ERROR) << "Failed to write config file"; return false; } return true; } void HostService::PrintHostVersion() { printf("%s\n", STRINGIZE(VERSION)); } void HostService::PrintPid() { // Caller running host service with privilege waits for the PID to continue, // so we need to flush it immediately. printf("%d\n", base::Process::Current().Pid()); fflush(stdout); } int HostService::RunHostFromOldScript() { base::CommandLine cmdline(old_host_helper_file_); cmdline.AppendSwitch(kSwitchHostRunFromLaunchd); base::LaunchOptions options; options.disclaim_responsibility = true; base::Process process = base::LaunchProcess(cmdline, options); if (!process.IsValid()) { LOG(ERROR) << "Failed to launch the old host script for unknown reason."; return 1; } g_host_pid = process.Pid(); int exit_code; process.WaitForExit(&exit_code); g_host_pid = 0; return exit_code; } } // namespace } // namespace remoting int main(int argc, char const* argv[]) { base::AtExitManager exitManager; base::CommandLine::Init(argc, argv); InitHostLogging(); HostService service; auto* current_cmdline = base::CommandLine::ForCurrentProcess(); std::string pid = base::NumberToString(base::Process::Current().Pid()); if (current_cmdline->HasSwitch(kSwitchDisable)) { service.PrintPid(); if (!service.Disable()) { LOG(ERROR) << "Failed to disable"; return 1; } } else if (current_cmdline->HasSwitch(kSwitchEnable)) { service.PrintPid(); if (!service.Enable()) { LOG(ERROR) << "Failed to enable"; return 1; } } else if (current_cmdline->HasSwitch(kSwitchSaveConfig)) { service.PrintPid(); if (!service.WriteStdinToConfig()) { LOG(ERROR) << "Failed to save config"; return 1; } } else if (current_cmdline->HasSwitch(kSwitchHostVersion)) { service.PrintHostVersion(); } else if (current_cmdline->HasSwitch(kSwitchHostRunFromLaunchd)) { RegisterSignalHandler(); HOST_LOG << "Host started for user " << GetUsername() << " at " << base::Time::Now(); return service.RunHost(); } else { service.PrintPid(); return 1; } return 0; }
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
f0c4866829f0b51e9de296ffd9ff55bdc2e00bea
423f76035af6fe90fbdbeb0aaed06c152800d400
/Extern/mssdk_dx7/samples/Multimedia/DInput/src/Tutorials/DIEx5/diex5.cpp
49af3882f87ef261b231d4224e98968a56b62e8e
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
majacQ/orbiter
687ede8b7a8008693055200589301763cce352a9
0b76a36c3ef52adeed6732fa6043df90ad1a6b21
refs/heads/master
2023-07-02T02:51:37.306756
2021-07-30T00:49:44
2021-07-30T00:49:44
390,885,751
0
0
NOASSERTION
2021-07-31T12:27:29
2021-07-30T00:42:40
C++
UTF-8
C++
false
false
17,605
cpp
//----------------------------------------------------------------------------- // Name: DIEx5.cpp // // Desc: DirectInput simple sample 5 // Demonstrates an application which retrieves buffered HID data // in non-exclusive mode via a blocking loop. // // Copyright (C) 1997-1999 Microsoft Corporation. All Rights Reserved. //----------------------------------------------------------------------------- #include <windows.h> #include <dinput.h> #define DIMAKEUSAGEDWORD(UsagePage, Usage) (DWORD)MAKELONG(Usage, UsagePage) #define DIDOI_GUIDISUSAGE 0x00010000 //----------------------------------------------------------------------------- // Global variables //----------------------------------------------------------------------------- #define DINPUT_BUFFERSIZE 16 // Number of buffer elements LPDIRECTINPUT g_pDI; LPDIRECTINPUTDEVICE g_pDIDevice; HANDLE g_hEvent; CHAR g_strText[1024]; // What we display in client area //----------------------------------------------------------------------------- // Name: struct VCRDATA // Desc: DInput custom data format used to read VCR data. It merely consists of // four buttons. Note: the size of this structure must be a multiple of four // (which it is...otherwise, padding would be necessary.) //----------------------------------------------------------------------------- #define VCROFS_PLAY FIELD_OFFSET( VCRDATA, bPlay ) #define VCROFS_STOP FIELD_OFFSET( VCRDATA, bStop ) #define VCROFS_REWIND FIELD_OFFSET( VCRDATA, bRewind ) #define VCROFS_FFORWARD FIELD_OFFSET( VCRDATA, bFForward ) struct VCRDATA { BYTE bPlay; BYTE bStop; BYTE bRewind; BYTE bFForward; }; //----------------------------------------------------------------------------- // Name: c_rgodfVCR // Desc: Array of DirectInput custom data formats, describing each field in our // VCRDATA structure. Each row in the array consists of four fields: // 1. (const GUID *)DIMAKEUSAGEDWORD(UsagePage, Usage) // The usage page and usage of the control we desire. // The DIDOI_GUIDISUSAGE flag in the dwFlags indicates that // the first field is really a DIMAKEUSAGEDWORD instead // of a pointer to a GUID. // 2. VCROFS_* // The data offset of the item. This information is used // to identify the control after the data format is selected. // 3. DIDFT_BUTTON | DIDFT_ANYINSTANCE // The data format object type filter. Here, we say that // we want a button, but we don't care which button. The // usage page and usage information will choose the right // button for us. // 4. DIDOI_GUIDISUSAGE // The first field of the DIOBJECTDATAFORMAT should be // interpreted as a usage page and usage, rather than a GUID. //----------------------------------------------------------------------------- // These magic numbers come from the USB HID Specification. #define HID_USAGE_PAGE_CONSUMER 0x000C // Consumer controls #define HID_USAGE_CONSUMER_PLAY 0x00B0 // Play #define HID_USAGE_CONSUMER_STOP 0x00B7 // Stop #define HID_USAGE_CONSUMER_REWIND 0x00B4 // Rewind #define HID_USAGE_CONSUMER_FFORWARD 0x00B3 // Fast Forward DIOBJECTDATAFORMAT c_rgodfVCR[4] = { // Play button { (const GUID *)DIMAKEUSAGEDWORD(HID_USAGE_PAGE_CONSUMER, HID_USAGE_CONSUMER_PLAY), VCROFS_PLAY, DIDFT_BUTTON | DIDFT_ANYINSTANCE, DIDOI_GUIDISUSAGE, }, // Stop button { (const GUID *)DIMAKEUSAGEDWORD(HID_USAGE_PAGE_CONSUMER, HID_USAGE_CONSUMER_STOP), VCROFS_STOP, DIDFT_BUTTON | DIDFT_ANYINSTANCE, DIDOI_GUIDISUSAGE, }, // Rewind button { (const GUID *)DIMAKEUSAGEDWORD(HID_USAGE_PAGE_CONSUMER, HID_USAGE_CONSUMER_REWIND), VCROFS_REWIND, DIDFT_BUTTON | DIDFT_ANYINSTANCE, DIDOI_GUIDISUSAGE, }, // Fast Forward button { (const GUID *)DIMAKEUSAGEDWORD(HID_USAGE_PAGE_CONSUMER, HID_USAGE_CONSUMER_FFORWARD), VCROFS_FFORWARD, DIDFT_BUTTON | DIDFT_ANYINSTANCE, DIDOI_GUIDISUSAGE, }, }; //----------------------------------------------------------------------------- // Name: c_dfVCR // Desc: DirectInput custom data format which ties all this information // together into a DirectInput data format. //----------------------------------------------------------------------------- DIDATAFORMAT c_dfVCR = { sizeof(DIDATAFORMAT), // dwSize sizeof(DIOBJECTDATAFORMAT), // dwObjSize 0, // No special flags sizeof(VCRDATA), // Size of data structure 4, // Number of objects in data format c_rgodfVCR, // The objects themselves }; //----------------------------------------------------------------------------- // Name: DisplayError() // Desc: Displays an error in a message box //----------------------------------------------------------------------------- VOID DisplayError( HRESULT hr, CHAR* strMessage ) { MessageBox( NULL, strMessage, "DirectInput Sample", MB_OK ); } //----------------------------------------------------------------------------- // Name: DITryCreatedDevice() // Desc: Check if a created device meets our needs (we are looking for a VCR // device.) //----------------------------------------------------------------------------- BOOL DITryCreatedDevice( LPDIRECTINPUTDEVICE pDIDevice, HWND hWnd ) { HRESULT hr; DIDEVCAPS caps; // Select our data format to see if this device supports the things we // request. A data format specifies which controls on a device we are // interested in, and how they should be reported. In this case, the // c_dfVCR data format specifies what we are looking for. if( FAILED( hr = pDIDevice->SetDataFormat( &c_dfVCR ) ) ) return FALSE; // Query the device capabilities to see if it requires polling. // This appliction isn't written to support polling. So, if the // device require it, then skip polling. // // Note that we set the caps.dwSize to sizeof(DIDEVCAPS_DX3) // because we don't particularly care about force feedback. // // Note that we check the DIDC_POLLEDDATAFORMAT flag instead of // the DIDC_POLLEDDEVICE flag. We don't care whether the device // requires polling, we only care if the VCR controls require // polling. caps.dwSize = sizeof(DIDEVCAPS_DX3); if( FAILED( hr = pDIDevice->GetCapabilities( &caps ) ) ) return FALSE; if( caps.dwFlags & DIDC_POLLEDDATAFORMAT ) return FALSE; // Set the cooperative level to let DirectInput know how // this device should interact with the system and with other // DirectInput applications. if( FAILED( hr = pDIDevice->SetCooperativeLevel( hWnd, DISCL_BACKGROUND | DISCL_EXCLUSIVE ) ) ) return FALSE; // DirectInput uses unbuffered I/O (buffer size = 0) by default. // If you want to read buffered data, you need to set a nonzero // buffer size. DIPROPDWORD dipdw = { { sizeof(DIPROPDWORD), // diph.dwSize sizeof(DIPROPHEADER), // diph.dwHeaderSize 0, // diph.dwObj DIPH_DEVICE, // diph.dwHow }, DINPUT_BUFFERSIZE, // dwData }; if( FAILED( hr = pDIDevice->SetProperty( DIPROP_BUFFERSIZE, &dipdw.diph ) ) ) return FALSE; // We are not a game, we are just a little VCR app. So // instead of going into a polling loop on the device, // use event notifications so we don't use any CPU until // the user actually presses a button. pDIDevice->SetEventNotification( g_hEvent); // The device met all the criteria. Return TRUE. return TRUE; } //----------------------------------------------------------------------------- // Name: EnumDevicesCallback() // Desc: Callback function called by EnumDevices(). Checks each device to see // if it meets our criteria (we are looking for a VCR device.) //----------------------------------------------------------------------------- BOOL CALLBACK EnumDevicesCallback( LPCDIDEVICEINSTANCE pInst, LPVOID pvRef ) { LPDIRECTINPUTDEVICE pDIDevice; HRESULT hr; HWND hWnd = (HWND)pvRef; // Our refdata is the coop window // Create the device we enumerated so we can snoop at it to decide // if we like it or not. hr = g_pDI->CreateDevice( pInst->guidInstance, &pDIDevice, NULL ); if( SUCCEEDED(hr) ) { // Use our helper function to see if this is a device // that is useful to us. if( DITryCreatedDevice( pDIDevice, hWnd ) ) { // Okay, we found a VCR control. Save the device pointer and bump // its refcount so it won't go away -- see below for the Release() // that this AddRef() counteracts. We've found a device so we can // stop enumerating. (Alternatively, we could keep enumerating and // put all accepted devices in a listbox.) g_pDIDevice = pDIDevice; return DIENUM_STOP; } // We didn't like the device, so destroy it pDIDevice->Release(); } return DIENUM_CONTINUE; } //----------------------------------------------------------------------------- // Name: CreateDInput() // Desc: Initialize the DirectInput globals //----------------------------------------------------------------------------- HRESULT CreateDInput( HWND hWnd ) { HINSTANCE hInst = (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE ); HRESULT hr; // We use event notifications, so we'll need an event. if( NULL == ( g_hEvent = CreateEvent( NULL, FALSE, FALSE, NULL ) ) ) { DisplayError( 0, "CreateEvent() failed" ); return E_FAIL; } // Register with the DirectInput subsystem and get a pointer to a // IDirectInput interface we can use. if( FAILED( hr = DirectInputCreate( hInst, DIRECTINPUT_VERSION, &g_pDI, NULL ) ) ) { DisplayError( hr, "DirectInputCreate() failed"); return hr; } // Enumerate all the devices in the system looking for one that we // like. if( FAILED( hr = g_pDI->EnumDevices( 0, EnumDevicesCallback, hWnd, DIEDFL_ATTACHEDONLY ) ) ) { DisplayError( hr, "EnumDevices() failed"); return hr; } // Complain if we couldn't find a VCR control. if( NULL == g_pDIDevice ) { DisplayError( 0, "Couldn't find a VCR control" ); return E_FAIL; } return S_OK; } //----------------------------------------------------------------------------- // Name: DestroyDInput() // Desc: Terminate our usage of DirectInput //----------------------------------------------------------------------------- VOID DestroyDInput() { // Destroy any lingering IDirectInputDevice object. if( g_pDIDevice ) { // Unacquire the device g_pDIDevice->Unacquire(); g_pDIDevice->Release(); g_pDIDevice = NULL; } // Destroy any lingering IDirectInput object. if( g_pDI ) { g_pDI->Release(); g_pDI = NULL; } // Destroy the event we were using. if( g_hEvent ) { CloseHandle( g_hEvent ); g_hEvent = NULL; } } //----------------------------------------------------------------------------- // Name: ReadVCRData() // Desc: Read and display status of the VCR buttons //----------------------------------------------------------------------------- VOID ReadVCRData( HWND hWnd ) { DIDEVICEOBJECTDATA rgod[DINPUT_BUFFERSIZE]; // Receives buffered data DWORD cod; HRESULT hr; cod = DINPUT_BUFFERSIZE; if( FAILED( hr = g_pDIDevice->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), rgod, &cod, 0 ) ) ) { // We got an error or we got DI_BUFFEROVERFLOW. Either way, it means // that continuous contact with the device has been lost, either due // to an external interruption, or because the buffer overflowed and // some events were lost. // // Consequently, if a button was pressed at the time the buffer // overflowed or the connection was broken, the corresponding "up" // message might have been lost. // // But since our simple sample doesn't actually have any state // associated with button up or down events, there is no state to // reset. (In a real app, ignoring the buffer overflow would result in // the app thinking a key was held down.) // // It would be more clever to call GetDeviceState() and compare the // current state against the state we think the device is in, and // process all the states that are currently different from our // private state. if( hr == DIERR_INPUTLOST ) { hr = g_pDIDevice->Acquire(); if( SUCCEEDED(hr) ) ReadVCRData( hWnd ); } } // In order for it to be worth our while to parse the buffer elements, the // GetDeviceData() call must have succeeded, and we must have received some // data at all. if( SUCCEEDED(hr) && cod > 0 ) { CHAR strBuf[1024]; // Process each of the buffer elements for( DWORD iod = 0; iod < cod; iod++ ) { CHAR* strObj = NULL; switch( rgod[iod].dwOfs ) { case VCROFS_PLAY: strObj = "Play"; break; case VCROFS_STOP: strObj = "Stop"; break; case VCROFS_REWIND: strObj = "FF"; break; case VCROFS_FFORWARD: strObj = "Rew"; break; } if( strObj ) wsprintf( strBuf, "%s was %s", strObj, (rgod[iod].dwData & 0x80) ? "pressed" : "released" ); } // Trigger a repaint if the status string changed. if( lstrcmp( g_strText, strBuf ) ) { lstrcpy( g_strText, strBuf ); InvalidateRect( hWnd, NULL, TRUE ); } } } //----------------------------------------------------------------------------- // Name: WndProc() // Desc: Application's message handler //----------------------------------------------------------------------------- LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch( msg ) { case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = BeginPaint( hWnd, &ps ); if( hDC ) { ExtTextOut( hDC, 0, 0, ETO_OPAQUE, &ps.rcPaint, g_strText, lstrlen(g_strText), NULL ); EndPaint( hWnd, &ps ); } } return 0; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc( hWnd, msg, wParam, lParam ); } //----------------------------------------------------------------------------- // Name: WinMain() // Desc: Application entry point. //----------------------------------------------------------------------------- int PASCAL WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, int nCmdShow ) { // Set up the window class WNDCLASS wc = { CS_HREDRAW | CS_VREDRAW, WndProc, 0, 0, hInst, LoadIcon( hInst, MAKEINTRESOURCE(IDI_APPLICATION)), LoadCursor(NULL, IDC_ARROW), NULL, NULL, TEXT("DI Window") }; if( !RegisterClass( &wc ) ) return FALSE; // Create the main window HWND hWnd = CreateWindow( "DI Window", "DIEx5 - Accessing a HID", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 100, NULL, NULL, hInst, 0 ); if( FAILED( CreateDInput( hWnd ) ) ) { DestroyWindow( hWnd ); return FALSE; } ShowWindow( hWnd, nCmdShow ); // Everything is all set up. Acquire the device and have at it. if( FAILED( g_pDIDevice->Acquire() ) ) { // Unable to obtain access to the device. Some other // application probably has it in exclusive mode. DisplayError( E_FAIL, "Cannot acquire device" ); DestroyDInput(); return FALSE; } // Standard game loop. while( TRUE ) { MSG msg; if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { // If it's a quit message, then we're done. if( msg.message == WM_QUIT ) break; // Otherwise translate and dispatch it TranslateMessage( &msg ); DispatchMessage( &msg ); } // Wait for a message or for our event. DWORD dwRc = MsgWaitForMultipleObjects( 1, &g_hEvent, FALSE, INFINITE, QS_ALLINPUT ); // dwRc is WAIT_OBJECT_0 if we have new input. if( dwRc == WAIT_OBJECT_0 ) ReadVCRData( hWnd ); } DestroyDInput(); return TRUE; }
[ "martins0815@googlemail.com" ]
martins0815@googlemail.com
ab6cc706a17f9ba32b87aa6d4a502f99d37010c3
c7ef2693331417afc8030502853bbdeeeee6741a
/MyOnlineSubmissions/Google-CodeJam/2020/QualificationRound/B-NestingDepth.cpp
6f9d77f1a88be2e44c6631d1a2b88f8cdf1b9b04
[]
no_license
supershivam13/DataStructures-Algorithms
4707befe53d8a44861bcf0211485bcfba54a5447
6019eddc41e4e38725b9aeed1bdbc89151f5e82d
refs/heads/master
2023-01-03T21:53:15.437185
2020-10-29T17:50:08
2020-10-29T17:50:08
300,433,445
8
8
null
2020-10-29T17:50:09
2020-10-01T21:48:01
C++
UTF-8
C++
false
false
2,154
cpp
#include<bits/stdc++.h> using namespace std; #define gc getchar_unlocked #define fo(i,n) for(i=0;i<n;i++) #define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define ll long long #define si(x) scanf("%d",&x) #define sl(x) scanf("%lld",&x) #define ss(s) scanf("%s",s) #define pi(x) printf("%d",x) #define pl(x) printf("%lld",x) #define ps(s) printf("%s",s) #define pnl() printf("\n") #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl #define pb push_back #define mp make_pair #define F first #define S second #define all(x) x.begin(), x.end() #define clr(x) memset(x, 0, sizeof(x)) #define sortall(x) sort(all(x)) #define tr(it, a) for(auto it = a.begin(); it != a.end(); it++) #define PI 3.1415926535897932384626 typedef pair<int, int> pii; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpii; typedef vector<pl> vpl; typedef vector<vi> vvi; typedef vector<vl> vvl; int mpow(int base, int exp); void ipgraph(int m); void dfs(int u, int par); const int mod = 1000000007; const int N = 18 * 103, M = N; //======================= vi g[N]; int main() { // ios_base::sync_with_stdio(0); int t, i, j, k, p, q, r, x, y, u, v, m, tt; si(t); fo(tt, t) { string s; cin >> s; vector<char> ans = {}; int cur = 0; for(char c: s) { int x = c-'0'; while(cur < x) ans.push_back('('), cur++; while(cur > x) ans.push_back(')'), cur--; ans.push_back(c); } while(cur) ans.push_back(')'), cur--; ps("Case #"); pi(tt+1); ps(": "); for(char c: ans) printf("%c",c); pnl(); } return 0; } int mpow(int base, int exp) { base %= mod; int result = 1; while (exp > 0) { if (exp & 1) result = ((ll)result * base) % mod; base = ((ll)base * base) % mod; exp >>= 1; } return result; } void ipgraph(int n, int m){ int i, u, v; while(m--){ cin>>u>>v; g[u-1].pb(v-1); g[v-1].pb(u-1); } } void dfs(int u, int par){ for(int v:g[u]){ if (v == par) continue; dfs(v, u); } }
[ "rachit.jain2095@gmail.com" ]
rachit.jain2095@gmail.com
01fb801b83f886c35da8004b72efac71f3235ba5
e8629d42c2dec629dc4ab8dec3d18813e4bf216d
/c_call_go/main.cpp
f450a891054b399b2f95b6c436b16db9f2319bf4
[]
no_license
pata00/samples
231ddd86da57b209e1fb9bbb88c5fe3749cfff3c
028f143e818a93d33cac2b3c9ab23260ee593916
refs/heads/master
2022-12-26T05:34:40.151878
2022-12-21T08:24:00
2022-12-21T08:24:00
230,587,031
0
0
null
null
null
null
UTF-8
C++
false
false
64
cpp
#include "hellofromgo.h" int main() { SayHello(); return 0; }
[ "wangyue9014@gmail.com" ]
wangyue9014@gmail.com
ea09aefce3a946803baba1d05eae225c28acda9d
263a50fb4ca9be07a5b229ac80047f068721f459
/skia/ext/platform_device.h
e56bb13d13904ea10e8677735e6e94ca16119e6c
[ "BSD-3-Clause" ]
permissive
talalbutt/clank
8150b328294d0ac7406fa86e2d7f0b960098dc91
d060a5fcce180009d2eb9257a809cfcb3515f997
refs/heads/master
2021-01-18T01:54:24.585184
2012-10-17T15:00:42
2012-10-17T15:00:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,919
h
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SKIA_EXT_PLATFORM_DEVICE_H_ #define SKIA_EXT_PLATFORM_DEVICE_H_ #pragma once #include "build/build_config.h" #if defined(OS_WIN) #include <windows.h> #include <vector> #endif #include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkDevice.h" #include "third_party/skia/include/core/SkPreConfig.h" class SkMatrix; class SkMetaData; class SkPath; class SkRegion; #if defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ || defined(OS_SUN) typedef struct _cairo cairo_t; typedef struct _cairo_rectangle cairo_rectangle_t; #elif defined(OS_MACOSX) typedef struct CGContext* CGContextRef; typedef struct CGRect CGRect; #endif namespace skia { class PlatformDevice; #if defined(OS_WIN) typedef HDC PlatformSurface; typedef RECT PlatformRect; #elif defined(ANDROID) typedef void* PlatformSurface; typedef SkIRect* PlatformRect; #elif defined(OS_LINUX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) \ || defined(OS_SUN) typedef cairo_t* PlatformSurface; typedef cairo_rectangle_t PlatformRect; #elif defined(OS_MACOSX) typedef CGContextRef PlatformSurface; typedef CGRect PlatformRect; #endif // The following routines provide accessor points for the functionality // exported by the various PlatformDevice ports. The PlatformDevice, and // BitmapPlatformDevice classes inherit directly from SkDevice, which is no // longer a supported usage-pattern for skia. In preparation of the removal of // these classes, all calls to PlatformDevice::* should be routed through these // helper functions. // Bind a PlatformDevice instance, |platform_device| to |device|. Subsequent // calls to the functions exported below will forward the request to the // corresponding method on the bound PlatformDevice instance. If no // PlatformDevice has been bound to the SkDevice passed, then the routines are // NOPS. SK_API void SetPlatformDevice(SkDevice* device, PlatformDevice* platform_device); SK_API PlatformDevice* GetPlatformDevice(SkDevice* device); #if defined(OS_WIN) // Initializes the default settings and colors in a device context. SK_API void InitializeDC(HDC context); #elif defined(OS_MACOSX) // Returns the CGContext that backing the SkDevice. Forwards to the bound // PlatformDevice. Returns NULL if no PlatformDevice is bound. SK_API CGContextRef GetBitmapContext(SkDevice* device); #endif // Following routines are used in print preview workflow to mark the draft mode // metafile and preview metafile. SK_API SkMetaData& getMetaData(const SkCanvas& canvas); SK_API void SetIsDraftMode(const SkCanvas& canvas, bool draft_mode); SK_API bool IsDraftMode(const SkCanvas& canvas); #if defined(OS_MACOSX) || defined(OS_WIN) SK_API void SetIsPreviewMetafile(const SkCanvas& canvas, bool is_preview); SK_API bool IsPreviewMetafile(const SkCanvas& canvas); #endif // A SkDevice is basically a wrapper around SkBitmap that provides a surface for // SkCanvas to draw into. PlatformDevice provides a surface Windows can also // write to. It also provides functionality to play well with GDI drawing // functions. This class is abstract and must be subclassed. It provides the // basic interface to implement it either with or without a bitmap backend. // // PlatformDevice provides an interface which sub-classes of SkDevice can also // provide to allow for drawing by the native platform into the device. class SK_API PlatformDevice { public: virtual ~PlatformDevice() {} #if defined(OS_MACOSX) // The CGContext that corresponds to the bitmap, used for CoreGraphics // operations drawing into the bitmap. This is possibly heavyweight, so it // should exist only during one pass of rendering. virtual CGContextRef GetBitmapContext() = 0; #endif // The DC that corresponds to the bitmap, used for GDI operations drawing // into the bitmap. This is possibly heavyweight, so it should be existant // only during one pass of rendering. virtual PlatformSurface BeginPlatformPaint(); // Finish a previous call to beginPlatformPaint. virtual void EndPlatformPaint(); // Draws to the given screen DC, if the bitmap DC doesn't exist, this will // temporarily create it. However, if you have created the bitmap DC, it will // be more efficient if you don't free it until after this call so it doesn't // have to be created twice. If src_rect is null, then the entirety of the // source device will be copied. virtual void DrawToNativeContext(PlatformSurface surface, int x, int y, const PlatformRect* src_rect) = 0; // Returns if GDI is allowed to render text to this device. virtual bool IsNativeFontRenderingAllowed(); // True if AlphaBlend() was called during a // BeginPlatformPaint()/EndPlatformPaint() pair. // Used by the printing subclasses. See |VectorPlatformDeviceEmf|. virtual bool AlphaBlendUsed() const; #if defined(OS_WIN) // Loads a SkPath into the GDI context. The path can there after be used for // clipping or as a stroke. Returns false if the path failed to be loaded. static bool LoadPathToDC(HDC context, const SkPath& path); // Loads a SkRegion into the GDI context. static void LoadClippingRegionToDC(HDC context, const SkRegion& region, const SkMatrix& transformation); #elif defined(OS_MACOSX) // Loads a SkPath into the CG context. The path can there after be used for // clipping or as a stroke. static void LoadPathToCGContext(CGContextRef context, const SkPath& path); // Initializes the default settings and colors in a device context. static void InitializeCGContext(CGContextRef context); // Loads a SkRegion into the CG context. static void LoadClippingRegionToCGContext(CGContextRef context, const SkRegion& region, const SkMatrix& transformation); #endif protected: #if defined(OS_WIN) // Arrays must be inside structures. struct CubicPoints { SkPoint p[4]; }; typedef std::vector<CubicPoints> CubicPath; typedef std::vector<CubicPath> CubicPaths; // Loads the specified Skia transform into the device context, excluding // perspective (which GDI doesn't support). static void LoadTransformToDC(HDC dc, const SkMatrix& matrix); // Transforms SkPath's paths into a series of cubic path. static bool SkPathToCubicPaths(CubicPaths* paths, const SkPath& skpath); #elif defined(OS_MACOSX) // Loads the specified Skia transform into the device context static void LoadTransformToCGContext(CGContextRef context, const SkMatrix& matrix); #endif }; } // namespace skia #endif // SKIA_EXT_PLATFORM_DEVICE_H_
[ "plind@mips.com" ]
plind@mips.com
81ccee3851a5850c6dbc389408818086fb72b857
3442ea09cc826bdd8ce7c677feb80c75c93c6582
/Final/king.cc
c4059c16524cef53bfdb6d5a50c3cda26e7b1393
[]
no_license
balintdbene/Chess
7eff964272682dfaceb48ec2f199ad79a48e1e8d
a9d31d1b0cb733717f1ec701a093e85a1d7ef3d5
refs/heads/master
2016-09-15T15:39:57.121924
2014-03-10T13:05:07
2014-03-10T13:05:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
7,705
cc
#include"king.h" #include<string> #include"board.h" using std::string; King::King(string team,Board* chessboard){ //constructor for a king Piece value = 200; this->chessboard = chessboard; this->team = team; if(team == "Black"){ type = 'k'; }else{ type = 'K'; } underAttack = false; hasMoved = false; checkingCastles = false; } vector<Move> King::validCastles(string location){ //checks for valid castling int row = 8-(location[1]-48); int column = location[0]-97; vector<Move> castles; checkingCastles = true; string notTeam; if(team == "White"){ notTeam = "Black"; }else{ notTeam = "White"; } string status; Move topRightCastle; topRightCastle.start = "e8"; topRightCastle.end = "g8"; topRightCastle.castling = true; Move topLeftCastle; topLeftCastle.start = "e8"; topLeftCastle.end = "c8"; topLeftCastle.castling = true; Move bottomRightCastle; bottomRightCastle.start = "e1"; bottomRightCastle.end = "g1"; bottomRightCastle.castling = true; Move bottomLeftCastle; bottomLeftCastle.start = "e1"; bottomLeftCastle.end = "c1"; bottomLeftCastle.castling = true; Piece* topRightRook = chessboard->theBoard[0][7].piece; Piece* topLeftRook = chessboard->theBoard[0][0].piece; Piece* bottomRightRook = chessboard->theBoard[7][7].piece; Piece* bottomLeftRook = chessboard->theBoard[7][0].piece; Move topRight1; topRight1.start = "e8"; topRight1.end = "f8"; Move topRight2; topRight2.start = "e8"; topRight2.end = "g8"; Move topLeft1; topLeft1.start = "e8"; topLeft1.end = "d8"; Move topLeft2; topLeft2.start = "e8"; topLeft2.end = "c8"; Move bottomRight1; bottomRight1.start = "e1"; bottomRight1.end = "f1"; Move bottomRight2; bottomRight2.start = "e1"; bottomRight2.end = "g1"; Move bottomLeft1; bottomLeft1.start = "e1"; bottomLeft1.end = "d1"; Move bottomLeft2; bottomLeft2.start = "e1"; bottomLeft2.end = "c1"; if(location == "e1" || location == "e8"){ if(!hasMoved){ if(chessboard->gameStatus(team) != "check"){ if(row == 0 && team == "Black"){//Black King if(topRightRook != NULL && topRightRook->type == 'r' && !topRightRook->hasMoved){ if(chessboard->theBoard[row][column+1].piece == NULL && chessboard->theBoard[row][column+2].piece == NULL){ //GENERATING KINGS TO CHECK FOR CHECK chessboard->theBoard[row][column+1].generatePiece('k',chessboard); chessboard->theBoard[row][column+2].generatePiece('k',chessboard); chessboard->setAttacks(); status = chessboard->gameStatus(team); if(status != "check" && status != "checkmate"){ castles.push_back(topRightCastle); } delete chessboard->theBoard[row][column+1].piece; chessboard->theBoard[row][column+1].piece = NULL; delete chessboard->theBoard[row][column+2].piece; chessboard->theBoard[row][column+2].piece = NULL; chessboard->setAttacks(); } } if(topLeftRook != NULL && topLeftRook->type == 'r' && !topLeftRook->hasMoved){ if(chessboard->theBoard[row][column-1].piece == NULL && chessboard->theBoard[row][column-2].piece == NULL){ //GENERATING KINGS TO CHECK FOR CHECK chessboard->theBoard[row][column-1].generatePiece('k',chessboard); chessboard->theBoard[row][column-2].generatePiece('k',chessboard); chessboard->setAttacks(); status = chessboard->gameStatus(team); if(status != "check" && status != "checkmate"){ castles.push_back(topLeftCastle); } delete chessboard->theBoard[row][column-1].piece; chessboard->theBoard[row][column-1].piece = NULL; delete chessboard->theBoard[row][column-2].piece; chessboard->theBoard[row][column-2].piece = NULL; chessboard->setAttacks(); } } } if(row == 7 && team == "White"){//White King if(bottomRightRook != NULL && bottomRightRook->type == 'R' && !bottomRightRook->hasMoved){ if(chessboard->theBoard[row][column+1].piece == NULL && chessboard->theBoard[row][column+2].piece == NULL){ //GENERATING KINGS TO CHECK FOR CHECK chessboard->theBoard[row][column+1].generatePiece('K',chessboard); chessboard->theBoard[row][column+2].generatePiece('K',chessboard); chessboard->setAttacks(); status = chessboard->gameStatus(team); if(status != "check" && status != "checkmate"){ castles.push_back(bottomRightCastle); } delete chessboard->theBoard[row][column+1].piece; chessboard->theBoard[row][column+1].piece = NULL; delete chessboard->theBoard[row][column+2].piece; chessboard->theBoard[row][column+2].piece = NULL; chessboard->setAttacks(); } } if(bottomLeftRook != NULL && bottomLeftRook->type == 'R' && !bottomLeftRook->hasMoved){ if(chessboard->theBoard[row][column-1].piece == NULL && chessboard->theBoard[row][column-2].piece == NULL){ //GENERATING KINGS TO CHECK FOR CHECK chessboard->theBoard[row][column-1].generatePiece('K',chessboard); chessboard->theBoard[row][column-2].generatePiece('K',chessboard); chessboard->setAttacks(); status = chessboard->gameStatus(team); if(status != "check" && status != "checkmate"){ castles.push_back(bottomLeftCastle); } delete chessboard->theBoard[row][column-1].piece; chessboard->theBoard[row][column-1].piece = NULL; delete chessboard->theBoard[row][column-2].piece; chessboard->theBoard[row][column-2].piece = NULL; chessboard->setAttacks(); } } } } } } checkingCastles = false; return castles; } vector<Move> King::getValidMoves(string location,bool moving){ //returns a vector of valid moves of the king based on the situation of the board vector<Move> validMoves; int numValidMoves = 0; string checkLocation = " "; if(!checkingCastles && !moving){ validMoves = validCastles(location); } //King can move once in any of eight direction so we check them individually //Up checkLocation[0] = location[0]; checkLocation[1] = location[1] - 1; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } //Up and right checkLocation[0] = location[0] + 1; checkLocation[1] = location[1] - 1; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } //Right checkLocation[0] = location[0] + 1; checkLocation[1] = location[1]; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } //down and right checkLocation[0] = location[0] + 1; checkLocation[1] = location[1] + 1; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } //down checkLocation[0] = location[0]; checkLocation[1] = location[1] + 1; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } //down left checkLocation[0] = location[0] - 1; checkLocation[1] = location[1] + 1; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } //left checkLocation[0] = location[0] - 1; checkLocation[1] = location[1]; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } //left and up checkLocation[0] = location[0] - 1; checkLocation[1] = location[1] - 1; if(validMove(location,checkLocation,moving)){ validMoves.push_back(setMove(location,checkLocation,chessboard)); } return validMoves; }
[ "bdbene@uwaterloo.ca" ]
bdbene@uwaterloo.ca
6050c0f53c5aaf587d9a2c2284a4a04b648b220b
b38c6d5189c5f4016c22ab77f386037e70a466b9
/src/windows/Server.cc
ce55ab8d7575deaa181410c745fa2d8fc7f7238a
[ "MIT", "BSD-2-Clause", "BSD-3-Clause", "BSD-1-Clause" ]
permissive
cubemoon/lacewing
e03b542d4490c818b50ecf307a80ccb72cc15739
2d786cb00d40ae697d87cea597b916653e40ee6c
refs/heads/master
2021-01-24T04:28:24.992939
2012-11-17T16:13:00
2012-11-17T16:14:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,007
cc
/* vim: set et ts=4 sw=4 ft=cpp: * * Copyright (C) 2011, 2012 James McLaughlin. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 "../lw_common.h" #include "../Address.h" #include "WinSSLClient.h" static void onClientClose (Stream &, void * tag); static void onClientData (Stream &, void * tag, const char * buffer, size_t size); struct Server::Internal { Lacewing::Server &Public; SOCKET Socket; Lacewing::Pump &Pump; struct { HandlerConnect Connect; HandlerDisconnect Disconnect; HandlerReceive Receive; HandlerError Error; } Handlers; Internal (Lacewing::Server &_Public, Lacewing::Pump &_Pump) : Public (_Public), Pump (_Pump) { Socket = -1; memset (&Handlers, 0, sizeof (Handlers)); CertificateLoaded = false; AcceptsPosted = 0; } ~ Internal () { } List <Server::Client::Internal *> Clients; bool CertificateLoaded; CredHandle SSLCreds; bool IssueAccept (); int AcceptsPosted; }; struct Server::Client::Internal { Lacewing::Server::Client Public; Lacewing::Server::Internal &Server; Internal (Lacewing::Server::Internal &_Server, HANDLE _FD) : Server (_Server), FD (_FD), Public (_Server.Pump, _FD) { UserCount = 0; Dead = false; Public.internal = this; Public.Tag = 0; /* The first added close handler is always the last called. * This is important, because ours will destroy the client. */ Public.AddHandlerClose (onClientClose, this); if (Server.CertificateLoaded) { /* TODO : negates the std::nothrow when accepting a client */ SSL = new WinSSLClient (Server.SSLCreds); Public.AddFilterDownstream (SSL->Downstream, false, true); Public.AddFilterUpstream (SSL->Upstream, false, true); } else { SSL = 0; } } ~ Internal () { lwp_trace ("Terminate %p", &Public); ++ UserCount; FD = INVALID_HANDLE_VALUE; if (Element) /* connect handler already called? */ { if (Server.Handlers.Disconnect) Server.Handlers.Disconnect (Server.Public, Public); Server.Clients.Erase (Element); } delete SSL; } int UserCount; bool Dead; WinSSLClient * SSL; AddressWrapper Address; List <Server::Client::Internal *>::Element * Element; HANDLE FD; }; Server::Client::Client (Lacewing::Pump &Pump, HANDLE FD) : FDStream (Pump) { SetFD (FD, 0, true); } Server::Server (Lacewing::Pump &Pump) { lwp_init (); internal = new Server::Internal (*this, Pump); Tag = 0; } Server::~Server () { Unhost(); delete internal; } const int IdealPendingAcceptCount = 16; struct AcceptOverlapped { OVERLAPPED Overlapped; HANDLE FD; char addr_buffer [(sizeof (sockaddr_storage) + 16) * 2]; }; bool Server::Internal::IssueAccept () { AcceptOverlapped * overlapped = new (std::nothrow) AcceptOverlapped; memset (overlapped, 0, sizeof (AcceptOverlapped)); if (!overlapped) return false; if ((overlapped->FD = (HANDLE) WSASocket (lwp_socket_addr (Socket).ss_family, SOCK_STREAM, IPPROTO_TCP, 0, 0, WSA_FLAG_OVERLAPPED)) == INVALID_HANDLE_VALUE) { delete overlapped; return false; } lwp_disable_ipv6_only ((lwp_socket) overlapped->FD); DWORD bytes_received; /* TODO : Use AcceptEx to receive the first data? */ if (!AcceptEx (Socket, (SOCKET) overlapped->FD, overlapped->addr_buffer, 0, sizeof (sockaddr_storage) + 16, sizeof (sockaddr_storage) + 16, &bytes_received, (OVERLAPPED *) overlapped)) { int error = WSAGetLastError (); if (error != ERROR_IO_PENDING) return false; } ++ AcceptsPosted; return true; } static void ListenSocketCompletion (void * tag, OVERLAPPED * _overlapped, unsigned int bytes_transferred, int error) { Server::Internal * internal = (Server::Internal *) tag; AcceptOverlapped * overlapped = (AcceptOverlapped *) _overlapped; -- internal->AcceptsPosted; if (error) { delete overlapped; return; } while (internal->AcceptsPosted < IdealPendingAcceptCount) if (!internal->IssueAccept ()) break; setsockopt ((SOCKET) overlapped->FD, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, (char *) &internal->Socket, sizeof (internal->Socket)); sockaddr_storage * local_addr, * remote_addr; int local_addr_len, remote_addr_len; GetAcceptExSockaddrs ( overlapped->addr_buffer, 0, sizeof (sockaddr_storage) + 16, sizeof (sockaddr_storage) + 16, (sockaddr **) &local_addr, &local_addr_len, (sockaddr **) &remote_addr, &remote_addr_len ); Server::Client::Internal * client = new (std::nothrow) Server::Client::Internal (*internal, overlapped->FD); if (!client) { closesocket ((SOCKET) overlapped->FD); delete overlapped; return; } client->Address.Set (remote_addr); delete overlapped; ++ client->UserCount; if (internal->Handlers.Connect) internal->Handlers.Connect (internal->Public, client->Public); if (client->Dead) { delete client; return; } client->Element = internal->Clients.Push (client); -- client->UserCount; if (internal->Handlers.Receive) { client->Public.AddHandlerData (onClientData, client); client->Public.Read (-1); } } void Server::Host (int Port) { Filter Filter; Filter.LocalPort(Port); Host(Filter); } void Server::Host (Filter &Filter) { Unhost (); Lacewing::Error Error; if ((internal->Socket = lwp_create_server_socket (Filter, SOCK_STREAM, IPPROTO_TCP, Error)) == -1) { if (internal->Handlers.Error) internal->Handlers.Error (*this, Error); return; } if (listen (internal->Socket, SOMAXCONN) == -1) { Error.Add (WSAGetLastError ()); Error.Add ("Error listening"); if (internal->Handlers.Error) internal->Handlers.Error (*this, Error); return; } internal->Pump.Add ((HANDLE) internal->Socket, internal, ListenSocketCompletion); while (internal->AcceptsPosted < IdealPendingAcceptCount) if (!internal->IssueAccept ()) break; } void Server::Unhost () { if(!Hosting ()) return; closesocket (internal->Socket); internal->Socket = -1; } bool Server::Hosting () { return internal->Socket != -1; } int Server::ClientCount () { return internal->Clients.Size; } int Server::Port () { return lwp_socket_port (internal->Socket); } bool Server::LoadSystemCertificate (const char * StoreName, const char * CommonName, const char * Location) { if (Hosting () || CertificateLoaded ()) { Lacewing::Error Error; Error.Add ("Either the server is already hosting, or a certificate has already been loaded"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } if(!Location || !*Location) Location = "CurrentUser"; if(!StoreName || !*StoreName) StoreName = "MY"; int LocationID = -1; do { if(!strcasecmp(Location, "CurrentService")) { LocationID = 0x40000; /* CERT_SYSTEM_STORE_CURRENT_SERVICE */ break; } if(!strcasecmp(Location, "CurrentUser")) { LocationID = 0x10000; /* CERT_SYSTEM_STORE_CURRENT_USER */ break; } if(!strcasecmp(Location, "CurrentUserGroupPolicy")) { LocationID = 0x70000; /* CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY */ break; } if(!strcasecmp(Location, "LocalMachine")) { LocationID = 0x20000; /* CERT_SYSTEM_STORE_LOCAL_MACHINE */ break; } if(!strcasecmp(Location, "LocalMachineEnterprise")) { LocationID = 0x90000; /* CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE */ break; } if(!strcasecmp(Location, "LocalMachineGroupPolicy")) { LocationID = 0x80000; /* CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY */ break; } if(!strcasecmp(Location, "Services")) { LocationID = 0x50000; /* CERT_SYSTEM_STORE_SERVICES */ break; } if(!strcasecmp(Location, "Users")) { LocationID = 0x60000; /* CERT_SYSTEM_STORE_USERS */ break; } } while(0); if(LocationID == -1) { Lacewing::Error Error; Error.Add("Unknown certificate location: %s", Location); Error.Add("Error loading certificate"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } HCERTSTORE CertStore = CertOpenStore ( (LPCSTR) 9, /* CERT_STORE_PROV_SYSTEM_A */ 0, 0, LocationID, StoreName ); if(!CertStore) { Lacewing::Error Error; Error.Add(WSAGetLastError ()); Error.Add("Error loading certificate"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } PCCERT_CONTEXT Context = CertFindCertificateInStore ( CertStore, X509_ASN_ENCODING, 0, CERT_FIND_SUBJECT_STR_A, CommonName, 0 ); if(!Context) { int Code = GetLastError(); Context = CertFindCertificateInStore ( CertStore, PKCS_7_ASN_ENCODING, 0, CERT_FIND_SUBJECT_STR_A, CommonName, 0 ); if(!Context) { Lacewing::Error Error; Error.Add(Code); Error.Add("Error finding certificate in store"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } } SCHANNEL_CRED Creds; memset(&Creds, 0, sizeof (Creds)); Creds.dwVersion = SCHANNEL_CRED_VERSION; Creds.cCreds = 1; Creds.paCred = &Context; Creds.grbitEnabledProtocols = (0x80 | 0x40); /* SP_PROT_TLS1 */ { TimeStamp ExpiryTime; int Result = AcquireCredentialsHandleA ( 0, (SEC_CHAR *) UNISP_NAME_A, SECPKG_CRED_INBOUND, 0, &Creds, 0, 0, &internal->SSLCreds, &ExpiryTime ); if(Result != SEC_E_OK) { Lacewing::Error Error; Error.Add(Result); Error.Add("Error acquiring credentials handle"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } } internal->CertificateLoaded = true; return true; } bool Server::LoadCertificateFile (const char * Filename, const char * CommonName) { if (!lw_file_exists (Filename)) { Lacewing::Error Error; Error.Add("File not found: %s", Filename); Error.Add("Error loading certificate"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } if (Hosting ()) Unhost (); if(CertificateLoaded()) { FreeCredentialsHandle (&internal->SSLCreds); internal->CertificateLoaded = false; } HCERTSTORE CertStore = CertOpenStore ( (LPCSTR) 7 /* CERT_STORE_PROV_FILENAME_A */, X509_ASN_ENCODING, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, Filename ); bool PKCS7 = false; if(!CertStore) { CertStore = CertOpenStore ( (LPCSTR) 7 /* CERT_STORE_PROV_FILENAME_A */, PKCS_7_ASN_ENCODING, 0, CERT_STORE_OPEN_EXISTING_FLAG | CERT_STORE_READONLY_FLAG, Filename ); PKCS7 = true; if(!CertStore) { Lacewing::Error Error; Error.Add(GetLastError ()); Error.Add("Error opening certificate file : %s", Filename); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } } PCCERT_CONTEXT Context = CertFindCertificateInStore ( CertStore, PKCS7 ? PKCS_7_ASN_ENCODING : X509_ASN_ENCODING, 0, CERT_FIND_SUBJECT_STR_A, CommonName, 0 ); if(!Context) { int Code = GetLastError(); Context = CertFindCertificateInStore ( CertStore, PKCS7 ? X509_ASN_ENCODING : PKCS_7_ASN_ENCODING, 0, CERT_FIND_SUBJECT_STR_A, CommonName, 0 ); if(!Context) { Lacewing::Error Error; Error.Add(Code); Error.Add("Error finding certificate in store"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } } SCHANNEL_CRED Creds; memset(&Creds, 0, sizeof (Creds)); Creds.dwVersion = SCHANNEL_CRED_VERSION; Creds.cCreds = 1; Creds.paCred = &Context; Creds.grbitEnabledProtocols = 0xF0; /* SP_PROT_SSL3TLS1 */ { TimeStamp ExpiryTime; int Result = AcquireCredentialsHandleA ( 0, (SEC_CHAR *) UNISP_NAME_A, SECPKG_CRED_INBOUND, 0, &Creds, 0, 0, &internal->SSLCreds, &ExpiryTime ); if(Result != SEC_E_OK) { Lacewing::Error Error; Error.Add(Result); Error.Add("Error acquiring credentials handle"); if (internal->Handlers.Error) internal->Handlers.Error (internal->Public, Error); return false; } } internal->CertificateLoaded = true; return true; } bool Server::CertificateLoaded () { return internal->CertificateLoaded; } bool Server::CanNPN () { /* NPN is currently not available w/ schannel */ return false; } void Server::AddNPN (const char *) { } const char * Server::Client::NPN () { return ""; } Address &Server::Client::GetAddress () { return internal->Address; } Server::Client * Server::Client::Next () { return internal->Element->Next ? &(** internal->Element->Next)->Public : 0; } Server::Client * Server::FirstClient () { return internal->Clients.First ? &(** internal->Clients.First)->Public : 0; } void onClientData (Stream &stream, void * tag, const char * buffer, size_t size) { Server::Client::Internal * client = (Server::Client::Internal *) tag; Server::Internal &server = client->Server; server.Handlers.Receive (server.Public, client->Public, buffer, size); } void onClientClose (Stream &stream, void * tag) { Server::Client::Internal * client = (Server::Client::Internal *) tag; if (client->UserCount > 0) client->Dead = false; else delete client; } void Server::onReceive (Server::HandlerReceive onReceive) { internal->Handlers.Receive = onReceive; if (onReceive) { /* Setting onReceive to a handler */ if (!internal->Handlers.Receive) { for (List <Server::Client::Internal *>::Element * E = internal->Clients.First; E; E = E->Next) { (** E)->Public.AddHandlerData (onClientData, (** E)); } } return; } /* Setting onReceive to 0 */ for (List <Server::Client::Internal *>::Element * E = internal->Clients.First; E; E = E->Next) { (** E)->Public.RemoveHandlerData (onClientData, (** E)); } } AutoHandlerFunctions (Server, Connect) AutoHandlerFunctions (Server, Disconnect) AutoHandlerFunctions (Server, Error)
[ "jamie@lacewing-project.org" ]
jamie@lacewing-project.org
22c2393a2ceb2c6b2f9ab8a8e0345e2ccdd50489
4c5d17bf6c0d4901f972e88aac459088a270b301
/gd/l2cap/internal/scheduler.h
281bf8ef960e1f05bd8667a83bb44ca98019d56d
[ "Apache-2.0" ]
permissive
LineageOS/android_system_bt
87e40748871e6aa6911cd691f98d957251d01919
7d057c89ab62916a31934f6e9a6f527fe7fc87fb
refs/heads/lineage-19.1
2023-08-31T13:31:22.112619
2023-03-28T18:40:51
2023-07-07T13:02:57
75,635,542
22
245
NOASSERTION
2022-10-02T20:22:16
2016-12-05T14:59:35
C++
UTF-8
C++
false
false
2,401
h
/* * Copyright 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <cstdint> #include "common/bidi_queue.h" #include "l2cap/cid.h" #include "l2cap/classic/dynamic_channel_configuration_option.h" #include "l2cap/internal/channel_impl.h" #include "l2cap/internal/data_controller.h" #include "l2cap/internal/sender.h" #include "l2cap/l2cap_packets.h" #include "packet/base_packet_builder.h" #include "packet/packet_view.h" namespace bluetooth { namespace l2cap { namespace internal { /** * Handle the scheduling of packets through the l2cap stack. * For each attached channel, dequeue its outgoing packets and enqueue it to the given LinkQueueUpEnd, according to some * policy (cid). * * Note: If a channel cannot dequeue from ChannelQueueDownEnd so that the buffer for incoming packet is full, further * incoming packets will be dropped. */ class Scheduler { public: using UpperEnqueue = packet::PacketView<packet::kLittleEndian>; using UpperDequeue = packet::BasePacketBuilder; using UpperQueueDownEnd = common::BidiQueueEnd<UpperEnqueue, UpperDequeue>; using LowerEnqueue = UpperDequeue; using LowerDequeue = UpperEnqueue; using LowerQueueUpEnd = common::BidiQueueEnd<LowerEnqueue, LowerDequeue>; /** * Callback from the sender to indicate that the scheduler could dequeue number_packets from it */ virtual void OnPacketsReady(Cid cid, int number_packets) {} /** * Let the scheduler send the specified cid first. * Used by A2dp software encoding. */ virtual void SetChannelTxPriority(Cid cid, bool high_priority) {} /** * Called by data controller to indicate that a channel is closed and packets should be dropped */ virtual void RemoveChannel(Cid cid) {} virtual ~Scheduler() = default; }; } // namespace internal } // namespace l2cap } // namespace bluetooth
[ "hsz@google.com" ]
hsz@google.com
7da16fa2e4fa8777c63d8a5bf1c804a42cd097dd
cd8cce191c78f2b34d5690b65e038b6a85c187b3
/GFF2017Project/GFF/Timer.cpp
e7041e5268c23a8e05fcd4cd2eb61900aaf308ce
[]
no_license
masato12021996/GFF
a982db09366539ddf7b6dcacafc8e76c33541cf9
72aaa0a1c00cae564aaa27f6be175d11e79ae728
refs/heads/master
2020-12-24T12:39:38.984267
2017-02-02T08:54:44
2017-02-02T08:54:44
72,969,337
0
0
null
null
null
null
UTF-8
C++
false
false
746
cpp
#include "Timer.h" #include <time.h> Timer::Timer ( int time_limit ): _time_limit( time_limit ) { _timer_start = false; _is_clear = false; _clear_time = 0; } Timer::~Timer( ) { } int Timer::getTimeCount( ) { int time = ( _time_limit * CLOCKS_PER_SEC ) - ( clock( ) - _start_time ); if ( time < 0 ) { time = 0; } if ( _is_clear ) { time = _clear_time; } return time; } void Timer::timerStart( ) { _start_time = clock( ); _timer_start = true; } bool Timer::isTimerStart( ) { return _timer_start; } bool Timer::isTimeLimit( ) { return ( ( clock( ) - _start_time ) / CLOCKS_PER_SEC ) >= _time_limit; } void Timer::clear( ) { _clear_time = ( _time_limit * CLOCKS_PER_SEC ) - ( clock( ) - _start_time ); _is_clear = true; }
[ "sunshine233333@gmail.com" ]
sunshine233333@gmail.com
9d50f1cbb0ce913aa18ddf4521bdba4368d291ee
fb1c4f630a2d4db6a9211a1ca3362f461f6916fb
/Src/Hardware/MCU/STM32L4xx/Src/Adc_Mcu.h
4f51d58e5519e32c73a929e9234ab4ecd3c27a6c
[ "MIT" ]
permissive
ThBreuer/EmbSysLib
a7e445f86564a68387e47e10b4b652535236de1b
1372c29aa1b9a6400b7ac2aeeb23aa1ed09c37a4
refs/heads/main
2023-04-07T02:54:17.452717
2023-04-06T10:16:37
2023-04-06T10:16:37
53,247,108
1
1
null
null
null
null
UTF-8
C++
false
false
1,484
h
//******************************************************************* /*! \file Adc_Mcu.h \author Thomas Breuer (Bonn-Rhein-Sieg University of Applied Sciences) \date 23.03.2016 License: See file "LICENSE" */ //******************************************************************* #ifndef _HW_ADC_MCU_H #define _HW_ADC_MCU_H //******************************************************************* #include "Hardware/Common/Analog/Adc.h" //******************************************************************* namespace EmbSysLib { namespace Hw { //******************************************************************* /*! \class Adc_Mcu \brief Implementation of the analg to digital converter (ADC) \example HwAdc.cpp */ class Adc_Mcu : public Adc { public: //--------------------------------------------------------------- /*! Initialize the ADC hardware \param timer Reference to a timer object for auto trigger conversion */ Adc_Mcu( Timer &timer ); private: //--------------------------------------------------------------- virtual WORD getResult( void ); //--------------------------------------------------------------- virtual void startCh( BYTE ch ); //--------------------------------------------------------------- virtual void configCh( BYTE ch, BYTE para = 0 ); public: //--------------------------------------------------------------- static Adc *adcPtr; }; //class Adc_Mcu } } //namespace #endif
[ "thomas.breuer@h-brs.de" ]
thomas.breuer@h-brs.de
bb400a3021584be3a3d14f8e57da9b9cdee517d0
6c2fc701cb4782c84e3334dccdd577c4d0c94cab
/RenderTiny_Device.cpp
3289fae70b115033bf73dc846fd52da81c0a692c
[]
no_license
yupingzhang/Bitcamp2014
507633706d4afa6db0fe437865bc0dcd04c1eeda
737d344bbf6f4a5e3aa3c0d1aee82742f95f8f22
refs/heads/master
2020-08-26T19:39:05.019395
2014-04-06T12:34:15
2014-04-06T12:34:15
18,483,808
1
0
null
null
null
null
UTF-8
C++
false
false
12,681
cpp
/************************************************************************************ Filename : RenderTiny_Device.cpp Content : Platform renderer for simple scene graph - implementation Created : September 6, 2012 Authors : Andrew Reisse Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ************************************************************************************/ #include "RenderTiny_Device.h" #include "Kernel/OVR_Log.h" namespace OVR { namespace RenderTiny { void Model::Render(const Matrix4f& ltw, RenderDevice* ren) { if (Visible) { Matrix4f m = ltw * GetMatrix(); ren->Render(m, this); } } void Container::Render(const Matrix4f& ltw, RenderDevice* ren) { Matrix4f m = ltw * GetMatrix(); for(unsigned i = 0; i < Nodes.GetSize(); i++) { Nodes[i]->Render(m, ren); } } void Scene::Render(RenderDevice* ren, const Matrix4f& view) { Lighting.Update(view, LightPos); ren->SetLighting(&Lighting); World.Render(view, ren); } UInt16 CubeIndices[] = { 0, 1, 3, 3, 1, 2, 5, 4, 6, 6, 4, 7, 8, 9, 11, 11, 9, 10, 13, 12, 14, 14, 12, 15, 16, 17, 19, 19, 17, 18, 21, 20, 22, 22, 20, 23 }; void Model::AddSolidColorBox(float x1, float y1, float z1, float x2, float y2, float z2, Color c) { float t; if(x1 > x2) { t = x1; x1 = x2; x2 = t; } if(y1 > y2) { t = y1; y1 = y2; y2 = t; } if(z1 > z2) { t = z1; z1 = z2; z2 = t; } // Cube vertices and their normals. Vector3f CubeVertices[][3] = { Vector3f(x1, y2, z1), Vector3f(z1, x1), Vector3f(0.0f, 1.0f, 0.0f), Vector3f(x2, y2, z1), Vector3f(z1, x2), Vector3f(0.0f, 1.0f, 0.0f), Vector3f(x2, y2, z2), Vector3f(z2, x2), Vector3f(0.0f, 1.0f, 0.0f), Vector3f(x1, y2, z2), Vector3f(z2, x1), Vector3f(0.0f, 1.0f, 0.0f), Vector3f(x1, y1, z1), Vector3f(z1, x1), Vector3f(0.0f, -1.0f, 0.0f), Vector3f(x2, y1, z1), Vector3f(z1, x2), Vector3f(0.0f, -1.0f, 0.0f), Vector3f(x2, y1, z2), Vector3f(z2, x2), Vector3f(0.0f, -1.0f, 0.0f), Vector3f(x1, y1, z2), Vector3f(z2, x1), Vector3f(0.0f, -1.0f, 0.0f), Vector3f(x1, y1, z2), Vector3f(z2, y1), Vector3f(-1.0f, 0.0f, 0.0f), Vector3f(x1, y1, z1), Vector3f(z1, y1), Vector3f(-1.0f, 0.0f, 0.0f), Vector3f(x1, y2, z1), Vector3f(z1, y2), Vector3f(-1.0f, 0.0f, 0.0f), Vector3f(x1, y2, z2), Vector3f(z2, y2), Vector3f(-1.0f, 0.0f, 0.0f), Vector3f(x2, y1, z2), Vector3f(z2, y1), Vector3f(1.0f, 0.0f, 0.0f), Vector3f(x2, y1, z1), Vector3f(z1, y1), Vector3f(1.0f, 0.0f, 0.0f), Vector3f(x2, y2, z1), Vector3f(z1, y2), Vector3f(1.0f, 0.0f, 0.0f), Vector3f(x2, y2, z2), Vector3f(z2, y2), Vector3f(1.0f, 0.0f, 0.0f), Vector3f(x1, y1, z1), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, -1.0f), Vector3f(x2, y1, z1), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, -1.0f), Vector3f(x2, y2, z1), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, -1.0f), Vector3f(x1, y2, z1), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, -1.0f), Vector3f(x1, y1, z2), Vector3f(x1, y1), Vector3f(0.0f, 0.0f, 1.0f), Vector3f(x2, y1, z2), Vector3f(x2, y1), Vector3f(0.0f, 0.0f, 1.0f), Vector3f(x2, y2, z2), Vector3f(x2, y2), Vector3f(0.0f, 0.0f, 1.0f), Vector3f(x1, y2, z2), Vector3f(x1, y2), Vector3f(0.0f, 0.0f, 1.0f) }; UInt16 startIndex = GetNextVertexIndex(); enum { CubeVertexCount = sizeof(CubeVertices) / sizeof(CubeVertices[0]), CubeIndexCount = sizeof(CubeIndices) / sizeof(CubeIndices[0]) }; for(int v = 0; v < CubeVertexCount; v++) { AddVertex(Vertex(CubeVertices[v][0], c, CubeVertices[v][1].x, CubeVertices[v][1].y, CubeVertices[v][2])); } // Renumber indices for(int i = 0; i < CubeIndexCount / 3; i++) { AddTriangle(CubeIndices[i * 3] + startIndex, CubeIndices[i * 3 + 1] + startIndex, CubeIndices[i * 3 + 2] + startIndex); } } //------------------------------------------------------------------------------------- void ShaderFill::Set(PrimitiveType prim) const { Shaders->Set(prim); for(int i = 0; i < 8; i++) { if(Textures[i]) { Textures[i]->Set(i); } } } //------------------------------------------------------------------------------------- // ***** Rendering RenderDevice::RenderDevice() : CurPostProcess(PostProcess_None), SceneColorTexW(0), SceneColorTexH(0), SceneRenderScale(1), Distortion(1.0f, 0.18f, 0.115f), PostProcessShaderActive(PostProcessShader_DistortionAndChromAb) { PostProcessShaderRequested = PostProcessShaderActive; } ShaderFill* RenderDevice::CreateTextureFill(RenderTiny::Texture* t) { ShaderSet* shaders = CreateShaderSet(); shaders->SetShader(LoadBuiltinShader(Shader_Vertex, VShader_MVP)); shaders->SetShader(LoadBuiltinShader(Shader_Fragment, FShader_Texture)); ShaderFill* f = new ShaderFill(*shaders); f->SetTexture(0, t); return f; } void RenderDevice::SetLighting(const LightingParams* lt) { if (!LightingBuffer) LightingBuffer = *CreateBuffer(); LightingBuffer->Data(Buffer_Uniform, lt, sizeof(LightingParams)); SetCommonUniformBuffer(1, LightingBuffer); } void RenderDevice::SetSceneRenderScale(float ss) { SceneRenderScale = ss; pSceneColorTex = NULL; } void RenderDevice::SetViewport(const Viewport& vp) { VP = vp; if (CurPostProcess == PostProcess_Distortion) { Viewport svp = vp; svp.w = (int)ceil(SceneRenderScale * vp.w); svp.h = (int)ceil(SceneRenderScale * vp.h); svp.x = (int)ceil(SceneRenderScale * vp.x); svp.y = (int)ceil(SceneRenderScale * vp.y); SetRealViewport(svp); } else { SetRealViewport(vp); } } bool RenderDevice::initPostProcessSupport(PostProcessType pptype) { if (pptype != PostProcess_Distortion) return true; if (PostProcessShaderRequested != PostProcessShaderActive) { pPostProcessShader.Clear(); PostProcessShaderActive = PostProcessShaderRequested; } if (!pPostProcessShader) { Shader *vs = LoadBuiltinShader(Shader_Vertex, VShader_PostProcess); Shader *ppfs = NULL; if (PostProcessShaderActive == PostProcessShader_Distortion) { ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcess); } else if (PostProcessShaderActive == PostProcessShader_DistortionAndChromAb) { ppfs = LoadBuiltinShader(Shader_Fragment, FShader_PostProcessWithChromAb); } else OVR_ASSERT(false); pPostProcessShader = *CreateShaderSet(); pPostProcessShader->SetShader(vs); pPostProcessShader->SetShader(ppfs); } int texw = (int)ceil(SceneRenderScale * WindowWidth), texh = (int)ceil(SceneRenderScale * WindowHeight); // If pSceneColorTex is already created and is of correct size, we are done. // It's important to check width/height in case window size changed. if (pSceneColorTex && (texw == SceneColorTexW) && (texh == SceneColorTexH)) { return true; } pSceneColorTex = *CreateTexture(Texture_RGBA | Texture_RenderTarget | Params.Multisample, texw, texh, NULL); if (!pSceneColorTex) { return false; } SceneColorTexW = texw; SceneColorTexH = texh; pSceneColorTex->SetSampleMode(Sample_ClampBorder | Sample_Linear); if (!pFullScreenVertexBuffer) { pFullScreenVertexBuffer = *CreateBuffer(); const RenderTiny::Vertex QuadVertices[] = { Vertex(Vector3f(0, 1, 0), Color(1, 1, 1, 1), 0, 0), Vertex(Vector3f(1, 1, 0), Color(1, 1, 1, 1), 1, 0), Vertex(Vector3f(0, 0, 0), Color(1, 1, 1, 1), 0, 1), Vertex(Vector3f(1, 0, 0), Color(1, 1, 1, 1), 1, 1) }; pFullScreenVertexBuffer->Data(Buffer_Vertex, QuadVertices, sizeof(QuadVertices)); } return true; } void RenderDevice::SetProjection(const Matrix4f& proj) { Proj = proj; SetWorldUniforms(proj); } void RenderDevice::BeginScene(PostProcessType pptype) { BeginRendering(); if ((pptype != PostProcess_None) && initPostProcessSupport(pptype)) { CurPostProcess = pptype; } else { CurPostProcess = PostProcess_None; } if (CurPostProcess == PostProcess_Distortion) { SetRenderTarget(pSceneColorTex); SetViewport(VP); } else { SetRenderTarget(0); } SetWorldUniforms(Proj); } void RenderDevice::FinishScene() { if (CurPostProcess == PostProcess_None) return; SetRenderTarget(0); SetRealViewport(VP); FinishScene1(); CurPostProcess = PostProcess_None; } void RenderDevice::FinishScene1() { // Clear with black Clear(0.0f, 0.0f, 0.0f, 1.0f); float w = float(VP.w) / float(WindowWidth), h = float(VP.h) / float(WindowHeight), x = float(VP.x) / float(WindowWidth), y = float(VP.y) / float(WindowHeight); float as = float(VP.w) / float(VP.h); // We are using 1/4 of DistortionCenter offset value here, since it is // relative to [-1,1] range that gets mapped to [0, 0.5]. pPostProcessShader->SetUniform2f("LensCenter", x + (w + Distortion.XCenterOffset * 0.5f)*0.5f, y + h*0.5f); pPostProcessShader->SetUniform2f("ScreenCenter", x + w*0.5f, y + h*0.5f); // MA: This is more correct but we would need higher-res texture vertically; we should adopt this // once we have asymmetric input texture scale. float scaleFactor = 1.0f / Distortion.Scale; pPostProcessShader->SetUniform2f("Scale", (w/2) * scaleFactor, (h/2) * scaleFactor * as); pPostProcessShader->SetUniform2f("ScaleIn", (2/w), (2/h) / as); pPostProcessShader->SetUniform4f("HmdWarpParam", Distortion.K[0], Distortion.K[1], Distortion.K[2], Distortion.K[3]); if (PostProcessShaderRequested == PostProcessShader_DistortionAndChromAb) { pPostProcessShader->SetUniform4f("ChromAbParam", Distortion.ChromaticAberration[0], Distortion.ChromaticAberration[1], Distortion.ChromaticAberration[2], Distortion.ChromaticAberration[3]); } Matrix4f texm(w, 0, 0, x, 0, h, 0, y, 0, 0, 0, 0, 0, 0, 0, 1); pPostProcessShader->SetUniform4x4f("Texm", texm); Matrix4f view(2, 0, 0, -1, 0, 2, 0, -1, 0, 0, 0, 0, 0, 0, 0, 1); ShaderFill fill(pPostProcessShader); fill.SetTexture(0, pSceneColorTex); Render(&fill, pFullScreenVertexBuffer, NULL, view, 0, 4, Prim_TriangleStrip); } int GetNumMipLevels(int w, int h) { int n = 1; while(w > 1 || h > 1) { w >>= 1; h >>= 1; n++; } return n; } void FilterRgba2x2(const UByte* src, int w, int h, UByte* dest) { for(int j = 0; j < (h & ~1); j += 2) { const UByte* psrc = src + (w * j * 4); UByte* pdest = dest + ((w >> 1) * (j >> 1) * 4); for(int i = 0; i < w >> 1; i++, psrc += 8, pdest += 4) { pdest[0] = (((int)psrc[0]) + psrc[4] + psrc[w * 4 + 0] + psrc[w * 4 + 4]) >> 2; pdest[1] = (((int)psrc[1]) + psrc[5] + psrc[w * 4 + 1] + psrc[w * 4 + 5]) >> 2; pdest[2] = (((int)psrc[2]) + psrc[6] + psrc[w * 4 + 2] + psrc[w * 4 + 6]) >> 2; pdest[3] = (((int)psrc[3]) + psrc[7] + psrc[w * 4 + 3] + psrc[w * 4 + 7]) >> 2; } } } }}
[ "draupnir37@gmail.com" ]
draupnir37@gmail.com
16a5cbbabac9881edcff7c74f92d2a3d38c66b37
08b8cf38e1936e8cec27f84af0d3727321cec9c4
/data/crawl/wget/old_hunk_254.cpp
ef4f9765682a5b471a835bb358edfa27676de6c7
[]
no_license
ccdxc/logSurvey
eaf28e9c2d6307140b17986d5c05106d1fd8e943
6b80226e1667c1e0760ab39160893ee19b0e9fb1
refs/heads/master
2022-01-07T21:31:55.446839
2018-04-21T14:12:43
2018-04-21T14:12:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
421
cpp
{ int type; if (opt.private_key_type != opt.cert_type) { /* GnuTLS can't handle this */ logprintf (LOG_NOTQUIET, _("ERROR: GnuTLS requires the key and the \ cert to be of the same type.\n")); } type = key_type_to_gnutls_type (opt.private_key_type); gnutls_certificate_set_x509_key_file (credentials, opt.cert_file, opt.private_key, type); } if (opt.ca_cert)
[ "993273596@qq.com" ]
993273596@qq.com
cc70ccf3f97b84a13d76c18f01ed312d3e01db1f
dae5801e04489f1dce1ba00c6831cd044bd009f1
/_backup_PCDWrapperLib.cpp
8078e041dd46742d1542d4486eafe9a3d004e5c9
[]
no_license
madingo87/netica
b5b9d54814806b173f3aa7884a4c439246ebbabe
ef7a4d6e21bee78a8f9b134d757a93e49dd0eb5b
refs/heads/master
2021-01-23T21:16:00.379576
2016-11-17T19:21:17
2016-11-17T19:21:17
38,059,583
0
0
null
null
null
null
ISO-8859-1
C++
false
false
5,430
cpp
// PCDWrapperLib.cpp : Definiert die exportierten Funktionen für die DLL-Anwendung. // // Dies ist die Haupt-DLL. #include "stdafx.h" //#include "PCDWrapperLib.h" #include <iostream> #include <cstring> #include <string> #include <vector> #undef max #undef min #include <pcl/io/pcd_io.h> #include <pcl/features/normal_3d.h> #include <pcl/features/our_cvfh.h> #include <pcl/visualization/pcl_plotter.h> extern "C" __declspec(dllexport) int evaluatePCD(const char* filename, bool print, const char* exportFile, int offset, bool plot); int evaluatePCD(const char* filename, bool print, const char* exportFile, int offset, bool plot) { // Cloud for storing the object. pcl::PointCloud<pcl::PointXYZ>::Ptr object(new pcl::PointCloud<pcl::PointXYZ>); // Object for storing the normals. pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>); // Object for storing the OUR-CVFH descriptors. pcl::PointCloud<pcl::VFHSignature308>::Ptr descriptors(new pcl::PointCloud<pcl::VFHSignature308>); // Note: you should have performed preprocessing to cluster out the object // from the cloud, and save it to this individual file. //const int num_required_args = 5; std::cout << "\nourCVFH -- 160408\n" "This program loads a Point Cloud Data File and extracts ourCVFH features from it. \n\n" "\tParameters: \n" "\t<on|off> print the histogram values in the console\n" "\t<offset> set an offset to the numbering of the histogram bins (needed for original purpose)\n" "\t[plot] optionally plot the histrogram\n\n" "\tUsage: \n" "\tourCVFH <path_pcd_file_list> <on|off> <path_output> <offset> [plot]\n" << std::endl; typedef std::vector<std::string> myList; std::string line; //const char * filename = "/home/basti/wodpcd_test_klein/pcd_pipeline_winzig.txt"; std::ifstream filelist; myList pathFromFile; filelist.open(filename, ios::in); if (filelist.is_open()) { while (getline(filelist, line)) { pathFromFile.push_back(line); } filelist.close(); } else { std::cout << "Unable to open file\n"; } for (unsigned int i = 0; i< pathFromFile.size(); i++){ // Read a PCD file from disk. if (pcl::io::loadPCDFile<pcl::PointXYZ>(pathFromFile.at(i), *object) != 0) { std::cout << "Unable to open or read file \n"; return -1; } // Estimate the normals. pcl::NormalEstimation<pcl::PointXYZ, pcl::Normal> normalEstimation; normalEstimation.setInputCloud(object); normalEstimation.setRadiusSearch(0.03); pcl::search::KdTree<pcl::PointXYZ>::Ptr kdtree(new pcl::search::KdTree<pcl::PointXYZ>); normalEstimation.setSearchMethod(kdtree); normalEstimation.compute(*normals); // OUR-CVFH estimation object. pcl::OURCVFHEstimation<pcl::PointXYZ, pcl::Normal, pcl::VFHSignature308> ourcvfh; ourcvfh.setInputCloud(object); ourcvfh.setInputNormals(normals); ourcvfh.setSearchMethod(kdtree); ourcvfh.setEPSAngleThreshold(5.0 / 180.0 * M_PI); // 5 degrees. ourcvfh.setCurvatureThreshold(1.0); ourcvfh.setNormalizeBins(false); // Set the minimum axis ratio between the SGURF axes. At the disambiguation phase, // this will decide if additional Reference Frames need to be created, if ambiguous. ourcvfh.setAxisRatio(0.8); ourcvfh.compute(*descriptors); std::cout << "\nBerechnung von OUR-CVFH abgeschlossen!" << std::endl; std::cout << "Anzahl Punkte in Wolke: " << object->points.size() << std::endl; int histo_bins = 308; // 308 is the standard of CVFH int histogram_std_idx = 0; double xy[2]; // print histogram values int arg_pos = 2; if (print) { std::cout << "\nAusgabe der Histogrammwerte:" << std::endl; std::cout << "----------------------------" << std::endl; for (int binIdx = 0; binIdx < histo_bins; ++binIdx){ xy[0] = binIdx; std::cout << binIdx; xy[1] = descriptors->points[histogram_std_idx].histogram[binIdx]; std::cout << ": " << descriptors->points[histogram_std_idx].histogram[binIdx] << std::endl; } } // write histogram values to file std::ofstream output_file; std::string s = pathFromFile.at(i); unsigned first = s.find_last_of("/"); unsigned last = s.find("."); std::string token = s.substr(first + 1, (last - 1) - first); std::cout << "output: " << exportFile << std::endl; std::string token2 = exportFile + token + ".txt"; // output path from argv and filename from token std::cout << "asdaS: " << token2 << std::endl; output_file.open(token2.c_str(), ios::out | ios::app); bool gnuplot = false; for (int binIdx = 0; binIdx < histo_bins; ++binIdx){ if (descriptors->points[histogram_std_idx].histogram[binIdx] != 0) //zero not needed for libsvm if (gnuplot){ output_file << (binIdx + offset) << " " << descriptors->points[histogram_std_idx].histogram[binIdx] << "\n"; } else { output_file << (binIdx + offset) << ":" << descriptors->points[histogram_std_idx].histogram[binIdx] << " "; } } output_file << "\n"; output_file.close(); // visualize the histogram if (plot) { std::cout << "\nVisualisieren der Histogrammwerte startet!" << std::endl; pcl::visualization::PCLPlotter plotter; // (cloud, horizontal length of histogram, name of legend) plotter.addFeatureHistogram(*descriptors, histo_bins, filename, 1000, 1000); plotter.setTitle("OUR-CVFH Histogram"); plotter.setXTitle("histogram bins"); plotter.setYTitle("histogram values"); plotter.plot(); } } }
[ "madingo87@gmx.de" ]
madingo87@gmx.de
c8514a75cafcdb9c34b83e64de8fb15cedbaeed4
897633afb50a5ddc0e9f6ec373253044041ec508
/GrpNVMWriteUncorrectCmd/grpNVMWriteUncorrectCmd.cpp
3592ad57af72b6f10c89a44de0ce4bfcea4cd44b
[ "Apache-2.0" ]
permissive
dtseng-zz/tnvme
556791cbffa41329231a896ef40a07173ce79c13
3387cf70f748a46632b9824a36616fe06e1893f1
refs/heads/master
2021-05-29T03:51:08.857145
2012-05-21T16:41:21
2012-05-21T16:41:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,581
cpp
/* * Copyright (c) 2011, Intel Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "tnvme.h" #include "../Exception/frmwkEx.h" #include "grpNVMWriteUncorrectCmd.h" #include "identify_r10b.h" namespace GrpNVMWriteUncorrectCmd { GrpNVMWriteUncorrectCmd::GrpNVMWriteUncorrectCmd(size_t grpNum, SpecRev specRev, ErrorRegs errRegs, int fd) : Group(grpNum, specRev, "GrpNVMWriteUncorrectCmd", "NVM cmd set compare test cases") { // For complete details about the APPEND_TEST_AT_?LEVEL() macros: // "https://github.com/nvmecompliance/tnvme/wiki/Test-Numbering" and // "https://github.com/nvmecompliance/tnvme/wiki/Test-Strategy switch (mSpecRev) { case SPECREV_10b: APPEND_TEST_AT_XLEVEL(Identify_r10b, fd, GrpNVMWriteUncorrectCmd, errRegs) break; default: case SPECREVTYPE_FENCE: throw FrmwkEx(HERE, "Object created with unknown SpecRev=%d", specRev); } } GrpNVMWriteUncorrectCmd::~GrpNVMWriteUncorrectCmd() { // mTests deallocated in parent } } // namespace
[ "todd.rentmeester@intel.com" ]
todd.rentmeester@intel.com
c525ad00e43741481e1810fa4908790c1284283c
393808e50ff4a94356090a71d304d5bc07d9e710
/lte/gateway/c/core/oai/tasks/amf/amf_app_transport.cpp
4d2cfe4c0b71af8f117de9dd1d3dfe8ec648ac24
[ "BSD-3-Clause" ]
permissive
hcgatewood/magma
f1ae8130f81c54c923c4f15ef72b68d83eace6ad
947e07422a734aa6e1411f277afd7af9dceaafcb
refs/heads/master
2022-05-24T08:20:06.681402
2022-03-17T00:19:16
2022-03-17T00:19:16
253,992,270
0
0
NOASSERTION
2021-12-14T21:55:05
2020-04-08T05:18:54
Go
UTF-8
C++
false
false
2,655
cpp
/** * Copyright 2020 The Magma Authors. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. * * 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 <sstream> #include <thread> #ifdef __cplusplus extern "C" { #endif #include "lte/gateway/c/core/oai/lib/itti/intertask_interface.h" #include "lte/gateway/c/core/oai/lib/itti/intertask_interface_types.h" #include "lte/gateway/c/core/oai/common/log.h" #include "lte/gateway/c/core/oai/common/dynamic_memory_check.h" #ifdef __cplusplus } #endif #include "lte/gateway/c/core/oai/common/common_defs.h" #include "lte/gateway/c/core/oai/tasks/amf/amf_app_state_manager.h" namespace magma5g { extern task_zmq_ctx_t amf_app_task_zmq_ctx; /* Handles NAS encoded message and sends it to NGAP task */ int amf_app_handle_nas_dl_req(const amf_ue_ngap_id_t ue_id, bstring nas_msg, nas5g_error_code_t transaction_status) { OAILOG_FUNC_IN(LOG_AMF_APP); MessageDef* message_p = NULL; int rc = RETURNok; gnb_ue_ngap_id_t gnb_ue_ngap_id = 0; message_p = itti_alloc_new_message(TASK_AMF_APP, NGAP_NAS_DL_DATA_REQ); amf_app_desc_t* amf_app_desc_p = get_amf_nas_state(false); if (!amf_app_desc_p) { OAILOG_ERROR( LOG_AMF_APP, "Downlink NAS transport: Failed to get global amf_app_desc context \n"); OAILOG_FUNC_RETURN(LOG_AMF_APP, RETURNerror); } ue_m5gmm_context_s* ue_context = amf_ue_context_exists_amf_ue_ngap_id(ue_id); if (ue_context) { gnb_ue_ngap_id = ue_context->gnb_ue_ngap_id; } else { OAILOG_ERROR(LOG_AMF_APP, "ue context not found for the UE ID = " AMF_UE_NGAP_ID_FMT, ue_id); OAILOG_FUNC_RETURN(LOG_AMF_APP, rc); } NGAP_NAS_DL_DATA_REQ(message_p).gnb_ue_ngap_id = gnb_ue_ngap_id; NGAP_NAS_DL_DATA_REQ(message_p).amf_ue_ngap_id = ue_id; NGAP_NAS_DL_DATA_REQ(message_p).nas_msg = bstrcpy(nas_msg); bdestroy_wrapper(&nas_msg); message_p->ittiMsgHeader.imsi = ue_context->amf_context.imsi64; rc = amf_send_msg_to_task(&amf_app_task_zmq_ctx, TASK_NGAP, message_p); if (transaction_status != M5G_AS_SUCCESS) { ue_context_release_command(ue_id, ue_context->gnb_ue_ngap_id, NGAP_NAS_AUTHENTICATION_FAILURE); } OAILOG_FUNC_RETURN(LOG_AMF_APP, rc); } } // namespace magma5g
[ "noreply@github.com" ]
noreply@github.com
5666538c8693c2187752b59e0a75e735822c4ab8
07c3b562136e85204420b0136f69ab7de165d1a5
/ExampleDemo/facepp/PupilGUI.h
cffd7b00cce5bdb2ca89e08c31a86dcd07d4905a
[]
no_license
hjimce/EyeLabelDemo
740bc6fef040929c6eb639dcf5bf585201a10de6
286b763164891c0ce4b9c158e9108a3d55a1ab56
refs/heads/master
2020-12-24T05:38:22.003793
2016-06-18T09:56:47
2016-06-18T09:56:47
60,592,285
0
1
null
null
null
null
GB18030
C++
false
false
634
h
#pragma once #include "faceppapi.h" #include "Vec.h" #include <vector> using namespace std; class CPupilGUI { public: CPupilGUI(void); ~CPupilGUI(void); CPupilGUI(BYTE* pImage, int nWidth, int nHeight); void Render(CDC*pDC); FACEPP_FACEINFO m_face_detection; bool isface; private: int m_width; int m_height; bool face_detection(byte *pData,int nWidth,int nHeight ,FACEPP_FACEINFO &face0); byte * ConvertToGray(BYTE* pImage, int nWidth, int nHeight); void GenerateCircle(float radius,vec2 center,vector<CPoint>&Reuslt); vector<CPoint>m_result;//最后的结果 vector<CPoint>m_inicir;//初始轮廓 DWORD m_Times; };
[ "hjimce1" ]
hjimce1
1e90b6650ee92768f7090cea13d7410703bdb0a7
c748c9ee82b645e6912cb08f55a4d602e17b2e38
/2/2.1.cpp
89753994e4ab266b23e26492eb925ac38667edea
[]
no_license
gpokat/cci_tasks
711ee9d13444f2c8d78eb75f63c5d21fa107e93f
adbd1da1f7df042f5c9cba01cb605021e37b69f2
refs/heads/master
2023-01-24T18:20:49.158341
2020-12-06T19:09:10
2020-12-06T19:09:10
257,710,209
0
0
null
null
null
null
UTF-8
C++
false
false
1,881
cpp
//Remove Dups: Write code to remove duplicates from an unsorted linked list. //FOLLOW UP //How would you solve this problem if a temporary buffer is not allowed? struct Node { Node *next; int value; //the data member //initialize constructor (set up next to nullptr by default) //need for right init. the node members }; //Node *header=new Node(); //header->next=first_node; //header->value=nullptr; //with extra buffer void RemoveDuplicatesFromULL() { Node *cur_node = header->next; //first_node Node *prev_node = header; vector<int> buff; //traversal throught linkedlist while (cur_node != nullptr) { int cur_value = cur_node->value; if (find(buff.begin(), buff.end(), cur_value) == buff.end()) { buff.emplace_back(cur_value); prev_node = cur_node; } else { prev_node->next = cur_node->next; } cur_node = cur_node->next; } } //FOLLOW UP //without extra buffer //avoid buffer, but add one extra loop void RemoveDuplicatesFromULL() { //vector<int> buff; Node *tmp_node = header->next; //traversal throught linkedlist //extra cycle while (tmp_node != nullptr) { Node *cur_node = tmp_node->next; //first_node Node *prev_node = tmp_node; //traversal throught linkedlist while (cur_node != nullptr) { int cur_value = cur_node->value; //if (find(buff.begin(), buff.end(), cur_value) == buff.end()) if (tmp_node->value != cur_value) { // buff.emplace_back(cur_value); prev_node = cur_node; } else { prev_node->next = cur_node->next; } cur_node = cur_node->next; } tmp_node = tmp_node->next; } }
[ "pokat.gleb@gmail.com" ]
pokat.gleb@gmail.com
f112d967927dfe7dfd66c61b98cbfda60d1beb64
b60c5b26b4d8c7f2ffbd10546352ebb103b180cd
/src/log/LoggerManager.h
2031cd97d776d60d973ec9e0426740454e0050d6
[]
no_license
BGCX261/zipper-beta-hg-to-git
b0df9b5ac2d26ea45e41f073a1011dcf93047838
19e046de1c8b4e5dee4743cc353427588e6fffc8
refs/heads/master
2020-04-06T04:05:41.774723
2013-08-22T19:34:47
2013-08-22T19:34:47
41,593,840
0
0
null
null
null
null
UTF-8
C++
false
false
2,496
h
/* * File: LoggerManager.h * Author: Daniela * * Created on March 21, 2013, 6:04 PM */ #ifndef LOGGERMANAGER_H #define LOGGERMANAGER_H #include "Logger.h" #include "FileLogger.h" #define DEBUG(format, ...){g_logger->log(DEBUG, __PRETTY_FUNCTION__, format, __VA_ARGS__);} #define INFO(format, ...){g_logger->log(INFO, __PRETTY_FUNCTION__, format, __VA_ARGS__);} #define WARN(format, ...){g_logger->log(WARN, __PRETTY_FUNCTION__, format, __VA_ARGS__);} #define ERROR(format, ...){g_logger->log(ERROR, __PRETTY_FUNCTION__, format, __VA_ARGS__);} #define BUFFER_GROW_SIZE 128 /** * Class in charge of manage the enabled loggers. */ class LoggerManager { public: /** * Instantiate a logger manager that supports 2 loggers. */ LoggerManager(); LoggerManager(const LoggerManager& orig); /** * Free the memory used for the logger list. */ virtual ~LoggerManager(); /** * Perform the log action in the enabled loggers. * * @param level Logging level * @param format Format for the message to log * @param ... Data to format the message */ void log(LoggingLevel level, const char* source, const char* format, ...); /** * Create a logger and add it to the logger list for the manager. * * @param filename Name of the file. * * @return True if the logger was added successfully. False in other case. */ bool addFileLogger(const char* filename); /** * Return the list of enables loggers. * * @return List of loggers */ Logger** getLoggers() { return loggers_; } /** * Get the logger count in this manager. * * @return Loggers count. */ int getLoggersCount() const { return size_; } private: /** * Release memory used by the buffer. */ void freeBuffer(); /** * Resize the buffer size. */ void resizeBuffer(); /** * List of enabled loggers. */ Logger** loggers_; /** * Capacity of the list. */ int capacity_; /** * Loggers count. */ int size_; /** * Buffer to merge pattern and varargs to pass the message to the added * loggers. */ char* buffer_; /** * Manage the current buffer size. */ int bufferSize_; }; #endif /* LOGGERMANAGER_H */
[ "daniela11290@gmail.com" ]
daniela11290@gmail.com
a4d1ffac11b46faf24a7074ee53ffc0ea523d555
1897ae5489b64fae9aa083d62f51254cfe52d26f
/II semester/programming-techniques/labovi/T8/Z5/main.cpp
bfe6d6533bfad1734402dd351c616067a2483cac
[ "Unlicense", "LicenseRef-scancode-proprietary-license" ]
permissive
MasovicHaris/etf-alles
f1bfe40cab2de06a26ceb46bdb5c47de2e6db73e
0ab1ad83d00fafc69b38266edd875bce08c1fc9e
refs/heads/main
2022-01-01T18:22:54.072030
2021-12-22T09:05:05
2021-12-22T09:05:05
138,169,714
9
15
Unlicense
2020-03-29T23:36:50
2018-06-21T12:50:51
C++
UTF-8
C++
false
false
2,077
cpp
//TP 2016/2017: Tutorijal 8, Zadatak 5 #include <iostream> template <typename TipElemenata> struct Cvor { TipElemenata element; Cvor *veza; }; template <typename TipElemenata> Cvor<TipElemenata> *KreirajPovezanuListu(TipElemenata zavrsni) { Cvor<TipElemenata> *pocetak(nullptr), *prethodni; for(;;) { TipElemenata broj; std::cin >> broj; if(broj == zavrsni) break; Cvor<TipElemenata> *novi(new Cvor<TipElemenata>); // Kreiranje novog čvora novi->element = broj; novi->veza = nullptr; if(!pocetak) pocetak = novi; // Prvi čvor... else prethodni->veza = novi; // Svi osim prvog... prethodni = novi; } return pocetak; } template <typename TipElemenata> int BrojElemenata(Cvor<TipElemenata> *pocetak) { int brojac(0); for(auto *p = pocetak; p != nullptr; p = p->veza) brojac++; return brojac; } template <typename TipElemenata> TipElemenata SumaElemenata(Cvor<TipElemenata> *pocetak) { if(pocetak == nullptr) return TipElemenata(); TipElemenata brojac(0); for(Cvor<TipElemenata> *p = pocetak; p != nullptr; p = p->veza) brojac += p->element; return brojac; } template <typename TipElemenata> int BrojVecihOd(Cvor<TipElemenata> *pocetak, TipElemenata prag) { if(pocetak == nullptr) return 0; int brojac(0); for(auto *p = pocetak; p != nullptr; p = p->veza) if(p->element > prag) brojac++; return brojac; } template <typename TipElemenata> void UnistiListu(Cvor<TipElemenata> *pocetak) { if(pocetak == nullptr) return; Cvor<TipElemenata> *pomocni; while (pocetak != nullptr) { pomocni = pocetak; pocetak = pocetak->veza; delete pomocni; } } int main() { Cvor<double> *pocetak = nullptr; std::cout << "Unesite slijed brojeva (0 za kraj): "; pocetak = KreirajPovezanuListu<double>(0); std::cout << "U slijedu ima " << BrojVecihOd(pocetak, SumaElemenata(pocetak)/BrojElemenata(pocetak)) <<" brojeva vecih od njihove aritmeticke sredine"; UnistiListu(pocetak); return 0; }
[ "masovicharis1337@gmail.com" ]
masovicharis1337@gmail.com
9b4f5f22f14ffb80eac0ca4f362b5239d37bb85c
f46ffde12192bbf8f18c26f51c5d9592134817d5
/day_02/leet_189/leet_189.h
9d32bffc1f9273a0df467c9df4664f110cb7a01c
[]
no_license
lev-gevorgyan/cobra-leetcode
0d26a0e579d800429802885740df90c7dc0dc131
26fa8de5282402fb043e17218feb90c5bfa14b9f
refs/heads/master
2023-04-23T22:45:51.276479
2021-05-14T11:40:33
2021-05-14T11:40:33
364,628,348
0
0
null
null
null
null
UTF-8
C++
false
false
200
h
// // Created by User on 5/7/2021. // #ifndef COBRA_LEETCODE_LEET_189_H #define COBRA_LEETCODE_LEET_189_H #include <vector> void rotate(std::vector<int>&, int); #endif //COBRA_LEETCODE_LEET_189_H
[ "lev.gevorgyan001@gmail.com" ]
lev.gevorgyan001@gmail.com
c17db6ee6d63cfa45410afff1a50b569b484c213
142c823aff524351be3861530a92ec2b659beb7f
/src/view/GraphicCircle.cpp
60f3f6e9da504e8fffef08b2f08cd1d7f8cabde2
[]
no_license
Nomadluap/circles
8a6e2aa6caabc446b27bef7b28cd5f17330efde4
23b069a39175421269c55c1be5d63756979be6cb
refs/heads/master
2021-01-10T15:03:25.158438
2016-04-28T03:00:28
2016-04-28T03:00:28
36,746,381
0
0
null
null
null
null
UTF-8
C++
false
false
1,668
cpp
#include "GraphicCircle.hpp" #include <QPainter> #include <QStyleOptionGraphicsItem> #include "packing/Circle.hpp" #include "packing/EuclidCircle.hpp" using namespace Circles; using namespace Circles::View; GraphicCircle::GraphicCircle(): QGraphicsItem() { this->setPos(0, 0); this->radius_ = 1.0; this->index_ = -1; // this->setCacheMode(QGraphicsItem::DeviceCoordinateCache); // prepareGeometryChange(); } View::GraphicCircle::GraphicCircle(const Packing::Circle& c): QGraphicsItem() { this->setPos(c.projCenter()); this->radius_ = c.projRadius(); this->index_ = c.index(); } QRectF GraphicCircle::boundingRect() const { qreal r = this->radius_; return QRectF(-r, -r, 2*r, 2*r); } QPainterPath GraphicCircle::shape() const { QPainterPath p; p.addEllipse(this->boundingRect()); return std::move(p); } void GraphicCircle::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(widget) //get the scale of the scene qreal lod = option->levelOfDetailFromTransform(painter->worldTransform()); painter->setPen(QPen(Qt::black, 1.50/lod )); painter->setBrush(QBrush(QColor(0, 0, 0, 0))); // painter->setClipRect(option->exposedRect); painter->drawEllipse(QPointF(0, 0), this->radius_, this->radius_); // QFont font("Times", 10); // font.setStyleStrategy(QFont::ForceOutline); // painter->setFont(font); // painter->save(); // painter->scale(1.0/lod, 1.0/lod); // painter->drawText(QPointF(0, 0), QString("%1").arg(this->index_)); // painter->restore(); } int GraphicCircle::graphIndex() const { return this->index_; }
[ "paulirino@gmail.com" ]
paulirino@gmail.com
bac75045a2cea05a9b24b6575cb20cc42e06410a
ad055716de1f5283fc905422c63a47c6d4796661
/Dynamic Programming/llyaandqueries.cpp
47cc29df47abe3a911f7ea1603b0643eba0ec632
[]
no_license
Akash-Sharma1/Competitive
75b1d59d8e39cd104b13f5df84f4ea4a39a68caf
93e1952038df4c3f467d18f52f7da16d49de40aa
refs/heads/master
2020-04-16T08:52:18.231098
2019-03-22T17:30:32
2019-03-22T17:30:32
165,441,602
0
0
null
null
null
null
UTF-8
C++
false
false
787
cpp
#include<bits/stdc++.h> #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define ALL(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i=(l);i<(r);i++) #define repd(i, l, r) for (int i=(l);i>=(r);i--) #define ll long long #define fi first #define se second #define be begin() #define en end() #define le length() #define pi pair<int,int> #define pii pair<int,pii> #define maxN 1000000005 using namespace std; int main(){ fastIO string str; cin >>str; int m; cin >> m; int n=str.length(); int arr[n]={0}; rep(i,1,n){ if(str[i-1]==str[i]){arr[i]+=arr[i-1]+1;} else{arr[i]=arr[i-1];} } rep(i,0,m){ int l,r; cin >> l >> r; l--;r--; cout<<arr[r]-arr[l]<<endl; } }
[ "aakashsharmajc100@gmail.com" ]
aakashsharmajc100@gmail.com
57223a4e2f2b140d67702e91ec991c06a94d44ce
7491300c8d064e81b2b98f518a9df13dadfaa6b8
/Templates.cpp
e993811098e995e5af50f8afc889e2346a3fdf32
[]
no_license
E-DeT/Main-Projects
6c0ee7cc1942415114efe45fd158868d96303f34
a155aa28f9661e8998fc94179083b94e41ef9498
refs/heads/master
2021-01-10T17:09:51.476472
2016-05-02T02:38:31
2016-05-02T02:38:31
54,348,483
0
0
null
2016-03-21T00:45:55
2016-03-21T00:35:57
null
UTF-8
C++
false
false
1,227
cpp
#include <iostream> using namespace std; template<class t> class List { public: List(int array_size = 10); ~List(); t* search(t& search_key); bool push(t& obj); t* pop(t& obj); private: t* t_P; int array_pos, size; }; template <class t> List<t>::List(int array_size): t_P(new t[array_size]), array_pos(0), size(array_size) {} template <class t> List<t>::~List() { delete [] t_P; t_P = 0; } template<class t> t* List<t>::search(t& search_key) { t* temp = t_P; while((*temp) != 0) { if((*temp) == search_key) { return temp; } temp += 1; } return 0; } template <class t> t* List<t>::pop(t& obj) { t* temp = t_P; if(array_pos <= 0) { return (*(temp += array_pos)); array_pos--; } else { return 0; } } template <class t> bool List<t>::push(t& obj) { t* temp = t_P; if(array_pos < size) { (*(temp += array_pos)) = obj; array_pos++; return true; } else { return false; } } int main(int argc, char* argv[]) { List<int> listints(5); int a = 6, b = 7; char* c = "Hallo"; List<char*> listchar; listchar.push(c); cout << *(listchar.search(c)) << endl; listints.push(a); if(listints.search(a)) { cout << *(listints.search(a)); } else { cout << "Failure"; } }
[ "evandetamble@gmail.com" ]
evandetamble@gmail.com
e9c5f881658e2af81f513bbfd017a896d1941ccb
780aeb7511e4dd31eea5ec67b66e60161dd8a927
/inst-exec-lab/RegFile.cpp
9ce0fc49c3b47fe804c051eb0df02a84484ac012
[]
no_license
jrocha2/spimulator
6350d7b06e7a78e6908b83c11dec6810c58f64fc
2d3546fa40c4f21f7434e55d188c75e061d058f5
refs/heads/master
2020-02-26T17:06:16.240971
2015-11-24T06:14:25
2015-11-24T06:14:25
43,873,649
0
0
null
null
null
null
UTF-8
C++
false
false
221
cpp
/* * RegFile.cpp * * Created on: Sep 14, 2015 * Author: jbb */ #include "RegFile.h" RegFile::RegFile() { } uint32_t& RegFile::operator [](unsigned i) { if (i == 0) { A[0] = 0; } return A[i]; }
[ "amcmaho4@nd.edu" ]
amcmaho4@nd.edu
61a0478b4f9783b5470ffbd182791c63d2109020
8f3efc7e9c8fbb960308900b40e6be2f1423bbe9
/mulvec.cpp
0c0edefc5236575bddc4b599d48558057ce5a2fe
[]
no_license
trinathg/Lid_driven_cavity_Re_100
4457a01153aa4f32d5fa0cd1deb21146b1bb743a
9f498830147e579ab402dfd9d9d728beb8c379cb
refs/heads/master
2016-09-02T05:26:46.059860
2015-07-16T09:16:17
2015-07-16T09:16:17
39,188,682
1
0
null
null
null
null
UTF-8
C++
false
false
68,495
cpp
#include "headers.h" #include "init_2.h" #include "declarations_2.h" vec old_mulvec(vec X, mg_grid * level) { int lev=0; int sp=pow(2,lev), ind; int nx_sol = (nx/pow(2,lev))-sp, ny_sol = (ny/pow(2,lev))-sp; //No of points for the computational domain after compatibility condition int tot_p_sol = (nx_sol)*(ny_sol); //No.of points that are solved for directly. The top and the farthest right lines of points are //removed due to periodicity vec ans(tot_p_sol), subans(tot_p_sol-1); int i_m, j_m, str_m=nx_sol, ind_m; int st_inx = sp, en_inx = nx - sp; int st_iny = sp, en_iny = ny - sp; double RHS1, RHS2, RHS3, RHS4, RHS5, RHS6; for(int j=st_iny;j<=en_iny;j=j+sp) { for(int i=st_inx;i<=en_inx;i=i+sp) { ind = i + j*str_x; i_m = (i/sp)-1; j_m = (j/sp)-1; ind_m = i_m + j_m*str_m; /*******************Case-1 j=1***********************/ if(j==st_iny) { if(i==st_inx) //Checked { RHS1 = dc_b1_11[lev]*X[ind_m] + dc_b1_12[lev]*X[ind_m+sp] + dc_b1_13[lev]*X[ind_m+2*sp] ; RHS2 = dc_b2_11[lev]*X[ind_m+sp*str_m] + dc_b2_12[lev]*X[ind_m+sp+sp*str_m] + dc_b2_13[lev]*X[ind_m+2*sp+sp*str_m]; RHS3 = dc_b3_11[lev]*X[ind_m+2*sp*str_m] + dc_b3_12[lev]*X[ind_m+sp+2*sp*str_m] + dc_b3_13[lev]*X[ind_m+2*sp+2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); //cout<<dc_b1_11[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b2_11[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b3_11[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_ny1_11[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_ny1_13[lev]<<"\n"<<dc_ny_11[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_13[lev]<<"\n"; } else if(i==st_inx+sp) //checked { RHS1 = dc_nb1_21[lev]*X[ind_m-sp] + dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m+sp] + dc_nb1_24[lev]*X[ind_m+2*sp] ; RHS2 = dc_nb2_21[lev]*X[ind_m-sp+sp*str_m] + dc_nb2_22[lev]*X[ind_m+sp*str_m] + dc_nb2_23[lev]*X[ind_m+sp+sp*str_m] + dc_nb2_24[lev]*X[ind_m+2*sp+sp*str_m] ; RHS3 = dc_nb3_21[lev]*X[ind_m-sp+2*sp*str_m] + dc_nb3_22[lev]*X[ind_m+2*sp*str_m] + dc_nb3_23[lev]*X[ind_m+sp+2*sp*str_m] + dc_nb3_24[lev]*X[ind_m+2*sp+2*sp*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); // cout<<dc_nb1_21[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_ny_21[lev]<<"\n"<<dc_ny_22[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_24[lev]<<"\n"; } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { RHS1 = dc_i1_32[lev]*X[ind_m-2*sp] + dc_i1_33[lev]*X[ind_m-sp] + dc_i1_34[lev]*X[ind_m] + dc_i1_35[lev]*X[ind_m+sp] + dc_i1_36[lev]*X[ind_m+2*sp]; RHS2 = dc_i2_32[lev]*X[ind_m-2*sp+sp*str_m] + dc_i2_33[lev]*X[ind_m-sp+sp*str_m] + dc_i2_34[lev]*X[ind_m+sp*str_m] + dc_i2_35[lev]*X[ind_m+sp+sp*str_m] + dc_i2_36[lev]*X[ind_m+2*sp+sp*str_m]; RHS3 = dc_i3_32[lev]*X[ind_m-2*sp+2*sp*str_m] + dc_i3_33[lev]*X[ind_m-sp+2*sp*str_m] + dc_i3_34[lev]*X[ind_m+2*sp*str_m] + dc_i3_35[lev]*X[ind_m+sp+2*sp*str_m] + dc_i3_36[lev]*X[ind_m+2*sp+2*sp*str_m]; // ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb1_21[lev]*X[ind_m+sp] + dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m-sp] + dc_nb1_24[lev]*X[ind_m-2*sp] ; RHS2 = dc_nb2_21[lev]*X[ind_m+sp+sp*str_m] + dc_nb2_22[lev]*X[ind_m+sp*str_m] + dc_nb2_23[lev]*X[ind_m-sp+sp*str_m] + dc_nb2_24[lev]*X[ind_m-2*sp+sp*str_m] ; RHS3 = dc_nb3_21[lev]*X[ind_m+sp+2*sp*str_m] + dc_nb3_22[lev]*X[ind_m+2*sp*str_m] + dc_nb3_23[lev]*X[ind_m-sp+2*sp*str_m] + dc_nb3_24[lev]*X[ind_m-2*sp+2*sp*str_m]; //cout<<dc_nb1_24[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"<<dc_nb1_21[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_22[lev]<<"\n"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); } else //Checked { RHS1 = dc_b1_11[lev]*X[ind_m] + dc_b1_12[lev]*X[ind_m-sp] + dc_b1_13[lev]*X[ind_m-2*sp]; RHS2 = dc_b2_11[lev]*X[ind_m+sp*str_m] + dc_b2_12[lev]*X[ind_m-sp+sp*str_m] + dc_b2_13[lev]*X[ind_m-2*sp+sp*str_m]; RHS3 = dc_b3_11[lev]*X[ind_m+2*sp*str_m] + dc_b3_12[lev]*X[ind_m-sp+2*sp*str_m] + dc_b3_13[lev]*X[ind_m-2*sp+2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); //cout<<dc_b1_12[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b1_11[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_11[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_11[lev]<<"\n"<<dc_ny1_13[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_ny1_11[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_12[lev]<<"\n"; } } /*****************Case-2 (j=2)**********************/ if(j==st_iny+sp) { if(i==st_inx) //Checked { RHS1 = dc_b4_11[lev]*X[ind_m-sp*str_m] + dc_b4_12[lev]*X[ind_m+sp-sp*str_m] + dc_b4_13[lev]*X[ind_m+2*sp-sp*str_m]; RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m+sp] + dc_b5_13[lev]*X[ind_m+2*sp]; RHS3 = dc_b6_11[lev]*X[ind_m+sp*str_m] + dc_b6_12[lev]*X[ind_m+sp+sp*str_m] + dc_b6_13[lev]*X[ind_m+2*sp+sp*str_m] ; RHS4 = dc_b7_11[lev]*X[ind_m+2*sp*str_m] + dc_b7_12[lev]*X[ind_m+sp+2*sp*str_m] + dc_b7_13[lev]*X[ind_m+2*sp+2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4) ; ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4) ; //cout<<dc_b4_11[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_pb7_11[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"; } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb4_21[lev]*X[ind_m-sp-sp*str_m] + dc_nb4_22[lev]*X[ind_m-sp*str_m] + dc_nb4_23[lev]*X[ind_m+sp-sp*str_m] + dc_nb4_24[lev]*X[ind_m+2*sp-sp*str_m]; RHS2 = dc_nb5_21[lev]*X[ind_m-sp] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m+sp] + dc_nb5_24[lev]*X[ind_m+2*sp]; RHS3 = dc_nb6_21[lev]*X[ind_m-sp+sp*str_m] + dc_nb6_22[lev]*X[ind_m+sp*str_m] + dc_nb6_23[lev]*X[ind_m+sp+sp*str_m] + dc_nb6_24[lev]*X[ind_m+2*sp+sp*str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m-sp+2*sp*str_m] + dc_nb7_22[lev]*X[ind_m+2*sp*str_m] + dc_nb7_23[lev]*X[ind_m+sp+2*sp*str_m] + dc_nb7_24[lev]*X[ind_m+2*sp+2*sp*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_nb4_21[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_pb7_21[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"<<dc_pb7_23[lev]<<"\n"<<dc_pb7_24[lev]<<"\n"; } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { RHS1 = dc_i4_32[lev]*X[ind_m-2*sp-sp*str_m] + dc_i4_33[lev]*X[ind_m-sp-sp*str_m] + dc_i4_34[lev]*X[ind_m-sp*str_m] + dc_i4_35[lev]*X[ind_m+sp-sp*str_m] + dc_i4_36[lev]*X[ind_m+2*sp-sp*str_m]; RHS2 = dc_i5_32[lev]*X[ind_m-2*sp] + dc_i5_33[lev]*X[ind_m-sp] + dc_i5_34[lev]*X[ind_m] + dc_i5_35[lev]*X[ind_m+sp] + dc_i5_36[lev]*X[ind_m+2*sp]; RHS3 = dc_i6_32[lev]*X[ind_m-2*sp+sp*str_m] + dc_i6_33[lev]*X[ind_m-sp+sp*str_m] + dc_i6_34[lev]*X[ind_m+sp*str_m] + dc_i6_35[lev]*X[ind_m+sp+sp*str_m] + dc_i6_36[lev]*X[ind_m+2*sp+sp*str_m]; RHS4 = dc_i7_32[lev]*level[lev].phi_s[ind_m-2*sp+2*sp*str_m] + dc_i7_33[lev]*X[ind_m-sp+2*sp*str_m] + dc_i7_34[lev]*X[ind_m+2*sp*str_m] + dc_i7_35[lev]*X[ind_m+sp+2*sp*str_m] + dc_i7_36[lev]*X[ind_m+2*sp+2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); /*cout<<dc_i4_32[lev]<<"\n"<<dc_i4_33[lev]<<"\n"<<dc_i4_34[lev]<<"\n"<<dc_i4_35[lev]<<"\n"<<dc_i4_36[lev]<<"\n"<<dc_i5_32[lev]<<"\n"<<dc_i5_33[lev]<<"\n"<<dc_i5_34[lev]<<"\n"<<dc_i5_35[lev]<<"\n"<<dc_i5_36[lev]<<"\n"<<dc_i6_32[lev]<<"\n"<<dc_i6_33[lev]<<"\n"<<dc_i6_34[lev]<<"\n"<<dc_i6_35[lev]<<"\n"<<dc_i6_36[lev]<<"\n"<<dc_i7_33[lev]<<"\n"<<dc_i7_34[lev]<<"\n"<<dc_i7_35[lev]<<"\n"<<dc_pb7_33[lev]<<"\n"<<dc_pb7_34[lev]<<"\n"<<dc_pb7_35[lev]<<"\n"; cout<<"--------------------------------------";*/ } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb4_21[lev]*X[ind_m+sp-sp*str_m] + dc_nb4_22[lev]*X[ind_m-sp*str_m] + dc_nb4_23[lev]*X[ind_m-sp-sp*str_m] + dc_nb4_24[lev]*X[ind_m-2*sp-sp*str_m]; RHS2 = dc_nb5_21[lev]*X[ind_m+sp] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m-sp] + dc_nb5_24[lev]*X[ind_m-2*sp]; RHS3 = dc_nb6_21[lev]*X[ind_m+sp+sp*str_m] + dc_nb6_22[lev]*X[ind_m+sp*str_m] + dc_nb6_23[lev]*X[ind_m-sp+sp*str_m] + dc_nb6_24[lev]*X[ind_m-2*sp+sp*str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m+sp+2*sp*str_m] + dc_nb7_22[lev]*X[ind_m+2*sp*str_m] + dc_nb7_23[lev]*X[ind_m-sp+2*sp*str_m] + dc_nb7_24[lev]*X[ind_m-2*sp+2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_nb4_24[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"<<dc_nb4_21[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_pb7_23[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"; } else //checked { RHS1 = dc_b4_11[lev]*X[ind_m-sp*str_m] + dc_b4_12[lev]*X[ind_m-sp-sp*str_m] + dc_b4_13[lev]*X[ind_m-2*sp-sp*str_m] ; RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m-sp] + dc_b5_13[lev]*X[ind_m-2*sp]; RHS3 = dc_b6_11[lev]*X[ind_m+sp*str_m] + dc_b6_12[lev]*X[ind_m-sp+sp*str_m] + dc_b6_13[lev]*X[ind_m-2*sp+sp*str_m]; RHS4 = dc_b7_11[lev]*X[ind_m+2*sp*str_m] + dc_b7_12[lev]*X[ind_m-sp+2*sp*str_m] + dc_b7_13[lev]*X[ind_m-2*sp+2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4) ; ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4) ; // cout<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"; } } /*****************Case-3 (j>=3 and j<=ny-3)**********************/ if(j>=st_iny+2*sp && j<=en_iny-2*sp) { if(i==st_inx) //Checked { RHS1 = dc_b8_11[lev]*X[ind_m-2*sp*str_m] + dc_b8_12[lev]*X[ind_m+sp-2*sp*str_m] + dc_b8_13[lev]*X[ind_m+2*sp-2*sp*str_m]; RHS2 = dc_b9_11[lev]*X[ind_m-sp*str_m] + dc_b9_12[lev]*X[ind_m+sp-sp*str_m] + dc_b9_13[lev]*X[ind_m+2*sp-sp*str_m]; RHS3 = dc_b10_11[lev]*X[ind_m] + dc_b10_12[lev]*X[ind_m+sp] + dc_b10_13[lev]*X[ind_m+2*sp] ; RHS4 = dc_b11_11[lev]*X[ind_m+sp*str_m] + dc_b11_12[lev]*X[ind_m+sp+sp*str_m] + dc_b11_13[lev]*X[ind_m+2*sp+sp*str_m] ; RHS5 = dc_b12_11[lev]*X[ind_m+2*sp*str_m] + dc_b12_12[lev]*X[ind_m+sp+2*sp*str_m] + dc_b12_13[lev]*X[ind_m+2*sp+2*sp*str_m]; //cout<<dc_b8_11[lev]<<"\n"<<dc_b8_12[lev]<<"\n"<<dc_b8_12[lev]<<"\n"<<dc_b9_11[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b10_11[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b11_11[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b12_11[lev]<<"\n"<<dc_b12_12[lev]<<"\n"<<dc_b12_12[lev]<<"\n"; //cout<<"--------------------------------------------"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb8_21[lev]*X[ind_m-sp-2*sp*str_m] + dc_nb8_22[lev]*X[ind_m-2*sp*str_m] + dc_nb8_23[lev]*X[ind_m+sp-2*sp*str_m] + dc_nb8_24[lev]*X[ind_m+2*sp-2*sp*str_m]; RHS2 = dc_nb9_21[lev]*X[ind_m-sp-sp*str_m] + dc_nb9_22[lev]*X[ind_m-sp*str_m] + dc_nb9_23[lev]*X[ind_m+sp-sp*str_m] + dc_nb9_24[lev]*X[ind_m+2*sp-sp*str_m]; RHS3 = dc_nb10_21[lev]*X[ind_m-sp] + dc_nb10_22[lev]*X[ind_m] + dc_nb10_23[lev]*X[ind_m+sp] + dc_nb10_24[lev]*X[ind_m+2*sp]; RHS4 = dc_nb11_21[lev]*X[ind_m-sp+sp*str_m] + dc_nb11_22[lev]*X[ind_m+sp*str_m] + dc_nb11_23[lev]*X[ind_m+sp+sp*str_m] + dc_nb11_24[lev]*X[ind_m+2*sp+sp*str_m]; RHS5 = dc_nb12_21[lev]*X[ind_m-sp+2*sp*str_m] + dc_nb12_22[lev]*X[ind_m+2*sp*str_m] + dc_nb12_23[lev]*X[ind_m+sp+2*sp*str_m] + dc_nb12_24[lev]*X[ind_m+2*sp+2*sp*str_m] ; // ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); /* cout<<dc_nb8_21[lev]<<"\n"<<dc_nb8_22[lev]<<"\n"<<dc_nb8_23[lev]<<"\n"<<dc_nb9_21[lev]<<"\n"<<dc_nb9_22[lev]<<"\n"<<dc_nb9_23[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb10_21[lev]<<"\n"<<dc_nb10_22[lev]<<"\n"<<dc_nb10_23[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb11_21[lev]<<"\n"<<dc_nb11_22[lev]<<"\n"<<dc_nb11_23[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb12_21[lev]<<"\n"<<dc_nb12_22[lev]<<"\n"<<dc_nb12_23[lev]<<"\n"; cout<<"--------------------------------------------";*/ } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { RHS1 = dc_i8_33[lev]*X[ind_m-sp-2*sp*str_m] + dc_i8_34[lev]*X[ind_m-2*sp*str_m] + dc_i8_35[lev]*X[ind_m+sp-2*sp*str_m]; RHS2 = dc_i9_32[lev]*X[ind_m-2*sp-sp*str_m] + dc_i9_33[lev]*X[ind_m-sp-sp*str_m] + dc_i9_34[lev]*X[ind_m-sp*str_m] + dc_i9_35[lev]*X[ind_m+sp-sp*str_m] + dc_i9_36[lev]*X[ind_m+2*sp-sp*str_m]; RHS3 = dc_i10_32[lev]*X[ind_m-2*sp] + dc_i10_33[lev]*X[ind_m-sp] + dc_i10_34[lev]*X[ind_m] + dc_i10_35[lev]*X[ind_m+sp] + dc_i10_36[lev]*X[ind_m+2*sp]; RHS4 = dc_i11_32[lev]*X[ind_m-2*sp+sp*str_m] + dc_i11_33[lev]*X[ind_m-sp+sp*str_m] + dc_i11_34[lev]*X[ind_m+sp*str_m] + dc_i11_35[lev]*X[ind_m+sp+sp*str_m] + dc_i11_36[lev]*X[ind_m+2*sp+sp*str_m]; RHS5 = dc_i12_33[lev]*X[ind_m-sp+2*sp*str_m] + dc_i12_34[lev]*X[ind_m+2*sp*str_m] + dc_i12_35[lev]*X[ind_m+sp+2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); /*cout<<dc_i8_33[lev]<<"\n"<<dc_i8_34[lev]<<"\n"<<dc_i8_35[lev]<<"\n"<<dc_i9_32[lev]<<"\n"<<dc_i9_33[lev]<<"\n"<<dc_i9_34[lev]<<"\n"<<dc_i9_35[lev]<<"\n"<<dc_i9_36[lev]<<"\n"<<dc_i10_32[lev]<<"\n"<<dc_i10_33[lev]<<"\n"<<dc_i10_34[lev]<<"\n"<<dc_i10_35[lev]<<"\n"<<dc_i10_36[lev]<<"\n"<<dc_i11_32[lev]<<"\n"<<dc_i11_33[lev]<<"\n"<<dc_i11_34[lev]<<"\n"<<dc_i11_35[lev]<<"\n"<<dc_i11_36[lev]<<"\n"<<dc_i12_33[lev]<<"\n"<<dc_i12_34[lev]<<"\n"<<dc_i12_35[lev]<<"\n"; cout<<"--------------------------------------------";*/ } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb8_21[lev]*X[ind_m+sp-2*sp*str_m] + dc_nb8_22[lev]*X[ind_m-2*sp*str_m] + dc_nb8_23[lev]*X[ind_m-sp-2*sp*str_m] + dc_nb8_24[lev]*X[ind_m-2*sp-2*sp*str_m]; RHS2 = dc_nb9_21[lev]*X[ind_m+sp-sp*str_m] + dc_nb9_22[lev]*X[ind_m-sp*str_m] + dc_nb9_23[lev]*X[ind_m-sp-sp*str_m] + dc_nb9_24[lev]*X[ind_m-2*sp-sp*str_m]; RHS3 = dc_nb10_21[lev]*X[ind_m+sp] + dc_nb10_22[lev]*X[ind_m] + dc_nb10_23[lev]*X[ind_m-sp] + dc_nb10_24[lev]*X[ind_m-2*sp]; RHS4 = dc_nb11_21[lev]*X[ind_m+sp+sp*str_m] + dc_nb11_22[lev]*X[ind_m+sp*str_m] + dc_nb11_23[lev]*X[ind_m-sp+sp*str_m] + dc_nb11_24[lev]*X[ind_m-2*sp+sp*str_m]; if(j+2*sp==en_iny) { RHS5 = dc_nb12_22[lev]*X[ind_m+2*sp*str_m] + dc_nb12_23[lev]*X[ind_m-sp+2*sp*str_m] + dc_nb12_24[lev]*X[ind_m-2*sp+2*sp*str_m]; //lcr } else { RHS5 = dc_nb12_21[lev]*X[ind_m+sp+2*sp*str_m] + dc_nb12_22[lev]*X[ind_m+2*sp*str_m] + dc_nb12_23[lev]*X[ind_m-sp+2*sp*str_m] + dc_nb12_24[lev]*X[ind_m-2*sp+2*sp*str_m]; } //cout<<dc_nb8_23[lev]<<"\n"<<dc_nb8_22[lev]<<"\n"<<dc_nb8_21[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb9_23[lev]<<"\n"<<dc_nb9_22[lev]<<"\n"<<dc_nb9_21[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb10_23[lev]<<"\n"<<dc_nb10_22[lev]<<"\n"<<dc_nb10_21[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb11_23[lev]<<"\n"<<dc_nb11_22[lev]<<"\n"<<dc_nb11_21[lev]<<"\n"<<dc_nb12_23[lev]<<"\n"<<dc_nb12_22[lev]<<"\n"<<dc_nb12_21[lev]<<"\n"; //cout<<"----------------------------------------------\n"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); } else //Checked { RHS1 = dc_b8_11[lev]*X[ind_m-2*sp*str_m] + dc_b8_12[lev]*X[ind_m-sp-2*sp*str_m] + dc_b8_13[lev]*X[ind_m-2*sp-2*sp*str_m]; RHS2 = dc_b9_11[lev]*X[ind_m-sp*str_m] + dc_b9_12[lev]*X[ind_m-sp-sp*str_m] + dc_b9_13[lev]*X[ind_m-2*sp-sp*str_m]; RHS3 = dc_b10_11[lev]*X[ind_m] + dc_b10_12[lev]*X[ind_m-sp] + dc_b10_13[lev]*X[ind_m-2*sp]; RHS4 = dc_b11_11[lev]*X[ind_m+sp*str_m] + dc_b11_12[lev]*X[ind_m-sp+sp*str_m] + dc_b11_13[lev]*X[ind_m-2*sp+sp*str_m]; if(j+2*sp==en_iny) { RHS5 = dc_b12_12[lev]*X[ind_m-sp+2*sp*str_m] + dc_b12_13[lev]*X[ind_m-2*sp+2*sp*str_m]; //lcr } else { RHS5 = dc_b12_11[lev]*X[ind_m+2*sp*str_m] + dc_b12_12[lev]*X[ind_m-sp+2*sp*str_m] + dc_b12_13[lev]*X[ind_m-2*sp+2*sp*str_m]; } //cout<<dc_b8_12[lev]<<"\n"<<dc_b8_12[lev]<<"\n"<<dc_b8_11[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b9_11[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b10_11[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b11_11[lev]<<"\n"<<dc_b12_12[lev]<<"\n"<<dc_b12_12[lev]<<"\n"<<dc_b12_11[lev]<<"\n"; //cout<<"---------------------------------------\n"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); } } /*****************Case-4(j=ny-2)**********************/ if(j==en_iny-sp) { if(i==st_inx) //checked { RHS1 = dc_b4_11[lev]*X[ind_m+sp*str_m] + dc_b4_12[lev]*X[ind_m+sp+sp*str_m] + dc_b4_13[lev]*X[ind_m+2*sp+sp*str_m] ; RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m+sp] + dc_b5_13[lev]*X[ind_m+2*sp]; RHS3 = dc_b6_11[lev]*X[ind_m-sp*str_m] + dc_b6_12[lev]*X[ind_m+sp-sp*str_m] + dc_b6_13[lev]*X[ind_m+2*sp-sp*str_m]; RHS4 = dc_b7_11[lev]*X[ind_m-2*sp*str_m] + dc_b7_12[lev]*X[ind_m+sp-2*sp*str_m] + dc_b7_13[lev]*X[ind_m+2*sp-2*sp*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_pb7_11[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b4_11[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"; } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb4_21[lev]*X[ind_m-sp+sp*str_m] + dc_nb4_22[lev]*X[ind_m+sp*str_m] + dc_nb4_23[lev]*X[ind_m+sp+sp*str_m] + dc_nb4_24[lev]*X[ind_m+2*sp+sp*str_m]; RHS2 = dc_nb5_21[lev]*X[ind_m-sp] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m+sp] + dc_nb5_24[lev]*X[ind_m+2*sp]; RHS3 = dc_nb6_21[lev]*X[ind_m-sp-sp*str_m] + dc_nb6_22[lev]*X[ind_m-sp*str_m] + dc_nb6_23[lev]*X[ind_m+sp-sp*str_m] + dc_nb6_24[lev]*X[ind_m+2*sp-sp*str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m-sp-2*sp*str_m] + dc_nb7_22[lev]*X[ind_m-2*sp*str_m] + dc_nb7_23[lev]*X[ind_m+sp-2*sp*str_m] + dc_nb7_24[lev]*X[ind_m+2*sp-2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_pb7_21[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"<<dc_pb7_23[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb4_21[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"; } else if(i>st_inx+sp && i<en_inx-sp) //Checked { if(i+2*sp==en_inx) { RHS1 = dc_i4_32[lev]*X[ind_m-2*sp+sp*str_m] + dc_i4_33[lev]*X[ind_m-sp+sp*str_m] + dc_i4_34[lev]*X[ind_m+sp*str_m] + dc_i4_35[lev]*X[ind_m+sp+sp*str_m] ; //lcr } else { RHS1 = dc_i4_32[lev]*X[ind_m-2*sp+sp*str_m] + dc_i4_33[lev]*X[ind_m-sp+sp*str_m] + dc_i4_34[lev]*X[ind_m+sp*str_m] + dc_i4_35[lev]*X[ind_m+sp+sp*str_m] + dc_i4_36[lev]*X[ind_m+2*sp+sp*str_m]; } /*cout<<dc_pb7_33[lev]<<"\n"<<dc_pb7_34[lev]<<"\n"<<dc_pb7_35[lev]<<"\n"<<dc_i7_33[lev]<<"\n"<<dc_i7_34[lev]<<"\n"<<dc_i7_35[lev]<<"\n"<<dc_i6_32[lev]<<"\n"<<dc_i6_33[lev]<<"\n"<<dc_i6_34[lev]<<"\n"<<dc_i6_35[lev]<<"\n"<<dc_i6_36[lev]<<"\n"<<dc_i5_32[lev]<<"\n"<<dc_i5_33[lev]<<"\n"<<dc_i5_34[lev]<<"\n"<<dc_i5_35[lev]<<"\n"<<dc_i5_36[lev]<<"\n"<<dc_i4_32[lev]<<"\n"<<dc_i4_33[lev]<<"\n"<<dc_i4_34[lev]<<"\n"<<dc_i4_35[lev]<<"\n"<<dc_i4_36[lev]<<"\n"; cout<<"ind_m= "<<ind_m<<"\n"; cout<<"----------------------------------------------------\n"; */ RHS2 = dc_i5_32[lev]*X[ind_m-2*sp] + dc_i5_33[lev]*X[ind_m-sp] + dc_i5_34[lev]*X[ind_m] + dc_i5_35[lev]*X[ind_m+sp] + dc_i5_36[lev]*X[ind_m+2*sp]; RHS3 = dc_i6_32[lev]*X[ind_m-2*sp-sp*str_m] + dc_i6_33[lev]*X[ind_m-sp-sp*str_m] + dc_i6_34[lev]*X[ind_m-sp*str_m] + dc_i6_35[lev]*X[ind_m+sp-sp*str_m] + dc_i6_36[lev]*X[ind_m+2*sp-sp*str_m]; RHS4 = dc_i7_32[lev]*X[ind_m-2*sp-2*sp*str_m] + dc_i7_33[lev]*X[ind_m-sp-2*sp*str_m] + dc_i7_34[lev]*X[ind_m-2*sp*str_m] + dc_i7_35[lev]*X[ind_m+sp-2*sp*str_m] + dc_i7_36[lev]*X[ind_m+2*sp-2*sp*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 + RHS4 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 + RHS4 ) ; } else if(i==en_inx-sp) //checked { RHS1 = dc_nb4_22[lev]*X[ind_m+sp*str_m] + dc_nb4_23[lev]*X[ind_m-sp+sp*str_m] + dc_nb4_24[lev]*X[ind_m-2*sp+sp*str_m]; //lcr RHS2 = dc_nb5_21[lev]*X[ind_m+sp] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m-sp] + dc_nb5_24[lev]*X[ind_m-2*sp]; RHS3 = dc_nb6_21[lev]*X[ind_m+sp-sp*str_m] + dc_nb6_22[lev]*X[ind_m-sp*str_m] + dc_nb6_23[lev]*X[ind_m-sp-sp*str_m] + dc_nb6_24[lev]*X[ind_m-2*sp-sp*str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m+sp-2*sp*str_m] + dc_nb7_22[lev]*X[ind_m-2*sp*str_m] + dc_nb7_23[lev]*X[ind_m-sp-2*sp*str_m] + dc_nb7_24[lev]*X[ind_m-2*sp-2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 + RHS4 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 + RHS4 ) ; //cout<<"ind_m= "<<ind_m<<"\n"; //cout<<dc_pb7_23[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"<<dc_pb7_21[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"; } else //Checked { RHS1 = dc_b4_12[lev]*X[ind_m-sp+sp*str_m] + dc_b4_13[lev]*X[ind_m-2*sp+sp*str_m]; //lcr RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m-sp] + dc_b5_13[lev]*X[ind_m-2*sp]; RHS3 = dc_b6_11[lev]*X[ind_m-sp*str_m] + dc_b6_12[lev]*X[ind_m-sp-sp*str_m] + dc_b6_13[lev]*X[ind_m-2*sp-sp*str_m]; RHS4 = dc_b7_11[lev]*X[ind_m-2*sp*str_m] + dc_b7_12[lev]*X[ind_m-sp-2*sp*str_m] + dc_b7_13[lev]*X[ind_m-2*sp-2*sp*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 + RHS4 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 + RHS4 ) ; // cout<<dc_pb7_12[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_pb7_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_12[lev]<<"\n"; } } /****************************************Case-5(j=en_iny)******************************************/ if(j==en_iny) { if(i==st_inx) { RHS1 = dc_b1_11[lev]*X[ind_m] + dc_b1_12[lev]*X[ind_m+sp] + dc_b1_13[lev]*X[ind_m+2*sp]; RHS2 = dc_b2_11[lev]*X[ind_m-sp*str_m] + dc_b2_12[lev]*X[ind_m+sp-sp*str_m] + dc_b2_13[lev]*X[ind_m+2*sp-sp*str_m]; RHS3 = dc_b3_11[lev]*X[ind_m-2*sp*str_m] + dc_b3_12[lev]*X[ind_m+sp-2*sp*str_m] + dc_b3_13[lev]*X[ind_m+2*sp-2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); //cout<<dc_ny_11[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny1_11[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_b3_11[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b2_11[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b1_11[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_13[lev]<<"\n"; } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb1_21[lev]*X[ind_m-sp] + dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m+sp] + dc_nb1_24[lev]*X[ind_m+2*sp] ; RHS2 = dc_nb2_21[lev]*X[ind_m-sp-sp*str_m] + dc_nb2_22[lev]*X[ind_m-sp*str_m] + dc_nb2_23[lev]*X[ind_m+sp-sp*str_m] + dc_nb2_24[lev]*X[ind_m+2*sp-sp*str_m]; RHS3 = dc_nb3_21[lev]*X[ind_m-sp-2*sp*str_m] + dc_nb3_22[lev]*X[ind_m-2*sp*str_m] + dc_nb3_23[lev]*X[ind_m+sp-2*sp*str_m] + dc_nb3_24[lev]*X[ind_m+2*sp-2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 ) ; /*cout<<"ind_m = "<<ind_m<<"\n"; cout<<dc_ny_21[lev]<<"\n"<<dc_ny_22[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_nb3_24[lev]<<"\n"<<dc_nb3_24[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb1_21[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_24[lev]<<"\n";*/ } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { if(i+2*sp==en_inx) { RHS1 = dc_i1_32[lev]*X[ind_m-2*sp] + dc_i1_33[lev]*X[ind_m-sp] + dc_i1_34[lev]*X[ind_m] + dc_i1_35[lev]*X[ind_m+sp]; //lcr } else { RHS1 = dc_i1_32[lev]*X[ind_m-2*sp] + dc_i1_33[lev]*X[ind_m-sp] + dc_i1_34[lev]*X[ind_m] + dc_i1_35[lev]*X[ind_m+sp] + dc_i1_36[lev]*X[ind_m+2*sp]; } /*cout<<"ind_m= "<<ind_m<<"\n"; cout<<dc_ny_32[lev]<<"\n"<<dc_ny_33[lev]<<"\n"<<dc_ny_34[lev]<<"\n"<<dc_ny_35[lev]<<"\n"<<dc_ny_36[lev]<<"\n"<<dc_ny1_33[lev]<<"\n"<<dc_ny1_34[lev]<<"\n"<<dc_ny1_35[lev]<<"\n"<<dc_i3_33[lev]<<"\n"<<dc_i3_34[lev]<<"\n"<<dc_i3_35[lev]<<"\n"<<dc_i2_32[lev]<<"\n"<<dc_i2_33[lev]<<"\n"<<dc_i2_34[lev]<<"\n"<<dc_i2_35[lev]<<"\n"<<dc_i2_36[lev]<<"\n"<<dc_i1_32[lev]<<"\n"<<dc_i1_33[lev]<<"\n"<<dc_i1_34[lev]<<"\n"<<dc_i1_35[lev]<<"\n"<<dc_i1_36[lev]<<"\n"; cout<<"---------------------------------------------------\n";*/ RHS2 = dc_i2_32[lev]*X[ind_m-2*sp-sp*str_m] + dc_i2_33[lev]*X[ind_m-sp-sp*str_m] + dc_i2_34[lev]*X[ind_m-sp*str_m] + dc_i2_35[lev]*X[ind_m+sp-sp*str_m] + dc_i2_36[lev]*X[ind_m+2*sp-sp*str_m]; RHS3 = dc_i3_32[lev]*X[ind_m-2*sp-2*sp*str_m] + dc_i3_33[lev]*X[ind_m-sp-2*sp*str_m] + dc_i3_34[lev]*X[ind_m-2*sp*str_m] + dc_i3_35[lev]*X[ind_m+sp-2*sp*str_m] + dc_i3_36[lev]*X[ind_m+2*sp-2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m-sp] + dc_nb1_24[lev]*X[ind_m-2*sp]; //lcr RHS2 = dc_nb2_21[lev]*X[ind_m+sp-sp*str_m] + dc_nb2_22[lev]*X[ind_m-sp*str_m] + dc_nb2_23[lev]*X[ind_m-sp-sp*str_m] + dc_nb2_24[lev]*X[ind_m-2*sp-sp*str_m]; RHS3 = dc_nb3_21[lev]*X[ind_m+sp-2*sp*str_m] + dc_nb3_22[lev]*X[ind_m-2*sp*str_m] + dc_nb3_23[lev]*X[ind_m-sp-2*sp*str_m] + dc_nb3_24[lev]*X[ind_m-2*sp-2*sp*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); /*cout<<"ind_m= "<<ind_m<<"\n"; cout<<dc_ny_24[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_22[lev]<<"\n"<<dc_ny_21[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"; */ } else //Checked { RHS1 = dc_b1_12[lev]*X[ind_m-sp] + dc_b1_13[lev]*X[ind_m-2*sp]; //lcr RHS2 = dc_b2_11[lev]*X[ind_m-sp*str_m] + dc_b2_12[lev]*X[ind_m-sp-sp*str_m] + dc_b2_13[lev]*X[ind_m-2*sp-sp*str_m]; RHS3 = dc_b3_11[lev]*X[ind_m-2*sp*str_m] + dc_b3_12[lev]*X[ind_m-sp-2*sp*str_m] + dc_b3_13[lev]*X[ind_m-2*sp-2*sp*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); //This mulvec part belongs to the pinned point. Hence, it is trimmed out and not involved in computation at all. ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); } } } } subans = ans.submat(0,0,tot_p_sol-2,0); return subans; } /***************************************************************************************/ vec mulvec(vec X, mg_grid * level, int lev) { int sp=pow(2,lev), ind; int nx_sol = (nx/sp)-1, ny_sol = (ny/sp)-1; //No of points for the computational domain after compatibility condition int tot_p_sol = (nx_sol)*(ny_sol); //No.of points that are solved for directly. The top and the farthest right lines of points are //removed due to periodicity vec ans(tot_p_sol), subans(tot_p_sol-1); int i_m, j_m, str_m=nx_sol, ind_m; int st_inx = sp, en_inx = nx - sp; int st_iny = sp, en_iny = ny - sp; double RHS1, RHS2, RHS3, RHS4, RHS5, RHS6; for(int j=st_iny;j<=en_iny;j=j+sp) { for(int i=st_inx;i<=en_inx;i=i+sp) { ind = i + j*str_x; i_m = i/sp-1; j_m = j/sp-1; ind_m = i_m + j_m*str_m; /*******************Case-1 j=1***********************/ if(j==st_iny) { if(i==st_inx) //Checked { RHS1 = dc_b1_11[lev]*X[ind_m] + dc_b1_12[lev]*X[ind_m+1] + dc_b1_13[lev]*X[ind_m+2] ; RHS2 = dc_b2_11[lev]*X[ind_m+str_m] + dc_b2_12[lev]*X[ind_m+1+str_m] + dc_b2_13[lev]*X[ind_m+2+str_m]; RHS3 = dc_b3_11[lev]*X[ind_m+2*str_m] + dc_b3_12[lev]*X[ind_m+1+2*str_m] + dc_b3_13[lev]*X[ind_m+2+2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); //cout<<dc_b1_11[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b2_11[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b3_11[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_ny1_11[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_ny1_13[lev]<<"\n"<<dc_ny_11[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_13[lev]<<"\n"; } else if(i==st_inx+sp) //checked { RHS1 = dc_nb1_21[lev]*X[ind_m-1] + dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m+1] + dc_nb1_24[lev]*X[ind_m+2] ; RHS2 = dc_nb2_21[lev]*X[ind_m-1+str_m] + dc_nb2_22[lev]*X[ind_m+str_m] + dc_nb2_23[lev]*X[ind_m+1+str_m] + dc_nb2_24[lev]*X[ind_m+2+str_m] ; RHS3 = dc_nb3_21[lev]*X[ind_m-1+2*str_m] + dc_nb3_22[lev]*X[ind_m+2*str_m] + dc_nb3_23[lev]*X[ind_m+1+2*str_m] + dc_nb3_24[lev]*X[ind_m+2+2*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); // cout<<dc_nb1_21[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_ny_21[lev]<<"\n"<<dc_ny_22[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_24[lev]<<"\n"; } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { RHS1 = dc_i1_32[lev]*X[ind_m-2] + dc_i1_33[lev]*X[ind_m-1] + dc_i1_34[lev]*X[ind_m] + dc_i1_35[lev]*X[ind_m+1] + dc_i1_36[lev]*X[ind_m+2]; RHS2 = dc_i2_32[lev]*X[ind_m-2+str_m] + dc_i2_33[lev]*X[ind_m-1+str_m] + dc_i2_34[lev]*X[ind_m+str_m] + dc_i2_35[lev]*X[ind_m+1+str_m] + dc_i2_36[lev]*X[ind_m+2+str_m]; RHS3 = dc_i3_32[lev]*X[ind_m-2+2*str_m] + dc_i3_33[lev]*X[ind_m-1+2*str_m] + dc_i3_34[lev]*X[ind_m+2*str_m] + dc_i3_35[lev]*X[ind_m+1+2*str_m] + dc_i3_36[lev]*X[ind_m+2+2*str_m]; // ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb1_21[lev]*X[ind_m+1] + dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m-1] + dc_nb1_24[lev]*X[ind_m-2] ; RHS2 = dc_nb2_21[lev]*X[ind_m+1+str_m] + dc_nb2_22[lev]*X[ind_m+str_m] + dc_nb2_23[lev]*X[ind_m-1+str_m] + dc_nb2_24[lev]*X[ind_m-2+str_m] ; RHS3 = dc_nb3_21[lev]*X[ind_m+1+2*str_m] + dc_nb3_22[lev]*X[ind_m+2*str_m] + dc_nb3_23[lev]*X[ind_m-1+2*str_m] + dc_nb3_24[lev]*X[ind_m-2+2*str_m]; //cout<<dc_nb1_24[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"<<dc_nb1_21[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_22[lev]<<"\n"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); } else //Checked { RHS1 = dc_b1_11[lev]*X[ind_m] + dc_b1_12[lev]*X[ind_m-1] + dc_b1_13[lev]*X[ind_m-2]; RHS2 = dc_b2_11[lev]*X[ind_m+str_m] + dc_b2_12[lev]*X[ind_m-1+str_m] + dc_b2_13[lev]*X[ind_m-2+str_m]; RHS3 = dc_b3_11[lev]*X[ind_m+2*str_m] + dc_b3_12[lev]*X[ind_m-1+2*str_m] + dc_b3_13[lev]*X[ind_m-2+2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3); ans(ind_m) = (RHS1 + RHS2 + RHS3); //cout<<dc_b1_12[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b1_11[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_11[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_11[lev]<<"\n"<<dc_ny1_13[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_ny1_11[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_12[lev]<<"\n"; } } /*****************Case-2 (j=2)**********************/ if(j==st_iny+sp) { if(i==st_inx) //Checked { RHS1 = dc_b4_11[lev]*X[ind_m-str_m] + dc_b4_12[lev]*X[ind_m+1-str_m] + dc_b4_13[lev]*X[ind_m+2-str_m]; RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m+1] + dc_b5_13[lev]*X[ind_m+2]; RHS3 = dc_b6_11[lev]*X[ind_m+str_m] + dc_b6_12[lev]*X[ind_m+1+str_m] + dc_b6_13[lev]*X[ind_m+2+str_m] ; RHS4 = dc_b7_11[lev]*X[ind_m+2*str_m] + dc_b7_12[lev]*X[ind_m+1+2*str_m] + dc_b7_13[lev]*X[ind_m+2+2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4) ; ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4) ; //cout<<dc_b4_11[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_pb7_11[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"; } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb4_21[lev]*X[ind_m-1-str_m] + dc_nb4_22[lev]*X[ind_m-str_m] + dc_nb4_23[lev]*X[ind_m+1-str_m] + dc_nb4_24[lev]*X[ind_m+2-str_m]; RHS2 = dc_nb5_21[lev]*X[ind_m-1] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m+1] + dc_nb5_24[lev]*X[ind_m+2]; RHS3 = dc_nb6_21[lev]*X[ind_m-1+str_m] + dc_nb6_22[lev]*X[ind_m+str_m] + dc_nb6_23[lev]*X[ind_m+1+str_m] + dc_nb6_24[lev]*X[ind_m+2+str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m-1+2*str_m] + dc_nb7_22[lev]*X[ind_m+2*str_m] + dc_nb7_23[lev]*X[ind_m+1+2*str_m] + dc_nb7_24[lev]*X[ind_m+2+2*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_nb4_21[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_pb7_21[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"<<dc_pb7_23[lev]<<"\n"<<dc_pb7_24[lev]<<"\n"; } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { RHS1 = dc_i4_32[lev]*X[ind_m-2-str_m] + dc_i4_33[lev]*X[ind_m-1-str_m] + dc_i4_34[lev]*X[ind_m-str_m] + dc_i4_35[lev]*X[ind_m+1-str_m] + dc_i4_36[lev]*X[ind_m+2-str_m]; RHS2 = dc_i5_32[lev]*X[ind_m-2] + dc_i5_33[lev]*X[ind_m-1] + dc_i5_34[lev]*X[ind_m] + dc_i5_35[lev]*X[ind_m+1] + dc_i5_36[lev]*X[ind_m+2]; RHS3 = dc_i6_32[lev]*X[ind_m-2+str_m] + dc_i6_33[lev]*X[ind_m-1+str_m] + dc_i6_34[lev]*X[ind_m+str_m] + dc_i6_35[lev]*X[ind_m+1+str_m] + dc_i6_36[lev]*X[ind_m+2+str_m]; RHS4 = dc_i7_32[lev]*level[lev].phi_s[ind_m-2+2*str_m] + dc_i7_33[lev]*X[ind_m-1+2*str_m] + dc_i7_34[lev]*X[ind_m+2*str_m] + dc_i7_35[lev]*X[ind_m+1+2*str_m] + dc_i7_36[lev]*X[ind_m+2+2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); /*cout<<dc_i4_32[lev]<<"\n"<<dc_i4_33[lev]<<"\n"<<dc_i4_34[lev]<<"\n"<<dc_i4_35[lev]<<"\n"<<dc_i4_36[lev]<<"\n"<<dc_i5_32[lev]<<"\n"<<dc_i5_33[lev]<<"\n"<<dc_i5_34[lev]<<"\n"<<dc_i5_35[lev]<<"\n"<<dc_i5_36[lev]<<"\n"<<dc_i6_32[lev]<<"\n"<<dc_i6_33[lev]<<"\n"<<dc_i6_34[lev]<<"\n"<<dc_i6_35[lev]<<"\n"<<dc_i6_36[lev]<<"\n"<<dc_i7_33[lev]<<"\n"<<dc_i7_34[lev]<<"\n"<<dc_i7_35[lev]<<"\n"<<dc_pb7_33[lev]<<"\n"<<dc_pb7_34[lev]<<"\n"<<dc_pb7_35[lev]<<"\n"; cout<<"--------------------------------------";*/ } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb4_21[lev]*X[ind_m+1-str_m] + dc_nb4_22[lev]*X[ind_m-str_m] + dc_nb4_23[lev]*X[ind_m-1-str_m] + dc_nb4_24[lev]*X[ind_m-2-str_m]; RHS2 = dc_nb5_21[lev]*X[ind_m+1] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m-1] + dc_nb5_24[lev]*X[ind_m-2]; RHS3 = dc_nb6_21[lev]*X[ind_m+1+str_m] + dc_nb6_22[lev]*X[ind_m+str_m] + dc_nb6_23[lev]*X[ind_m-1+str_m] + dc_nb6_24[lev]*X[ind_m-2+str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m+1+2*str_m] + dc_nb7_22[lev]*X[ind_m+2*str_m] + dc_nb7_23[lev]*X[ind_m-1+2*str_m] + dc_nb7_24[lev]*X[ind_m-2+2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_nb4_24[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"<<dc_nb4_21[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_pb7_23[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"; } else //checked { RHS1 = dc_b4_11[lev]*X[ind_m-str_m] + dc_b4_12[lev]*X[ind_m-1-str_m] + dc_b4_13[lev]*X[ind_m-2-str_m] ; RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m-1] + dc_b5_13[lev]*X[ind_m-2]; RHS3 = dc_b6_11[lev]*X[ind_m+str_m] + dc_b6_12[lev]*X[ind_m-1+str_m] + dc_b6_13[lev]*X[ind_m-2+str_m]; RHS4 = dc_b7_11[lev]*X[ind_m+2*str_m] + dc_b7_12[lev]*X[ind_m-1+2*str_m] + dc_b7_13[lev]*X[ind_m-2+2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4) ; ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4) ; // cout<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"; } } /*****************Case-3 (j>=3 and j<=ny-3)**********************/ if(j>=st_iny+2*sp && j<=en_iny-2*sp) { if(i==st_inx) //Checked { RHS1 = dc_b8_11[lev]*X[ind_m-2*str_m] + dc_b8_12[lev]*X[ind_m+1-2*str_m] + dc_b8_13[lev]*X[ind_m+2-2*str_m]; RHS2 = dc_b9_11[lev]*X[ind_m-str_m] + dc_b9_12[lev]*X[ind_m+1-str_m] + dc_b9_13[lev]*X[ind_m+2-str_m]; RHS3 = dc_b10_11[lev]*X[ind_m] + dc_b10_12[lev]*X[ind_m+1] + dc_b10_13[lev]*X[ind_m+2] ; RHS4 = dc_b11_11[lev]*X[ind_m+str_m] + dc_b11_12[lev]*X[ind_m+1+str_m] + dc_b11_13[lev]*X[ind_m+2+str_m] ; RHS5 = dc_b12_11[lev]*X[ind_m+2*str_m] + dc_b12_12[lev]*X[ind_m+1+2*str_m] + dc_b12_13[lev]*X[ind_m+2+2*str_m]; //cout<<dc_b8_11[lev]<<"\n"<<dc_b8_12[lev]<<"\n"<<dc_b8_12[lev]<<"\n"<<dc_b9_11[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b10_11[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b11_11[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b12_11[lev]<<"\n"<<dc_b12_12[lev]<<"\n"<<dc_b12_12[lev]<<"\n"; //cout<<"--------------------------------------------"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb8_21[lev]*X[ind_m-1-2*str_m] + dc_nb8_22[lev]*X[ind_m-2*str_m] + dc_nb8_23[lev]*X[ind_m+1-2*str_m] + dc_nb8_24[lev]*X[ind_m+2-2*str_m]; RHS2 = dc_nb9_21[lev]*X[ind_m-1-str_m] + dc_nb9_22[lev]*X[ind_m-str_m] + dc_nb9_23[lev]*X[ind_m+1-str_m] + dc_nb9_24[lev]*X[ind_m+2-str_m]; RHS3 = dc_nb10_21[lev]*X[ind_m-1] + dc_nb10_22[lev]*X[ind_m] + dc_nb10_23[lev]*X[ind_m+1] + dc_nb10_24[lev]*X[ind_m+2]; RHS4 = dc_nb11_21[lev]*X[ind_m-1+str_m] + dc_nb11_22[lev]*X[ind_m+str_m] + dc_nb11_23[lev]*X[ind_m+1+str_m] + dc_nb11_24[lev]*X[ind_m+2+str_m]; RHS5 = dc_nb12_21[lev]*X[ind_m-1+2*str_m] + dc_nb12_22[lev]*X[ind_m+2*str_m] + dc_nb12_23[lev]*X[ind_m+1+2*str_m] + dc_nb12_24[lev]*X[ind_m+2+2*str_m] ; // ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); /* cout<<dc_nb8_21[lev]<<"\n"<<dc_nb8_22[lev]<<"\n"<<dc_nb8_23[lev]<<"\n"<<dc_nb9_21[lev]<<"\n"<<dc_nb9_22[lev]<<"\n"<<dc_nb9_23[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb10_21[lev]<<"\n"<<dc_nb10_22[lev]<<"\n"<<dc_nb10_23[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb11_21[lev]<<"\n"<<dc_nb11_22[lev]<<"\n"<<dc_nb11_23[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb12_21[lev]<<"\n"<<dc_nb12_22[lev]<<"\n"<<dc_nb12_23[lev]<<"\n"; cout<<"--------------------------------------------";*/ } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { RHS1 = dc_i8_33[lev]*X[ind_m-1-2*str_m] + dc_i8_34[lev]*X[ind_m-2*str_m] + dc_i8_35[lev]*X[ind_m+1-2*str_m]; RHS2 = dc_i9_32[lev]*X[ind_m-2-str_m] + dc_i9_33[lev]*X[ind_m-1-str_m] + dc_i9_34[lev]*X[ind_m-str_m] + dc_i9_35[lev]*X[ind_m+1-str_m] + dc_i9_36[lev]*X[ind_m+2-str_m]; RHS3 = dc_i10_32[lev]*X[ind_m-2] + dc_i10_33[lev]*X[ind_m-1] + dc_i10_34[lev]*X[ind_m] + dc_i10_35[lev]*X[ind_m+1] + dc_i10_36[lev]*X[ind_m+2]; RHS4 = dc_i11_32[lev]*X[ind_m-2+str_m] + dc_i11_33[lev]*X[ind_m-1+str_m] + dc_i11_34[lev]*X[ind_m+str_m] + dc_i11_35[lev]*X[ind_m+1+str_m] + dc_i11_36[lev]*X[ind_m+2+str_m]; RHS5 = dc_i12_33[lev]*X[ind_m-1+2*str_m] + dc_i12_34[lev]*X[ind_m+2*str_m] + dc_i12_35[lev]*X[ind_m+1+2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); /*cout<<dc_i8_33[lev]<<"\n"<<dc_i8_34[lev]<<"\n"<<dc_i8_35[lev]<<"\n"<<dc_i9_32[lev]<<"\n"<<dc_i9_33[lev]<<"\n"<<dc_i9_34[lev]<<"\n"<<dc_i9_35[lev]<<"\n"<<dc_i9_36[lev]<<"\n"<<dc_i10_32[lev]<<"\n"<<dc_i10_33[lev]<<"\n"<<dc_i10_34[lev]<<"\n"<<dc_i10_35[lev]<<"\n"<<dc_i10_36[lev]<<"\n"<<dc_i11_32[lev]<<"\n"<<dc_i11_33[lev]<<"\n"<<dc_i11_34[lev]<<"\n"<<dc_i11_35[lev]<<"\n"<<dc_i11_36[lev]<<"\n"<<dc_i12_33[lev]<<"\n"<<dc_i12_34[lev]<<"\n"<<dc_i12_35[lev]<<"\n"; cout<<"--------------------------------------------";*/ } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb8_21[lev]*X[ind_m+1-2*str_m] + dc_nb8_22[lev]*X[ind_m-2*str_m] + dc_nb8_23[lev]*X[ind_m-1-2*str_m] + dc_nb8_24[lev]*X[ind_m-2-2*str_m]; RHS2 = dc_nb9_21[lev]*X[ind_m+1-str_m] + dc_nb9_22[lev]*X[ind_m-str_m] + dc_nb9_23[lev]*X[ind_m-1-str_m] + dc_nb9_24[lev]*X[ind_m-2-str_m]; RHS3 = dc_nb10_21[lev]*X[ind_m+1] + dc_nb10_22[lev]*X[ind_m] + dc_nb10_23[lev]*X[ind_m-1] + dc_nb10_24[lev]*X[ind_m-2]; RHS4 = dc_nb11_21[lev]*X[ind_m+1+str_m] + dc_nb11_22[lev]*X[ind_m+str_m] + dc_nb11_23[lev]*X[ind_m-1+str_m] + dc_nb11_24[lev]*X[ind_m-2+str_m]; if(j+2*sp==en_iny) { RHS5 = dc_nb12_22[lev]*X[ind_m+2*str_m] + dc_nb12_23[lev]*X[ind_m-1+2*str_m] + dc_nb12_24[lev]*X[ind_m-2+2*str_m]; //lcr } else { RHS5 = dc_nb12_21[lev]*X[ind_m+1+2*str_m] + dc_nb12_22[lev]*X[ind_m+2*str_m] + dc_nb12_23[lev]*X[ind_m-1+2*str_m] + dc_nb12_24[lev]*X[ind_m-2+2*str_m]; } //cout<<dc_nb8_23[lev]<<"\n"<<dc_nb8_22[lev]<<"\n"<<dc_nb8_21[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb9_24[lev]<<"\n"<<dc_nb9_23[lev]<<"\n"<<dc_nb9_22[lev]<<"\n"<<dc_nb9_21[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb10_24[lev]<<"\n"<<dc_nb10_23[lev]<<"\n"<<dc_nb10_22[lev]<<"\n"<<dc_nb10_21[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb11_24[lev]<<"\n"<<dc_nb11_23[lev]<<"\n"<<dc_nb11_22[lev]<<"\n"<<dc_nb11_21[lev]<<"\n"<<dc_nb12_23[lev]<<"\n"<<dc_nb12_22[lev]<<"\n"<<dc_nb12_21[lev]<<"\n"; //cout<<"----------------------------------------------\n"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); } else //Checked { RHS1 = dc_b8_11[lev]*X[ind_m-2*str_m] + dc_b8_12[lev]*X[ind_m-1-2*str_m] + dc_b8_13[lev]*X[ind_m-2-2*str_m]; RHS2 = dc_b9_11[lev]*X[ind_m-str_m] + dc_b9_12[lev]*X[ind_m-1-str_m] + dc_b9_13[lev]*X[ind_m-2-str_m]; RHS3 = dc_b10_11[lev]*X[ind_m] + dc_b10_12[lev]*X[ind_m-1] + dc_b10_13[lev]*X[ind_m-2]; RHS4 = dc_b11_11[lev]*X[ind_m+str_m] + dc_b11_12[lev]*X[ind_m-1+str_m] + dc_b11_13[lev]*X[ind_m-2+str_m]; if(j+2*sp==en_iny) { RHS5 = dc_b12_12[lev]*X[ind_m-1+2*str_m] + dc_b12_13[lev]*X[ind_m-2+2*str_m]; //lcr } else { RHS5 = dc_b12_11[lev]*X[ind_m+2*str_m] + dc_b12_12[lev]*X[ind_m-1+2*str_m] + dc_b12_13[lev]*X[ind_m-2+2*str_m]; } //cout<<dc_b8_12[lev]<<"\n"<<dc_b8_12[lev]<<"\n"<<dc_b8_11[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_13[lev]<<"\n"<<dc_b9_12[lev]<<"\n"<<dc_b9_11[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_13[lev]<<"\n"<<dc_b10_12[lev]<<"\n"<<dc_b10_11[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_13[lev]<<"\n"<<dc_b11_12[lev]<<"\n"<<dc_b11_11[lev]<<"\n"<<dc_b12_12[lev]<<"\n"<<dc_b12_12[lev]<<"\n"<<dc_b12_11[lev]<<"\n"; //cout<<"---------------------------------------\n"; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4 + RHS5); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4 + RHS5); } } /*****************Case-4(j=ny-2)**********************/ if(j==en_iny-sp) { if(i==st_inx) //checked { RHS1 = dc_b4_11[lev]*X[ind_m+str_m] + dc_b4_12[lev]*X[ind_m+1+str_m] + dc_b4_13[lev]*X[ind_m+2+str_m]; RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m+1] + dc_b5_13[lev]*X[ind_m+2]; RHS3 = dc_b6_11[lev]*X[ind_m-str_m] + dc_b6_12[lev]*X[ind_m+1-str_m] + dc_b6_13[lev]*X[ind_m+2-str_m]; RHS4 = dc_b7_11[lev]*X[ind_m-2*str_m] + dc_b7_12[lev]*X[ind_m+1-2*str_m] + dc_b7_13[lev]*X[ind_m+2-2*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_pb7_11[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b4_11[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"; } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb4_21[lev]*X[ind_m-1+str_m] + dc_nb4_22[lev]*X[ind_m+str_m] + dc_nb4_23[lev]*X[ind_m+1+str_m] + dc_nb4_24[lev]*X[ind_m+2+str_m]; RHS2 = dc_nb5_21[lev]*X[ind_m-1] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m+1] + dc_nb5_24[lev]*X[ind_m+2]; RHS3 = dc_nb6_21[lev]*X[ind_m-1-str_m] + dc_nb6_22[lev]*X[ind_m-str_m] + dc_nb6_23[lev]*X[ind_m+1-str_m] + dc_nb6_24[lev]*X[ind_m+2-str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m-1-2*str_m] + dc_nb7_22[lev]*X[ind_m-2*str_m] + dc_nb7_23[lev]*X[ind_m+1-2*str_m] + dc_nb7_24[lev]*X[ind_m+2-2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*(RHS1 + RHS2 + RHS3 + RHS4); ans(ind_m) = (RHS1 + RHS2 + RHS3 + RHS4); //cout<<dc_pb7_21[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"<<dc_pb7_23[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb4_21[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"; } else if(i>st_inx+sp && i<en_inx-sp) //Checked { if(i+2*sp==en_inx) { RHS1 = dc_i4_32[lev]*X[ind_m-2+str_m] + dc_i4_33[lev]*X[ind_m-1+str_m] + dc_i4_34[lev]*X[ind_m+str_m] + dc_i4_35[lev]*X[ind_m+1+str_m] ; //lcr } else { RHS1 = dc_i4_32[lev]*X[ind_m-2+str_m] + dc_i4_33[lev]*X[ind_m-1+str_m] + dc_i4_34[lev]*X[ind_m+str_m] + dc_i4_35[lev]*X[ind_m+1+str_m] + dc_i4_36[lev]*X[ind_m+2+str_m]; } /*cout<<dc_pb7_33[lev]<<"\n"<<dc_pb7_34[lev]<<"\n"<<dc_pb7_35[lev]<<"\n"<<dc_i7_33[lev]<<"\n"<<dc_i7_34[lev]<<"\n"<<dc_i7_35[lev]<<"\n"<<dc_i6_32[lev]<<"\n"<<dc_i6_33[lev]<<"\n"<<dc_i6_34[lev]<<"\n"<<dc_i6_35[lev]<<"\n"<<dc_i6_36[lev]<<"\n"<<dc_i5_32[lev]<<"\n"<<dc_i5_33[lev]<<"\n"<<dc_i5_34[lev]<<"\n"<<dc_i5_35[lev]<<"\n"<<dc_i5_36[lev]<<"\n"<<dc_i4_32[lev]<<"\n"<<dc_i4_33[lev]<<"\n"<<dc_i4_34[lev]<<"\n"<<dc_i4_35[lev]<<"\n"<<dc_i4_36[lev]<<"\n"; cout<<"ind_m= "<<ind_m<<"\n"; cout<<"----------------------------------------------------\n"; */ RHS2 = dc_i5_32[lev]*X[ind_m-2] + dc_i5_33[lev]*X[ind_m-1] + dc_i5_34[lev]*X[ind_m] + dc_i5_35[lev]*X[ind_m+1] + dc_i5_36[lev]*X[ind_m+2]; RHS3 = dc_i6_32[lev]*X[ind_m-2-str_m] + dc_i6_33[lev]*X[ind_m-1-str_m] + dc_i6_34[lev]*X[ind_m-str_m] + dc_i6_35[lev]*X[ind_m+1-str_m] + dc_i6_36[lev]*X[ind_m+2-str_m]; RHS4 = dc_i7_32[lev]*X[ind_m-2-2*str_m] + dc_i7_33[lev]*X[ind_m-1-2*str_m] + dc_i7_34[lev]*X[ind_m-2*str_m] + dc_i7_35[lev]*X[ind_m+1-2*str_m] + dc_i7_36[lev]*X[ind_m+2-2*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 + RHS4 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 + RHS4 ) ; } else if(i==en_inx-sp) //checked { RHS1 = dc_nb4_22[lev]*X[ind_m+str_m] + dc_nb4_23[lev]*X[ind_m-1+str_m] + dc_nb4_24[lev]*X[ind_m-2+str_m]; //lcr RHS2 = dc_nb5_21[lev]*X[ind_m+1] + dc_nb5_22[lev]*X[ind_m] + dc_nb5_23[lev]*X[ind_m-1] + dc_nb5_24[lev]*X[ind_m-2]; RHS3 = dc_nb6_21[lev]*X[ind_m+1-str_m] + dc_nb6_22[lev]*X[ind_m-str_m] + dc_nb6_23[lev]*X[ind_m-1-str_m] + dc_nb6_24[lev]*X[ind_m-2-str_m]; RHS4 = dc_nb7_21[lev]*X[ind_m+1-2*str_m] + dc_nb7_22[lev]*X[ind_m-2*str_m] + dc_nb7_23[lev]*X[ind_m-1-2*str_m] + dc_nb7_24[lev]*X[ind_m-2-2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 + RHS4 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 + RHS4 ) ; //cout<<"ind_m= "<<ind_m<<"\n"; //cout<<dc_pb7_23[lev]<<"\n"<<dc_pb7_22[lev]<<"\n"<<dc_pb7_21[lev]<<"\n"<<dc_nb7_23[lev]<<"\n"<<dc_nb7_22[lev]<<"\n"<<dc_nb7_21[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_24[lev]<<"\n"<<dc_nb6_23[lev]<<"\n"<<dc_nb6_22[lev]<<"\n"<<dc_nb6_21[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_24[lev]<<"\n"<<dc_nb5_23[lev]<<"\n"<<dc_nb5_22[lev]<<"\n"<<dc_nb5_21[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_24[lev]<<"\n"<<dc_nb4_23[lev]<<"\n"<<dc_nb4_22[lev]<<"\n"; } else //Checked { RHS1 = dc_b4_12[lev]*X[ind_m-1+str_m] + dc_b4_13[lev]*X[ind_m-2+str_m]; //lcr RHS2 = dc_b5_11[lev]*X[ind_m] + dc_b5_12[lev]*X[ind_m-1] + dc_b5_13[lev]*X[ind_m-2]; RHS3 = dc_b6_11[lev]*X[ind_m-str_m] + dc_b6_12[lev]*X[ind_m-1-str_m] + dc_b6_13[lev]*X[ind_m-2-str_m]; RHS4 = dc_b7_11[lev]*X[ind_m-2*str_m] + dc_b7_12[lev]*X[ind_m-1-2*str_m] + dc_b7_13[lev]*X[ind_m-2-2*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 + RHS4 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 + RHS4 ) ; // cout<<dc_pb7_12[lev]<<"\n"<<dc_pb7_12[lev]<<"\n"<<dc_pb7_11[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_12[lev]<<"\n"<<dc_b7_11[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_13[lev]<<"\n"<<dc_b6_12[lev]<<"\n"<<dc_b6_11[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_13[lev]<<"\n"<<dc_b5_12[lev]<<"\n"<<dc_b5_11[lev]<<"\n"<<dc_b4_12[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_13[lev]<<"\n"<<dc_b4_12[lev]<<"\n"; } } /****************************************Case-5(j=en_iny)******************************************/ if(j==en_iny) { if(i==st_inx) { RHS1 = dc_b1_11[lev]*X[ind_m] + dc_b1_12[lev]*X[ind_m+1] + dc_b1_13[lev]*X[ind_m+2]; RHS2 = dc_b2_11[lev]*X[ind_m-str_m] + dc_b2_12[lev]*X[ind_m+1-str_m] + dc_b2_13[lev]*X[ind_m+2-str_m]; RHS3 = dc_b3_11[lev]*X[ind_m-2*str_m] + dc_b3_12[lev]*X[ind_m+1-2*str_m] + dc_b3_13[lev]*X[ind_m+2-2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); //cout<<dc_ny_11[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_13[lev]<<"\n"<<dc_ny_12[lev]<<"\n"<<dc_ny1_11[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_ny1_12[lev]<<"\n"<<dc_b3_11[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b3_12[lev]<<"\n"<<dc_b2_11[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_13[lev]<<"\n"<<dc_b2_12[lev]<<"\n"<<dc_b1_11[lev]<<"\n"<<dc_b1_12[lev]<<"\n"<<dc_b1_13[lev]<<"\n"<<dc_b1_13[lev]<<"\n"; } else if(i==st_inx+sp) //Checked { RHS1 = dc_nb1_21[lev]*X[ind_m-1] + dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m+1] + dc_nb1_24[lev]*X[ind_m+2] ; RHS2 = dc_nb2_21[lev]*X[ind_m-1-str_m] + dc_nb2_22[lev]*X[ind_m-str_m] + dc_nb2_23[lev]*X[ind_m+1-str_m] + dc_nb2_24[lev]*X[ind_m+2-str_m]; RHS3 = dc_nb3_21[lev]*X[ind_m-1-2*str_m] + dc_nb3_22[lev]*X[ind_m-2*str_m] + dc_nb3_23[lev]*X[ind_m+1-2*str_m] + dc_nb3_24[lev]*X[ind_m+2-2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ) ; ans(ind_m) = ( RHS1 + RHS2 + RHS3 ) ; /*cout<<"ind_m = "<<ind_m<<"\n"; cout<<dc_ny_21[lev]<<"\n"<<dc_ny_22[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_nb3_24[lev]<<"\n"<<dc_nb3_24[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb1_21[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_24[lev]<<"\n";*/ } else if(i>=st_inx+2*sp && i<=en_inx-2*sp) //Checked { if(i+2*sp==en_inx) { RHS1 = dc_i1_32[lev]*X[ind_m-2] + dc_i1_33[lev]*X[ind_m-1] + dc_i1_34[lev]*X[ind_m] + dc_i1_35[lev]*X[ind_m+1]; //lcr } else { RHS1 = dc_i1_32[lev]*X[ind_m-2] + dc_i1_33[lev]*X[ind_m-1] + dc_i1_34[lev]*X[ind_m] + dc_i1_35[lev]*X[ind_m+1] + dc_i1_36[lev]*X[ind_m+2]; } /*cout<<"ind_m= "<<ind_m<<"\n"; cout<<dc_ny_32[lev]<<"\n"<<dc_ny_33[lev]<<"\n"<<dc_ny_34[lev]<<"\n"<<dc_ny_35[lev]<<"\n"<<dc_ny_36[lev]<<"\n"<<dc_ny1_33[lev]<<"\n"<<dc_ny1_34[lev]<<"\n"<<dc_ny1_35[lev]<<"\n"<<dc_i3_33[lev]<<"\n"<<dc_i3_34[lev]<<"\n"<<dc_i3_35[lev]<<"\n"<<dc_i2_32[lev]<<"\n"<<dc_i2_33[lev]<<"\n"<<dc_i2_34[lev]<<"\n"<<dc_i2_35[lev]<<"\n"<<dc_i2_36[lev]<<"\n"<<dc_i1_32[lev]<<"\n"<<dc_i1_33[lev]<<"\n"<<dc_i1_34[lev]<<"\n"<<dc_i1_35[lev]<<"\n"<<dc_i1_36[lev]<<"\n"; cout<<"---------------------------------------------------\n";*/ RHS2 = dc_i2_32[lev]*X[ind_m-2-str_m] + dc_i2_33[lev]*X[ind_m-1-str_m] + dc_i2_34[lev]*X[ind_m-str_m] + dc_i2_35[lev]*X[ind_m+1-str_m] + dc_i2_36[lev]*X[ind_m+2-str_m]; RHS3 = dc_i3_32[lev]*X[ind_m-2-2*str_m] + dc_i3_33[lev]*X[ind_m-1-2*str_m] + dc_i3_34[lev]*X[ind_m-2*str_m] + dc_i3_35[lev]*X[ind_m+1-2*str_m] + dc_i3_36[lev]*X[ind_m+2-2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); } else if(i==en_inx-sp) //Checked { RHS1 = dc_nb1_22[lev]*X[ind_m] + dc_nb1_23[lev]*X[ind_m-1] + dc_nb1_24[lev]*X[ind_m-2]; //lcr RHS2 = dc_nb2_21[lev]*X[ind_m+1-str_m] + dc_nb2_22[lev]*X[ind_m-str_m] + dc_nb2_23[lev]*X[ind_m-1-str_m] + dc_nb2_24[lev]*X[ind_m-2-str_m]; RHS3 = dc_nb3_21[lev]*X[ind_m+1-2*str_m] + dc_nb3_22[lev]*X[ind_m-2*str_m] + dc_nb3_23[lev]*X[ind_m-1-2*str_m] + dc_nb3_24[lev]*X[ind_m-2-2*str_m] ; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); /*cout<<"ind_m= "<<ind_m<<"\n"; cout<<dc_ny_24[lev]<<"\n"<<dc_ny_24[lev]<<"\n"<<dc_ny_23[lev]<<"\n"<<dc_ny_22[lev]<<"\n"<<dc_ny_21[lev]<<"\n"<<dc_ny1_23[lev]<<"\n"<<dc_ny1_22[lev]<<"\n"<<dc_ny1_21[lev]<<"\n"<<dc_nb3_23[lev]<<"\n"<<dc_nb3_22[lev]<<"\n"<<dc_nb3_21[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_24[lev]<<"\n"<<dc_nb2_23[lev]<<"\n"<<dc_nb2_22[lev]<<"\n"<<dc_nb2_21[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_24[lev]<<"\n"<<dc_nb1_23[lev]<<"\n"<<dc_nb1_22[lev]<<"\n"; */ } else //Checked { RHS1 = dc_b1_12[lev]*X[ind_m-1] + dc_b1_13[lev]*X[ind_m-2]; //lcr RHS2 = dc_b2_11[lev]*X[ind_m-str_m] + dc_b2_12[lev]*X[ind_m-1-str_m] + dc_b2_13[lev]*X[ind_m-2-str_m]; RHS3 = dc_b3_11[lev]*X[ind_m-2*str_m] + dc_b3_12[lev]*X[ind_m-1-2*str_m] + dc_b3_13[lev]*X[ind_m-2-2*str_m]; //ans(ind_m) = level[lev].coeff[ind]*( RHS1 + RHS2 + RHS3 ); //This mulvec part belongs to the pinned point. Hence, it is trimmed out and not involved in computation at all. ans(ind_m) = ( RHS1 + RHS2 + RHS3 ); } } } } subans = ans.submat(0,0,tot_p_sol-2,0); return subans; } /*******************************************************************************/
[ "trinathg@gmail.com" ]
trinathg@gmail.com
6a81efe5382dd9f9e17306b128be49cd8c42d539
53c913bcb36c9b61d6800dc73b8bdcb684bd2f84
/parking/main.cpp
22ad93bebdf9bf4eea9f1fd5402ebb524ad6e7ca
[]
no_license
aymennegra/SmartSupermarker-Desktop
bfb069a2a0edeba74fd4ab0001b558ccf6c2d7aa
75e78ae2b222ab53bde7224b0d97d754a012c4b6
refs/heads/main
2023-06-24T03:43:56.843980
2021-07-29T19:48:25
2021-07-29T19:48:25
390,831,069
0
0
null
null
null
null
UTF-8
C++
false
false
742
cpp
#include "mainwindow.h" #include <QApplication> #include <QMessageBox> #include "connexion.h" #include<iostream> using namespace std; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; Connection c; bool test=c.createconnect(); if(test) { w.show(); QMessageBox::information(nullptr, QObject::tr("database is open"), QObject::tr("connection successful.\n" "Click Cancel to exit."), QMessageBox::Cancel); } else QMessageBox::critical(nullptr, QObject::tr("database is not open"), QObject::tr("connection failed.\n" "Click Cancel to exit."), QMessageBox::Cancel); return a.exec(); }
[ "aymen.negra@esprit.tn" ]
aymen.negra@esprit.tn
f42ec7f78e326c3e2a4b6df7ca386bc5ccacd2aa
0b61696c792ff930bfe300644bd8a495591616e7
/Enemy/EnemyData.cpp
b367dbb851856594dd1738a71f6c278b32161c73
[]
no_license
lordplatypus/Rhythm_Game_Remake
fe9757b15e324ac3ea1a47601ddf27a8834eb25f
0a85af35bf9905411ec30371b8b2c52b7bdd6cf0
refs/heads/master
2023-04-08T05:53:37.280431
2021-04-15T02:30:43
2021-04-15T02:30:43
312,985,470
0
0
null
null
null
null
UTF-8
C++
false
false
275
cpp
#include "EnemyData.h" EnemyData::EnemyData(int ID, int hp, int maxhp, int atk, int range, bool heal, int moneyDropRate, bool visibility) : ID_{ID}, hp_{hp}, maxhp_{maxhp}, atk_{atk}, range_{range}, heal_{heal}, moneyDropRate_{moneyDropRate}, visibility_{visibility} {}
[ "lordplatypus7@gmail.com" ]
lordplatypus7@gmail.com
08636eade2980faac572e02e3b5c94b770f0f192
401d9dcad746b533f0bc8d4150270a54a45e72f1
/testCaseExamples.cpp
420366ee6b73fbd65996ba6691ccbba1ddf67a7d
[]
no_license
unspezifische/Doc-Test-Usage-CPP
b383609aa82a11c96044a4f515b7c8a08d02bc5f
75c1233e8ab9f819ddca5c4fdbe46f7211f68ccf
refs/heads/master
2022-03-12T10:41:49.362748
2019-11-12T16:54:15
2019-11-12T16:54:15
91,846,496
0
0
null
null
null
null
UTF-8
C++
false
false
1,778
cpp
#include <iostream> // used to format and output text #include <vector> // Allows creation and manipulation of vectors // Allows test cases #define DOCTEST_CONFIG_IMPLEMENT #include "doctest.h" using namespace std; // Definitions for example functions bool functionName(std::string input) { return true; } int functionExample(int input) { return 25; } vector<int> vectorFunction1(vector<int> input) { return input; } vector<double> vectorFunction2(vector<double> input) { return input; } double divide(double dividend, double divisor) { return (dividend / divisor); } double getPi() { return 3.14159265359; } // Main int main() { int result = (new doctest::Context())->run(); return result; } TEST_CASE("Example") { CHECK(functionName("input") == true); // Checks for correct bool value CHECK(functionExample(0) == 25); // Checks for correct int value CHECK(vectorFunction1({1, 2, 3, 4}) == vector<int>({1, 2, 3, 4})); CHECK(vectorFunction2({1, 2, 3, 4}) == vector<double>({1.0, 2.0, 3.0, 4.0})); CHECK(divide(5, 2) == 2.5); // Divides 5 by 2 PASSES CHECK(getPi() == 3.14); // FAILS if function returns pi to a greater // precision // than 2 decimal places CHECK(getPi() == doctest::Approx(3.14159)); // Passes because doctest::Approx // overloads the comparisons // operator CHECK(getPi() == doctest::Approx(3.14).epsilon(0.01)); // Adding the epsilon // method changes the // acceptable percent // error }
[ "noreply@github.com" ]
noreply@github.com
068873f79127eccfd571e40c55fa03a565900332
94546aa657f9f17a60100a6c7480f876b780fcbb
/Doubly Lined List.cpp
bfba444a58d52e40bd0b8926f87dae7c47b158b7
[]
no_license
Raiyan11/Data-Structure
84232c224a9360b03333d6c47952633e22aacfdb
e3268ee82a47183a1e0714dc15ec56e3704ba5e9
refs/heads/master
2020-04-03T07:32:42.838331
2018-10-30T04:18:21
2018-10-30T04:18:21
155,105,841
0
0
null
null
null
null
UTF-8
C++
false
false
8,736
cpp
#include<iostream> #include<conio.h> #include<stdlib.h> using namespace std; struct node { int data; struct node * prev; struct node * next; }*head, *last; void createList(int n); void displayList(); void insertAtBeginning(int data); void insertAtEnd(int data); void insertAtN(int data, int position); void deleteFromBeginning(); void deleteFromEnd(); void deleteFromN(int position); void search_by_data(); void node_count(); int totalsum(); int main() { int n, data, choice=1, totalNode; head = NULL; last = NULL; while(choice != 0) { cout << " ============================================" << endl; cout << " DOUBLY LINKED LIST MAIN MANU" << endl; cout << " ============================================" << endl; cout << " 1. Create List" << endl; cout << " 2. Insert First" << endl; cout << " 3. Insert Last" << endl; cout << " 4. Insert N" << endl; cout << " 5. Delete First" << endl; cout << " 6. Delete Last" <<endl; cout << " 7. Delete N" << endl; cout << " 8 Search by data" << endl; cout << " 9. Count The Number Of Nodes" << endl; cout << " 10. SUM " << endl; cout << " 11. Display List" << endl; cout << " 0. Exit" << endl; cout << "--------------------------------------------" << endl; cout << " Enter your choice : "; cin >> choice; switch(choice) { case 1: cout << " Enter the total number of nodes in list: "; cin >> n; createList(n); break; case 2: cout << " Enter data of first node : "; cin >> data; insertAtBeginning(data); break; case 3: cout << " Enter data of last node : "; cin >> data; insertAtEnd(data); break; case 4: cout << " Enter the position where you want to insert new node: "; cin >> n; cout << " Enter data of " << n << " node : "; cin >> data; insertAtN(data, n); break; case 5: deleteFromBeginning(); break; case 6: deleteFromEnd(); break; case 7: cout << " Enter the node position which you want to delete: "; cin >> n; deleteFromN(n); break; case 8: search_by_data(); break; case 9: node_count(); break; case 10: totalNode = totalsum(); cout << endl << " The sum is : " << totalNode << endl; break; case 11: displayList(); break; case 0: break; default: cout << " Error! Invalid choice. Please choose between 0-11"; } cout << endl << endl << endl << endl << endl << endl; } getch(); } void createList(int n) { int i, data; struct node *newNode; if(n >= 1) { head = (struct node *)malloc(sizeof(struct node)); cout << " Enter data for node 1: "; cin >> data; head->data = data; head->prev = NULL; head->next = NULL; last = head; for(i=2; i<=n; i++) { newNode = (struct node *)malloc(sizeof(struct node)); cout << " Enter data for node " << i << ": "; cin >> data; newNode->data = data; newNode->prev = last; newNode->next = NULL; last->next = newNode; last = newNode; } cout << endl << endl << " DOUBLY LINKED LIST CREATED SUCCESSFULLY" << endl; } } void displayList() { struct node * temp; int n = 1; if(head == NULL) { cout << " List is empty." << endl; } else { temp = head; cout << " DATA IN THE LIST: " << endl; while(temp != NULL) { cout << " DATA of " << n << " node = " << temp->data << endl; n++; temp = temp->next; } } } void insertAtBeginning(int data) { struct node * newNode; if(head == NULL) { cout << " Error, List is Empty!" << endl; } else { newNode = (struct node *)malloc(sizeof(struct node)); newNode->data = data; newNode->next = head; newNode->prev = NULL; head->prev = newNode; head = newNode; cout << endl << " NODE INSERTED SUCCESSFULLY AT THE BEGINNING OF THE LIST" << endl; } } void insertAtEnd(int data) { struct node * newNode; if(last == NULL) { cout << " Error, List is empty!" << endl; } else { newNode = (struct node *)malloc(sizeof(struct node)); newNode->data = data; newNode->next = NULL; newNode->prev = last; last->next = newNode; last = newNode; cout << endl << " NODE INSERTED SUCCESSFULLY AT THE END OF LIST" << endl; } } void insertAtN(int data, int position) { int i; struct node * newNode, *temp; if(head == NULL) { cout << " Error, List is empty!" << endl; } else { temp = head; i=1; while(i<position-1 && temp!=NULL) { temp = temp->next; i++; } if(position == 1) { insertAtBeginning(data); } else if(temp == last) { insertAtEnd(data); } else if(temp!=NULL) { newNode = (struct node *)malloc(sizeof(struct node)); newNode->data = data; newNode->next = temp->next; newNode->prev = temp; if(temp->next != NULL) { temp->next->prev = newNode; } temp->next = newNode; cout << endl << " NODE INSERTED SUCCESSFULLY AT " << position << " POSITION" <<endl; } else { cout << " Error, Invalid position" << endl; } } } void deleteFromBeginning() { struct node * toDelete; if(head == NULL) { cout << " Unable to delete. List is empty." << endl; } else { toDelete = head; head = head->next; if (head != NULL) head->prev = NULL; free(toDelete); cout << endl << " SUCCESSFULLY DELETED NODE FROM BEGINNING OF THE LIST." << endl; } } void deleteFromEnd() { struct node * toDelete; if(last == NULL) { cout << " Unable to delete. List is empty." << endl; } else { toDelete = last; last = last->prev; if (last != NULL) last->next = NULL; free(toDelete); cout << endl << " SUCCESSFULLY DELETED NODE FROM END OF THE LIST." << endl; } } void deleteFromN(int position) { struct node *current; int i; current = head; for(i=1; i<position && current!=NULL; i++) { current = current->next; } if(position == 1) { deleteFromBeginning(); } else if(current == last) { deleteFromEnd(); } else if(current != NULL) { current->prev->next = current->next; current->next->prev = current->prev; free(current); cout << endl << " SUCCESSFULLY DELETED NODE FROM " << position << " POSITION."; } else { cout << " Invalid position!" << endl; } } void search_by_data() { int n, count = 0; last = head; if (last == NULL) { cout << endl << " Error : List empty to search for data"; return; } cout << endl << " Enter data to search : "; cin >> n; while (last != NULL) { if (last->data == n) { cout << endl << " Data found in " << count + 1 << " position" << endl; return; } else last = last->next; count++; } cout << endl << " Error : " << n << " not found in list"; } void node_count() { struct node *q = head; int cnt = 0; while (q != NULL) { q = q->next; cnt++; } cout << endl << " Number of nodes are: "<< cnt << endl; } int totalsum() { int sum = 0; struct node *tmp; tmp = head; while(tmp) { sum += tmp->data; tmp = tmp->next; } return sum; }
[ "noreply@github.com" ]
noreply@github.com
7b4f997e2faecc613f899f0e9770c2213ebd42e1
84830cc39b6c36ed55dabb04a0f4469071074136
/tensorflow/lite/tools/accuracy/ilsvrc/imagenet_model_evaluator.cc
0d0865dc8fc35ed4b22310f7b4ea3b5dc8f1f3cc
[ "Apache-2.0" ]
permissive
avasid/tensorflow
0dc7e7b7b92dd565b31fcbc595c6e7daa494c35e
75982a4ed59454e9840e56deab7506ff87fa66a5
refs/heads/master
2020-05-15T22:48:07.427248
2019-04-21T13:49:40
2019-04-21T13:49:40
182,528,959
0
1
Apache-2.0
2019-10-31T09:24:40
2019-04-21T12:16:53
C++
UTF-8
C++
false
false
11,978
cc
/* Copyright 2018 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/lite/tools/accuracy/ilsvrc/imagenet_model_evaluator.h" #include <dirent.h> #include <fstream> #include <iomanip> #include <mutex> // NOLINT(build/c++11) #include <string> #include <thread> // NOLINT(build/c++11) #include <vector> #include "absl/memory/memory.h" #include "tensorflow/core/platform/logging.h" #include "tensorflow/lite/c/c_api_internal.h" #include "tensorflow/lite/tools/command_line_flags.h" #include "tensorflow/lite/tools/evaluation/proto/evaluation_config.pb.h" #include "tensorflow/lite/tools/evaluation/proto/evaluation_stages.pb.h" #include "tensorflow/lite/tools/evaluation/stages/image_classification_stage.h" #include "tensorflow/lite/tools/evaluation/utils.h" namespace { constexpr char kNumImagesFlag[] = "num_images"; constexpr char kModelOutputLabelsFlag[] = "model_output_labels"; constexpr char kGroundTruthImagesPathFlag[] = "ground_truth_images_path"; constexpr char kGroundTruthLabelsFlag[] = "ground_truth_labels"; constexpr char kBlacklistFilePathFlag[] = "blacklist_file_path"; constexpr char kModelFileFlag[] = "model_file"; std::string StripTrailingSlashes(const std::string& path) { int end = path.size(); while (end > 0 && path[end - 1] == '/') { end--; } return path.substr(0, end); } template <typename T> std::vector<T> GetFirstN(const std::vector<T>& v, int n) { if (n >= v.size()) return v; std::vector<T> result(v.begin(), v.begin() + n); return result; } template <typename T> std::vector<std::vector<T>> Split(const std::vector<T>& v, int n) { if (n <= 0) { return std::vector<std::vector<T>>(); } std::vector<std::vector<T>> vecs(n); int input_index = 0; int vec_index = 0; while (input_index < v.size()) { vecs[vec_index].push_back(v[input_index]); vec_index = (vec_index + 1) % n; input_index++; } return vecs; } // File pattern for imagenet files. const char* const kImagenetFilePattern = "*.[jJ][pP][eE][gG]"; } // namespace namespace tensorflow { namespace metrics { class CompositeObserver : public ImagenetModelEvaluator::Observer { public: explicit CompositeObserver(const std::vector<Observer*>& observers) : observers_(observers) {} void OnEvaluationStart(const std::unordered_map<uint64_t, int>& shard_id_image_count_map) override { std::lock_guard<std::mutex> lock(mu_); for (auto observer : observers_) { observer->OnEvaluationStart(shard_id_image_count_map); } } void OnSingleImageEvaluationComplete( uint64_t shard_id, const tflite::evaluation::TopkAccuracyEvalMetrics& metrics, const std::string& image) override { std::lock_guard<std::mutex> lock(mu_); for (auto observer : observers_) { observer->OnSingleImageEvaluationComplete(shard_id, metrics, image); } } private: const std::vector<ImagenetModelEvaluator::Observer*>& observers_; std::mutex mu_; }; /*static*/ TfLiteStatus ImagenetModelEvaluator::Create( int argc, char* argv[], int num_threads, std::unique_ptr<ImagenetModelEvaluator>* model_evaluator) { Params params; params.number_of_images = 100; std::vector<tflite::Flag> flag_list = { tflite::Flag::CreateFlag(kNumImagesFlag, &params.number_of_images, "Number of examples to evaluate, pass 0 for all " "examples. Default: 100"), tflite::Flag::CreateFlag( kModelOutputLabelsFlag, &params.model_output_labels_path, "Path to labels that correspond to output of model." " E.g. in case of mobilenet, this is the path to label " "file where each label is in the same order as the output" " of the model."), tflite::Flag::CreateFlag( kGroundTruthImagesPathFlag, &params.ground_truth_images_path, "Path to ground truth images. These will be evaluated in " "alphabetical order of filename"), tflite::Flag::CreateFlag( kGroundTruthLabelsFlag, &params.ground_truth_labels_path, "Path to ground truth labels, corresponding to alphabetical ordering " "of ground truth images."), tflite::Flag::CreateFlag( kBlacklistFilePathFlag, &params.blacklist_file_path, "Path to blacklist file (optional) where each line is a single " "integer that is " "equal to index number of blacklisted image."), tflite::Flag::CreateFlag(kModelFileFlag, &params.model_file_path, "Path to test tflite model file.")}; tflite::Flags::Parse(&argc, const_cast<const char**>(argv), flag_list); if (params.number_of_images < 0) { LOG(ERROR) << "Invalid: num_examples"; return kTfLiteError; } *model_evaluator = absl::make_unique<ImagenetModelEvaluator>(params, num_threads); return kTfLiteOk; } struct ImageLabel { std::string image; std::string label; }; TfLiteStatus EvaluateModelForShard(const uint64_t shard_id, const std::vector<ImageLabel>& image_labels, const std::vector<std::string>& model_labels, const ImagenetModelEvaluator::Params& params, ImagenetModelEvaluator::Observer* observer, int num_ranks) { tflite::evaluation::EvaluationStageConfig eval_config; eval_config.set_name("image_classification"); auto* classification_params = eval_config.mutable_specification() ->mutable_image_classification_params(); auto* inference_params = classification_params->mutable_inference_params(); inference_params->set_model_file_path(params.model_file_path); classification_params->mutable_topk_accuracy_eval_params()->set_k(num_ranks); tflite::evaluation::ImageClassificationStage eval(eval_config); eval.SetAllLabels(model_labels); TF_LITE_ENSURE_STATUS(eval.Init()); for (const auto& image_label : image_labels) { eval.SetInputs(image_label.image, image_label.label); TF_LITE_ENSURE_STATUS(eval.Run()); observer->OnSingleImageEvaluationComplete( shard_id, eval.LatestMetrics() .process_metrics() .image_classification_metrics() .topk_accuracy_metrics(), image_label.image); } return kTfLiteOk; } // TODO(b/130823599): Move to tools/evaluation/utils. TfLiteStatus FilterBlackListedImages(const std::string& blacklist_file_path, std::vector<ImageLabel>* image_labels) { if (!blacklist_file_path.empty()) { std::vector<std::string> lines; if (!tflite::evaluation::ReadFileLines(blacklist_file_path, &lines)) { LOG(ERROR) << "Could not read: " << blacklist_file_path; return kTfLiteError; } std::vector<int> blacklist_ids; blacklist_ids.reserve(lines.size()); // Populate blacklist_ids with indices of images. std::transform(lines.begin(), lines.end(), std::back_inserter(blacklist_ids), [](const std::string& val) { return std::stoi(val) - 1; }); std::vector<ImageLabel> filtered_images; std::sort(blacklist_ids.begin(), blacklist_ids.end()); const size_t size_post_filtering = image_labels->size() - blacklist_ids.size(); filtered_images.reserve(size_post_filtering); int blacklist_index = 0; for (int image_index = 0; image_index < image_labels->size(); image_index++) { if (blacklist_index < blacklist_ids.size() && blacklist_ids[blacklist_index] == image_index) { blacklist_index++; continue; } filtered_images.push_back((*image_labels)[image_index]); } if (filtered_images.size() != size_post_filtering) { LOG(ERROR) << "Invalid number of filtered images"; return kTfLiteError; } *image_labels = filtered_images; } return kTfLiteOk; } // TODO(b/130823599): Move to tools/evaluation/utils. TfLiteStatus GetSortedFileNames(const std::string dir_path, std::vector<std::string>* result) { DIR* dir; struct dirent* ent; if (result == nullptr) { LOG(ERROR) << "result cannot be nullptr"; return kTfLiteError; } if ((dir = opendir(dir_path.c_str())) != nullptr) { while ((ent = readdir(dir)) != nullptr) { std::string filename(std::string(ent->d_name)); if (filename.size() <= 2) continue; result->emplace_back(dir_path + "/" + filename); } closedir(dir); } else { LOG(ERROR) << "Could not open dir: " << dir_path; return kTfLiteError; } std::sort(result->begin(), result->end()); return kTfLiteOk; } TfLiteStatus ImagenetModelEvaluator::EvaluateModel() const { const std::string data_path = StripTrailingSlashes(params_.ground_truth_images_path) + "/"; std::vector<std::string> image_files; TF_LITE_ENSURE_STATUS(GetSortedFileNames(data_path, &image_files)); std::vector<string> ground_truth_image_labels; if (!tflite::evaluation::ReadFileLines(params_.ground_truth_labels_path, &ground_truth_image_labels)) return kTfLiteError; if (image_files.size() != ground_truth_image_labels.size()) { LOG(ERROR) << "Images and ground truth labels don't match"; return kTfLiteError; } std::vector<ImageLabel> image_labels; image_labels.reserve(image_files.size()); for (int i = 0; i < image_files.size(); i++) { image_labels.push_back({image_files[i], ground_truth_image_labels[i]}); } // Filter any blacklisted images. if (FilterBlackListedImages(params_.blacklist_file_path, &image_labels) != kTfLiteOk) { LOG(ERROR) << "Could not filter by blacklist"; return kTfLiteError; } if (params_.number_of_images > 0) { image_labels = GetFirstN(image_labels, params_.number_of_images); } std::vector<string> model_labels; if (!tflite::evaluation::ReadFileLines(params_.model_output_labels_path, &model_labels)) { LOG(ERROR) << "Could not read: " << params_.model_output_labels_path; return kTfLiteError; } if (model_labels.size() != 1001) { LOG(ERROR) << "Invalid number of labels: " << model_labels.size(); return kTfLiteError; } auto img_labels = Split(image_labels, num_threads_); CompositeObserver observer(observers_); std::vector<std::thread> thread_pool; bool all_okay = true; std::unordered_map<uint64_t, int> shard_id_image_count_map; thread_pool.reserve(num_threads_); for (int i = 0; i < num_threads_; i++) { const auto& image_label = img_labels[i]; const uint64_t shard_id = i + 1; shard_id_image_count_map[shard_id] = image_label.size(); auto func = [shard_id, &image_label, &model_labels, this, &observer, &all_okay]() { if (EvaluateModelForShard(shard_id, image_label, model_labels, params_, &observer, params_.num_ranks) != kTfLiteOk) { all_okay = all_okay && false; } }; thread_pool.push_back(std::thread(func)); } observer.OnEvaluationStart(shard_id_image_count_map); for (auto& thread : thread_pool) { thread.join(); } return kTfLiteOk; } } // namespace metrics } // namespace tensorflow
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
62ecb0a8bf305f384239be7c8686e7e2a65cbcbb
8951e1e68ab636dca1acbc8262170c4facf9c08d
/ibrdtn/daemon/src/routing/distance/ContentStorage.cpp
1c56f0806b45dacd45c5060096b8da5423635d15
[ "Apache-2.0" ]
permissive
jeremyasm/ibrdtn
e61e43b449395fe34ee835088280df4c2a57cb82
a68a5a49ff164b27bcddc9dad2b46a0c43b5beee
refs/heads/master
2021-01-14T12:34:46.638611
2016-04-04T15:39:44
2016-04-04T15:39:44
37,256,574
0
0
null
2015-06-11T11:14:38
2015-06-11T11:14:37
null
UTF-8
C++
false
false
390
cpp
/* * ContentStorage.cpp * * Created on: Jul 2, 2015 * Author: jeremy */ #include "ContentStorage.h" #include <vector> #include <map> namespace dtn { namespace routing { ContentStorage::ContentStorage(){ } //virtual ContentStorage::~ContentStorage(){ ContentStorage::~ContentStorage(){ } //std::map<dtn::data::BundleString, DataET > _contentStorage; } }
[ "root@ndndtn2.ibr.cs.tu-bs.de" ]
root@ndndtn2.ibr.cs.tu-bs.de
4994fbfa53444ba227db580bbe3ad614a62ffffe
1ae7e3c269e0bd2df0bc725a33f307971816d40d
/app/src/main/cpp/boost/thread/executors/scheduler.hpp
5bee0e7b5f8b1ce2acc8f8789aab13b00bd14dad
[]
no_license
HOTFIGHTER/XmLogger
347902372bf2afc88cf26d2342434c1ea556201f
433a0420c99a883bd65e99fd5f04ac353ac6d7b6
refs/heads/master
2021-02-18T08:46:12.122640
2020-03-05T14:16:39
2020-03-05T14:16:39
245,178,943
2
0
null
null
null
null
UTF-8
C++
false
false
6,264
hpp
// Copyright (C) 2014 Vicente J. Botet Escriba // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_THREAD_EXECUTORS_SCHEDULER_HPP #define BOOST_THREAD_EXECUTORS_SCHEDULER_HPP #include <boost/thread/detail/config.hpp> #include <boost/thread/executors/detail/scheduled_executor_base.hpp> #include <boost/chrono/time_point.hpp> #include <boost/chrono/duration.hpp> #include <boost/chrono/system_clocks.hpp> #include <boost/config/abi_prefix.hpp> namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost { namespace executors { /// Wraps the reference to an executor and a function to make a work that submit the function using the executor. template<class Executor, class Function> class resubmitter { public: resubmitter(Executor &ex, Function funct) : ex(ex), funct(mars_boost::move(funct)) {} void operator()() { ex.submit(funct); } private: Executor &ex; Function funct; }; /// resubmitter factory template<class Executor, class Function> resubmitter<Executor, typename decay<Function>::type> resubmit(Executor &ex, BOOST_THREAD_FWD_REF(Function) funct) { return resubmitter<Executor, typename decay<Function>::type>(ex, mars_boost::move(funct)); } /// Wraps references to a @c Scheduler and an @c Executor providing an @c Executor that /// resubmit the function using the referenced Executor at a given @c time_point known at construction. template<class Scheduler, class Executor> class resubmit_at_executor { public: typedef typename Scheduler::clock clock; typedef typename Scheduler::work work; template<class Duration> resubmit_at_executor(Scheduler &sch, Executor &ex, chrono::time_point <clock, Duration> const &tp) : sch(sch), ex(ex), tp(tp), is_closed(false) { } ~resubmit_at_executor() { close(); } template<class Work> void submit(BOOST_THREAD_FWD_REF(Work) w) { if (closed()) { BOOST_THROW_EXCEPTION(sync_queue_is_closed()); } sch.submit_at(resubmit(ex, mars_boost::forward<Work>(w)), tp); } Executor &underlying_executor() { return ex; } Scheduler &underlying_scheduler() { return sch; } void close() { is_closed = true; } bool closed() { return is_closed || sch.closed() || ex.closed(); } private: Scheduler &sch; Executor &ex; typename clock::time_point tp; bool is_closed; }; /// Expression template helper storing a pair of references to an @c Scheduler and an @c Executor /// It provides factory helper functions such as at/after that convert these a pair of @c Scheduler @c Executor /// into an new @c Executor that submit the work using the referenced @c Executor at/after a specific time/duration /// respectively, using the referenced @Scheduler. template<class Scheduler, class Executor> class scheduler_executor_wrapper { public: typedef typename Scheduler::clock clock; typedef typename Scheduler::work work; typedef resubmit_at_executor<Scheduler, Executor> the_executor; scheduler_executor_wrapper(Scheduler &sch, Executor &ex) : sch(sch), ex(ex) {} ~scheduler_executor_wrapper() { } Executor &underlying_executor() { return ex; } Scheduler &underlying_scheduler() { return sch; } template<class Rep, class Period> the_executor after(chrono::duration <Rep, Period> const &rel_time) { return at(clock::now() + rel_time); } template<class Duration> the_executor at(chrono::time_point <clock, Duration> const &abs_time) { return the_executor(sch, ex, abs_time); } private: Scheduler &sch; Executor &ex; }; //end class /// Wraps a reference to a @c Scheduler providing an @c Executor that /// run the function at a given @c time_point known at construction. template<class Scheduler> class at_executor { public: typedef typename Scheduler::clock clock; typedef typename Scheduler::work work; typedef typename clock::time_point time_point; template<class Duration> at_executor(Scheduler &sch, chrono::time_point <clock, Duration> const &tp) : sch(sch), tp(tp), is_closed(false) {} ~at_executor() { close(); } Scheduler &underlying_scheduler() { return sch; } void close() { is_closed = true; } bool closed() { return is_closed || sch.closed(); } template<class Work> void submit(BOOST_THREAD_FWD_REF(Work) w) { if (closed()) { BOOST_THROW_EXCEPTION(sync_queue_is_closed()); } sch.submit_at(mars_boost::forward<Work>(w), tp); } template<class Executor> resubmit_at_executor<Scheduler, Executor> on(Executor &ex) { return resubmit_at_executor<Scheduler, Executor>(sch, ex, tp); } private: Scheduler &sch; time_point tp; bool is_closed; }; //end class /// A @c Scheduler using a specific thread. Note that a Scheduler is not an Executor. /// It provides factory helper functions such as at/after that convert a @c Scheduler into an @c Executor /// that submit the work at/after a specific time/duration respectively. template<class Clock = chrono::steady_clock> class scheduler: public detail::scheduled_executor_base<Clock> { public: typedef typename detail::scheduled_executor_base<Clock>::work work; typedef Clock clock; scheduler() : super(), thr(&super::loop, this) {} ~scheduler() { this->close(); thr.join(); } template<class Ex> scheduler_executor_wrapper<scheduler, Ex> on(Ex &ex) { return scheduler_executor_wrapper<scheduler, Ex>(*this, ex); } template<class Rep, class Period> at_executor<scheduler> after(chrono::duration <Rep, Period> const &rel_time) { return at(rel_time + clock::now()); } template<class Duration> at_executor<scheduler> at(chrono::time_point <clock, Duration> const &tp) { return at_executor<scheduler>(*this, tp); } private: typedef detail::scheduled_executor_base <Clock> super; thread thr; }; } using executors::resubmitter; using executors::resubmit; using executors::resubmit_at_executor; using executors::scheduler_executor_wrapper; using executors::at_executor; using executors::scheduler; } #include <boost/config/abi_suffix.hpp> #endif
[ "linfeng.yu@ximalaya.com" ]
linfeng.yu@ximalaya.com
5dda1d35cdb173309541477d27d8a25278ada9ab
23c60f684485207d04d68aea0eb8d5357f2de363
/Algorithms/11. DynamicProgramming/Algorithm_11_LCS/main.cpp
8af865641ba620a7458867887e705447ba0d4287
[]
no_license
Yoodahun/Studied-in-University
b45cac98e905702ed1b641bcec1369e1807682f1
505cdbe1ef6264e102a0143c0a12b33a142c8454
refs/heads/master
2021-06-27T03:56:12.576759
2020-12-12T03:03:46
2020-12-12T03:03:46
184,989,610
0
0
null
null
null
null
UTF-8
C++
false
false
3,943
cpp
// // main.cpp // Algorithm_11_LCS // // Created by 유다훈 on 2017. 12. 5.. // Copyright © 2017년 유다훈. All rights reserved. // #include <iostream> void print_LCS(int ** b, char * firstSequence, int firstM, int secondN) { //부분문자열의 순서를 출력하는 함수 if ( firstM == 0 || secondN == 0) { return; } if(b[firstM][secondN] == 1) { print_LCS(b, firstSequence, firstM-1, secondN-1); printf("%c", firstSequence[firstM-1]); } else if (b[firstM][secondN] == 0) { print_LCS(b, firstSequence, firstM-1, secondN); } else { print_LCS(b, firstSequence, firstM, secondN-1); } } void LCS_Length(char * firstSequence, char * secondSequence, int firstM, int secondN, int maxValue) { int ** b; int ** c; b = (int **)malloc(sizeof(int*) * firstM); //첫번째 문자열 c = (int **)malloc(sizeof(int*) * firstM); //두번째 문자열 for (int i = 0; i < firstM; i++) { b[i] = (int *)malloc(sizeof(int *) * secondN); c[i] = (int *)malloc(sizeof(int *) * secondN); } for(int i=0; i<firstM; i++) { for(int j=0; j<secondN; j++) { b[i][j] =maxValue; //값을 제대로 검사하기 위해서 모든 값들을 최대값으로 채워넣고 시작. } } /* 배열의 초기화 */ for(int i = 0; i<firstM; i++) { c[i][0] =0; } for (int j=0; j<secondN; j++) { c[0][j] = 0; } /* 배열의 초기화 */ /* Longest Common Subsequence */ for(int i = 1; i<firstM; i++) { for (int j = 1; j<secondN ; j++ ) { if(firstSequence[i-1] == secondSequence[j-1]) { //첫번째 문자열을 기준으로 두번쨰 문자열을 비교해나가기 시작 c[i][j] = c[i-1][j-1] + 1; // 만일 같은 값이라면 대각선 이전 위치의 값에 +1을 더함 b[i][j] = 1; // 순서를 저장할 배열 b에 1 저장 } else if (c[i-1][j] >= c[i][j-1]) { //그렇지 않다면, 이전행의 값이 이전열의 값보다 크다면 c[i][j] = c[i-1][j]; //이전 행의 값을 옮겨 저장 b[i][j] = 0; //순서를 저장할 배열 b에 0 저장 } else { c[i][j]= c[i][j-1]; //그렇지 않다면, 이전열의 값 저장 b[i][j] = -1; //순서를 저장할 배열 b에 -1저장 } } } /* Longest Common Subsequence */ for(int i=0; i<firstM; i++) { for(int j=0; j<secondN; j++) { printf("%d ", c[i][j]); } printf("\n"); } printf("\n"); for(int i=0; i<firstM; i++) { for(int j=0; j<secondN; j++) { printf("%d ", b[i][j]); } printf("\n"); } printf("\n"); print_LCS(b, firstSequence, firstM-1, secondN-1); } int main(int argc, const char * argv[]) { // insert code here... int maxValue = 0x7fffff; //무한대값 // File Open FILE *rf = fopen("sample_lcs1.txt", "r"); if ( rf == NULL) printf("read file open error"); int i,n,m; // Struct Graph fscanf(rf, "%d\n", &n); char * firstSequence; firstSequence = (char *)malloc(sizeof(char) * n); // Initialization for (i = 0; i < n; i++){ fscanf(rf, "%c", &firstSequence[i]); //첫번째 수열 } fscanf(rf, "%d\n", &m); char * secondSequence = (char *)malloc(sizeof(char) * m); for (i = 0; i < m; i++){ fscanf(rf, "%c", &secondSequence[i]); //두번째 수열 } for (i = 0; i < n; i++){ printf("%c", firstSequence[i]); } printf("\n"); for (i = 0; i < m; i++){ printf("%c", secondSequence[i]); } printf("\n"); fclose(rf); LCS_Length(firstSequence, secondSequence, n+1, m+1, maxValue); std::cout << "\nHello, World!\n"; return 0; }
[ "dahun4032@gmail.com" ]
dahun4032@gmail.com
a7b22d6bbeaea1f7380e2f243f50d970cbd410fe
c3c3b97e824370642f20a0cb408bb054c7b6049c
/BOJ/불우이웃돕기/불우이웃돕기/main.cpp
890a0a72ebc64a9be40c015c8d8cae4a44c21a60
[]
no_license
chrisais9/algorithm
00333c0f731ffd5971bf20871e622b48d22617c2
2a4fdf8e3f5d3da0b88cd2832d74e8e1dcbe09e9
refs/heads/master
2022-06-13T04:57:32.181733
2022-06-03T08:35:36
2022-06-03T08:35:36
136,615,290
0
0
null
null
null
null
UTF-8
C++
false
false
668
cpp
#include <iostream> using namespace std; int tb[200][200],sum=0,check[101],n; int main() { int i,j,min,t,cnt=0; cin>>n; for(i=0;i<n;i++)for(j=0;j<n;j++)cin>>tb[i][j]; check[0]=1; do { min=0x7fffffff; cnt++; if(cnt==n)break; for(i=0;i<n;i++) { if(check[i]) { for(j=0;j<n;j++) { if(!check[j]&&min>tb[i][j]) { t=j; min=tb[i][j]; } } } } check[t]=1; sum+=min; }while(1); cout<<sum; }
[ "chrisais9@naver.com" ]
chrisais9@naver.com
ec7e64921ea9333bca8b1d8dcbe7b7e2bb0103df
98716913d4133592a5c5834c6cb827070a9235b8
/tests/test_app/my_custom_button.cpp
0d58775171420c730f5bd3812c59fe7c910a7e2a
[ "BSD-3-Clause" ]
permissive
dowellr85/qt_monkey
0def268bd6633975898ad7c9a4238625ab3a6ba9
f034fefc6519dcdf659fa7e4d35dfbb358ed881e
refs/heads/master
2020-06-18T10:23:46.567172
2019-07-10T20:27:45
2019-07-10T20:27:45
196,270,333
0
0
BSD-3-Clause
2019-07-10T20:23:37
2019-07-10T20:23:37
null
UTF-8
C++
false
false
32
cpp
#include "my_custom_button.hpp"
[ "dushistov@mail.ru" ]
dushistov@mail.ru
8efc9f993024e719c219f08ce19a14de454db16e
4d430b718bed3a675e2b54516004e7be5b7362de
/ESP32SoftAP.ino
8d7ce39d13afd9d948fa99624c59521774f14ed4
[]
no_license
anokhramesh/ESP32-Dev-Module-Web-Server
a19a63796929fb5abd3194f1724c9cc79c0f7a27
eed8b6a3d9c0eaa9a3f3e41521ae5cc6109abc80
refs/heads/main
2023-08-14T18:51:27.402184
2021-09-17T13:00:41
2021-09-17T13:00:41
407,540,150
0
0
null
null
null
null
UTF-8
C++
false
false
9,154
ino
/****** This code is for esp32 for using esp8266 just replace <wifi.h> into <esp8266wifi.h> , also change the output GPIO pins ****/ // Load Wi-Fi library #include <WiFi.h> // Replace with your network credentials // to create its own wifi network const char* ssid = "ESP32-Access-Point";// Accesspoint name DDID const char* password = "123456789";// password // Set web server port number to 80 WiFiServer server(80); // Variable to store the HTTP request String header; // Auxiliar variables to store the current output state //this pins for esp32 //change the pins for esp8266 String output12State = "off"; String output13State = "off"; String output14State = "off"; String output27State = "off"; // Assign output variables to GPIO pins const int output12 = 12;//connect Relay1 to GPIO pin 12 of ESP32 const int output13 = 13;//connect Relay2 to GPIO pin 13 of ESP32 const int output14 = 14;//connect Relay3 to GPIO pin 14 of ESP32 const int output27 = 27;//connect Relay4 to GPIO pin 27 of ESP32 void setup() { Serial.begin(115200); // Initialize the output variables as outputs pinMode(output12, OUTPUT); pinMode(output13, OUTPUT); pinMode(output14, OUTPUT); pinMode(output27, OUTPUT); // Set outputs to high because we are using active low type relay module digitalWrite(output12, HIGH); digitalWrite(output13, HIGH); digitalWrite(output14, HIGH); digitalWrite(output27, HIGH); // Connect to Wi-Fi network with SSID and password Serial.print("Setting AP (Access Point)…"); // Remove the password parameter, if you want the AP (Access Point) to be open WiFi.softAP(ssid, password); IPAddress IP = WiFi.softAPIP(); Serial.print("AP IP address: "); Serial.println(IP); server.begin(); } void loop(){ WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, Serial.println("New Client."); // print a message out in the serial port String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected if (client.available()) { // if there's bytes to read from the client, char c = client.read(); // read a byte, then Serial.write(c); // print it out the serial monitor header += c; if (c == '\n') { // if the byte is a newline character // if the current line is blank, you got two newline characters in a row. // that's the end of the client HTTP request, so send a response: if (currentLine.length() == 0) { // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK) // and a content-type so the client knows what's coming, then a blank line: client.println("HTTP/1.1 200 OK"); client.println("Content-type:text/html"); client.println("Connection: close"); client.println(); // turns the GPIOs on and off //foe GPIO12 if (header.indexOf("GET /12/on") >= 0) { Serial.println("GPIO 12 on"); output12State = "on"; digitalWrite(output12, LOW); } else if (header.indexOf("GET /12/off") >= 0) { Serial.println("GPIO 12 off"); output12State = "off"; digitalWrite(output12, HIGH); } //for GPIO13 else if (header.indexOf("GET /13/on") >= 0) { Serial.println("GPIO 13 on"); output13State = "on"; digitalWrite(output13, LOW); } else if (header.indexOf("GET /13/off") >= 0) { Serial.println("GPIO 13 off"); output13State = "off"; digitalWrite(output13, HIGH); } //for GPIO14 else if (header.indexOf("GET /14/on") >= 0) { Serial.println("GPIO 14 on"); output14State = "on"; digitalWrite(output14, LOW); } else if (header.indexOf("GET /14/off") >= 0) { Serial.println("GPIO 14 off"); output14State = "off"; digitalWrite(output14, HIGH); } //for GPIO27 else if (header.indexOf("GET /27/on") >= 0) { Serial.println("GPIO 27 on"); output27State = "on"; digitalWrite(output27, LOW); } else if (header.indexOf("GET /27/off") >= 0) { Serial.println("GPIO 27 off"); output27State = "off"; digitalWrite(output27, HIGH); } // Display the HTML web page client.println("<!DOCTYPE html><html>"); client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); client.println("<link rel=\"icon\" href=\"data:,\">"); // CSS to style the on/off buttons // Feel free to change the background-color and font-size attributes to fit your preferences client.println("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}"); client.println(".button { background-color: #4CAF50; border: none; color: white; padding: 16px 40px;"); client.println("text-decoration: none; font-size: 30px; margin: 2px; cursor: pointer;}"); client.println(".button2 {background-color: #555555;}</style></head>"); // Web Page Heading client.println("<body><h1>ESP32 Web Server</h1>"); // Display current state, and ON/OFF buttons for GPIO 12 client.println("<p>GPIO 12 - State " + output12State + "</p>"); // If the output12State is off, it displays the ON button if (output12State=="off") { client.println("<p><a href=\"/12/on\"><button class=\"button\">ON</button></a></p>"); } else { client.println("<p><a href=\"/12/off\"><button class=\"button button2\">OFF</button></a></p>"); } // Display current state, and ON/OFF buttons for GPIO 27 client.println("<p>GPIO 27 - State " + output27State + "</p>"); // If the output27State is off, it displays the ON button if (output27State=="off") { client.println("<p><a href=\"/27/on\"><button class=\"button\">ON</button></a></p>"); } else { client.println("<p><a href=\"/27/off\"><button class=\"button button2\">OFF</button></a></p>"); } // Display current state, and ON/OFF buttons for GPIO 13 client.println("<p>GPIO 13 - State " + output13State + "</p>"); // If the output13State is off, it displays the ON button if (output13State=="off") { client.println("<p><a href=\"/13/on\"><button class=\"button\">ON</button></a></p>"); } else { client.println("<p><a href=\"/13/off\"><button class=\"button button2\">OFF</button></a></p>"); } // Display current state, and ON/OFF buttons for GPIO 14 client.println("<p>GPIO 14 - State " + output14State + "</p>"); // If the output14State is off, it displays the ON button if (output14State=="off") { client.println("<p><a href=\"/14/on\"><button class=\"button\">ON</button></a></p>"); } else { client.println("<p><a href=\"/14/off\"><button class=\"button button2\">OFF</button></a></p>"); } client.println("</body></html>"); // The HTTP response ends with another blank line client.println(); // Break out of the while loop break; } else { // if you got a newline, then clear currentLine currentLine = ""; } } else if (c != '\r') { // if you got anything else but a carriage return character, currentLine += c; // add it to the end of the currentLine } } } // Clear the header variable header = ""; // Close the connection client.stop(); Serial.println("Client disconnected."); Serial.println(""); } }
[ "noreply@github.com" ]
noreply@github.com
9a595ba41225c03dc4ef5a1e564d66d2113d3baa
ff3661b1cafd5540eadf5168e2fb9866d442d8da
/reverse_array.cpp
9f7566ae9d9709e1cf18c90d3a86081cd07f94df
[]
no_license
Himank0/gp
b11d039920a58a11c6a664a86f571e508edc402f
41d5c009870d3c2ade172f32b745c69d70a34a83
refs/heads/main
2023-06-19T01:58:35.694010
2021-07-18T10:29:18
2021-07-18T10:29:18
387,149,188
0
0
null
null
null
null
UTF-8
C++
false
false
886
cpp
/* // reverse an array #include <iostream> using namespace std; void revar(int a[], int start , int end) { int temp; int n = end; for(;end>start;start++,end--) { temp = a[start]; a[start] = a[end]; a[end] = temp; } for(int i=0;i<=n;i++) cout<<a[i]<<" "; } int main() { int ar[5]={1,2,3,4,5}; int n = sizeof(ar); for(int i=0;i<n;i++) cin>>ar[i]; revar(ar,0,n-1); return 0; } */ // using recursive approach // reverse an array #include <iostream> using namespace std; void revar(int a[], int start , int end) { int temp; if(end<=start) return ; temp = a[start]; a[start]=a[end]; a[end]=temp; revar(a,start+1,end-1); } int main() { int ar[]={1,2,3,4,5}; revar(ar,0,4); cout<<"reverse array:"<<endl; for(int i=0;i<5;i++) cout<<ar[i]; return 0; }
[ "kandpal.himank@gmail.com" ]
kandpal.himank@gmail.com
cdc435065dc2d0dae7aa62fae004d762ca394ddb
adf54ae67a1977a4c78382ddca05e9071fd99aea
/gen2.cc
ace7eb8337c61ba6e2bbbbba79528a8911838f9b
[]
no_license
a1ph/icfp13
b40806a0651a137f7b7ed11105d4f15d2d3023d0
5026db5f394de931880ee4096276a4326e6ad0b1
refs/heads/master
2021-01-22T23:11:18.171541
2013-08-11T22:17:30
2013-08-11T22:22:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
12,687
cc
#include "gen2.h" #include <assert.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <memory.h> #include <sstream> #include <string> #include <list> #include <utility> int Expr::arity(Op op) { switch (op) { case C0: case C1: case VAR: return 0; case NOT: case SHL1: case SHR1: case SHR4: case SHR16: return 1; case PLUS: case XOR: case OR: case AND: return 2; case IF0: case FOLD: return 3; default: fprintf(stderr, "bad op at arity\n"); exit(1); } } int Expr::arity() { return arity(op); } Val Expr::eval(Context* ctx) { if (flags & F_CONST) return val; Val res = 0; switch (op) { case C0: res = 0; break; case C1: res = 1; break; case VAR: res = ctx->get(var); break; case NOT: res = ~opnd[0]->eval(ctx); break; case SHL1: res = opnd[0]->eval(ctx) << 1; break; case SHR1: res = opnd[0]->eval(ctx) >> 1; break; case SHR4: res = opnd[0]->eval(ctx) >> 4; break; case SHR16: res = opnd[0]->eval(ctx) >> 16; break; case PLUS: res = opnd[0]->eval(ctx) + opnd[1]->eval(ctx); break; case AND: res = opnd[0]->eval(ctx) & opnd[1]->eval(ctx); break; case OR: res = opnd[0]->eval(ctx) | opnd[1]->eval(ctx); break; case XOR: res = opnd[0]->eval(ctx) ^ opnd[1]->eval(ctx); break; case IF0: res = opnd[0]->eval(ctx) == 0 ? opnd[1]->eval(ctx) : opnd[2]->eval(ctx); break; case FOLD: res = do_fold(ctx); break; default: fprintf(stderr, "Error: Unknown op %d\n", op); ASSERT(0); } // printf("eval: %d = 0x%016lx\n", op, res); return res; } Val Expr::do_fold(Context* ctx) { Val data = opnd[0]->eval(ctx); Val acc = opnd[1]->eval(ctx); for (int i = 0; i < 8; i++) { Val byte = data & 0xff; ctx->push(byte); ctx->push(acc); acc = opnd[2]->eval(ctx); ctx->pop(); ctx->pop(); data >>= 8; } return acc; } static string itos(int i) // convert int to string { std::stringstream s; s << i; return s.str(); } string Expr::code() { switch (op) { case C0: return "0"; case C1: return "1"; case VAR: return "x" + itos(var); case NOT: return "(not " + opnd[0]->code() + ")"; case SHL1: return "(shl1 " + opnd[0]->code() + ")"; case SHR1: return "(shr1 " + opnd[0]->code() + ")"; case SHR4: return "(shr4 " + opnd[0]->code() + ")"; case SHR16: return "(shr16 " + opnd[0]->code() + ")"; case PLUS: return "(plus " + opnd[0]->code() + " " + opnd[1]->code() + ")"; case AND: return "(and " + opnd[0]->code() + " " + opnd[1]->code() + ")"; case OR: return "(or " + opnd[0]->code() + " " + opnd[1]->code() + ")"; case XOR: return "(xor " + opnd[0]->code() + " " + opnd[1]->code() + ")"; case IF0: return "(if0 " + opnd[0]->code() + " " + opnd[1]->code() + " " + opnd[2]->code() + ")"; // The code below assumes there's the only fold operation. case FOLD: return "(fold " + opnd[0]->code() + " " + opnd[1]->code() + " (lambda (x1 x2) " + opnd[2]->code() + "))"; default: fprintf(stderr, "Error: Unknown op %d\n", op); ASSERT(0); } } string Expr::program() { return "(lambda (x0) " + code() + ")"; } Val Expr::run(Val input) { Context ctx; ctx.push(input); return eval(&ctx); } /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// Arena::Arena() { // memset(arena, 0, sizeof(arena)); optimize_ = true; callback_ = NULL; no_more_fold_ = false; } void Arena::generate(int size, int valence, int args) { // printf("generate %d %d %d\n", size, valence, args); count_ = 0; optimize_ = true; int min_size = valence + 1; allowed_ops_.add(C0); allowed_ops_.add(C1); allowed_ops_.add(VAR); done_ = false; for (int sz = min_size; sz <= size; sz++) { size_ = sz - 1; // printf("current size %d\n", size_); arena_ptr = 0; valents_ptr = 0; valence_ = valence; num_vars_ = args; gen(size_, 0); if (done_) break; } // printf("generated: %d\n", count_); } void Arena::gen(int left_ops, int valence) { // printf("gen %d %d\n", left_ops, valence); int max_valence = valence_ + (left_ops - 1) * 2; int min_valence = valence_ - (left_ops - 1); if (allowed_ops_.has(IF0) && valence >= 3) { Expr* cond_opnd = peep_arg(0); if (!optimize_ || !(cond_opnd->flags & Expr::F_CONST)) try_emit(IF0, left_ops, valence); } // fold consumes at least 3 ops: fold, lambda, and its expr. int fold_max_valence = valence_ + (left_ops - 3) * 2; int fold_min_valence = valence_ - (left_ops - 3); if (fold_min_valence <= valence - 1 && valence - 1 <= fold_max_valence && valence >= 2) { emit_fold(); } try_emit(C0, left_ops, valence); try_emit(C1, left_ops, valence); try_emit(VAR, left_ops, valence); if (valence >= 1) { Expr* opnd = peep_arg(0); if (!optimize_ || opnd->op != NOT) { try_emit(NOT, left_ops, valence); } // Do not shift 0 if (!optimize_ || !opnd->is_const(0)) { try_emit(SHL1, left_ops, valence); } if (!optimize_ || !opnd->is_const(0) && !opnd->is_const(1)) { try_emit(SHR1, left_ops, valence); try_emit(SHR4, left_ops, valence); try_emit(SHR16, left_ops, valence); } } if (valence >= 2) { Expr* opnd1 = peep_arg(0); Expr* opnd2 = peep_arg(1); if (!optimize_ || !opnd1->is_const(0) && !opnd2->is_const(0)) { try_emit(PLUS, left_ops, valence); try_emit(OR, left_ops, valence); try_emit(XOR, left_ops, valence); try_emit(AND, left_ops, valence); } } } Expr* Arena::peep_arg(int arg) { return &arena[valents[valents_ptr - arg - 1]]; } void Arena::try_emit(Op op, int left_ops, int valence) { int max_valence = valence_ + (left_ops - 1) * 2; int min_valence = valence_ - (left_ops - 1); if (!allowed_ops_.has(op)) return; if (left_ops == 1) { if (op == SHL1 && (properties_ & NO_TOP_SHL1)) return; if (op == SHR1 && (properties_ & NO_TOP_SHR1)) return; if (op == SHR4 && (properties_ & NO_TOP_SHR4)) return; if (op == SHR16 && (properties_ & NO_TOP_SHR16)) return; } int arity = Expr::arity(op); // ensure we don't miss a fold if it's required if (!no_more_fold_ && allowed_ops_.has(FOLD)) { int new_valence = valence - arity + 1; int new_left_ops = left_ops - 1; // folds valency of 2 if (new_valence > 2) new_left_ops -= allowed_ops_.has(IF0) ? (new_valence - 2) / 2 : new_valence - 2; // need to consume extra valence else new_left_ops += 2 - new_valence; // need to generate extra valence if (new_left_ops < 3) return; // no chance fold will fit after this op } if (min_valence <= valence - arity + 1 && valence - arity + 1 <= max_valence && valence >= arity) { if (op == VAR) { for (int i = 0; i < num_vars_; i++) emit(VAR, i); } else { emit(op); } } } void Arena::emit(Op op, int var) { if (done_) return; int my_ptr = push_op(op, var); Expr& e = arena[my_ptr]; // printf("arena: %d size:%d\n", arena_ptr, size_); if (size_ == arena_ptr) { done_ = complete(&e, size_ + 1); } else { gen(size_ - arena_ptr, valents_ptr); } pop_op(); } bool Arena::complete(Expr* e, int size) { count_++; return callback_ ? !callback_->action(e, size) : false; } int Arena::push_op(Op op, int var) { int my_ptr = arena_ptr++; // printf("push_op %d -> [%d]: ", op, my_ptr); Expr& e = arena[my_ptr]; memset(&e, 0, sizeof(Expr)); e.op = op; e.flags = 0; e.val = (unsigned long)-1; if (op == VAR) e.var = var; bool const_expr = op != VAR && op != FOLD; int arity = e.arity(); if (op == FOLD) arity = 2; // special processing for the fold's lambda for (int i = 0; i < arity; i++) { ASSERT(valents_ptr > 0); int opnd_index = valents[--valents_ptr]; Expr& opnd = arena[opnd_index]; e.opnd[i] = &opnd; opnd.parent = &e; const_expr = const_expr && (opnd.flags & Expr::F_CONST); } if (op == FOLD) { e.opnd[2] = fold_lambda_; fold_lambda_->parent = &e; } if (const_expr) { if (op == FOLD) { Context ctx; e.val = e.eval(&ctx); } else { // no context as it shouldn't reference any var // things like (plus x 0) should no appear in the code as well. e.val = e.eval(NULL); } // eval before setting the flag, otherwise it won't really do eval. e.flags |= Expr::F_CONST; } valents[valents_ptr++] = my_ptr; // printf("curried into: %s\n", e.code().c_str()); // printf("\tvalents after push_op %d\n", valents_ptr); return my_ptr; } void Arena::pop_op() { arena_ptr--; // printf("pop_op [%d]\n", arena_ptr); int my_ptr = arena_ptr; Expr& e = arena[my_ptr]; valents_ptr--; int arity = e.arity(); if (e.op == FOLD) arity = 2; // special processing for the fold's lambda for (int i = arity - 1; i >= 0; i--) { valents[valents_ptr++] = e.opnd[i] - arena; } } void Arena::emit_fold() { if (no_more_fold_) return; if (!allowed_ops_.has(FOLD)) return; no_more_fold_ = true; int max_size = size_ - arena_ptr - 1; // 1 takes FOLD Arena fold_lambda; fold_lambda.set_callback(this); fold_lambda.no_more_fold_ = true; // disable inner folds fold_lambda.allowed_ops_ = allowed_ops_; fold_lambda.generate(max_size, 1, 3); no_more_fold_ = false; } bool Arena::action(Expr* expr, int size) { if (optimize_ && (expr->is_const() || expr->is_var(0))) return true; arena_ptr += size; fold_lambda_ = expr; emit(FOLD); arena_ptr -= size; return true; } void Arena::add_allowed_op(Op op) { allowed_ops_.add(op); } ///////////////////////////////////////////////// void ArenaBonus::generate(int size, int args) { no_more_fold_ = true; Arena::generate(size - 3, 3, 1); } bool ArenaBonus::complete(Expr* e, int size) { push_op(C1); push_op(AND); int op_ptr = push_op(IF0); bool res = Arena::complete(&arena[op_ptr], size + 3); pop_op(); pop_op(); pop_op(); return res; } /////////////////////// void ArenaTfold::generate(int size, int args) { no_more_fold_ = true; Arena::generate(size - 4, 1, 3); } bool ArenaTfold::complete(Expr* e, int size) { fold_lambda_ = e; push_op(C0); push_op(VAR, 0); int op_ptr = push_op(FOLD); bool res = Arena::complete(&arena[op_ptr], size + 4); pop_op(); pop_op(); pop_op(); return res; } bool Printer::action(Expr* e, int size) { count_++; static int cnt = 0; cnt++; #ifdef GEN2 printf("%9d: [%2d] %s\n", cnt, size, e->program().c_str()); #else if ((cnt & 0x3fffff) == 0) printf("%9d: [%2d] %s\n", cnt, size, e->program().c_str()); #endif return true; } ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////// void Verifier::add(Val input, Val output) { pairs.push_back(std::pair<Val,Val>(input, output)); } bool Verifier::action(Expr* program, int size) { for (Pairs::iterator it = pairs.begin(); it != pairs.end(); ++it) { Val actual = program->run((*it).first); if (actual != (*it).second) { // printf("%s failed 0x%lx -> 0x%lx\n", program->program().c_str(), (*it).first, actual); return true; } } printf("--- %6d: %s\n", ++count, program->program().c_str()); #if 0 for (Pairs::iterator it = pairs.begin(); it != pairs.end(); ++it) { printf(" 0x%016lx -> 0x%016lx\n", (*it).first, (*it).second); } #endif return false; } void Generator::generate(int size) { if (mode_tfold_) { ArenaTfold a; a.set_callback(callback_); a.allowed_ops_ = allowed_ops_; a.generate(size); printf("count=%d\n", a.count_); } else if (mode_bonus_) { ArenaBonus a; a.set_callback(callback_); a.allowed_ops_ = allowed_ops_; a.generate(size); printf("count=%d\n", a.count_); } else { Arena a; a.set_callback(callback_); a.set_properties(properties_); a.allowed_ops_ = allowed_ops_; a.generate(size); printf("count=%d\n", a.count_); } } #ifdef GEN2 int main() { Printer p; Arena a; a.set_callback(&p); a.add_allowed_op(IF0); a.add_allowed_op(FOLD); a.generate(GEN2); printf("Total: %d\n", p.count_); return 0; } #endif
[ "alph@chromium.org" ]
alph@chromium.org
f26f0a9c28a12a24559347ac103ff5c3babf6746
a11aa0a45ffd68ba87e9381c2615d08fc31b3f51
/Atlas Engine/Source/New/Rendering/2D/Text/Text.cpp
635f68f08e4b84ee0cf1bbda04ed21e294e709cb
[]
no_license
YanniSperon/Atlas-Engine
7e2c17ddd84cdb0800054ec24f64e3cd67fd62d4
b6f12e445e8342c2c5625d023a7fca8e253d78a5
refs/heads/master
2023-01-31T01:40:34.648755
2020-12-07T10:58:57
2020-12-07T10:58:57
277,727,067
0
0
null
null
null
null
UTF-8
C++
false
false
426
cpp
#include "Text.h" Atlas::Text::Text() : text(), font(nullptr), finalTransformation(1.0f) { } Atlas::Text::~Text() { } void Atlas::Text::Update(float deltaTime) { } void Atlas::Text::SetFinalTransformation(glm::mat4 trans) { finalTransformation = trans; } Atlas::Node* Atlas::Text::GetReferencingNode() { return referencingNode; } void Atlas::Text::SetReferencingNode(Node* newNode) { referencingNode = newNode; }
[ "yannisperon@gmail.com" ]
yannisperon@gmail.com
f72560e41f67fe7dfe88cda40ab2152ec3c886e4
abdf7c66b1ac40c82a0642fec6ade1097016fc54
/冒泡排序/4.尝试消元(仅一列)/尝试消元(仅一列).cpp
ea13e87dbb38a59585eaf2398ee7f1dabac7185c
[]
no_license
Night-Voyager/A-Calculator-for-Linear-Algebra
96703b086774e9dbe493cbfad77f28a18cf99d89
fd56bafd381e8bad9b856481ff1cf885ab5d0e40
refs/heads/main
2023-03-27T08:08:12.357917
2021-03-26T16:35:45
2021-03-26T16:35:45
351,842,660
0
0
null
null
null
null
GB18030
C++
false
false
1,387
cpp
#include <stdio.h> #include "matrixio.h" float **bubble_sort(float **A); void main() { float **A; A = getmatrix(); putmatrix(bubble_sort(A)); } float **bubble_sort(float **A) { int i, j, k, m, n, p; float temp; m = (int)A[0][0]; n = (int)A[0][1]; for (i=1; i<m; i++) { for (j=1; j<m; j++) { if(A[j][1] > A[j+1][1]) { for (k=1; k<=n; k++) { temp = A[j][k]; A[j][k] = A[j+1][k]; A[j+1][k] = temp; } } } } //对所有项从小到大排,负数在前,正数在后 //(<0, 0, 0.x, 1, >1) for (i=1, p=0; i<=m; i++) { if (A[i][1]<0) p++; } //数出负数个数 for (i=p+1; i<m; i++) { for (j=p+1; j<m; j++) { if(A[j][1] < A[j+1][1]) { for (k=1; k<=n; k++) { temp = A[j][k]; A[j][k] = A[j+1][k]; A[j+1][k] = temp; } } } } //对非负项从大到小排,负数留在最前,0被排在最后 //(<0, >1, 1, 0.x, 0) for (i=m, p=0; A[i][1]!=1; i--, p++) ;//数出[0, 1)的数的个数 for (i=1; i<=(m-p)/2; i++) { for (k=1; k<=n; k++) { temp = A[i][k]; A[i][k] = A[m-p-i+1][k]; A[m-p-i+1][k] = temp; } }//翻转 //(1, >1, <0, 0.x, 0) for (i=2; i<=m; i++) { for (j=n; j>=1; j--) { A[i][j] = A[i][j]-A[1][j]*A[i][1]/A[1][1]; } }//消元 return(A); }
[ "18722007@bjtu.edu.cn" ]
18722007@bjtu.edu.cn
702571a01be648f2b9a6884eff693b9ab41fa206
8888717f4e2127bf3bbe2359d3257a33095c885d
/cardapioFinal.cpp
0aa321fe3139629fc2a606b0b0f27c3a57a881be
[]
no_license
Gabriel-Gith12/exercicios_C
7d4c07661e311614b5b25d52aedf48a469a3ef87
113d9c3b3b0b35c1e53318570634b62e21fde8b6
refs/heads/main
2023-06-12T21:41:23.228938
2021-07-07T20:07:59
2021-07-07T20:07:59
null
0
0
null
null
null
null
ISO-8859-1
C++
false
false
4,444
cpp
/// O cardápio automatizado de uma lancheria///// /// Quando o usuário abra o sistema mostra a seguinte informação /// Entrada : /// Qual o numero da Mesa ?: XX /// Qual o item (Codigo) do pedido abaixo? ///Entrada em loop : /// Código Produto Preço Unitário (R$) /// 101 Cachorro quente R$ 5,70 /// 102 X Completo R$ 18,30 /// 103 X Salada R$ 16,50 /// 104 Hamburguer R$ 22,40 /// 105 Coca 2L R$ 10,00 /// 106 Refrigerante R$ 1,00 /// 000 Encerra pedido /// Codigo:XX /// Quantidade:XX /// Saida: /// A mesa XXX pediu os seguintes itens: /// 1- Cachorro /// 3- X Completo /// Com valor total de R$: 60,6 #include <stdio.h> #include <stdlib.h> #include <string.h> int main(){ int flag = 0, pedido, numero = 0; int qt = 0, qt100 = 0, qt101 = 0, qt102 = 0, qt103 = 0, qt104 = 0, qt105 = 0, flag100 = 0, flag101 = 0, flag102 = 0, flag103 = 0, flag104 = 0, flag105 = 0; float valor = 0, valor100 = 0, valor101 = 0, valor102 = 0, valor103 = 0, valor104 = 0, valor105 = 0; char sair[10], pedido2[10], qt2[10]; while(flag == 0){ printf("Qual o numero da Mesa ? \n"); scanf("%s", &sair); numero = atoi(sair); if(numero == 0 ){ printf("Numero da Mesa Invalido: \n"); main; } else{ break; } } printf("Qual o item (Codigo) do pedido abaixo? \n" ); printf("\nCodigo Produto Preco Unitario (R$)"); printf("\n100 Cachorro quente R$ 5.70"); printf("\n101 X Completo R$ 18.30"); printf("\n102 X Salada R$ 16.50"); printf("\n103 Hamburguer R$ 22.40"); printf("\n104 Coca 2L R$ 10.00"); printf("\n105 Refrigerante R$ 1.00"); printf("\n999 Encerra pedido \n"); while(pedido!=999){ do{ printf("Codigo do Pedido: \n"); scanf("%s", &pedido2); pedido = atoi(pedido2); if(pedido == 0 ){ printf("Pedido Invalido: \n"); } while(pedido != 100 && pedido != 101 && pedido != 102 && pedido != 103 && pedido != 104 && pedido != 105 && pedido != 999){ printf("Informe um codigo valido: \n"); scanf("%d", &pedido); } }while(pedido == 0); do{ if(pedido != 999){ printf("Digite a quantidade: \n"); scanf("%s",&qt2); qt = atoi(qt2); if(qt == 0 ){ printf("Quantidade Invalido: \n"); } } }while(qt == 0 ); switch(pedido){ case 100: qt100 += qt; valor100 = (5.70 * qt100); valor += (5.70 * qt); flag100 = 1; break; case 101: qt101 += qt; valor101 = (18.30 * qt101); valor += (18.30 * qt); flag101 = 1; break; case 102: qt102 += qt; valor102 = (16.50 * qt102); valor += (16.50 * qt); flag102 = 1; break; case 103: qt103 += qt; valor103 = (22.40 * qt103); valor += (22.40 * qt); flag103 = 1; break; case 104: qt104 += qt; valor104 = (10.00 * qt104); valor += (10.00 * qt); flag104 = 1; break; case 105: qt105 += qt; valor105 = (1.00 * qt105); valor += (1.00 * qt); flag105 = 1; break; } } printf("\nA mesa %d pediu os seguintes itens: \n", numero); if(flag100 == 1){ printf("%d- Cachorro quente valor: %.2f \n", qt100, valor100); } if(flag101 == 1){ printf("%d- X Completo valor: %.2f \n", qt101, valor101); } if(flag102 == 1){ printf("%d- X Salada valor: %.2f \n", qt102, valor102); } if(flag103 == 1){ printf("%d- Hamburger valor: %.2f \n", qt103, valor103); } if(flag104 == 1){ printf("%d- Coca 2L valor: %.2f \n", qt104, valor104); } if(flag105 == 1){ printf("%d- Refrigente valor: %.2f \n", qt105, valor105); } printf("valor total de R$: %.2f \n",valor); system("pause"); return(0); }
[ "noreply@github.com" ]
noreply@github.com
93416c07f42455225345c6b5da3290229453fea2
4e5c8e17bad3b9f192203fbe01d668e334daa267
/jsAndCppHash/main.cpp
92035f278004780e98903cb048398692db8300db
[]
no_license
caijw/test
e14b7a06bc69e5d3af0fa3c281a1c0ce64d9a6e0
b51198f9bb0908ca4be7497fcafd8abb496507f2
refs/heads/master
2020-03-07T10:32:58.221635
2019-03-16T16:42:28
2019-03-16T16:42:28
36,712,628
0
0
null
null
null
null
UTF-8
C++
false
false
2,120
cpp
#include "./common.h" #include <node_api.h> #include <iostream> unsigned long hash(char *str, size_t strLen) { unsigned long hash = 5381; int c; for(size_t i = 0; i < strLen; ++i){ c = str[i]; hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ } return hash; } /* convert unsigned long to string */ char *ul2str(unsigned long num){ char *str = new char[65]; /*8个字节加null总共65bit*/ sprintf(str, "%lu" , num); return str; } /* 返回64位的无符号在nodejs 10.x还是一个Experimental的特性,文档如下 https://nodejs.org/dist/latest-v10.x/docs/api/n-api.html#n_api_napi_create_bigint_uint64 这里将其转换为v8的string返回,会有性能损耗,等n_api_napi_create_bigint_uint64特性不再是Experimental再改成n_api_napi_create_bigint_uint64 */ napi_value hash(napi_env env, napi_callback_info info){ size_t argc = 1; napi_value args[1]; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, NULL, NULL)); NAPI_ASSERT(env, argc == 1, "hash: Wrong number of arguments. Expects 1 argument."); napi_valuetype valuetype; NAPI_CALL(env, napi_typeof(env, args[0], &valuetype)); NAPI_ASSERT(env, valuetype == napi_string, "hash: Wrong type of arguments. Expects a string as first argument."); size_t strLen = 0; NAPI_CALL(env, napi_get_value_string_utf8(env, args[0], 0, 0, &strLen)); //没有终止符 unsigned long hashRes = 0; if(strLen > 0){ char *strBuf = new char[strLen + 1]; NAPI_CALL(env, napi_get_value_string_utf8(env, args[0], strBuf, strLen + 1, &strLen)); strBuf[strLen] = '\0'; hashRes = hash(strBuf, strLen); delete[] strBuf; char *hashResStr = ul2str(hashRes); napi_value hash_napi; NAPI_CALL(env, napi_create_string_utf8(env, hashResStr, NAPI_AUTO_LENGTH, &hash_napi)); delete[] hashResStr; return hash_napi; }else{ return NULL; } } napi_value Init(napi_env env, napi_value exports) { napi_value newExports; NAPI_CALL(env, napi_create_function(env, "exports", NAPI_AUTO_LENGTH, hash, NULL, &newExports) ); return newExports; } NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)
[ "kingweicai@tencent.com" ]
kingweicai@tencent.com
968f69c76522824964d4da782d7d225fd8dd0050
98b94d54c6893ac8cedd026c4c66f03a3f0e713e
/arduino_course/lv 10 program/lcd_switch_operation/lcd_switch_operation.ino
b9d50ff334ed534bcd317feee283a0887ad33419
[]
no_license
liuzhiping1/Robotics
213ea89221ea3f972057759c3361b5e01080b676
db868fcd434b4913d880137d346a98c01f4f7da7
refs/heads/master
2023-03-23T12:47:27.850438
2021-03-11T16:00:34
2021-03-11T16:00:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
834
ino
#include <LiquidCrystal.h> LiquidCrystal Lcd(13,12,8,7,4,2); int a=0,value; void setup() { pinMode(A4,INPUT); Lcd.begin(16,2); } void loop() { value=digitalRead(A4); if(value==HIGH) { delay(500); if(a<=5) { a=a+1; } else { a=0; } } switch(a) { case 0: Lcd.clear(); Lcd.setCursor(0,0); Lcd.print("zero"); break; case 1: Lcd.clear(); Lcd.setCursor(0,0); Lcd.print("one"); break; case 2: Lcd.clear(); Lcd.setCursor(0,0); Lcd.print("two"); break; case 3: Lcd.clear(); Lcd.setCursor(0,0); Lcd.print("three"); break; case 4: Lcd.clear(); Lcd.setCursor(0,0); Lcd.print("four"); break; case 5: Lcd.clear(); Lcd.setCursor(0,0); Lcd.print("five"); break; } delay(100); }
[ "f20201839@goa.bits-pilani.ac.in" ]
f20201839@goa.bits-pilani.ac.in
ed47569b4a48f7822a31f476beef8bd8f60ee58b
9f9bc55039022735acde82997c1f1a0bd7bd37cf
/Student_OMP/src/cpp/test/unit/02_Test_Pi/TestPi.cpp
61d28f225a16030ac4734a6c1d25370097bbe096
[]
no_license
khansabassem/GPGPU
1bc503252d81739c9c318ac49fc6134a5eb2327d
66bebe5c298afced9ddcd3f36f6998595c490091
refs/heads/main
2023-08-13T07:19:58.048558
2021-10-18T10:59:46
2021-10-18T10:59:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,256
cpp
#include "TestPi.h" #include <limits.h> /*----------------------------------------------------------------------*\ |* Declaration *| \*---------------------------------------------------------------------*/ /*--------------------------------------*\ |* Imported *| \*-------------------------------------*/ extern bool isPiSequentiel_OK(int n); extern bool isPiOMPEntrelacerPromotionTab_Ok(int n); extern bool isPiOMPEntrelacerCritical_Ok(int n); extern bool isPiOMPEntrelacerAtomic_Ok(int n); extern bool isPiOMPforCritical_Ok(int n); extern bool isPiOMPforAtomic_Ok(int n); extern bool isPiOMPforPromotionTab_Ok(int n); extern bool isPiOMPforReduction_Ok(int n); /*----------------------------------------------------------------------*\ |* Implementation *| \*---------------------------------------------------------------------*/ TestPi::TestPi(void) { this->n = INT_MAX / 10; TEST_ADD(TestPi::testSequentiel); TEST_ADD(TestPi::testEntrelacerPromotionTab); TEST_ADD(TestPi::testEntrelacerAtomic); TEST_ADD(TestPi::testEntrelacerCritical); TEST_ADD(TestPi::testAtomic); TEST_ADD(TestPi::testCritical); TEST_ADD(TestPi::testPromotionTab); TEST_ADD(TestPi::testForReduction); } void TestPi::testSequentiel(void) { TEST_ASSERT(isPiSequentiel_OK(n) == true); } void TestPi::testEntrelacerPromotionTab(void) { TEST_ASSERT(isPiOMPEntrelacerPromotionTab_Ok(n) == true); } void TestPi::testEntrelacerAtomic(void) { TEST_ASSERT(isPiOMPEntrelacerAtomic_Ok(n) == true); } void TestPi::testEntrelacerCritical(void) { TEST_ASSERT(isPiOMPEntrelacerCritical_Ok(n) == true); } void TestPi::testCritical(void) { TEST_ASSERT(isPiOMPforCritical_Ok(n) == true); } void TestPi::testAtomic(void) { TEST_ASSERT(isPiOMPforAtomic_Ok(n) == true); } void TestPi::testPromotionTab(void) { TEST_ASSERT(isPiOMPforPromotionTab_Ok(n) == true); } void TestPi::testForReduction(void) { TEST_ASSERT(isPiOMPforReduction_Ok(n) == true); } /*----------------------------------------------------------------------*\ |* End *| \*---------------------------------------------------------------------*/
[ "65398755+khansabassem@users.noreply.github.com" ]
65398755+khansabassem@users.noreply.github.com
a2c38dbd9e38b0e61185b4719c93bf09f0e4423c
86c5a5f4c27d0b78275ceb46a596c7ca452f7e93
/Commands/MoveForward.cpp
91b8e83b9a10fe8a625ba14bc2967689060fbc42
[]
no_license
first-robocopz/FRC2016-CLEAN
9f82e5affe390879bd646e72d95e3af35c8af7ab
0ae3795e85bdf8e78730cd6a1e9af487f0ac828b
refs/heads/master
2021-01-10T11:30:59.375144
2016-03-11T14:40:36
2016-03-11T19:37:31
53,552,351
0
0
null
null
null
null
UTF-8
C++
false
false
907
cpp
#include "MoveForward.h" #include "../RobotMap.h" #include <Timer.h> bool done; MoveForward::MoveForward() { // Use Requires() here to declare subsystem dependencies // eg. Requires(chassis); Requires(drivetrain); } // Called just before this Command runs the first time void MoveForward::Initialize() { done = false; } // Called repeatedly when this Command is scheduled to run void MoveForward::Execute() { drivetrain->TankDrivenum(-0.5, 0.5); Wait(autonomousTime); drivetrain->Stop(); done = true; } // Make this return true when this Command no longer needs to run execute() bool MoveForward::IsFinished() { return done; } // Called once after isFinished returns true void MoveForward::End() { drivetrain->Stop(); } // Called when another command which requires one or more of the same // subsystems is scheduled to run void MoveForward::Interrupted() { End(); }
[ "ralian@ralian.net" ]
ralian@ralian.net
e7fb38f4bdbb392e6b5c28280a5e2b196433543f
2502943d23a18cce4b2cb169288ca08e2243ca4f
/HDOJcode/1587 2013-02-05 21 25 02.cpp
4ef37236920c1f298439a4322991ffc798bd1ceb
[]
no_license
townboy/acm-algorithm
27745db88cf8e3f84836f98a6c2dfa4a76ee4227
4999e15efcd7574570065088b085db4a7c185a66
refs/heads/master
2021-01-01T16:20:50.099324
2014-11-29T06:13:49
2014-11-29T06:13:49
18,025,712
0
1
null
null
null
null
UTF-8
C++
false
false
790
cpp
****************************** Author : townboy Submit time : 2013-02-05 21:25:02 Judge Status : Accepted HDOJ Runid : 7597201 Problem id : 1587 Exe.time : 15MS Exe.memory : 640K https://github.com/townboy ****************************** #include<stdio.h> #include<memory.h> #include<iostream> using namespace std; int dp[100010]; int n,m; void chu() { memset(dp,0,sizeof(dp)); } void fun(int tem) { int i; for(i=tem;i<=100000;i++) dp[i]=max(dp[i],dp[i-tem]+1); } int main() { int i,tem; while(scanf("%d%d",&n,&m)!=EOF) { chu(); for(i=0;i<n;i++) { scanf("%d",&tem); fun(tem); } printf("%d\n",dp[m]); } return 0; }
[ "564690377@qq.com" ]
564690377@qq.com
c3b56ae63648b59116973f5402355b2b194421b0
82918094c076b84dd2299f865349e2bf1e7096c0
/main.cpp
348fcc3bb31016313fb3948a0ba07ef4795438bb
[]
no_license
verzep/NERVE
f86c50a738f743186fadf61188a6f87299a3c65b
7cb1a8b7f63d85b882774475675eb0b252840195
refs/heads/master
2021-10-24T02:35:12.726081
2019-03-21T13:16:46
2019-03-21T13:16:46
111,420,411
0
0
null
null
null
null
UTF-8
C++
false
false
2,121
cpp
#include <iostream> #include <cmath> #include <cstdlib> #include <stdlib.h> #include <time.h> #include <random> #include <vector> #include <fstream> #include <string> #include <sstream> #include <iomanip> #include <iostream> // std::cout #include <algorithm> // std::sort #include <vector> // std::vector #include "Class_Neuron.h" #include "Class_NeuralNetwork.h" #include "statistic.h" using namespace std; double** getMatrix(int N); int main(){ int N; double mu, sigma, theta, C; string esp; cout << "insert N (number of neurons)" << endl; cin >> N; cout << "insert mu (drift)" << endl; cin >> mu; cout << "insert sigma (noise intensity)" << endl; cin >> sigma; cout << "insert theta (membrane time)" << endl; cin >> theta; cout << "insert C (threshold)" << endl; cin >> C; NeuralNetwork NN1(N, mu, sigma, theta, C ); // N , mu, sigma ,theta, C (threshold) // Uncomment next line if you want a neuron to have a different mu //NN1.getNeur(1)->setMu(2); //JUMP MODEL cout << "insert the jump matrix " << endl; NN1.createJumpMatrix(getMatrix(N)); // COVARIANCE MODEL //cout << "insert the covariance matrix " << endl; //NN1.createCovMatrix(getMatrix(N)); cout << "Name of the experiment" << endl; cin >> esp; //NN1.printParam(); //-------------------- FPT NN1.FPT(10000); NN1.writeSpikeTimes_FPT(); //--------------------- SPIKE TRAIN //NN1.spikeTrain(250000, false); //NN1.writeSpikeTimes_ST(esp); //Il copia e incolla e' la fonte di ogni nequizia //ISI_full_3D(NN1.getNeur(0)->getSpikeTimes() , NN1.getNeur(1)->getSpikeTimes(), NN1.getNeur(2)->getSpikeTimes() , esp); //cout << NN1.getNeur(0) ->getLog().size() << endl; //cout << NN1.getNeur(1) ->getLog().size() << endl; NN1.printParam(); //NN1.writeLog(); }// end main double** getMatrix(int N){ double **K = new double *[N]; for(int i =0; i < N; i++){ K[i] = new double[N]; for(int j =0; j < N; ++j){ cout << "Insert element " << i+1 <<"," << j+1 << endl; cin >> K[i][j]; } } return K; }
[ "pietro.verzelli@gmail.com" ]
pietro.verzelli@gmail.com
1a4f4c50b62c2e14b44f5c2c449a5200400a083b
e88e91f8be9f62500591bc0f413fc213fc241fec
/forduo1/tv_optim/src/Expander.hpp
87604eeb16a2b3ecb9168d4ad562a2276c05d27b
[]
no_license
matthiasvegh/nng2014
e0e19ea83a1733ef38dc588f7c662ab01639f4bc
7d4af2e0a8416ef65abbeb9aef37f8b6025f3df8
refs/heads/master
2021-01-19T08:37:05.593858
2014-11-28T17:42:29
2014-11-28T17:42:29
27,274,398
1
1
null
null
null
null
UTF-8
C++
false
false
676
hpp
#ifndef SRC_EXPANDER_HPP #define SRC_EXPANDER_HPP #include "HeurCalculator.hpp" #include "NodeFactory.hpp" #include "PrioNodeQueue.hpp" #include "VisitedStates.hpp" class Expander { friend class InternalExpander; PrioNodeQueue& queue; VisitedStates& visitedStates; HeurCalculator calculator; NodeFactory nodeFactory; int expandedNodes = 0; public: Expander(PrioNodeQueue& queue, VisitedStates& visitedStates): queue(queue), visitedStates(visitedStates), nodeFactory{calculator} {} ~Expander(); void expand(const Status::ConstPtr& status, std::shared_ptr<Node> base); int getExpandedNodes() const { return expandedNodes; } }; #endif /* SRC_EXPANDER_HPP */
[ "kangirigungi@gmail.com" ]
kangirigungi@gmail.com
dd00c7bbf0f0bafceec66cf7777eb9ddfa2a9f76
3d232018a25f15042164aa7726b73f71e3165252
/indra/llcommon/reflectivet.h
e960eb183034c4da01790ab31d7a715de1c0a7f9
[]
no_license
OS-Development/VW.Meerkat
ee8dae5b077a709a618ed6550f157797fe577dcf
00645a93b672dd3ce5e02bd620a90b8e275aba01
refs/heads/master
2021-01-19T18:08:40.932912
2015-04-04T23:20:08
2015-04-04T23:20:08
33,423,332
1
0
null
null
null
null
UTF-8
C++
false
false
1,724
h
/** * @file reflectivet.h * * $LicenseInfo:firstyear=2006&license=viewergpl$ * * Copyright (c) 2006-2008, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab * to you under the terms of the GNU General Public License, version 2.0 * ("GPL"), unless you have obtained a separate licensing agreement * ("Other License"), formally executed by you and Linden Lab. Terms of * the GPL can be found in doc/GPL-license.txt in this distribution, or * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 * * There are special exceptions to the terms and conditions of the GPL as * it is applied to this Source Code. View the full text of the exception * in the file doc/FLOSS-exception.txt in this software distribution, or * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, * and agree to abide by those obligations. * * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * COMPLETENESS OR PERFORMANCE. * $/LicenseInfo$ */ #ifndef LL_REFLECTIVET_H #define LL_REFLECTIVET_H #include "reflective.h" template <class T> class LLReflectiveT : public LLReflective { public: LLReflectiveT(const T& value) : mValue(value) {;} virtual ~LLReflectiveT() {;} virtual const LLMetaClass& getMetaClass() const {return LLMetaClassT<LLReflectiveT<T> >::instance();} const T& getValue() const {return mValue;} private: T mValue; }; #endif
[ "?@?.?" ]
?@?.?
f3ccab06d81d21b21b4d4338ae81f46d54bf6487
3d2d8493bac65238cfb624f5d1c0438810ecff55
/JaalGraphics/MOC/moc_SingletDialog.cpp
03d5988ecba23a97349b1b99b076cad5515bc7e4
[]
no_license
csv610/JaalGeometry
238033bdac1e650b7b126a1721c7fe478304173d
f6c714e7bf1c24f2663a234ea300c02cd9ebb47b
refs/heads/master
2020-12-30T22:43:36.729295
2017-02-14T19:41:50
2017-02-14T19:41:50
80,649,641
10
2
null
null
null
null
UTF-8
C++
false
false
3,954
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'SingletDialog.hpp' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.5.1) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "SingletDialog.hpp" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'SingletDialog.hpp' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.5.1. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_JSingletDialog_t { QByteArrayData data[5]; char stringdata0[50]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_JSingletDialog_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_JSingletDialog_t qt_meta_stringdata_JSingletDialog = { { QT_MOC_LITERAL(0, 0, 14), // "JSingletDialog" QT_MOC_LITERAL(1, 15, 14), // "searchSinglets" QT_MOC_LITERAL(2, 30, 0), // "" QT_MOC_LITERAL(3, 31, 8), // "setColor" QT_MOC_LITERAL(4, 40, 9) // "removeAll" }, "JSingletDialog\0searchSinglets\0\0setColor\0" "removeAll" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_JSingletDialog[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 3, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 29, 2, 0x08 /* Private */, 3, 0, 30, 2, 0x08 /* Private */, 4, 0, 31, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, QMetaType::Void, QMetaType::Void, 0 // eod }; void JSingletDialog::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { JSingletDialog *_t = static_cast<JSingletDialog *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->searchSinglets(); break; case 1: _t->setColor(); break; case 2: _t->removeAll(); break; default: ; } } Q_UNUSED(_a); } const QMetaObject JSingletDialog::staticMetaObject = { { &QDialog::staticMetaObject, qt_meta_stringdata_JSingletDialog.data, qt_meta_data_JSingletDialog, qt_static_metacall, Q_NULLPTR, Q_NULLPTR } }; const QMetaObject *JSingletDialog::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *JSingletDialog::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_JSingletDialog.stringdata0)) return static_cast<void*>(const_cast< JSingletDialog*>(this)); if (!strcmp(_clname, "Ui::SingletDialog")) return static_cast< Ui::SingletDialog*>(const_cast< JSingletDialog*>(this)); return QDialog::qt_metacast(_clname); } int JSingletDialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 3) qt_static_metacall(this, _c, _id, _a); _id -= 3; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 3) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 3; } return _id; } QT_END_MOC_NAMESPACE
[ "csverma@blackhole2" ]
csverma@blackhole2
ac94e4a6e82f4eb71e4db7b0c89f2694f25b3a8d
ac1b1c717d68b29dbdfff56ce7f3422d01c1b961
/Tutorial/chapters.cpp
b15c88fcda36b93ef67a399937403d064de32f9c
[]
no_license
chapmankyle/learning-cpp
295c4ff4051417c96d2c82d70ed71543f465bed3
f6670fefc4f8ef8bf8a6978b73d3511add7a9073
refs/heads/master
2022-12-02T23:19:34.216773
2020-08-23T17:34:05
2020-08-23T17:34:05
285,798,686
0
0
null
null
null
null
UTF-8
C++
false
false
37,136
cpp
#include <array> // for std::array #include <algorithm> // for std::sort() #include <bitset> // for std::bitset #include <iterator> // for std::size() #include <string> // for std::string and std::getline #include <string_view> // for std::string_view #include <utility> // for std::swap() #include <vector> // for std::vector #include <cstddef> // for std::nullptr_t #include <cstdint> // for std::int_fast#_t and std::int_least#_t #include <cstdlib> // for std::rand() and std::srand() #include <ctime> // for std::time() #include <typeinfo> // for typeid() #include <iostream> // preprocessor macros #define SOME_TEXT "Some Text" #define PRINT /** * Chapter 1.4 * Variable assignment and initialization * (https://www.learncpp.com/cpp-tutorial/variable-assignment-and-initialization/) */ void chap1point4() { int a; // define variable (uninitialized) a = 5; // copy assignment of value 5 into 'a' #ifdef PRINT std::cout << "a = " << a << '\n'; #endif int b = 7; // copy initialization of value 7 into 'b' #ifdef PRINT std::cout << "b = " << b << '\n'; #endif int c(9); // direct initialization of value 9 into 'c' #ifdef PRINT std::cout << "c = " << c << '\n'; #endif int d{ 2 }; // direct brace initialization of value 2 into 'd' #ifdef PRINT std::cout << "d = " << d << '\n'; #endif int e{}; // direct brace zero initialization #ifdef PRINT std::cout << "e = " << e << '\n'; #endif int f{ 0 }; // when using value immediately after int g{}; // when immediately replacing value #ifdef PRINT std::cout << "f = " << f << '\n'; std::cout << "g = " << g << '\n'; #endif } /** * Chapter 1.6 * Tricks compiler into thinking parameter value is used * (https://www.learncpp.com/cpp-tutorial/uninitialized-variables-and-undefined-behavior/) */ void doNothing(int&) { } /** * Chapter 1.7 * All of the current keywords present in C++17 * (https://www.learncpp.com/cpp-tutorial/keywords-and-naming-identifiers/) */ void chap1point7() { std::string_view a{ "alignas alignof and and_eq asm auto bitand bitor bool break\n" }; std::string_view b{ "case catch char char16_t char32_t class compl const constexpr const_cast\n" }; std::string_view c{ "continue decltype default delete do double dynamic_cast else enum explicit\n" }; std::string_view d{ "export extern false float for friend goto if inline int\n" }; std::string_view e{ "long mutable namespace new noexcept not not_eq nullptr operator or\n" }; std::string_view f{ "or_eq private protected public register reinterpret_cast return short signed sizeof\n" }; std::string_view g{ "static static_assert static_cast struct switch template this thread_local throw\n" }; std::string_view h{ "true try typedef typeid typename union unsigned using virtual void\n" }; std::string_view i{ "volatile wchar_t while xor xor_eq\n" }; std::cout << a << b << c << d << e << f << g << h << i; } /** * Chapter 1.9 * Introduction to expressions * (https://www.learncpp.com/cpp-tutorial/introduction-to-expressions/) */ void chap1point9(void) { int x{ 17 }; // direct brace initialization int y{ x - 12 }; // expression within initialization std::cout << "x = " << x << "\ny = " << y << '\n'; } /* * Chapter 4.6 * Fixed-width integers and size_t * (https://www.learncpp.com/cpp-tutorial/fixed-width-integers-and-size-t/) */ void chap4point6() { // unsigned (avoid use as may not be defined on all target architectures) std::uint8_t a{}; // (1) 0 to 255 std::uint16_t b{}; // (2) 0 to 65,535 std::uint32_t c{}; // (4) 0 to 4,294,967,295 std::uint64_t d{}; // (8) 0 to 18,446,744,073,709,551,615 // signed (avoid use as may not be defined on all target architectures) std::int8_t e{}; // (1) -128 to 127 (may be interpreted as a char on some compilers) std::int16_t f{}; // (2) -32,768 to 32,767 std::int32_t g{}; // (4) -2,147,483,648 to 2,147,483,647 std::int64_t h{}; // (8) -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 // fast integers (guaranteed minimum size, safe and recommended) std::int_fast16_t i{}; // at least 16 bits (2 bytes) std::int_fast32_t j{}; // at least 32 bits (4 bytes) std::int_fast64_t k{}; // at least 64 bits (8 bytes) // least integers (guaranteed actual size, safe and recommended) std::int_least16_t l{}; // guaranteed to be 16 bits (2 bytes) std::int_least32_t m{}; // guaranteed to be 32 bits (4 bytes) std::int_least64_t n{}; // guaranteed to be 64 bits (8 bytes) // std::size_t is the size of the largest object creatable on your system } /* * Chapter 4.9 * Boolean values * (https://www.learncpp.com/cpp-tutorial/boolean-values/) */ void chap4point9() { // declaration bool isTrue{ true }; // use std::boolalpha to print boolean values as 'true' or 'false' std::cout << std::boolalpha; std::cout << true << '\n'; // use std::noboolalpha to return to normal printing std::cout << std::noboolalpha; std::cout << true << '\n'; } /* * Chapter 4.11 * Chars * (https://www.learncpp.com/cpp-tutorial/chars/) */ void chap4point11() { // use single quotes over double quotes in every applicable instance char c{ 'a' }; // equally as valid as above, but not preferred char d{ 97 }; // casting from one type to another // static_cast<new_type>(expression) char e{ static_cast<char>(97) }; // hex numbers can be printed by using '\x<hex>' std::cout << "6F in hex is char '\x6F'\n"; } /* * Chapter 4.12 * Literals * (https://www.learncpp.com/cpp-tutorial/literals/) */ void chap4point12() { // add suffix with upper or lowercase letter to specify type explicitly long x{ 5L }; float y{ 4.3f }; // no need to specify explicitly since any decimal will be converted to // double unless 'f' is appended to the end double z{ 6.02e23 }; // assigning binary value using hexadecimal int bin{}; bin = 0x01; // assign binary 0000 0001 to the variable bin = 0x02; // assign binary 0000 0010 to the variable bin = 0x04; // assign binary 0000 0100 to the variable bin = 0x08; // assign binary 0000 1000 to the variable bin = 0x10; // assign binary 0001 0000 to the variable bin = 0x20; // assign binary 0010 0000 to the variable bin = 0x40; // assign binary 0100 0000 to the variable bin = 0x80; // assign binary 1000 0000 to the variable bin = 0xFF; // assign binary 1111 1111 to the variable bin = 0xB3; // assign binary 1011 0011 to the variable // print in different formats std::cout << std::dec; // decimal (default) std::cout << std::hex; // hexadecimal std::cout << std::oct; // octal // to print binary, use std::bitset<num_bits>{expression} // useful for holding actual binary values and working with them std::cout << std::bitset<4>{ 0b1010 } << '\n'; // magic numbers int numClassrooms{ 10 }; int maxStudents{ numClassrooms * 30 }; // '30' is a MAGIC number } /* * Chapter 4.13 * Const, constexpr and symbolic constants * (https://www.learncpp.com/cpp-tutorial/const-constexpr-and-symbolic-constants/) */ void chap4point13() { const double gravity{ 9.8 }; // value will not change // const is often used in function parameters // e.g. void someFunc(const int age) // ---------------------------------- // This tells the person calling the function that the function will not // change the value of the parameter, and it ensures that the function does // not change the value of the parameter. // constexpr needs to be able to be resolved at COMPILE time. // e.g. constexpr int nextAge{ age + 1 }; // => not valid since 'age' is evaluated at RUNTIME. constexpr int nextAge{ 12 + 32 }; // valid since 12 + 32 can be resolved at COMPILE time // symbolic constants // - using preprocessor macros (#define <identifier> <substitution>) // -> could break if including some file with a macro with the same name // - using constexpr variables (recommended) // inline function - removes a function call by copy/pasting the function // body into the call site (may create a larger executable). // inline function will be ignored if function contains // 1) a loop // 2) static variables // 3) recursive calls // 4) switch / goto statement // inline variable - guarantees that the variable will have the same // memory address no matter where it is called from or defined. // using constants in multiple files // 1) create header file to hold constants // 2) declare namespace inside header file // 3) add all constants to namespace // 4) #include header file wherever you need // e.g.: // constants.hpp // namespace constants { // inline constexpr double pi{ 3.14159 }; // } // use as following -> constants::pi } /* * Chapter 5.2 * Arithmetic operators * (https://www.learncpp.com/cpp-tutorial/arithmetic-operators/) */ void chap5point2() { int x{ 7 }; int y{ 4 }; // the following shows that if any of the operands are a floating // point number, the result will be a floating point value std::cout << "int / int = " << x / y << '\n'; std::cout << "double / int = " << static_cast<double>(x) / y << '\n'; std::cout << "int / double = " << x / static_cast<double>(y) << '\n'; std::cout << "double / double = " << static_cast<double>(x) / static_cast<double>(y) << '\n'; } /* * Chapter 5.3 * Modulus and exponentiation * (https://www.learncpp.com/cpp-tutorial/5-3-modulus-and-exponentiation/) */ void chap5point3() { // modulus always takes the sign of the first operand constexpr int x{ -6 }; constexpr int y{ 4 }; constexpr int z{ -2 }; std::cout << x << " % " << y << " = " << x % y << '\n'; // -2 std::cout << x << " % " << z << " = " << x % z << '\n'; // 0 std::cout << y << " % " << x << " = " << y % x << '\n'; // 4 std::cout << y << " % " << z << " = " << y % z << '\n'; // 0 std::cout << z << " % " << x << " = " << z % x << '\n'; // -2 std::cout << z << " % " << y << " = " << z % y << '\n'; // -2 } /* * Chapter 5.5 * Comma and conditional operators * (https://www.learncpp.com/cpp-tutorial/comma-and-conditional-operators/) */ void chap5point5() { // comma separator is used to evaluate first expression and then second int x{ 1 }; int y{ 2 }; std::cout << (++x, ++y) << '\n'; // increment x and y, evaluates to right operand // conditional operator (always surround entire operator with parentheses) int larger = ((x > y) ? x : y); } /* * Optional chapter O.1 * Bit flags and bit manipulation via std::bitset * (https://www.learncpp.com/cpp-tutorial/o-1-bit-flags-and-bit-manipulation-via-stdbitset/) */ void chapOpoint1() { // set initial bitset with 8 bits std::bitset<8> bits{ 0b0000'0101 }; // available functions bits.set(3); // set bit position 3 to 1 (now have 0000 1101) bits.flip(4); // flip bit position 4 (now have 0001 1101) bits.reset(4); // set bit position 4 to 0 (now have 0000 1101) bits.test(1); // returns the value of the bit at position 1 (returns 0) } /* * Optional chapter O.2 * Bitwise operators * (https://www.learncpp.com/cpp-tutorial/bitwise-operators/) */ void chapOpoint2() { // NB: only used unsigned integers for bit manipulation! unsigned int x{ 0b1010 }; unsigned int res{}; // [insert 0 at the end] left shift by 1 bit (1010 -> 0100) res = x << 1; // [insert 0 at the start] right shift by 1 bit (1010 -> 0101) res = x << 1; // bitwise not (flips every bit: 1010 -> 0101) res = ~x; // bitwise AND (&) returns true if both bits are true, false otherwise // 0 1 0 1 AND // 0 1 1 0 // ------- // 0 1 0 0 // bitwise OR (|) returns false if both bits are false, true otherwise // 0 1 0 1 OR // 0 1 1 0 // ------- // 0 1 1 1 // bitwise XOR (^) returns true if and only if one bit is true, false otherwise // 0 1 0 1 XOR // 0 1 1 0 // ------- // 0 0 1 1 } /* * Optional chapter O.3 * Bit manipulation with bitwise operators and bit masks * (https://www.learncpp.com/cpp-tutorial/bit-manipulation-with-bitwise-operators-and-bit-masks/) */ void chapOpoint3() { // bit masks protect the bits we don't want altered and change the bits // we did want to change (use 0 to mask out bits we don't want changed, // and use 1 to denote the bits we want changed) constexpr std::uint_fast8_t mask0{ 0b0000'0001 }; constexpr std::uint_fast8_t mask1{ 0b0000'0010 }; constexpr std::uint_fast8_t mask2{ 0b0000'0100 }; constexpr std::uint_fast8_t mask3{ 0b0000'1000 }; std::uint_fast8_t check{ 0b0000'0101 }; // ######## TEST ######## // check if bit 0 is on or off std::cout << "bit 0 is " << ((check & mask0) ? "on\n" : "off\n"); // 0 0 0 0 0 1 0 1 AND // 0 0 0 0 0 0 0 1 // --------------- // 0 0 0 0 0 0 0 1 (= 2^0 = 1 => true) // check if bit 1 is on or off std::cout << "bit 1 is " << ((check & mask1) ? "on\n" : "off\n"); // 0 0 0 0 0 1 0 1 AND // 0 0 0 0 0 0 1 0 // --------------- // 0 0 0 0 0 0 0 0 (= 0 => false) // ######## SET ######## std::cout << "bit 1 is " << ((check & mask1) ? "on\n" : "off\n"); check |= mask1; std::cout << "bit 1 is " << ((check & mask1) ? "on\n" : "off\n"); // 0 0 0 0 0 1 0 1 OR // 0 0 0 0 0 0 1 0 // --------------- // 0 0 0 0 0 1 1 1 // you can set multiple bits at the same time check |= (mask2 | mask3); // ######## RESET ######## std::cout << "bit 1 is " << ((check & mask1) ? "on\n" : "off\n"); check &= ~mask1; std::cout << "bit 1 is " << ((check & mask1) ? "on\n" : "off\n"); // 0 0 0 0 0 0 1 0 NOT // --------------- // 1 1 1 1 1 1 0 1 // // 0 0 0 0 0 1 1 1 AND // 1 1 1 1 1 1 0 1 // --------------- // 0 0 0 0 0 1 0 1 // you can reset multiple bits at the same time check &= ~(mask2 | mask3); // ######## FLIP ######## std::cout << "bit 1 is " << ((check & mask1) ? "on\n" : "off\n"); check ^= mask1; std::cout << "bit 1 is " << ((check & mask1) ? "on\n" : "off\n"); // you can flip multiple bits at the same time check ^= (mask2 | mask3); // most useful for passing in options to a function, so instead of // | void someFunc(bool option1, bool option2, ..., bool option 32) | // we can have // | void someFunc(std::bitset<32> options) | // then call with // someFunc(option2 | option10) } /* * Chapter 6.2 * User defined namespaces * (https://www.learncpp.com/cpp-tutorial/user-defined-namespaces/) */ void chap6point2() { // declaring namespace // namespace foo { // int sum(int x, int y) { // return x + y; // } // } // then use it as foo::sum(x, y) // :: is called the 'scope resolution modifier' // calling a function in the global namespace can be done by // ::funcName [no prefix] // namespace with same name can have functions added to it in different // files, so you can actually add functions to the `std` namespace if you // wanted // you can alias namespaces, for example // namespace boo = foo::goo; } /* * Chapter 6.4 * Introduction to global variables * (https://www.learncpp.com/cpp-tutorial/introduction-to-global-variables/) */ void chap6point4() { // global variables, declare with g_ // zero-initialized by default // internal linkage - can be seen and used within a single file, but // not accessible from other files // => also known as 'internal' variables // external linkage - can be seen and used across multiple files // => also known as 'external' variables // non-constant global variables have external linkage by default // 'static' (storage class specifier) keyword gives variable internal linkage // 'const' has internal linkage by default // 'constexpr' has internal linkage by default } /* * Chapter 6.7 * External linkage * (https://www.learncpp.com/cpp-tutorial/external-linkage/) */ void chap6point7() { // convert variables/functions with internal linkage to external by using // extern <type> <name> // eg: extern const int g_x{ 1 }; will convert g_x to an external variable // inline global variables have external linkage by default // prefer using // inline constexpr <name>{ <value> }; // in a namespace than using 'extern' } /* * Chapter 6.13 * Typedefs and type aliases * (https://www.learncpp.com/cpp-tutorial/typedefs-and-type-aliases/) */ void chap6point13() { // typedef => type definition, allows programmer to create alias for // a data type (usually suffixed with a "_t" // 'typedef <data_type> <alias>' (type definition) OR // 'using <alias> = <data_type>' (type alias) typedef double distance_t; using speed_t = double; distance_t distanceTravelled{ 300 }; speed_t carSpeed{ 118.5 }; } /* * Chapter 6.14 * The auto keyword * (https://www.learncpp.com/cpp-tutorial/the-auto-keyword/) */ void chap6point14() { // during initialization, you can tell C++ to infer the correct type using 'auto' // the below two statements are the same double a{ 5.0 }; auto b{ 5.0 }; // auto can be used for function return types (NOT RECOMMENDED) // e.g. auto add(int x, int y) { return x + y } // will return a value of type int // you can use 'trailing return syntax' to make all forward declarations of // functions line up // e.g. auto add(int x, int y) -> int; // auto divide(double x, double y) -> double; // auto substr(const std::string &s, int start, int len) -> std::string; // DO NOT USE 'auto' FOR FUNCTION PARAMETERS // instead use 'function templates' } /* * Chapter 6.15 * Implicit type conversion (coercion) * (https://www.learncpp.com/cpp-tutorial/implicit-type-conversion-coercion/) */ void chap6point15() { // two type conversions: // - implicit => compiler transforms one data type into another // e.g. double d{ 3 }; => compiler converts int 3 into a double // - explicit => developer uses casting operator to direct the conversion // e.g. double d{ static_cast<double>(3) }; // numeric promotion long l{ 64 }; // widen integer 64 into a long double d{ 0.12f }; // promote float 0.12 into a double // integral promotion => conversion of integer types narrower than int (bool, // char, unsigned char, short, unsigned short) to an int (if possible), or // unsigned int otherwise (usually involves adding leading 0s) // floating point promotion => conversion of float to double // std::cout << std::setprecision(9); // sets the precision to print to in the console (#include <iomanip>) int a{ 4 }; int b{ 5 }; // show the type of an expression std::cout << typeid(a + b).name() << ' ' << a + b << '\n'; // when two operands are of a different type, the following priority applies: // - long double (highest) // - double // - float // - unsigned long long // - long long // - unsigned long // - long // - unsigned int // - int (lowest) // ==> e.g. if one operand is a 'long double' and the other operand is an // 'int', both operands will be cast to 'long double' since it has // a higher priority } /* * Chapter 6.16 * Explicit type conversion (casting) * (https://www.learncpp.com/cpp-tutorial/explicit-type-conversion-casting-and-static-cast/) */ void chap6point16() { // AVOID const casts AND reinterpret casts UNLESS GOOD REASON TO USE THEM // AVOID C-style casts => float f{ (float) 1 / 2 }; // favour static casts when converting from one fundamental type to another int a{ 10 }; int b{ 4 }; float f{ static_cast<float>(a) / b }; } /* * Chapter 6.17 * Unnamed and inline namespaces * (https://www.learncpp.com/cpp-tutorial/unnamed-and-inline-namespaces/) */ void chap6point17() { // unnamed namespace is typically used when you have a lot of content that you // want to ensure stays local to the file, instead of individually marking each // declaration as static // e.g. namespace { void sayHello() { std::cout << "Hello\n"; } } // inline namespaces will be used when no scope resolution modifier (::) is // provided // for example: // inline namespace v1 { void sayHi() { std::cout << "Hi\n"; } } // namespace v2 { void sayHi() { std::cout << "Hello\n"; } } // v1::sayHi() => calls sayHi from namespace v1 // v2::sayHi() => calls sayHi from namespace v2 // sayHi() => calls sayHi from namespace v1 } /* * Chapter S.4.4b * An introduction to std::string * (https://www.learncpp.com/cpp-tutorial/4-4b-an-introduction-to-stdstring/) */ void chapSpoint4b() { // declare string std::string myName{ "Kyle" }; // getting input from std::cin only reads until first whitespace // use std::getline instead to get the full line std::cout << "Enter your name: "; std::string enteredName{}; std::getline(std::cin, enteredName); // if you use std::cin then std::getline, you may run into problems // => ignore characters using // std::cin.ignore(32767, '\n') OR // std::cin.ignore(std::numeric_limits<sttd::streamsize>::max(), '\n') // which ignores up to 32767 characters until a \n is removed // std::numeric_limits needs #include <limits> // get length of string int nameLength{ static_cast<int>(myName.length()) }; // get character at index char a{ myName.at(1) }; char b{ myName[1] }; } /* * Chapter S.4.5 * Enumerated types * (https://www.learncpp.com/cpp-tutorial/45-enumerated-types/) */ void chapSpoint5() { // use an enum to represent options // enum Result { // RESULT_SUCCESS, // (0) // RESULT_ERROR_OPENING_FILE, // (1) // RESULT_ERROR_READING_FILE // (2) // } // only problem is that the enum values can conflict with // preprocessor macros // you can forward-declare an enum, but you have to specify its type // enum Color : int; // then you need to include the base when defining it // enum Color : int { // ... // } // problem with enum types is the following: // enum Color { COLOR_RED, COLOR_BLUE }; // enum FRUIT { FRUIT_APPLE, FRUIT_BANANA }; // Color col{ COLOR_RED }; // Fruit fruit{ FRUIT_APPLE }; // (col == fruit) => returns true, even though they are from different enums // fix is to use enum classes // enum class Color { RED }; // call with // Color col{ Color::RED }; } /* * Chapter S.4.7 * Structs * (https://www.learncpp.com/cpp-tutorial/47-structs/) */ void chapSpoint7() { // struct can aggregate variables of different data types struct Person { std::string name; int age; double bmi; }; // define as follows Person me{ "Kyle", 21, 18.8 }; Person beb{ "Beb", 21 }; // `bmi` will default to a zero value // interact using the dot '.' int meAge{ me.age }; me.bmi += 0.3; // you can set default values for a struct struct Rectangle { double width{ 1.0 }; double height{ 1.0 }; }; // we can get the zero of any struct by using the curly braces // Point3D getZeroPoint() { // return {}; // } // OR // Point3D getZeroPoint() { // return { 0.0, 0.0, 0.0 }; // } // to be more explicit, but will have to change number of 0s if update struct parameters // to use struct across many files, put struct declaration in header file // and #include header } /* * Chapter 5.9 * Random number generation * (https://www.learncpp.com/cpp-tutorial/59-random-number-generation/) */ void chap5point9() { // set seed to time std::srand(static_cast<unsigned int>(std::time(nullptr))); // get random number int rand{ std::rand() }; // get random number between range, where RAND_MAX ~= 32767 // int getRandomNumber(int min, int max) { // static constexpr double fraction { 1.0 / (RAND_MAX + 1.0) }; // only calculates value once // return min + static_cast<int>((max - min + 1) * (std::rand() * fraction)); // } // when debugging using a random number, set the seed to a concrete // value so that the same random numbers are generated every time // Mersenne Twister PRNG // #include <random> // for std::mt19937 // namespace Rand { // std::mt19937 mersenne{ static_cast<std::mt19937::result_type> }; // } // int getRandomNumber(int min, int max) { // std::uniform_int_distribution die{ min, max }; // create distribution in any function that needs it // return die(Rand::mersenne); // } } /* * Chapter P.6.1 * Arrays (Part I) * (https://www.learncpp.com/cpp-tutorial/61-arrays-part-i/) */ void chapPpoint1() { // zero initialize array of size 4 double someArray[4]{}; // initialize array with elements (let compiler decide how many elements) int theArray[]{ 1, 2, 3, 4 }; // array size has to be compile-time constant // cannot be some variable that is read in from command-line for example } /* * Chapter P.6.2 * Arrays (Part II) * (https://www.learncpp.com/cpp-tutorial/62-arrays-part-ii/) */ void chapPpoint2() { // if array has greater size than declaration, rest will be zeros int prime[5]{ 1, 3, 5, 7 }; // use enums to get the elements (allows you to add more students and keeps track of size) enum StudentNames { KYLE, JENNA, FRANNA, ANTON, MAX_STUDENTS }; // initialize as follows int testScores[MAX_STUDENTS]{}; testScores[KYLE] = 76; // does not work with enum classes, since they don't automatically convert to int enum class OtherStudents { BEB, ADRIAN, RONALDO, AIDAN, MAX_STUDENTS }; // use static_cast for enum classes int otherTestScores[static_cast<int>(OtherStudents::MAX_STUDENTS)]{}; otherTestScores[static_cast<int>(OtherStudents::RONALDO)] = 21; // however, this is a pain so we use enum inside of namespace // namespace MoreStudents { // enum SomeMoreStudents { // DECLAN, // MORNE, // JARROD, // MAX_STUDENTS // }; // } // then use like // int testScores[MoreStudents::MAX_STUDENTS]{}; // function parameters are pass-by-value, but arrays are // pass-by-reference // to not alter the array passed as a parameter, we can use // func(const <array_type> <array_name>[<num_elements>]) // find size of array using std::size() [need to #include <iterator>] int findingSize[]{ 1, 2, 3, 4, 5, 6 }; int sizeOfArray1{ static_cast<int>(std::size(findingSize)) }; // added in C++17 // find size of array using sizeof() int sizeOfArray2{ sizeof(findingSize) / sizeof(findingSize[0]) }; } /* * Chapter P.6.4 * Sorting using selection sort * (https://www.learncpp.com/cpp-tutorial/64-sorting-an-array-using-selection-sort/) */ void chapPpoint4() { // selection sort int arr[]{ 30, 50, 20, 10, 40 }; constexpr int length{ static_cast<int>(std::size(arr)) }; // last element will already be sorted when we get there for (int i{ 0 }; i < length - 1; ++i) { // assume smallest element is first element int minIdx{ i }; // look for smaller element for (int j{ i + 1 }; j < length; ++j) { if (arr[j] < arr[i]) { minIdx = j; } } // swap indices std::swap(arr[i], arr[minIdx]); } // alternatively, use std::sort() from <algorithm> header int otherArr[]{ 30, 50, 20, 10, 40 }; // sorts in-place std::sort(std::begin(otherArr), std::end(otherArr)); } /* * Chapter P.6.5 * Multidimensional arrays * (https://www.learncpp.com/cpp-tutorial/65-multidimensional-arrays/) */ void chapPpoint5() { // order is [<num_rows>][<num_cols>] // can only omit left-most length specifier int arr[][3]{ {1, 2, 3}, {4, 5, 6} }; } /* * Chapter P.6.6a * An introduction to std::string_view * (https://www.learncpp.com/cpp-tutorial/6-6a-an-introduction-to-stdstring_view/) */ void chapPpoint6() { // can create strings using a character array char text[]{ "hello" }; // copies value into a seperate string object std::string str1{ text }; std::string str2{ str1 }; // string_view is simply a view onto a string // i.e. does not copy string, instead refers to original string // any operation done to string is changed in original string // std::string and std::string_view cannot be concatenated // if std::string_view refers to string that is out of scope, causes // undefined behaviour } /* * Chapter P.6.7 * Introduction to pointers * (https://www.learncpp.com/cpp-tutorial/67-introduction-to-pointers/) */ void chapPpoint7() { // define normal variable int x{ 5 }; // store address of (&) variable in pointer int *addrX{ &x }; // store value of (*), a.k.a dereference, variable int valX{ *(&x) }; // for variables => put asterisk next to variable name // for functions => put asterisk next to return type // pointer size depends on size of type the pointer is storing // i.e. int => pointer of size 4 bytes // char => pointer of size 1 byte } /* * Chapter P.6.7a * Null pointers * (https://www.learncpp.com/cpp-tutorial/6-7a-null-pointers/) */ void chapPpoint7a() { // use nullptr to denote a null pointer int *x{ nullptr }; // can specify null pointer to function by using null pointer type std::nullptr_t ptr{ nullptr }; } /* * Chapter P.6.8a * Pointer arithmetic and array indexing * (https://www.learncpp.com/cpp-tutorial/6-8a-pointer-arithmetic-and-array-indexing/) */ void chapPpoint8a() { // arrays *decay* into a pointer that points to the first element int arr[]{ 1, 2, 3, 4, 5 }; // we can index into array using pointers { arr[n] == *(arr + n) } int firstElem{ *arr }; int secondElem{ *(arr + 1) }; // trying to print address of character pointer will print garbage } /* * Chapter P.6.9 * Dynamic memory allocation with new and delete * (https://www.learncpp.com/cpp-tutorial/69-dynamic-memory-allocation-with-new-and-delete/) */ void chapPpoint9() { int *ptr{ new int }; // dynamically allocate an integer *ptr = 7; // assign value to memory allocated delete ptr; // return memory to operating system // any further references to ptr will cause undefined behaviour (dangling pointer) int *otherPtr{ new int{ 7 } }; // use uniform initialization for dynamic variable // check if memory has been allocated int *val{ new (std::nothrow) int{} }; // val will be set to nullptr if allocation fails if (!val) { std::cout << "Could not allocate memory"; } // have to delete to stop memory leaks (does nothing if val == nullptr) delete val; // if dynamically allocated variable does not get deleted, // can cause memory leak since the address is lost when variable // goes out of scope } /* * Chapter P.6.9a * Dynamically allocating arrays * (https://www.learncpp.com/cpp-tutorial/6-9a-dynamically-allocating-arrays/) */ void chapPpoint9a() { // dynamic array allocation std::size_t arrLength{ 2 }; // needs to be size_t or use a static_cast<std::size_t>(...) int *arr{ new int[arrLength] }; // dynamic array deletion delete[] arr; // show differences between const pointers and normal pointers int val{ 5 }; const int *ptr1 = &val; // ptr1 points to "const int" => pointer to constant value int *const ptr2 = &val; // ptr2 points to an "int" => const pointer to non-const value const int *const ptr3 = &val; // ptr3 points to "const int" => constant pointer to const value } /* * Chapter P.6.11 * References * (https://www.learncpp.com/cpp-tutorial/611-references/) */ void chapPpoint11() { // keep reference to value int value{ 5 }; int &ref{ value }; // setting or getting the value from a reference will alter the original value // l-value (ell-value) is value that has an address in memory // r-value (arr-value) is value that is not an l-value // when needing to change the value of a variable, use a reference as the parameter // i.e. // void changeN(int &ref) { // ref = 6; // } // int main() { // int n{ 5 }; // std::cout << n << '\n'; // changeN(n); // std::cout << n << '\n'; // return 0; // } // can be used to reference nested values in structs, for example: struct Point { float x; float y; }; struct Rectangle { Point p1; Point p2; Point p3; Point p4; }; Rectangle rect{}; float &fx{ rect.p1.x }; // access nested float // member selection using pointer to struct Rectangle *r{ &rect }; (*r).p1.x = 21.3; // valid r->p1.x = 22.4; // equally valid and preferred } /* * Chapter P.6.12a * For-each loops * (https://www.learncpp.com/cpp-tutorial/6-12a-for-each-loops/) */ void chapPpoint12() { // looping over array using for-each constexpr int fibonacci[]{ 0, 1, 1, 2, 3, 5, 8, 13 }; for (int num : fibonacci) { // copies each element from array std::cout << num << ' '; } std::cout << '\n'; // using 'auto' keyword is better than typing entire type // using 'const' keyword is preferred when not changing value // using '&' (reference) is preferred if the elements are NON-FUNDAMENTAL data types std::string names[]{ "Kyle", "Beb", "Declan" }; for (const auto &name : names) { std::cout << name << ' '; } std::cout << '\n'; } /* * Chapter P.6.13 * Void pointers * (https://www.learncpp.com/cpp-tutorial/613-void-pointers/) */ void chapPpoint13() { // void pointers can point to any data type int val{ 5 }; void *ptr{ &val }; // in order to use it, pointer must be explicitly cast to another type int *intPtr{ static_cast<int*>(ptr) }; // used mainly for passing to functions // i.e. printPointer(void *ptr) // can call `printPointer(int *ptr)` } /* * Chapter P.6.15 * An introduction to std::array * (https://www.learncpp.com/cpp-tutorial/6-15-an-introduction-to-stdarray/) */ void chapPpoint15() { // create array std::array numbers{ 0, 1, 2, 3, 4 }; // can use [] or .at to get element int someNum{ numbers[2] }; // no bounds-checking someNum = numbers.at(1); // bounds-checking // get the length of the array int len = numbers.size(); // always pass std::array by reference or const reference // can sort in ascending or descending order std::sort(numbers.begin(), numbers.end()); // increasing order std::sort(numbers.rbegin(), numbers.rend()); // decreasing order // can use for-each for (int num : numbers) { std::cout << num << ' '; } std::cout << '\n'; // BE CAREFUL when using a normal for loop because `size` returns size_type (unsigned) // use 'std::size_t' keyword for index variable, since std::array::size_type is alias for std::size_t for (std::size_t i{ 0 }; i < numbers.size(); ++i) { std::cout << numbers[i] << ' '; } std::cout << '\n'; // reverse for loop DOES NOT work like you think // the below code produces an infinite loop // 1) for (auto i{ numbers.size() - 1 }; i >= 0; --i) { // 2) ... // 3) } // this is because the result of `numbers.size() - 1` will be an unsigned int, // thus always >= 0 // WORKING reverse for loop, but looks odd for (auto i{ numbers.size() }; i-- > 0; ) { std::cout << numbers[i] << ' '; } std::cout << '\n'; // works because we decrement after comparison, so it wraps around for // the last time, but we don't use that result // cannot brace initialize an array of structs // std::array - fixed size array // std::vector - dynamically allocated array (allows for resize) } /* * Chapter P.6.18 * Introduction to standard library algorithms * (https://www.learncpp.com/cpp-tutorial/introduction-to-standard-library-algorithms/) */ void chapPpoint18() { std::array numbers{ 1, 2, 3, 4, 8 }; int search{ 5 }; // find an element in array, returning end if not found or iterator pointing to element auto found{ std::find(numbers.begin(), numbers.end(), search) }; // check if found element if (found == numbers.end()) { std::cout << "Could not find " << search << '\n'; } // check if string array contains string std::array<std::string_view, 4> arr{ "apple", "banana", "orange", "lemon" }; bool contains = arr[0].find("nana") != std::string_view::npos; // use std::for_each to apply a function to each element in array // std::for_each(arr.begin(), arr.end(), doubleNum); // vector used for dynamic arrays std::vector someVec{ "hi", "there" }; } /* * Chapter F.7.4 * Passing arguments by value, reference and address * (https://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/) */ void chapFpoint4() { // pass by value // - copies value from parameter and is destroyed after function call // - best used for passing primitive data types // - e.g: void func(int val); // pass by reference // - uses actual value from parameter, so changing param is possible // - best used for passing non-primitive data types and to change parameter // - e.g: void func(std::array &arr); // pass by address // - uses the address of the value as a parameter (actually decays to pass-by-value) // - prefer pass-by-reference instead // - e.g: void func(int *x); // return by value // - best used when returning variables that were declared inside function // - e.g: int func(int val); // return by reference // - best used when returning variables that were passed by reference or when returning a struct/class // - e.g: std::array& func(std::array &arr); // return by address // - best used when returning dynamically allocated memory // - e.g: int* func(int *val); // `static` inside function ensures variable is not destroyed when function ends }
[ "kyleichapman@gmail.com" ]
kyleichapman@gmail.com
5484d80e6803492f3f5b0830a5f830f6c093f7ba
0494c9caa519b27f3ed6390046fde03a313d2868
/src/content/renderer/dom_storage/dom_storage_cached_area.h
2aa4cd9ffa2795b80d4bd8c23642d59f944b8018
[ "BSD-3-Clause" ]
permissive
mhcchang/chromium30
9e9649bec6fb19fe0dc2c8b94c27c9d1fa69da2c
516718f9b7b95c4280257b2d319638d4728a90e1
refs/heads/master
2023-03-17T00:33:40.437560
2017-08-01T01:13:12
2017-08-01T01:13:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,373
h
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ #define CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_ #include <map> #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "base/strings/nullable_string16.h" #include "content/common/content_export.h" #include "url/gurl.h" namespace dom_storage { class DomStorageMap; } namespace content { class DomStorageProxy; // Unlike the other classes in the dom_storage library, this one is intended // for use in renderer processes. It maintains a complete cache of the // origin's Map of key/value pairs for fast access. The cache is primed on // first access and changes are written to the backend thru the |proxy|. // Mutations originating in other processes are applied to the cache via // the ApplyMutation method. class CONTENT_EXPORT DomStorageCachedArea : public base::RefCounted<DomStorageCachedArea> { public: DomStorageCachedArea(int64 namespace_id, const GURL& origin, DomStorageProxy* proxy); int64 namespace_id() const { return namespace_id_; } const GURL& origin() const { return origin_; } unsigned GetLength(int connection_id); base::NullableString16 GetKey(int connection_id, unsigned index); base::NullableString16 GetItem(int connection_id, const base::string16& key); bool SetItem(int connection_id, const base::string16& key, const base::string16& value, const GURL& page_url); void RemoveItem(int connection_id, const base::string16& key, const GURL& page_url); void Clear(int connection_id, const GURL& page_url); void ApplyMutation(const base::NullableString16& key, const base::NullableString16& new_value); size_t MemoryBytesUsedByCache() const; private: friend class DomStorageCachedAreaTest; friend class base::RefCounted<DomStorageCachedArea>; ~DomStorageCachedArea(); // Primes the cache, loading all values for the area. void Prime(int connection_id); void PrimeIfNeeded(int connection_id) { if (!map_.get()) Prime(connection_id); } // Resets the object back to its newly constructed state. void Reset(); // Async completion callbacks for proxied operations. // These are used to maintain cache consistency by preventing // mutation events from other processes from overwriting local // changes made after the mutation. void OnLoadComplete(bool success); void OnSetItemComplete(const base::string16& key, bool success); void OnClearComplete(bool success); void OnRemoveItemComplete(const base::string16& key, bool success); bool should_ignore_key_mutation(const base::string16& key) const { return ignore_key_mutations_.find(key) != ignore_key_mutations_.end(); } bool ignore_all_mutations_; std::map<base::string16, int> ignore_key_mutations_; int64 namespace_id_; GURL origin_; scoped_refptr<dom_storage::DomStorageMap> map_; scoped_refptr<DomStorageProxy> proxy_; base::WeakPtrFactory<DomStorageCachedArea> weak_factory_; }; } // namespace content #endif // CONTENT_RENDERER_DOM_STORAGE_DOM_STORAGE_CACHED_AREA_H_
[ "1990zhaoshuang@163.com" ]
1990zhaoshuang@163.com
c46a80986cad6fa4c5cd3e49e3a0a96c1cf12661
05d5a62d6fa8349ad9cb6925c75cf5925d477d04
/cuaderno_comunicaciones/windows/runner/main.cpp
8006d4f276a04f7647da66e95e6d5069a1919e70
[]
no_license
AldanaCisnero2/aldanacisnero
aa2cab5b13c87ae8ecd8a358f296b5bb1cbdf9b8
a26e8d80a1aec121df3e4f3f0f94f0cdd0eb7ee1
refs/heads/main
2023-06-15T22:26:49.992433
2021-07-01T18:19:01
2021-07-01T18:19:01
384,558,741
0
0
null
null
null
null
UTF-8
C++
false
false
1,283
cpp
#include <flutter/dart_project.h> #include <flutter/flutter_view_controller.h> #include <windows.h> #include "flutter_window.h" #include "utils.h" int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, _In_ wchar_t *command_line, _In_ int show_command) { // Attach to console when present (e.g., 'flutter run') or create a // new console when running with a debugger. if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { CreateAndAttachConsole(); } // Initialize COM, so that it is available for use in the library and/or // plugins. ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); flutter::DartProject project(L"data"); std::vector<std::string> command_line_arguments = GetCommandLineArguments(); project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); if (!window.CreateAndShow(L"cuaderno_comunicaciones", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); ::MSG msg; while (::GetMessage(&msg, nullptr, 0, 0)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } ::CoUninitialize(); return EXIT_SUCCESS; }
[ "contacto.ezequiel.lopez@gmail.com" ]
contacto.ezequiel.lopez@gmail.com
cc0c43f0603ddbd1684a55ccd119c001769ff84c
dffb1b2a5f9e8e9ee81a005e6f00ba0dfc65dd8f
/2.1.2/2.1.2/源.cpp
1051c2417795c6ddcf7c9daa5584bc01963796e9
[]
no_license
SnailForce/CppPrimer
00c2f59f73075678757abf8dd4792b35a87c034d
9fed047bee49fc8a5a1ee12a5033a5589d97f4f7
refs/heads/master
2022-11-30T02:14:07.382396
2020-07-17T06:08:57
2020-07-17T06:08:57
280,289,632
0
0
null
null
null
null
UTF-8
C++
false
false
286
cpp
#include <iostream> int main() { bool a; for (int i = 1; i <= 100; ++i) { a = i; std::cout << a << " " << std::endl; } unsigned int u1 = 42, u2 = 10; std::cout << u2 - u1 << std::endl; std::cout << "3333\?" "2333" << std::endl; system("pause"); return 0; }
[ "1078374406@qq.com" ]
1078374406@qq.com
7fa9c8dcf054c1ec3af2919aa929f9ee523a2093
358aa0790a4311ddf3659e409284ff7b9ff647c6
/MIPSSimulator/mipsClass.cpp
a3c8117cf8fe8334e251c074bd8f7b9bce79f2f5
[]
no_license
nguyentructien7/Computer-Science-312
acb4ab15e6dce3425045512afbf420a2a9e4a782
60a1aefedb6cb1aeb90096a781f744ad5b1f41c3
refs/heads/master
2020-07-10T20:38:38.430851
2019-08-26T00:27:50
2019-08-26T00:27:50
204,365,783
0
0
null
null
null
null
UTF-8
C++
false
false
16,928
cpp
// Names: Kelsey Nguyen & Maram Almutairi // Project: Mips Simulator // Date: 4-6-2017 // Class: CS312 - Prof. McKenney //function def #include "mipsClass.hpp" #include <iostream> using namespace std; Mips::Mips() { for (int i = 0; i <20; i++) data[i] = 0; instructionAmount = 0; for (int k = 0; k <32; k++) { registers[k] = 0; } PC = PCSTART; previousPC = PCSTART; afterBreak = 0; } bool Mips::ValadOp(int instruction) { if (data[instruction] < 0) return true; else return false; } string Mips::DetermineOperation(int instruction) { int opcode; opcode = (data[instruction] & DEMASKER); if (data[instruction] == NOOP) { return("NOP"); //return noop instruction } opcode = opcode >> 24; if (ValadOp(instruction)) { if (opcode == ADDIOP) { return("ADDI"); } else if (opcode == JOP) { return("J"); } else if (opcode == LWOP) { return("LW"); } else if (opcode == SWOP) { return("SW"); } else if (opcode == BEQOP) { return("BEQ"); } else if (opcode == MULOP) { return("MUL"); } else if (opcode == BLTZOP) { return("BLTZ"); } else { opcode = (data[instruction] & DEMASKER2); if (opcode == ADDOP) { return("ADD"); } else if (opcode == JROP) { return("JR"); } else if (opcode == SUBOP) { return("SUB"); } else if (opcode == SLLOP) { return("SLL"); } else if (opcode == SLROP) { return("SRL"); } else if (opcode == ANDOP) { return("AND"); } else if (opcode == OROP) { return("OR"); } else if (opcode == MOVZOP) { return("MOVZ"); } else if (opcode == BREAKOP) { return("BREAK"); } } } else { return("Invalid Instruction"); } return (0); } void Mips::loadInstructions(int at, int instruction) { data[at] = instruction; } void Mips::SetInstructionAmount(int value) { instructionAmount = value; } void Mips::OutputDis(string outDisFile) { outDisFile.append("_dis.txt"); ofstream disfile; disfile.open(outDisFile); int currentPC = 96; int i = (currentPC - 96) / 4; do { int binary = (data[i]); for (int k = 0; k < 32; k++) { if (k == 0) { if (ValadOp(i)) { disfile << 1; cout << 1; binary = ((binary & DEMASKERPRO) << 1); } else { disfile << 0; cout << 0; binary = ((binary & DEMASKERPRO) << 1); } } else { if ((binary >> 31) == 0xffffffff) { disfile << 1; cout << 1; } else { disfile << (binary >> 31); cout << (binary >> 31); } binary = (binary << 1); } if (k>29) { } else if (k % 5 == 0) { disfile << ' '; cout << ' '; } } disfile << "\t" << currentPC << "\t" << DetermineOperation(i); cout << "\t" << currentPC << "\t" << DetermineOperation(i); findDestinationLocation(i, disfile); disfile << endl; cout << endl; currentPC = currentPC + 4; i = (currentPC - 96) / 4; } while (DetermineOperation((currentPC - 96 - 4) / 4) != "BREAK"); for (i; i < instructionAmount; i++) { int binary = (data[i]); for (int k = 0; k < 32; k++) { if ((binary >> 31) == 0xffffffff) { disfile << 1; cout << 1; } else { disfile << (binary >> 31); cout << (binary >> 31); } binary = (binary << 1); } disfile << "\t" << currentPC << "\t" << dec << (data[i]) << endl; cout << "\t" << currentPC << "\t" << dec << (data[i]) << endl; currentPC = currentPC + 4; } disfile.close(); } void Mips::DetermineOperationCal(int instruction) { int opcode; opcode = (data[instruction] & DEMASKER); if ((data[instruction] == NOOP) || !ValadOp(instruction)) { NOOPaction(); return; //return noop instruction } opcode = opcode >> 24; if (ValadOp(instruction)) { if (opcode == ADDIOP) { ADDI(instruction); } else if (opcode == JOP) { Jump(instruction); } else if (opcode == LWOP) { LW(instruction); } else if (opcode == SWOP) { SW(instruction); } else if (opcode == BEQOP) { BEQ(instruction); } else if (opcode == MULOP) { MUL(instruction); } else if (opcode == BLTZOP) { BLTZ(instruction); } else { opcode = (data[instruction] & DEMASKER2); if (opcode == ADDOP) { ADD(instruction); } else if (opcode == JROP) { JR(instruction); } else if (opcode == SUBOP) { SUB(instruction); } else if (opcode == SLLOP) { SLL(instruction); } else if (opcode == SLROP) { SLR(instruction); } else if (opcode == ANDOP) { AND(instruction); } else if (opcode == OROP) { OR(instruction); } else if (opcode == MOVZOP) { MOVZ(instruction); } else if (opcode == BREAKOP) { NOOPaction(); } } } } void Mips::ComputeInstructions(string file) { file.append("_sim.txt"); ofstream simfile; simfile.open(file); int i = (PC - 96) / 4; int cycleNumber = 1; do { if (ValadOp(i)) { DetermineOperationCal(i); OutputSim(i, cycleNumber, simfile); cycleNumber++; } else { PC = PC + 4; } i = (PC - 96) / 4; } while (DetermineOperation((PC - 96 - 4) / 4) != "BREAK"); simfile.close(); } void Mips::OutputSim(int instruction, int cycle, ofstream& simfile) { int value = afterBreak; int valueOfdataPC; simfile << "====================" << endl; simfile << "cycle:" << cycle << "\t" << previousPC << "\t" << DetermineOperation(instruction); cout << "====================" << endl; cout << "cycle:" << cycle << "\t" << previousPC << "\t" << DetermineOperation(instruction); findDestinationLocation(instruction, simfile); simfile << endl << endl << "registers:" << endl << "r00:"; cout << endl << endl << "registers:" << endl << "r00:"; for (int k = 0; k <8; k++) { simfile << "\t" << registers[k]; cout << "\t" << registers[k]; } simfile << endl << "r08:"; cout << endl << "r08:"; for (int k = 8; k<16; k++) { simfile << "\t" << registers[k]; cout << "\t" << registers[k]; } simfile << endl << "r16:"; cout << endl << "r16:"; for (int k = 16; k<24; k++) { simfile << "\t" << registers[k]; cout << "\t" << registers[k]; } simfile << endl << "r24:"; cout << endl << "r24:"; for (int k = 24; k<32; k++) { simfile << "\t" << registers[k]; cout << "\t" << registers[k]; } simfile << endl << endl << "data:" << endl; cout << endl << endl << "data:" << endl; for (value; value < instructionAmount; (value++)) { valueOfdataPC = value * 4 + 96; simfile << valueOfdataPC << ':'; cout << valueOfdataPC << ':'; int q = 0; int temp = value; while ((q < 8) && ((q + value) < instructionAmount)) { simfile << "\t" << data[value + q]; cout << "\t" << data[value + q]; q++; } simfile << endl; cout << endl; value = value + 7; } simfile << endl; cout << endl; } //finds where the break point will occur in the instruction set //this aids in outputing items to the screen that are in "memory" void Mips::findAfterBreak() { int fakePc = 96; while (DetermineOperation((fakePc - 96) / 4) != "BREAK") { fakePc = fakePc + 4; } afterBreak = (fakePc - 96 + 4) / 4; } void Mips::findDestinationLocation(int instruction, ofstream& outfile) { string word = DetermineOperation(instruction); if ((word == "LW") || (word == "SW")) outputLoad(instruction, outfile); else if ((word == "SLL") || (word == "SRL")) outputRdRtSa(instruction, outfile); else if ((word == "BEQ") || (word == "BLTZ")) outputBranch(instruction, outfile); else if (word == "ADDI") outputAddi(instruction, outfile); else if (word == "J") outputJ(instruction, outfile); else if (word == "JR") outputJR(instruction, outfile); else if ((word == "MOVZ") || (word == "ADD") || (word == "MUL") || (word == "SUB") || (word == "AND") || (word == "OR")) outputRdRSRT(instruction, outfile); } //to show values in the instructions void Mips::outputRdRSRT(int instruction, ofstream& outfile) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; cout << "\tR" << rd << ", R" << rs << ", R" << rt; outfile << "\tR" << rd << ", R" << rs << ", R" << rt; } void Mips::outputRdRtSa(int instruction, ofstream &outfile) { int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; int sa = (data[instruction] & DEMASKSA) >> 6; cout << "\tR" << rd << ", R" << rt << ", #" << sa; outfile << "\tR" << rd << ", R" << rt << ", #" << sa; } void Mips::outputAddi(int instruction, ofstream &outfile) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int neg = (data[instruction] & 0x00008000); int Im = (data[instruction] & DEMASKIM); if (neg == 0x00008000) Im = Im | 0xFFFF0000; cout << "\tR" << rt << ", R" << rs << ", #" << Im; outfile << "\tR" << rt << ", R" << rs << ", #" << Im; } void Mips::outputJ(int instruction, ofstream &outfile) { int value = (data[instruction] & DEMASKJ) << 2; cout << "\t#" << value; outfile << "\t#" << value; } void Mips::outputJR(int instruction, ofstream &outfile) { int rs = (data[instruction] & DEMASKRS) >> 21; cout << "\tR" << rs; outfile << "\tR" << rs; } void Mips::outputBranch(int instruction, ofstream &outfile) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int ofset = (data[instruction] & DEMASKIM) << 2; if (DetermineOperation(instruction) == "BEQ") { cout << "\tR" << rs << ", R" << rt << ", #" << ofset; outfile << "\tR" << rs << ", R" << rt << ", #" << ofset; } else { cout << "\tR" << rs << ", #" << ofset; outfile << "\tR" << rs << ", #" << ofset; } } void Mips::outputLoad(int instruction, ofstream &outfile) { int base = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int ofset = (data[instruction] & DEMASKIM); cout << "\tR" << rt << ", " << ofset << "(R" << base << ')'; outfile << "\tR" << rt << ", " << ofset << "(R" << base << ')'; } //start of calulatory stuff void Mips::ADD(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; registers[rd] = registers[rs] + registers[rt]; previousPC = PC; PC = PC + 4; } void Mips::ADDI(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int neg = (data[instruction] & 0x00008000); int Im = (data[instruction] & DEMASKIM); if (neg == 0x00008000) Im = Im | 0xFFFF0000; registers[rt] = registers[rs] + Im; previousPC = PC; PC = PC + 4; } void Mips::AND(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; registers[rd] = registers[rs] & registers[rt]; previousPC = PC; PC = PC + 4; } //had an issue here but after looking up code saw you didn't do delay continued //after see that made it much easier for BEQ/BLTZ void Mips::BEQ(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int ofset = (data[instruction] & DEMASKIM) << 2; previousPC = PC; if (registers[rs] == registers[rt]) PC = PC + ofset; PC = PC + 4; } void Mips::BLTZ(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int ofset = (data[instruction] & DEMASKIM) << 2; previousPC = PC; if (registers[rs] < 0) PC = PC + ofset; PC = PC + 4; } void Mips::Jump(int instruction) { int value = (data[instruction] & DEMASKJ) << 2; previousPC = PC; PC = value; } void Mips::JR(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; previousPC = PC; PC = registers[rs]; } void Mips::LW(int instruction) { int base = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int ofset = (data[instruction] & DEMASKIM); registers[rt] = data[(((ofset + registers[base]) - 96) / 4)]; previousPC = PC; PC = PC + 4; } void Mips::SW(int instruction) { int base = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int ofset = (data[instruction] & DEMASKIM); data[(((ofset + registers[base]) - 96) / 4)] = registers[rt]; previousPC = PC; PC = PC + 4; } void Mips::SUB(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; registers[rd] = registers[rs] - registers[rt]; previousPC = PC; PC = PC + 4; } void Mips::MUL(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; registers[rd] = registers[rs] * registers[rt]; previousPC = PC; PC = PC + 4; } void Mips::MOVZ(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; if (registers[rt] == 0) registers[rd] = registers[rs]; previousPC = PC; PC = PC + 4; } void Mips::OR(int instruction) { int rs = (data[instruction] & DEMASKRS) >> 21; int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; registers[rd] = registers[rs] | registers[rt]; previousPC = PC; PC = PC + 4; } void Mips::SLL(int instruction) { int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; int sa = (data[instruction] & DEMASKSA) >> 6; registers[rd] = registers[rt] << sa; previousPC = PC; PC = PC + 4; } void Mips::SLR(int instruction) { int rt = (data[instruction] & DEMASKRT) >> 16; int rd = (data[instruction] & DEMASKRD) >> 11; int sa = (data[instruction] & DEMASKSA) >> 6; registers[rd] = registers[rt] >> sa; previousPC = PC; PC = PC + 4; } void Mips::NOOPaction() { previousPC = PC; PC = PC + 4; }
[ "noreply@github.com" ]
noreply@github.com
cefcac4a7ec39f050323cfc5319a1d888cca3e63
68032b48023e9daff30e446fee2f83886cf66d57
/C++项目/02/源程序/OftenNotedlg.cpp
d11145d3172889d180c27f1d04e3b34f26c767c7
[]
no_license
std2312/C-PLUS-PLUS
c77c1bb7fe60fd39bc4d576300d6817e543b27bd
5a51b124a3c7073b80579ff3b1ad79cacb85b657
refs/heads/master
2021-05-11T04:49:15.667040
2018-01-18T08:03:44
2018-01-18T08:03:44
117,946,728
1
0
null
null
null
null
GB18030
C++
false
false
4,763
cpp
// OftenNotedlg.cpp : implementation file // #include "stdafx.h" #include "NoteManage.h" #include "OftenNotedlg.h" #include "ADOConn.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // COftenNotedlg dialog COftenNotedlg::COftenNotedlg(CWnd* pParent /*=NULL*/) : CDialog(COftenNotedlg::IDD, pParent) { //{{AFX_DATA_INIT(COftenNotedlg) m_Note = _T(""); //}}AFX_DATA_INIT } void COftenNotedlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(COftenNotedlg) DDX_Control(pDX, IDC_BUTDEL, m_ButDel); DDX_Control(pDX, IDC_BUTMOD, m_ButMod); DDX_Control(pDX, IDC_BUTADD, m_ButAdd); DDX_Control(pDX, IDC_LIST1, m_Grid); DDX_Text(pDX, IDC_EDIT1, m_Note); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(COftenNotedlg, CDialog) //{{AFX_MSG_MAP(COftenNotedlg) ON_BN_CLICKED(IDC_BUTADD, OnButadd) ON_BN_CLICKED(IDC_BUTMOD, OnButmod) ON_BN_CLICKED(IDC_BUTDEL, OnButdel) ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // COftenNotedlg message handlers void COftenNotedlg::OnButadd() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(m_Note.IsEmpty()) { MessageBox("常用短语不能为空!"); return; } ADOConn m_ADOConn; m_ADOConn.OnInitADOConn(); CString sql; sql.Format("insert into tb_note (常用短语) values ('%s')",m_Note); m_ADOConn.ExecuteSQL((_bstr_t)sql); m_ADOConn.ExitConnect(); m_Grid.DeleteAllItems(); AddToGrid(); m_Note = ""; UpdateData(FALSE); } void COftenNotedlg::OnButmod() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(m_ID<0) { MessageBox("请在列表中选择常用短语!"); return; } ADOConn m_ADOConn; m_ADOConn.OnInitADOConn(); CString sql; sql.Format("update tb_note set 常用短语='%s' where 编号=%d",m_Note,m_ID); m_ADOConn.ExecuteSQL((_bstr_t)sql); m_ADOConn.ExitConnect(); m_Grid.DeleteAllItems(); AddToGrid(); m_ID = -1; } void COftenNotedlg::OnButdel() { // TODO: Add your control notification handler code here if(m_ID < 0) { MessageBox("请在列表中选择常用短语!"); return; } ADOConn m_ADOConn; m_ADOConn.OnInitADOConn(); CString sql; sql.Format("delete from tb_note where 编号=%d",m_ID); m_ADOConn.ExecuteSQL((_bstr_t)sql); m_ADOConn.ExitConnect(); m_Grid.DeleteAllItems(); AddToGrid(); m_ID = -1; } BOOL COftenNotedlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here //设置列表视图的扩展风格 m_Grid.SetExtendedStyle(LVS_EX_FLATSB |LVS_EX_FULLROWSELECT |LVS_EX_HEADERDRAGDROP |LVS_EX_ONECLICKACTIVATE |LVS_EX_GRIDLINES); m_Grid.InsertColumn(0,"编号",LVCFMT_LEFT,70,0); //设置表头 m_Grid.InsertColumn(1,"常用短语",LVCFMT_LEFT,330,1); AddToGrid(); m_ID = -1; m_ButAdd.SetBitmap(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BUTADD1))); //设置位图 m_ButAdd.SetHBitmap(LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BUTADD2)), LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BUTADD1))); m_ButMod.SetBitmap(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BUTMOD1))); //设置位图 m_ButMod.SetHBitmap(LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BUTMOD2)), LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BUTMOD1))); m_ButDel.SetBitmap(LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BUTDEL1))); //设置位图 m_ButDel.SetHBitmap(LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BUTDEL2)), LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BUTDEL1))); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void COftenNotedlg::AddToGrid() { ADOConn m_ADOConn; m_ADOConn.OnInitADOConn(); CString sql; int i = 0; sql.Format("select * from tb_note"); m_ADOConn.m_pRecordset = m_ADOConn.GetRecordSet((_bstr_t)sql); while(!m_ADOConn.m_pRecordset->adoEOF) { m_Grid.InsertItem(i,""); m_Grid.SetItemText(i,0,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("编号")); m_Grid.SetItemText(i,1,(char*)(_bstr_t)m_ADOConn.m_pRecordset->GetCollect("常用短语")); m_ADOConn.m_pRecordset->MoveNext(); i++; } m_ADOConn.ExitConnect(); } void COftenNotedlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here int pos = m_Grid.GetSelectionMark(); m_ID = atoi(m_Grid.GetItemText(pos,0)); m_Note = m_Grid.GetItemText(pos,1); UpdateData(FALSE); *pResult = 0; } void COftenNotedlg::OnOK() { }
[ "std2312@126.com" ]
std2312@126.com