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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
48b2f112e8c37a92b2f743b3c3b0430adfb008c8 | a58e629a5a1844a7771e02dec2af14dc76f13dcc | /ConsoleApplication2/ConsoleApplication2/ConsoleApplication2.cpp | ca73c5620918123daba9012b079e9d9f66f4125b | [] | no_license | ZmiyGreen/NamelessConsoleFiles | a95abe4445fc91c1ed161422b5c79dccdde4be51 | 32b715eb9fea1249e095c7499ca415e1fe10f064 | refs/heads/master | 2020-04-24T11:56:44.326510 | 2019-02-21T21:38:15 | 2019-02-21T21:38:15 | 171,941,942 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,083 | cpp | #include "pch.h"
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include "windows.h"
class Person
{
private:
std::string Name;
std::array<double, 5> Results;
double SumResult;
public:
Person(std::string N, std::initializer_list<double> L) : Name(N)
{
int index = 0;
for (double i : L)
{
Results[index++] = i;
std::cout << Results[index - 1] << " ";
}
int imin = 0;
int imax = 0;
for (int i = 1; i < Results.size(); i++)
{
if (Results[i] > Results[imax])
imax = i;
if (Results[i] < Results[imin])
imin = i;
}
for (int i = 0; i < Results.size(); i++)
if (i != imax && i != imin)
SumResult += Results[i];
}
void Print()
{
std::cout << "Имя: " << Name << " Суммарный результат: " << SumResult << " Результаты попыток: ";
for (auto i : Results)
std::cout << i << " ";
std::cout << std::endl;
}
};
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
Person P("Иванов", { 7,4,2,0,4 });
P.Print();
std::cout << "Привет мир!\n";
} | [
"zmiy1900@yandex.ru"
] | zmiy1900@yandex.ru |
e704a04ef6d2c1da1b8657bcefab27ce6f8e0a57 | 46bb942866601c28ba6253e15f82e7da60169008 | /CarTrainerAll/CarTrainer Learning alghorythm/CarTrainer/NeuralNetwork2.h | ce9d1eb5130caf9fdd1e530de34a9cff579b55b0 | [] | no_license | LeonidMurashov/VS_Projects | 471c78c4b1f5d0328ddc29525cfb6a4f6eabb158 | dcf73339f0419cdaf1a040c9f41d1a8dfe12e5f2 | refs/heads/master | 2020-07-26T03:59:53.613736 | 2017-04-27T06:13:29 | 2017-04-27T06:13:29 | 73,639,926 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,437 | h |
/*
*
* Author: Leonid Murashov 30.05.2016
*
* Neural network consists of classes(network, layer and neuron),
* All neurons have connetions with all neurons of previous layer,
* Several transfer functions,
* Standart deviation random generator(Gaussian),
* Merge networks method with passed to merge functions as parameters,
* Save to and load from XML files methods
*
*/
#pragma once
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string>
#include <vector>
#include "tinyxml2.h"
//using namespace std;
//using namespace tinyxml2;
namespace NeuralNetworkLibrary2
{
//#define Length(a) (sizeof(a) / sizeof(a[0])) // Returns the length of the array (!!! only for static !!!)
#define randDouble() ((double)(rand() / (double)RAND_MAX)) // Returns a random double from 0 to 1
#define NORMAL_HIDDEN_LAYER_SIZE 7
#define NORMAL_HIDDEN_LAYERS_COUNT 1
#define TRANSFER_FUNCTIONS_COUNT 5
#pragma region Transfer functions and their derivative
enum TransferFunction
{
None,
Linear,
Sigmoid,
Gaussian,
RationalSigmoid
};
class TransferFunctions
{
public:
static double Evaluate(TransferFunction tFunc, double input)
{
switch (tFunc)
{
case TransferFunction::Sigmoid:
return sigmoid(input);
case TransferFunction::Linear:
return linear(input);
case TransferFunction::Gaussian:
return gaussian(input);
case TransferFunction::RationalSigmoid:
return rationalsigmoid(input);
case TransferFunction::None:
default:
return 0.0;
}
}
static double EvaluateDerivative(TransferFunction tFunc, double input)
{
switch (tFunc)
{
case TransferFunction::Sigmoid:
return sigmoid_derivative(input);
case TransferFunction::Linear:
return linear_derivative(input);
case TransferFunction::Gaussian:
return gaussian_derivative(input);
case TransferFunction::RationalSigmoid:
return rationalsigmoid_derivative(input);
case TransferFunction::None:
default:
return 0.0;
}
}
/* Transfer functions declaration*/
private:
static double sigmoid(double x)
{
return 1.0 / (1.0 + exp(-x));
}
static double sigmoid_derivative(double x)
{
return sigmoid(x) * (1 - sigmoid(x));
}
static double linear(double x)
{
return x;
}
static double linear_derivative(double x)
{
return 1;
}
static double gaussian(double x)
{
return exp(-pow(x, 2));
}
static double gaussian_derivative(double x)
{
return -2.0 * x * gaussian(x);
}
static double rationalsigmoid(double x)
{
return x / (1.0 + sqrt(1.0 + x * x));
}
static double rationalsigmoid_derivative(double x)
{
double val = sqrt(1.0 + x * x);
return 1.0 / (val * (1 + val));
}
};
#pragma endregion
class Gaussian
{
public:
static double GetRandomGaussian()
{
return GetRandomGaussian(0.0, 1.0);
}
static double GetRandomGaussian(double mean, double stddev)
{
double rVal1, rVal2;
GetRandomGaussian(mean, stddev, rVal1, rVal2);
return rVal1;
}
static void GetRandomGaussian(double mean, double stddev, double &val1, double &val2)
{
double u, v, s, t;
do
{
u = 2 * randDouble() - 1;
v = 2 * randDouble() - 1;
} while (u * u + v * v > 1 || (u == 0 && v == 0));
s = u * u + v * v;
t = sqrt((-2.0 * log(s)) / s);
val1 = stddev * u * t + mean;
val2 = stddev * v * t + mean;
}
};
enum LayerPosition { INPUT_LAYER, HIDDEN_LAYER, OUTPUT_LAYER };
/*Some defines for MergeFunctions*/
// Merge weights and biases
typedef double(*Merge1)(double a, double b);
// Merge layers and neurons count
typedef int(*Merge2)(int a, int b);
// Merge TransferFunctions
typedef TransferFunction(*Merge3)(TransferFunction a, TransferFunction b);
#pragma region Neuron class
class Neuron
{
private:
double output;
// For input layers(is not used by hidden and output layers)
double inputData;
// For hidden and output layers(is not used by input layers)
std::vector<double> weights;
double bias;
public:
// Default constructor
Neuron(TransferFunction transferFunction, std::vector<Neuron *>previousLayerNeurons)
{
if (transferFunction != TransferFunction::None) // If neuron is not on input
{
for (int i = 0; i < previousLayerNeurons.size(); i++)
weights.push_back(Gaussian::GetRandomGaussian());
bias = Gaussian::GetRandomGaussian();
}
}
// Merge constructor
Neuron(std::vector<double> _weights, double _bias)
{
weights = _weights;
bias = _bias;
}
void Run(TransferFunction transferFunction, std::vector<Neuron *>previousLayerNeurons)
{
if (transferFunction != TransferFunction::None) // If neuron is not on input
{
double sum = 0;
for (int i = 0; i < previousLayerNeurons.size(); i++)
sum += weights[i] * previousLayerNeurons[i]->GetOutput();
output = TransferFunctions::Evaluate(transferFunction, sum + bias);
}
else
output = inputData;
}
double GetOutput() { return output; }
void SetInputData(double _inputData) { inputData = _inputData; }
private:
static void CastWeights(std::vector<double> &a, int previousLayerSize)
{
while (a.size() < previousLayerSize)
a.push_back(Gaussian::GetRandomGaussian());
if (a.size() > previousLayerSize)
a.resize(previousLayerSize);
}
public:
// MergeFunction() is situated in [GeneticEngine] source file
// Cannot be used to create input neuron
static Neuron* MergeNeurons(Neuron* neuron1, Neuron* neuron2, int previousLayerSize, TransferFunction transferFunction, Merge1 MergeFunction)
{
if (transferFunction == TransferFunction::None)
throw("MergeNeurons function cannot be used to create input neuron");
std::vector<double> weights1, weights2, finalWeights;
double bias1, bias2, finalBias;
// Getting data from neurons 1 and 2
neuron1->GetInvolvedData(weights1, bias1);
neuron2->GetInvolvedData(weights2, bias2);
//Casting weights to be the same demention
CastWeights(weights1, previousLayerSize);
CastWeights(weights2, previousLayerSize);
// Merging data
for (int i = 0; i < previousLayerSize; i++)
finalWeights.push_back((*MergeFunction)(weights1[i], weights2[i]));
finalBias = (*MergeFunction)(bias1, bias2);
return new Neuron(finalWeights, finalBias);
}
void GetInvolvedData(std::vector<double> &_weights, double &_bias)
{
_weights = weights;
_bias = bias;
}
~Neuron()
{
weights.clear();
}
};
#pragma endregion
class Layer
{
public:
std::vector<Neuron*> neurons;
TransferFunction transferFunction;
Layer* previousLayer;
// Default constructor
Layer(int size, TransferFunction _transferFunction, Layer *_previousLayer)
{
if (size == 0)
throw("Layer cannot be empty");
if (_transferFunction == TransferFunction::None && _previousLayer || !_transferFunction == TransferFunction::None && !_previousLayer)
throw("Only input layer can have None TransferFunction");
transferFunction = _transferFunction;
previousLayer = _previousLayer;
// Create neurons
for (int i = 0; i < size; i++)
neurons.push_back(new Neuron(transferFunction, (previousLayer) ? previousLayer->neurons : std::vector<Neuron*>()));
}
// Merge constructor
Layer(std::vector<Neuron*> _neurons, TransferFunction _transferFunction, Layer *_previousLayer)
{
if (_neurons.size() == 0)
throw("Layer cannot be empty");
if (_transferFunction == TransferFunction::None && !_previousLayer)
throw("Only input layer can have None TransferFunction");
neurons = _neurons;
transferFunction = _transferFunction;
previousLayer = _previousLayer;
}
void Run()
{
for (int i = 0; i < neurons.size(); i++)
neurons[i]->Run(transferFunction, (previousLayer) ? previousLayer->neurons : std::vector<Neuron*>());
}
// MergeFunction() is situated in [GeneticEngine] source file
// Layer* previosActualLayer is needed for creating layer, but if
// layer is on input can be NULL
static Layer* MergeLayers(Layer* lay1, Layer* lay2, Layer* previosActualLayer, LayerPosition layerPosition,
Merge1 MergeFunction, Merge2 MergeFunctionInt,
Merge3 MergeFunctionTransfer)
{
std::vector<Neuron*> _neurons;
TransferFunction _transferFunction = (*MergeFunctionTransfer)(lay1->transferFunction, lay2->transferFunction);
int size;
// Set demention of layer
if (layerPosition == LayerPosition::HIDDEN_LAYER)
size = (*MergeFunctionInt)((int)lay1->neurons.size(), (int)lay2->neurons.size());
else
size = (int)lay1->neurons.size();
// Neurons will be merged and set later
Layer *finalLayer = new Layer(0, _transferFunction, previosActualLayer);
// Actions for not input layer
if (previosActualLayer != NULL)
{
CastLayer(lay1, size);
CastLayer(lay2, size);
for (int i = 0; i < size; i++)
_neurons.push_back(Neuron::MergeNeurons(lay1->neurons[i], lay2->neurons[i], (int)previosActualLayer->neurons.size(), _transferFunction, MergeFunction));
}
else // Actions in case of input layer
{
for (int i = 0; i < size; i++)
_neurons.push_back(new Neuron(_transferFunction, previosActualLayer->neurons));
}
finalLayer->neurons = _neurons;
return finalLayer;
}
static Layer* GetRandomLayer(Layer* _previousLayer)
{
int size;
do
{
size = (int)round(Gaussian::GetRandomGaussian(NORMAL_HIDDEN_LAYER_SIZE, (double)NORMAL_HIDDEN_LAYER_SIZE / (double)2));
} while (size < 1);
return new Layer(size, TransferFunction(rand() % (TRANSFER_FUNCTIONS_COUNT - 2) + 2), _previousLayer);
}
~Layer()
{
neurons.clear();
}
private:
static void CastLayer(Layer * lay, int size)
{
while (lay->neurons.size() < size)
lay->neurons.push_back(new Neuron(lay->transferFunction, lay->previousLayer->neurons));
if (lay->neurons.size() > size)
lay->neurons.resize(size);
}
};
class NeuralNetwork
{
std::vector<Layer*> layers;
public:
// Default constructor
NeuralNetwork(std::vector<int> layerSizes, std::vector <TransferFunction> transferFunctions)
{
// Validate the input data
if (transferFunctions.size() != layerSizes.size() || transferFunctions[0] != TransferFunction::None)
throw ("Cannot construct a network with these parameters");
// Create layers
for (int i = 0; i < layerSizes.size(); i++)
layers.push_back(new Layer(layerSizes[i], transferFunctions[i], i == 0 ? NULL : layers[i - 1]));
}
// Merge constructor
NeuralNetwork(std::vector<Layer*> _layers)
{
// Validate the input data
if (_layers.size() < 2)
throw ("Cannot construct a network with these parameters");
// Set layers
layers = _layers;
}
std::vector<double> Run(std::vector<double> input)
{
// Make sure we have enough data
if (input.size() != layers[0]->neurons.size())
throw ("Input data is not of the correct dimention.");
for (int i = 0; i < layers[0]->neurons.size(); i++)
layers[0]->neurons[i]->SetInputData(input[i]);
// Calculating the result
for (int i = 0; i < layers.size(); i++)
layers[i]->Run();
// Pushing the result to std::vector
std::vector<double> output;
for (int i = 0; i < layers[layers.size() - 1]->neurons.size(); i++)
output.push_back(layers[layers.size() - 1]->neurons[i]->GetOutput());
return output;
}
std::vector<Layer*> GetLayers() { return layers; }
private:
static void CastNetworkLayers(std::vector<Layer*> &a, int size)
{
if (size < 2)
throw("Casting network layers failed");
Layer* outputLayer = a[a.size() - 1];
a.pop_back();
while (a.size() < size - 1)
a.push_back(Layer::GetRandomLayer(a[a.size() - 1]));
if (a.size() > size - 1)
a.resize(size - 1);
a.push_back(outputLayer);
}
public:
// MergeFunction() is situated in [GeneticEngine] source file
static NeuralNetwork* MergeNetworks(NeuralNetwork* net1, NeuralNetwork* net2,
Merge1 MergeFunction, Merge2 MergeFunctionInt,
Merge3 MergeFunctionTransfer)
{
if (!MergeFunction || !MergeFunctionInt || !MergeFunctionTransfer)
throw ("NULL MergeFuction recieved");
std::vector<Layer*> layers1 = net1->GetLayers(),
layers2 = net2->GetLayers(),
finalLayers;
int size = (*MergeFunctionInt)((int)layers1.size(), (int)layers2.size());
// Casting layers to be the same demention
CastNetworkLayers(layers1, size);
CastNetworkLayers(layers2, size);
for (int i = 0; i < size; i++)
{
LayerPosition layerPosition;
if (i == 0) layerPosition = LayerPosition::INPUT_LAYER;
else if (i == size - 1) layerPosition = LayerPosition::OUTPUT_LAYER;
else layerPosition = LayerPosition::HIDDEN_LAYER;
finalLayers.push_back(Layer::MergeLayers(layers1[i], layers2[i], i == 0 ? NULL : finalLayers[i - 1], layerPosition,
MergeFunction, MergeFunctionInt, MergeFunctionTransfer));
}
return new NeuralNetwork(finalLayers);
}
static NeuralNetwork* GetRandomNetwork(int inputsCount, int outputsCount)
{
std::vector<Layer*> _layers;
_layers.push_back(new Layer(inputsCount, TransferFunction::None, NULL));
int size;
do
{
size = (int)round(Gaussian::GetRandomGaussian(NORMAL_HIDDEN_LAYERS_COUNT, (double)NORMAL_HIDDEN_LAYERS_COUNT / (double)2));
} while (size < 0);
for (int i = 0; i < size; i++)
_layers.push_back(Layer::GetRandomLayer(_layers[_layers.size() - 1]));
_layers.push_back(new Layer(outputsCount, TransferFunction::Linear, _layers[_layers.size() - 1]));
return new NeuralNetwork(_layers);
}
#define XMLCheckResult(a_eResult) if (a_eResult != tinyxml2::XML_SUCCESS) { return nullptr; }
#define XMLCheckResultForNull(a_eResult) if(!a_eResult) { return nullptr; }
/*
Return a Neural Network created according to file
*/
static NeuralNetwork* LoadFromFile(const char* str)
{
std::vector<Layer*> layers;
tinyxml2::XMLDocument xmlDoc;
XMLCheckResult(xmlDoc.LoadFile(str));
tinyxml2::XMLNode * pRoot = xmlDoc.FirstChild();
XMLCheckResultForNull(pRoot);
tinyxml2::XMLElement * layElement = pRoot->FirstChildElement("Layer");
XMLCheckResultForNull(layElement);
int size;
XMLCheckResult(layElement->QueryIntAttribute("size", &size));
layers.push_back(new Layer(size, TransferFunction::None, NULL));
layElement = layElement->NextSiblingElement();
while (layElement)
{
std::vector<Neuron*> neurons;
TransferFunction transferFunction;
layElement->QueryAttribute("transferFunction", (int*)&transferFunction);
XMLCheckResultForNull(transferFunction);
tinyxml2::XMLElement *neuronElement = layElement->FirstChildElement("Neuron");
XMLCheckResultForNull(neuronElement);
while (neuronElement)
{
double bias;
std::vector<double> weights;
tinyxml2::XMLElement *paramElement = neuronElement->FirstChildElement("Bias");
XMLCheckResultForNull(paramElement);
XMLCheckResult(paramElement->QueryDoubleText(&bias));
paramElement = neuronElement->LastChildElement("Weights");
XMLCheckResultForNull(paramElement);
tinyxml2::XMLElement *weightElement = paramElement->FirstChildElement("Weight");
XMLCheckResultForNull(weightElement);
while (weightElement)
{
double weight;
XMLCheckResult(weightElement->QueryDoubleText(&weight));
weights.push_back(weight);
weightElement = weightElement->NextSiblingElement("Weight");
}
neurons.push_back(new Neuron(weights, bias));
neuronElement = neuronElement->NextSiblingElement();
}
layers.push_back(new Layer(neurons, transferFunction, layers[layers.size()-1]));
layElement = layElement->NextSiblingElement();
}
try {
return new NeuralNetwork(layers);
}
catch (...) {
return nullptr;
}
}
#undef XMLCheckResult
#define XMLCheckResult(a_eResult) if (a_eResult != tinyxml2::XML_SUCCESS) { return false; }
/*
Save Network to XML file
*/
bool SaveToFile(const char* str)
{
tinyxml2::XMLDocument xmlDoc;
XMLCheckResult(xmlDoc.SaveFile(str));
tinyxml2::XMLNode * pRoot = xmlDoc.NewElement("NeuralNetwork");
xmlDoc.InsertFirstChild(pRoot);
tinyxml2::XMLElement * layElement = xmlDoc.NewElement("Layer");
layElement->SetAttribute("type", "input");
layElement->SetAttribute("transferFunction", TransferFunction::None);
layElement->SetAttribute("size", (int)layers[0]->neurons.size());
pRoot->InsertFirstChild(layElement);
for (int i = 1; i < layers.size(); i++)
{
layElement = xmlDoc.NewElement("Layer");
if(i != layers.size() - 1)
layElement->SetAttribute("type", "hidden");
else
layElement->SetAttribute("type", "output");
layElement->SetAttribute("transferFunction", layers[i]->transferFunction);
for (auto neuron : layers[i]->neurons)
{
tinyxml2::XMLElement * neuronElement = xmlDoc.NewElement("Neuron");
std::vector<double> weights;
double bias;
neuron->GetInvolvedData(weights, bias);
tinyxml2::XMLElement * weightsElement = xmlDoc.NewElement("Weights");
for (int j = -1; j < (int)weights.size(); j++)
{
tinyxml2::XMLElement * paramElement;
if (j == -1)
{
paramElement = xmlDoc.NewElement("Bias");
paramElement->SetText(bias);
neuronElement->InsertFirstChild(paramElement);
}
else
{
paramElement = xmlDoc.NewElement("Weight");
paramElement->SetText(weights[j]);
weightsElement->InsertEndChild(paramElement);
}
}
neuronElement->InsertEndChild(weightsElement);
layElement->InsertEndChild(neuronElement);
}
pRoot->InsertEndChild(layElement);
}
xmlDoc.InsertEndChild(pRoot);
XMLCheckResult(xmlDoc.SaveFile(str));
return true;
}
~NeuralNetwork()
{
layers.clear();
}
};
} | [
"="
] | = |
be8fd9980849c4b8713ef634de3900f2f68cdc86 | 90d39aa2f36783b89a17e0687980b1139b6c71ce | /Codechef/aug14cook/PERMSUFF.cpp | a8842a3eeaa43491874491539db738277ec4052f | [] | no_license | nims11/coding | 634983b21ad98694ef9badf56ec8dfc950f33539 | 390d64aff1f0149e740629c64e1d00cd5fb59042 | refs/heads/master | 2021-03-22T08:15:29.770903 | 2018-05-28T23:27:37 | 2018-05-28T23:27:37 | 247,346,971 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,440 | cpp | /*
Nimesh Ghelani (nims11)
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<string>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<stack>
#include<set>
#include<utility>
#define in_T int t;for(scanf("%d",&t);t--;)
#define in_I(a) scanf("%d",&a)
#define in_F(a) scanf("%lf",&a)
#define in_L(a) scanf("%lld",&a)
#define in_S(a) scanf("%s",a)
#define newline printf("\n")
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
#define SWAP(a,b) {int tmp=a;a=b;b=tmp;}
#define P_I(a) printf("%d",a)
using namespace std;
int arr[100001];
int visited[100001][2];
int foo[100001];
int main()
{
in_T{
int n, m;
in_I(n);in_I(m);
for(int i = 0;i<n;i++)
in_I(arr[i+1]), foo[i+1] = 0, visited[i][0] = visited[i][1] =0;
for(int i = 0;i<m;i++){
int x, y;
in_I(x);in_I(y);
visited[x][0]++;
visited[y][1]++;
}
int cnt = 0;
int cur = 0;
for(int i = 1;i<=n;i++){
cur += visited[i][0];
foo[i] = cnt;
cur -= visited[i][1];
if(cur == 0)
cnt++;
}
bool flag = true;
for(int i = 1;i<=n;i++){
if(foo[i] != foo[arr[i]])
flag = false;
}
cout<<(flag?"Possible":"Impossible")<<endl;
}
}
| [
"nimeshghelani@gmail.com"
] | nimeshghelani@gmail.com |
e3cd539c2411063fc9aa8abbb0580fff34f05b74 | 4f00d16d1fe7d214a5c8a0f9cdda5613f83e9500 | /src/gui/Regard3DDensificationDialog.h | 6f09ba16aea4d6a8e6fde21a3febc4abec514792 | [
"MIT"
] | permissive | nanhaishiyounan/Regard3D | e7fb32db5e4ca4197f74e8e1a3e5c015656b562d | 2822275259e9ca140b77b89c1edeccf72bc45f07 | refs/heads/master | 2023-03-18T01:41:19.279120 | 2019-03-15T20:44:51 | 2019-03-15T20:44:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,666 | h | /**
* Copyright (C) 2015 Roman Hiestand
*
* 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.
*/
#ifndef REGARD3DDENSIFICATIONDIALOG_H
#define REGARD3DDENSIFICATIONDIALOG_H
#include "Regard3DMainFrameBase.h"
#include "R3DProject.h"
class Regard3DDensificationDialog: public Regard3DDensificationDialogBase
{
public:
Regard3DDensificationDialog(wxWindow *pParent);
virtual ~Regard3DDensificationDialog();
void getResults(R3DProject::Densification *pDensification);
protected:
virtual void OnInitDialog( wxInitDialogEvent& event );
virtual void OnUseCMVSCheckBox( wxCommandEvent& event );
virtual void OnPMVSLevelSliderScroll( wxScrollEvent& event );
virtual void OnPMVSCellSizeSliderScroll( wxScrollEvent& event );
virtual void OnPMVSThresholdSliderScroll( wxScrollEvent& event );
virtual void OnPMVSWSizeSliderScroll( wxScrollEvent& event );
virtual void OnPMVSMinImageNumSliderScroll( wxScrollEvent& event );
virtual void OnMVEScaleSliderScroll( wxScrollEvent& event );
virtual void OnMVEFilterWidthSliderScroll( wxScrollEvent& event );
virtual void OnSMVSInputScaleSliderScroll( wxScrollEvent& event );
virtual void OnSMVSOutputScaleSliderScroll( wxScrollEvent& event );
virtual void OnSMVSSurfaceSmoothingFactorSliderScroll( wxScrollEvent& event );
void updatePMVSLevelText();
void updatePMVSCellSizeText();
void updatePMVSThresholdText();
void updatePMVSWSizeText();
void updatePMVSMinImageNumText();
void updateMVEScaleText();
void updateMVEFilterWidthText();
void updateSMVSInputScaleText();
void updateSMVSOutputScaleText();
void updateSMVSSurfaceSmoothingFactorText();
private:
DECLARE_EVENT_TABLE()
};
#endif
| [
"hiestandroman@gmail.com"
] | hiestandroman@gmail.com |
fa9676ecdf6a4a83dfeb079236159220c53e3485 | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /ipc/ipc_mojo_handle_attachment.cc | 819a12b890ad1c3da3857f3f36923c16854576e4 | [
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 851 | cc | // Copyright (c) 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 "ipc/ipc_mojo_handle_attachment.h"
#include <utility>
#include "build/build_config.h"
namespace IPC {
namespace internal {
MojoHandleAttachment::MojoHandleAttachment(mojo::ScopedHandle handle)
: handle_(std::move(handle)) {}
MojoHandleAttachment::~MojoHandleAttachment() {
}
MessageAttachment::Type MojoHandleAttachment::GetType() const {
return TYPE_MOJO_HANDLE;
}
#if defined(OS_POSIX)
base::PlatformFile MojoHandleAttachment::TakePlatformFile() {
NOTREACHED();
return base::kInvalidPlatformFile;
}
#endif // OS_POSIX
mojo::ScopedHandle MojoHandleAttachment::TakeHandle() {
return std::move(handle_);
}
} // namespace internal
} // namespace IPC
| [
"enrico.weigelt@gr13.net"
] | enrico.weigelt@gr13.net |
8d76a39cb3a807c170eea8bd4c8814808af73d4f | 4e47a01ea752ef050a8a22d173a16957ff1fa762 | /src/qt/optionsmodel.cpp | 093afc720cb5b0bc22e434626323652247634ef7 | [
"MIT"
] | permissive | levantcoin-project/levantcoin | fad784bc901b4611e4bf9870f1d90601b245e4f3 | 8eeea42a411f24ced737946706cf71b113702112 | refs/heads/main | 2021-07-14T11:22:57.494789 | 2021-02-22T19:59:04 | 2021-02-22T19:59:04 | 237,375,658 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 18,397 | cpp | // Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2019 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#if defined(HAVE_CONFIG_H)
#include "config/levantcoin-config.h"
#endif
#include "optionsmodel.h"
#include "bitcoinunits.h"
#include "guiutil.h"
#include "amount.h"
#include "init.h"
#include "main.h"
#include "net.h"
#include "txdb.h" // for -dbcache defaults
#include "util.h"
#ifdef ENABLE_WALLET
#include "masternodeconfig.h"
#include "wallet/wallet.h"
#include "wallet/walletdb.h"
#endif
#include <QNetworkProxy>
#include <QSettings>
#include <QStringList>
OptionsModel::OptionsModel(QObject* parent) : QAbstractListModel(parent)
{
Init();
}
void OptionsModel::addOverriddenOption(const std::string& option)
{
strOverriddenByCommandLine += QString::fromStdString(option) + "=" + QString::fromStdString(mapArgs[option]) + " ";
}
// Writes all missing QSettings with their default values
void OptionsModel::Init()
{
resetSettings = false;
QSettings settings;
// Ensure restart flag is unset on client startup
setRestartRequired(false);
// These are Qt-only settings:
// Window
if (!settings.contains("fMinimizeToTray"))
settings.setValue("fMinimizeToTray", false);
fMinimizeToTray = settings.value("fMinimizeToTray").toBool();
if (!settings.contains("fMinimizeOnClose"))
settings.setValue("fMinimizeOnClose", false);
fMinimizeOnClose = settings.value("fMinimizeOnClose").toBool();
// Display
if (!settings.contains("nDisplayUnit"))
settings.setValue("nDisplayUnit", BitcoinUnits::LVC);
nDisplayUnit = settings.value("nDisplayUnit").toInt();
if (!settings.contains("strThirdPartyTxUrls"))
settings.setValue("strThirdPartyTxUrls", "");
strThirdPartyTxUrls = settings.value("strThirdPartyTxUrls", "").toString();
if (!settings.contains("fHideZeroBalances"))
settings.setValue("fHideZeroBalances", true);
fHideZeroBalances = settings.value("fHideZeroBalances").toBool();
if (!settings.contains("fHideOrphans"))
settings.setValue("fHideOrphans", false);
fHideOrphans = settings.value("fHideOrphans").toBool();
if (!settings.contains("fCoinControlFeatures"))
settings.setValue("fCoinControlFeatures", false);
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
if (!settings.contains("fZeromintEnable"))
settings.setValue("fZeromintEnable", true);
fEnableZeromint = settings.value("fZeromintEnable").toBool();
if (!settings.contains("fEnableAutoConvert"))
settings.setValue("fEnableAutoConvert", true);
fEnableAutoConvert = settings.value("fEnableAutoConvert").toBool();
if (!settings.contains("nZeromintPercentage"))
settings.setValue("nZeromintPercentage", 10);
nZeromintPercentage = settings.value("nZeromintPercentage").toLongLong();
if (!settings.contains("nPreferredDenom"))
settings.setValue("nPreferredDenom", 0);
nPreferredDenom = settings.value("nPreferredDenom", "0").toLongLong();
if (!settings.contains("fShowMasternodesTab"))
settings.setValue("fShowMasternodesTab", masternodeConfig.getCount());
// These are shared with the core or have a command-line parameter
// and we want command-line parameters to overwrite the GUI settings.
//
// If setting doesn't exist create it with defaults.
//
// If SoftSetArg() or SoftSetBoolArg() return false we were overridden
// by command-line and show this in the UI.
// Main
if (!settings.contains("nDatabaseCache"))
settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache);
if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString()))
addOverriddenOption("-dbcache");
if (!settings.contains("nThreadsScriptVerif"))
settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS);
if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString()))
addOverriddenOption("-par");
// Wallet
#ifdef ENABLE_WALLET
if (!settings.contains("bSpendZeroConfChange"))
settings.setValue("bSpendZeroConfChange", false);
if (!SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool()))
addOverriddenOption("-spendzeroconfchange");
#endif
if (!settings.contains("nStakeSplitThreshold"))
settings.setValue("nStakeSplitThreshold", 1);
// Network
if (!settings.contains("fUseUPnP"))
settings.setValue("fUseUPnP", DEFAULT_UPNP);
if (!SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()))
addOverriddenOption("-upnp");
if (!settings.contains("fListen"))
settings.setValue("fListen", DEFAULT_LISTEN);
if (!SoftSetBoolArg("-listen", settings.value("fListen").toBool()))
addOverriddenOption("-listen");
if (!settings.contains("fUseProxy"))
settings.setValue("fUseProxy", false);
if (!settings.contains("addrProxy"))
settings.setValue("addrProxy", "127.0.0.1:9050");
// Only try to set -proxy, if user has enabled fUseProxy
if (settings.value("fUseProxy").toBool() && !SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()))
addOverriddenOption("-proxy");
else if (!settings.value("fUseProxy").toBool() && !GetArg("-proxy", "").empty())
addOverriddenOption("-proxy");
// Display
if (!settings.contains("digits"))
settings.setValue("digits", "2");
if (!settings.contains("theme"))
settings.setValue("theme", "");
if (!settings.contains("fCSSexternal"))
settings.setValue("fCSSexternal", false);
if (!settings.contains("language"))
settings.setValue("language", "");
if (!SoftSetArg("-lang", settings.value("language").toString().toStdString()))
addOverriddenOption("-lang");
if (settings.contains("fZeromintEnable"))
SoftSetBoolArg("-enablezeromint", settings.value("fZeromintEnable").toBool());
if (settings.contains("fEnableAutoConvert"))
SoftSetBoolArg("-enableautoconvertaddress", settings.value("fEnableAutoConvert").toBool());
if (settings.contains("nZeromintPercentage"))
SoftSetArg("-zeromintpercentage", settings.value("nZeromintPercentage").toString().toStdString());
if (settings.contains("nPreferredDenom"))
SoftSetArg("-preferredDenom", settings.value("nPreferredDenom").toString().toStdString());
if (settings.contains("nAnonymizeLevantcoinAmount"))
SoftSetArg("-anonymizelevantcoinamount", settings.value("nAnonymizeLevantcoinAmount").toString().toStdString());
language = settings.value("language").toString();
}
void OptionsModel::Reset()
{
QSettings settings;
// Remove all entries from our QSettings object
settings.clear();
resetSettings = true; // Needed in levantcoin.cpp during shotdown to also remove the window positions
// default setting for OptionsModel::StartAtStartup - disabled
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(false);
}
int OptionsModel::rowCount(const QModelIndex& parent) const
{
return OptionIDRowCount;
}
// read QSettings values and return them
QVariant OptionsModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::EditRole) {
QSettings settings;
switch (index.row()) {
case StartAtStartup:
return GUIUtil::GetStartOnSystemStartup();
case MinimizeToTray:
return fMinimizeToTray;
case MapPortUPnP:
#ifdef USE_UPNP
return settings.value("fUseUPnP");
#else
return false;
#endif
case MinimizeOnClose:
return fMinimizeOnClose;
// default proxy
case ProxyUse:
return settings.value("fUseProxy", false);
case ProxyIP: {
// contains IP at index 0 and port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
return strlIpPort.at(0);
}
case ProxyPort: {
// contains IP at index 0 and port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
return strlIpPort.at(1);
}
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
return settings.value("bSpendZeroConfChange");
case ShowMasternodesTab:
return settings.value("fShowMasternodesTab");
#endif
case StakeSplitThreshold:
if (pwalletMain)
return QVariant((int)pwalletMain->nStakeSplitThreshold);
return settings.value("nStakeSplitThreshold");
case DisplayUnit:
return nDisplayUnit;
case ThirdPartyTxUrls:
return strThirdPartyTxUrls;
case Digits:
return settings.value("digits");
case Theme:
return settings.value("theme");
case Language:
return settings.value("language");
case CoinControlFeatures:
return fCoinControlFeatures;
case DatabaseCache:
return settings.value("nDatabaseCache");
case ThreadsScriptVerif:
return settings.value("nThreadsScriptVerif");
case HideZeroBalances:
return settings.value("fHideZeroBalances");
case HideOrphans:
return settings.value("fHideOrphans");
case ZeromintEnable:
return QVariant(fEnableZeromint);
case ZeromintAddresses:
return QVariant(fEnableAutoConvert);
case ZeromintPercentage:
return QVariant(nZeromintPercentage);
case ZeromintPrefDenom:
return QVariant(nPreferredDenom);
case Listen:
return settings.value("fListen");
default:
return QVariant();
}
}
return QVariant();
}
// write QSettings values
bool OptionsModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
bool successful = true; /* set to false on parse error */
if (role == Qt::EditRole) {
QSettings settings;
switch (index.row()) {
case StartAtStartup:
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
break;
case MinimizeToTray:
fMinimizeToTray = value.toBool();
settings.setValue("fMinimizeToTray", fMinimizeToTray);
break;
case MapPortUPnP: // core option - can be changed on-the-fly
settings.setValue("fUseUPnP", value.toBool());
MapPort(value.toBool());
break;
case MinimizeOnClose:
fMinimizeOnClose = value.toBool();
settings.setValue("fMinimizeOnClose", fMinimizeOnClose);
break;
// default proxy
case ProxyUse:
if (settings.value("fUseProxy") != value) {
settings.setValue("fUseProxy", value.toBool());
setRestartRequired(true);
}
break;
case ProxyIP: {
// contains current IP at index 0 and current port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
// if that key doesn't exist or has a changed IP
if (!settings.contains("addrProxy") || strlIpPort.at(0) != value.toString()) {
// construct new value from new IP and current port
QString strNewValue = value.toString() + ":" + strlIpPort.at(1);
settings.setValue("addrProxy", strNewValue);
setRestartRequired(true);
}
} break;
case ProxyPort: {
// contains current IP at index 0 and current port at index 1
QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts);
// if that key doesn't exist or has a changed port
if (!settings.contains("addrProxy") || strlIpPort.at(1) != value.toString()) {
// construct new value from current IP and new port
QString strNewValue = strlIpPort.at(0) + ":" + value.toString();
settings.setValue("addrProxy", strNewValue);
setRestartRequired(true);
}
} break;
#ifdef ENABLE_WALLET
case SpendZeroConfChange:
if (settings.value("bSpendZeroConfChange") != value) {
settings.setValue("bSpendZeroConfChange", value);
setRestartRequired(true);
}
break;
case ShowMasternodesTab:
if (settings.value("fShowMasternodesTab") != value) {
settings.setValue("fShowMasternodesTab", value);
setRestartRequired(true);
}
break;
#endif
case StakeSplitThreshold:
settings.setValue("nStakeSplitThreshold", value.toInt());
setStakeSplitThreshold(value.toInt());
break;
case DisplayUnit:
setDisplayUnit(value);
break;
case ThirdPartyTxUrls:
if (strThirdPartyTxUrls != value.toString()) {
strThirdPartyTxUrls = value.toString();
settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls);
setRestartRequired(true);
}
break;
case Digits:
if (settings.value("digits") != value) {
settings.setValue("digits", value);
setRestartRequired(true);
}
break;
case Theme:
if (settings.value("theme") != value) {
settings.setValue("theme", value);
setRestartRequired(true);
}
break;
case Language:
if (settings.value("language") != value) {
settings.setValue("language", value);
setRestartRequired(true);
}
break;
case ZeromintEnable:
fEnableZeromint = value.toBool();
settings.setValue("fZeromintEnable", fEnableZeromint);
emit zeromintEnableChanged(fEnableZeromint);
break;
case ZeromintAddresses:
fEnableAutoConvert = value.toBool();
settings.setValue("fEnableAutoConvert", fEnableAutoConvert);
emit zeromintAddressesChanged(fEnableAutoConvert);
case ZeromintPercentage:
nZeromintPercentage = value.toInt();
settings.setValue("nZeromintPercentage", nZeromintPercentage);
emit zeromintPercentageChanged(nZeromintPercentage);
break;
case ZeromintPrefDenom:
nPreferredDenom = value.toInt();
settings.setValue("nPreferredDenom", nPreferredDenom);
emit preferredDenomChanged(nPreferredDenom);
break;
case HideZeroBalances:
fHideZeroBalances = value.toBool();
settings.setValue("fHideZeroBalances", fHideZeroBalances);
emit hideZeroBalancesChanged(fHideZeroBalances);
break;
case HideOrphans:
fHideOrphans = value.toBool();
settings.setValue("fHideOrphans", fHideOrphans);
emit hideOrphansChanged(fHideOrphans);
break;
case CoinControlFeatures:
fCoinControlFeatures = value.toBool();
settings.setValue("fCoinControlFeatures", fCoinControlFeatures);
emit coinControlFeaturesChanged(fCoinControlFeatures);
break;
case DatabaseCache:
if (settings.value("nDatabaseCache") != value) {
settings.setValue("nDatabaseCache", value);
setRestartRequired(true);
}
break;
case ThreadsScriptVerif:
if (settings.value("nThreadsScriptVerif") != value) {
settings.setValue("nThreadsScriptVerif", value);
setRestartRequired(true);
}
break;
case Listen:
if (settings.value("fListen") != value) {
settings.setValue("fListen", value);
setRestartRequired(true);
}
break;
default:
break;
}
}
emit dataChanged(index, index);
return successful;
}
/** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
void OptionsModel::setDisplayUnit(const QVariant& value)
{
if (!value.isNull()) {
QSettings settings;
nDisplayUnit = value.toInt();
settings.setValue("nDisplayUnit", nDisplayUnit);
emit displayUnitChanged(nDisplayUnit);
}
}
/* Update StakeSplitThreshold's value in wallet */
void OptionsModel::setStakeSplitThreshold(int value)
{
// XXX: maybe it's worth to wrap related stuff with WALLET_ENABLE ?
uint64_t nStakeSplitThreshold;
nStakeSplitThreshold = value;
if (pwalletMain && pwalletMain->nStakeSplitThreshold != nStakeSplitThreshold) {
CWalletDB walletdb(pwalletMain->strWalletFile);
LOCK(pwalletMain->cs_wallet);
{
pwalletMain->nStakeSplitThreshold = nStakeSplitThreshold;
if (pwalletMain->fFileBacked)
walletdb.WriteStakeSplitThreshold(nStakeSplitThreshold);
}
}
}
bool OptionsModel::getProxySettings(QNetworkProxy& proxy) const
{
// Directly query current base proxy, because
// GUI settings can be overridden with -proxy.
proxyType curProxy;
if (GetProxy(NET_IPV4, curProxy)) {
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(QString::fromStdString(curProxy.proxy.ToStringIP()));
proxy.setPort(curProxy.proxy.GetPort());
return true;
} else
proxy.setType(QNetworkProxy::NoProxy);
return false;
}
void OptionsModel::setRestartRequired(bool fRequired)
{
QSettings settings;
return settings.setValue("fRestartRequired", fRequired);
}
bool OptionsModel::isRestartRequired()
{
QSettings settings;
return settings.value("fRestartRequired", false).toBool();
}
| [
"60064323+levantcoin-project@users.noreply.github.com"
] | 60064323+levantcoin-project@users.noreply.github.com |
c9eff8b6566c1379b8f3b06b2ba1bda06b98cf2a | 21a880dcdf84fd0c812f8506763a689fde297ba7 | /test/cme/exchange/mut_strategy_communicator.h | d6efb495552bb6b1fd1a83e262f6ffdd1108c5c2 | [] | no_license | chenlucan/fix_handler | 91df9037eeb675b0c7ea6f22d541da74b220092f | 765462ff1a85567f43f63e04c29dbc9546a6c2e1 | refs/heads/master | 2021-03-22T02:07:39.016551 | 2017-08-01T02:02:20 | 2017-08-01T02:02:20 | 84,138,943 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,003 | h |
#ifndef __FH_CORE_STRATEGY_MUT_STRATEGY_COMMUNICATOR_H__
#define __FH_CORE_STRATEGY_MUT_STRATEGY_COMMUNICATOR_H__
#include "gtest/gtest.h"
#include <string>
#include "core/global.h"
#include "core/exchange/exchangei.h"
#include "core/exchange/exchangelisteneri.h"
#include "cme/exchange/order_manager.h"
#include "cme/exchange/exchange_settings.h"
#include "cme/exchange/globex_logger.h"
#include "pb/ems/ems.pb.h"
#include "core/strategy/invalid_order.h"
namespace fh
{
namespace core
{
namespace strategy
{
class MutStrategyCommunicator : public testing::Test
{
public:
MutStrategyCommunicator();
virtual ~MutStrategyCommunicator();
virtual void SetUp();
virtual void TearDown();
private:
DISALLOW_COPY_AND_ASSIGN(MutStrategyCommunicator);
};
} // namespace strategy
} // namespace core
} // namespace fh
#endif // __FH_CORE_STRATEGY_MUT_STRATEGY_COMMUNICATOR_H__
| [
"461010295@qq.com"
] | 461010295@qq.com |
7a83af891370ae5be308ee2d1a99dab9631848d0 | ec3a644fdf1a50fa8efade552bfac649ae9a9386 | /src/include/duckdb/planner/expression_binder/insert_binder.hpp | 095a3e20005fa095f703f68ebffbdec805137b7c | [
"MIT"
] | permissive | Longi94/duckdb | 71c012fb00ee190f712c02da4a9a3d172d712705 | 2debf14528e408841a4bc6f43eb114275a096d4e | refs/heads/master | 2020-09-08T20:47:10.391723 | 2020-01-14T13:32:52 | 2020-01-14T13:32:52 | 221,237,347 | 0 | 0 | MIT | 2019-11-12T14:28:50 | 2019-11-12T14:28:49 | null | UTF-8 | C++ | false | false | 748 | hpp | //===----------------------------------------------------------------------===//
// DuckDB
//
// duckdb/planner/expression_binder/insert_binder.hpp
//
//
//===----------------------------------------------------------------------===//
#pragma once
#include "duckdb/planner/expression_binder.hpp"
namespace duckdb {
//! The INSERT binder is responsible for binding expressions within the VALUES of an INSERT statement
class InsertBinder : public ExpressionBinder {
public:
InsertBinder(Binder &binder, ClientContext &context);
protected:
BindResult BindExpression(ParsedExpression &expr, index_t depth, bool root_expression = false) override;
string UnsupportedAggregateMessage() override;
};
} // namespace duckdb
| [
"mark.raasveldt@gmail.com"
] | mark.raasveldt@gmail.com |
93ef5c7150aa0e35ecd95361c7bc0226569447f2 | 7f3ebccc627fc4c11133bc6db9a167817f6c79e9 | /src/patterns/diamondWithStarsWithoutSpaces.cpp | f7b65420b2801aa9b24196fa0bf49fd361230f54 | [] | no_license | Gs-Rawat/ProgrammingQuestions | 4ce1b90a8793308c55de7f102a3c59e7491e2cd7 | cf84098bd8b71c1fb540dd8a685879582faf330f | refs/heads/master | 2023-03-18T22:55:55.621465 | 2021-02-25T16:56:06 | 2021-02-25T16:56:06 | 341,554,899 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 525 | cpp | #include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n-i-1; j++) {
cout << " ";
}
for(int k = 0; k < 2*i+1; k++) {
cout << "*";
}
cout << endl;
}
for(int i = n-2; i >= 0; i--) {
for(int j = 0; j < n-i-1; j++) {
cout << " ";
}
for(int k = 0; k < 2*i+1; k++) {
cout << "*";
}
cout << endl;
}
return 0;
} | [
"gsrawat0512@gmail.com"
] | gsrawat0512@gmail.com |
2fccd708d94e4c9f7f711025bee6ab0c5a15f01b | 0bd015a249d604fbbf7ea2b64b60e684539ef1da | /robot/PIC/ROBO-PICA_examples/A5-1/Movement.cp | c2bda73fe31fee4031df63914e91d42fff8482b5 | [] | no_license | LeonidMurashov/AVR_Arduino | db25a0976180ca3cc4ce4b0f65c5f6ee539e1941 | 309330b1a08a48b2ba212cd6e8d88f187ab0eea5 | refs/heads/master | 2020-07-15T18:39:03.772084 | 2018-02-14T21:02:36 | 2018-02-14T21:02:36 | 73,959,828 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,165 | cp | #line 1 "E:/Work2007/MikroC/Code/A5-1/Movement.c"
#line 1 "c:/program files/mikroelektronika/mikroc/include/motor.h"
char motor_duty_= 127;
char motor_init_=0;
#line 17 "c:/program files/mikroelektronika/mikroc/include/motor.h"
void Motor_Init()
{
if (motor_init_==0)
{
motor_init_=1;
ANSELH.F0=0;
ANSELH.F2=0;
TRISB.F1=0;
TRISB.F2=0;
TRISD.F0=0;
TRISD.F1=0;
Pwm1_Init(5000);
Pwm2_Init(5000);
}
}
void Change_Duty(char speed)
{
if (speed != motor_duty_)
{
motor_duty_=speed;
Pwm1_Change_Duty(speed);
Pwm2_Change_Duty(speed);
}
}
void Motor_A_FWD()
{
Pwm1_Start();
PORTD.F0 =0;
PORTD.F1 =1;
}
void Motor_B_FWD()
{
Pwm2_Start();
PORTB.F1 =0;
PORTB.F2 =1;
}
void Motor_A_BWD()
{
Pwm1_Start();
PORTD.F0 =1;
PORTD.F1 =0;
}
void Motor_B_BWD()
{
Pwm2_Start();
PORTB.F1 =1;
PORTB.F2 =0;
}
void Forward(char speed)
{
Motor_Init();
Change_Duty(speed);
Motor_A_FWD();
Motor_B_FWD();
}
void Backward(char speed)
{
Motor_Init();
Change_Duty(speed);
Motor_A_BWD();
Motor_B_BWD();
}
void S_Right(char speed)
{
Motor_Init();
Change_Duty(speed);
Motor_A_FWD();
Motor_B_BWD();
}
void S_Left(char speed)
{
Motor_Init();
Change_Duty(speed);
Motor_A_BWD();
Motor_B_FWD();
}
void Motor_A_Off()
{
Pwm1_Stop();
PORTD.F0 =0;
PORTD.F1 =0;
}
void Motor_B_Off()
{
Pwm2_Stop();
PORTB.F1 =0;
PORTB.F2 =0;
}
void Motor_Stop()
{
Change_Duty(0);
Motor_A_Off();
Motor_B_Off();
motor_init_=0;
}
#line 2 "E:/Work2007/MikroC/Code/A5-1/Movement.c"
void main()
{
Sound_Init(&PORTC, 0);
while(PORTA.F4==1);
Sound_Play(2000,50);
Forward(255);
Delay_ms(2000);
Sound_Play(2000,50);
S_Left(255);
Delay_ms(800);
Sound_Play(2000,50);
Forward(255);
Delay_ms(2000);
Sound_Play(2000,50);
S_Right(255);
Delay_ms(800);
Sound_Play(2000,50);
Forward(255);
Delay_ms(2000);
Sound_Play(2000,50);
S_Left(255);
Delay_ms(800);
Sound_Play(2000,50);
Backward(255);
Delay_ms(1000);
Sound_Play(2000,50);
Motor_Stop();
}
| [
"="
] | = |
6922a6d888b730c2cee65677bab23ffe2df3e03f | 542b91e07d5fc4c8447e41d45af03baab7448331 | /Array&Linked List/problem/rotateList61.cpp | 5103759f03c98310833cc93c50756f9edb69ff13 | [] | no_license | Mrszhao112/Algorithm | da6ac5d5fdd1b8cae56075130635ca214005174d | 245cda00f107ba024ca458a55381d7085dea16f8 | refs/heads/master | 2022-11-28T06:34:22.763820 | 2020-08-15T02:29:49 | 2020-08-15T02:29:49 | 256,908,367 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,789 | cpp | // 给定一个链表,旋转链表,将链表每个节点向右移动 k 个位置,其中 k 是非负数。
//一道链表的拼接题目 注意控制边界条件
class Solution {
public:
ListNode* rotateRight(ListNode* head, int k) {
if (head == NULL) {
return head;
}
ListNode* tmp = head;
ListNode* end = head;
int sz = 0;
while (tmp != NULL) {//计算长度
tmp = tmp->next;
++sz;
}
k %= sz;//取余防止旋转长度超出链表长度
if (k == 0) {
return head;
}
tmp = head;
k = sz - k;//计算需要旋转的地方
while(--k) {
tmp = tmp->next;
}
end = tmp; //新的链表尾部
tmp = tmp->next;
end->next = NULL;
end = tmp;
while (tmp->next != NULL) {//拼接链表
tmp = tmp->next;
}
tmp->next = head;
return end; //返回链表头
}
};
///////////////////////////////////////////////////////////////////////////////////
//大佬的clean code 值得学习
class Solution {
public:
ListNode* rotateRight(ListNode* head, int k) {
if(!head) return head;
int len=1; // number of nodes
ListNode *newH, *tail;
newH=tail=head;
while(tail->next) // get the number of nodes in the list
{
tail = tail->next;
len++;
}
tail->next = head; // circle the link
if(k %= len)
{
for(auto i=0; i<len-k; i++) tail = tail->next; // the tail node is the (len-k)-th node (1st node is head)
}
newH = tail->next;
tail->next = NULL;
return newH;
}
};
| [
"noreply@github.com"
] | noreply@github.com |
3edd0f38c5d662a87499e6c2b7dd9345b4267bbc | d0c44dd3da2ef8c0ff835982a437946cbf4d2940 | /cmake-build-debug/programs_tiling/function14335/function14335_schedule_16/function14335_schedule_16.cpp | 6816dcd93c5af50fe5e315b34234437692e87008 | [] | no_license | IsraMekki/tiramisu_code_generator | 8b3f1d63cff62ba9f5242c019058d5a3119184a3 | 5a259d8e244af452e5301126683fa4320c2047a3 | refs/heads/master | 2020-04-29T17:27:57.987172 | 2019-04-23T16:50:32 | 2019-04-23T16:50:32 | 176,297,755 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,995 | cpp | #include <tiramisu/tiramisu.h>
using namespace tiramisu;
int main(int argc, char **argv){
tiramisu::init("function14335_schedule_16");
constant c0("c0", 64), c1("c1", 128), c2("c2", 64), c3("c3", 128);
var i0("i0", 0, c0), i1("i1", 0, c1), i2("i2", 0, c2), i3("i3", 0, c3), i01("i01"), i02("i02"), i03("i03"), i04("i04");
input input00("input00", {i1, i3}, p_int32);
input input01("input01", {i1, i2, i3}, p_int32);
input input02("input02", {i0, i2, i3}, p_int32);
input input03("input03", {i0}, p_int32);
input input04("input04", {i1, i2, i3}, p_int32);
input input05("input05", {i3}, p_int32);
input input06("input06", {i2}, p_int32);
input input07("input07", {i0}, p_int32);
computation comp0("comp0", {i0, i1, i2, i3}, input00(i1, i3) - input01(i1, i2, i3) + input02(i0, i2, i3) + input03(i0) - input04(i1, i2, i3) - input05(i3) * input06(i2) * input07(i0));
comp0.tile(i1, i2, 128, 32, i01, i02, i03, i04);
comp0.parallelize(i0);
buffer buf00("buf00", {128, 128}, p_int32, a_input);
buffer buf01("buf01", {128, 64, 128}, p_int32, a_input);
buffer buf02("buf02", {64, 64, 128}, p_int32, a_input);
buffer buf03("buf03", {64}, p_int32, a_input);
buffer buf04("buf04", {128, 64, 128}, p_int32, a_input);
buffer buf05("buf05", {128}, p_int32, a_input);
buffer buf06("buf06", {64}, p_int32, a_input);
buffer buf07("buf07", {64}, p_int32, a_input);
buffer buf0("buf0", {64, 128, 64, 128}, p_int32, a_output);
input00.store_in(&buf00);
input01.store_in(&buf01);
input02.store_in(&buf02);
input03.store_in(&buf03);
input04.store_in(&buf04);
input05.store_in(&buf05);
input06.store_in(&buf06);
input07.store_in(&buf07);
comp0.store_in(&buf0);
tiramisu::codegen({&buf00, &buf01, &buf02, &buf03, &buf04, &buf05, &buf06, &buf07, &buf0}, "../data/programs/function14335/function14335_schedule_16/function14335_schedule_16.o");
return 0;
} | [
"ei_mekki@esi.dz"
] | ei_mekki@esi.dz |
4df6252de651ca574a36b6ea651158a46d467c33 | c80bd09af0df142029d5996587aed5d23c237fbc | /DevTitle/audioclass.cpp | 68996f4567a6785258f3a0174b72afddd53f2f3c | [] | no_license | jamesconrad/Mainframe | 6e58e9df6a601b44901d3205b3e2de81e4f8d37d | 70ce57eba4755cc3f5bd3539d29c2da2be28f8c9 | refs/heads/master | 2021-03-13T00:10:20.881803 | 2018-05-02T22:12:50 | 2018-05-02T22:12:50 | 24,145,975 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,006 | cpp | #include "audioclass.h"
#include <uuids.h>
AudioClass::AudioClass()
{
pigb = NULL;
pimc = NULL;
pimex = NULL;
piba = NULL;
ready = false;
currentFile = NULL;
}
AudioClass::~AudioClass()
{
Shutdown();
}
void AudioClass::Shutdown()
{
if (pimc)
pimc->Stop();
if (pigb)
{
pigb->Release();
pigb = NULL;
}
if (pimc)
{
pimc->Release();
pimc = NULL;
}
if (pimex)
{
pimex->Release();
pimex = NULL;
}
if (piba)
{
piba->Release();
piba = NULL;
}
ready = false;
}
bool AudioClass::Load(LPCWSTR szFile)
{
//Make sure file is not already loaded
if (currentFile != szFile)
{
//Reset
Shutdown();
CoInitialize(NULL);
//Check if properly reset
if (SUCCEEDED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&this->pigb)))
{
//Get handles to required objects
pigb->QueryInterface(IID_IMediaControl, (void**)&pimc);
pigb->QueryInterface(IID_IMediaEventEx, (void**)&pimex);
pigb->QueryInterface(IID_IBasicAudio, (void**)&piba);
//Check if sucessful
HRESULT hr = pigb->RenderFile(szFile, NULL);
if (SUCCEEDED(hr))
{
ready = true;
}
}
return ready;
}
return ready;
}
bool AudioClass::Play()
{
//Start playing music
if (ready && pimc)
{
HRESULT hr = pimc->Run();
return SUCCEEDED(hr);
}
return false;
}
bool AudioClass::Pause()
{
//Pause music
if (ready && pimc)
{
HRESULT hr = pimc->Pause();
return SUCCEEDED(hr);
}
return false;
}
bool AudioClass::Stop()
{
//Set time to 0, and pause.
if (ready && pimc)
{
HRESULT hr = pimc->Stop();
return SUCCEEDED(hr);
}
return false;
}
bool AudioClass::SetVolume(long vol)
{
//Change volume, returns sucesses
if (ready && piba)
{
HRESULT hr = piba->put_Volume(vol);
return SUCCEEDED(hr);
}
return false;
}
long AudioClass::GetVolume()
{
//Get volume, returns -1 if not ready
if (ready && piba)
{
long vol = -1;
HRESULT hr = piba->get_Volume(&vol);
if (SUCCEEDED(hr))
return vol;
}
return -1;
} | [
"james.conrad@uoit.net"
] | james.conrad@uoit.net |
989ce928f2aec2df34265850fd5ed3aa92c3b834 | 16834ff79f86ad959608f72e53bde826695a3762 | /PoolTests/Synthetic/interface/Branch.h | ead2bf5dc6e7fa256260fc1b8c56d1ae3bc40d0f | [] | no_license | VinInn/MyCMSSW | d2f56b53b1fe353892b549e482b0c22c1eaf9c81 | 3e42f710d93b49e2337d972a3e16ee760b23d703 | refs/heads/master | 2020-04-29T15:34:30.448310 | 2013-03-14T08:41:15 | 2013-03-14T08:41:15 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,117 | h | #ifndef Synthetic_Branch_H
#define Synthetic_Branch_H
#include "PoolTests/Synthetic/interface/BaseBranch.h"
#include "PoolTests/Synthetic/interface/Synthesis.h"
#include "Reflex/Type.h"
#include "DataSvc/Ref.h"
#include "PersistencySvc/Placement.h"
#include "StorageSvc/DbType.h"
#include <string>
namespace synthetic {
std::string branchName(std::string const & tname,
std::string const & cname) {
return tname+"("+cname+")";
}
template <typename Vec>
class Branch : public BaseBranch {
public:
typedef Vec vec_type;
Branch(pool::IDataSvc *svc,
std::string const & fname,
std::string const & tname,
std::string const & cname) :
dict(cname.c_str()),
place(fname, pool::DatabaseSpecification::PFN,
branchName(tname,cname),
ROOT::Reflex::Type(),
pool::ROOTTREE_StorageType.type()),
obj(svc), count(0), added(false) {}
template <typename IT>
Branch(pool::IDataSvc *svc,
std::string const & fname,
std::string const & tname,
std::string const & cname,
IT ib, IT ie) :
dict(cname.c_str(),ib,ie),
place(fname, pool::DatabaseSpecification::PFN,
branchName(tname,cname),
ROOT::Reflex::Type(),
pool::ROOTTREE_StorageType.type()),
obj(svc), count(0), added(false) {}
bool add(std::auto_ptr<vec_type> v) {
if (added) return false; // throw?
obj = v.release();
added = obj;
if (added) count++;
return added;
}
void clean() {
obj=0;
if (added) {
count--;
added=false;
}
}
private:
synthetic::Dict<vec_type> dict;
pool::Placement place;
pool::Ref<vec_type> obj;
int count;
bool added;
private:
void write(int globalCount) {
if (globalCount<count) ; // throw
// fill previous rows with defaults...
for (;count!=globalCount; count++) {
pool::Ref<vec_type> dummy(obj); dummy=new vec_type();
dummy.markWrite(place);
}
if (added) {
obj.markWrite(place);
added=false;
}
}
};
}
#endif // Synthetic_Branch_H
| [
""
] | |
f9e53bd8a2d3d56e97a4d5541d9001ab285b7029 | 091afb7001e86146209397ea362da70ffd63a916 | /inst/include/nt2/include/functions/thousand.hpp | 89ba63866bc8f7801230d1752baec9998904d47f | [] | no_license | RcppCore/RcppNT2 | f156b58c08863243f259d1e609c9a7a8cf669990 | cd7e548daa2d679b6ccebe19744b9a36f1e9139c | refs/heads/master | 2021-01-10T16:15:16.861239 | 2016-02-02T22:18:25 | 2016-02-02T22:18:25 | 50,460,545 | 15 | 1 | null | 2019-11-15T22:08:50 | 2016-01-26T21:29:34 | C++ | UTF-8 | C++ | false | false | 164 | hpp | #ifndef NT2_INCLUDE_FUNCTIONS_THOUSAND_HPP_INCLUDED
#define NT2_INCLUDE_FUNCTIONS_THOUSAND_HPP_INCLUDED
#include <nt2/core/include/functions/thousand.hpp>
#endif
| [
"kevinushey@gmail.com"
] | kevinushey@gmail.com |
2b98ead60589e503d1c6c34e1387cebb6314c364 | b8a4905d309b382383143b6510f0759fb66bc054 | /src/qt/bitcoin.cpp | b1d6acee1001c8dc2b99abce582964478033db48 | [
"MIT"
] | permissive | zero24x/legends | b86817d7e91d7aaef7cb680606459e9b9dbeb5b0 | 53c8decffc146c80351c6d9026de42bd38d87ae3 | refs/heads/master | 2020-03-23T00:46:07.686153 | 2018-07-13T20:03:41 | 2018-07-13T20:03:41 | 140,884,518 | 0 | 0 | MIT | 2018-07-13T19:14:39 | 2018-07-13T19:14:39 | null | UTF-8 | C++ | false | false | 9,069 | cpp | /*
* W.J. van der Laan 2011-2012
*/
#include "bitcoingui.h"
#include "clientmodel.h"
#include "walletmodel.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "guiconstants.h"
#include "init.h"
#include "ui_interface.h"
#include "qtipcserver.h"
#include <QApplication>
#include <QMessageBox>
#include <QTextCodec>
#include <QLocale>
#include <QTranslator>
#include <QSplashScreen>
#include <QLibraryInfo>
#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED)
#define _BITCOIN_QT_PLUGINS_INCLUDED
#define __INSURE__
#include <QtPlugin>
Q_IMPORT_PLUGIN(qcncodecs)
Q_IMPORT_PLUGIN(qjpcodecs)
Q_IMPORT_PLUGIN(qtwcodecs)
Q_IMPORT_PLUGIN(qkrcodecs)
Q_IMPORT_PLUGIN(qtaccessiblewidgets)
#endif
// Need a global reference for the notifications to find the GUI
static BitcoinGUI *guiref;
static QSplashScreen *splashref;
static void ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style)
{
// Message from network thread
if(guiref)
{
bool modal = (style & CClientUIInterface::MODAL);
// in case of modal message, use blocking connection to wait for user to click OK
QMetaObject::invokeMethod(guiref, "error",
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(caption)),
Q_ARG(QString, QString::fromStdString(message)),
Q_ARG(bool, modal));
}
else
{
printf("%s: %s\n", caption.c_str(), message.c_str());
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
}
}
static bool ThreadSafeAskFee(int64_t nFeeRequired, const std::string& strCaption)
{
if(!guiref)
return false;
if(nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon)
return true;
bool payFee = false;
QMetaObject::invokeMethod(guiref, "askFee", GUIUtil::blockingGUIThreadConnection(),
Q_ARG(qint64, nFeeRequired),
Q_ARG(bool*, &payFee));
return payFee;
}
static void ThreadSafeHandleURI(const std::string& strURI)
{
if(!guiref)
return;
QMetaObject::invokeMethod(guiref, "handleURI", GUIUtil::blockingGUIThreadConnection(),
Q_ARG(QString, QString::fromStdString(strURI)));
}
static void InitMessage(const std::string &message)
{
if(splashref)
{
splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(232,186,63));
QApplication::instance()->processEvents();
}
}
static void QueueShutdown()
{
QMetaObject::invokeMethod(QCoreApplication::instance(), "quit", Qt::QueuedConnection);
}
/*
Translate string to current locale using Qt.
*/
static std::string Translate(const char* psz)
{
return QCoreApplication::translate("bitcoin-core", psz).toStdString();
}
/* Handle runaway exceptions. Shows a message box with the problem and quits the program.
*/
static void handleRunawayException(std::exception *e)
{
PrintExceptionContinue(e, "Runaway exception");
QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. LEGENDS can no longer continue safely and will quit.") + QString("\n\n") + QString::fromStdString(strMiscWarning));
exit(1);
}
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
// Do this early as we don't want to bother initializing if we are just calling IPC
ipcScanRelay(argc, argv);
#if QT_VERSION < 0x050000
// Internal string conversion is all UTF-8
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
#endif
Q_INIT_RESOURCE(bitcoin);
QApplication app(argc, argv);
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
// Command-line options take precedence:
ParseParameters(argc, argv);
// ... then bitcoin.conf:
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
// This message can not be translated, as translation is not initialized yet
// (which not yet possible because lang=XX can be overridden in bitcoin.conf in the data directory)
QMessageBox::critical(0, "LEGENDS",
QString("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
return 1;
}
ReadConfigFile(mapArgs, mapMultiArgs);
// Application identification (must be set before OptionsModel is initialized,
// as it is used to locate QSettings)
app.setOrganizationName("LEGENDS");
//XXX app.setOrganizationDomain("");
if(GetBoolArg("-testnet")) // Separate UI settings for testnet
app.setApplicationName("LEGENDS-Qt-testnet");
else
app.setApplicationName("LEGENDS-Qt");
// ... then GUI settings:
OptionsModel optionsModel;
// Get desired locale (e.g. "de_DE") from command line or use system locale
QString lang_territory = QString::fromStdString(GetArg("-lang", QLocale::system().name().toStdString()));
QString lang = lang_territory;
// Convert to "de" only by truncating "_DE"
lang.truncate(lang_territory.lastIndexOf('_'));
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
// Load language files for configured locale:
// - First load the translator for the base language, without territory
// - Then load the more specific locale translator
// Load e.g. qt_de.qm
if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app.installTranslator(&qtTranslatorBase);
// Load e.g. qt_de_DE.qm
if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
app.installTranslator(&qtTranslator);
// Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
if (translatorBase.load(lang, ":/translations/"))
app.installTranslator(&translatorBase);
// Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
if (translator.load(lang_territory, ":/translations/"))
app.installTranslator(&translator);
// Subscribe to global signals from core
uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee);
uiInterface.ThreadSafeHandleURI.connect(ThreadSafeHandleURI);
uiInterface.InitMessage.connect(InitMessage);
uiInterface.QueueShutdown.connect(QueueShutdown);
uiInterface.Translate.connect(Translate);
// Show help message immediately after parsing command-line options (for "-lang") and setting locale,
// but before showing splash screen.
if (mapArgs.count("-?") || mapArgs.count("--help"))
{
GUIUtil::HelpMessageBox help;
help.showOrPrint();
return 1;
}
QSplashScreen splash(QPixmap(":/images/splash"), 0);
if (GetBoolArg("-splash", true) && !GetBoolArg("-min"))
{
splash.show();
splashref = &splash;
}
app.processEvents();
app.setQuitOnLastWindowClosed(false);
try
{
// Regenerate startup link, to fix links to old versions
if (GUIUtil::GetStartOnSystemStartup())
GUIUtil::SetStartOnSystemStartup(true);
BitcoinGUI window;
guiref = &window;
if(AppInit2())
{
{
// Put this in a block, so that the Model objects are cleaned up before
// calling Shutdown().
if (splashref)
splash.finish(&window);
ClientModel clientModel(&optionsModel);
WalletModel walletModel(pwalletMain, &optionsModel);
window.setClientModel(&clientModel);
window.setWalletModel(&walletModel);
// If -min option passed, start window minimized.
if(GetBoolArg("-min"))
{
window.showMinimized();
}
else
{
window.show();
}
// Place this here as guiref has to be defined if we don't want to lose URIs
ipcInit(argc, argv);
app.exec();
window.hide();
window.setClientModel(0);
window.setWalletModel(0);
guiref = 0;
}
// Shutdown the core and its threads, but don't exit Bitcoin-Qt here
Shutdown(NULL);
}
else
{
return 1;
}
} catch (std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
}
return 0;
}
#endif // BITCOIN_QT_TEST
| [
"legev@gmail.com"
] | legev@gmail.com |
5e4c24d726faddd6b63128c9a98c68e204aae9fa | 5c71fd153e436eb7118d4224765ad14ee3632787 | /JobManagerPrivate.cpp | fe927fa0b684e50faad9d95bfe62c7618f473c03 | [] | no_license | sriks/NextJob | 8437c59e195618c369a44449dbca3ff8ef086141 | f159a4667e973a55d5b443e876d1ec2ddbcc555e | refs/heads/master | 2021-01-01T16:00:22.583099 | 2012-09-23T09:56:53 | 2012-09-23T09:56:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,253 | cpp | #include <QDebug>
#include <QMap>
#include <QFile>
#include <QXmlStreamWriter>
#include <QStringListIterator>
#include "JobManagerPrivate.h"
#include "Constants.h"
#include "rssmanager.h"
#include "rssparser.h"
#include "Worker.h"
#include "JobModel.h"
#include "JobAlert.h"
#include "AlertModel.h"
#include "JobInfo.h"
JobManagerPrivate::JobManagerPrivate(QObject* parent)
:QObject(parent) {
searchModel = NULL;
favoritesModel = NULL;
newJobsAlertModel = NULL;
allJobsAlertModel = NULL;
worker = new Worker(this);
}
JobManagerPrivate::~JobManagerPrivate() {
saveState();
delete searchModel;
delete favoritesModel;
delete newJobsAlertModel;
delete allJobsAlertModel;
qDeleteAll(alerts.begin(),alerts.end());
worker->wait();
delete worker;
}
/*!
Creates an id for the supplied key
**/
QString JobManagerPrivate::alertId(QVariantMap key) const {
// create key which is sum of all key params
return key.value(NJ_SKILL).toString().simplified() +
key.value(NJ_LOCATION).toString().simplified() +
key.value(NJ_COUNTRY).toString().simplified();
}
void JobManagerPrivate::restoreState() {
worker->clearData();
worker->setTask(Worker::RestoreState);
connect(worker,SIGNAL(finished()),this,SLOT(handleRestoreCompleted()));
worker->start();
}
void JobManagerPrivate::handleRestoreCompleted() {
worker->quit();
favs = worker->favs();
favLookup = worker->favLookup();
alertKeys = worker->alertKeys();
QListIterator< QVariantMap > iter(alertKeys);
while(iter.hasNext())
JobManager::instance()->addAlert(iter.next());
emit restoreCompleted();
}
void JobManagerPrivate::saveState() {
RSSManager* rssMgr = JobManager::instance()->feedManager();
QMapIterator<QString,JobAlert*> iter(alerts);
qDebug()<<Q_FUNC_INFO<<"saving alerts:"<<alerts.size();
while(iter.hasNext()) {
JobAlert* a = iter.next().value();
if(!a->isVisited())
rssMgr->forgetCheckpoint(a->model()->baseUrl());
rssMgr->setUserData(a->model()->baseUrl(),convertToFeedUserData(a->key()));
}
saveFavorites();
}
QString JobManagerPrivate::favFilePath() const {
static QString path;
if(path.isEmpty())
path = JobManager::instance()->feedManager()->storagePath() + "/" + FAV_FILENAME;
return path;
}
// writes to fav file
void JobManagerPrivate::saveFavorites() {
qDebug()<<Q_FUNC_INFO<<favs.size();
QFile f(favFilePath());
// TODO: Should we delete this file before using ?
if(!f.open(QIODevice::WriteOnly)) {
qWarning()<<Q_FUNC_INFO<<"Unable to open file in write mode: "<<favFilePath();
return;
}
QXmlStreamWriter writer(&f);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeStartElement(FAV_XML_ROOT);
QListIterator< QVariantMap > iter(favs);
while(iter.hasNext()) {
writer.writeStartElement(FAV_XML_ITEM);
QVariantMap key = iter.next();
QMapIterator< QString,QVariant > keyIter(key);
while(keyIter.hasNext()) {
keyIter.next();
writer.writeTextElement(keyIter.key(),keyIter.value().toString());
}
writer.writeEndElement(); // closing itemb
}
writer.writeEndElement();
writer.writeEndDocument();
f.close();
}
void JobManagerPrivate::addToFavorites(QVariantMap key) {
favs.insert(0,key); // to ensure that latest fav is at top
}
bool JobManagerPrivate::removeFromFavorites(QVariantMap key) {
int i = favs.indexOf(key);
if(i >= 0) {
favs.removeAt(i);
return true;
} else {
return false;
}
}
void JobManagerPrivate::removeAllFavorites() {
favs.clear();
this->favoritesModel->reset();
}
FeedUserData JobManagerPrivate::convertToFeedUserData(QVariantMap map) {
FeedUserData userdata;
QMapIterator<QString,QVariant> iter(map);
while(iter.hasNext()) {
iter.next();
if(iter.value().canConvert(QVariant::String))
userdata.insert(iter.key(),iter.value().toString());
}
return userdata;
}
RSSManager *JobManagerPrivate::feedManager() {
return RSSManager::instance(APP_FOLDER_NAME);
}
// eof
| [
"srikanthsombhatla@gmail.com"
] | srikanthsombhatla@gmail.com |
6597d1888eeb943e9367398bf16d19bcbf13a35d | 05ae49411964a91124710dd5b5986c7b60aed799 | /poj3664.cpp | 37a8a47e7243bf1681074e90a6ec603f640e6ca3 | [] | no_license | lcccc/nfcjcodes | 24da3564a6df7a5c0796330d0b42ede0af41e8a9 | 17c501606e09b3b65c9288581882284e05519d65 | refs/heads/master | 2020-05-18T10:29:51.124723 | 2011-12-25T04:05:48 | 2011-12-25T04:05:48 | 2,945,286 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,143 | cpp | /*
* Author: FreePascal
* Created Time: 2011/11/2 13:29:57
* File Name: poj3664.cpp
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <stack>
using namespace std;
#define out(v) cerr << #v << ": " << (v) << endl
#define SZ(v) ((int)(v).size())
const int maxint = -1u>>1;
template <class T> bool get_max(T& a, const T &b) {return b > a? a = b, 1: 0;}
template <class T> bool get_min(T& a, const T &b) {return b < a? a = b, 1: 0;}
struct cow{
int va,vb,id;
};
cow tc;
vector<cow> cows;
int n,k;
bool mycmp1(cow c1,cow c2)
{
return c1.va > c2.va;
}
bool mycmp2(cow c1,cow c2)
{
return c1.vb > c2.vb;
}
int main() {
//cin>>n>>k;
scanf("%d%d",&n,&k);
for(int i = 0;i < n;i++)
{
//cin>>tc.va>>tc.vb;
scanf("%d%d", &(tc.va),&(tc.vb));
tc.id = i;
cows.push_back(tc);
}
sort(cows.begin(),cows.end(),mycmp1);
sort(cows.begin(),cows.begin() + k,mycmp2);
cout<<cows[0].id + 1<<endl;
return 0;
}
| [
"root@lc-laptop.(none)"
] | root@lc-laptop.(none) |
980b36aca7d84310cc161cfb8b5c6338f5d622e2 | 6d760556cbfade17db9b990dda17658d81a81a55 | /src/libs/fvmodels/relative_position/ball_trigo.h | a446f7fc40c935e322b04c087a1c9565c612b210 | [] | no_license | sj/fawkresrobotics-fawkes-copy | 8e247a5d2ed76d14aeb06c9a439ee35cf194b025 | 1854db8cafa1718bc636631162c76d15b6894c5b | refs/heads/master | 2020-03-31T13:05:51.779358 | 2018-10-09T11:45:37 | 2018-10-09T11:45:37 | 152,241,372 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,358 | h |
/****************************************************************************
* ball_trigo.h - Ball relpos for pan/tilt camera using basic trigonometry
*
* Created: Mon Mar 23 09:39:26 2009
* Copyright 2009 Tim Niemueller [www.niemueller.de]
*
****************************************************************************/
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. A runtime exception applies to
* this software (see LICENSE.GPL_WRE file mentioned below for details).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
*/
#ifndef __FIREVISION_MODELS_RELATIVE_POSITION_BALL_TRIGO_H_
#define __FIREVISION_MODELS_RELATIVE_POSITION_BALL_TRIGO_H_
#include <fvmodels/relative_position/relativepositionmodel.h>
namespace firevision {
#if 0 /* just to make Emacs auto-indent happy */
}
#endif
class BallTrigoRelativePos : public RelativePositionModel
{
public:
BallTrigoRelativePos(unsigned int image_width,
unsigned int image_height,
float camera_height,
float camera_offset_x,
float camera_offset_y,
float camera_base_pan,
float camera_base_tilt,
float horizontal_angle,
float vertical_angle,
float ball_circumference);
virtual const char * get_name() const;
virtual void set_radius(float r);
virtual void set_center(float x, float y);
virtual void set_center(const center_in_roi_t& c);
virtual void set_pan_tilt(float pan = 0.0f, float tilt = 0.0f);
virtual void get_pan_tilt(float *pan, float *tilt) const;
virtual float get_distance() const;
virtual float get_x() const;
virtual float get_y() const;
virtual float get_bearing() const;
virtual float get_slope() const;
virtual void calc();
virtual void calc_unfiltered() { calc(); }
virtual void reset();
virtual bool is_pos_valid() const;
private:
center_in_roi_t __cirt_center;
float __pan;
float __tilt;
float __horizontal_angle;
float __vertical_angle;
float __pan_rad_per_pixel;
float __tilt_rad_per_pixel;
unsigned int __image_width;
unsigned int __image_width_2; // image_width / 2
unsigned int __image_height;
unsigned int __image_height_2; // image_height / 2
float __camera_height;
float __camera_offset_x;
float __camera_offset_y;
float __camera_base_pan;
float __camera_base_tilt;
float __ball_circumference;
float __ball_radius;
float __ball_x;
float __ball_y;
float __bearing;
float __slope;
float __distance;
};
} // end namespace firevision
#endif
| [
"github@s.traiectum.net"
] | github@s.traiectum.net |
14cfbcf22c88abd60a09c4e8e711d58a7d8a8f44 | 2473fa1f15f7ee116b008e3ba9faef1af65230e1 | /fuse_core/src/async_publisher.cpp | 58054bd1c0b3053a2cb48a966d99fc3b98c3c282 | [
"BSD-3-Clause"
] | permissive | locusrobotics/fuse | c08ab905fb9368ec310812fe49e93bc180b8be21 | 6814698a3a850ec37bf0535240e0c0eb5dd64bdf | refs/heads/devel | 2023-08-17T04:03:38.390980 | 2023-08-16T22:07:48 | 2023-08-16T22:07:48 | 139,344,157 | 524 | 91 | NOASSERTION | 2023-08-16T22:07:49 | 2018-07-01T16:21:44 | C++ | UTF-8 | C++ | false | false | 3,698 | cpp | /*
* Software License Agreement (BSD License)
*
* Copyright (c) 2018, Locus Robotics
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <fuse_core/async_publisher.h>
#include <fuse_core/callback_wrapper.h>
#include <fuse_core/graph.h>
#include <fuse_core/transaction.h>
#include <ros/node_handle.h>
#include <boost/make_shared.hpp>
#include <functional>
#include <utility>
#include <string>
namespace fuse_core
{
AsyncPublisher::AsyncPublisher(size_t thread_count) :
name_("uninitialized"),
spinner_(thread_count, &callback_queue_)
{
}
void AsyncPublisher::initialize(const std::string& name)
{
// Initialize internal state
name_ = name;
node_handle_.setCallbackQueue(&callback_queue_);
private_node_handle_ = ros::NodeHandle("~/" + name_);
private_node_handle_.setCallbackQueue(&callback_queue_);
// Call the derived onInit() function to perform implementation-specific initialization
onInit();
// Start the async spinner to service the local callback queue
spinner_.start();
}
void AsyncPublisher::notify(Transaction::ConstSharedPtr transaction, Graph::ConstSharedPtr graph)
{
// Insert a call to the `notifyCallback` method into the internal callback queue.
// This minimizes the time spent by the optimizer's thread calling this function.
auto callback = boost::make_shared<CallbackWrapper<void>>(
std::bind(&AsyncPublisher::notifyCallback, this, std::move(transaction), std::move(graph)));
callback_queue_.addCallback(callback, reinterpret_cast<uint64_t>(this));
}
void AsyncPublisher::start()
{
auto callback = boost::make_shared<CallbackWrapper<void>>(std::bind(&AsyncPublisher::onStart, this));
auto result = callback->getFuture();
callback_queue_.addCallback(callback, reinterpret_cast<uint64_t>(this));
result.wait();
}
void AsyncPublisher::stop()
{
if (ros::ok())
{
auto callback = boost::make_shared<CallbackWrapper<void>>(std::bind(&AsyncPublisher::onStop, this));
auto result = callback->getFuture();
callback_queue_.addCallback(callback, reinterpret_cast<uint64_t>(this));
result.wait();
}
else
{
spinner_.stop();
onStop();
}
}
} // namespace fuse_core
| [
"noreply@github.com"
] | noreply@github.com |
6f3c3d780b939ac6b09d4e4b5ad62c18a1913558 | 502bfad29a399bc1a1ee7237ce523849d8e9f3a6 | /DP/shortest-common-supersequence.cpp | dbd42a18431edd65cb4a3598e880f2f38a06a8c7 | [] | no_license | shoifmohammad/DS-Algo | 9223ab4b426c8282e5ae8708eb18a85d364a8632 | 2a89402f2b2b3c5d781f1536847d6eb393e7ac99 | refs/heads/main | 2023-06-12T04:09:45.575624 | 2021-07-09T18:06:39 | 2021-07-09T18:06:39 | 353,276,462 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 755 | cpp | #include <bits/stdc++.h>
using namespace std;
int lcs(string s1, string s2) {
int n1 = s1.length(), n2 = s2.length();
int dp[n1+1][n2+1];
for(int i=0; i<=n1; i++) {
for(int j=0; j<=n2; j++) {
if(i == 0 || j == 0) {
dp[i][j] = 0;
continue;
}
if(s1[i-1] == s2[j-1])
dp[i][j] = 1+dp[i-1][j-1];
else
dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
}
}
return dp[n1][n2];
}
int shortestSuperSequence(string s1, string s2) {
return s1.length() + s2.length() - lcs(s1, s2);
}
int main() {
string s1 = "AGGTAB";
string s2 = "GXTXAYB";
cout << shortestSuperSequence(s1, s2) << "\n";
return 0;
} | [
"shoifmohammad@gmail.com"
] | shoifmohammad@gmail.com |
908c7f913dc06768dceec8327229d5469d1d898f | eb5eceea004041093f35415beeb85c75f4ce9cb5 | /trabalho 1004/Questao35/Questao35/stdafx.cpp | e353c0f1fa9257f2f45468079739c29344891b9b | [] | no_license | ivens-bruno/Logica_de_Programacao | 26c1d76f96848727afe1b6dd76e97806539d0ba5 | 972dfac9498b547d1ac7dff8a00059e9e13bcf43 | refs/heads/master | 2021-01-19T18:36:32.334929 | 2017-04-16T22:22:32 | 2017-04-16T22:22:32 | 88,368,984 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 310 | cpp | // stdafx.cpp : arquivo de origem que inclui apenas as inclusões padrões
// Questao35.pch será o cabeçalho pré-compilado
// stdafx.obj conterá as informações de tipo pré-compiladas
#include "stdafx.h"
// TODO: referencie qualquer cabeçalho adicional necessário em STDAFX.H
// e não neste arquivo
| [
"ivens_bruno@hotmail.com"
] | ivens_bruno@hotmail.com |
34aa10036cb879f97e19ad107dab0e1d2721f93c | 9169ca2e25a0eba1db159f88d2d434c0bf41c964 | /include/boost/asio/impl/dispatch.hpp | a013d2b945b1ba6fb21f059a4d77505b5f8b7e12 | [] | no_license | zcl/asio | 0e2c2eca7d684db172403ffc6d1f676443c40545 | 4c07b71c3377a614ad75c42108d7f17047a7bb4f | refs/heads/master | 2023-03-16T13:55:14.740954 | 2021-02-25T08:30:11 | 2021-02-25T08:30:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,707 | hpp | //
// impl/dispatch.hpp
// ~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_IMPL_DISPATCH_HPP
#define BOOST_ASIO_IMPL_DISPATCH_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <boost/asio/associated_allocator.hpp>
#include <boost/asio/associated_executor.hpp>
#include <boost/asio/detail/work_dispatcher.hpp>
#include <boost/asio/execution/allocator.hpp>
#include <boost/asio/execution/blocking.hpp>
#include <boost/asio/prefer.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace detail {
class initiate_dispatch
{
public:
template <typename CompletionHandler>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
typename enable_if<
execution::is_executor<
typename associated_executor<
typename decay<CompletionHandler>::type
>::type
>::value
>::type* = 0) const
{
typedef typename decay<CompletionHandler>::type handler_t;
typename associated_executor<handler_t>::type ex(
(get_associated_executor)(handler));
typename associated_allocator<handler_t>::type alloc(
(get_associated_allocator)(handler));
execution::execute(
boost::asio::prefer(ex,
execution::blocking.possibly,
execution::allocator(alloc)),
BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
}
template <typename CompletionHandler>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
typename enable_if<
!execution::is_executor<
typename associated_executor<
typename decay<CompletionHandler>::type
>::type
>::value
>::type* = 0) const
{
typedef typename decay<CompletionHandler>::type handler_t;
typename associated_executor<handler_t>::type ex(
(get_associated_executor)(handler));
typename associated_allocator<handler_t>::type alloc(
(get_associated_allocator)(handler));
ex.dispatch(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), alloc);
}
};
template <typename Executor>
class initiate_dispatch_with_executor
{
public:
typedef Executor executor_type;
explicit initiate_dispatch_with_executor(const Executor& ex)
: ex_(ex)
{
}
executor_type get_executor() const BOOST_ASIO_NOEXCEPT
{
return ex_;
}
template <typename CompletionHandler>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
typename enable_if<
execution::is_executor<
typename conditional<true, executor_type, CompletionHandler>::type
>::value
>::type* = 0,
typename enable_if<
!detail::is_work_dispatcher_required<
typename decay<CompletionHandler>::type,
Executor
>::value
>::type* = 0) const
{
typedef typename decay<CompletionHandler>::type handler_t;
typename associated_allocator<handler_t>::type alloc(
(get_associated_allocator)(handler));
execution::execute(
boost::asio::prefer(ex_,
execution::blocking.possibly,
execution::allocator(alloc)),
BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
}
template <typename CompletionHandler>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
typename enable_if<
execution::is_executor<
typename conditional<true, executor_type, CompletionHandler>::type
>::value
>::type* = 0,
typename enable_if<
detail::is_work_dispatcher_required<
typename decay<CompletionHandler>::type,
Executor
>::value
>::type* = 0) const
{
typedef typename decay<CompletionHandler>::type handler_t;
typedef typename associated_executor<
handler_t, Executor>::type handler_ex_t;
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
typename associated_allocator<handler_t>::type alloc(
(get_associated_allocator)(handler));
execution::execute(
boost::asio::prefer(ex_,
execution::blocking.possibly,
execution::allocator(alloc)),
detail::work_dispatcher<handler_t, handler_ex_t>(
BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex));
}
template <typename CompletionHandler>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
typename enable_if<
!execution::is_executor<
typename conditional<true, executor_type, CompletionHandler>::type
>::value
>::type* = 0,
typename enable_if<
!detail::is_work_dispatcher_required<
typename decay<CompletionHandler>::type,
Executor
>::value
>::type* = 0) const
{
typedef typename decay<CompletionHandler>::type handler_t;
typename associated_allocator<handler_t>::type alloc(
(get_associated_allocator)(handler));
ex_.dispatch(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), alloc);
}
template <typename CompletionHandler>
void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler,
typename enable_if<
!execution::is_executor<
typename conditional<true, executor_type, CompletionHandler>::type
>::value
>::type* = 0,
typename enable_if<
detail::is_work_dispatcher_required<
typename decay<CompletionHandler>::type,
Executor
>::value
>::type* = 0) const
{
typedef typename decay<CompletionHandler>::type handler_t;
typedef typename associated_executor<
handler_t, Executor>::type handler_ex_t;
handler_ex_t handler_ex((get_associated_executor)(handler, ex_));
typename associated_allocator<handler_t>::type alloc(
(get_associated_allocator)(handler));
ex_.dispatch(detail::work_dispatcher<handler_t, handler_ex_t>(
BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler),
handler_ex), alloc);
}
private:
Executor ex_;
};
} // namespace detail
template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) dispatch(
BOOST_ASIO_MOVE_ARG(CompletionToken) token)
{
return async_initiate<CompletionToken, void()>(
detail::initiate_dispatch(), token);
}
template <typename Executor,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken>
BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) dispatch(
const Executor& ex, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
typename enable_if<
execution::is_executor<Executor>::value || is_executor<Executor>::value
>::type*)
{
return async_initiate<CompletionToken, void()>(
detail::initiate_dispatch_with_executor<Executor>(ex), token);
}
template <typename ExecutionContext,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken>
inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) dispatch(
ExecutionContext& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
typename enable_if<is_convertible<
ExecutionContext&, execution_context&>::value>::type*)
{
return async_initiate<CompletionToken, void()>(
detail::initiate_dispatch_with_executor<
typename ExecutionContext::executor_type>(
ctx.get_executor()), token);
}
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_IMPL_DISPATCH_HPP
| [
"chris@kohlhoff.com"
] | chris@kohlhoff.com |
66dea4e83d0f513331097353c3b11cc00637d4ed | ffcc7adaba1295576924db445faa51678f18fa4c | /is_prime.cpp | 1d8c3ac627114c5ba14a50d4b3d82fdec779c4ae | [] | no_license | gdeepanshu46/coding-dsa | 62a7ddbbc1c0728730c88db80dd9b13a35c1af48 | 9332f749b76b5a2fca8626b4145dcc39d1e82db0 | refs/heads/master | 2022-12-22T02:38:56.567201 | 2020-09-21T03:36:41 | 2020-09-21T03:36:41 | 286,990,450 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 940 | cpp | //According to Fundamental Theorem of Arithmetic, every positive whole number can be
//written as the unique product of primes. This is the reason why 1 is not a prime no.
//15 = 5*3 correct
//15 = 1*5*3 or 1*1*5*3 violates the Theorem
#include <bits/stdc++.h>
using namespace std;
//Time : O(sqrt(n))
bool isPrime(int n){
if(n == 0 || n == 1) return 0;
for(int i=2; i<=sqrt(n); i++){
if(n%i == 0) return 0;
}
return 1;
}
//Every prime no can be expressed in the form of 6*n + 1 or 6*n - 1 except 2 and 3
//But not every no that can be expressed in this form is a prime
//this method can be only used to weed out some possibilities
//Time : O(1)
bool isPrime_(long long n){
if(n <= 1) return 0;
if(n <= 3) return 1;
int left = n-1;
int right = n+1;
if(left%6 == 0 || right%6 == 0) return 1;
return 0;
}
int main(){
int t; cin>>t;
while(t--){
long long n; cin>>n;
cout << isPrime_(n) << endl;
}
return 0;
} | [
"gdeepanshu46@gmail.com"
] | gdeepanshu46@gmail.com |
dd0c06ed8354899245808809c2256711ecffd721 | f83ef53177180ebfeb5a3e230aa29794f52ce1fc | /ACE/ACE_wrappers/TAO/orbsvcs/tests/InterfaceRepo/Latency_Test/Latency_Query_Client.h | 9debce055302094ed08e13a518a7c1c57897ea5d | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-sun-iiop"
] | permissive | msrLi/portingSources | fe7528b3fd08eed4a1b41383c88ee5c09c2294ef | 57d561730ab27804a3172b33807f2bffbc9e52ae | refs/heads/master | 2021-07-08T01:22:29.604203 | 2019-07-10T13:07:06 | 2019-07-10T13:07:06 | 196,183,165 | 2 | 1 | Apache-2.0 | 2020-10-13T14:30:53 | 2019-07-10T10:16:46 | null | UTF-8 | C++ | false | false | 1,657 | h | // -*- C++ -*-
//=============================================================================
/**
* @file Latency_Query_Client.h
*
* This class tests the latency of queries made on the IFR.
*
* @author Jeff Parsons <parsons@isis-server.isis.vanderbilt.edu>
*/
//=============================================================================
#if !defined (LATENCY_QUERY_CLIENT_H)
#define LATENCY_QUERY_CLIENT_H
#include "tao/IFR_Client/IFR_BasicC.h"
#include "tao/ORB.h"
/**
* @class Latency_Query_Client
*
* @brief Querying IFR Client Implementation
*
* Class wrapper for a client which queries the Interface Repository.
*/
class Latency_Query_Client
{
public:
/// Constructor
Latency_Query_Client (void);
/// Destructor
~Latency_Query_Client (void);
/// Initialize the ORB and get the IFR object reference.
int init (int argc,
ACE_TCHAR *argv[]);
/// Execute test code.
int run (void);
private:
/// Process the command line arguments.
int parse_args (int argc,
ACE_TCHAR *argv[]);
/// Put in something to query about.
int populate_ifr (void);
private:
/// Toggle debugging output.
bool debug_;
/// Toggle saving of dump history.
bool do_dump_history_;
/// Number of queries in a run.
CORBA::ULong iterations_;
/// Storage of the ORB reference.
CORBA::ORB_var orb_;
/// Storage of the IFR reference.
CORBA::Repository_var repo_;
// CORBA::AliasDef_var tdef_;
// Storage of the typedef definition that we will query.
/// Storage of the attribute definition we will query.
CORBA::AttributeDef_var attr_;
};
#endif /* LATENCY_QUERY_CLIENT_H */
| [
"lihuibin705@163.com"
] | lihuibin705@163.com |
58dd4a37bbf59c8b035ac7efd62f1cc3eb343972 | 56a0cc85155605f94571a0701efa6e582d51a467 | /SW_Expert_Academy/SW_Expert_Academy/5656.cpp | 81e58bb3454a972fd9d25c518371333aac9bc365 | [] | no_license | morecreativa/Algorithm_Practice | ec16282fd4c64c1910a7c29338eb614d7d563548 | f4cba6af47ffb450864a183cae5fdf90c1112251 | refs/heads/master | 2022-01-24T02:27:41.937382 | 2022-01-07T10:56:58 | 2022-01-07T10:56:58 | 232,247,649 | 2 | 1 | null | null | null | null | UHC | C++ | false | false | 1,686 | cpp | //5656 벽돌깨기
#include <iostream>
using namespace std;
int ans = INT32_MAX;
int map[15][12];
int n, w, h;
void mapremove(int cx, int cy)
{
int mp = map[cx][cy];
map[cx][cy] = 0;
if (mp == 1) return;
for (int a = cx - mp + 1; a <= cx + mp - 1; a++)
{
if (a >= 0 && a <= h - 1 && map[a][cy] != 0 && a != cx) mapremove(a, cy);
}
for (int b = cy - mp + 1; b <= cy + mp - 1; b++)
{
if (b >= 0 && b <= w - 1 && b != cy && map[cx][b] != 0) mapremove(cx, b);
}
return;
}
void pull()
{
for (int i = 0; i < w; i++)
for (int j = h - 1; j >= 0; j--) {
if (map[j][i] == 0)
{
for (int x = j - 1; x >= 0; x--)
if (map[x][i] != 0)
{
map[j][i] = map[x][i];
map[x][i] = 0;
break;
}
}
}
return;
}
void lego(int i)
{
if (i == n) {
int temp = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
if (map[i][j] != 0)temp++;
if (ans > temp)ans = temp;
return;
}
int tmap[15][12];
for (int x = 0; x < h; x++)
for (int y = 0; y < w; y++)
tmap[x][y] = map[x][y];
for (int x = 0; x < w; x++)
for (int y = 0; y < h; y++)
{
if (map[y][x] != 0)
{
mapremove(y, x);
pull();
lego(i + 1);
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
{
map[i][j] = tmap[i][j];
}
break;
}
}
}
int main()
{
int T, test_case;
cin >> T;
for (test_case = 0; test_case < T; test_case++)
{
cin >> n >> w >> h;
ans = INT32_MAX;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++)
{
cin >> map[i][j];
}
lego(0);
if (ans == INT32_MAX) ans = 0;
cout << '#' << test_case + 1 << ' ' << ans << endl;
//초기화 작업
}
return 0;
} | [
"morecreativa@naver.com"
] | morecreativa@naver.com |
25f4e809df9a883b43c1852e1ea52be193826f52 | c3dee65885f52cc3abefe5fd1a36662f7ec8c59f | /kernel/utils/utils.h | 3df0abd413016dfbffade7174b41c88d07375c33 | [] | no_license | yuan39/SlardarOS | bedb0cc4ef1bfdb09d8e4c4520ab53dd775cfe9d | 8b9f806202ba59410690cef5986ee7309d3cdb0c | refs/heads/master | 2021-05-01T05:30:18.983781 | 2016-11-04T00:36:32 | 2016-11-04T00:36:32 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 211 | h | #ifndef __UTILS_H
#define __UTILS_H
#include "defs.h"
#include "io/io.h"
#include "test/assert.h"
#include "new"
namespace os {
namespace utils {
void setSegmentRegisters(uint16_t);
} // utils
} // os
#endif | [
"zhangshangtong.cpp@icloud.com"
] | zhangshangtong.cpp@icloud.com |
3e762c15ae742229fb06b1c444695210c87ed8d4 | b012b15ec5edf8a52ecf3d2f390adc99633dfb82 | /releases/moos-ivp-4.0/ivp/src/pMarinePID/MarinePID.h | db8de8ff42a201a7f0508096498e1f3296597d88 | [] | no_license | crosslore/moos-ivp-aro | cbe697ba3a842961d08b0664f39511720102342b | cf2f1abe0e27ccedd0bbc66e718be950add71d9b | refs/heads/master | 2022-12-06T08:14:18.641803 | 2020-08-18T06:39:14 | 2020-08-18T06:39:14 | 263,586,714 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,598 | h | /*****************************************************************/
/* NAME: Michael Benjamin and John Leonard */
/* ORGN: NAVSEA Newport RI and MIT Cambridge MA */
/* FILE: MarinePID.h */
/* DATE: April 10 2006 */
/* */
/* This program is free software; you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation; either version */
/* 2 of the License, or (at your option) any later version. */
/* */
/* This program is distributed in the hope that it will be */
/* useful, but WITHOUT ANY WARRANTY; without even the implied */
/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
/* PURPOSE. See the GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with this program; if not, write to the Free */
/* Software Foundation, Inc., 59 Temple Place - Suite 330, */
/* Boston, MA 02111-1307, USA. */
/*****************************************************************/
#ifndef MARINE_PID_HEADER
#define MARINE_PID_HEADER
#include <string>
#include "MOOSLib.h"
#include "PIDEngine.h"
class MarinePID : public CMOOSApp
{
public:
MarinePID();
virtual ~MarinePID() {};
bool OnNewMail(MOOSMSG_LIST &NewMail);
bool Iterate();
bool OnConnectToServer();
bool OnStartUp();
void postCharStatus();
void postAllStop();
void registerVariables();
bool handleYawSettings();
bool handleSpeedSettings();
bool handleDepthSettings();
protected:
bool m_has_control;
bool m_allow_overide;
bool m_allstop_posted;
double m_speed_factor;
double m_current_heading;
double m_current_speed;
double m_current_depth;
double m_current_pitch;
double m_desired_heading;
double m_desired_speed;
double m_desired_depth;
double m_current_thrust;
double m_max_pitch;
double m_max_rudder;
double m_max_thrust;
double m_max_elevator;
PIDEngine m_pengine;
std::string m_verbose;
int m_iteration;
double m_start_time;
bool m_depth_control;
bool m_paused;
double m_time_of_last_helm_msg;
double m_time_of_last_nav_msg;
};
#endif
| [
"zouxueson@hotmail.com"
] | zouxueson@hotmail.com |
f7fe41b7eacd40aaedcc904725d691d86ff38fa6 | 0079e84d43992b419221bd640a1817409b35e585 | /839数据结构/c语言/输出x的所有祖先结点.cpp | 1a1767b5fa199eac2d06a8e6588278222fe567f6 | [] | no_license | JayGitH/839C-language-and-data-structure | 2c8f467736bf5504b7c9811d89ebbaa9949adcfd | 009edfeaecef8e23536e3ef7b90ed79a8fbf9956 | refs/heads/master | 2020-05-07T14:26:58.190633 | 2018-12-24T01:17:37 | 2018-12-24T01:17:37 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 495 | cpp | /*
Name: 输出x的所有祖先结点
Copyright:
Author: 11楼
Date: 15/12/18 20:00
Description: 我做了一定修改
*/
typedef struct Tree {
int data;
Tree *lchild;
Tree *rchild;
}Tree;
int IsAnce(Tree *t,int x) {
if (t) {
if (t->data == x)
return 1;
else
return IsAnce(t->lchild, x) || IsAnce(t->rchild, x);
}
return 0;
}
void OutX(Tree *t,int x) {
if (IsAnce(t,x))
printf("%d", t->data);/*这一句是递归出口*/
OutX(t->lchild, x);
OutX(t->rchild, x);
}
| [
"37898999+lingr7@users.noreply.github.com"
] | 37898999+lingr7@users.noreply.github.com |
47cdca64cfbe2419581726095a314d52d2ce458f | b0528fa1c74e45222358df0f8203d1a6bb2641e4 | /WatchList.h | 8d4548a4aea3f080ed7e2f1a63b9621101b2340c | [] | no_license | GavriloviciEduard/Polymorphic-UNDO | 62a79a245fa80303d1ee3048ab726776628f7dac | 6c57ee2ab414c71f23455ec29ddb5ec6341c70d6 | refs/heads/master | 2020-03-17T05:56:29.556226 | 2018-05-14T09:11:12 | 2018-05-14T09:11:12 | 133,334,405 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 464 | h | #pragma once
#include "vector"
#include "Movie.h"
#include <algorithm>
class WatchList
{
protected:
std::vector<Movie> wlist;
public:
int add_wlist(const Movie& mv);
int remove_wlist(const std::string& title, const int& year);
int find_wlist(const std::string title, const int& year);
int get_sizeWL() { return (int)this->wlist.size(); }
std::vector<Movie> get_WL() { return this->wlist; }
virtual ~WatchList() {}
};
| [
"noreply@github.com"
] | noreply@github.com |
2cc80edf0e9e3500a6d3df19ec0fe7c47b916c3d | a56252fda5c9e42eff04792c6e16e413ad51ba1a | /resources/home/dnanexus/root/include/TGeoMaterial.h | f554e533ca9d81c74cc48e678067929ce6940fce | [
"LGPL-2.1-or-later",
"LGPL-2.1-only",
"Apache-2.0"
] | permissive | edawson/parliament2 | 4231e692565dbecf99d09148e75c00750e6797c4 | 2632aa3484ef64c9539c4885026b705b737f6d1e | refs/heads/master | 2021-06-21T23:13:29.482239 | 2020-12-07T21:10:08 | 2020-12-07T21:10:08 | 150,246,745 | 0 | 0 | Apache-2.0 | 2019-09-11T03:22:55 | 2018-09-25T10:21:03 | Python | UTF-8 | C++ | false | false | 9,831 | h | // @(#)root/geom:$Id$
// Author: Andrei Gheata 25/10/01
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TGeoMaterial
#define ROOT_TGeoMaterial
#include "TNamed.h"
#include "TAttFill.h"
#include "TGeoElement.h"
// forward declarations
class TGeoExtension;
// Some units used in G4
static const Double_t STP_temperature = 273.15; // [K]
static const Double_t STP_pressure = 6.32420e+8; // [MeV/mm3]
class TGeoMaterial : public TNamed,
public TAttFill
{
public:
enum EGeoMaterial {
kMatUsed = BIT(17),
kMatSavePrimitive = BIT(18)
};
enum EGeoMaterialState {
kMatStateUndefined,
kMatStateSolid,
kMatStateLiquid,
kMatStateGas
};
protected:
Int_t fIndex; // material index
Double_t fA; // A of material
Double_t fZ; // Z of material
Double_t fDensity; // density of material
Double_t fRadLen; // radiation length
Double_t fIntLen; // interaction length
Double_t fTemperature; // temperature
Double_t fPressure; // pressure
EGeoMaterialState fState; // material state
TObject *fShader; // shader with optical properties
TObject *fCerenkov; // pointer to class with Cerenkov properties
TGeoElement *fElement; // pointer to element composing the material
TGeoExtension *fUserExtension; //! Transient user-defined extension to materials
TGeoExtension *fFWExtension; //! Transient framework-defined extension to materials
// methods
TGeoMaterial(const TGeoMaterial&);
TGeoMaterial& operator=(const TGeoMaterial&);
public:
// constructors
TGeoMaterial();
TGeoMaterial(const char *name);
TGeoMaterial(const char *name, Double_t a, Double_t z,
Double_t rho, Double_t radlen=0, Double_t intlen=0);
TGeoMaterial(const char *name, Double_t a, Double_t z, Double_t rho,
EGeoMaterialState state, Double_t temperature=STP_temperature, Double_t pressure=STP_pressure);
TGeoMaterial(const char *name, TGeoElement *elem, Double_t rho);
// destructor
virtual ~TGeoMaterial();
// methods
static Double_t Coulomb(Double_t z);
// radioactive mixture evolution
virtual TGeoMaterial *DecayMaterial(Double_t time, Double_t precision=0.001);
virtual void FillMaterialEvolution(TObjArray *population, Double_t precision=0.001);
// getters & setters
virtual Int_t GetByteCount() const {return sizeof(*this);}
virtual Double_t GetA() const {return fA;}
virtual Double_t GetZ() const {return fZ;}
virtual Int_t GetDefaultColor() const;
virtual Double_t GetDensity() const {return fDensity;}
virtual Int_t GetNelements() const {return 1;}
virtual TGeoElement *GetElement(Int_t i=0) const;
virtual void GetElementProp(Double_t &a, Double_t &z, Double_t &w, Int_t i=0);
TGeoElement *GetBaseElement() const {return fElement;}
char *GetPointerName() const;
virtual Double_t GetRadLen() const {return fRadLen;}
virtual Double_t GetIntLen() const {return fIntLen;}
Int_t GetIndex();
virtual TObject *GetCerenkovProperties() const {return fCerenkov;}
Char_t GetTransparency() const {return (fFillStyle<3000 || fFillStyle>3100)?0:Char_t(fFillStyle-3000);}
Double_t GetTemperature() const {return fTemperature;}
Double_t GetPressure() const {return fPressure;}
EGeoMaterialState GetState() const {return fState;}
virtual Double_t GetSpecificActivity(Int_t) const {return 0.;}
TGeoExtension *GetUserExtension() const {return fUserExtension;}
TGeoExtension *GetFWExtension() const {return fFWExtension;}
TGeoExtension *GrabUserExtension() const;
TGeoExtension *GrabFWExtension() const;
virtual Bool_t IsEq(const TGeoMaterial *other) const;
Bool_t IsUsed() const {return TObject::TestBit(kMatUsed);}
virtual Bool_t IsMixture() const {return kFALSE;}
virtual void Print(const Option_t *option="") const;
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void SetA(Double_t a) {fA = a; SetRadLen(0);}
virtual void SetZ(Double_t z) {fZ = z; SetRadLen(0);}
virtual void SetDensity(Double_t density) {fDensity = density; SetRadLen(0);}
void SetIndex(Int_t index) {fIndex=index;}
virtual void SetCerenkovProperties(TObject* cerenkov) {fCerenkov = cerenkov;}
void SetRadLen(Double_t radlen, Double_t intlen=0.);
void SetUsed(Bool_t flag=kTRUE) {TObject::SetBit(kMatUsed, flag);}
void SetTransparency(Char_t transparency=0) {fFillStyle = 3000+transparency;}
void SetTemperature(Double_t temperature) {fTemperature = temperature;}
void SetPressure(Double_t pressure) {fPressure = pressure;}
void SetState(EGeoMaterialState state) {fState = state;}
void SetUserExtension(TGeoExtension *ext);
void SetFWExtension(TGeoExtension *ext);
static Double_t ScreenFactor(Double_t z);
ClassDef(TGeoMaterial, 5) // base material class
//***** Need to add classes and globals to LinkDef.h *****
};
class TGeoMixture : public TGeoMaterial
{
protected :
// data members
Int_t fNelements; // number of elements
Double_t *fZmixture; // [fNelements] array of Z of the elements
Double_t *fAmixture; // [fNelements] array of A of the elements
Double_t *fWeights; // [fNelements] array of relative proportions by mass
Int_t *fNatoms; // [fNelements] array of numbers of atoms
Double_t *fVecNbOfAtomsPerVolume; //[fNelements] array of numbers of atoms per unit volume
TObjArray *fElements; // array of elements composing the mixture
// methods
TGeoMixture(const TGeoMixture&); // Not implemented
TGeoMixture& operator=(const TGeoMixture&); // Not implemented
void AverageProperties();
public:
// constructors
TGeoMixture();
TGeoMixture(const char *name, Int_t nel, Double_t rho=-1);
// destructor
virtual ~TGeoMixture();
// methods for adding elements
void AddElement(Double_t a, Double_t z, Double_t weight);
void AddElement(TGeoMaterial *mat, Double_t weight);
void AddElement(TGeoElement *elem, Double_t weight);
void AddElement(TGeoElement *elem, Int_t natoms);
// backward compatibility for defining elements
void DefineElement(Int_t iel, Double_t a, Double_t z, Double_t weight);
void DefineElement(Int_t iel, TGeoElement *elem, Double_t weight);
void DefineElement(Int_t iel, Int_t z, Int_t natoms);
// radioactive mixture evolution
virtual TGeoMaterial *DecayMaterial(Double_t time, Double_t precision=0.001);
virtual void FillMaterialEvolution(TObjArray *population, Double_t precision=0.001);
// getters
virtual Int_t GetByteCount() const {return 48+12*fNelements;}
virtual TGeoElement *GetElement(Int_t i=0) const;
virtual void GetElementProp(Double_t &a, Double_t &z, Double_t &w, Int_t i=0) {a=fAmixture[i]; z=fZmixture[i]; w=fWeights[i];}
virtual Int_t GetNelements() const {return fNelements;}
Double_t *GetZmixt() const {return fZmixture;}
Double_t *GetAmixt() const {return fAmixture;}
Double_t *GetWmixt() const {return fWeights;}
Int_t *GetNmixt() const {return fNatoms;}
virtual Double_t GetSpecificActivity(Int_t i=-1) const;
// utilities
virtual Bool_t IsEq(const TGeoMaterial *other) const;
virtual Bool_t IsMixture() const {return kTRUE;}
virtual void Print(const Option_t *option="") const;
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void SetA(Double_t a) {fA = a;}
virtual void SetZ(Double_t z) {fZ = z;}
virtual void SetDensity(Double_t density) {fDensity = density; AverageProperties();}
void ComputeDerivedQuantities();
void ComputeRadiationLength();
void ComputeNuclearInterLength();
ClassDef(TGeoMixture, 3) // material mixtures
};
inline void TGeoMixture::DefineElement(Int_t, Double_t a, Double_t z, Double_t weight)
{return AddElement(a,z,weight);}
inline void TGeoMixture::DefineElement(Int_t, TGeoElement *elem, Double_t weight)
{return AddElement(elem,weight);}
#endif
| [
"slzarate96@gmail.com"
] | slzarate96@gmail.com |
5f8e619bb636bfca52b13079a24ade6e50c8d9e8 | 69b790fc8af3fb04c0f9eb3ef91a8fac4615271a | /src/canvas.cpp | 05e3da295d3d927928ad5ca866d5dc1b1f560a68 | [
"MIT"
] | permissive | rokn/DigitRecognition | 57c199ab77dc03e0a260df5791c3b924c5ab6d2b | 7ba7395c880eaad680caec4a851d632cbcc4f1d4 | refs/heads/master | 2021-01-19T05:14:07.093164 | 2016-06-11T21:05:02 | 2016-06-11T21:05:02 | 60,648,914 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,347 | cpp | #include "canvas.hpp"
#include <cmath>
namespace recognize
{
Canvas::Canvas(int canvasWidth, int canvasHeight, sf::RenderWindow& window)
: _window(window)
{
_canvasWidth = canvasWidth;
_canvasHeight = canvasHeight;
_canvas = new sf::RenderTexture();
_canvas->create(_canvasWidth, _canvasHeight);
Clear(sf::Color::White);
setTexture(_canvas->getTexture());
}
Canvas::~Canvas()
{
delete _canvas;
if(_drawShape == NULL)
{
delete _drawShape;
}
_drawShape;
}
void Canvas::SetShape(sf::Shape* shape)
{
if(_drawShape == NULL)
{
delete _drawShape;
}
_drawShape = shape;
}
sf::Shape& Canvas::GetShape()
{
return *_drawShape;
}
void Canvas::DrawShape()
{
sf::Vector2i mPos = sf::Mouse::getPosition(_window);
mPos.y = abs(mPos.y - (int)_window.getSize().y);
sf::Vector2f mMapped = _window.mapPixelToCoords(mPos);
mMapped.x -= getPosition().x;
mMapped.y -= getPosition().y;
DrawShape(mMapped);
}
void Canvas::DrawShape(sf::Vector2f position)
{
_drawShape->setPosition(position);
_canvas->draw(*_drawShape);
}
void Canvas::Clear(sf::Color clearColor)
{
_canvas->clear(clearColor);
}
void Canvas::GetPixels(int& pixelsCount, sf::Image* pixels) const
{
pixelsCount = _canvas->getSize().x * _canvas->getSize().y;
*pixels = _canvas->getTexture().copyToImage();
}
}
| [
"amindov@abv.bg"
] | amindov@abv.bg |
aa747371851966c6a6cd57818fc9c731c916bb12 | 89589cf869727039920f1ccfdab4594b4f712cad | /stdafx.cpp | 265de01783a6c621db89eda0e2853f793d37d258 | [] | no_license | oyefremov/sudoku | a79b68fec0577cf3bd63f74995c1c53cae0a9f20 | 39c218a1b34ead59fb1576c3f8ca6aeb40b8f348 | refs/heads/master | 2021-01-09T02:41:51.963520 | 2020-02-21T19:53:20 | 2020-02-21T19:53:20 | 242,219,562 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 199 | cpp | // stdafx.cpp : source file that includes just the standard includes
// sudoku.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
| [
"oleksandr.yefremov@gmail.com"
] | oleksandr.yefremov@gmail.com |
7dfd91f4274074c64cecc08137d784591c5c70d8 | 5f43dc746e8728b6c6326134b06a44f5712eeaab | /Special C Program/机器人走迷宫.cpp | 52b5f916cc79d9a0d9a86294d18638e66007c652 | [] | no_license | TianMaXingKong2003/C-and-C-plus-plus | 65c7c853478355250f7b434c0d26b1b1703cabb6 | 920681f6c93ab5c72ac64fdd0bffd0371602ee74 | refs/heads/master | 2022-05-30T18:57:44.262689 | 2022-05-27T08:49:53 | 2022-05-27T08:49:53 | 103,086,401 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,464 | cpp | #include<iostream>
#include<string>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<windows.h>
#define maxn 21
using namespace std;
int nx=0,ny=0;
int x=0;
int steps=0;
int fx[4][2]={-1,0,1,0,0,-1,0,1};
int M[maxn][maxn]={ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,
0,1,1,1,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,
0,0,0,1,1,1,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,
0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,1,0,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,
0,0,0,1,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,0,
0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,
0,0,0,1,0,1,0,0,1,1,0,0,0,1,0,0,1,1,1,0,0,
0,0,0,1,1,1,0,1,1,0,0,0,0,1,0,0,1,0,1,0,0,
0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,1,1,0,
0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,
0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
int robot[maxn][maxn]={0}; // 记录机器人的路径
void show()
{
for(int i=0;i<27;i++)
cout<<"#";cout<<endl;
cout<<"# #"<<endl;
for(int i=0;i<14;i++)
{
cout<<"# ";
for(int j=0;j<21;j++)
{
if(i==nx&&j==ny)
cout<<"@";
else
if(M[i][j])
cout<<" ";
else
cout<<"*";
}
cout<<" #";cout<<endl;
}
cout<<"# #"<<endl;
for(int i=0;i<27;i++)
cout<<"#";cout<<endl;
//cout<<endl<<"由方向键控制\n"<<endl;
cout<<endl<<"步数\t"<<steps<<endl<<endl;
}
int cango(int x,int y)
{
if(M[x][y]==1)
return 1;
else
{
cout<<"Can't go"<<endl;
return 0;
}
}
void dfs(int x,int y) // 深度优先搜索算法
{
if(x==13&&y==20)
{
steps++;
while(nx!=x&&ny!=y)
{
for(int i=0;i<4;i++)
{
int n_x=nx+fx[i][0];
int n_y=ny+fx[i][1];
if(robot[n_x][n_y]==4)
{
nx=n_x;ny=n_y;
robot[n_x][n_y]=3;
system("cls");
show();
Sleep(300);
steps++;
}
}
}
}
else{
for(int i=0;i<4;i++)
{
int nextx=x+fx[i][0];
int nexty=y+fx[i][1];
if(nextx>=0&&nexty>=0&&nextx<=13&&nexty<=20&&M[nextx][nexty]&&robot[nextx][nexty]!=4)
{
robot[nextx][nexty]=4;
dfs(nextx,nexty);
robot[nextx][nexty]=0;
}
}
}
}
void Ai()
{
dfs(nx,ny);
}
int main()
{
string name;
cout<<"================================"<<endl;
cout<<"\t欢迎来到勇者迷宫!"<<endl;
cout<<"================================"<<endl;
cout<<endl<<"输入账号名robot即可调用AI算法\n"<<endl;
cout<<"请输入您的用户名:";cin>>name;
system("cls");
if(name=="robot") // Ai算法
Ai();
else // 游戏模式
{
int begintime=clock();
show();steps++;
//按键检测 72 80 75 77
while(nx!=13&&ny!=22)
{
if(kbhit()!=0)
{
getch();x=getch();
}
if(x==72) //上
{
if(cango(nx-1,ny))
{
nx-=1;
system("cls");
show();steps++;
}
x=0;
}
if(x==80) //下
{
if(cango(nx+1,ny))
{
nx+=1;
system("cls");
show();
steps++;
} x=0;
}
if(x==75) //左
{
if(cango(nx,ny-1))
{
ny-=1;
system("cls");
show();
steps++;
}x=0;
}
if(x==77) //右
{
if(cango(nx,ny+1))
{
ny+=1;
system("cls");
show();
steps++;
}x=0;
}
}
int endtime=clock();
cout<<endl<<"恭喜你走出迷宫!"<<endl<<endl;
cout<<name<<"的总用时为:"<<(endtime-begintime)/1000<<"秒"<<endl;
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
966586518da537e9eef6b8ce5ce6b1b79e516735 | f9451e836cbd9c8a8d1e1ed3ce7db92a9cf3c294 | /src/Level.cpp | 64df3abdaa6fa79101c2aa6aea93e6ab0fe28108 | [] | no_license | exomo/Snake | 85bf28f733c4a089596ea9d9af4c29cbc168f196 | cb23ddb0cc766f971c6a3a301d49daa667850603 | refs/heads/master | 2020-05-03T16:35:15.350347 | 2019-03-31T18:37:27 | 2019-03-31T18:37:27 | 178,726,098 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,475 | cpp | #include "Level.h"
#include <sstream>
#include "utf8stream.h"
using namespace ExomoSnake;
Level::Level()
: name(L"Bis zum bitteren Ende")
, pointsToWin(150)
, speed(200)
, startPosition(2,2)
{
// Default level ist eine Wand an allen Rändern
for(int x=0; x<sizeX; ++x)
{
field[x][0] = '*';
field[x][sizeY-1] = '*';
}
for(int y=0; y<sizeY; ++y)
{
field[0][y] = '*';
field[sizeX-1][y] = '*';
}
}
int Level::GetPointsToWin() const
{
return pointsToWin;
}
TileType Level::GetTileType(int x, int y) const
{
return (field[x][y] == '*') ? TileType::Wall : TileType::Empty;
}
const std::wstring& Level::GetName() const
{
return name;
}
int Level::GetSpeed() const
{
return speed;
}
std::pair<int,int> Level::GetStartPosition() const
{
return startPosition;
}
Direction Level::GetStartDirection() const
{
return startDirection;
}
void Level::LoadFromFile(const std::string& filename)
{
std::wifstream file;
openUtf8ForReading(file, filename);
std::wstring line;
int y = 0;
// Die erste Zeile ist der Name des Levels
std::getline(file, name);
// Die zweite Zeile enthält die Punkte zum Gewinnen und die Geschwindigkeit
std::getline(file, line);
std::wistringstream iss(line);
iss >> pointsToWin >> speed;
if(pointsToWin < 1 || pointsToWin > 230)
{
throw loadlevel_exception(filename, "Ungültige Angabe für Punkte");
}
if(speed < 20 || speed > 1000)
{
throw loadlevel_exception(filename, "Ungültige Angabe für Geschwindigkeit");
}
// Alle anderen Zeilen beschreiben das Spielfeld
while(std::getline(file, line))
{
// Wenn mehr Zeilen in der Datei sind als das Spielfeld hat wird eine exception geworfen
if(y >= sizeY)
{
throw loadlevel_exception(filename, "Zu viele Zeilen");
}
// Zeilen müssen genau die richtige Länge haben
if(line.length() != sizeX)
{
std::cout << line.length() << std::endl;
throw loadlevel_exception(filename, "Zeile hat eine falsche Länge");
}
for(int x = 0; x < sizeX; ++x)
{
// Wand wird gespeichert
switch(line[x])
{
case '*':
case 'X':
case 'x':
field[x][y] = '*';
break;
case '<':
field[x][y] = ' ';
startPosition = std::make_pair(x,y);
startDirection = Direction::Left;
break;
case '>':
field[x][y] = ' ';
startPosition = std::make_pair(x,y);
startDirection = Direction::Right;
break;
case '^':
field[x][y] = ' ';
startPosition = std::make_pair(x,y);
startDirection = Direction::Up;
break;
case 'v':
field[x][y] = ' ';
startPosition = std::make_pair(x,y);
startDirection = Direction::Down;
break;
default:
field[x][y] = ' ';
break;
}
}
++y;
}
// Wenn weniger Zeilen in der Datei sind als das Spielfeld hat wird eine exception geworfen
if(y < sizeY)
{
throw loadlevel_exception(filename, "Zu wenige Zeilen");
}
}
| [
"exomo@gmx.de"
] | exomo@gmx.de |
5231660d2771879d6139bbcadbb80ba88464579a | 7dd75e1397942261f7cded76cdb8bb596c6bc032 | /paxos/ClientRegistrar.cpp | 8efe3ce7218d82309b259dc9ef3ea9cb0820f465 | [] | no_license | bhan/nos-cpp | a570f34d2def8c1f88b78c77311c479e00297f7b | c5be2e746a35ef158d4d930ad268d13a84ed9c63 | refs/heads/master | 2021-01-09T07:04:39.085059 | 2014-12-11T21:27:43 | 2014-12-11T21:27:43 | 27,895,528 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 866 | cpp | #include <string>
#include <typeinfo>
#include <unordered_map>
#include "../nos/NOSClientTypeUtil.hpp"
#include "AcceptorGenerated.hpp"
ClientObj* constructAcceptorClient(std::string name, NOSClient* client, std::string address, int port) {
return new AcceptorClient(name, client, address, port);
}
NOSClientTypeUtil::NOSClientTypeUtil() {
_client_nameToFunc[typeid(AcceptorAgent).name()] = &constructAcceptorClient; // AUTO
}
ClientObj* NOSClientTypeUtil::getClientObjFromAgentName(
const std::string type_name, const std::string name, NOSClient* client,
std::string address, int port) const {
const auto got = _client_nameToFunc.find(type_name);
if (got == _client_nameToFunc.end()) {
return nullptr;
}
const auto func = got->second;
return func(name, client, address, port); // call the specific constructor
}
| [
"bo.ning.han@gmail.com"
] | bo.ning.han@gmail.com |
66a90303e2b82305945469dfed4343f3ff53fe75 | 948f4e13af6b3014582909cc6d762606f2a43365 | /testcases/juliet_test_suite/testcases/CWE762_Mismatched_Memory_Management_Routines/s01/CWE762_Mismatched_Memory_Management_Routines__delete_array_int_malloc_02.cpp | 7cb610ee9fd2908a3421ec67dac304c8db2c6328 | [] | no_license | junxzm1990/ASAN-- | 0056a341b8537142e10373c8417f27d7825ad89b | ca96e46422407a55bed4aa551a6ad28ec1eeef4e | refs/heads/master | 2022-08-02T15:38:56.286555 | 2022-06-16T22:19:54 | 2022-06-16T22:19:54 | 408,238,453 | 74 | 13 | null | 2022-06-16T22:19:55 | 2021-09-19T21:14:59 | null | UTF-8 | C++ | false | false | 4,403 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE762_Mismatched_Memory_Management_Routines__delete_array_int_malloc_02.cpp
Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete_array.label.xml
Template File: sources-sinks-02.tmpl.cpp
*/
/*
* @description
* CWE: 762 Mismatched Memory Management Routines
* BadSource: malloc Allocate data using malloc()
* GoodSource: Allocate data using new []
* Sinks:
* GoodSink: Deallocate data using free()
* BadSink : Deallocate data using delete []
* Flow Variant: 02 Control flow: if(1) and if(0)
*
* */
#include "std_testcase.h"
namespace CWE762_Mismatched_Memory_Management_Routines__delete_array_int_malloc_02
{
#ifndef OMITBAD
void bad()
{
int * data;
/* Initialize data*/
data = NULL;
if(1)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */
data = (int *)malloc(100*sizeof(int));
}
if(1)
{
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to free() to deallocate the memory */
delete [] data;
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G1() - use badsource and goodsink by changing the second 1 to 0 */
static void goodB2G1()
{
int * data;
/* Initialize data*/
data = NULL;
if(1)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */
data = (int *)malloc(100*sizeof(int));
}
if(0)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Free memory using free() */
free(data);
}
}
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the second if */
static void goodB2G2()
{
int * data;
/* Initialize data*/
data = NULL;
if(1)
{
/* POTENTIAL FLAW: Allocate memory with a function that requires free() to free the memory */
data = (int *)malloc(100*sizeof(int));
}
if(1)
{
/* FIX: Free memory using free() */
free(data);
}
}
/* goodG2B1() - use goodsource and badsink by changing the first 1 to 0 */
static void goodG2B1()
{
int * data;
/* Initialize data*/
data = NULL;
if(0)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Allocate memory using new [] */
data = new int[100];
}
if(1)
{
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to free() to deallocate the memory */
delete [] data;
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the first if */
static void goodG2B2()
{
int * data;
/* Initialize data*/
data = NULL;
if(1)
{
/* FIX: Allocate memory using new [] */
data = new int[100];
}
if(1)
{
/* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may
* require a call to free() to deallocate the memory */
delete [] data;
}
}
void good()
{
goodB2G1();
goodB2G2();
goodG2B1();
goodG2B2();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE762_Mismatched_Memory_Management_Routines__delete_array_int_malloc_02; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"yzhang0701@gmail.com"
] | yzhang0701@gmail.com |
0c6607fa27fe99602fb7ad13e990e8b5494e3869 | 3f82430fa9fd05dff681d000c44034ff2ab4f9db | /fi.cpp | 6f02d77075dcb152099cc94eb78b0843c4caf676 | [] | no_license | vishalabhinav12/jay | 8ee29ff35b28c92d2a6466f65b5613ca0b58b8e7 | db8b0044dd806dee6e3db2b77a5aae08b17bb56a | refs/heads/master | 2021-05-23T13:11:23.864548 | 2020-04-05T18:25:32 | 2020-04-05T18:25:32 | 253,303,288 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,913 | cpp | #include <bits/stdc++.h>
#include<iostream>
using namespace std;
#define totalprocess 5
// Making a struct to hold the given input
struct process
{
int at,bt,pr,pno;
};
process proc[50];
bool comp(process a,process b)
{
if(a.at == b.at)
{
return a.pr<b.pr;
}
else
{
return a.at<b.at;
}
}
void get_wt_time(int wt[])
{
// declaring service array that stores cumulative burst time
int service[50];
// Initilising initial elements of the arrays
service[0]=0;
wt[0]=0;
for(int i=1;i<totalprocess;i++)
{
service[i]=proc[i-1].bt+service[i-1];
wt[i]=service[i]-proc[i].at+1;
// If waiting time is negative, change it into zero
if(wt[i]<0)
{
wt[i]=0;
}
}
}
void get_tat_time(int tat[],int wt[])
{
// Filling turnaroundtime array
for(int i=0;i<totalprocess;i++)
{
tat[i]=proc[i].bt+wt[i];
}
}
void findgc()
{
//Declare waiting time and turnaround time array
int wt[50],tat[50];
double wavg=0,tavg=0;
// Function call to find waiting time array
get_wt_time(wt);
//Function call to find turnaround time
get_tat_time(tat,wt);
int stime[50],ctime[50];
stime[0]=1;
ctime[0]=stime[0]+tat[0];
// calculating starting and ending time
for(int i=1;i<totalprocess;i++)
{
stime[i]=ctime[i-1];
ctime[i]=stime[i]+tat[i]-wt[i];
}
cout<<"Process_no\tStart_time\tComplete_time\tTurn_Around_Time\tWaiting_Time"<<endl;
// display the process details
for(int i=0;i<totalprocess;i++)
{
wavg += wt[i];
tavg += tat[i];
cout<<proc[i].pno<<"\t\t"<<
stime[i]<<"\t\t"<<ctime[i]<<"\t\t"<<
tat[i]<<"\t\t\t"<<wt[i]<<endl;
}
// display the average waiting time
//and average turn around time
cout<<"Average waiting time is : ";
cout<<wavg/(float)totalprocess<<endl;
cout<<"average turnaround time : ";
cout<<tavg/(float)totalprocess<<endl;
}
int main()
{
int n ;
cout << "Enter number of processes:- ";
cin >> n ;
int arrivaltime[n];
cout << "Enter Arrival Time For All Processes:- ";
for(auto &x : arrivaltime) cin >> x ;
int bursttime[n];
cout << "Enter Burst Time For All Processes:- ";
for(auto &x : bursttime) cin >> x ;
int priority[n];
cout << "Enter Priority For All Processes:- ";
for(auto &x : priority) cin >> x ;
for(int i=0;i<totalprocess;i++)
{
proc[i].at=arrivaltime[i];
proc[i].bt=bursttime[i];
proc[i].pr=priority[i];
proc[i].pno=i+1;
}
//Using inbuilt sort function
sort(proc,proc+totalprocess,comp);
//Calling function findgc for finding Gantt Chart
findgc();
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
108be22aac00bab538271a0021f685597ebb3b7a | e88a5f63da66b71d62fd74afc280ac4c03a0cf8d | /src/serialization/__serialize_140.cpp | 400da94412e76bddd0fea13d8a6f10134c78d565 | [
"BSD-2-Clause"
] | permissive | chrinide/fertilized-forests | 3558241fbc6d5004a846e6cdaf3df3173e8d3300 | 6364d8a7ff252db5c2ebecb56d09e66a14f4bb9c | refs/heads/master | 2021-01-17T11:31:45.282902 | 2016-12-15T21:22:40 | 2016-12-15T21:22:40 | 84,038,434 | 1 | 0 | null | 2017-03-06T06:32:46 | 2017-03-06T06:32:46 | null | UTF-8 | C++ | false | false | 2,616 | cpp |
// Author: Christoph Lassner.
/**
* This is an automatically generated file!
*/
#if defined SERIALIZATION_ENABLED
#include "fertilized/global.h"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/version.hpp>
#include "fertilized/features/isurfacecalculator.h"
#include "fertilized/serialization/_serialization_definition.h"
namespace fertilized {
template <class Archive>
void __serialization_register_140(Archive &ar,
const bool &always_register,
const unsigned int &serialization_library_version) {
if (0 > FERTILIZED_LIB_VERSION()) {
throw Fertilized_Exception("The serialization generation of the class "
"ISurfaceCalculator is higher than the current library version "
"(0 > " + std::to_string(FERTILIZED_LIB_VERSION()) +
")! This will break serialization! Raise the library version in the file "
"'global.h' to at least 0!");
}
if (always_register ||
serialization_library_version >= 0) {
}
};
TemplateFuncExport DllExport void __serialization_register_140(
boost::archive::text_iarchive &ar,
const bool &always_register,
const unsigned int &serialization_library_version);
TemplateFuncExport DllExport void __serialization_register_140(
boost::archive::text_oarchive &ar,
const bool &always_register,
const unsigned int &serialization_library_version);
TemplateFuncExport DllExport std::string serialize(const ISurfaceCalculator<
uint8_t,
uint8_t,
uint
> *, const bool &);
TemplateFuncExport DllExport ISurfaceCalculator<
uint8_t,
uint8_t,
uint
>* deserialize(std::stringstream &);
TemplateFuncExport DllExport void deserialize(std::stringstream &, ISurfaceCalculator<
uint8_t,
uint8_t,
uint
>*);
} // namespace fertilized
// For types, etc.
using namespace fertilized;
namespace boost {
namespace serialization {
template <>
struct version<ISurfaceCalculator<
uint8_t,
uint8_t,
uint
>> {
typedef mpl::int_<FERTILIZED_VERSION_COUNT> type;
typedef mpl::integral_c_tag tag;
BOOST_STATIC_CONSTANT(int, value = version::type::value);
BOOST_MPL_ASSERT((
boost::mpl::less<
boost::mpl::int_<FERTILIZED_VERSION_COUNT>,
boost::mpl::int_<256>
>
));
};
}
}
#endif // SERIALIZATION_ENABLED | [
"mail@christophlassner.de"
] | mail@christophlassner.de |
c05eb7437d4cfa8047c650fbbf759019fcd2f671 | 76a672b8c58de9f331278edfae8d27ee321b705e | /queue/first negative in window of sixe k(sliding window problem).cpp | 509bb8d6c75c5a5843289e0c09c823157f4d4b68 | [] | no_license | rishabhgoyal777/ds | b8e817a428929f07b7395e37c80c265c31416be9 | 7864a56447c018bf37e3d33d0a456615730b67e3 | refs/heads/main | 2023-06-24T17:22:52.154691 | 2021-07-23T08:06:44 | 2021-07-23T08:06:44 | 337,030,761 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,492 | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
vector<int> v;
for(int i=0;i<n;i++){
cin>>a[i];
}
int k;
cin>>k;
for(int i=0;i<n-k+1;i++){ int flag=1;
for(int j=i;j<i+k;j++){
if(a[j]<0){
v.push_back(a[j]); flag=0; break;
}
}if(flag==1) v.push_back(0);
}
for(int i : v){
cout<<i<<" ";
}cout<<endl;
}
}
o(nk)
optimized o(n) using dequeue(sliding window problem)
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int k;
cin>>k;
deque<int> q;
int i;
for(i=0;i<k;i++){
if(a[i]<0)
q.push_back(i);
}
for(i;i<n;i++){
if(!q.empty())
cout<<a[q.front()]<<" ";
else cout<<0<<" ";
while(!q.empty() && q.front() < (i-k+1)){
q.pop_front();
}
if(a[i]<0)
q.push_back(i);
}
if(!q.empty())
cout<<a[q.front()]<<" ";
else cout<<0<<" ";
cout<<endl;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
82f470faff990ca7b49355af9016b917fd9afdbd | 69a9656c939ffc9ce2916b5b70777b02946683f3 | /8045G.inc | f47dc680078d4c08244d02ddb35ae628ecc0d851 | [] | no_license | yamanetoshi/tubemodel_3.20 | 55b0fa4ed5139e1eedb7eb8084f93e3db07064da | 81a888bbcc7ce3ab350322ba17c93e78a6eacbdf | refs/heads/master | 2020-03-28T20:26:52.668078 | 2018-09-25T11:17:23 | 2018-09-25T11:17:23 | 149,071,675 | 0 | 0 | null | 2018-09-25T11:17:24 | 2018-09-17T05:08:36 | C++ | UTF-8 | C++ | false | false | 853 | inc | *
* Generic triode model: 8045G
* Copyright 2003--2008 by Ayumi Nakabayashi, All rights reserved.
* Version 3.10, Generated on Sat Mar 8 22:42:25 2008
* Plate
* | Grid
* | | Cathode
* | | |
.SUBCKT 8045G A G K
BGG GG 0 V=V(G,K)+1
BM1 M1 0 V=(0.16254949*(URAMP(V(A,K))+1e-10))**-1.8473377
BM2 M2 0 V=(0.44811732*(URAMP(V(GG)+URAMP(V(A,K))/3.3951672)+1e-10))**3.3473377
BP P 0 V=0.006744417*(URAMP(V(GG)+URAMP(V(A,K))/7.5765141)+1e-10)**1.5
BIK IK 0 V=U(V(GG))*V(P)+(1-U(V(GG)))*0.0099093555*V(M1)*V(M2)
BIG IG 0 V=0.0033722085*URAMP(V(G,K))**1.5*(URAMP(V(G,K))/(URAMP(V(A,K))+URAMP(V(G,K)))*1.2+0.4)
BIAK A K I=URAMP(V(IK,IG)-URAMP(V(IK,IG)-(0.0047506048*URAMP(V(A,K))**1.5)))+1e-10*V(A,K)
BIGK G K I=V(IG)
* CAPS
CGA G A 16p
CGK G K 24p
CAK A K 16p
.ENDS
| [
"yamanetoshi@gmail.com"
] | yamanetoshi@gmail.com |
9d1b8a07831a1a327a90bf3d9d5bef542e9688a7 | e6a362c77de6681448f796c64938070d21b7ffc0 | /src/checkpoints.cpp | f26eb3d2169dcc9bcc05715b6719e35aca5409d8 | [
"MIT"
] | permissive | CCYofficial/CCY | 9afd69de377e4e6e6366535e6e846a6dbdde998f | 5c9affe1eb89c36f28786d6747fb0d85124a7a99 | refs/heads/master | 2021-06-19T18:08:07.940998 | 2021-05-17T11:21:22 | 2021-05-17T11:21:22 | 206,141,549 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,434 | cpp | // Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2018 The Cryptocurrency developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "checkpoints.h"
#include "chainparams.h"
#include "main.h"
#include "uint256.h"
#include <stdint.h>
#include <boost/foreach.hpp>
namespace Checkpoints
{
/**
* How many times we expect transactions after the last checkpoint to
* be slower. This number is a compromise, as it can't be accurate for
* every system. When reindexing from a fast disk with a slow CPU, it
* can be up to 20, while when downloading from a slow network with a
* fast multicore CPU, it won't be much higher than 1.
*/
static const double SIGCHECK_VERIFICATION_FACTOR = 5.0;
bool fEnabled = true;
bool CheckBlock(int nHeight, const uint256& hash)
{
if (!fEnabled)
return true;
const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
if (i == checkpoints.end()) return true;
return hash == i->second;
}
//! Guess how far we are in the verification process at the given block index
double GuessVerificationProgress(CBlockIndex* pindex, bool fSigchecks)
{
if (pindex == NULL)
return 0.0;
int64_t nNow = time(NULL);
double fSigcheckVerificationFactor = fSigchecks ? SIGCHECK_VERIFICATION_FACTOR : 1.0;
double fWorkBefore = 0.0; // Amount of work done before pindex
double fWorkAfter = 0.0; // Amount of work left after pindex (estimated)
// Work is defined as: 1.0 per transaction before the last checkpoint, and
// fSigcheckVerificationFactor per transaction after.
const CCheckpointData& data = Params().Checkpoints();
if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) {
double nCheapBefore = pindex->nChainTx;
double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx;
double nExpensiveAfter = (nNow - data.nTimeLastCheckpoint) / 86400.0 * data.fTransactionsPerDay;
fWorkBefore = nCheapBefore;
fWorkAfter = nCheapAfter + nExpensiveAfter * fSigcheckVerificationFactor;
} else {
double nCheapBefore = data.nTransactionsLastCheckpoint;
double nExpensiveBefore = pindex->nChainTx - data.nTransactionsLastCheckpoint;
double nExpensiveAfter = (nNow - pindex->GetBlockTime()) / 86400.0 * data.fTransactionsPerDay;
fWorkBefore = nCheapBefore + nExpensiveBefore * fSigcheckVerificationFactor;
fWorkAfter = nExpensiveAfter * fSigcheckVerificationFactor;
}
return fWorkBefore / (fWorkBefore + fWorkAfter);
}
int GetTotalBlocksEstimate()
{
if (!fEnabled)
return 0;
const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
return checkpoints.rbegin()->first;
}
CBlockIndex* GetLastCheckpoint()
{
if (!fEnabled)
return NULL;
const MapCheckpoints& checkpoints = *Params().Checkpoints().mapCheckpoints;
BOOST_REVERSE_FOREACH (const MapCheckpoints::value_type& i, checkpoints) {
const uint256& hash = i.second;
BlockMap::const_iterator t = mapBlockIndex.find(hash);
if (t != mapBlockIndex.end())
return t->second;
}
return NULL;
}
} // namespace Checkpoints
| [
"root@server1500.nazwa.pl"
] | root@server1500.nazwa.pl |
cb2042f4ae7a9bcccb74d84e4b7872a6de0828b5 | c51febc209233a9160f41913d895415704d2391f | /library/ATF/RPC_BLOCKING_FN.hpp | 778b264ffc53fa3def53627c2176a86d66b7a588 | [
"MIT"
] | permissive | roussukke/Yorozuya | 81f81e5e759ecae02c793e65d6c3acc504091bc3 | d9a44592b0714da1aebf492b64fdcb3fa072afe5 | refs/heads/master | 2023-07-08T03:23:00.584855 | 2023-06-29T08:20:25 | 2023-06-29T08:20:25 | 463,330,454 | 0 | 0 | MIT | 2022-02-24T23:15:01 | 2022-02-24T23:15:00 | null | UTF-8 | C++ | false | false | 258 | hpp | // This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
START_ATF_NAMESPACE
typedef int (WINAPIV *RPC_BLOCKING_FN)(void *, void *, void *);
END_ATF_NAMESPACE
| [
"b1ll.cipher@yandex.ru"
] | b1ll.cipher@yandex.ru |
e85469c8fa439012c02681d2c79a21ea17964ec0 | bd9d2329feb1ed59466fd1357647e46875e211f9 | /code/lte/let_server.h | 62bfd841837ca698f3866e1bfbd6bbfdb2d37592 | [] | no_license | ww4u/megarobo_app_server | 927fb6b734528190c3f95ac68a530b74d08eb05d | 90f24ee567056bfcd7a8f3329241aa10f202b003 | refs/heads/master | 2022-12-21T11:30:21.665921 | 2019-05-17T14:57:58 | 2019-05-17T14:57:58 | 296,256,550 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 616 | h | #ifndef LET_SERVER_H
#define LET_SERVER_H
#include "../mappserver.h"
#include "letpara.h"
#include "axes.h"
class Let_Server : public MAppServer, public LetPara
{
public:
Let_Server( int portBase=2345, int cnt = 1,
QObject *pParent = nullptr );
public:
virtual int start();
virtual int open();
virtual void close();
virtual void rst();
virtual MAppServer::ServerStatus status();
virtual void on_dislink();
virtual bool isLinked();
public:
int load();
int zpdir();
public:
Axes mZAxes;
};
#endif // LET_SERVER_H
| [
"wangzhiyan@megarobo.tech"
] | wangzhiyan@megarobo.tech |
2a81d885b5812ccdb9b3e7b119ca503f6d0d2dd3 | 6cc41b86b995f1e7420d53e4f7c09d7edd4a8d7c | /inc/hgl/thread/Workflow.h | 8edd01c7525cdfb1cb07d374ad22290c36102cf9 | [] | no_license | hyzboy/CMCore | b8f831c73c10ad72507f3a1e4ea4784caa2288e6 | 3b71e680cc71689bed3dbed0491324819f5e2edc | refs/heads/master | 2023-08-16T21:16:50.087101 | 2023-08-14T13:02:24 | 2023-08-14T13:02:24 | 203,144,540 | 1 | 1 | null | 2021-03-20T04:43:56 | 2019-08-19T09:46:38 | C++ | UTF-8 | C++ | false | false | 11,040 | h | #ifndef HGL_WORKFLOW_INCLUDE
#define HGL_WORKFLOW_INCLUDE
#include<hgl/thread/Thread.h>
#include<hgl/thread/ThreadMutex.h>
#include<hgl/thread/SwapData.h>
#include<hgl/thread/DataPost.h>
#include<hgl/type/List.h>
namespace hgl
{
/**
* 工作流名字空间<br>
* 工作流是一种对工作的多线安排管理机制,它适用于按业务分配多线程的工作环境<br>
* 开发者需要为每一种工作指定一定的线程数量,但每一种工作确只有一个工作分配入口和分发出口。<br>
* 由其它程序提交工作任务到入口,开发者可以自行重载分配入口的分配函数。
*/
namespace workflow
{
/**
* 工作处理基类模板
* @param W 工作对象
*/
template<typename W> class WorkProc
{
public:
virtual ~WorkProc()=default;
public: //投递工作线程所需调用的方法
virtual void Post(W *w)=0; ///<投递一个工作
virtual void Post(W **w,int count)=0; ///<投递一批工作
public: //需用户重载实现的真正执行工作的方法
/**
* 单个工作执行事件函数,此函数需用户重载实现
*/
virtual void OnWork(const uint,W *)=0;
public: //由工作线程调用的执行工作事件函数
/**
* 工作执行处理函数
*/
virtual bool OnExecuteWork(const uint)=0;
};//template<typename W> class WorkProc
/**
* 单体工作处理<br>
* 该类可以由多个线程投递工作,但只能被一个工作线程获取工作
*/
template<typename W> class SingleWorkProc:public WorkProc<W>
{
public:
using WorkList=List<W *>;
private:
SemSwapData<WorkList> work_list; ///<工程列表
protected:
double time_out;
public:
SingleWorkProc()
{
time_out=5;
}
virtual ~SingleWorkProc()=default;
void SetTimeOut(const double to) ///<设置超时时间
{
if(to<=0)time_out=0;
else time_out=to;
}
virtual void Post(W *w) override ///<投递一个工作
{
WorkList &wl=work_list.GetPost();
wl.Add(w);
work_list.ReleasePost();
}
virtual void Post(W **w,int count) override ///<投递一批工作
{
WorkList &wl=work_list.GetPost();
wl.Add(w,count);
work_list.ReleasePost();
}
virtual void ToWork() ///<将堆积的工作列表发送给工作线程
{
work_list.PostSem(1);
}
public:
/**
* 当前工作序列完成事件函数,如需使用请重载此函数
*/
virtual void OnFinish(const uint wt_index)
{
}
/**
* 开始执行工作函数
*/
virtual bool OnExecuteWork(const uint wt_index) override
{
//为什么不使用TrySemSwap,使用TrySemSwap固然会立即返回结果,但会引起线程频繁刷新造成CPU的流费。
//使用WaitSemSwap目前唯一坏处是在退出时,需要等待超时时间。
if(!work_list.WaitSemSwap(time_out))
return(false);
WorkList &wl=work_list.GetReceive();
const int count=wl.GetCount();
if(count>0)
{
W **p=wl.GetData();
for(int i=0;i<count;i++)
{
this->OnWork(wt_index,*p);
++p;
}
this->OnFinish(wt_index);
wl.Clear();
}
return(true);
}
};//template<typename W> class SingleWorkProc:public WorkProc<W>
/**
* 多体工作处理<br>
* 该类可以由多个线程投递工作,也可以同时被多个工作线程获取工作
*/
template<typename W> class MultiWorkProc:public WorkProc<W>
{
protected:
SemDataPost<W> work_list; ///<工程列表
protected:
double time_out;
public:
MultiWorkProc()
{
time_out=5;
}
virtual ~MultiWorkProc()=default;
void SetTimeOut(const double to) ///<设置超时时间
{
if(to<=0)time_out=0;
else time_out=to;
}
virtual void Post(W *w) override ///<投递一个工作
{
if(!w)return;
work_list.Post(w);
work_list.PostSem(1);
}
virtual void Post(W **w,int count) override ///<投递一批工作
{
if(!w||count<=0)return;
work_list.Post(w,count);
work_list.PostSem(count);
}
public:
/**
* 开始执行工作函数
*/
virtual bool OnExecuteWork(const uint wt_index) override
{
//为什么不使用TrySemReceive,使用TrySemReceive固然会立即返回结果,但会引起线程频繁刷新造成CPU的流费。
//使用WaitSemReceive目前唯一坏处是在退出时,需要等待超时时间。
W *obj=work_list.WaitSemReceive(time_out);
if(!obj)
return(false);
this->OnWork(wt_index,obj);
return(true);
}
};//template<typename W> class MultiWorkProc:public WorkProc<W>
/**
* 工作线程,用于真正处理事务
*/
template<typename W> class WorkThread:public Thread
{
protected:
using WorkList=List<W *>;
WorkProc<W> *work_proc;
uint work_thread_index;
bool force_close;
public:
WorkThread(WorkProc<W> *wp)
{
work_proc=wp;
work_thread_index=0;
force_close=false;
}
#ifndef _DEBUG
virtual ~WorkThread()=default;
#else
virtual ~WorkThread()
{
LOG_INFO(U8_TEXT("WorkThread Destruct [")+thread_addr_string+U8_TEXT("]"));
}
#endif//_DEBUG
bool IsExitDelete()const override{return false;} ///<返回在退出线程时,不删除本对象
void SetWorkThreadIndex(const uint index)
{
work_thread_index=index;
}
void ExitWork(const bool fc)
{
force_close=fc;
Thread::WaitExit();
}
virtual void ProcEndThread() override
{
if(!force_close) //不是强退
while(work_proc->OnExecuteWork(work_thread_index)); //把工作全部做完
#ifdef _DEBUG
{
LOG_INFO(U8_TEXT("WorkThread Finish [")+thread_addr_string+U8_TEXT("]"));
}
#endif//_DEBUG
}
virtual bool Execute() override
{
if(!work_proc)
RETURN_FALSE;
work_proc->OnExecuteWork(work_thread_index);
return(true);
}
};//template<typename W> class WorkThread:public Thread
/**
* 工作组<br>
* 用于管理一组的工作线程以及投递器<br>
* 注:可以一组工作线程共用一个投递器,也可以每个工作线程配一个投递器。工作组管理只为方便统一清理
*/
template<typename WP,typename WT> class WorkGroup
{
ObjectList<WP> wp_list; ///<投递器列表
ObjectList<WT> wt_list; ///<工作线程列表
bool run=false;
public:
virtual ~WorkGroup()
{
Close();
}
virtual bool Add(WP *wp)
{
if(!wp)return(false);
wp_list.Add(wp);
return(true);
}
virtual bool Add(WP **wp,const int count)
{
if(!wp)return(false);
wp_list.Add(wp,count);
return(true);
}
virtual bool Add(WT *wt)
{
if(!wt)return(false);
int index=wt_list.Add(wt);
wt->SetWorkThreadIndex(index);
return(true);
}
virtual bool Add(WT **wt,const int count)
{
if(!wt)return(false);
int index=wt_list.Add(wt,count);
for(int i=0;i<count;i++)
{
(*wt)->SetWorkThreadIndex(index);
++index;
++wt;
}
return(true);
}
virtual bool Start()
{
int count=wt_list.GetCount();
if(count<=0)
RETURN_FALSE;
WT **wt=wt_list.GetData();
for(int i=0;i<count;i++)
wt[i]->Start();
run=true;
return(true);
}
virtual void Close(bool force_close=false)
{
if(!run)return;
int count=wt_list.GetCount();
WT **wt=wt_list.GetData();
for(int i=0;i<count;i++)
wt[i]->ExitWork(force_close);
run=false;
}
};//template<typename WP,typename WT> class WorkGroup
}//namespace workflow
}//namespace hgl
#endif//HGL_WORKFLOW_INCLUDE
| [
"hyzboy@gmail.com"
] | hyzboy@gmail.com |
64a901df0a91e79f430de5e728bb1f23cdb2315c | cde1213fc1b6db21c507b9fb04314f97c677bc4f | /HT_Analyzer_All/trkCorrTable/xiaoTrkCorrCymbal.h | a573de29c5ea472670fd3a05120b1d7b6652372c | [] | no_license | kurtejung/JetTrackCorrelations | 227226679bce86d4f5004f4d2a87b8d53661a12d | 19b75649d7fd4a3cdb6c5c4b02dcc48bf69d94ca | refs/heads/master | 2020-04-04T22:31:09.599617 | 2018-03-12T15:16:19 | 2018-03-12T15:16:19 | 62,832,993 | 0 | 2 | null | 2016-07-07T19:28:15 | 2016-07-07T19:28:15 | null | UTF-8 | C++ | false | false | 1,735 | h |
#ifndef TRKCORRCYMBAL_H
#define TRKCORRCYMBAL_H
#ifndef ROOT_TH2F
#include "TH2F.h"
#endif
#ifndef ROOT_TH1F
#include "TH1F.h"
#endif
#include <iostream>
class xiaoTrkCorrCymbal{
public:
int jhist;
int khist;
TFile* corf;
xiaoTrkCorrCymbal(TString fname);
float getTrkCorr(float pt, float eta, float phi, int hibin);
private:
float ptbins[11];
int hibins[45]; // we combined last 4 corr. table
int nhibin;
int nptbin;
int hibinWidth;
float etaw;
float phiw;
TH2F* corrTable[50][10];
};
xiaoTrkCorrCymbal::xiaoTrkCorrCymbal(TString fname){
hibinWidth = 4;
nhibin=43;
nptbin =10;
etaw = 0.1;
phiw = 0.12;
TFile* corf = TFile::Open(fname,"read");
if( corf->IsOpen()){
for(int j=0;j<nhibin;j++){
hibins[j]=j*hibinWidth;
for(int k=0; k<nptbin;k++){
corrTable[j][k]= (TH2F*)corf->Get(Form("corr_%d_%d",j,k));
}
}
hibins[nhibin]=200;
}
else cout<<"didn't open the correction file!"<<endl;
ptbins[0] =0.5;
ptbins[1] =0.7;
ptbins[2] =1;
ptbins[3] =2;
ptbins[4] =3;
ptbins[5] =4;
ptbins[6] =8;
ptbins[7] =12;
ptbins[8] =16;
ptbins[9] =20;
ptbins[10] =300;
}
float xiaoTrkCorrCymbal::getTrkCorr(float pt, float eta, float phi, int hibin){
jhist = -1;
khist = -1;
float corr =1;
for(int j=0;j<nhibin;j++){
if(hibin >= hibins[j] && hibin< hibins[j+1]) {
jhist=j;
break;
}
}
if( jhist <0) {
cout<<"hibin out of the range!"<<endl;
return 1;
}
for(int k =0;k<nptbin;k++){
if(pt >= ptbins[k] && pt< ptbins[k+1]) khist=k;
}
if( khist <0) {
cout<<"pt out of the range of this correction!"<<endl;
cout<<pt<<endl;
return 1;
}
corr = corrTable[jhist][khist]->GetBinContent(corrTable[jhist][khist]->FindBin(eta,phi));
return corr;
}
#endif
| [
"kurtejung@gmail.com"
] | kurtejung@gmail.com |
bb480fbe294c6ef6770189a0096fa757038f26b7 | bbbe7ca3e114846f4c752ffd16d1afcce56f82b0 | /AnotherStupidProject/Project/src/Texture.cpp | ca66884f13cfdb70f9b06ccf37ae752ec1ed4c9a | [] | no_license | Abagofair/AnotherStupidProject | 1c1aa348e21ebf9a92445e5e4bded5b511ef0f3e | 7c4bdbde5ae2882077342d9f07f8542b75d17047 | refs/heads/master | 2023-06-09T13:50:19.839064 | 2021-06-22T21:26:47 | 2021-06-22T21:26:47 | 379,403,907 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,948 | cpp | #pragma once
#include <Texture.hpp>
Texture::Texture(
std::string path)
{
_hasId = false;
SDL_Surface* surface = IMG_Load(path.c_str());
_width = surface->w;
_height = surface->h;
CopyFromPixels(_width, _height, surface->pixels);
SDL_FreeSurface(surface);
}
Texture::Texture(
unsigned int width,
unsigned int height) : _width(width), _height(height)
{
_hasId = false;
std::size_t size = sizeof(uint32_t) * width * height;
uint32_t* whitePixels = (uint32_t*)(malloc(size));
if (whitePixels == nullptr)
throw;
for (size_t i = 0; i < width * height; ++i)
{
if (i % 100 == 0 || i % 105 == 0)
{
whitePixels[i] = 0x00000000;
}
else
{
whitePixels[i] = 0xFFFFFFFF;
}
}
CopyFromPixels(_width, _height, static_cast<void*>(whitePixels));
free(whitePixels);
}
Texture::~Texture()
{
glDeleteTextures(1, &_glTextureId);
}
void Texture::Bind()
{
glBindTexture(GL_TEXTURE_2D, _glTextureId);
}
void Texture::Unbind()
{
glBindTexture(GL_TEXTURE_2D, 0);
}
void Texture::UpdateTexture(void* pixels)
{
Bind();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, _width, _height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
Unbind();
}
void Texture::CopyFromPixels(
unsigned short width,
unsigned short height,
void* pixels)
{
if (_hasId)
{
throw;
}
glGenTextures(1, &_glTextureId);
glBindTexture(GL_TEXTURE_2D, _glTextureId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
glBindTexture(GL_TEXTURE_2D, 0);
_hasId = true;
} | [
"anderskoch.airbag@gmail.com"
] | anderskoch.airbag@gmail.com |
d1bb992bc3dfb52ae52fd5c7c9f66b243443e791 | d63e953a3440e70a39fc7b3351b35bc689fb1231 | /Component/stdafx.cpp | deeda0542fec7edcca8d552ea93adfa0e7336e08 | [] | no_license | WizardMerlin/design_pattern_life | 3e15d57f13b4a17b337df75e5067e107a98a91f4 | 5b59d22183c714810ded3c773ec1c1462134013f | refs/heads/master | 2021-01-25T11:14:23.237847 | 2017-06-13T16:33:37 | 2017-06-13T16:33:37 | 93,916,324 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 260 | cpp | // stdafx.cpp : 只包括标准包含文件的源文件
// Component.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中引用任何所需的附加头文件,
//而不是在此文件中引用
| [
"yuyankai945@hotmail.com"
] | yuyankai945@hotmail.com |
d09ddf31f9ae0024844dee2e0398c218ac2462ef | b0037831a6dc021c1c9c67f2b0511d750f33a91e | /1.17(Date类)/1.17(Date类)/test.cpp | a215e3eebb18e12ce26ace5ff10f53e5ee2975df | [] | no_license | 477918269/C-cpp | a01b47b55bb8b0b6d88f5efb8eda4925fe43cc95 | a2a1a435fe030bfc76ef8e960949aacbc84edf6c | refs/heads/master | 2022-03-03T23:20:34.542904 | 2019-10-13T15:05:05 | 2019-10-13T15:05:05 | 163,571,435 | 1 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 3,061 | cpp | #include<iostream>
#include<stdlib.h>
using namespace std;
class Date
{
public:
int Monthday(int year, int month)
{
int a[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if (month == 2)
{
if ((year % 4 == 0) && (year % 100 != 0) || year % 400 == 0)
{
return 29;
}
return 28;
}
return a[month];
}
Date(int year = 1900, int month = 1, int day = 1)
{
_year = year;
_month = month;
_day = day;
}
Date(const Date& d)
{
if (!(this == &d))
{
_year = d._year;
_month = d._month;
_day = d._day;
}
}
Date& operator=(const Date& d)
{
_year = d._year;
_month = d._month;
_day = d._day;
return *this;
}
Date operator+(int days)
{
while ((_day + days) >= Monthday(_year,_month))
{
days -= (Monthday(_year, _month) - _day);
if (_month == 12)
{
_year += 1;
_month = 1;
}
_day = 0;
_month += 1;
}
_day = _day + days;
return *this;
}
Date operator-(int days)
{
while ((_day - days) <= 0)
{
days -= _day;
if (_month == 1)
{
_year -= 1;
_month = 12;
}
_day = Monthday(_year, _month - 1);
_month -= 1;
}
_day = _day - days;
return *this;
}
int operator-(const Date& d)
{
Date max = *this;
Date min = d;
int flag = 1;
int days = 0;
if (min >= max)
{
Date tmp = max;
max = min;
min = tmp;
flag = -1;
}
while (min != max)
{
++min;
++days;
}
return days;
}
Date& operator++()
{
*this + 1;
return *this;
}
Date operator++(int)
{
Date tmp(*this);
*this + 1;
return tmp;
}
Date& operator--()
{
*this = *this - 1;
return *this;
}
Date operator--(int)
{
Date tmp(*this);
*this + 1;
return tmp;
}
bool operator > (const Date& d)const
{
return (_year > d._year)
|| (_year == d._year && _month > d._month)
|| (_year == d._year && _month == d._month && _day > d._day);
}
bool operator>=(const Date& d)const
{
return !(*this < d);
}
bool operator<(const Date& d)const
{
return (_year < d._year)
|| (_year == d._year && _month < d._month)
|| (_year == d._year && _month == d._month && _day < d._day);
}
bool operator <= (const Date& d)const
{
return !(*this > d);
}
bool operator==(const Date& d)const
{
return _year == d._year
&& _month == d._month
&& _day == d._day;
}
bool operator!=(const Date& d)const
{
return !(*this == d);
}
void Print()
{
cout << _year << "-" << _month << "-" << _day << endl;
}
private:
int _year;
int _month;
int _day;
};
void Test1()
{
Date d1(2019, 1, 17);
Date d2(2019, 1, 18);
cout << (d1 >= d2) << endl;
cout << (d1 <= d2) << endl;
cout << (d1 != d2) << endl;
cout << (d1 > d2) << endl;
cout << (d1 < d2) << endl;
cout << (d1 == d2) << endl;
}
void Test2()
{
Date d1(2019, 1, 17);
/*d1 + 15;
d1.Print();*/
//d1 - 17;
//d1++(0).Print();
//(++d1).Print();//µ÷ÓÃǰÖÃ++
}
void Test3()
{
Date d1(2019, 1, 17);
Date d2(2019, 2, 21);
cout << (d1 - d2) << endl;
}
int main()
{
Test3();
system("pause");
return 0;
} | [
"477918269@qq.com"
] | 477918269@qq.com |
bc925aae9f93b128d9002f8823da61f6168082f2 | a9d483e95f40543fdd7ad8d5c9ff26742f276d96 | /gps_arduino.ino | 82bce57b89ae42d4596e36152bc9075dc06ec32e | [] | no_license | Pratyasha2000/Wrist-Module | 13f282a1d026b400bc587bea1d5a7d7981041ad1 | 9de6b8f1bd251bdb24df7a0f706ea18fb3f3307c | refs/heads/master | 2023-08-29T10:57:57.872459 | 2021-10-28T20:16:08 | 2021-10-28T20:16:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 386 | ino | #include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
}
void loop()
{
// Output raw GPS data to the serial monitor
while (ss.available() > 0){
Serial.write(ss.read());
}
}
| [
"noreply@github.com"
] | noreply@github.com |
6ab824e05e5755f63baf927a41a6932c1b46d7f4 | 2af29f0c2676c57191678f1a2f0244c364f81fa1 | /Libs/d3d9font/d3dutil.h | 897a0d11b76c5ec7212eba739b025e8ce367bb65 | [
"MIT"
] | permissive | kochol/kge | 7c313c0c68242e7d9eee1f4a7dd97fd60038f63e | 9ffee7ab7f56481383d8f152cfa0434e2f9103c1 | refs/heads/master | 2020-04-26T11:28:25.158808 | 2018-06-30T07:26:07 | 2018-06-30T07:26:07 | 4,322,408 | 10 | 1 | null | 2014-05-29T20:47:11 | 2012-05-14T10:11:55 | C | UTF-8 | C++ | false | false | 6,387 | h | //-----------------------------------------------------------------------------
// File: D3DUtil.h
//
// Desc: Helper functions and typing shortcuts for Direct3D programming.
//
// Copyright (c) 1997-2001 Microsoft Corporation. All rights reserved
//-----------------------------------------------------------------------------
#ifndef D3DUTIL_H
#define D3DUTIL_H
#include <D3D9.h>
#include <D3DX9Math.h>
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitMaterial()
// Desc: Initializes a D3DMATERIAL9 structure, setting the diffuse and ambient
// colors. It does not set emissive or specular colors.
//-----------------------------------------------------------------------------
VOID D3DUtil_InitMaterial( D3DMATERIAL9& mtrl, FLOAT r=0.0f, FLOAT g=0.0f,
FLOAT b=0.0f, FLOAT a=1.0f );
//-----------------------------------------------------------------------------
// Name: D3DUtil_InitLight()
// Desc: Initializes a D3DLIGHT structure, setting the light position. The
// diffuse color is set to white, specular and ambient left as black.
//-----------------------------------------------------------------------------
VOID D3DUtil_InitLight( D3DLIGHT9& light, D3DLIGHTTYPE ltType,
FLOAT x=0.0f, FLOAT y=0.0f, FLOAT z=0.0f );
//-----------------------------------------------------------------------------
// Name: D3DUtil_CreateTexture()
// Desc: Helper function to create a texture. It checks the root path first,
// then tries the DXSDK media path (as specified in the system registry).
//-----------------------------------------------------------------------------
HRESULT D3DUtil_CreateTexture( LPDIRECT3DDEVICE9 pd3dDevice, TCHAR* strTexture,
LPDIRECT3DTEXTURE9* ppTexture,
D3DFORMAT d3dFormat = D3DFMT_UNKNOWN );
//-----------------------------------------------------------------------------
// Name: D3DUtil_GetCubeMapViewMatrix()
// Desc: Returns a view matrix for rendering to a face of a cubemap.
//-----------------------------------------------------------------------------
D3DXMATRIX D3DUtil_GetCubeMapViewMatrix( DWORD dwFace );
//-----------------------------------------------------------------------------
// Name: D3DUtil_GetRotationFromCursor()
// Desc: Returns a quaternion for the rotation implied by the window's cursor
// position.
//-----------------------------------------------------------------------------
D3DXQUATERNION D3DUtil_GetRotationFromCursor( HWND hWnd,
FLOAT fTrackBallRadius=1.0f );
//-----------------------------------------------------------------------------
// Name: D3DUtil_SetDeviceCursor
// Desc: Builds and sets a cursor for the D3D device based on hCursor.
//-----------------------------------------------------------------------------
HRESULT D3DUtil_SetDeviceCursor( LPDIRECT3DDEVICE9 pd3dDevice, HCURSOR hCursor,
BOOL bAddWatermark );
//-----------------------------------------------------------------------------
// Name: class CD3DArcBall
// Desc:
//-----------------------------------------------------------------------------
class CD3DArcBall
{
INT m_iWidth; // ArcBall's window width
INT m_iHeight; // ArcBall's window height
FLOAT m_fRadius; // ArcBall's radius in screen coords
FLOAT m_fRadiusTranslation; // ArcBall's radius for translating the target
D3DXQUATERNION m_qDown; // Quaternion before button down
D3DXQUATERNION m_qNow; // Composite quaternion for current drag
D3DXMATRIXA16 m_matRotation; // Matrix for arcball's orientation
D3DXMATRIXA16 m_matRotationDelta; // Matrix for arcball's orientation
D3DXMATRIXA16 m_matTranslation; // Matrix for arcball's position
D3DXMATRIXA16 m_matTranslationDelta; // Matrix for arcball's position
BOOL m_bDrag; // Whether user is dragging arcball
BOOL m_bRightHanded; // Whether to use RH coordinate system
D3DXVECTOR3 ScreenToVector( int sx, int sy );
public:
LRESULT HandleMouseMessages( HWND, UINT, WPARAM, LPARAM );
D3DXMATRIX* GetRotationMatrix() { return &m_matRotation; }
D3DXMATRIX* GetRotationDeltaMatrix() { return &m_matRotationDelta; }
D3DXMATRIX* GetTranslationMatrix() { return &m_matTranslation; }
D3DXMATRIX* GetTranslationDeltaMatrix() { return &m_matTranslationDelta; }
BOOL IsBeingDragged() { return m_bDrag; }
VOID SetRadius( FLOAT fRadius );
VOID SetWindow( INT w, INT h, FLOAT r=0.9 );
VOID SetRightHanded( BOOL bRightHanded ) { m_bRightHanded = bRightHanded; }
CD3DArcBall();
};
//-----------------------------------------------------------------------------
// Name: class CD3DCamera
// Desc:
//-----------------------------------------------------------------------------
class CD3DCamera
{
D3DXVECTOR3 m_vEyePt; // Attributes for view matrix
D3DXVECTOR3 m_vLookatPt;
D3DXVECTOR3 m_vUpVec;
D3DXVECTOR3 m_vView;
D3DXVECTOR3 m_vCross;
D3DXMATRIXA16 m_matView;
D3DXMATRIXA16 m_matBillboard; // Special matrix for billboarding effects
FLOAT m_fFOV; // Attributes for projection matrix
FLOAT m_fAspect;
FLOAT m_fNearPlane;
FLOAT m_fFarPlane;
D3DXMATRIXA16 m_matProj;
public:
// Access functions
D3DXVECTOR3 GetEyePt() { return m_vEyePt; }
D3DXVECTOR3 GetLookatPt() { return m_vLookatPt; }
D3DXVECTOR3 GetUpVec() { return m_vUpVec; }
D3DXVECTOR3 GetViewDir() { return m_vView; }
D3DXVECTOR3 GetCross() { return m_vCross; }
D3DXMATRIX GetViewMatrix() { return m_matView; }
D3DXMATRIX GetBillboardMatrix() { return m_matBillboard; }
D3DXMATRIX GetProjMatrix() { return m_matProj; }
VOID SetViewParams( D3DXVECTOR3 &vEyePt, D3DXVECTOR3& vLookatPt,
D3DXVECTOR3& vUpVec );
VOID SetProjParams( FLOAT fFOV, FLOAT fAspect, FLOAT fNearPlane,
FLOAT fFarPlane );
CD3DCamera();
};
#endif // D3DUTIL_H
| [
"kocholsoft@yahoo.com"
] | kocholsoft@yahoo.com |
a8c527a947f9eee8eaa7195f143a61e0c8d22499 | 24ad822c3c65266ec31904574368f3e49c9c7323 | /solver.h | 01ab9fa3ba562b04e309c9401f9202851fda59c0 | [] | no_license | fur30089/fur30089-GameTheory_PJ3 | bc81149aa3e6e7a81cb68888f0298069a1b67433 | c24e8ca09abe675cf742c93a9806799408c90efe | refs/heads/master | 2020-04-15T01:26:21.763026 | 2019-01-10T07:07:18 | 2019-01-10T07:07:18 | 164,275,925 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 15,405 | h | #pragma once
#include <iostream>
#include <algorithm>
#include <cmath>
#include "board.h"
#include <numeric>
#include "action.h"
#include <vector>
#include <time.h>
double StateValue(board b){
double score=0;
for(int i=0;i<=5;i++){
if (b(i)>=3){
score+=pow(3,log(IndextoValue(b(i))/3)/log(2)+1);
}
}
return score;
}
double max(double a[],int n){
double max=a[0];
for(int i=0;i<n;i++){ //
if(a[i]>max)
max=a[i];
}
return max;
}
double avg(double a[],int n){
double sum=0;
for(int i=0;i<n;i++)
sum+=a[i];
return sum/n;
}
template<typename TT> //4d vector
std::vector<std::vector<std::vector<std::vector<TT> > > > make_4d_vector(double zz,double z, double y, double x, TT value)
{
return std::vector<std::vector<std::vector<std::vector<TT> > > >(zz,std::vector<std::vector<std::vector<TT> > >(z, std::vector<std::vector<TT> >(y, std::vector<TT>(x, value))));
}
template<typename T> //3d vector
std::vector<std::vector<std::vector<T> > > make_3d_vector(double z, double y, double x, T value)
{
return std::vector<std::vector<std::vector<T> > >(z, std::vector<std::vector<T> >(y, std::vector<T>(x, value)));
}
template<typename U> //2d vector
std::vector<std::vector<U> > make_2d_vector( double y, double x, U value)
{
return std::vector<std::vector<U> > (y, std::vector<U>(x, value));
}
class state_type {
public:
enum type : char {
before = 'b',
after = 'a',
illegal = 'i'
};
public:
state_type() : t(illegal) {}
state_type(const state_type& st) = default;
state_type(state_type::type code) : t(code) {}
friend std::istream& operator >>(std::istream& in, state_type& type) {
std::string s;
if (in >> s) type.t = static_cast<state_type::type>((s + " ").front());
return in;
}
friend std::ostream& operator <<(std::ostream& out, const state_type& type) {
return out << char(type.t);
}
bool is_before() const { return t == before; }
bool is_after() const { return t == after; }
bool is_illegal() const { return t == illegal; }
private:
type t;
};
class state_hint {
public:
state_hint(const board& state) : state(const_cast<board&>(state)) {}
char type() const { return state.info() ? state.info() + '0' : 'x'; }
operator board::cell() const { return state.info(); }
public:
friend std::istream& operator >>(std::istream& in, state_hint& hint) {
while (in.peek() != '+' && in.good()) in.ignore(1);
char v; in.ignore(1) >> v;
hint.state.info(v != 'x' ? v - '0' : 0);
return in;
}
friend std::ostream& operator <<(std::ostream& out, const state_hint& hint) {
return out << "+" << hint.type();
}
private:
board& state;
};
class solver {
public:
typedef double value_t;
public:
class answer {
public:
answer(value_t min = 0.0/0.0, value_t avg = 0.0/0.0, value_t max = 0.0/0.0) : min(min), avg(avg), max(max) {}
friend std::ostream& operator <<(std::ostream& out, const answer& ans) {
return !std::isnan(ans.avg) ? (out << ans.min << " " << ans.avg << " " << ans.max) : (out << "-1") << std::endl;
}
public:
const value_t min, avg, max;
};
public:
solver(const std::string& args) {
// TODO: explore the tree and save the result
board state;
state(0)=0;
state(1)=0;
state(2)=0;
state(3)=0;
state(4)=0;
state(5)=0;
//std::cout <<"value: "<< value << '\n'; //20
//std::cout <<"value: "<< StateValue(state) << '\n'; //20
//std::cout <<"value: "<< state(0)<< '\n'; //20
//std::array<double, 3> value=TreeBefore(state,2);
std::array<double, 3> value=TreeAfter(state,0,0);
//std::cout<<"value:"<<state<<" +1= "<<value<<'\n';
// std::cout << "feel free to display some messages..." << std::endl;
}
answer solve(const board& state, state_type type = state_type::before) {
// TODO: find the answer in the lookup table and return it
// do NOT recalculate the tree at here
// to fetch the hint
// for a legal state, return its three values.
// return { min, avg, max };
// for an illegal state, simply return {}
board::cell hint = state_hint(state);
value_t min;
value_t avg;
value_t max;
if (type.is_before()){
if (TableB[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint-1][0]==-1) return -1;
min=TableB[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint-1][0];
avg=TableB[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint-1][1];
max=TableB[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint-1][2];
}
else{
int n=0;
for (int i=0;i<=3;i++){
if (TableA[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint][i][1]==-1) continue;
min=TableA[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint][i][0];
avg=TableA[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint][i][1];
max=TableA[state(0)*pow(10,5)+state(1)*pow(10,4)+state(2)*pow(10,3)+state(3)*pow(10,2)+state(4)*10+state(5)][hint][i][2];
n=1;
}
if (n==0) return -1;
}
return {min,avg,max};
}
private:
// TODO: place your transposition table here
std::vector<std::vector<std::vector<std::vector<double> > > > TableA = make_4d_vector<double>(pow(10,6), 4, 4,3, -1);
//std::vector<std::vector<std::vector<double> > > TableA = make_3d_vector<double>(pow(10,6), 4, 4, -1);
//std::cout << TableA[5][5][5] << '\n'; //20
std::vector<std::vector<std::vector<double> > > TableB = make_3d_vector<double>(pow(10,6), 3, 3, -1);
//std::vector<std::vector<double> > TableB = make_2d_vector<double>(pow(10,6), 3, -1);
//TableB[5][5]=78.8;
//std::cout << TableB[5][5] << '\n'; //20
std::array<double, 3> TreeAfter(board after,int hint,int last)
{
if (hint==0){
int i=0;
std::array<double, 3> Value={1000000,0,-1000000};
for (int pos=0;pos<=5;pos++) {
for (int tile=1;tile<=3;tile++) {
board before=after;
before(pos) = tile;
Value=allhint(before,hint,i,Value);
i++;
}
}
TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][last]={Value[0],Value[1],Value[2]};
//std::cout<<"a "<<after<<" +"<<hint<<"= "<<Value[1]<<'\n';
return Value;
}
else{
if (last==0){
int i=0;
std::array<double, 3> Value={1000000,0,-1000000};
for (int pos=3;pos<=5;pos++) {
board before=after;
if (before(pos) != 0) continue;
before(pos) = hint;
Value=allhint(before,hint,i,Value);
i++;
//std::cout<<before<<'\n';
}
TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][last]={Value[0],Value[1],Value[2]};
//std::cout<<"a "<<after<<" +"<<hint<<"= "<<Value[1]<<'\n';
return Value;
}
else if (last==1){
int i=0;
std::array<double, 3> Value={1000000,0,-1000000};
for (int pos=0;pos<=3;pos=pos+3) {
board before=after;
if (before(pos) != 0) continue;
before(pos) = hint;
Value=allhint(before,hint,i,Value);
i++;
//std::cout<<before<<'\n';
}
TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][last]={Value[0],Value[1],Value[2]};
//std::cout<<"a "<<after<<" +"<<hint<<"= "<<Value[1]<<'\n';
return Value;
}
else if (last==2){
int i=0;
std::array<double, 3> Value={1000000,0,-1000000};
for (int pos=0;pos<=2;pos++) {
board before=after;
if (before(pos) != 0) continue;
before(pos) = hint;
Value=allhint(before,hint,i,Value);
i++;
//std::cout<<before<<'\n';
}
TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][last]={Value[0],Value[1],Value[2]};
//std::cout<<"a "<<after<<" +"<<hint<<"= "<<Value[1]<<'\n';
return Value;
}
else if (last==3){
int i=0;
std::array<double, 3> Value={1000000,0,-1000000};
for (int pos=2;pos<=5;pos=pos+3) {
board before=after;
if (before(pos) != 0) continue;
before(pos) = hint;
Value=allhint(before,hint,i,Value);
i++;
//std::cout<<before<<'\n';
}
TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][last]={Value[0],Value[1],Value[2]};
//std::cout<<"a "<<after<<" +"<<hint<<"= "<<Value[1]<<'\n';
return Value;
}
}
}
std::array<double, 3> allhint(board before, int hint, int i, std::array<double, 3> Value)
{ int total=0;
for (int pos=0;pos<=5;pos++) {
total+=IndextoValue(before(pos));
}
if (total%6==0){
Value[1]=Value[1]*i*3;
for (int hint_=1;hint_<=3;hint_++){
Value=Fvalue(before,hint_,Value);
}
return {Value[0],Value[1]/((i+1)*3),Value[2]};
}
else if (total%6==1){
Value[1]=Value[1]*i*2;
for (int hint_=2;hint_<=3;hint_++){
Value=Fvalue(before,hint_,Value);
}
return {Value[0],Value[1]/((i+1)*2),Value[2]};
}
else if (total%6==2){
Value[1]=Value[1]*i*2;
for (int hint_=1;hint_<=3;hint_=hint_+2){
Value=Fvalue(before,hint_,Value);
}
return {Value[0],Value[1]/((i+1)*2),Value[2]};
}
else if (total%6==3 & (hint==3 or hint==0) ){
Value[1]=Value[1]*i*2;
for (int hint_=1;hint_<=2;hint_++){
Value=Fvalue(before,hint_,Value);
}
return {Value[0],Value[1]/((i+1)*2),Value[2]};
}
else if (total%6==3 & hint!=3){
Value[1]=Value[1]*i;
int hint_=3;
Value=Fvalue(before,hint_,Value);
return {Value[0],Value[1]/((i+1)),Value[2]};
}
else if (total%6==4){
Value[1]=Value[1]*i;
int hint_=2;
Value=Fvalue(before,hint_,Value);
return {Value[0],Value[1]/((i+1)),Value[2]};
}
else if (total%6==5){
Value[1]=Value[1]*i;
int hint_=1;
Value=Fvalue(before,hint_,Value);
return {Value[0],Value[1]/((i+1)),Value[2]};
}
}
std::array<double, 3> Fvalue(board before,int hint_,std::array<double, 3> Value){
if (TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10+before(5)][hint_-1][1]!=-1){
Value[1]+=TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10+before(5)][hint_-1][1];
}
else{
Value[1]+=TreeBefore(before,hint_)[1];
}
if (TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10+before(5)][hint_-1][0]!=-1){
Value[0]=std::min(Value[0],TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10+before(5)][hint_-1][0]); }
else{
Value[0]=std::min(Value[0],TreeBefore(before,hint_)[0]);
}
if (TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10+before(5)][hint_-1][2]!=-1){
Value[2]=std::max(Value[2],TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10+before(5)][hint_-1][2]); }
else{
Value[2]=std::max(Value[2],TreeBefore(before,hint_)[2]);
}
return Value;
}
std::array<double, 3> TreeBefore(board before,int hint)
{
int N_Beforechildnode=0;
std::array<double, 3> Value={0,-1000000000,0};
for (int slide=3;slide>=0;slide=slide-1) {
board after=before;
board::reward reward = after.slide(slide);
if (reward != -1){
if (TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][slide][1]!=-1){
if (TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][slide][1]>Value[1]){
Value[0]=TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][slide][0];
Value[1]=TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][slide][1];
Value[2]=TableA[after(0)*pow(10,5)+after(1)*pow(10,4)+after(2)*pow(10,3)+after(3)*pow(10,2)+after(4)*10+after(5)][hint][slide][2];
}
}
else{
if (TreeAfter(after,hint,slide)[1]>Value[1]){
Value=TreeAfter(after,hint,slide);
}
}
N_Beforechildnode++;
}
}
if (N_Beforechildnode!=0){ // non terminal state
TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10+before(5)][hint-1]={Value[0],Value[1],Value[2]};
//std::cout<<"b "<<before<<" +"<<hint<<"= "<<Value<<'\n';
//std::cout<<"b "<<before<<" +"<<hint<<'\n';
return Value;
}
else{ //terminal state
TableB[before(0)*pow(10,5)+before(1)*pow(10,4)+before(2)*pow(10,3)+before(3)*pow(10,2)+before(4)*10
+before(5)][hint-1]={StateValue(before),StateValue(before),StateValue(before)};
//std::cout<<"b "<<before<<" +"<<hint<<"= "<<StateValue(before)<<" terminal"<<'\n';
return {StateValue(before),StateValue(before),StateValue(before)};
}
}
};
| [
"fuj30089@gmail.com"
] | fuj30089@gmail.com |
acaf12d0c11496998363a47d0173b3efebd0f76d | 74b331f98903b818d2d742998f79404049c33b67 | /test/bfs,dfs.cpp | cb2674389f42e854663772d8919e087fb8440131 | [] | no_license | nik258heda/CS204 | 0992c28b0020333eaff6a0d7a876eff4610f13f1 | 23ca0864d5aa9de556921fb9e4c7b0a27b307841 | refs/heads/master | 2020-06-28T21:29:15.870668 | 2019-11-14T13:56:33 | 2019-11-14T13:56:33 | 200,346,382 | 0 | 0 | null | 2019-08-03T10:36:50 | 2019-08-03T07:30:54 | C++ | UTF-8 | C++ | false | false | 850 | cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
const ll N=1e6+5;
vector<vector<ll>> adj(N);
queue<ll> q;
vector<bool> used(N);
vector<ll> d(N), p(N);
void bfs(ll s){
q.push(s);
used[s] = true;
p[s] = -1;
while (!q.empty()) {
ll v = q.front();
cout<<v<<" ";
q.pop();
for (ll u : adj[v]) {
if (!used[u]) {
used[u] = true;
q.push(u);
d[u] = d[v] + 1;
p[u] = v;
}
}
}
fill(used.begin(),used.end(),false);
//This is so it clears previous history, it will not be their for particular questions.
}
void dfs(ll v) {
used[v] = true;
cout<<v<<" ";
for(ll u : adj[v]){
if(!used[u])
dfs(u);
}
}
int main(){
int n;
cin>>n;
//Input Here
bfs(x);
dfs(y);
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
da53fad4eb05c3032970681c77509305a67eddc2 | fae551eb54ab3a907ba13cf38aba1db288708d92 | /chromeos/services/ime/public/mojom/mojom_traits.cc | 5197900488e5835a097f9183f0aa3e75860213bf | [
"BSD-3-Clause"
] | permissive | xtblock/chromium | d4506722fc6e4c9bc04b54921a4382165d875f9a | 5fe0705b86e692c65684cdb067d9b452cc5f063f | refs/heads/main | 2023-04-26T18:34:42.207215 | 2021-05-27T04:45:24 | 2021-05-27T04:45:24 | 371,258,442 | 2 | 1 | BSD-3-Clause | 2021-05-27T05:36:28 | 2021-05-27T05:36:28 | null | UTF-8 | C++ | false | false | 3,122 | cc | // Copyright 2021 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 "chromeos/services/ime/public/mojom/mojom_traits.h"
#include "chromeos/services/ime/public/mojom/input_engine.mojom-shared.h"
namespace mojo {
namespace {
using CompletionCandidateDataView =
chromeos::ime::mojom::CompletionCandidateDataView;
using SuggestionMode = chromeos::ime::mojom::SuggestionMode;
using SuggestionType = chromeos::ime::mojom::SuggestionType;
using SuggestionCandidateDataView =
chromeos::ime::mojom::SuggestionCandidateDataView;
using TextCompletionCandidate = chromeos::ime::TextCompletionCandidate;
using TextSuggestionMode = chromeos::ime::TextSuggestionMode;
using TextSuggestionType = chromeos::ime::TextSuggestionType;
using TextSuggestion = chromeos::ime::TextSuggestion;
} // namespace
SuggestionMode EnumTraits<SuggestionMode, TextSuggestionMode>::ToMojom(
TextSuggestionMode mode) {
switch (mode) {
case TextSuggestionMode::kCompletion:
return SuggestionMode::kCompletion;
case TextSuggestionMode::kPrediction:
return SuggestionMode::kPrediction;
}
}
bool EnumTraits<SuggestionMode, TextSuggestionMode>::FromMojom(
SuggestionMode input,
TextSuggestionMode* output) {
switch (input) {
case SuggestionMode::kCompletion:
*output = TextSuggestionMode::kCompletion;
return true;
case SuggestionMode::kPrediction:
*output = TextSuggestionMode::kPrediction;
return true;
}
return false;
}
SuggestionType EnumTraits<SuggestionType, TextSuggestionType>::ToMojom(
TextSuggestionType type) {
switch (type) {
case TextSuggestionType::kAssistivePersonalInfo:
return SuggestionType::kAssistivePersonalInfo;
case TextSuggestionType::kAssistiveEmoji:
return SuggestionType::kAssistiveEmoji;
case TextSuggestionType::kMultiWord:
return SuggestionType::kMultiWord;
}
}
bool EnumTraits<SuggestionType, TextSuggestionType>::FromMojom(
SuggestionType input,
TextSuggestionType* output) {
switch (input) {
case SuggestionType::kAssistivePersonalInfo:
*output = TextSuggestionType::kAssistivePersonalInfo;
return true;
case SuggestionType::kAssistiveEmoji:
*output = TextSuggestionType::kAssistiveEmoji;
return true;
case SuggestionType::kMultiWord:
*output = TextSuggestionType::kMultiWord;
return true;
}
return false;
}
bool StructTraits<SuggestionCandidateDataView, TextSuggestion>::Read(
SuggestionCandidateDataView input,
TextSuggestion* output) {
if (!input.ReadMode(&output->mode))
return false;
if (!input.ReadType(&output->type))
return false;
if (!input.ReadText(&output->text))
return false;
return true;
}
bool StructTraits<CompletionCandidateDataView, TextCompletionCandidate>::Read(
CompletionCandidateDataView input,
TextCompletionCandidate* output) {
if (!input.ReadText(&output->text))
return false;
output->score = input.normalized_score();
return true;
}
} // namespace mojo
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
73dbf67617a8dc159828cad343fb463a0b991037 | 8e442102fb22f57a842f3883eede10b9a4e120be | /PokerHands/BestHand.h | 55cb12d0690f6b0bbcbd701486b7bb40da5f0f89 | [] | no_license | ManicMeerkat/PokerHands | 403467e4b096bf1a18d0317424ce6e6616a127af | d20b40aa091ec8f3432c621b65ea0669f9cc5bf1 | refs/heads/master | 2021-01-16T18:20:11.610537 | 2013-08-13T06:33:10 | 2013-08-13T06:33:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,089 | h | #pragma once
#include <string>
#include "Card.h"
//------------------------------------------------------
//BestHand is the representation of the best possible hand.
//It doesn't have cards. It only has components of a description of the best hand.
//Type is the quality of the hand, in order from weakest to strongest
//Suit is the name of the suit making the hand, for which suit is appropriate (flushes)
//Rank1 is the rank of the primary card rank making up the hand. This is the stronger of the two ranks in a two pair or a full house,
//or the single rank for a high card, pair, four of a kind, or the highest card in a straight
//Rank2 is the rank of the secondary (or weaker) card in the hand, where appropriate, such as the lower card rank in
//a two pair or full house.
class Hand;
class BestHand
{
public:
BestHand(const Hand& hand);
enum Type {InvalidHand, HighCard, Pair, TwoPair, ThreeOfAKind, Straight, Flush, FullHouse, FourOfAKind, StraightFlush};
std::string getDescription() const;
protected:
Type type;
Card::Rank rank1;
Card::Rank rank2;
Card::Suit suit;
};
| [
"jlpollack@gmail.com"
] | jlpollack@gmail.com |
11ec48e9fd0bde9124ab9e35972115d968494b38 | ed3a1bfb78362eab5dbed63b529d404f913f031c | /435LGame/bullet.h | 00788db0a1c977e052e58db2ca4cb1ca7c28bcbb | [] | no_license | AliAkbarH/435LGame | 6ca4c4c009bc2973eb8560c6af704640c633a9f3 | 02a156a9a5cbccde8e7c072d919eafefba4b826f | refs/heads/master | 2020-03-30T01:39:25.807514 | 2018-12-09T18:09:00 | 2018-12-09T18:09:00 | 150,587,361 | 0 | 0 | null | 2018-11-07T05:46:45 | 2018-09-27T12:59:32 | C++ | UTF-8 | C++ | false | false | 873 | h | /**
\file bullet.h
\brief QGraphicsPixmapItem representing the bullets
\author Ali Al Akbar Haidoura
*/
#ifndef BULLET_H
#define BULLET_H
#include <QGraphicsPixmapItem>
#include<QTimer>
#include<QDebug>
#include"game2scene.h"
class Bullet :public QObject, public QGraphicsPixmapItem
{
Q_OBJECT
public:
Bullet(int direction, int x, int y, Game2Scene *scene);//!<Bullet Constructor
QPixmap *icon;//!<QPixmap holding the image of the bullet
QTimer *timer;//!<QTimer that trigger s==s
Game2Scene *scene;//!<The Scene where the Bullet is
int step;//!<A steps counter used for deleting the bullet at a certain range
int direction;//!<Integer holding the direction of the Bullet according to the last step the tester made
signals:
public slots:
void move();//!<The slot that moves the Bullet on the timer's timeout
};
#endif // BULLET_H
| [
"ahh68@mail.aub.edu"
] | ahh68@mail.aub.edu |
ac4d649c1f081e184cdb55735423051f4706e731 | 3857a7da8adeaf993c7f94210019c7c58d67b1ad | /지상엽/BrainFUck/2774 - 아름다운 수/Source.cpp | de440b627c2688a17a318106d96cd0965e46ec1d | [] | no_license | CodeSang/Koreatech_study | 16b005710dec771ded33edcffafe95d203a4b688 | 5d1b06695b299b3746412f332189d4bae9e54f8b | refs/heads/master | 2020-12-29T00:41:36.424448 | 2016-08-24T02:20:53 | 2016-08-24T02:20:53 | 62,278,334 | 2 | 2 | null | 2016-07-19T09:24:12 | 2016-06-30T04:05:45 | C++ | UTF-8 | C++ | false | false | 315 | cpp | #include<iostream>
#include<algorithm>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int mat[10] = { 0 };
int temp;
cin >> temp;
while (temp)
{
mat[temp % 10] = 1;
temp /= 10;
}
int maxi = 0;
for (int i = 0; i < 10; i++)
maxi += mat[i];
cout << maxi << endl;
}
}
| [
"tkdduq9915@koreatech.ac.kr"
] | tkdduq9915@koreatech.ac.kr |
ccd79ad1eb949c961c157917000e33b648a0e823 | d71d11e4847387c1592fe0eeace108dbb2701a05 | /ios/CoreLocation_interface.h | e939235190e12b59881e3f5ca7d10e74d704b60d | [
"MIT"
] | permissive | frranck/CCGeolocation | 4405e22dac25cd48bb88013ffe904e7a530e5561 | 8f855273d3248f32eabb96df737e162d79c9a84e | refs/heads/master | 2020-05-22T14:16:35.411103 | 2016-01-26T10:41:23 | 2016-01-26T10:41:23 | 10,865,073 | 8 | 5 | null | 2016-01-26T10:41:24 | 2013-06-22T12:55:07 | Java | UTF-8 | C++ | false | false | 379 | h | //
// CoreLocation_interface.h
//
// Created by franck on 4/12/13.
//
//
#ifndef CoreLocation_interface_h
#define CoreLocation_interface_h
class CoreLocationImpl
{
public:
CoreLocationImpl ( void );
~CoreLocationImpl( void );
static CoreLocationImpl * getInstance();
bool init( void );
void dealloc ( void );
private:
void * self;
};
#endif
| [
"franck@secretfatty.net"
] | franck@secretfatty.net |
3f6867f36e8554cfbbf6e8ad9d6e4b5e50453a34 | 11da664bcd3a9d8d2f4d919faf2869f1d2fb85fb | /test/unit/DedupBlocksTest.cpp | a6cc70494d0f04c8791d55bd290332375cbd49f3 | [
"MIT"
] | permissive | anchit87/redex | 503b3fa1b0b117bfc4b6cc27d5cace0203780b6e | 612396644ac7ba6d67924db000ce74d8fc85548d | refs/heads/master | 2020-08-15T00:35:48.967304 | 2019-10-15T09:07:53 | 2019-10-15T09:07:53 | 215,254,545 | 0 | 0 | MIT | 2019-10-15T09:07:54 | 2019-10-15T09:05:52 | null | UTF-8 | C++ | false | false | 18,634 | cpp | /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <gtest/gtest.h>
#include <iterator>
#include "ControlFlow.h"
#include "Creators.h"
#include "DedupBlocksPass.h"
#include "DexAsm.h"
#include "DexUtil.h"
#include "IRAssembler.h"
#include "IRCode.h"
#include "RedexTest.h"
struct Branch {
MethodItemEntry* source;
MethodItemEntry* target;
};
void run_passes(std::vector<Pass*> passes, std::vector<DexClass*> classes) {
std::vector<DexStore> stores;
DexMetadata dm;
dm.set_id("classes");
DexStore store(dm);
store.add_classes(classes);
stores.emplace_back(std::move(store));
PassManager manager(passes);
manager.set_testing_mode();
Json::Value conf_obj = Json::nullValue;
ConfigFiles dummy_config(conf_obj);
manager.run_passes(stores, dummy_config);
}
struct DedupBlocksTest : public RedexTest {
DexClass* m_class;
DexTypeList* m_args;
DexProto* m_proto;
DexType* m_type;
ClassCreator* m_creator;
DedupBlocksTest() {
m_args = DexTypeList::make_type_list({});
m_proto = DexProto::make_proto(known_types::_void(), m_args);
m_type = DexType::make_type("testClass");
m_creator = new ClassCreator(m_type);
m_class = m_creator->get_class();
}
DexMethod* get_fresh_method(const std::string& name) {
DexMethod* method =
DexMethod::make_method(m_type, DexString::make_string(name), m_proto)
->make_concrete(ACC_PUBLIC | ACC_STATIC, false);
method->set_code(std::make_unique<IRCode>(method, 1));
m_creator->add_method(method);
return method;
}
void run_dedup_blocks() {
std::vector<Pass*> passes = {new DedupBlocksPass()};
std::vector<DexClass*> classes = {m_class};
run_passes(passes, classes);
}
~DedupBlocksTest() {}
};
// in Code: A B E C D (where C == D)
// in CFG: A -> B -> C -> E
// \ /
// > -- D >
//
// out Code: A B E C
// out CFG: A -> B -> C -> E
// \ /
// > --- >
TEST_F(DedupBlocksTest, simplestCase) {
using namespace dex_asm;
DexMethod* method = get_fresh_method("simplestCase");
auto str = R"(
(
; A
(const v0 0)
(mul-int v0 v0 v0)
(if-eqz v0 :D)
; B
(mul-int v0 v0 v0)
(goto :C)
(:E)
(return-void)
(:C)
(add-int v0 v0 v0)
(goto :E)
(:D)
(add-int v0 v0 v0)
(goto :E)
)
)";
auto code = assembler::ircode_from_string(str);
method->set_code(std::move(code));
run_dedup_blocks();
auto expected_str = R"(
(
; A
(const v0 0)
(mul-int v0 v0 v0)
(if-eqz v0 :C)
; B
(mul-int v0 v0 v0)
(:C)
(add-int v0 v0 v0)
; E
(return-void)
; no D!
)
)";
auto expected_code = assembler::ircode_from_string(expected_str);
EXPECT_CODE_EQ(expected_code.get(), method->get_code());
}
// in Code: A B E C D (where C and D ends with same instructions)
// in CFG: A -> B -> C -> E
// \ /
// > -- D >
//
// out Code: A B E C
// out CFG: A -> B -> C' -> F -> E
// \ /
// > --------- D'
TEST_F(DedupBlocksTest, simplestPostfixCase) {
using namespace dex_asm;
DexMethod* method = get_fresh_method("simplestPostfixCase");
auto str = R"(
(
; A
(const v0 0)
(mul-int v0 v0 v0)
(if-eqz v0 :D)
; B
(mul-int v0 v0 v0)
(goto :C)
(:E)
(return-void)
(:C)
(mul-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(goto :E)
(:D)
(const v1 1)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(goto :E)
)
)";
auto code = assembler::ircode_from_string(str);
method->set_code(std::move(code));
run_dedup_blocks();
auto expected_str = R"(
(
; A
(const v0 0)
(mul-int v0 v0 v0)
(if-eqz v0 :D)
; B
(mul-int v0 v0 v0)
; C
(mul-int v0 v0 v0)
(:F)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(:E)
(return-void)
(:D)
(const v1 1)
(goto :F)
)
)";
auto expected_code = assembler::ircode_from_string(expected_str);
EXPECT_CODE_EQ(expected_code.get(), method->get_code());
}
TEST_F(DedupBlocksTest, postfixDiscardingOneCase) {
using namespace dex_asm;
DexMethod* method = get_fresh_method("postfixDiscardingOneCase");
auto str = R"(
(
; A
(const v0 0)
(mul-int v0 v0 v0)
(if-eqz v0 :D)
; B
(mul-int v0 v0 v0)
(goto :C)
(:E)
(return-void)
(:C)
(mul-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(goto :E)
(:D)
(if-eqz v0 :F)
(goto :G)
(:F)
(const v2 2)
(goto :E)
(:G)
(const v1 1)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(goto :E)
)
)";
auto code = assembler::ircode_from_string(str);
method->set_code(std::move(code));
run_dedup_blocks();
auto expected_str = R"(
(
; A
(const v0 0)
(mul-int v0 v0 v0)
(if-eqz v0 :D)
; B
(mul-int v0 v0 v0)
(:C)
(mul-int v0 v0 v0)
(:H)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(:E)
(return-void)
(:D)
(if-eqz v0 :F)
(:G)
(const v1 1)
(goto :H)
(:F)
(const v2 2)
(goto :E)
)
)";
auto expected_code = assembler::ircode_from_string(expected_str);
EXPECT_CODE_EQ(expected_code.get(), method->get_code());
}
TEST_F(DedupBlocksTest, deepestIsNotTheBestCase) {
using namespace dex_asm;
DexMethod* method = get_fresh_method("deepestIsNotTheBestCase");
auto str = R"(
(
(const v0 0)
(const v1 1)
(switch v0 (:a :b :c :d :e :f))
(return v0)
(:a 0)
(return v0)
(:b 1)
(const v1 1)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
(:c 2)
(const v1 2)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
(:d 3)
(const v0 0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
(:e 4)
(const v0 0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
(:f 5)
(const v0 0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
)
)";
auto code = assembler::ircode_from_string(str);
method->set_code(std::move(code));
run_dedup_blocks();
auto expected_str = R"(
(
(const v0 0)
(const v1 1)
(switch v0 (:a :b :c :d :e :f))
(:a 0)
(return v0)
(:f 5)
(:e 4)
(:d 3)
(const v0 0)
(goto :g)
(:c 2)
(const v1 2)
(goto :g)
(:b 1)
(const v1 1)
(:g)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
)
)";
auto expected_code = assembler::ircode_from_string(expected_str);
EXPECT_CODE_EQ(expected_code.get(), method->get_code());
}
TEST_F(DedupBlocksTest, postfixSwitchCase) {
using namespace dex_asm;
DexMethod* method = get_fresh_method("postfixSwitchCase");
auto str = R"(
(
(const v0 0)
(const v1 1)
(switch v0 (:a :b :c))
(:a 0)
(return v0)
(:b 1)
(const v1 1)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
(:c 2)
(const v0 0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
)
)";
auto code = assembler::ircode_from_string(str);
method->set_code(std::move(code));
run_dedup_blocks();
auto expected_str = R"(
(
(const v0 0)
(const v1 1)
(switch v0 (:a :b :c))
(:a 0)
(return v0)
(:c 2)
(const v0 0)
(goto :d)
(:b 1)
(const v1 1)
(:d)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(add-int v0 v0 v0)
(return v1)
)
)";
auto expected_code = assembler::ircode_from_string(expected_str);
EXPECT_CODE_EQ(expected_code.get(), method->get_code());
}
TEST_F(DedupBlocksTest, noDups) {
auto str = R"(
(
(const v0 0)
(if-eqz v0 :lbl)
(const v0 1)
(:lbl)
(return v0)
)
)";
auto method = get_fresh_method("noDups");
auto code = assembler::ircode_from_string(str);
method->set_code(std::move(code));
run_dedup_blocks();
auto expected_code = assembler::ircode_from_string(str);
EXPECT_CODE_EQ(expected_code.get(), method->get_code());
}
TEST_F(DedupBlocksTest, repeatedSwitchBlocks) {
auto input_code = assembler::ircode_from_string(R"(
(
(const v0 0)
(const v1 1)
(switch v0 (:a :b :c))
(return v0)
(:a 0)
(return v0)
(:b 1)
(return v1)
(:c 2)
(return v1)
)
)");
auto method = get_fresh_method("repeatedSwitchBlocks");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expected_code = assembler::ircode_from_string(R"(
(
(const v0 0)
(const v1 1)
(switch v0 (:a :b :c))
(:a 0)
(return v0)
(:c 2)
(:b 1)
(return v1)
)
)");
EXPECT_CODE_EQ(expected_code.get(), code);
}
TEST_F(DedupBlocksTest, diffSuccessorsNoChange1) {
auto str = R"(
(
(const v0 0)
(if-eqz v0 :left)
; right
; same code as `:left` block but different successors
(const v1 1)
(if-eqz v1 :right2)
(:middle)
(return-void)
(:right2)
(const v3 3)
(goto :middle)
(:left)
(const v1 1)
(if-eqz v1 :left2)
(goto :middle)
(:left2)
(const v2 2)
(goto :middle)
)
)";
auto input_code = assembler::ircode_from_string(str);
auto method = get_fresh_method("diffSuccessorsNoChange1");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expected_code = assembler::ircode_from_string(str);
EXPECT_CODE_EQ(expected_code.get(), code);
}
TEST_F(DedupBlocksTest, diffSuccessorsNoChange2) {
auto str = R"(
(
(const v0 0)
(if-eqz v0 :left)
; right
; same code as `:left` block but different successors
(const v1 1)
(if-eqz v1 :middle)
; right2
(const v3 3)
(:middle)
(return-void)
(:left)
(const v1 1)
(if-eqz v1 :middle)
; left2
(const v2 2)
(goto :middle)
)
)";
auto input_code = assembler::ircode_from_string(str);
auto method = get_fresh_method("diffSuccessorsNoChange2");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expected_code = assembler::ircode_from_string(str);
EXPECT_CODE_EQ(expected_code.get(), code);
}
TEST_F(DedupBlocksTest, diamond) {
auto input_code = assembler::ircode_from_string(R"(
(
(const v0 0)
(if-eqz v0 :left)
(goto :right)
(:left)
(const v1 1)
(goto :middle)
(:right)
(const v1 1)
(:middle)
(return-void)
)
)");
auto method = get_fresh_method("diamond");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expected_code = assembler::ircode_from_string(R"(
(
(const v0 0)
(if-eqz v0 :left)
(:left)
(const v1 1)
(:middle)
(return-void)
)
)");
EXPECT_CODE_EQ(expected_code.get(), code);
}
// in Code: A B C (where B == C,
// and they contain a pair of new-instance and constructor instructions)
// in CFG: A -> B
// \
// > C
// out Code: A B
// out CFG: A -> B
TEST_F(DedupBlocksTest, blockWithNewInstanceAndConstroctor) {
auto input_code = assembler::ircode_from_string(R"(
(
(:a)
(const v0 0)
(const v1 1)
(if-eqz v0 :c)
(:b)
(new-instance "testClass")
(move-result-pseudo-object v0)
(invoke-direct (v0 v1) "testClass.<init>:(I)V")
(throw v0)
(:c)
(new-instance "testClass")
(move-result-pseudo-object v0)
(invoke-direct (v0 v1) "testClass.<init>:(I)V")
(throw v0)
)
)");
auto method = get_fresh_method("blockWithNewInstanceAndConstroctor");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expected_code = assembler::ircode_from_string(R"(
(
(:a)
(const v0 0)
(const v1 1)
(if-eqz v0 :c)
(:b)
(:c)
(new-instance "testClass")
(move-result-pseudo-object v0)
(invoke-direct (v0 v1) "testClass.<init>:(I)V")
(throw v0)
)
)");
EXPECT_CODE_EQ(expected_code.get(), code);
}
// in Code: A B C D E (where C == E,
// and they construct an object from B and D respectively)
// in CFG: A -> B -> C
// \
// > D -> E
// out Code: the same as the in Code
// out CFG: the same as the in CFG
TEST_F(DedupBlocksTest, constructsObjectFromAnotherBlock) {
std::string str_code = R"(
(
(:a)
(const v0 0)
(if-eqz v0 :d)
(:b)
(new-instance "testClass")
(move-result-pseudo-object v0)
(:c)
(const v1 1)
(invoke-direct (v0 v1) "testClass.<init>:(I)V")
(throw v0)
(:d)
(new-instance "testClass")
(move-result-pseudo-object v0)
(const v1 2)
(:e)
(const v1 1)
(invoke-direct (v0 v1) "testClass.<init>:(I)V")
(throw v0)
)
)";
auto input_code = assembler::ircode_from_string(str_code);
auto method = get_fresh_method("constructsObjectFromAnotherBlock");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expect_code = assembler::ircode_from_string(str_code);
EXPECT_CODE_EQ(expect_code.get(), code);
}
// newly created instances may be moved around, but that doesn't change that
// we must not dedup in the face of multiple new-instance instructions
TEST_F(DedupBlocksTest, constructsObjectFromAnotherBlockViaMove) {
std::string str_code = R"(
(
(:a)
(const v0 0)
(if-eqz v0 :d)
(:b)
(new-instance "testClass")
(move-result-pseudo-object v2)
(:c)
(move-object v0 v2)
(const v1 1)
(invoke-direct (v0 v1) "testClass.<init>:(I)V")
(throw v0)
(:d)
(new-instance "testClass")
(move-result-pseudo-object v2)
(const v1 2)
(:e)
(move-object v0 v2)
(const v1 1)
(invoke-direct (v0 v1) "testClass.<init>:(I)V")
(throw v0)
)
)";
auto input_code = assembler::ircode_from_string(str_code);
auto method = get_fresh_method("constructsObjectFromAnotherBlock");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expect_code = assembler::ircode_from_string(str_code);
EXPECT_CODE_EQ(expect_code.get(), code);
}
TEST_F(DedupBlocksTest, dedupCatchBlocks) {
std::string str_code = R"(
(
(.try_start t_0)
(new-instance "testClass")
(move-result-pseudo-object v0)
(invoke-direct (v0) "testClass.<init>:()V")
(.try_end t_0)
(.try_start t_2)
(iget v0 "testClass;.a:I")
(move-result-pseudo v2)
(.try_end t_2)
(.try_start t_1)
(iget v0 "testClass;.b:I")
(move-result-pseudo v3)
(.try_end t_1)
(return-void)
(:block_catch_t_0)
(.catch (t_0))
(move-exception v2)
(throw v2)
(:block_catch_t_1)
(.catch (t_1))
(move-exception v2)
(throw v2)
(:block_catch_t_2)
(.catch (t_2))
(throw v0)
)
)";
auto input_code = assembler::ircode_from_string(str_code);
auto method = get_fresh_method("dedupCatchBlocks");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
std::string expect_str = R"(
(
(.try_start t_0)
(new-instance "testClass")
(move-result-pseudo-object v0)
(invoke-direct (v0) "testClass.<init>:()V")
(.try_end t_0)
(.try_start t_2)
(iget v0 "testClass;.a:I")
(move-result-pseudo v2)
(.try_end t_2)
(.try_start t_0)
(iget v0 "testClass;.b:I")
(move-result-pseudo v3)
(.try_end t_0)
(return-void)
(:block_catch_t_0)
(.catch (t_0))
(move-exception v2)
(throw v2)
(:block_catch_t_2)
(.catch (t_2))
(throw v0)
)
)";
auto expect_code = assembler::ircode_from_string(expect_str);
expect_code->build_cfg(true);
expect_code->clear_cfg();
EXPECT_CODE_EQ(expect_code.get(), code);
}
TEST_F(DedupBlocksTest, dontDedupCatchBlockAndNonCatchBlock) {
std::string str_code = R"(
(
(.try_start t_0)
(new-instance "testClass")
(move-result-pseudo-object v0)
(invoke-direct (v0) "testClass.<init>:()V")
(.try_end t_0)
(if-eqz v0 :block_no_catch)
(return-void)
(:block_catch_t_0)
(.catch (t_0))
(move-exception v2)
(throw v2)
(:block_no_catch)
(move-exception v2)
(throw v2)
)
)";
auto input_code = assembler::ircode_from_string(str_code);
auto method = get_fresh_method("dontDedupCatchBlockAndNonCatchBlock");
method->set_code(std::move(input_code));
auto code = method->get_code();
run_dedup_blocks();
auto expect_code = assembler::ircode_from_string(str_code);
expect_code->build_cfg(true);
expect_code->clear_cfg();
EXPECT_CODE_EQ(expect_code.get(), code);
}
TEST_F(DedupBlocksTest, respectTypes) {
using namespace dex_asm;
DexMethod* method = get_fresh_method("v");
auto str = R"(
(
; A
(const-string "hello")
(move-result-pseudo-object v0)
(if-eqz v0 :D)
; B
(const v0 1)
(if-eqz v0 :C)
(:E)
(return-void)
(:C)
(if-nez v0 :E)
(goto :E)
(:D)
(if-nez v0 :E)
(goto :E)
)
)";
auto code = assembler::ircode_from_string(str);
method->set_code(std::move(code));
run_dedup_blocks();
auto expected_str = str;
auto expected_code = assembler::ircode_from_string(expected_str);
EXPECT_CODE_EQ(expected_code.get(), method->get_code());
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
41d9c05154792178979fbffbaf224c7ecbbf20cb | 6e5dc3a7f4552010a8fde3b4109b688027f7cc6f | /DsApp/Source/NeuralNetwork/DsNeuronCtrl.h | b22ae93e49cf327807a38a47fa966af3947bc1ec | [] | no_license | Dsukeaaa/DsApplication | 00f95b2a46ad0f5bfa005babefb8195464d46356 | c495fca2b9af84500bf8bf788864d8f1be788889 | refs/heads/master | 2021-06-25T14:18:59.964000 | 2020-09-25T15:27:25 | 2020-09-25T15:27:25 | 165,542,044 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 563 | h | #ifndef _DS_NEURON_CTRL_
namespace DsApp
{
struct DsNeuralNetwork;
}
namespace DsApp
{
class DsNeuronCtrl
{
public:
DsNeuronCtrl()
: m_inputNum(0)
, m_outputNum(0)
, m_innerLayerNum(0)
, m_innerNeuronNum(0)
{}
virtual ~DsNeuronCtrl(){}
public:
DsNeuralNetwork* CreateNeuralNetwork();
void CalcOutput(DsNeuralNetwork* pNet );
private:
int m_inputNum;//入力ニューロン数
int m_outputNum;//出力ニューロン数
int m_innerLayerNum;//中間層数
int m_innerNeuronNum;//中間層ニューロン数
};
}
#endif | [
"dddddd.d.d.d.b@gmail.com"
] | dddddd.d.d.d.b@gmail.com |
b0d468c6445ae5797c1597b69a89b0190a805edf | 050c8a810d34fe125aecae582f9adfd0625356c6 | /JBOI/2009/E - BBQ Hard/main.cpp | b84909d777e062e5f9674f239e9f54a60d456b71 | [] | no_license | georgerapeanu/c-sources | adff7a268121ae8c314e846726267109ba1c62e6 | af95d3ce726325dcd18b3d94fe99969006b8e138 | refs/heads/master | 2022-12-24T22:57:39.526205 | 2022-12-21T16:05:01 | 2022-12-21T16:05:01 | 144,864,608 | 11 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,039 | cpp | #include <iostream>
#define MOD 1000000007
using namespace std;
pair<int,int> V[200005];
bool cmp(pair<int,int> a,pair<int,int> b)
{
return a.first+a.second<b.first+b.second;
}
int lgpow(int b,int e)
{
int p=1;
while(e)
{
if(e&1)p=(1LL*p*b)%MOD;
b=(1LL*b*b)%MOD;
e>>=1;
}
return p;
}
int fact[10005];
int inv[10005];
int frecv[4005];
int N;
int rez;
int c,d;
void eval()
{
rez=0;
for(int i=1;i<=4000;i++)
{
rez=(rez+(1LL*frecv[i]*((1LL*fact[c+i]*inv[c])%MOD))%MOD)%MOD;
}
}
void scoate(int d)
{
rez=((rez-1LL*fact[c+d]*inv[c])%MOD+MOD)%MOD;
frecv[d]--;
}
void creste(int x)
{
}
int main()
{
fact[0]=inv[0]=1;
for(int i=1;i<=10000;i++)fact[i]=(1LL*fact[i-1]*i)%MOD;inv[10000]=lgpow(fact[10000],MOD-2);
for(int i=9999;i;i--)inv[i]=(1LL*inv[i+1]*(i+1))%MOD;
cin>>N;
for(int i=1;i<=N;i++)
{
cin>>V[i].first>>V[i].second;
frecv[V[i].first+V[i].second]++;
}
sort(V+1,V+1+N,cmp);
c=0;
eval();
return 0;
}
| [
"alexandrurapeanu@yahoo.com"
] | alexandrurapeanu@yahoo.com |
ba76c7782e8c8e18601cc58432d1baddc1e6c49b | f8b56b711317fcaeb0fb606fb716f6e1fe5e75df | /Internal/SDK/SDLetter_ExclusionEntitlement_Campaign022_classes.h | 249c2c1cc4722b2398ce707b70772fef7736ec72 | [] | no_license | zanzo420/SoT-SDK-CG | a5bba7c49a98fee71f35ce69a92b6966742106b4 | 2284b0680dcb86207d197e0fab6a76e9db573a48 | refs/heads/main | 2023-06-18T09:20:47.505777 | 2021-07-13T12:35:51 | 2021-07-13T12:35:51 | 385,600,112 | 0 | 0 | null | 2021-07-13T12:42:45 | 2021-07-13T12:42:44 | null | UTF-8 | C++ | false | false | 860 | h | #pragma once
// Name: Sea of Thieves, Version: 2.2.0.2
/*!!DEFINE!!*/
/*!!HELPER_DEF!!*/
/*!!HELPER_INC!!*/
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
namespace CG
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass SDLetter_ExclusionEntitlement_Campaign022.SDLetter_ExclusionEntitlement_Campaign022_C
// 0x0000 (FullSize[0x00D8] - InheritedSize[0x00D8])
class USDLetter_ExclusionEntitlement_Campaign022_C : public UEntitlementDesc
{
public:
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass SDLetter_ExclusionEntitlement_Campaign022.SDLetter_ExclusionEntitlement_Campaign022_C");
return ptr;
}
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
b391a12071b1a8c1447c2d4483ef29f39efad831 | ad4a16f08dfdcdd6d6f4cb476a35a8f70bfc069c | /source/bsys/windowmenu/windowmenu_window_plate.cpp | 4c65c7fc63841689f1b143a50b8f329797ea4401 | [
"OpenSSL",
"MIT"
] | permissive | bluebackblue/brownie | fad5c4a013291e0232ab0c566bee22970d18bd58 | 917fcc71e5b0a807c0a8dab22a9ca7f3b0d60917 | refs/heads/master | 2021-01-20T04:47:08.775947 | 2018-11-20T19:38:42 | 2018-11-20T19:38:42 | 89,730,769 | 0 | 0 | MIT | 2017-12-31T13:44:33 | 2017-04-28T17:48:23 | C++ | UTF-8 | C++ | false | false | 2,503 | cpp |
/**
* Copyright (c) blueback
* Released under the MIT License
* https://github.com/bluebackblue/brownie/blob/master/LICENSE.txt
* http://bbbproject.sakura.ne.jp/wordpress/mitlicense
* @brief デバッグメニュー。
*/
/** include
*/
#include <bsys_pch.h>
/** include
*/
#pragma warning(push)
#pragma warning(disable:4464)
#include "../types/types.h"
#pragma warning(pop)
/** include
*/
#pragma warning(push)
#pragma warning(disable:4464)
#include "../color/color.h"
#pragma warning(pop)
/** include
*/
#include "./windowmenu.h"
#include "./windowmenu_window_plate.h"
/** warning
4710 : この関数はインライン展開のために選択されましたが、コンパイラはインライン展開を実行しませんでした。
*/
#pragma warning(disable:4710)
/** NBsys::NWindowMenu
*/
#if(BSYS_WINDOWMENU_ENABLE)
#pragma warning(push)
#pragma warning(disable:4711)
namespace NBsys{namespace NWindowMenu
{
/** constructor
*/
WindowMenu_Window_Plate::WindowMenu_Window_Plate(const STLString& a_name)
:
WindowMenu_Window_Base(a_name,WindowMenu_WindowType::Plate),
color(1.0f,1.0f,1.0f,1.0f),
texture_id(-1),
mouseblock(true)
{
}
/** destructor
*/
WindowMenu_Window_Plate::~WindowMenu_Window_Plate()
{
}
/** Initialize
*/
void WindowMenu_Window_Plate::Initialize(const WindowMenu_Window_Base::InitItem& a_inititem)
{
WindowMenu_Window_Base::Initialize(a_inititem);
{
/** color
*/
this->color = NBsys::NColor::Color_F(1.0f,1.0f,1.0f,1.0f);
/** texture_id
*/
this->texture_id = -1;
/** mouseblock
*/
this->mouseblock = true;
}
}
/** 描画処理。
*/
bool WindowMenu_Window_Plate::CallBack_Draw(s32 a_z_sort)
{
if((this->calc_rect.ww >= 0.0f)&&(this->calc_rect.hh >= 0.0f)){
GetSystemInstance()->GetCallback()->DrawRect_Callback(
a_z_sort + this->z_sort,
this->calc_rect,
this->texture_id,
this->color
);
}
//子の描画を行う。
return true;
}
/** マウス処理。
a_mousefix : true = マウスは処理済み。
*/
void WindowMenu_Window_Plate::CallBack_MouseUpdate(WindowMenu_Mouse& a_mouse,bool& a_mousefix)
{
if(a_mousefix == false){
if(this->mouseblock){
if(this->IsRange(a_mouse.pos)){
//マウス処理。
a_mousefix = true;
return;
}
}
}
}
}}
#pragma warning(pop)
#endif
| [
"blueback28@gmail.com"
] | blueback28@gmail.com |
aa00db813a76eea67c703407996ef7153f7a1072 | f67b47259c734b4355057246ac7111ab59086dd6 | /src/plugins/serial2tcp/Serial2TcpBase.h | 2219078c505c82b419714badce8386ebeed7a9eb | [] | no_license | externall-projects/esp8266-kfc-fw | 2b28b848f9ab54a7107e6b27319606b5ad17f727 | 5889f7dce2ced0347ff96db3cbf27d1ea50dc466 | refs/heads/master | 2022-04-22T07:59:02.233681 | 2020-04-12T03:46:03 | 2020-04-12T03:46:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,394 | h | /**
* Author: sascha_lammers@gmx.de
*/
#pragma once
#include <Arduino_compat.h>
#include <PrintHtmlEntitiesString.h>
#include <vector>
#include "kfc_fw_config.h"
#include "Serial2TcpConnection.h"
class Serial2TcpBase {
protected:
Serial2TcpBase(Stream &serial, uint8_t serialPort);
public:
virtual ~Serial2TcpBase();
void setAuthentication(bool hasAuthentication) {
// _hasAuthentication = hasAuthentication;
// TODO authentication not supported yet
_hasAuthentication = false;
}
bool hasAuthentication() const {
return _hasAuthentication;
}
void setIdleTimeout(uint16_t idleTimeout) {
_idleTimeout = idleTimeout;
}
uint16_t getIdleTimeout() const {
return _idleTimeout;
}
void setKeepAlive(uint8_t keepAlive) {
_keepAlive = keepAlive;
}
bool getAutoConnect() const {
return _autoConnect;
}
uint8_t getAutoReconnect() const {
return _autoReconnect;
}
uint8_t getKeepAlive() const {
return _keepAlive;
}
void setAuthenticationParameters(const char *username, const char *password) {
_username = username;
_password = password;
}
uint16_t getPort() const {
return _port;
}
String getHost() const {
return _host;
}
String getUsername() const {
return _username;
}
String getPassword() const {
return _password;
}
void setConnectionParameters(const char *host, uint16_t port, bool autoConnect, uint8_t autoReconnect);
static void onSerialData(uint8_t type, const uint8_t *buffer, size_t len);
static void handleSerialDataLoop();
static void handleConnect(void *arg, AsyncClient *client);
static void handleError(void *arg, AsyncClient *client, int8_t error);
static void handleData(void *arg, AsyncClient *client, void *data, size_t len);
static void handleDisconnect(void *arg, AsyncClient *client);
static void handleTimeOut(void *arg, AsyncClient *client, uint32_t time);
static void handleAck(void *arg, AsyncClient *client, size_t len, uint32_t time);
static void handlePoll(void *arg, AsyncClient *client);
static bool isServer(const ConfigFlags &flags) {
return (flags.serial2TCPMode == SERIAL2TCP_MODE_SECURE_SERVER || flags.serial2TCPMode == SERIAL2TCP_MODE_UNSECURE_SERVER);
}
static bool isTLS(const ConfigFlags &flags) {
return (flags.serial2TCPMode == SERIAL2TCP_MODE_SECURE_SERVER || flags.serial2TCPMode == SERIAL2TCP_MODE_SECURE_CLIENT);
}
protected:
void _setBaudRate(uint32_t rate);
Stream &_getSerial() const {
return _serial;
}
uint8_t _getSerialPort() const {
return _serialPort;
}
virtual void _onSerialData(uint8_t type, const uint8_t *buffer, size_t len);
virtual void _onConnect(AsyncClient *client);
virtual void _onData(AsyncClient *client, void *data, size_t len);
// void onError(AsyncClient *client, int8_t error);
virtual void _onDisconnect(AsyncClient *client, const __FlashStringHelper *reason);
// void onTimeOut(AsyncClient *client, uint32_t time);
// virtual void _onAck(AsyncClient *client, size_t len, uint32_t time);
// virtual void onPoll(AsyncClient *client);
void _serialHandlerLoop();
void _processData(Serial2TcpConnection *conn, const char *data, size_t len);
virtual size_t _serialWrite(Serial2TcpConnection *conn, const char *data, size_t len);
size_t _serialWrite(Serial2TcpConnection *conn, char data);
size_t _serialPrintf_P(Serial2TcpConnection *conn, PGM_P format, ...);
public:
virtual void getStatus(PrintHtmlEntitiesString &output) = 0;
virtual void begin() = 0;
virtual void end() = 0;
private:
Stream &_serial;
uint8_t _serialPort;
uint8_t _hasAuthentication: 1;
uint8_t _autoConnect: 1;
uint8_t _autoReconnect;
uint16_t _idleTimeout;
uint8_t _keepAlive;
String _host;
uint16_t _port;
String _username;
String _password;
public:
static Serial2TcpBase *createInstance();
static void destroyInstance();
static Serial2TcpBase *getInstance() {
return _instance;
}
private:
static Serial2TcpBase *_instance;
public:
#if IOT_DIMMER_MODULE
static bool _resetAtmega;
#endif
#if DEBUG
static bool _debugOutput;
#endif
};
| [
"sascha_lammers@gmx.de"
] | sascha_lammers@gmx.de |
f4f74a04360b030ea094d8904b896f2b2129bd85 | da5d30a4fdcc91aa2bb63099ccb86321281a41e4 | /Engine/Engine/lightclass.cpp | 3e8d7532e58c1ce1ebd5c2e5c9ba6d49aecf0f71 | [] | no_license | DKallan/DX11-Engine | df211f304e83cbc107c2508151c7fb1ac97ba33a | bf1bd24c17edac8268ee7bb4eaeed3fbc1a8dc94 | refs/heads/master | 2021-09-08T10:38:24.236774 | 2017-10-23T10:20:57 | 2017-10-23T10:20:57 | 106,738,155 | 0 | 0 | null | 2017-10-21T12:29:57 | 2017-10-12T19:47:16 | C++ | UTF-8 | C++ | false | false | 1,304 | cpp | ////////////////////////////////////////////////////////////////////////////////
// Filename: lightclass.cpp
////////////////////////////////////////////////////////////////////////////////
#include "lightclass.h"
LightClass::LightClass()
{
}
LightClass::LightClass(const LightClass& other)
{
}
LightClass::~LightClass()
{
}
void LightClass::SetAmbientColor(float red, float green, float blue, float alpha)
{
m_ambientColor = XMFLOAT4(red, green, blue, alpha);
return;
}
void LightClass::SetDiffuseColor(float red, float green, float blue, float alpha)
{
m_diffuseColor = XMFLOAT4(red, green, blue, alpha);
return;
}
void LightClass::SetDirection(float x, float y, float z)
{
m_direction = XMFLOAT3(x, y, z);
return;
}
void LightClass::SetSpecularColor(float red, float green, float blue, float alpha)
{
m_specularColor = XMFLOAT4(red, green, blue, alpha);
return;
}
void LightClass::SetSpecularPower(float power)
{
m_specularPower = power;
return;
}
XMFLOAT4 LightClass::GetAmbientColor()
{
return m_ambientColor;
}
XMFLOAT4 LightClass::GetDiffuseColor()
{
return m_diffuseColor;
}
XMFLOAT3 LightClass::GetDirection()
{
return m_direction;
}
XMFLOAT4 LightClass::GetSpecularColor()
{
return m_specularColor;
}
float LightClass::GetSpecularPower()
{
return m_specularPower;
} | [
"danilokallan@hotmail.com"
] | danilokallan@hotmail.com |
0cb2f6dc1af2cbcce07b8d155456123391005f7e | a9922d559d43880009effef26ec3b6263e93f88e | /solutions/kattis/ecna21/growingsomeoobleck_hcz.cpp | 7bbe83b2d743ed381c126202ca69e439d9414396 | [] | no_license | buckeye-cn/ACM_ICPC_Materials | e7cc8e476de42f8b8a3559a9721b421a85a95a48 | 6d32af96030397926c8d5e354c239802d5d171db | refs/heads/master | 2023-04-26T03:02:51.341470 | 2023-04-16T10:46:17 | 2023-04-16T10:46:17 | 102,976,270 | 23 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,255 | cpp | // https://open.kattis.com/problems/growingsomeoobleck
#include <cstdlib>
#include <cstdint>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#define sqr(x) ((x) * (x))
using namespace std;
double x[100];
double y[100];
double rad[100];
double spd[100];
bool done[100];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.precision(10);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i] >> rad[i] >> spd[i];
}
int nn = n;
while (true) {
double best_t = 1e9;
int best_i = -1;
for (int i = 0; i < n; ++i) {
if (done[i]) continue;
for (int j = 0; j < i; ++j) {
if (done[j]) continue;
double t = (sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j])) - rad[i] - rad[j]) / (spd[i] + spd[j]);
if (best_t > t) {
best_t = t;
best_i = i;
}
}
}
for (int i = 0; i < n; ++i) {
rad[i] += spd[i] * best_t;
}
while (true) {
int tot = 1;
double sum_x = x[best_i];
double sum_y = y[best_i];
double sum_sqr = sqr(rad[best_i]);
double max_spd = spd[best_i];
for (int i = 0; i < n; ++i) {
if (done[i] || i == best_i) continue;
if (sqr(x[i] - x[best_i]) + sqr(y[i] - y[best_i]) < sqr(rad[i] + rad[best_i] + 1e-6)) {
tot += 1;
sum_x += x[i];
sum_y += y[i];
sum_sqr += sqr(rad[i]);
max_spd = max(max_spd, spd[i]);
done[i] = true;
nn -= 1;
}
}
if (tot > 1) {
x[best_i] = sum_x / tot;
y[best_i] = sum_y / tot;
rad[best_i] = sqrt(sum_sqr);
spd[best_i] = max_spd;
} else {
break;
}
}
if (nn == 1) {
cout << x[best_i] << ' ' << y[best_i] << endl;
cout << rad[best_i] << endl;
return 0;
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
d512e92b3b063abb2f087887b47caf209f78666a | 99b234f8ba4a9661ffdc8b3af06521556d1745ca | /lengthOfLastWord.cc | 3cc41e02b49f9a128058a379c51238acd7e4b665 | [] | no_license | SSQ2000/ssq | 307e75d959460aac69cbe2e1eb3815d54963a112 | 3420d644ea445904c329d0d45536587193d25ed5 | refs/heads/master | 2023-03-18T02:21:31.581630 | 2021-02-28T08:26:03 | 2021-02-28T08:26:03 | 334,557,450 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 499 | cc | class Solution {
public:
int lengthOfLastWord(string s) {
int arr=s.length()-1; //得到字符串的长度
while(s[arr]==' '){ //while循环判断字符串是否为空,是则输出0
arr--;
if(arr==-1)return 0;
}
int temp=arr;
while(s[arr]!=' '){ //while循环找到最后一个空格
arr--;
if(arr==-1)return temp+1;
}
return temp-arr;
}
}; | [
"3199249657@qq.com"
] | 3199249657@qq.com |
947a71ce3c1c7e525ff070f5b0f164830b5c80ce | 0cb0e8b4afdbeedbb49b16528a9ddefe10ae767c | /Bearded2/Bearded2/RBearded2.hpp | 42eee72c019cb39f7a39cd1fc61d3dad085627e7 | [] | no_license | pconn/CKMR | 58fd0c1e9bfcd201ab2891e9665699cb2cb82c71 | 66a9837f732cf2caa576d741d88e42972e612002 | refs/heads/master | 2022-06-10T10:49:51.957286 | 2022-05-19T22:15:04 | 2022-05-19T22:15:04 | 98,912,295 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 646 | hpp | // ----------------------------------------------------------------------------
// RBearded2.hpp
// ----------------------------------------------------------------------------
#ifndef __RBearded2_HPP__
#define __RBearded2_HPP__
#include "DBearded2.hpp"
// ----------------------------------------------------------------------------
class RBearded2 : public DBearded2
{
protected:
/* AD_LIBNAME Bearded2 */
/* AD_ALIAS RBd=RIBearded2, DBearded2 */
/* AUTOINIT */
/* AUTODEC */
#include "RBd_array_plans.hpp"
public:
RBearded2(
#include "RBd_constructor_args.hpp"
);
virtual ~RBearded2();
};
#endif //__RBearded2_HPP__
| [
"paul.conn"
] | paul.conn |
9a35ff0ed21049628045a2daec7fc6ae3c19e037 | c8a2cc98d283552f10e0730ee937d96241434e6f | /include/oglplus/gl_api/enum_types.hpp | 65f3a93cb8c1301b7681aeeaafafc131fb1d6d5f | [
"BSL-1.0"
] | permissive | lineCode/oglplu2 | f144e76e9f952a9b971604517f9f882fe5dbb9a9 | fcaf775d85038e40be4f552dbe2bef8952dcc6d6 | refs/heads/master | 2022-11-21T17:09:02.789613 | 2020-07-18T21:17:50 | 2020-07-18T21:17:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,963 | hpp | /**
* @file oglplus/gl_api/enum_types.hpp
*
* Copyright Matus Chochlik.
* 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 OGLPLUS_GL_API_ENUM_TYPES_HPP
#define OGLPLUS_GL_API_ENUM_TYPES_HPP
#include "enum_class.hpp"
namespace eagine::oglp {
//------------------------------------------------------------------------------
struct true_false : gl_bool_class<true_false, EAGINE_ID_V(TrueFalse)> {
using enum_class::enum_class;
constexpr explicit operator bool() const noexcept {
#ifdef GL_TRUE
return this->_value == GL_TRUE;
#else
return false;
#endif
}
constexpr bool operator!() const noexcept {
#ifdef GL_FALSE
return this->_value == GL_FALSE;
#else
return false;
#endif
}
};
struct error_code : gl_enum_class<error_code, EAGINE_ID_V(ErrorCode)> {
using enum_class::enum_class;
};
struct context_flag_bit
: gl_bitfield_class<context_flag_bit, EAGINE_ID_V(CtxFlagBit)> {
using enum_class::enum_class;
};
struct context_profile_bit
: gl_bitfield_class<context_profile_bit, EAGINE_ID_V(CtxProfBit)> {
using enum_class::enum_class;
};
struct context_release_behavior
: gl_enum_class<context_release_behavior, EAGINE_ID_V(CtxRlsBhvr)> {
using enum_class::enum_class;
};
struct reset_notification_strategy
: gl_enum_class<reset_notification_strategy, EAGINE_ID_V(RstNtfStgy)> {
using enum_class::enum_class;
};
struct capability : gl_enum_class<capability, EAGINE_ID_V(Capability)> {
using enum_class::enum_class;
};
struct client_capability
: gl_enum_class<client_capability, EAGINE_ID_V(ClientCap)> {
using enum_class::enum_class;
};
struct graphics_reset_status
: gl_enum_class<graphics_reset_status, EAGINE_ID_V(GrphRstStt)> {
using enum_class::enum_class;
};
struct memory_barrier_bit
: gl_bitfield_class<memory_barrier_bit, EAGINE_ID_V(MemBrirBit)> {
using enum_class::enum_class;
};
struct access_specifier
: gl_enum_class<access_specifier, EAGINE_ID_V(AccessSpec)> {
using enum_class::enum_class;
};
struct precision_type : gl_enum_class<precision_type, EAGINE_ID_V(PrecisType)> {
using enum_class::enum_class;
};
struct object_type : gl_enum_class<object_type, EAGINE_ID_V(ObjectType)> {
using enum_class::enum_class;
};
struct sync_type : gl_enum_class<sync_type, EAGINE_ID_V(SyncType)> {
using enum_class::enum_class;
};
struct sync_status : gl_enum_class<sync_status, EAGINE_ID_V(SyncStatus)> {
using enum_class::enum_class;
};
struct sync_condition : gl_enum_class<sync_condition, EAGINE_ID_V(SyncCondtn)> {
using enum_class::enum_class;
};
struct sync_flag_bit
: gl_bitfield_class<sync_flag_bit, EAGINE_ID_V(SyncFlgBit)> {
using enum_class::enum_class;
};
struct sync_parameter : gl_enum_class<sync_parameter, EAGINE_ID_V(SynParamtr)> {
using enum_class::enum_class;
};
struct sync_wait_result
: gl_enum_class<sync_wait_result, EAGINE_ID_V(SynWaitRes)> {
using enum_class::enum_class;
};
struct shader_type : gl_enum_class<shader_type, EAGINE_ID_V(ShaderType)> {
using enum_class::enum_class;
};
struct shader_parameter
: gl_enum_class<shader_parameter, EAGINE_ID_V(ShdrPrmter)> {
using enum_class::enum_class;
};
struct program_stage_bit
: gl_bitfield_class<program_stage_bit, EAGINE_ID_V(PrgStgeBit)> {
using enum_class::enum_class;
};
struct program_stage_parameter
: gl_enum_class<program_stage_parameter, EAGINE_ID_V(PrgStgePrm)> {
using enum_class::enum_class;
};
struct program_parameter
: gl_enum_class<program_parameter, EAGINE_ID_V(ProgPrmter)> {
using enum_class::enum_class;
};
struct program_binary_format
: gl_enum_class<program_binary_format, EAGINE_ID_V(ProgBinFmt)> {
using enum_class::enum_class;
};
struct program_pipeline_parameter
: gl_enum_class<program_pipeline_parameter, EAGINE_ID_V(PiplPrmter)> {
using enum_class::enum_class;
};
struct buffer_target : gl_enum_class<buffer_target, EAGINE_ID_V(BufferTgt)> {
using enum_class::enum_class;
};
struct buffer_parameter
: gl_enum_class<buffer_parameter, EAGINE_ID_V(BufParmtr)> {
using enum_class::enum_class;
};
struct buffer_usage : gl_enum_class<buffer_usage, EAGINE_ID_V(BufferUsge)> {
using enum_class::enum_class;
};
struct buffer_map_access_bit
: gl_bitfield_class<buffer_map_access_bit, EAGINE_ID_V(BufMapAccB)> {
using enum_class::enum_class;
};
struct buffer_storage_bit
: gl_bitfield_class<buffer_storage_bit, EAGINE_ID_V(BufStrgBit)> {
using enum_class::enum_class;
};
struct program_interface
: gl_enum_class<program_interface, EAGINE_ID_V(ProgrmIntf)> {
using enum_class::enum_class;
};
struct program_property
: gl_enum_class<program_property, EAGINE_ID_V(ProgrmProp)> {
using enum_class::enum_class;
};
struct buffer_clear_bit
: gl_bitfield_class<buffer_clear_bit, EAGINE_ID_V(BufClerBit)> {
using enum_class::enum_class;
};
struct buffer_blit_bit
: gl_bitfield_class<buffer_blit_bit, EAGINE_ID_V(BufBlitBit)> {
using enum_class::enum_class;
};
struct texture_unit : gl_enum_class<texture_unit, EAGINE_ID_V(TexUnit)> {
using enum_class::enum_class;
};
struct texture_target : gl_enum_class<texture_target, EAGINE_ID_V(TexTarget)> {
using enum_class::enum_class;
};
struct texture_compare_mode
: gl_enum_class<texture_compare_mode, EAGINE_ID_V(TexCmpMode)> {
using enum_class::enum_class;
};
struct texture_min_filter
: gl_enum_class<texture_min_filter, EAGINE_ID_V(TexMinFltr)> {
using enum_class::enum_class;
};
struct texture_mag_filter
: gl_enum_class<texture_mag_filter, EAGINE_ID_V(TexMagFltr)> {
using enum_class::enum_class;
};
struct texture_filter : gl_enum_class<texture_filter, EAGINE_ID_V(TexFilter)> {
using enum_class::enum_class;
};
struct texture_level_parameter
: gl_enum_class<texture_level_parameter, EAGINE_ID_V(TexLvlParm)> {
using enum_class::enum_class;
};
struct texture_parameter
: gl_enum_class<texture_parameter, EAGINE_ID_V(TexParamtr)> {
using enum_class::enum_class;
};
struct texture_swizzle_coord
: gl_enum_class<texture_swizzle_coord, EAGINE_ID_V(TexSwzCord)> {
using enum_class::enum_class;
};
struct texture_swizzle_mode
: gl_enum_class<texture_swizzle_mode, EAGINE_ID_V(TexSwzMode)> {
using enum_class::enum_class;
};
struct texture_wrap_coord
: gl_enum_class<texture_wrap_coord, EAGINE_ID_V(TexWrpCord)> {
using enum_class::enum_class;
};
struct texture_wrap_mode
: gl_enum_class<texture_wrap_mode, EAGINE_ID_V(TexWrpMode)> {
using enum_class::enum_class;
};
struct renderbuffer_target
: gl_enum_class<renderbuffer_target, EAGINE_ID_V(RboTarget)> {
using enum_class::enum_class;
};
struct renderbuffer_parameter
: gl_enum_class<renderbuffer_parameter, EAGINE_ID_V(RboParamtr)> {
using enum_class::enum_class;
};
struct framebuffer_target
: gl_enum_class<framebuffer_target, EAGINE_ID_V(FboTarget)> {
using enum_class::enum_class;
};
struct framebuffer_status
: gl_enum_class<framebuffer_status, EAGINE_ID_V(FboStatus)> {
using enum_class::enum_class;
};
struct framebuffer_parameter
: gl_enum_class<framebuffer_parameter, EAGINE_ID_V(FboParamtr)> {
using enum_class::enum_class;
};
struct framebuffer_attachment_parameter
: gl_enum_class<framebuffer_attachment_parameter, EAGINE_ID_V(FboAtchPar)> {
using enum_class::enum_class;
};
struct framebuffer_buffer
: gl_enum_class<framebuffer_buffer, EAGINE_ID_V(FboBuffer)> {
using enum_class::enum_class;
};
struct framebuffer_attachment
: gl_enum_class<framebuffer_attachment, EAGINE_ID_V(FboAttchmt)> {
using enum_class::enum_class;
};
struct sampler_parameter
: gl_enum_class<sampler_parameter, EAGINE_ID_V(SamParamtr)> {
using enum_class::enum_class;
};
struct query_target : gl_enum_class<query_target, EAGINE_ID_V(QryTarget)> {
using enum_class::enum_class;
};
struct counter_query_target
: gl_enum_class<counter_query_target, EAGINE_ID_V(CntrQryTgt)> {
using enum_class::enum_class;
};
struct query_parameter
: gl_enum_class<query_parameter, EAGINE_ID_V(QryParamtr)> {
using enum_class::enum_class;
};
struct transform_feedback_target
: gl_enum_class<transform_feedback_target, EAGINE_ID_V(XfbTarget)> {
using enum_class::enum_class;
};
struct transform_feedback_primitive_type
: gl_enum_class<transform_feedback_primitive_type, EAGINE_ID_V(XfbPrimTyp)> {
using enum_class::enum_class;
};
struct transform_feedback_mode
: gl_enum_class<transform_feedback_mode, EAGINE_ID_V(XfbMode)> {
using enum_class::enum_class;
};
struct transform_feedback_parameter
: gl_enum_class<transform_feedback_parameter, EAGINE_ID_V(XfbParamtr)> {
using enum_class::enum_class;
};
struct vertex_attrib_parameter
: gl_enum_class<vertex_attrib_parameter, EAGINE_ID_V(VAtrParmtr)> {
using enum_class::enum_class;
};
struct primitive_type : gl_enum_class<primitive_type, EAGINE_ID_V(PrmtveType)> {
using enum_class::enum_class;
};
struct old_primitive_type
: gl_enum_class<old_primitive_type, EAGINE_ID_V(OldPrmType)> {
using enum_class::enum_class;
};
struct tess_gen_primitive_type
: gl_enum_class<tess_gen_primitive_type, EAGINE_ID_V(TsGnPrmTyp)> {
using enum_class::enum_class;
};
struct tess_gen_primitive_spacing
: gl_enum_class<tess_gen_primitive_spacing, EAGINE_ID_V(TsGnPrmSpc)> {
using enum_class::enum_class;
};
struct patch_parameter
: gl_enum_class<patch_parameter, EAGINE_ID_V(PtchParmtr)> {
using enum_class::enum_class;
};
struct provoke_mode : gl_enum_class<provoke_mode, EAGINE_ID_V(ProvkeMode)> {
using enum_class::enum_class;
};
struct conditional_render_mode
: gl_enum_class<conditional_render_mode, EAGINE_ID_V(CndRndrMod)> {
using enum_class::enum_class;
};
struct face_mode : gl_enum_class<face_mode, EAGINE_ID_V(FaceMode)> {
using enum_class::enum_class;
};
struct face_orientation
: gl_enum_class<face_orientation, EAGINE_ID_V(FaceOrient)> {
using enum_class::enum_class;
};
struct surface_buffer : gl_enum_class<surface_buffer, EAGINE_ID_V(SrfceBuffr)> {
using enum_class::enum_class;
};
struct compare_function
: gl_enum_class<compare_function, EAGINE_ID_V(ComparFunc)> {
using enum_class::enum_class;
};
struct blit_filter : gl_enum_class<blit_filter, EAGINE_ID_V(BlitFilter)> {
using enum_class::enum_class;
};
struct binding_query : gl_enum_class<binding_query, EAGINE_ID_V(BindQuery)> {
using enum_class::enum_class;
};
struct integer_query : gl_enum_class<integer_query, EAGINE_ID_V(IntQuery)> {
using enum_class::enum_class;
};
struct float_query : gl_enum_class<float_query, EAGINE_ID_V(FloatQuery)> {
using enum_class::enum_class;
};
struct string_query : gl_enum_class<string_query, EAGINE_ID_V(StrQuery)> {
using enum_class::enum_class;
};
struct data_type : gl_enum_class<data_type, EAGINE_ID_V(DataType)> {
using enum_class::enum_class;
};
struct index_data_type
: gl_enum_class<index_data_type, EAGINE_ID_V(IdxDtaType)> {
using enum_class::enum_class;
};
struct sl_data_type : gl_enum_class<sl_data_type, EAGINE_ID_V(SLDataType)> {
using enum_class::enum_class;
};
struct point_parameter
: gl_enum_class<point_parameter, EAGINE_ID_V(PtParametr)> {
using enum_class::enum_class;
};
struct point_sprite_coord_origin
: gl_enum_class<point_sprite_coord_origin, EAGINE_ID_V(PtSprCrdOr)> {
using enum_class::enum_class;
};
struct polygon_mode : gl_enum_class<polygon_mode, EAGINE_ID_V(PolygnMode)> {
using enum_class::enum_class;
};
struct stencil_operation
: gl_enum_class<stencil_operation, EAGINE_ID_V(StencilOp)> {
using enum_class::enum_class;
};
struct logic_operation : gl_enum_class<logic_operation, EAGINE_ID_V(LogicOp)> {
using enum_class::enum_class;
};
struct blend_equation : gl_enum_class<blend_equation, EAGINE_ID_V(BlendEqtn)> {
using enum_class::enum_class;
};
struct blend_equation_advanced
: gl_enum_class<blend_equation_advanced, EAGINE_ID_V(BlndEqAdvn)> {
using enum_class::enum_class;
};
struct blend_function : gl_enum_class<blend_function, EAGINE_ID_V(BlendFunc)> {
using enum_class::enum_class;
};
struct pixel_data_type
: gl_enum_class<pixel_data_type, EAGINE_ID_V(PixDataTyp)> {
using enum_class::enum_class;
};
struct pixel_format : gl_enum_class<pixel_format, EAGINE_ID_V(PixelFrmat)> {
using enum_class::enum_class;
};
struct image_unit_format
: gl_enum_class<image_unit_format, EAGINE_ID_V(ImgUnitFmt)> {
using enum_class::enum_class;
};
struct pixel_internal_format
: gl_enum_class<pixel_internal_format, EAGINE_ID_V(PixIntlFmt)> {
using enum_class::enum_class;
};
struct pixel_store_parameter
: gl_enum_class<pixel_store_parameter, EAGINE_ID_V(PixStorPrm)> {
using enum_class::enum_class;
};
struct internal_format_parameter
: gl_enum_class<internal_format_parameter, EAGINE_ID_V(IntlFmtPrm)> {
using enum_class::enum_class;
};
struct image_compatibility_class
: gl_enum_class<image_compatibility_class, EAGINE_ID_V(ImCompClss)> {
using enum_class::enum_class;
};
struct view_compatibility_class
: gl_enum_class<view_compatibility_class, EAGINE_ID_V(VwCompClss)> {
using enum_class::enum_class;
};
struct hint_option : gl_enum_class<hint_option, EAGINE_ID_V(HintOption)> {
using enum_class::enum_class;
};
struct sample_parameter
: gl_enum_class<sample_parameter, EAGINE_ID_V(SampleParm)> {
using enum_class::enum_class;
};
struct hint_target : gl_enum_class<hint_target, EAGINE_ID_V(HintTarget)> {
using enum_class::enum_class;
};
struct debug_output_severity
: gl_enum_class<debug_output_severity, EAGINE_ID_V(DbgOutSvrt)> {
using enum_class::enum_class;
};
struct debug_output_source
: gl_enum_class<debug_output_source, EAGINE_ID_V(DbgOutSrce)> {
using enum_class::enum_class;
};
struct debug_output_type
: gl_enum_class<debug_output_type, EAGINE_ID_V(DbgOutType)> {
using enum_class::enum_class;
};
struct support_level : gl_enum_class<support_level, EAGINE_ID_V(SupportLvl)> {
using enum_class::enum_class;
};
struct matrix_mode : gl_enum_class<matrix_mode, EAGINE_ID_V(MatrixMode)> {
using enum_class::enum_class;
};
struct path_command_nv
: gl_ubyte_class<path_command_nv, EAGINE_ID_V(PathComand)> {
using enum_class::enum_class;
};
struct path_cap_style_nv
: gl_enum_class<path_cap_style_nv, EAGINE_ID_V(PathCapSty)> {
using enum_class::enum_class;
};
struct path_color_format_nv
: gl_enum_class<path_color_format_nv, EAGINE_ID_V(PathClrFmt)> {
using enum_class::enum_class;
};
struct path_color_nv : gl_enum_class<path_color_nv, EAGINE_ID_V(PathColor)> {
using enum_class::enum_class;
};
struct path_dash_offset_reset_nv
: gl_enum_class<path_dash_offset_reset_nv, EAGINE_ID_V(PathDsORst)> {
using enum_class::enum_class;
};
struct path_stroke_cover_mode_nv
: gl_enum_class<path_stroke_cover_mode_nv, EAGINE_ID_V(PathStCvrM)> {
using enum_class::enum_class;
};
struct path_fill_cover_mode_nv
: gl_enum_class<path_fill_cover_mode_nv, EAGINE_ID_V(PathFlCvrM)> {
using enum_class::enum_class;
};
struct path_fill_mode_nv
: gl_enum_class<path_fill_mode_nv, EAGINE_ID_V(PathFillMd)> {
using enum_class::enum_class;
};
struct path_font_style_nv
: gl_bitfield_class<path_font_style_nv, EAGINE_ID_V(PathFntSty)> {
using enum_class::enum_class;
};
struct path_join_style_nv
: gl_bitfield_class<path_join_style_nv, EAGINE_ID_V(PathJinSty)> {
using enum_class::enum_class;
};
struct path_font_target_nv
: gl_enum_class<path_font_target_nv, EAGINE_ID_V(PathFntTgt)> {
using enum_class::enum_class;
};
struct path_format_nv : gl_enum_class<path_format_nv, EAGINE_ID_V(PathFormat)> {
using enum_class::enum_class;
};
struct path_gen_mode_nv
: gl_enum_class<path_gen_mode_nv, EAGINE_ID_V(PathGenMod)> {
using enum_class::enum_class;
};
struct path_list_mode_nv
: gl_enum_class<path_list_mode_nv, EAGINE_ID_V(PathLstMod)> {
using enum_class::enum_class;
};
struct path_metric_query_nv
: gl_bitfield_class<path_metric_query_nv, EAGINE_ID_V(PathMrcQry)> {
using enum_class::enum_class;
};
struct path_missing_glyph_nv
: gl_bitfield_class<path_missing_glyph_nv, EAGINE_ID_V(PathMsnGph)> {
using enum_class::enum_class;
};
struct path_parameter_nv
: gl_bitfield_class<path_parameter_nv, EAGINE_ID_V(PathPrmter)> {
using enum_class::enum_class;
};
struct path_text_encoding_nv
: gl_bitfield_class<path_text_encoding_nv, EAGINE_ID_V(PathTxtEnc)> {
using enum_class::enum_class;
};
struct path_transform_type_nv
: gl_bitfield_class<path_transform_type_nv, EAGINE_ID_V(PathTrnsfT)> {
using enum_class::enum_class;
};
//------------------------------------------------------------------------------
} // namespace eagine::oglp
#endif // OGLPLUS_GL_API_ENUM_TYPES_HPP
| [
"chochlik@gmail.com"
] | chochlik@gmail.com |
31a774bcdcb0869d77ddc9e8c25e8e0863323cc6 | a134e7437e254405d327f9060ede1ed45cd9012a | /cs120/Homework/hw_2e.cpp | 55f51b9a272d51f457439cfddac89bb295795844 | [] | no_license | captainswain/cpp-classes | 77e58049ec39444db650446eb3276cb37f3dd653 | 5e6a8dd176032cb2a8eaa3bbc2f3cde4c159d767 | refs/heads/master | 2020-05-23T07:49:55.797253 | 2017-01-30T18:51:41 | 2017-01-30T18:51:41 | 80,451,169 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,609 | cpp | /*
==================================================================
____ ____ ____ _ ___ __
/\ _`\ /'\_/`\/\ _`\ /\ _`\ /' \ /'___`\ /'__`\
\ \ \/\_\ /\ \ \ \L\ \ \ \L\ \ /\_, \ /\_\ /\ \ /\ \/\ \
\ \ \/_/_\ \ \__\ \ \ ,__/\ \ , / \/_/\ \\/_/// /__\ \ \ \ \
\ \ \L\ \\ \ \_/\ \ \ \/ \ \ \\ \ \ \ \ // /_\ \\ \ \_\ \
\ \____/ \ \_\\ \_\ \_\ \ \_\ \_\ \ \_\/\______/ \ \____/
\/___/ \/_/ \/_/\/_/ \/_/\/ / \/_/\/_____/ \/___/
==================================================================
Information
------------------------------------------------------------------
Program: hw_2E
------------------------------------------------------------------
Written by: Shane Lindsay
------------------------------------------------------------------
Class: CMPR 120
==================================================================
*/
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
string firstinitial;
string lastinitial;
cout << "What is your first initial?";
cin >> firstinitial;
cout << "What is your last initial?";
cin >> lastinitial;
cout << "Your first initial is " << firstinitial << " and your last intial is " << lastinitial;
return 0;
}
/*
==================================================================
Output
------------------------------------------------------------------
Shanes-MacBook-Air:cppclass swain$ ./hw_2d
My school is Santiago Canyon College
It is in the city of Orange
==================================================================
*/
| [
"shaneboom@gmail.com"
] | shaneboom@gmail.com |
4d6f001345b79e8b3798ef5b9593546678a6fbff | 8cf763c4c29db100d15f2560953c6e6cbe7a5fd4 | /src/qt/qtbase/src/corelib/io/qtldurl.cpp | d0205c3be5e19190a1e9a8230960f00b30001b3a | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"LGPL-2.1-only",
"GFDL-1.3-only",
"Qt-LGPL-exception-1.1",
"LicenseRef-scancode-digia-qt-commercial",
"LGPL-3.0-only",
"GPL-3.0-only",
"LicenseRef-scancode-digia-qt-preview",
"LGPL-2.1-or-later",
"GPL-1.0-or-later",
"LicenseRef-scancode-unknown-license-refe... | permissive | chihlee/phantomjs | 69d6bbbf1c9199a78e82ae44af072aca19c139c3 | 644e0b3a6c9c16bcc6f7ce2c24274bf7d764f53c | refs/heads/master | 2021-01-19T13:49:41.265514 | 2018-06-15T22:48:11 | 2018-06-15T22:48:11 | 82,420,380 | 0 | 0 | BSD-3-Clause | 2018-06-15T22:48:12 | 2017-02-18T22:34:48 | C++ | UTF-8 | C++ | false | false | 4,260 | cpp | /****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qplatformdefs.h"
#include "qurl.h"
#include "private/qurltlds_p.h"
#include "private/qtldurl_p.h"
#include "QtCore/qstring.h"
#include "QtCore/qvector.h"
#include "QtCore/qhash.h"
QT_BEGIN_NAMESPACE
static bool containsTLDEntry(const QString &entry)
{
int index = qt_hash(entry) % tldCount;
// select the right chunk from the big table
short chunk = 0;
uint chunkIndex = tldIndices[index], offset = 0;
while (tldIndices[index] >= tldChunks[chunk] && chunk < tldChunkCount) {
chunkIndex -= tldChunks[chunk];
offset += tldChunks[chunk];
chunk++;
}
// check all the entries from the given index
while (chunkIndex < tldIndices[index+1] - offset) {
QString currentEntry = QString::fromUtf8(tldData[chunk] + chunkIndex);
if (currentEntry == entry)
return true;
chunkIndex += qstrlen(tldData[chunk] + chunkIndex) + 1; // +1 for the ending \0
}
return false;
}
/*!
\internal
Return the top-level-domain per Qt's copy of the Mozilla public suffix list of
\a domain.
*/
Q_CORE_EXPORT QString qTopLevelDomain(const QString &domain)
{
const QString domainLower = domain.toLower();
QVector<QStringRef> sections = domainLower.splitRef(QLatin1Char('.'), QString::SkipEmptyParts);
if (sections.isEmpty())
return QString();
QString level, tld;
for (int j = sections.count() - 1; j >= 0; --j) {
level.prepend(QLatin1Char('.') + sections.at(j));
if (qIsEffectiveTLD(level.right(level.size() - 1)))
tld = level;
}
return tld;
}
/*!
\internal
Return true if \a domain is a top-level-domain per Qt's copy of the Mozilla public suffix list.
*/
Q_CORE_EXPORT bool qIsEffectiveTLD(const QString &domain)
{
// for domain 'foo.bar.com':
// 1. return if TLD table contains 'foo.bar.com'
if (containsTLDEntry(domain))
return true;
if (domain.contains(QLatin1Char('.'))) {
int count = domain.size() - domain.indexOf(QLatin1Char('.'));
QString wildCardDomain;
wildCardDomain.reserve(count + 1);
wildCardDomain.append(QLatin1Char('*'));
wildCardDomain.append(domain.right(count));
// 2. if table contains '*.bar.com',
// test if table contains '!foo.bar.com'
if (containsTLDEntry(wildCardDomain)) {
QString exceptionDomain;
exceptionDomain.reserve(domain.size() + 1);
exceptionDomain.append(QLatin1Char('!'));
exceptionDomain.append(domain);
return (! containsTLDEntry(exceptionDomain));
}
}
return false;
}
QT_END_NAMESPACE
| [
"ariya.hidayat@gmail.com"
] | ariya.hidayat@gmail.com |
5b2e78c0dbad32ab09c424a8abfa88429db6f614 | ae2b5043e288f6129a895373515f5db81d3a36a7 | /xulrunner-sdk/include/nsIAccessibleEvent.h | b794e55b3414f269b040a03c41dbbd08e0f231d7 | [] | no_license | gh4ck3r/FirefoxOSInsight | c1307c82c2a4075648499ff429363f600c47276c | a7f3d9b6e557e229ddd70116ed2d27c4a553b314 | refs/heads/master | 2021-01-01T06:33:16.046113 | 2013-11-20T11:28:07 | 2013-11-20T11:28:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,146 | h | /*
* DO NOT EDIT. THIS FILE IS GENERATED FROM /builds/slave/rel-m-rel-xr_lx_bld-0000000000/build/accessible/public/nsIAccessibleEvent.idl
*/
#ifndef __gen_nsIAccessibleEvent_h__
#define __gen_nsIAccessibleEvent_h__
#ifndef __gen_nsISupports_h__
#include "nsISupports.h"
#endif
/* For IDL files that don't want to include root IDL files. */
#ifndef NS_NO_VTABLE
#define NS_NO_VTABLE
#endif
class nsIAccessible; /* forward declaration */
class nsIAccessibleDocument; /* forward declaration */
class nsIDOMNode; /* forward declaration */
#define NS_ACCESSIBLE_EVENT_TOPIC "accessible-event"
/* starting interface: nsIAccessibleEvent */
#define NS_IACCESSIBLEEVENT_IID_STR "7f66a33a-9ed7-4fd4-87a8-e431b0f43368"
#define NS_IACCESSIBLEEVENT_IID \
{0x7f66a33a, 0x9ed7, 0x4fd4, \
{ 0x87, 0xa8, 0xe4, 0x31, 0xb0, 0xf4, 0x33, 0x68 }}
class NS_NO_VTABLE nsIAccessibleEvent : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IACCESSIBLEEVENT_IID)
enum {
EVENT_SHOW = 1U,
EVENT_HIDE = 2U,
EVENT_REORDER = 3U,
EVENT_ACTIVE_DECENDENT_CHANGED = 4U,
EVENT_FOCUS = 5U,
EVENT_STATE_CHANGE = 6U,
EVENT_LOCATION_CHANGE = 7U,
EVENT_NAME_CHANGE = 8U,
EVENT_DESCRIPTION_CHANGE = 9U,
EVENT_VALUE_CHANGE = 10U,
EVENT_HELP_CHANGE = 11U,
EVENT_DEFACTION_CHANGE = 12U,
EVENT_ACTION_CHANGE = 13U,
EVENT_ACCELERATOR_CHANGE = 14U,
EVENT_SELECTION = 15U,
EVENT_SELECTION_ADD = 16U,
EVENT_SELECTION_REMOVE = 17U,
EVENT_SELECTION_WITHIN = 18U,
EVENT_ALERT = 19U,
EVENT_FOREGROUND = 20U,
EVENT_MENU_START = 21U,
EVENT_MENU_END = 22U,
EVENT_MENUPOPUP_START = 23U,
EVENT_MENUPOPUP_END = 24U,
EVENT_CAPTURE_START = 25U,
EVENT_CAPTURE_END = 26U,
EVENT_MOVESIZE_START = 27U,
EVENT_MOVESIZE_END = 28U,
EVENT_CONTEXTHELP_START = 29U,
EVENT_CONTEXTHELP_END = 30U,
EVENT_DRAGDROP_START = 31U,
EVENT_DRAGDROP_END = 32U,
EVENT_DIALOG_START = 33U,
EVENT_DIALOG_END = 34U,
EVENT_SCROLLING_START = 35U,
EVENT_SCROLLING_END = 36U,
EVENT_MINIMIZE_START = 37U,
EVENT_MINIMIZE_END = 38U,
EVENT_DOCUMENT_LOAD_COMPLETE = 39U,
EVENT_DOCUMENT_RELOAD = 40U,
EVENT_DOCUMENT_LOAD_STOPPED = 41U,
EVENT_DOCUMENT_ATTRIBUTES_CHANGED = 42U,
EVENT_DOCUMENT_CONTENT_CHANGED = 43U,
EVENT_PROPERTY_CHANGED = 44U,
EVENT_PAGE_CHANGED = 45U,
EVENT_TEXT_ATTRIBUTE_CHANGED = 46U,
EVENT_TEXT_CARET_MOVED = 47U,
EVENT_TEXT_CHANGED = 48U,
EVENT_TEXT_INSERTED = 49U,
EVENT_TEXT_REMOVED = 50U,
EVENT_TEXT_UPDATED = 51U,
EVENT_TEXT_SELECTION_CHANGED = 52U,
EVENT_VISIBLE_DATA_CHANGED = 53U,
EVENT_TEXT_COLUMN_CHANGED = 54U,
EVENT_SECTION_CHANGED = 55U,
EVENT_TABLE_CAPTION_CHANGED = 56U,
EVENT_TABLE_MODEL_CHANGED = 57U,
EVENT_TABLE_SUMMARY_CHANGED = 58U,
EVENT_TABLE_ROW_DESCRIPTION_CHANGED = 59U,
EVENT_TABLE_ROW_HEADER_CHANGED = 60U,
EVENT_TABLE_ROW_INSERT = 61U,
EVENT_TABLE_ROW_DELETE = 62U,
EVENT_TABLE_ROW_REORDER = 63U,
EVENT_TABLE_COLUMN_DESCRIPTION_CHANGED = 64U,
EVENT_TABLE_COLUMN_HEADER_CHANGED = 65U,
EVENT_TABLE_COLUMN_INSERT = 66U,
EVENT_TABLE_COLUMN_DELETE = 67U,
EVENT_TABLE_COLUMN_REORDER = 68U,
EVENT_WINDOW_ACTIVATE = 69U,
EVENT_WINDOW_CREATE = 70U,
EVENT_WINDOW_DEACTIVATE = 71U,
EVENT_WINDOW_DESTROY = 72U,
EVENT_WINDOW_MAXIMIZE = 73U,
EVENT_WINDOW_MINIMIZE = 74U,
EVENT_WINDOW_RESIZE = 75U,
EVENT_WINDOW_RESTORE = 76U,
EVENT_HYPERLINK_END_INDEX_CHANGED = 77U,
EVENT_HYPERLINK_NUMBER_OF_ANCHORS_CHANGED = 78U,
EVENT_HYPERLINK_SELECTED_LINK_CHANGED = 79U,
EVENT_HYPERTEXT_LINK_ACTIVATED = 80U,
EVENT_HYPERTEXT_LINK_SELECTED = 81U,
EVENT_HYPERLINK_START_INDEX_CHANGED = 82U,
EVENT_HYPERTEXT_CHANGED = 83U,
EVENT_HYPERTEXT_NLINKS_CHANGED = 84U,
EVENT_OBJECT_ATTRIBUTE_CHANGED = 85U,
EVENT_VIRTUALCURSOR_CHANGED = 86U,
EVENT_LAST_ENTRY = 87U
};
/* readonly attribute unsigned long eventType; */
NS_IMETHOD GetEventType(uint32_t *aEventType) = 0;
/* readonly attribute nsIAccessible accessible; */
NS_IMETHOD GetAccessible(nsIAccessible * *aAccessible) = 0;
/* readonly attribute nsIAccessibleDocument accessibleDocument; */
NS_IMETHOD GetAccessibleDocument(nsIAccessibleDocument * *aAccessibleDocument) = 0;
/* readonly attribute nsIDOMNode DOMNode; */
NS_IMETHOD GetDOMNode(nsIDOMNode * *aDOMNode) = 0;
/* readonly attribute boolean isFromUserInput; */
NS_IMETHOD GetIsFromUserInput(bool *aIsFromUserInput) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIAccessibleEvent, NS_IACCESSIBLEEVENT_IID)
/* Use this macro when declaring classes that implement this interface. */
#define NS_DECL_NSIACCESSIBLEEVENT \
NS_IMETHOD GetEventType(uint32_t *aEventType); \
NS_IMETHOD GetAccessible(nsIAccessible * *aAccessible); \
NS_IMETHOD GetAccessibleDocument(nsIAccessibleDocument * *aAccessibleDocument); \
NS_IMETHOD GetDOMNode(nsIDOMNode * *aDOMNode); \
NS_IMETHOD GetIsFromUserInput(bool *aIsFromUserInput);
/* Use this macro to declare functions that forward the behavior of this interface to another object. */
#define NS_FORWARD_NSIACCESSIBLEEVENT(_to) \
NS_IMETHOD GetEventType(uint32_t *aEventType) { return _to GetEventType(aEventType); } \
NS_IMETHOD GetAccessible(nsIAccessible * *aAccessible) { return _to GetAccessible(aAccessible); } \
NS_IMETHOD GetAccessibleDocument(nsIAccessibleDocument * *aAccessibleDocument) { return _to GetAccessibleDocument(aAccessibleDocument); } \
NS_IMETHOD GetDOMNode(nsIDOMNode * *aDOMNode) { return _to GetDOMNode(aDOMNode); } \
NS_IMETHOD GetIsFromUserInput(bool *aIsFromUserInput) { return _to GetIsFromUserInput(aIsFromUserInput); }
/* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
#define NS_FORWARD_SAFE_NSIACCESSIBLEEVENT(_to) \
NS_IMETHOD GetEventType(uint32_t *aEventType) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetEventType(aEventType); } \
NS_IMETHOD GetAccessible(nsIAccessible * *aAccessible) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetAccessible(aAccessible); } \
NS_IMETHOD GetAccessibleDocument(nsIAccessibleDocument * *aAccessibleDocument) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetAccessibleDocument(aAccessibleDocument); } \
NS_IMETHOD GetDOMNode(nsIDOMNode * *aDOMNode) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetDOMNode(aDOMNode); } \
NS_IMETHOD GetIsFromUserInput(bool *aIsFromUserInput) { return !_to ? NS_ERROR_NULL_POINTER : _to->GetIsFromUserInput(aIsFromUserInput); }
#if 0
/* Use the code below as a template for the implementation class for this interface. */
/* Header file */
class nsAccessibleEvent : public nsIAccessibleEvent
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIACCESSIBLEEVENT
nsAccessibleEvent();
private:
~nsAccessibleEvent();
protected:
/* additional members */
};
/* Implementation file */
NS_IMPL_ISUPPORTS1(nsAccessibleEvent, nsIAccessibleEvent)
nsAccessibleEvent::nsAccessibleEvent()
{
/* member initializers and constructor code */
}
nsAccessibleEvent::~nsAccessibleEvent()
{
/* destructor code */
}
/* readonly attribute unsigned long eventType; */
NS_IMETHODIMP nsAccessibleEvent::GetEventType(uint32_t *aEventType)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute nsIAccessible accessible; */
NS_IMETHODIMP nsAccessibleEvent::GetAccessible(nsIAccessible * *aAccessible)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute nsIAccessibleDocument accessibleDocument; */
NS_IMETHODIMP nsAccessibleEvent::GetAccessibleDocument(nsIAccessibleDocument * *aAccessibleDocument)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute nsIDOMNode DOMNode; */
NS_IMETHODIMP nsAccessibleEvent::GetDOMNode(nsIDOMNode * *aDOMNode)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute boolean isFromUserInput; */
NS_IMETHODIMP nsAccessibleEvent::GetIsFromUserInput(bool *aIsFromUserInput)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* End of implementation class template. */
#endif
#endif /* __gen_nsIAccessibleEvent_h__ */
| [
"gh4ck3r@gmail.com"
] | gh4ck3r@gmail.com |
703c439476ad77f4cf519e6c95b5ae3c39fd000c | 48b42bcea7b09844dee832db9fdb11adb8ec94d5 | /src/programs/shell.cpp | 7d37b3006927547a4761f5bf318e68b7facf8856 | [] | no_license | AAA97AAA/SoftSec | bb33353e68f90ed9b5ab516b19f3bf8fff386891 | 49ad666c22ed53f04e4417c56524debf60b7ae30 | refs/heads/master | 2020-04-25T23:07:32.641586 | 2019-05-26T09:11:37 | 2019-05-26T09:11:37 | 173,134,542 | 0 | 0 | null | 2019-05-16T15:39:49 | 2019-02-28T15:13:30 | C++ | UTF-8 | C++ | false | false | 3,766 | cpp | #include "programs.h"
#include "core/process.h"
#include "io/channel.h"
#include "core/runsys.h"
#include <iostream>
#include <string>
#include <exception>
#include <sstream>
#include <unordered_map>
using namespace std;
static unordered_map<string, Program *> programs
{
{"ping", Ping},
{"whoami", WhoAmI},
{"w", Who},
{"mkdir", MakeDir},
{"rm", Remove},
{"get", GetFile},
{"put", PutFile},
{"grep", Grep},
{"date", Date},
{"ls", Ls},
};
static void ShellExceptionHandler(Process &proc, exception_ptr ex, void *arg)
{
Channel *io = reinterpret_cast<Channel *>(arg);
try {
rethrow_exception(ex);
} catch (const std::exception& e) {
try {
io->out() << "Error: " << e.what() << endl;
cout << "Error: " << e.what() << endl;
} catch (...) {
cout << "Fatal error: " << e.what() << endl;
}
}
}
static int PrivilegedShell(const string &args, Process &proc, Channel *io);
string get_args(istream &in)
{
string args;
string line;
getline(in, line);
istringstream liness(line);
getline(liness >> ws, args);
return args;
}
static int launch_application(Process *parent, Program *p, const string &args, Channel *io)
{
pid_t pid = parent->sys_.create_application(parent, parent->env_);
Process *child = parent->sys_.get_process(pid);
return child->run(p, args, io);
}
static void exit_counter()
{
static int i = 0;
++i;
}
void (*detif)() = &exit_counter;
void (*notif)() = &exit_counter;
int LoginShell(const string &args, Process &proc, Channel *io)
{
proc.set_ex_handler(&ShellExceptionHandler, io);
istream &in = io->in();
ostream &out = io->out();
string tmp;
out << "Welcome to GraaS" << endl;
out << "> " << flush;
while (in >> tmp) {
string c_args = get_args(in);
if (tmp == "login") {
string username = c_args;
out << "> " << flush;
in >> tmp;
c_args = get_args(in);
if (tmp == "pass") {
string password = c_args;
if (proc.sys_.verify_credentials(username, password)) {
pid_t pid = proc.sys_.create_application(&proc, proc.env_);
Process *child = proc.sys_.get_process(pid);
child->env_["USER"] = username;
if (child->run(PrivilegedShell, "", io) == -1) {
break; // exit when priv. shell exits
}
} else {
out << "Error: invalid login credentials." << endl;
}
} else {
out << "Error: illegal command during login." << endl;
}
} else if (tmp == "ping") {
launch_application(&proc, Ping, c_args, io);
} else if (tmp == "exit") {
break;
} else {
// command not found
out << "Unrecognized command \"" << tmp << "\"" << endl;
}
out << "> " << flush;
}
out << "Goodbye!" << endl;
return 0;
}
static int PrivilegedShell(const string &args, Process &proc, Channel *io)
{
istream &in = io->in();
ostream &out = io->out();
string user = proc.env_["USER"];
out << "Welcome, " << user << "!" << endl;
out << user << "@grass:" << proc.env_.get_wd().stripped() << "$ " << flush;
string cmd;
while (in >> cmd) {
string cmd_args = get_args(in);
if (cmd == "exit") {
notif();
return -1;
} else if (cmd == "logout") {
return 0;
} else if (cmd == "cd") {
try {
if (cmd_args.size() == 0) {
ScopedPath nwd = proc.sys_.resolve(proc, "/");
proc.env_.set_wd(nwd);
} else {
ScopedPath nwd = proc.sys_.resolve(proc, cmd_args);
proc.env_.set_wd(nwd);
}
} catch (const std::exception &e) {
ShellExceptionHandler(proc, current_exception(), io);
}
} else {
auto it = programs.find(cmd);
if (it != programs.end()) {
launch_application(&proc, it->second, cmd_args, io);
} else {
out << "Unrecognized command \"" << cmd << "\"" << endl;
}
}
out << user << "@grass:" << proc.env_.get_wd().stripped() << "$ " << flush;
}
return 0;
}
| [
"ahmad.hazimeh@epfl.ch"
] | ahmad.hazimeh@epfl.ch |
651495ac358ac5252e5e062a5aa36eaaa212a2ce | 2a5d4544cf877439f4d274738750e0bb607d1c72 | /codeforces/317 div2/q4.cpp | da21e0a9db720be7e1cfc18a0d335fa36b03c5a1 | [] | no_license | shivam215/code | 65294836832a0eb76a2156a872b1803bb0b68075 | d70751ca0add4a42a0b91ee8805eda140028452a | refs/heads/master | 2021-01-11T08:32:55.557166 | 2017-09-13T16:00:41 | 2017-09-13T16:00:41 | 76,486,143 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 511 | cpp | #include <bits/stdc++.h>
#define scanint(x) scanf("%d",&x)
#define scanll(x) scanf("%lld",&x)
#define pb push_back
#define mp make_pair
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector< pii >
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std;
ll a[300005];
int main()
{
int n,k;
cin>>n>>k;
for(i=0;i<n;i++)cin>>a[i];
sort(a,a+n);
ll res=0;
for(i=0;i<n-1;i++)
{
res += a[i+1]-a[i];
}
cout<<res<<endl;
return 0;
}
| [
"shivam.kumargarg0008@gmail.com"
] | shivam.kumargarg0008@gmail.com |
181d91252fe2675f3488e40b10e0e167f6fa506a | 29c177e233195d33beb8fd5ce3198a180055ea5d | /Gestao-Biblioteca/Validacoes.cpp | 31f8154cb354784903c66f02cba6a6d7594ef29b | [] | no_license | AlgyJr/Gestao-Biblioteca | 187290c2d7623f35272743b82159ce4155ad9445 | ad611d385d5ba3cd56140d368889c4734ab4e642 | refs/heads/master | 2022-04-02T23:34:15.455586 | 2019-12-12T21:55:11 | 2019-12-12T21:55:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,731 | cpp | //
// Validacoes.cpp
// Gestao-Biblioteca
//
// Created by ALgy Aly, Juicy dos Santos, Regina Massiua, Celeste Ngonhamo on 11/4/19.
// Copyright © 2019 ALgy Aly. All rights reserved.
//
#include "Validacoes.hpp"
#include <iostream>
#include <string.h>
#include <string>
using namespace std;
string Validacoes::validarString(string msg, short min, short m, string erro) {
string val;
int i = 0;
do {
cout<<msg;
getline(cin,val);
i++;
cout<<endl;
if (val.length() < min || val.length() > m)
cout<<erro<<endl;
} while (val.length() < min || val.length() > m);
return val;
}
short Validacoes::validarShort(string msg, short min, short m, string erro) {
short v;
do {
cout<<msg;
cin>>v;
cout<<endl;
if (v < min || v > m)
cout<<erro<<endl;
} while (v < min || v > m);
return v;
}
int Validacoes::validarInt(string msg, int min, int m, string erro) {
int a;
do {
cout<<msg;
cin>>a;
cout<<endl;
if(a < min || a > m)
cout<<erro<<endl;
} while (a < min || a > m);
return a;
}
float Validacoes::validarFloat(string msg, float min, float m, string erro) {
float v;
do {
cout<<msg;
cin>>v;
cout<<endl;
if(v < min || v > m)
cout<<erro<<endl;
} while (v < min || v > m);
return v;
}
string Validacoes::validarRegex(string msg, string expres, string erro) {
//Este copiei na internet nao sei o que significaa nada do que esta escrito kkk, desculpa teras que testar
string val;
do {
// regex url_regex(val);
cout<<msg<<endl;
cin>>val;
cout<<endl;
if(/*regex_match(url,url_regex) == */false)
cout<<"Erro! URL inválido, tente novamente."<<endl;
} while (/*regex_match(url,url_regex) ==*/ false);
return val;
}
string Validacoes::validarStringOptions(string msg, string opt1, string opt2, string opt3, string opt4, string erro) {
string v;
do {
cout<<msg<<endl;
cin>>v;
cout<<endl;
if (v != opt1 && v != opt2 && v != opt2 && v != opt3 && v != opt4)
cout<<erro<<endl;
} while (v != opt1 && v != opt2 && v != opt2 && v != opt3 && v != opt4);
return v;
}
char Validacoes::validarCharOption(string msg, char opt1, char opt2, char opt3, char opt4, string erro){
char v;
do {
cout<<msg<<endl;
cin>>v;
cout<<endl;
if (v != opt1 && v != opt2 && v != opt2 && v != opt3 && v != opt4)
cout<<erro<<endl;
} while (v != opt1 && v != opt2 && v != opt2 && v != opt3 && v != opt4);
return v;
}
| [
"algymussa@gmail.com"
] | algymussa@gmail.com |
3a5db6873d3b73a83d2e3a674c5e46c62211e2f4 | 8702291c0e735660ee06cc1208a481d4ae56de36 | /deps/spidershim/src/v8script.cc | 1fac49e81ca653d5a506c16b6ba3c43da7e9fa3e | [
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"Artistic-2.0",
"Zlib",
"ICU",
"MIT",
"LicenseRef-scancode-unicode",
"BSD-3-Clause",
"NTP",
"LicenseRef-scancode-unknown-license-reference",
"NAIST-2003",
"LicenseRef-scancode-openssl"
] | permissive | evilpie/spidernode | 3e4fbca99013a331528be62937783f8c10ff81ac | b22df3c4b0599264356928a81da1b3046ef1fae1 | refs/heads/master | 2020-04-01T14:59:53.230456 | 2016-04-15T22:39:33 | 2016-04-15T22:39:33 | 56,397,870 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,719 | cc | // Copyright Mozilla Foundation. All rights reserved.
//
// 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.
#include "v8.h"
#include "jsapi.h"
#include "js/CharacterEncoding.h"
#include "v8local.h"
namespace v8 {
MaybeLocal<Script> Script::Compile(Local<Context> context,
Local<String> source,
ScriptOrigin* origin) {
// TODO: Add support for origin.
assert(!origin && "The origin argument is not supported yet");
JSContext* cx = JSContextFromContext(*context);
auto sourceJsVal = reinterpret_cast<JS::Value*>(*source);
auto sourceStr = sourceJsVal->toString();
size_t length = JS_GetStringLength(sourceStr);
auto buffer = static_cast<char16_t*>(js_malloc(sizeof(char16_t)*(length + 1)));
mozilla::Range<char16_t> dest(buffer, length + 1);
if (!JS_CopyStringChars(cx, dest, sourceStr)) {
return MaybeLocal<Script>();
}
JS::SourceBufferHolder sbh(buffer, length,
JS::SourceBufferHolder::GiveOwnership);
JS::CompileOptions options(cx);
options.setVersion(JSVERSION_DEFAULT)
.setNoScriptRval(false);
JS::RootedScript jsScript(cx);
if (!JS::Compile(cx, options, sbh, &jsScript)) {
return MaybeLocal<Script>();
}
return internal::Local<Script>::New(context->GetIsolate(), jsScript);
}
MaybeLocal<Value> Script::Run(Local<Context> context) {
assert(script_);
JSContext* cx = JSContextFromContext(*context);
JS::Rooted<JS::Value> result(cx);
if (!JS_ExecuteScript(cx, JS::Handle<JSScript*>::fromMarkedLocation(&script_), &result)) {
return MaybeLocal<Value>();
}
return internal::Local<Value>::New(context->GetIsolate(), result);
}
}
| [
"ehsan@mozilla.com"
] | ehsan@mozilla.com |
2954c7779762080fc718922a2af8ef0de6502803 | c33a9cee45b3351c50268359aeb505bda82acf26 | /Lesson8/src/timer.cpp | b1e93a45c78dd7ccba17ad73f82386d857cf2649 | [
"MIT"
] | permissive | haklabo/TwinklebearDev-Lessons | 41c386e452d05e365cef7eca72a1d76ddb228e73 | 09f4aecd937681746a4e52fd378b6e337b3e23ea | refs/heads/master | 2020-12-24T22:29:45.542483 | 2013-06-12T06:46:50 | 2013-06-12T06:46:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 965 | cpp | #include <SDL.h>
#include "timer.h"
Timer::Timer()
: mStartTicks(0), mPausedTicks(0), mStarted(false), mPaused(false)
{
}
void Timer::Start(){
mStarted = true;
mPaused = false;
mStartTicks = SDL_GetTicks();
}
void Timer::Stop(){
mStarted = false;
mPaused = false;
}
void Timer::Pause(){
if (mStarted && !mPaused){
mPaused = true;
mPausedTicks = SDL_GetTicks() - mStartTicks;
}
}
void Timer::Unpause(){
if (mPaused){
mPaused = false;
mStartTicks = SDL_GetTicks() - mPausedTicks;
mPausedTicks = 0;
}
}
int Timer::Restart(){
int elapsedTicks = Ticks();
Start();
return elapsedTicks;
}
int Timer::Ticks() const {
if (mStarted){
if (mPaused)
return mPausedTicks;
else
return SDL_GetTicks() - mStartTicks;
}
return 0;
}
bool Timer::Started() const {
return mStarted;
}
bool Timer::Paused() const {
return mPaused;
}
| [
"willusher.life@gmail.com"
] | willusher.life@gmail.com |
858e233b499b85b2a597036240c0d70b0354b1b6 | ca9a748bcaef72bbfd160335a10682dc9c216dba | /External/ChaiScript/include/chaiscript/dispatchkit/function_call.hpp | a434f07c12416f40d5e138e30f92ae94f0e2cfd4 | [] | no_license | lufinkey/iSSB | 37a74f7dd4056868744c87871d3c0b150ca301e9 | 4a1ed538b5f3d380be3f95092893dc5bfd33fb8c | refs/heads/master | 2023-04-15T23:27:28.055281 | 2022-05-13T23:39:10 | 2022-05-13T23:39:10 | 21,109,603 | 36 | 15 | null | 2022-05-18T14:36:35 | 2014-06-23T00:43:40 | C++ | UTF-8 | C++ | false | false | 4,393 | hpp | // This file is distributed under the BSD License.
// See "license.txt" for details.
// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
// Copyright 2009-2014, Jason Turner (jason@emptycrate.com)
// http://www.chaiscript.com
#ifndef CHAISCRIPT_FUNCTION_CALL_HPP_
#define CHAISCRIPT_FUNCTION_CALL_HPP_
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#include "boxed_cast.hpp"
#include "function_call_detail.hpp"
#include "proxy_functions.hpp"
namespace chaiscript {
class Boxed_Value;
class Type_Conversions;
namespace detail {
template <typename T> struct Cast_Helper;
} // namespace detail
} // namespace chaiscript
namespace chaiscript
{
namespace dispatch
{
/// Build a function caller that knows how to dispatch on a set of functions
/// example:
/// std::function<void (int)> f =
/// build_function_caller(dispatchkit.get_function("print"));
/// \returns A std::function object for dispatching
/// \param[in] funcs the set of functions to dispatch on.
template<typename FunctionType>
std::function<FunctionType>
functor(const std::vector<Const_Proxy_Function> &funcs, const Type_Conversions *t_conversions)
{
FunctionType *p=nullptr;
return detail::build_function_caller_helper(p, funcs, t_conversions);
}
/// Build a function caller for a particular Proxy_Function object
/// useful in the case that a function is being pass out from scripting back
/// into code
/// example:
/// void my_function(Proxy_Function f)
/// {
/// std::function<void (int)> local_f =
/// build_function_caller(f);
/// }
/// \returns A std::function object for dispatching
/// \param[in] func A function to execute.
template<typename FunctionType>
std::function<FunctionType>
functor(Const_Proxy_Function func, const Type_Conversions *t_conversions)
{
return functor<FunctionType>(std::vector<Const_Proxy_Function>({func}), t_conversions);
}
/// Helper for automatically unboxing a Boxed_Value that contains a function object
/// and creating a typesafe C++ function caller from it.
template<typename FunctionType>
std::function<FunctionType>
functor(const Boxed_Value &bv, const Type_Conversions *t_conversions)
{
return functor<FunctionType>(boxed_cast<Const_Proxy_Function >(bv, t_conversions), t_conversions);
}
}
namespace detail{
/// Cast helper to handle automatic casting to const std::function &
template<typename Signature>
struct Cast_Helper<const std::function<Signature> &>
{
typedef std::function<Signature> Result_Type;
static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *t_conversions)
{
if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>()))
{
return dispatch::functor<Signature>(ob, t_conversions);
} else {
return Cast_Helper_Inner<const std::function<Signature> &>::cast(ob, t_conversions);
}
}
};
/// Cast helper to handle automatic casting to std::function
template<typename Signature>
struct Cast_Helper<std::function<Signature> >
{
typedef std::function<Signature> Result_Type;
static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *t_conversions)
{
if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>()))
{
return dispatch::functor<Signature>(ob, t_conversions);
} else {
return Cast_Helper_Inner<std::function<Signature> >::cast(ob, t_conversions);
}
}
};
/// Cast helper to handle automatic casting to const std::function
template<typename Signature>
struct Cast_Helper<const std::function<Signature> >
{
typedef std::function<Signature> Result_Type;
static Result_Type cast(const Boxed_Value &ob, const Type_Conversions *t_conversions)
{
if (ob.get_type_info().bare_equal(user_type<Const_Proxy_Function>()))
{
return dispatch::functor<Signature>(ob, t_conversions);
} else {
return Cast_Helper_Inner<const std::function<Signature> >::cast(ob, t_conversions);
}
}
};
}
}
#endif
| [
"Luis Finke"
] | Luis Finke |
a8f9745f154284a85a59f38557c6f8b0ee0ee725 | 95af4fbb629649981d19ae57ea162bf138e73491 | /Algorithms/Strings/hr_in_string.cpp | 40fd818713327d067ac62c5bef9fe9db96ef04cf | [] | no_license | xUrbana/HackerRank | 2cc052ad89f15b7d31172d08d60fab78ad54f3a3 | b93b0909845aa332f7c4a1df3d60456925eea38c | refs/heads/master | 2021-09-25T02:20:53.800806 | 2018-10-16T23:11:59 | 2018-10-16T23:11:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 511 | cpp | #include <bits/stdc++.h>
using namespace std;
string hackerrankInString(string s) {
string hr = "hackerrank";
int p = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] != hr[p]) continue;
else p++;
}
if (p == hr.length()) return "YES";
else return "NO";
}
int main() {
int q;
cin >> q;
for(int a0 = 0; a0 < q; a0++){
string s;
cin >> s;
string result = hackerrankInString(s);
cout << result << endl;
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
f482288b251d996c61f98d02de0d22c0632d7cfe | d77c09721974375972c32c37c73b2d732b13e766 | /src/filterelement.h | 39b5b4759d1fca14c04ebecf4514470cbd147501 | [
"MIT"
] | permissive | eLtMosen/harbour-fishtheke | 2921562f26364045cb9cbdaf5e66aa828b1030f6 | 7fd127ef0fee370a20f617f113364b665c17a4d3 | refs/heads/master | 2020-04-10T02:23:43.913564 | 2019-01-10T17:29:24 | 2019-01-10T17:29:24 | 160,743,240 | 1 | 0 | MIT | 2018-12-06T23:01:24 | 2018-12-06T23:01:24 | null | UTF-8 | C++ | false | false | 1,160 | h | #ifndef SEARCHELEMENT_H
#define SEARCHELEMENT_H
#include <QObject>
class FilterElement : public QObject
{
Q_OBJECT
Q_PROPERTY(QString query READ getQuery WRITE setQuery NOTIFY dummy)
Q_PROPERTY(bool channel READ getChannel WRITE setChannel NOTIFY dummy)
Q_PROPERTY(bool topic READ getTopic WRITE setTopic NOTIFY dummy)
Q_PROPERTY(bool title READ getTitle WRITE setTitle NOTIFY dummy)
Q_PROPERTY(bool description READ getDescription WRITE setDescription NOTIFY dummy)
public:
FilterElement() = default;
FilterElement(const FilterElement &);
QString getQuery() const;
void setQuery(const QString &value);
bool getChannel() const;
void setChannel(bool value);
bool getTopic() const;
void setTopic(bool value);
bool getTitle() const;
void setTitle(bool value);
bool getDescription() const;
void setDescription(bool value);
signals:
void dummy();
private:
QString query;
bool description = false;
bool channel = false;
bool title = false;
bool topic = false;
};
// Registering it for use in QVariant
Q_DECLARE_METATYPE(FilterElement)
#endif // SEARCHELEMENT_H
| [
"zwieberl@users.noreply.github.com"
] | zwieberl@users.noreply.github.com |
08034dd5842d88fd69f17f61a77296a1dd5380ea | 881bd8d6c83ee50e6ced7761b224cda5777c3c11 | /src/hacks/Triggerbot.cpp | e73871efcad9b41bb9efe63c36df1db0e4e1759a | [] | no_license | ALEHACKsp/AssaultCube-Multihack | 5d48c1b549c1b92db7a1c78fabc2453bf2748383 | 5a87262132b65b17ddcb6b32190487ddf3efb220 | refs/heads/main | 2023-02-21T03:48:00.382607 | 2021-01-19T04:42:30 | 2021-01-19T04:42:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 697 | cpp | #include <pch.h>
#include <base.h>
static bool bEnabled = false;
void Base::Hacks::Triggerbot()
{
if (Data::Settings::EnableTriggerbot)
{
playerent* pCrosshairPlayer = Data::game.playerincrosshair();
if ((pCrosshairPlayer && pCrosshairPlayer->state == CS_ALIVE && (pCrosshairPlayer->team != Data::game.player1->team || !m_teammode && !m_coop)) && (!Data::Settings::TriggerbotToggle && Data::WMKeys[Data::Keys::Triggerbot] || Data::Settings::TriggerbotToggle && Data::Settings::TriggerbotToggleState))
{
Data::game.player1->attacking = true;
bEnabled = true;
}
else if (bEnabled)
{
Data::game.player1->attacking = false;
bEnabled = false;
}
}
} | [
"rdbodev@gmail.com"
] | rdbodev@gmail.com |
60389c0dca23cbe5d1df3b2b6df943630a575e45 | 478570cde911b8e8e39046de62d3b5966b850384 | /apicompatanamdw/bcdrivers/mw/appinstall/startup_list_management_api/SelfSignedStartupApp/src/SelfSignedStartupApp.cpp | 566d36d6ba87e52fa35325832bbf617c54fd30f9 | [] | no_license | SymbianSource/oss.FCL.sftools.ana.compatanamdw | a6a8abf9ef7ad71021d43b7f2b2076b504d4445e | 1169475bbf82ebb763de36686d144336fcf9d93b | refs/heads/master | 2020-12-24T12:29:44.646072 | 2010-11-11T14:03:20 | 2010-11-11T14:03:20 | 72,994,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,196 | cpp | /*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:
*
*/
#include <e32std.h>
#include <e32base.h>
#include <e32cons.h>
_LIT( KTestMessage, "Test Application started" );
CConsoleBase* console;
void callTestL( )
{
console = Console::NewL( _L( "MyTestApp" ), TSize( KConsFullScreen, KConsFullScreen ) );
CleanupStack::PushL( console );
console->Printf( _L("\nThis is a test application lauched during startup") );
while (1) {
User::After(5000000);
}
CleanupStack::PopAndDestroy( console );
}
GLDEF_C TInt E32Main()
{
CTrapCleanup* cleanup=CTrapCleanup::New();
TRAPD( error, callTestL() );
__ASSERT_ALWAYS( !error, User::Panic( KTestMessage, error ) );
delete cleanup;
return 0;
}
| [
"none@none"
] | none@none |
57618c0af163b1c7f6b50464e11623ce3e2accb0 | 1ffce36cb30229154cca40669549532f5fec8337 | /3061/3061/3061.cpp | 2f946e649ba183463f580e3a77f46f283e138494 | [] | no_license | zszzlmt/Solutions-for-OJ-of-Peking-University | a1a1692ce6ecdaa6efba1d279f66aa0880a1043a | 4fe13e873b8cc45b185d8d11ac9802f2d96cfaa5 | refs/heads/master | 2021-01-20T06:11:36.803241 | 2017-07-24T14:53:34 | 2017-07-24T14:53:34 | 89,847,121 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,621 | cpp | /*******************************************************************************
** Copyright (C), 2017- , Zach Yeo. *
** File name: 3061.cpp *
** Description: *
** Author: Zhang Shize <zszv587@gmail.com> *
**-----------------------------------------------------------------------------*
** History: *
** v1.0 2017-05-10 *
********************************************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
int t[ 100000 + 1 ];
int main ( ){
int nCase;
int k;
int i;
int n;
int s;
int head;
int tail;
int len;
int sum;
int min;
cin >> nCase;
for ( k = 1; k <= nCase; k ++ ){
cin >> n >> s;
for ( i = 1; i <= n; i ++ ){
cin >> t[ i ];
}
min = 100001;
sum = t[ 1 ];
head = 1;
tail = 1;
while ( true ){
while ( sum < s && tail < n ){
sum += t[ ++ tail ];
}
if ( sum >= s ){
while ( sum >= s ){
sum -= t[ head ++ ];
}
if ( head == 1 && tail == 1 ){
len = 1;
}
else {
len = tail - head + 2;
}
if ( len < min ){
min = len;
}
}
else {
break;
}
}
if ( min == 100001 ){
cout << 0 << endl;
}
else {
cout << min << endl;
}
}
return 0;
} | [
"814135975@qq.com"
] | 814135975@qq.com |
1bba0a43bb717737d5ec80d4ec040665e4f52444 | 80609088adb653e5b546216cf7a7587d2a4ba894 | /src/storage/exec/IndexLimitNode.h | 576d77123bdbc4507d6ffc4daed3e14371973ecb | [
"Apache-2.0"
] | permissive | sherman-the-tank/nebula | 85c10d84b157cbd89e46f553df5249663d5fa422 | c4fe6bf6cf7b48d78de1b0dd4ad720ba5b422634 | refs/heads/master | 2023-05-11T22:33:42.662742 | 2022-01-29T09:40:30 | 2022-01-29T09:40:30 | 187,134,147 | 0 | 0 | Apache-2.0 | 2019-12-17T09:40:48 | 2019-05-17T02:37:45 | C++ | UTF-8 | C++ | false | false | 781 | h | /* Copyright (c) 2021 vesoft inc. All rights reserved.
*
* This source code is licensed under Apache 2.0 License.
*/
#pragma once
#include "folly/Likely.h"
#include "storage/exec/IndexNode.h"
namespace nebula {
namespace storage {
class IndexLimitNode : public IndexNode {
public:
IndexLimitNode(const IndexLimitNode& node);
IndexLimitNode(RuntimeContext* context, uint64_t offset, uint64_t limit);
IndexLimitNode(RuntimeContext* context, uint64_t limit);
std::unique_ptr<IndexNode> copy() override;
std::string identify() override;
protected:
const uint64_t offset_, limit_;
private:
nebula::cpp2::ErrorCode doExecute(PartitionID partId) override;
Result doNext() override;
uint64_t currentOffset_ = 0;
};
} // namespace storage
} // namespace nebula
| [
"noreply@github.com"
] | noreply@github.com |
747078599c0081952dc0b3ff430c1baad2bb7bbb | e7ef5eaaacdbc26563cbcf230880fef2c588dd83 | /input/inputsystem.h | 5f0d8072e3f690b819fcda7e709639d26a0fb1db | [
"Apache-2.0"
] | permissive | federicotdn/tecs | 67934d2016d4997f9a6725a3b80e8a3bf2611e47 | bb043ee61d41900143f2f3be58269ad85e56379f | refs/heads/master | 2020-05-18T17:05:27.611356 | 2015-08-22T05:32:35 | 2015-08-22T05:32:35 | 40,375,809 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 379 | h | #ifndef TECS_INPUTSYSTEM
#define TECS_INPUTSYSTEM
#include "inputnode.h"
#include "../system.h"
struct GLFWwindow;
namespace ecs
{
class Engine;
class InputSystem : public System<InputNode>
{
GLFWwindow *win;
Engine &engine;
public:
InputSystem(GLFWwindow* w, Engine& eng);
void update(const double gameTime) override;
};
}
#endif
/* TECS_INPUTSYSTEM */
| [
"ftedinur@itba.edu.ar"
] | ftedinur@itba.edu.ar |
0bd21f84cbd146d5f78551a4afc0ed366fd034bb | f6529b63d418f7d0563d33e817c4c3f6ec6c618d | /source/menu/menu_config_adv.cpp | 9e12aaa8671ffba0949c9f1f0e0ff8022f69ab4b | [] | no_license | Captnoord/Wodeflow | b087659303bc4e6d7360714357167701a2f1e8da | 5c8d6cf837aee74dc4265e3ea971a335ba41a47c | refs/heads/master | 2020-12-24T14:45:43.854896 | 2011-07-25T14:15:53 | 2011-07-25T14:15:53 | 2,096,630 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 9,873 | cpp |
#include "menu.hpp"
#include "wbfs.h"
#include <dirent.h>
#include <wiiuse/wpad.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
using namespace std;
static const int g_curPage = 2;
template <class T> static inline T loopNum(T i, T s)
{
return (i + s) % s;
}
void CMenu::_hideConfigAdv(bool instant)
{
m_btnMgr.hide(m_configLblTitle, instant);
m_btnMgr.hide(m_configBtnBack, instant);
m_btnMgr.hide(m_configLblPage, instant);
m_btnMgr.hide(m_configBtnPageM, instant);
m_btnMgr.hide(m_configBtnPageP, instant);
//
m_btnMgr.hide(m_configAdvLblInstall, instant);
m_btnMgr.hide(m_configAdvBtnInstall, instant);
m_btnMgr.hide(m_configAdvLblTheme, instant);
m_btnMgr.hide(m_configAdvLblCurTheme, instant);
m_btnMgr.hide(m_configAdvBtnCurThemeM, instant);
m_btnMgr.hide(m_configAdvBtnCurThemeP, instant);
m_btnMgr.hide(m_configAdvLblLanguage, instant);
m_btnMgr.hide(m_configAdvLblCurLanguage, instant);
m_btnMgr.hide(m_configAdvBtnCurLanguageM, instant);
m_btnMgr.hide(m_configAdvBtnCurLanguageP, instant);
m_btnMgr.hide(m_configAdvLblCFTheme, instant);
m_btnMgr.hide(m_configAdvBtnCFTheme, instant);
for (u32 i = 0; i < ARRAY_SIZE(m_configAdvLblUser); ++i)
if (m_configAdvLblUser[i] != -1u)
m_btnMgr.hide(m_configAdvLblUser[i], instant);
}
void CMenu::_showConfigAdv(void)
{
_setBg(m_configAdvBg, m_configAdvBg);
m_btnMgr.show(m_configLblTitle);
m_btnMgr.show(m_configBtnBack);
m_btnMgr.show(m_configLblPage);
m_btnMgr.show(m_configBtnPageM);
m_btnMgr.show(m_configBtnPageP);
//
m_btnMgr.show(m_configAdvLblCurTheme);
m_btnMgr.show(m_configAdvBtnCurThemeM);
m_btnMgr.show(m_configAdvBtnCurThemeP);
m_btnMgr.show(m_configAdvLblTheme);
if( !m_locked )
{
m_btnMgr.show(m_configAdvLblInstall);
m_btnMgr.show(m_configAdvBtnInstall);
m_btnMgr.show(m_configAdvLblLanguage);
m_btnMgr.show(m_configAdvLblCurLanguage);
m_btnMgr.show(m_configAdvBtnCurLanguageM);
m_btnMgr.show(m_configAdvBtnCurLanguageP);
m_btnMgr.show(m_configAdvLblCFTheme);
m_btnMgr.show(m_configAdvBtnCFTheme);
}
for (u32 i = 0; i < ARRAY_SIZE(m_configAdvLblUser); ++i)
if (m_configAdvLblUser[i] != -1u)
m_btnMgr.show(m_configAdvLblUser[i]);
//
m_btnMgr.setText(m_configLblPage, wfmt(L"%i / %i", g_curPage, m_locked ? g_curPage : CMenu::_nbCfgPages));
m_btnMgr.setText(m_configAdvLblCurLanguage, m_curLanguage);
m_btnMgr.setText(m_configAdvLblCurTheme, m_cfg.getString(" GENERAL", "theme"));
}
static string upperCase(string text)
{
char c;
for (string::size_type i = 0; i < text.size(); ++i)
{
c = text[i];
if (c >= 'a' && c <= 'z')
text[i] = c & 0xDF;
}
return text;
}
static void listThemes(const char * path, vector<string> &themes)
{
DIR *d;
struct dirent *dir;
string fileName;
bool def = false;
themes.clear();
d = opendir(path);
if (d != 0)
{
dir = readdir(d);
while (dir != 0)
{
fileName = upperCase(dir->d_name);
def = def || fileName == "DEFAULT.INI";
if (fileName.size() > 4 && fileName.substr(fileName.size() - 4, 4) == ".INI")
themes.push_back(fileName.substr(0, fileName.size() - 4));
dir = readdir(d);
}
closedir(d);
}
if (!def)
themes.push_back("DEFAULT");
sort(themes.begin(), themes.end());
}
int CMenu::_configAdv(void)
{
s32 padsState;
WPADData *wd;
u32 btn;
int nextPage = 0;
vector<string> themes;
int curTheme;
string prevTheme = m_cfg.getString(" GENERAL", "theme");
listThemes(m_themeDir.c_str(), themes);
curTheme = 0;
for (u32 i = 0; i < themes.size(); ++i)
if (themes[i] == prevTheme)
{
curTheme = i;
break;
}
_showConfigAdv();
while (true)
{
WPAD_ScanPads();
padsState = WPAD_ButtonsDown(0);
wd = WPAD_Data(0);
btn = _btnRepeat(wd->btns_h);
if ((padsState & (WPAD_BUTTON_HOME | WPAD_BUTTON_B)) != 0)
break;
if (wd->ir.valid)
m_btnMgr.mouse(wd->ir.x - m_cur.width() / 2, wd->ir.y - m_cur.height() / 2);
else if ((padsState & WPAD_BUTTON_UP) != 0)
m_btnMgr.up();
else if ((padsState & WPAD_BUTTON_DOWN) != 0)
m_btnMgr.down();
if ((padsState & WPAD_BUTTON_MINUS) != 0 || ((padsState & WPAD_BUTTON_A) != 0 && m_btnMgr.selected() == m_configBtnPageM))
{
nextPage = max(1, m_locked ? 1 : g_curPage - 1);
m_btnMgr.click(m_configBtnPageM);
break;
}
if (!m_locked && ((padsState & WPAD_BUTTON_PLUS) != 0 || ((padsState & WPAD_BUTTON_A) != 0 && m_btnMgr.selected() == m_configBtnPageP)))
{
nextPage = min(g_curPage + 1, CMenu::_nbCfgPages);
m_btnMgr.click(m_configBtnPageP);
break;
}
if ((padsState & WPAD_BUTTON_A) != 0)
{
m_btnMgr.click();
if (m_btnMgr.selected() == m_configBtnBack)
break;
else if (m_btnMgr.selected() == m_configAdvBtnInstall)
{
if (!WBFS_IsReadOnly())
{
_hideConfigAdv();
_wbfsOp(CMenu::WO_ADD_GAME);
_showConfigAdv();
}
else
{
error(_t("wbfsop10", L"This filesystem is read-only. You cannot install games or remove them."));
}
}
else if (m_btnMgr.selected() == m_configAdvBtnCurThemeP)
{
curTheme = loopNum(curTheme + 1, (int)themes.size());
m_cfg.setString(" GENERAL", "theme", themes[curTheme]);
_showConfigAdv();
}
else if (m_btnMgr.selected() == m_configAdvBtnCurThemeM)
{
curTheme = loopNum(curTheme - 1, (int)themes.size());
m_cfg.setString(" GENERAL", "theme", themes[curTheme]);
_showConfigAdv();
}
else if (m_btnMgr.selected() == m_configAdvBtnCurLanguageP)
{
m_curLanguage = m_loc.nextDomain(m_curLanguage);
m_cfg.setString(" GENERAL", "language", m_curLanguage);
_updateText();
_showConfigAdv();
}
else if (m_btnMgr.selected() == m_configAdvBtnCurLanguageM)
{
m_curLanguage = m_loc.prevDomain(m_curLanguage);
m_cfg.setString(" GENERAL", "language", m_curLanguage);
_updateText();
_showConfigAdv();
}
else if (m_btnMgr.selected() == m_configAdvBtnCFTheme)
{
_hideConfigAdv();
_cfTheme();
_showConfigAdv();
}
}
_mainLoopCommon(wd);
}
_hideConfigAdv();
if (m_gameList.empty())
_loadGameList();
return nextPage;
}
void CMenu::_initConfigAdvMenu(CMenu::SThemeData &theme)
{
_addUserLabels(theme, m_configAdvLblUser, ARRAY_SIZE(m_configAdvLblUser), "CONFIG_ADV");
m_configAdvBg = _texture(theme.texSet, "CONFIG_ADV/BG", "texture", theme.bg);
m_configAdvLblTheme = _addLabel(theme, "CONFIG_ADV/THEME", theme.lblFont, L"", 40, 130, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_configAdvLblCurTheme = _addLabel(theme, "CONFIG_ADV/THEME_BTN", theme.btnFont, L"", 386, 130, 158, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
m_configAdvBtnCurThemeM = _addPicButton(theme, "CONFIG_ADV/THEME_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 330, 130, 56, 56);
m_configAdvBtnCurThemeP = _addPicButton(theme, "CONFIG_ADV/THEME_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 544, 130, 56, 56);
m_configAdvLblLanguage = _addLabel(theme, "CONFIG_ADV/LANGUAGE", theme.lblFont, L"", 40, 190, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_configAdvLblCurLanguage = _addLabel(theme, "CONFIG_ADV/LANGUAGE_BTN", theme.btnFont, L"", 386, 190, 158, 56, theme.btnFontColor, FTGX_JUSTIFY_CENTER | FTGX_ALIGN_MIDDLE, theme.btnTexC);
m_configAdvBtnCurLanguageM = _addPicButton(theme, "CONFIG_ADV/LANGUAGE_MINUS", theme.btnTexMinus, theme.btnTexMinusS, 330, 190, 56, 56);
m_configAdvBtnCurLanguageP = _addPicButton(theme, "CONFIG_ADV/LANGUAGE_PLUS", theme.btnTexPlus, theme.btnTexPlusS, 544, 190, 56, 56);
m_configAdvLblCFTheme = _addLabel(theme, "CONFIG_ADV/CUSTOMIZE_CF", theme.lblFont, L"", 40, 250, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_configAdvBtnCFTheme = _addButton(theme, "CONFIG_ADV/CUSTOMIZE_CF_BTN", theme.btnFont, L"", 330, 250, 270, 56, theme.btnFontColor);
m_configAdvLblInstall = _addLabel(theme, "CONFIG_ADV/INSTALL", theme.lblFont, L"", 40, 310, 290, 56, theme.lblFontColor, FTGX_JUSTIFY_LEFT | FTGX_ALIGN_MIDDLE);
m_configAdvBtnInstall = _addButton(theme, "CONFIG_ADV/INSTALL_BTN", theme.btnFont, L"", 330, 310, 270, 56, theme.btnFontColor);
//
_setHideAnim(m_configAdvLblTheme, "CONFIG_ADV/THEME", 100, 0, -2.f, 0.f);
_setHideAnim(m_configAdvLblCurTheme, "CONFIG_ADV/THEME_BTN", 0, 0, 1.f, -1.f);
_setHideAnim(m_configAdvBtnCurThemeM, "CONFIG_ADV/THEME_MINUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_configAdvBtnCurThemeP, "CONFIG_ADV/THEME_PLUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_configAdvLblLanguage, "CONFIG_ADV/LANGUAGE", 100, 0, -2.f, 0.f);
_setHideAnim(m_configAdvLblCurLanguage, "CONFIG_ADV/LANGUAGE_BTN", 0, 0, 1.f, -1.f);
_setHideAnim(m_configAdvBtnCurLanguageM, "CONFIG_ADV/LANGUAGE_MINUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_configAdvBtnCurLanguageP, "CONFIG_ADV/LANGUAGE_PLUS", 0, 0, 1.f, -1.f);
_setHideAnim(m_configAdvLblCFTheme, "CONFIG_ADV/CUSTOMIZE_CF", 100, 0, -2.f, 0.f);
_setHideAnim(m_configAdvBtnCFTheme, "CONFIG_ADV/CUSTOMIZE_CF_BTN", 0, 0, 1.f, -1.f);
_setHideAnim(m_configAdvLblInstall, "CONFIG_ADV/INSTALL", 100, 0, -2.f, 0.f);
_setHideAnim(m_configAdvBtnInstall, "CONFIG_ADV/INSTALL_BTN", 0, 0, 1.f, -1.f);
_hideConfigAdv(true);
_textConfigAdv();
}
void CMenu::_textConfigAdv(void)
{
m_btnMgr.setText(m_configAdvLblTheme, _t("cfga7", L"Theme"));
m_btnMgr.setText(m_configAdvLblLanguage, _t("cfga6", L"Language"));
m_btnMgr.setText(m_configAdvLblCFTheme, _t("cfgc4", L"Adjust Coverflow"));
m_btnMgr.setText(m_configAdvBtnCFTheme, _t("cfgc5", L"Go"));
m_btnMgr.setText(m_configAdvLblInstall, _t("cfga2", L"Install game"));
m_btnMgr.setText(m_configAdvBtnInstall, _t("cfga3", L"Install"));
}
| [
"r-win@live.com@a6d911d2-2a6f-2b2f-592f-0469abc2858f"
] | r-win@live.com@a6d911d2-2a6f-2b2f-592f-0469abc2858f |
2622bf55ed87c24324f56f529d5c040023a4265d | 6b2c596adad1eed4ee1237e1dc1c84e5e401f8ab | /external/cpp-taskflow/cpp-taskflow-cpp14/benchmark/black_scholes/common.hpp | bd3ca941f75ef8e514ae4f2cb7f29c2fdcd45c54 | [
"MIT",
"BSD-3-Clause"
] | permissive | ahmed-agiza/OpenPhySyn | 76253ca03aeb70e53e170d9be76e1018ac78fe7b | 51841240e5213a7e74bc6321bbe4193323378c8e | refs/heads/master | 2020-09-26T06:42:07.214499 | 2019-12-14T03:42:56 | 2019-12-14T03:42:56 | 226,192,119 | 0 | 0 | BSD-3-Clause | 2019-12-05T21:28:39 | 2019-12-05T21:28:38 | null | UTF-8 | C++ | false | false | 7,566 | hpp | #include <stdlib.h>
#include <math.h>
#include <string>
#include <cassert>
#include <iostream>
#include <chrono>
#include <fstream>
#include <memory>
//Precision to use for calculations
#define FPTYPE float
#define NUM_RUNS 100
typedef struct OptionData_ {
FPTYPE s; // spot price
FPTYPE strike; // strike price
FPTYPE r; // risk-free interest rate
FPTYPE divq; // dividend rate
FPTYPE v; // volatility
FPTYPE t; // time to maturity or option expiration in years
// (1yr = 1.0, 6mos = 0.5, 3mos = 0.25, ..., etc)
char OptionType; // Option type. "P"=PUT, "C"=CALL
FPTYPE divs; // dividend vals (not used in this test)
FPTYPE DGrefval; // DerivaGem Reference Value
} OptionData;
inline OptionData *data;
inline FPTYPE *prices;
inline int numOptions;
inline int* otype;
inline FPTYPE* sptprice;
inline FPTYPE* strike;
inline FPTYPE* rate;
inline FPTYPE* volatility;
inline FPTYPE* otime;
inline int numError {0};
inline FPTYPE* BUFFER {nullptr};
inline int* BUFFER2 {nullptr};
////////////////////////////////////////////////////////////////////////////////
// Cumulative Normal Distribution Function
// See Hull, Section 11.8, P.243-244
////////////////////////////////////////////////////////////////////////////////
#define inv_sqrt_2xPI 0.39894228040143270286
inline FPTYPE CNDF( FPTYPE InputX ) {
int sign;
FPTYPE OutputX;
FPTYPE xInput;
FPTYPE xNPrimeofX;
FPTYPE expValues;
FPTYPE xK2;
FPTYPE xK2_2, xK2_3;
FPTYPE xK2_4, xK2_5;
FPTYPE xLocal, xLocal_1;
FPTYPE xLocal_2, xLocal_3;
// Check for negative value of InputX
if (InputX < 0.0) {
InputX = -InputX;
sign = 1;
}
else {
sign = 0;
}
xInput = InputX;
// Compute NPrimeX term common to both four & six decimal accuracy calcs
expValues = std::exp(-0.5f * InputX * InputX);
xNPrimeofX = expValues;
xNPrimeofX = xNPrimeofX * inv_sqrt_2xPI;
xK2 = 0.2316419 * xInput;
xK2 = 1.0 + xK2;
xK2 = 1.0 / xK2;
xK2_2 = xK2 * xK2;
xK2_3 = xK2_2 * xK2;
xK2_4 = xK2_3 * xK2;
xK2_5 = xK2_4 * xK2;
xLocal_1 = xK2 * 0.319381530;
xLocal_2 = xK2_2 * (-0.356563782);
xLocal_3 = xK2_3 * 1.781477937;
xLocal_2 = xLocal_2 + xLocal_3;
xLocal_3 = xK2_4 * (-1.821255978);
xLocal_2 = xLocal_2 + xLocal_3;
xLocal_3 = xK2_5 * 1.330274429;
xLocal_2 = xLocal_2 + xLocal_3;
xLocal_1 = xLocal_2 + xLocal_1;
xLocal = xLocal_1 * xNPrimeofX;
xLocal = 1.0 - xLocal;
OutputX = xLocal;
if (sign) {
OutputX = 1.0 - OutputX;
}
return OutputX;
}
inline FPTYPE BlkSchlsEqEuroNoDiv(
FPTYPE sptprice, FPTYPE strike, FPTYPE rate,
FPTYPE volatility, FPTYPE time, int otype, float timet) {
FPTYPE OptionPrice;
// local private working variables for the calculation
//FPTYPE xStockPrice; // These two variables are not used
//FPTYPE xStrikePrice;
FPTYPE xRiskFreeRate;
FPTYPE xVolatility;
FPTYPE xTime;
FPTYPE xSqrtTime;
FPTYPE logValues;
FPTYPE xLogTerm;
FPTYPE xD1;
FPTYPE xD2;
FPTYPE xPowerTerm;
FPTYPE xDen;
FPTYPE d1;
FPTYPE d2;
FPTYPE FutureValueX;
FPTYPE NofXd1;
FPTYPE NofXd2;
FPTYPE NegNofXd1;
FPTYPE NegNofXd2;
//xStockPrice = sptprice;
//xStrikePrice = strike;
xRiskFreeRate = rate;
xVolatility = volatility;
xTime = time;
xSqrtTime = std::sqrt(xTime);
logValues = std::log(sptprice/strike);
xLogTerm = logValues;
xPowerTerm = xVolatility * xVolatility;
xPowerTerm = xPowerTerm * 0.5;
xD1 = xRiskFreeRate + xPowerTerm;
xD1 = xD1 * xTime;
xD1 = xD1 + xLogTerm;
xDen = xVolatility * xSqrtTime;
xD1 = xD1 / xDen;
xD2 = xD1 - xDen;
d1 = xD1;
d2 = xD2;
NofXd1 = CNDF( d1 );
NofXd2 = CNDF( d2 );
FutureValueX = strike * ( std::exp( -(rate)*(time) ) );
if (otype == 0) {
OptionPrice = (sptprice * NofXd1) - (FutureValueX * NofXd2);
}
else {
NegNofXd1 = (1.0 - NofXd1);
NegNofXd2 = (1.0 - NofXd2);
OptionPrice = (FutureValueX * NegNofXd2) - (sptprice * NegNofXd1);
}
return OptionPrice;
}
inline void check_error(unsigned i, FPTYPE price) {
FPTYPE priceDelta = data[i].DGrefval - price;
if(std::fabs(priceDelta) >= 1e-4 ){
printf("Error on %d. Computed=%.5f, Ref=%.5f, Delta=%.5f\n",
i, price, data[i].DGrefval, priceDelta);
numError ++;
}
}
// Sequential version
inline void bs_seq(FPTYPE *seq_prices) {
int i, j;
FPTYPE price;
for (j=0; j<NUM_RUNS; j++) {
for (i=0; i<numOptions; i++) {
/* Calling main function to calculate option value based on
* Black & Scholes's equation.
*/
price = BlkSchlsEqEuroNoDiv( sptprice[i], strike[i],
rate[i], volatility[i], otime[i],
otype[i], 0);
seq_prices[i] = price;
#ifdef ERR_CHK
check_error(i, seq_prices[i]);
#endif
}
}
}
// Write prices to output file
inline void dump(const std::string& output_file) {
std::ofstream ofs(output_file);
if(!ofs) {
std::cerr << "ERROR: Unable to open file " << output_file << std::endl;
return ;
}
ofs << numOptions << '\n';
for(auto i=0; i<numOptions; i++) {
ofs << prices[i] << '\n';
}
}
// Read input option data from file
inline bool parse_options(const std::string& option_file) {
FILE* file = fopen(option_file.data(), "r");
if(file == NULL) {
std::cerr << "ERROR: Unable to open file " << option_file << std::endl;
return false;
}
if(fscanf(file, "%i", &numOptions) != 1) {
std::cerr << "ERROR: Unable to read from file " << option_file << std::endl;
fclose(file);
return false;
}
// Allocate spaces for the option data
data = static_cast<OptionData*>(malloc(numOptions*sizeof(OptionData)));
prices = static_cast<FPTYPE*>(malloc(numOptions*sizeof(FPTYPE)));
for (int i = 0; i < numOptions; ++ i) {
int num = fscanf(file, "%f %f %f %f %f %f %c %f %f",
&data[i].s, &data[i].strike, &data[i].r,
&data[i].divq, &data[i].v, &data[i].t,
&data[i].OptionType, &data[i].divs, &data[i].DGrefval);
if(num != 9) {
std::cerr << "ERROR: Unable to read from file " << option_file << std::endl;
fclose(file);
return false;
}
}
const int PAD {256};
const int LINESIZE {64};
BUFFER = static_cast<FPTYPE *>(malloc(5 * numOptions * sizeof(FPTYPE) + PAD));
sptprice = reinterpret_cast<FPTYPE *>(((unsigned long long)BUFFER + PAD) & ~(LINESIZE - 1));
strike = sptprice + numOptions;
rate = strike + numOptions;
volatility = rate + numOptions;
otime = volatility + numOptions;
BUFFER2 = static_cast<int *>(malloc(numOptions * sizeof(FPTYPE) + PAD));
//otype = (int *) (((unsigned long long)BUFFER2 + PAD) & ~(LINESIZE - 1));
otype = reinterpret_cast<int *>(((unsigned long long)BUFFER2 + PAD) & ~(LINESIZE - 1));
for(auto i=0; i<numOptions; i++) {
otype[i] = (data[i].OptionType == 'P') ? 1 : 0;
sptprice[i] = data[i].s;
strike[i] = data[i].strike;
rate[i] = data[i].r;
volatility[i] = data[i].v;
otime[i] = data[i].t;
}
fclose(file);
return true;
//std::cout << "Size of data: " << numOptions * (sizeof(OptionData) + sizeof(int)) << std::endl;
}
std::chrono::microseconds measure_time_taskflow(unsigned);
std::chrono::microseconds measure_time_tbb(unsigned);
std::chrono::microseconds measure_time_omp(unsigned);
| [
"ahmed.agiza22@gmail.com"
] | ahmed.agiza22@gmail.com |
bcfe39f7aca93a1c5194d34276f39c3f2895e279 | fd2b409199cc0e2fdd8d020623b7fda0d2d5af97 | /smsapp/smtable/index.h | 1b69eae1f58fc5517d2f1ad2956764fddf9bc98b | [] | no_license | wujunjenny/smgw | 6cc7a936b605abe9a9dc5ad316a4203819c6afc6 | 2c2bc82922b1f14a54660c635afb01177e6a4524 | refs/heads/master | 2021-01-23T02:39:54.218476 | 2017-05-10T15:36:31 | 2017-05-10T15:36:31 | 86,011,729 | 1 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,087 | h | #if !defined(_INDEX_H_INCLUDED_)
#define _INDEX_H_INCLUDED_
#define UL unsigned long
#include <time.h>
#include <string.h>
#include <iostream>
#include <stdlib.h>
#define INSERT_FAIL -2
#define STRING_IS_UNIQUE 1
#define TIME_IS_UNIQUE 2
#define OUT_OFF_MEMORY -1
#define NOT_FIND -3
#define MAX_STRING_INDEX 2
#define MAX_UL_INDEX 2
#define MAX_INDEX MAX_STRING_INDEX+MAX_UL_INDEX
typedef unsigned long POINTER;
class CPOSITION
{
public:
POINTER Point;
int Offset;
};
/*===========================================================
元素类:
=============================================================*/
class CElement
{
public:
void SetValue(void* pValue);
void* GetValue();
CPOSITION * GetRelativeIndex(int index);
void SetRelativeIndex(CPOSITION * pos,int index);
CPOSITION * GetRelativeMap();
void SetRelativeMap(CPOSITION * pos);
CElement(void * pValue);
private:
CPOSITION m_posIndexItem[MAX_INDEX];
CPOSITION m_posMapItem;
void * m_pValue;
};
/*============================================================
文件名index.h
/*============================================================
字符串索引项结构
=============================================================*/
class CStringIndexItem
{
#ifdef _DEBUG
char str[128];
#endif
public:
char * m_pKey;
CElement * m_pLinkElement;
CStringIndexItem * m_pNext;
CStringIndexItem * m_pPre;
CStringIndexItem( char * pKey,CElement * pLinkElement=NULL, CStringIndexItem *pNext=NULL,CStringIndexItem *pPre=NULL);
~CStringIndexItem();
};
/*============================================================
数字索引项结构
=============================================================*/
class CNumberIndexItem
{
#ifdef _DEBUG
char str[128];
#endif
public:
UL m_nKey;
CElement * m_pLinkElement;
CNumberIndexItem * m_pNext;
CNumberIndexItem * m_pPre;
CNumberIndexItem(UL nKey, CElement * pLinkElement, CNumberIndexItem* pNext,CNumberIndexItem *pPre)
{
#ifdef _DEBUG
strcpy(str, "CNumberIndexItem, ABCDEFGHIJKABCDEFGHIJKABCDEFGHIJKABCDEFGHIJK");
#endif
m_nKey=nKey;m_pLinkElement=pLinkElement;m_pNext=pNext;m_pPre=pPre;
}
};
/*=================================================================
字符串索引类
=================================================================*/
class CStringIndex
{
public:
CStringIndex(int HashSize=1024 , int DefStringSize=40 , int Unique=1);
~CStringIndex();
int Find( char* pKey,CElement *** pResult);
int Insert( char *pKey,CElement *pElement,CPOSITION * pos);
int Delete( char *pKey);
int Delete(CPOSITION * pos, CElement *pElement);
int GetKeyLen(){return m_nKeyLen;};
void SetKeyLen(int nLen){m_nKeyLen=nLen;};
// CStringIndexItem ** GetHashTable(){ return m_HashTable; }
void print();
protected:
void Clear();
int m_nKeyLen;
unsigned long m_nHashSize;
int m_nUnique;
CStringIndexItem ** m_HashTable;
int HashFuc(const char * string);
};
/*=================================================================
数字索引类
=================================================================*/
class CNumberIndex
{
public:
CNumberIndex(int HashSize =3600,int Unique=0);
~CNumberIndex();
int Find(UL nKey,CElement *** pResult);
int Insert(UL nKey,CElement *pElement,CPOSITION * pos);
int Delete(UL nKey);
int Delete(CPOSITION * pos , CElement *pElement);
// CNumberIndexItem ** GetHashTable(){ return m_HashTable;}
void print();
void printHash();
protected:
virtual int HashFuc(UL nKey);
unsigned long m_nHashSize;
int m_nUnique;
CNumberIndexItem ** m_HashTable;
};
class CMapIndex : public CNumberIndex
{
public:
CMapIndex(int HashSize =3600,int Unique=1) : CNumberIndex(HashSize,Unique) {};
~CMapIndex() { };
int FindForClear(UL ulOffset,CElement *** pResult);
protected:
int HashFuc(UL nKey);
};
#endif // !defined(_INDEX_H_INCLUDED_)
| [
"wujun@shareinfo.com.cn"
] | wujun@shareinfo.com.cn |
ee7620c3695d831974c264def16da1cd74023402 | c96bb8615706654dd4960b26330028358b15e25e | /src/CollisionObject/MeshCollisionUtils.hpp | 11caf6d13520281ade44a57f207f333af078f313 | [
"MIT"
] | permissive | brookman/IPC | b94da8fbb4e1a92110de7e7b2192cc0f3b92f7e2 | 531527c3583d4b3ef7950bb10147a6d33308f7a3 | refs/heads/master | 2023-06-27T15:21:28.237717 | 2021-07-26T17:22:51 | 2021-07-26T17:22:51 | 349,055,185 | 0 | 0 | MIT | 2021-03-18T11:55:56 | 2021-03-18T11:55:56 | null | UTF-8 | C++ | false | false | 88,091 | hpp | //
// MeshCollisionUtils.hpp
// IPC
//
// Created by Minchen Li on 6/03/19.
//
#ifndef MeshCollisionUtils_hpp
#define MeshCollisionUtils_hpp
#include "Types.hpp"
#include "Mesh.hpp"
#include <iostream>
#include <array>
#include <boost/functional/hash.hpp>
#include <Eigen/Eigen>
namespace IPC {
class MMCVID {
public:
std::array<int, 4> data;
public:
MMCVID(int a, int b, int c, int d)
{
data[0] = a;
data[1] = b;
data[2] = c;
data[3] = d;
}
MMCVID(int a = -1)
{
data[0] = a;
data[1] = data[2] = data[3] = -1;
}
void set(int a, int b, int c, int d)
{
data[0] = a;
data[1] = b;
data[2] = c;
data[3] = d;
}
const int& operator[](int i) const
{
return data[i];
}
int& operator[](int i)
{
return data[i];
}
friend bool operator==(const MMCVID& lhs, const MMCVID& rhs)
{
if ((lhs[0] == rhs[0]) && (lhs[1] == rhs[1]) && (lhs[2] == rhs[2]) && (lhs[3] == rhs[3])) {
return true;
}
else {
return false;
}
}
friend bool operator<(const MMCVID& lhs, const MMCVID& rhs)
{
if (lhs[0] < rhs[0]) {
return true;
}
else if (lhs[0] == rhs[0]) {
if (lhs[1] < rhs[1]) {
return true;
}
else if (lhs[1] == rhs[1]) {
if (lhs[2] < rhs[2]) {
return true;
}
else if (lhs[2] == rhs[2]) {
if (lhs[3] < rhs[3]) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
else {
return false;
}
}
std::string str() const
{
std::stringstream s;
s << "(";
for (int i = 0; i < data.size(); i++) {
s << this->data[i] << (i != data.size() - 1 ? "," : ")");
}
return s.str();
}
};
class MMCVIDHash {
public:
size_t operator()(const MMCVID& mmcvid) const
{
return boost::hash_range(mmcvid.data.begin(), mmcvid.data.end());
}
};
template <int dim>
inline void compute_c(
const Eigen::Matrix<double, 1, dim>& v0, // point
const Eigen::Matrix<double, 1, dim>& v1, // triangle point 0
const Eigen::Matrix<double, 1, dim>& v2, // triangle point 2
const Eigen::Matrix<double, 1, dim>& v3, // triangle point 1
double& c, double coef)
{
if constexpr (dim == 3) {
c = coef * (v3 - v0).dot((v1 - v0).cross(v2 - v0));
}
else {
}
}
inline bool pointInTriangle(double x, double y)
{
return (x >= 0.0) && (y >= 0.0) && (1.0 - x - y >= 0.0);
}
template <int dim>
inline bool pointInTriangleSweep(const Eigen::Matrix<double, 1, dim>& pt,
const Eigen::Matrix<double, 1, dim>& v0,
const Eigen::Matrix<double, 1, dim>& v1,
const Eigen::Matrix<double, 1, dim>& v2)
{
//TODO: consider directions!
Eigen::Matrix<double, 2, dim> basis;
basis.row(0) = v1 - v0;
basis.row(1) = v2 - v0;
Eigen::Matrix<double, 1, dim> vect = pt - v0;
Eigen::Matrix<double, 2, 1> pt2D01 = (basis * basis.transpose()).ldlt().solve(basis * vect.transpose());
return pointInTriangle(pt2D01[0], pt2D01[1]);
}
inline void d_PP(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
double& d)
{
d = (v0 - v1).squaredNorm();
}
inline void g_PP(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
Eigen::Matrix<double, 6, 1>& g)
{
g.template segment<3>(0) = 2.0 * (v0 - v1);
g.template segment<3>(3) = -g.template segment<3>(0);
}
inline void H_PP(Eigen::Matrix<double, 6, 6>& H)
{
H.setZero();
H(0, 0) = H(1, 1) = H(2, 2) = H(3, 3) = H(4, 4) = H(5, 5) = 2.0;
H(0, 3) = H(1, 4) = H(2, 5) = H(3, 0) = H(4, 1) = H(5, 2) = -2.0;
}
inline void derivTest_PP(void)
{
Eigen::RowVector3d v[2];
v[0] << 0.0, 0.0, 0.0;
v[1] << 1.0, 0.1, 0.0;
double d0;
d_PP(v[0], v[1], d0);
double eps = 1.0e-6;
Eigen::Matrix<double, 6, 1> fd, s;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[2];
vv[0] = v[0];
vv[1] = v[1];
vv[i][j] += eps;
double d;
d_PP(vv[0], vv[1], d);
fd[i * 3 + j] = (d - d0) / eps;
}
}
g_PP(v[0], v[1], s);
std::cout << s.transpose() << std::endl;
std::cout << fd.transpose() << std::endl;
std::cout << "relError = " << (s - fd).norm() / fd.norm() << std::endl;
Eigen::Matrix<double, 6, 6> Hfd, Hs;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[2];
vv[0] = v[0];
vv[1] = v[1];
vv[i][j] += eps;
Eigen::Matrix<double, 6, 1> g;
g_PP(vv[0], vv[1], g);
Hfd.col(i * 3 + j) = (g - s) / eps;
}
}
H_PP(Hs);
std::cout << Hs.transpose() << std::endl;
std::cout << Hfd.transpose() << std::endl;
std::cout << "relError = " << (Hs - Hfd).norm() / Hfd.norm() << std::endl;
}
inline void d_PE(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
double& d)
{
d = (v1 - v0).cross(v2 - v0).squaredNorm() / (v2 - v1).squaredNorm();
}
inline void g_PE(double v01, double v02, double v03, double v11, double v12, double v13,
double v21, double v22, double v23, double g[9])
{
double t17;
double t18;
double t19;
double t20;
double t21;
double t22;
double t23;
double t24;
double t25;
double t42;
double t44;
double t45;
double t46;
double t43;
double t50;
double t51;
double t52;
/* G_PE */
/* G = G_PE(V01,V02,V03,V11,V12,V13,V21,V22,V23) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 10-Jun-2019 18:02:37 */
t17 = -v11 + v01;
t18 = -v12 + v02;
t19 = -v13 + v03;
t20 = -v21 + v01;
t21 = -v22 + v02;
t22 = -v23 + v03;
t23 = -v21 + v11;
t24 = -v22 + v12;
t25 = -v23 + v13;
t42 = 1.0 / ((t23 * t23 + t24 * t24) + t25 * t25);
t44 = t17 * t21 + -(t18 * t20);
t45 = t17 * t22 + -(t19 * t20);
t46 = t18 * t22 + -(t19 * t21);
t43 = t42 * t42;
t50 = (t44 * t44 + t45 * t45) + t46 * t46;
t51 = (v11 * 2.0 + -(v21 * 2.0)) * t43 * t50;
t52 = (v12 * 2.0 + -(v22 * 2.0)) * t43 * t50;
t43 = (v13 * 2.0 + -(v23 * 2.0)) * t43 * t50;
g[0] = t42 * (t24 * t44 * 2.0 + t25 * t45 * 2.0);
g[1] = -t42 * (t23 * t44 * 2.0 - t25 * t46 * 2.0);
g[2] = -t42 * (t23 * t45 * 2.0 + t24 * t46 * 2.0);
g[3] = -t51 - t42 * (t21 * t44 * 2.0 + t22 * t45 * 2.0);
g[4] = -t52 + t42 * (t20 * t44 * 2.0 - t22 * t46 * 2.0);
g[5] = -t43 + t42 * (t20 * t45 * 2.0 + t21 * t46 * 2.0);
g[6] = t51 + t42 * (t18 * t44 * 2.0 + t19 * t45 * 2.0);
g[7] = t52 - t42 * (t17 * t44 * 2.0 - t19 * t46 * 2.0);
g[8] = t43 - t42 * (t17 * t45 * 2.0 + t18 * t46 * 2.0);
}
inline void g_PE(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
Eigen::Matrix<double, 9, 1>& g)
{
g_PE(v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
g.data());
}
inline void H_PE(double v01, double v02, double v03, double v11, double v12, double v13,
double v21, double v22, double v23, double H[81])
{
double t17;
double t18;
double t19;
double t20;
double t21;
double t22;
double t23;
double t24;
double t25;
double t26;
double t27;
double t28;
double t35;
double t36;
double t37;
double t50;
double t51;
double t52;
double t53;
double t54;
double t55;
double t56;
double t62;
double t70;
double t71;
double t75;
double t79;
double t80;
double t84;
double t88;
double t38;
double t39;
double t40;
double t41;
double t42;
double t43;
double t44;
double t46;
double t48;
double t57;
double t58;
double t60;
double t63;
double t65;
double t67;
double t102;
double t103;
double t104;
double t162;
double t163;
double t164;
double t213;
double t214;
double t215;
double t216;
double t217;
double t218;
double t225;
double t226;
double t227;
double t229;
double t230;
double t311;
double t231;
double t232;
double t233;
double t234;
double t235;
double t236;
double t237;
double t238;
double t239;
double t240;
double t245;
double t279;
double t281;
double t282;
double t283;
double t287;
double t289;
double t247;
double t248;
double t249;
double t250;
double t251;
double t252;
double t253;
double t293;
double t295;
double t299;
double t300;
double t303;
double t304;
double t294;
double t297;
double t301;
double t302;
/* H_PE */
/* H = H_PE(V01,V02,V03,V11,V12,V13,V21,V22,V23) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 10-Jun-2019 18:02:39 */
t17 = -v11 + v01;
t18 = -v12 + v02;
t19 = -v13 + v03;
t20 = -v21 + v01;
t21 = -v22 + v02;
t22 = -v23 + v03;
t23 = -v21 + v11;
t24 = -v22 + v12;
t25 = -v23 + v13;
t26 = v11 * 2.0 + -(v21 * 2.0);
t27 = v12 * 2.0 + -(v22 * 2.0);
t28 = v13 * 2.0 + -(v23 * 2.0);
t35 = t23 * t23;
t36 = t24 * t24;
t37 = t25 * t25;
t50 = t17 * t21;
t51 = t18 * t20;
t52 = t17 * t22;
t53 = t19 * t20;
t54 = t18 * t22;
t55 = t19 * t21;
t56 = t17 * t20 * 2.0;
t62 = t18 * t21 * 2.0;
t70 = t19 * t22 * 2.0;
t71 = t17 * t23 * 2.0;
t75 = t18 * t24 * 2.0;
t79 = t19 * t25 * 2.0;
t80 = t20 * t23 * 2.0;
t84 = t21 * t24 * 2.0;
t88 = t22 * t25 * 2.0;
t38 = t17 * t17 * 2.0;
t39 = t18 * t18 * 2.0;
t40 = t19 * t19 * 2.0;
t41 = t20 * t20 * 2.0;
t42 = t21 * t21 * 2.0;
t43 = t22 * t22 * 2.0;
t44 = t35 * 2.0;
t46 = t36 * 2.0;
t48 = t37 * 2.0;
t57 = t50 * 2.0;
t58 = t51 * 2.0;
t60 = t52 * 2.0;
t63 = t53 * 2.0;
t65 = t54 * 2.0;
t67 = t55 * 2.0;
t102 = 1.0 / ((t35 + t36) + t37);
t36 = t50 + -t51;
t35 = t52 + -t53;
t37 = t54 + -t55;
t103 = t102 * t102;
t104 = pow(t102, 3.0);
t162 = -(t23 * t24 * t102 * 2.0);
t163 = -(t23 * t25 * t102 * 2.0);
t164 = -(t24 * t25 * t102 * 2.0);
t213 = t18 * t36 * 2.0 + t19 * t35 * 2.0;
t214 = t17 * t35 * 2.0 + t18 * t37 * 2.0;
t215 = t21 * t36 * 2.0 + t22 * t35 * 2.0;
t216 = t20 * t35 * 2.0 + t21 * t37 * 2.0;
t217 = t24 * t36 * 2.0 + t25 * t35 * 2.0;
t218 = t23 * t35 * 2.0 + t24 * t37 * 2.0;
t35 = (t36 * t36 + t35 * t35) + t37 * t37;
t225 = t17 * t36 * 2.0 + -(t19 * t37 * 2.0);
t226 = t20 * t36 * 2.0 + -(t22 * t37 * 2.0);
t227 = t23 * t36 * 2.0 + -(t25 * t37 * 2.0);
t36 = t26 * t103;
t229 = t36 * t213;
t37 = t27 * t103;
t230 = t37 * t213;
t311 = t28 * t103;
t231 = t311 * t213;
t232 = t36 * t214;
t233 = t37 * t214;
t234 = t311 * t214;
t235 = t36 * t215;
t236 = t37 * t215;
t237 = t311 * t215;
t238 = t36 * t216;
t239 = t37 * t216;
t240 = t311 * t216;
t214 = t36 * t217;
t215 = t37 * t217;
t216 = t311 * t217;
t217 = t36 * t218;
t245 = t37 * t218;
t213 = t311 * t218;
t279 = t103 * t35 * 2.0;
t281 = t26 * t26 * t104 * t35 * 2.0;
t282 = t27 * t27 * t104 * t35 * 2.0;
t283 = t28 * t28 * t104 * t35 * 2.0;
t287 = t26 * t27 * t104 * t35 * 2.0;
t218 = t26 * t28 * t104 * t35 * 2.0;
t289 = t27 * t28 * t104 * t35 * 2.0;
t247 = t36 * t225;
t248 = t37 * t225;
t249 = t311 * t225;
t250 = t36 * t226;
t251 = t37 * t226;
t252 = t311 * t226;
t253 = t36 * t227;
t35 = t37 * t227;
t36 = t311 * t227;
t293 = t102 * (t75 + t79) + t214;
t295 = -(t102 * (t80 + t84)) + t213;
t299 = t102 * ((t63 + t22 * t23 * 2.0) + -t60) + t217;
t300 = t102 * ((t67 + t22 * t24 * 2.0) + -t65) + t245;
t303 = -(t102 * ((t57 + t17 * t24 * 2.0) + -t58)) + t215;
t304 = -(t102 * ((t60 + t17 * t25 * 2.0) + -t63)) + t216;
t294 = t102 * (t71 + t75) + -t213;
t297 = -(t102 * (t80 + t88)) + t35;
t88 = -(t102 * (t84 + t88)) + -t214;
t301 = t102 * ((t58 + t21 * t23 * 2.0) + -t57) + t253;
t302 = t102 * ((t65 + t21 * t25 * 2.0) + -t67) + t36;
t84 = t102 * ((t57 + t20 * t24 * 2.0) + -t58) + -t215;
t80 = t102 * ((t60 + t20 * t25 * 2.0) + -t63) + -t216;
t75 = -(t102 * ((t63 + t19 * t23 * 2.0) + -t60)) + -t217;
t227 = -(t102 * ((t67 + t19 * t24 * 2.0) + -t65)) + -t245;
t311 = ((-(t17 * t19 * t102 * 2.0) + t231) + -t232) + t218;
t245 = ((-(t20 * t22 * t102 * 2.0) + t237) + -t238) + t218;
t226 = ((-t102 * (t67 - t54 * 4.0) + t233) + t252) + -t289;
t28 = ((-t102 * (t63 - t52 * 4.0) + t232) + -t237) + -t218;
t27 = ((-t102 * (t58 - t50 * 4.0) + t247) + -t236) + -t287;
t225 = ((-(t102 * (t65 + -(t55 * 4.0))) + t239) + t249) + -t289;
t26 = ((-(t102 * (t60 + -(t53 * 4.0))) + t238) + -t231) + -t218;
t103 = ((-(t102 * (t57 + -(t51 * 4.0))) + t250) + -t230) + -t287;
t104 = (((-(t102 * (t56 + t62)) + t234) + t240) + t279) + -t283;
t218 = (((-(t102 * (t56 + t70)) + t248) + t251) + t279) + -t282;
t217 = (((-(t102 * (t62 + t70)) + -t229) + -t235) + t279) + -t281;
t216 = t102 * (t71 + t79) + -t35;
t215 = -(t102 * ((t58 + t18 * t23 * 2.0) + -t57)) + -t253;
t214 = -(t102 * ((t65 + t18 * t25 * 2.0) + -t67)) + -t36;
t213 = ((-(t17 * t18 * t102 * 2.0) + t230) + -t247) + t287;
t37 = ((-(t20 * t21 * t102 * 2.0) + t236) + -t250) + t287;
t36 = ((-(t18 * t19 * t102 * 2.0) + -t233) + -t249) + t289;
t35 = ((-(t21 * t22 * t102 * 2.0) + -t239) + -t252) + t289;
H[0] = t102 * (t46 + t48);
H[1] = t162;
H[2] = t163;
H[3] = t88;
H[4] = t84;
H[5] = t80;
H[6] = t293;
H[7] = t303;
H[8] = t304;
H[9] = t162;
H[10] = t102 * (t44 + t48);
H[11] = t164;
H[12] = t301;
H[13] = t297;
H[14] = t302;
H[15] = t215;
H[16] = t216;
H[17] = t214;
H[18] = t163;
H[19] = t164;
H[20] = t102 * (t44 + t46);
H[21] = t299;
H[22] = t300;
H[23] = t295;
H[24] = t75;
H[25] = t227;
H[26] = t294;
H[27] = t88;
H[28] = t301;
H[29] = t299;
H[30] = ((t235 * 2.0 + -t279) + t281) + t102 * (t42 + t43);
H[31] = t37;
H[32] = t245;
H[33] = t217;
H[34] = t27;
H[35] = t28;
H[36] = t84;
H[37] = t297;
H[38] = t300;
H[39] = t37;
H[40] = ((t251 * -2.0 + -t279) + t282) + t102 * (t41 + t43);
H[41] = t35;
H[42] = t103;
H[43] = t218;
H[44] = t226;
H[45] = t80;
H[46] = t302;
H[47] = t295;
H[48] = t245;
H[49] = t35;
H[50] = ((t240 * -2.0 + -t279) + t283) + t102 * (t41 + t42);
H[51] = t26;
H[52] = t225;
H[53] = t104;
H[54] = t293;
H[55] = t215;
H[56] = t75;
H[57] = t217;
H[58] = t103;
H[59] = t26;
H[60] = ((t229 * 2.0 + -t279) + t281) + t102 * (t39 + t40);
H[61] = t213;
H[62] = t311;
H[63] = t303;
H[64] = t216;
H[65] = t227;
H[66] = t27;
H[67] = t218;
H[68] = t225;
H[69] = t213;
H[70] = ((t248 * -2.0 + -t279) + t282) + t102 * (t38 + t40);
H[71] = t36;
H[72] = t304;
H[73] = t214;
H[74] = t294;
H[75] = t28;
H[76] = t226;
H[77] = t104;
H[78] = t311;
H[79] = t36;
H[80] = ((t234 * -2.0 + -t279) + t283) + t102 * (t38 + t39);
}
inline void H_PE(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
Eigen::Matrix<double, 9, 9>& H)
{
H_PE(v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
H.data());
}
inline void derivTest_PE(void)
{
Eigen::RowVector3d v[3];
v[0] << 0.0, 0.0, 0.0;
v[1] << 1.0, 0.1, 0.0;
v[2] << 0.0, 1.1, -0.1;
double d0;
d_PE(v[0], v[1], v[2], d0);
double eps = 1.0e-6;
Eigen::Matrix<double, 9, 1> fd, s;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[3];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[i][j] += eps;
double d;
d_PE(vv[0], vv[1], vv[2], d);
fd[i * 3 + j] = (d - d0) / eps;
}
}
g_PE(v[0], v[1], v[2], s);
std::cout << s.transpose() << std::endl;
std::cout << fd.transpose() << std::endl;
std::cout << "relError = " << (s - fd).norm() / fd.norm() << std::endl;
Eigen::Matrix<double, 9, 9> Hfd, Hs;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[3];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[i][j] += eps;
Eigen::Matrix<double, 9, 1> g;
g_PE(vv[0], vv[1], vv[2], g);
Hfd.col(i * 3 + j) = (g - s) / eps;
}
}
H_PE(v[0], v[1], v[2], Hs);
std::cout << Hs.transpose() << std::endl;
std::cout << Hfd.transpose() << std::endl;
std::cout << "relError = " << (Hs - Hfd).norm() / Hfd.norm() << std::endl;
}
inline void d_PT(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double& d)
{
Eigen::RowVector3d b = (v2 - v1).cross(v3 - v1);
double aTb = (v0 - v1).dot(b);
d = aTb * aTb / b.squaredNorm();
}
inline void g_PT(double v01, double v02, double v03, double v11, double v12, double v13,
double v21, double v22, double v23, double v31, double v32, double v33,
double g[12])
{
double t11;
double t12;
double t13;
double t14;
double t15;
double t16;
double t17;
double t18;
double t19;
double t20;
double t21;
double t22;
double t32;
double t33;
double t34;
double t43;
double t45;
double t44;
double t46;
/* G_PT */
/* G = G_PT(V01,V02,V03,V11,V12,V13,V21,V22,V23,V31,V32,V33) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 10-Jun-2019 17:42:16 */
t11 = -v11 + v01;
t12 = -v12 + v02;
t13 = -v13 + v03;
t14 = -v21 + v11;
t15 = -v22 + v12;
t16 = -v23 + v13;
t17 = -v31 + v11;
t18 = -v32 + v12;
t19 = -v33 + v13;
t20 = -v31 + v21;
t21 = -v32 + v22;
t22 = -v33 + v23;
t32 = t14 * t18 + -(t15 * t17);
t33 = t14 * t19 + -(t16 * t17);
t34 = t15 * t19 + -(t16 * t18);
t43 = 1.0 / ((t32 * t32 + t33 * t33) + t34 * t34);
t45 = (t13 * t32 + t11 * t34) + -(t12 * t33);
t44 = t43 * t43;
t46 = t45 * t45;
g[0] = t34 * t43 * t45 * 2.0;
g[1] = t33 * t43 * t45 * -2.0;
g[2] = t32 * t43 * t45 * 2.0;
t45 *= t43;
g[3] = -t44 * t46 * (t21 * t32 * 2.0 + t22 * t33 * 2.0) - t45 * ((t34 + t12 * t22) - t13 * t21) * 2.0;
t43 = t44 * t46;
g[4] = t43 * (t20 * t32 * 2.0 - t22 * t34 * 2.0) + t45 * ((t33 + t11 * t22) - t13 * t20) * 2.0;
g[5] = t43 * (t20 * t33 * 2.0 + t21 * t34 * 2.0) - t45 * ((t32 + t11 * t21) - t12 * t20) * 2.0;
g[6] = t45 * (t12 * t19 - t13 * t18) * 2.0 + t43 * (t18 * t32 * 2.0 + t19 * t33 * 2.0);
g[7] = t45 * (t11 * t19 - t13 * t17) * -2.0 - t43 * (t17 * t32 * 2.0 - t19 * t34 * 2.0);
g[8] = t45 * (t11 * t18 - t12 * t17) * 2.0 - t43 * (t17 * t33 * 2.0 + t18 * t34 * 2.0);
g[9] = t45 * (t12 * t16 - t13 * t15) * -2.0 - t43 * (t15 * t32 * 2.0 + t16 * t33 * 2.0);
g[10] = t45 * (t11 * t16 - t13 * t14) * 2.0 + t43 * (t14 * t32 * 2.0 - t16 * t34 * 2.0);
g[11] = t45 * (t11 * t15 - t12 * t14) * -2.0 + t43 * (t14 * t33 * 2.0 + t15 * t34 * 2.0);
}
inline void g_PT(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
Eigen::Matrix<double, 12, 1>& g)
{
g_PT(v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
v3[0], v3[1], v3[2],
g.data());
}
inline void H_PT(double v01, double v02, double v03, double v11, double v12, double v13,
double v21, double v22, double v23, double v31, double v32, double v33,
double H[144])
{
double t11;
double t12;
double t13;
double t18;
double t20;
double t22;
double t23;
double t24;
double t25;
double t26;
double t27;
double t28;
double t65;
double t66;
double t67;
double t68;
double t69;
double t70;
double t71;
double t77;
double t85;
double t86;
double t90;
double t94;
double t95;
double t99;
double t103;
double t38;
double t39;
double t40;
double t41;
double t42;
double t43;
double t44;
double t45;
double t46;
double t72;
double t73;
double t75;
double t78;
double t80;
double t82;
double t125;
double t126;
double t127;
double t128;
double t129;
double t130;
double t131;
double t133;
double t135;
double t149;
double t150;
double t151;
double t189;
double t190;
double t191;
double t192;
double t193;
double t194;
double t195;
double t196;
double t197;
double t198;
double t199;
double t200;
double t202;
double t205;
double t203;
double t204;
double t206;
double t241;
double t309;
double t310;
double t312;
double t313;
double t314;
double t315;
double t316;
double t317;
double t318;
double t319;
double t321;
double t322;
double t323;
double t324;
double t325;
double t261;
double t262;
double t599;
double t600;
double t602;
double t605;
double t609;
double t610;
double t611;
double t613;
double t615;
double t616;
double t621;
double t622;
double t623;
double t625;
double t645;
double t646_tmp;
double t646;
double t601;
double t603;
double t604;
double t606;
double t607;
double t608;
double t612;
double t614;
double t617;
double t618;
double t619;
double t620;
double t624;
double t626;
double t627;
double t628;
double t629;
double t630;
double t631;
double t632;
double t633;
double t634;
double t635;
double t636;
double t637;
double t638;
/* H_PT */
/* H = H_PT(V01,V02,V03,V11,V12,V13,V21,V22,V23,V31,V32,V33) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 10-Jun-2019 17:42:25 */
t11 = -v11 + v01;
t12 = -v12 + v02;
t13 = -v13 + v03;
t18 = -v21 + v11;
t20 = -v22 + v12;
t22 = -v23 + v13;
t23 = -v31 + v11;
t24 = -v32 + v12;
t25 = -v33 + v13;
t26 = -v31 + v21;
t27 = -v32 + v22;
t28 = -v33 + v23;
t65 = t18 * t24;
t66 = t20 * t23;
t67 = t18 * t25;
t68 = t22 * t23;
t69 = t20 * t25;
t70 = t22 * t24;
t71 = t18 * t23 * 2.0;
t77 = t20 * t24 * 2.0;
t85 = t22 * t25 * 2.0;
t86 = t18 * t26 * 2.0;
t90 = t20 * t27 * 2.0;
t94 = t22 * t28 * 2.0;
t95 = t23 * t26 * 2.0;
t99 = t24 * t27 * 2.0;
t103 = t25 * t28 * 2.0;
t38 = t18 * t18 * 2.0;
t39 = t20 * t20 * 2.0;
t40 = t22 * t22 * 2.0;
t41 = t23 * t23 * 2.0;
t42 = t24 * t24 * 2.0;
t43 = t25 * t25 * 2.0;
t44 = t26 * t26 * 2.0;
t45 = t27 * t27 * 2.0;
t46 = t28 * t28 * 2.0;
t72 = t65 * 2.0;
t73 = t66 * 2.0;
t75 = t67 * 2.0;
t78 = t68 * 2.0;
t80 = t69 * 2.0;
t82 = t70 * 2.0;
t125 = t11 * t20 + -(t12 * t18);
t126 = t11 * t22 + -(t13 * t18);
t127 = t12 * t22 + -(t13 * t20);
t128 = t11 * t24 + -(t12 * t23);
t129 = t11 * t25 + -(t13 * t23);
t130 = t12 * t25 + -(t13 * t24);
t131 = t65 + -t66;
t133 = t67 + -t68;
t135 = t69 + -t70;
t149 = t131 * t131;
t150 = t133 * t133;
t151 = t135 * t135;
t189 = (t11 * t27 + -(t12 * t26)) + t131;
t190 = (t11 * t28 + -(t13 * t26)) + t133;
t191 = (t12 * t28 + -(t13 * t27)) + t135;
t192 = t20 * t131 * 2.0 + t22 * t133 * 2.0;
t193 = t18 * t133 * 2.0 + t20 * t135 * 2.0;
t194 = t24 * t131 * 2.0 + t25 * t133 * 2.0;
t195 = t23 * t133 * 2.0 + t24 * t135 * 2.0;
t196 = t27 * t131 * 2.0 + t28 * t133 * 2.0;
t197 = t26 * t133 * 2.0 + t27 * t135 * 2.0;
t198 = t18 * t131 * 2.0 + -(t22 * t135 * 2.0);
t199 = t23 * t131 * 2.0 + -(t25 * t135 * 2.0);
t200 = t26 * t131 * 2.0 + -(t28 * t135 * 2.0);
t202 = 1.0 / ((t149 + t150) + t151);
t205 = (t13 * t131 + t11 * t135) + -(t12 * t133);
t203 = t202 * t202;
t204 = pow(t202, 3.0);
t206 = t205 * t205;
t241 = t131 * t135 * t202 * 2.0;
t309 = t11 * t202 * t205 * 2.0;
t310 = t12 * t202 * t205 * 2.0;
t13 = t13 * t202 * t205 * 2.0;
t312 = (-v21 + v01) * t202 * t205 * 2.0;
t313 = (-v22 + v02) * t202 * t205 * 2.0;
t314 = (-v23 + v03) * t202 * t205 * 2.0;
t315 = (-v31 + v01) * t202 * t205 * 2.0;
t316 = t18 * t202 * t205 * 2.0;
t317 = (-v32 + v02) * t202 * t205 * 2.0;
t318 = t20 * t202 * t205 * 2.0;
t319 = (-v33 + v03) * t202 * t205 * 2.0;
t11 = t22 * t202 * t205 * 2.0;
t321 = t23 * t202 * t205 * 2.0;
t322 = t24 * t202 * t205 * 2.0;
t323 = t25 * t202 * t205 * 2.0;
t324 = t26 * t202 * t205 * 2.0;
t325 = t27 * t202 * t205 * 2.0;
t12 = t28 * t202 * t205 * 2.0;
t261 = -(t131 * t133 * t202 * 2.0);
t262 = -(t133 * t135 * t202 * 2.0);
t599 = t130 * t135 * t202 * 2.0 + t135 * t194 * t203 * t205 * 2.0;
t600 = -(t125 * t131 * t202 * 2.0) + t131 * t193 * t203 * t205 * 2.0;
t602 = t129 * t133 * t202 * 2.0 + t133 * t199 * t203 * t205 * 2.0;
t605 = -(t131 * t189 * t202 * 2.0) + t131 * t197 * t203 * t205 * 2.0;
t609 = (t127 * t133 * t202 * 2.0 + -t11) + t133 * t192 * t203 * t205 * 2.0;
t610 = (t126 * t135 * t202 * 2.0 + t11) + t135 * t198 * t203 * t205 * 2.0;
t611 = (t130 * t131 * t202 * 2.0 + -t322) + t131 * t194 * t203 * t205 * 2.0;
t613 = (t126 * t131 * t202 * 2.0 + -t316) + t131 * t198 * t203 * t205 * 2.0;
t615 = (-(t125 * t135 * t202 * 2.0) + -t318) + t135 * t193 * t203 * t205 * 2.0;
t616 = (-(t128 * t133 * t202 * 2.0) + -t321) + t133 * t195 * t203 * t205 * 2.0;
t621 = (t133 * t191 * t202 * 2.0 + -t12) + t133 * t196 * t203 * t205 * 2.0;
t622 = (t135 * t190 * t202 * 2.0 + t12) + t135 * t200 * t203 * t205 * 2.0;
t623 = (t131 * t190 * t202 * 2.0 + -t324) + t131 * t200 * t203 * t205 * 2.0;
t625 = (-(t135 * t189 * t202 * 2.0) + -t325) + t135 * t197 * t203 * t205 * 2.0;
t645 = ((((t127 * t129 * t202 * 2.0 + -t13) + (t72 + -(t66 * 4.0)) * t203 * t206) + t129 * t192 * t203 * t205 * 2.0) + t127 * t199 * t203 * t205 * 2.0) + t192 * t199 * t204 * t206 * 2.0;
t646_tmp = t203 * t206;
t646 = ((((t126 * t130 * t202 * 2.0 + t13) + t646_tmp * (t73 - t65 * 4.0)) + t126 * t194 * t203 * t205 * 2.0) + t130 * t198 * t203 * t205 * 2.0) + t194 * t198 * t204 * t206 * 2.0;
t601 = t128 * t131 * t202 * 2.0 + -(t131 * t195 * t203 * t205 * 2.0);
t603 = -(t127 * t135 * t202 * 2.0) + -(t135 * t192 * t203 * t205 * 2.0);
t604 = -(t126 * t133 * t202 * 2.0) + -(t133 * t198 * t203 * t205 * 2.0);
t606 = -(t135 * t191 * t202 * 2.0) + -(t135 * t196 * t203 * t205 * 2.0);
t607 = -(t133 * t190 * t202 * 2.0) + -(t133 * t200 * t203 * t205 * 2.0);
t608 = (t125 * t133 * t202 * 2.0 + t316) + -(t133 * t193 * t203 * t205 * 2.0);
t612 = (t128 * t135 * t202 * 2.0 + t322) + -(t135 * t195 * t203 * t205 * 2.0);
t614 = (-(t127 * t131 * t202 * 2.0) + t318) + -(t131 * t192 * t203 * t205 * 2.0);
t617 = (-(t130 * t133 * t202 * 2.0) + t323) + -(t133 * t194 * t203 * t205 * 2.0);
t618 = (-(t129 * t131 * t202 * 2.0) + t321) + -(t131 * t199 * t203 * t205 * 2.0);
t619 = (-(t129 * t135 * t202 * 2.0) + -t323) + -(t135 * t199 * t203 * t205 * 2.0);
t620 = (t133 * t189 * t202 * 2.0 + t324) + -(t133 * t197 * t203 * t205 * 2.0);
t624 = (-(t131 * t191 * t202 * 2.0) + t325) + -(t131 * t196 * t203 * t205 * 2.0);
t626 = (((t125 * t127 * t202 * 2.0 + t18 * t22 * t203 * t206 * 2.0) + t125 * t192 * t203 * t205 * 2.0) + -(t127 * t193 * t203 * t205 * 2.0)) + -(t192 * t193 * t204 * t206 * 2.0);
t627 = (((t128 * t130 * t202 * 2.0 + t23 * t25 * t203 * t206 * 2.0) + t128 * t194 * t203 * t205 * 2.0) + -(t130 * t195 * t203 * t205 * 2.0)) + -(t194 * t195 * t204 * t206 * 2.0);
t628 = (((-(t125 * t126 * t202 * 2.0) + t20 * t22 * t203 * t206 * 2.0) + t126 * t193 * t203 * t205 * 2.0) + -(t125 * t198 * t203 * t205 * 2.0)) + t193 * t198 * t204 * t206 * 2.0;
t629 = (((-(t128 * t129 * t202 * 2.0) + t24 * t25 * t203 * t206 * 2.0) + t129 * t195 * t203 * t205 * 2.0) + -(t128 * t199 * t203 * t205 * 2.0)) + t195 * t199 * t204 * t206 * 2.0;
t630 = (((-(t126 * t127 * t202 * 2.0) + t18 * t20 * t203 * t206 * 2.0) + -(t126 * t192 * t203 * t205 * 2.0)) + -(t127 * t198 * t203 * t205 * 2.0)) + -(t192 * t198 * t204 * t206 * 2.0);
t631 = (((-(t129 * t130 * t202 * 2.0) + t23 * t24 * t203 * t206 * 2.0) + -(t129 * t194 * t203 * t205 * 2.0)) + -(t130 * t199 * t203 * t205 * 2.0)) + -(t194 * t199 * t204 * t206 * 2.0);
t632 = (((-(t125 * t128 * t202 * 2.0) + (t71 + t77) * t203 * t206) + t128 * t193 * t203 * t205 * 2.0) + t125 * t195 * t203 * t205 * 2.0) + -(t193 * t195 * t204 * t206 * 2.0);
t633 = (((-(t127 * t130 * t202 * 2.0) + (t77 + t85) * t203 * t206) + -(t130 * t192 * t203 * t205 * 2.0)) + -(t127 * t194 * t203 * t205 * 2.0)) + -(t192 * t194 * t204 * t206 * 2.0);
t634 = (((-(t126 * t129 * t202 * 2.0) + (t71 + t85) * t203 * t206) + -(t129 * t198 * t203 * t205 * 2.0)) + -(t126 * t199 * t203 * t205 * 2.0)) + -(t198 * t199 * t204 * t206 * 2.0);
t635 = (((t127 * t191 * t202 * 2.0 + -((t90 + t94) * t203 * t206)) + t127 * t196 * t203 * t205 * 2.0) + t191 * t192 * t203 * t205 * 2.0) + t192 * t196 * t204 * t206 * 2.0;
t636 = (((-(t128 * t189 * t202 * 2.0) + (t95 + t99) * t203 * t206) + t128 * t197 * t203 * t205 * 2.0) + t189 * t195 * t203 * t205 * 2.0) + -(t195 * t197 * t204 * t206 * 2.0);
t637 = (((t125 * t189 * t202 * 2.0 + -((t86 + t90) * t203 * t206)) + -(t125 * t197 * t203 * t205 * 2.0)) + -(t189 * t193 * t203 * t205 * 2.0)) + t193 * t197 * t204 * t206 * 2.0;
t638 = (((-(t130 * t191 * t202 * 2.0) + (t99 + t103) * t203 * t206) + -(t130 * t196 * t203 * t205 * 2.0)) + -(t191 * t194 * t203 * t205 * 2.0)) + -(t194 * t196 * t204 * t206 * 2.0);
t86 = (((t126 * t190 * t202 * 2.0 + -((t86 + t94) * t203 * t206)) + t126 * t200 * t203 * t205 * 2.0) + t190 * t198 * t203 * t205 * 2.0) + t198 * t200 * t204 * t206 * 2.0;
t71 = (((-(t129 * t190 * t202 * 2.0) + (t95 + t103) * t203 * t206) + -(t129 * t200 * t203 * t205 * 2.0)) + -(t190 * t199 * t203 * t205 * 2.0)) + -(t199 * t200 * t204 * t206 * 2.0);
t85 = (((t189 * t191 * t202 * 2.0 + t26 * t28 * t203 * t206 * 2.0) + t189 * t196 * t203 * t205 * 2.0) + -(t191 * t197 * t203 * t205 * 2.0)) + -(t196 * t197 * t204 * t206 * 2.0);
t90 = (((-(t189 * t190 * t202 * 2.0) + t27 * t28 * t203 * t206 * 2.0) + t190 * t197 * t203 * t205 * 2.0) + -(t189 * t200 * t203 * t205 * 2.0)) + t197 * t200 * t204 * t206 * 2.0;
t99 = (((-(t190 * t191 * t202 * 2.0) + t26 * t27 * t203 * t206 * 2.0) + -(t190 * t196 * t203 * t205 * 2.0)) + -(t191 * t200 * t203 * t205 * 2.0)) + -(t196 * t200 * t204 * t206 * 2.0);
t77 = ((((-(t127 * t128 * t202 * 2.0) + t310) + (t75 + -(t68 * 4.0)) * t203 * t206) + t127 * t195 * t203 * t205 * 2.0) + -(t128 * t192 * t203 * t205 * 2.0)) + t192 * t195 * t204 * t206 * 2.0;
t131 = ((((t126 * t128 * t202 * 2.0 + -t309) + (t80 + -(t70 * 4.0)) * t203 * t206) + t128 * t198 * t203 * t205 * 2.0) + -(t126 * t195 * t203 * t205 * 2.0)) + -(t195 * t198 * t204 * t206 * 2.0);
t133 = ((((-(t125 * t130 * t202 * 2.0) + -t310) + t646_tmp * (t78 - t67 * 4.0))
+ t130 * t193 * t203 * t205 * 2.0)
+ -(t125 * t194 * t203 * t205 * 2.0))
+ t193 * t194 * t204 * t206 * 2.0;
t325 = ((((t125 * t129 * t202 * 2.0 + t309) + t646_tmp * (t82 - t69 * 4.0)) + t125 * t199 * t203 * t205 * 2.0) + -(t129 * t193 * t203 * t205 * 2.0))
+ -(t193 * t199 * t204 * t206 * 2.0);
t135 = ((((t125 * t191 * t202 * 2.0 + t313) + ((t75 + t18 * t28 * 2.0) + -t78) * t203 * t206) + t125 * t196 * t203 * t205 * 2.0) + -(t191 * t193 * t203 * t205 * 2.0)) + -(t193 * t196 * t204 * t206 * 2.0);
t324 = ((((t127 * t189 * t202 * 2.0 + -t313) + ((t78 + t22 * t26 * 2.0) + -t75) * t203 * t206) + -(t127 * t197 * t203 * t205 * 2.0)) + t189 * t192 * t203 * t205 * 2.0) + -(t192 * t197 * t204 * t206 * 2.0);
t318 = ((((-(t126 * t189 * t202 * 2.0) + t312) + ((t82 + t22 * t27 * 2.0) + -t80) * t203 * t206) + t126 * t197 * t203 * t205 * 2.0) + -(t189 * t198 * t203 * t205 * 2.0)) + t197 * t198 * t204 * t206 * 2.0;
t321 = ((((-(t130 * t189 * t202 * 2.0) + t317) + -(((t78 + t25 * t26 * 2.0) + -t75) * t203 * t206)) + t130 * t197 * t203 * t205 * 2.0) + -(t189 * t194 * t203 * t205 * 2.0)) + t194 * t197 * t204 * t206 * 2.0;
t323 = ((((t129 * t191 * t202 * 2.0 + t319) + -(((t72 + t23 * t27 * 2.0) + -t73) * t203 * t206)) + t129 * t196 * t203 * t205 * 2.0) + t191 * t199 * t203 * t205 * 2.0) + t196 * t199 * t204 * t206 * 2.0;
t322 = ((((-(t125 * t190 * t202 * 2.0) + -t312) + ((t80 + t20 * t28 * 2.0) + -t82) * t203 * t206) + -(t125 * t200 * t203 * t205 * 2.0)) + t190 * t193 * t203 * t205 * 2.0) + t193 * t200 * t204 * t206 * 2.0;
t316 = ((((t130 * t190 * t202 * 2.0 + -t319) + -(((t73 + t24 * t26 * 2.0) + -t72) * t203 * t206)) + t130 * t200 * t203 * t205 * 2.0) + t190 * t194 * t203 * t205 * 2.0) + t194 * t200 * t204 * t206 * 2.0;
t65 = ((((-(t128 * t191 * t202 * 2.0) + -t317) + -(((t75 + t23 * t28 * 2.0) + -t78) * t203 * t206)) + -(t128 * t196 * t203 * t205 * 2.0)) + t191 * t195 * t203 * t205 * 2.0) + t195 * t196 * t204 * t206 * 2.0;
t66 = ((((-(t127 * t190 * t202 * 2.0) + t314) + ((t73 + t20 * t26 * 2.0) + -t72) * t203 * t206) + -(t127 * t200 * t203 * t205 * 2.0)) + -(t190 * t192 * t203 * t205 * 2.0)) + -(t192 * t200 * t204 * t206 * 2.0);
t13 = ((((t128 * t190 * t202 * 2.0 + t315) + -(((t80 + t24 * t28 * 2.0) + -t82) * t203 * t206)) + t128 * t200 * t203 * t205 * 2.0) + -(t190 * t195 * t203 * t205 * 2.0)) + -(t195 * t200 * t204 * t206 * 2.0);
t12 = ((((-(t126 * t191 * t202 * 2.0) + -t314) + ((t72 + t18 * t27 * 2.0) + -t73) * t203 * t206) + -(t126 * t196 * t203 * t205 * 2.0)) + -(t191 * t198 * t203 * t205 * 2.0)) + -(t196 * t198 * t204 * t206 * 2.0);
t11 = ((((t129 * t189 * t202 * 2.0 + -t315) + -(((t82 + t25 * t27 * 2.0) + -t80) * t203 * t206)) + -(t129 * t197 * t203 * t205 * 2.0)) + t189 * t199 * t203 * t205 * 2.0) + -(t197 * t199 * t204 * t206 * 2.0);
H[0] = t151 * t202 * 2.0;
H[1] = t262;
H[2] = t241;
H[3] = t606;
H[4] = t622;
H[5] = t625;
H[6] = t599;
H[7] = t619;
H[8] = t612;
H[9] = t603;
H[10] = t610;
H[11] = t615;
H[12] = t262;
H[13] = t150 * t202 * 2.0;
H[14] = t261;
H[15] = t621;
H[16] = t607;
H[17] = t620;
H[18] = t617;
H[19] = t602;
H[20] = t616;
H[21] = t609;
H[22] = t604;
H[23] = t608;
H[24] = t241;
H[25] = t261;
H[26] = t149 * t202 * 2.0;
H[27] = t624;
H[28] = t623;
H[29] = t605;
H[30] = t611;
H[31] = t618;
H[32] = t601;
H[33] = t614;
H[34] = t613;
H[35] = t600;
H[36] = t606;
H[37] = t621;
H[38] = t624;
H[39] = ((t191 * t191 * t202 * 2.0 + t196 * t196 * t204 * t206 * 2.0) - t646_tmp * (t45 + t46)) + t191 * t196 * t203 * t205 * 4.0;
H[40] = t99;
H[41] = t85;
H[42] = t638;
H[43] = t323;
H[44] = t65;
H[45] = t635;
H[46] = t12;
H[47] = t135;
H[48] = t622;
H[49] = t607;
H[50] = t623;
H[51] = t99;
H[52] = ((t190 * t190 * t202 * 2.0 + t200 * t200 * t204 * t206 * 2.0) - t646_tmp * (t44 + t46)) + t190 * t200 * t203 * t205 * 4.0;
H[53] = t90;
H[54] = t316;
H[55] = t71;
H[56] = t13;
H[57] = t66;
H[58] = t86;
H[59] = t322;
H[60] = t625;
H[61] = t620;
H[62] = t605;
H[63] = t85;
H[64] = t90;
H[65] = ((t189 * t189 * t202 * 2.0 + t197 * t197 * t204 * t206 * 2.0) - t646_tmp * (t44 + t45)) - t189 * t197 * t203 * t205 * 4.0;
H[66] = t321;
H[67] = t11;
H[68] = t636;
H[69] = t324;
H[70] = t318;
H[71] = t637;
H[72] = t599;
H[73] = t617;
H[74] = t611;
H[75] = t638;
H[76] = t316;
H[77] = t321;
H[78] = ((t130 * t130 * t202 * 2.0 + t194 * t194 * t204 * t206 * 2.0) - t646_tmp * (t42 + t43)) + t130 * t194 * t203 * t205 * 4.0;
H[79] = t631;
H[80] = t627;
H[81] = t633;
H[82] = t646;
H[83] = t133;
H[84] = t619;
H[85] = t602;
H[86] = t618;
H[87] = t323;
H[88] = t71;
H[89] = t11;
H[90] = t631;
H[91] = ((t129 * t129 * t202 * 2.0 + t199 * t199 * t204 * t206 * 2.0) - t646_tmp * (t41 + t43)) + t129 * t199 * t203 * t205 * 4.0;
H[92] = t629;
H[93] = t645;
H[94] = t634;
H[95] = t325;
H[96] = t612;
H[97] = t616;
H[98] = t601;
H[99] = t65;
H[100] = t13;
H[101] = t636;
H[102] = t627;
H[103] = t629;
H[104] = ((t128 * t128 * t202 * 2.0 + t195 * t195 * t204 * t206 * 2.0) - t646_tmp * (t41 + t42)) - t128 * t195 * t203 * t205 * 4.0;
H[105] = t77;
H[106] = t131;
H[107] = t632;
H[108] = t603;
H[109] = t609;
H[110] = t614;
H[111] = t635;
H[112] = t66;
H[113] = t324;
H[114] = t633;
H[115] = t645;
H[116] = t77;
H[117] = ((t127 * t127 * t202 * 2.0 + t192 * t192 * t204 * t206 * 2.0) - t646_tmp * (t39 + t40)) + t127 * t192 * t203 * t205 * 4.0;
H[118] = t630;
H[119] = t626;
H[120] = t610;
H[121] = t604;
H[122] = t613;
H[123] = t12;
H[124] = t86;
H[125] = t318;
H[126] = t646;
H[127] = t634;
H[128] = t131;
H[129] = t630;
H[130] = ((t126 * t126 * t202 * 2.0 + t198 * t198 * t204 * t206 * 2.0) - t646_tmp * (t38 + t40)) + t126 * t198 * t203 * t205 * 4.0;
H[131] = t628;
H[132] = t615;
H[133] = t608;
H[134] = t600;
H[135] = t135;
H[136] = t322;
H[137] = t637;
H[138] = t133;
H[139] = t325;
H[140] = t632;
H[141] = t626;
H[142] = t628;
H[143] = ((t125 * t125 * t202 * 2.0 + t193 * t193 * t204 * t206 * 2.0) - t646_tmp * (t38 + t39)) - t125 * t193 * t203 * t205 * 4.0;
}
inline void H_PT(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
Eigen::Matrix<double, 12, 12>& H)
{
H_PT(v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
v3[0], v3[1], v3[2],
H.data());
}
inline void derivTest_PT(void)
{
Eigen::RowVector3d v[4];
v[0] << 0.0, 0.0, 0.0;
v[1] << 1.0, 0.1, 0.0;
v[2] << 0.0, 1.1, -0.1;
v[3] << 0.0, 0.1, -1.1;
double d0;
d_PT(v[0], v[1], v[2], v[3], d0);
double eps = 1.0e-6;
Eigen::Matrix<double, 12, 1> fd, s;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
double d;
d_PT(vv[0], vv[1], vv[2], vv[3], d);
fd[i * 3 + j] = (d - d0) / eps;
}
}
g_PT(v[0], v[1], v[2], v[3], s);
std::cout << s.transpose() << std::endl;
std::cout << fd.transpose() << std::endl;
std::cout << "relError = " << (s - fd).norm() / fd.norm() << std::endl;
Eigen::Matrix<double, 12, 12> Hfd, Hs;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
Eigen::Matrix<double, 12, 1> g;
g_PT(vv[0], vv[1], vv[2], vv[3], g);
Hfd.col(i * 3 + j) = (g - s) / eps;
}
}
H_PT(v[0], v[1], v[2], v[3], Hs);
std::cout << Hs.transpose() << std::endl;
std::cout << Hfd.transpose() << std::endl;
std::cout << "relError = " << (Hs - Hfd).norm() / Hfd.norm() << std::endl;
}
inline void d_EE(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double& d)
{
Eigen::RowVector3d b = (v1 - v0).cross(v3 - v2);
double aTb = (v2 - v0).dot(b);
d = aTb * aTb / b.squaredNorm();
}
inline void g_EE(double v01, double v02, double v03, double v11, double v12, double v13,
double v21, double v22, double v23, double v31, double v32, double v33,
double g[12])
{
double t11;
double t12;
double t13;
double t14;
double t15;
double t16;
double t17;
double t18;
double t19;
double t32;
double t33;
double t34;
double t35;
double t36;
double t37;
double t44;
double t45;
double t46;
double t75;
double t77;
double t76;
double t78;
double t79;
double t80;
double t81;
double t83;
/* G_EE */
/* G = G_EE(V01,V02,V03,V11,V12,V13,V21,V22,V23,V31,V32,V33) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 14-Jun-2019 13:58:25 */
t11 = -v11 + v01;
t12 = -v12 + v02;
t13 = -v13 + v03;
t14 = -v21 + v01;
t15 = -v22 + v02;
t16 = -v23 + v03;
t17 = -v31 + v21;
t18 = -v32 + v22;
t19 = -v33 + v23;
t32 = t14 * t18;
t33 = t15 * t17;
t34 = t14 * t19;
t35 = t16 * t17;
t36 = t15 * t19;
t37 = t16 * t18;
t44 = t11 * t18 + -(t12 * t17);
t45 = t11 * t19 + -(t13 * t17);
t46 = t12 * t19 + -(t13 * t18);
t75 = 1.0 / ((t44 * t44 + t45 * t45) + t46 * t46);
t77 = (t16 * t44 + t14 * t46) + -(t15 * t45);
t76 = t75 * t75;
t78 = t77 * t77;
t79 = (t12 * t44 * 2.0 + t13 * t45 * 2.0) * t76 * t78;
t80 = (t11 * t45 * 2.0 + t12 * t46 * 2.0) * t76 * t78;
t81 = (t18 * t44 * 2.0 + t19 * t45 * 2.0) * t76 * t78;
t18 = (t17 * t45 * 2.0 + t18 * t46 * 2.0) * t76 * t78;
t83 = (t11 * t44 * 2.0 + -(t13 * t46 * 2.0)) * t76 * t78;
t19 = (t17 * t44 * 2.0 + -(t19 * t46 * 2.0)) * t76 * t78;
t76 = t75 * t77;
g[0] = -t81 + t76 * ((-t36 + t37) + t46) * 2.0;
g[1] = t19 - t76 * ((-t34 + t35) + t45) * 2.0;
g[2] = t18 + t76 * ((-t32 + t33) + t44) * 2.0;
g[3] = t81 + t76 * (t36 - t37) * 2.0;
g[4] = -t19 - t76 * (t34 - t35) * 2.0;
g[5] = -t18 + t76 * (t32 - t33) * 2.0;
t17 = t12 * t16 + -(t13 * t15);
g[6] = t79 - t76 * (t17 + t46) * 2.0;
t18 = t11 * t16 + -(t13 * t14);
g[7] = -t83 + t76 * (t18 + t45) * 2.0;
t19 = t11 * t15 + -(t12 * t14);
g[8] = -t80 - t76 * (t19 + t44) * 2.0;
g[9] = -t79 + t76 * t17 * 2.0;
g[10] = t83 - t76 * t18 * 2.0;
g[11] = t80 + t76 * t19 * 2.0;
}
inline void g_EE(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
Eigen::Matrix<double, 12, 1>& g)
{
g_EE(v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
v3[0], v3[1], v3[2],
g.data());
}
inline void H_EE(double v01, double v02, double v03, double v11, double v12, double v13,
double v21, double v22, double v23, double v31, double v32, double v33,
double H[144])
{
double t11;
double t12;
double t13;
double t14;
double t15;
double t16;
double t26;
double t27;
double t28;
double t47;
double t48;
double t49;
double t50;
double t51;
double t52;
double t53;
double t54;
double t55;
double t56;
double t57;
double t58;
double t59;
double t65;
double t73;
double t35;
double t36;
double t37;
double t38;
double t39;
double t40;
double t98;
double t99;
double t100;
double t101;
double t103;
double t105;
double t107;
double t108;
double t109;
double t137;
double t138;
double t139;
double t140;
double t141;
double t142;
double t143;
double t144;
double t145;
double t146;
double t147;
double t148;
double t156;
double t159;
double t157;
double t262;
double t263;
double t264;
double t265;
double t266;
double t267;
double t268;
double t269;
double t270;
double t271;
double t272;
double t273;
double t274;
double t275;
double t276;
double t277;
double t278;
double t279;
double t298;
double t299;
double t300;
double t301;
double t302;
double t303;
double t310;
double t311;
double t312;
double t313;
double t314;
double t315;
double t322;
double t323;
double t325;
double t326;
double t327;
double t328;
double t329;
double t330;
double t335;
double t337;
double t339;
double t340;
double t341;
double t342;
double t343;
double t345;
double t348;
double t353;
double t356;
double t358;
double t359;
double t360;
double t362;
double t367;
double t368;
double t369;
double t371;
double t374;
double t377;
double t382;
double t386;
double t387;
double t398;
double t399;
double t403;
double t408;
double t423;
double t424;
double t427;
double t428;
double t431;
double t432;
double t433;
double t434;
double t437;
double t438;
double t441;
double t442;
double t446;
double t451;
double t455;
double t456;
double t467;
double t468;
double t472;
double t477;
double t491;
double t492;
double t495;
double t497;
double t499;
double t500;
double t503;
double t504;
double t506;
double t508;
double t550;
double t568;
double t519_tmp;
double b_t519_tmp;
double t519;
double t520_tmp;
double b_t520_tmp;
double t520;
double t521_tmp;
double b_t521_tmp;
double t521;
double t522_tmp;
double b_t522_tmp;
double t522;
double t523_tmp;
double b_t523_tmp;
double t523;
double t524_tmp;
double b_t524_tmp;
double t524;
double t525;
double t526;
double t527;
double t528;
double t529;
double t530;
double t531;
double t532;
double t533;
double t534;
double t535;
double t536;
double t537;
double t538;
double t539;
double t540;
double t542;
double t543;
double t544;
/* H_EE */
/* H = H_EE(V01,V02,V03,V11,V12,V13,V21,V22,V23,V31,V32,V33) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 14-Jun-2019 13:58:38 */
t11 = -v11 + v01;
t12 = -v12 + v02;
t13 = -v13 + v03;
t14 = -v21 + v01;
t15 = -v22 + v02;
t16 = -v23 + v03;
t26 = -v31 + v21;
t27 = -v32 + v22;
t28 = -v33 + v23;
t47 = t11 * t27;
t48 = t12 * t26;
t49 = t11 * t28;
t50 = t13 * t26;
t51 = t12 * t28;
t52 = t13 * t27;
t53 = t14 * t27;
t54 = t15 * t26;
t55 = t14 * t28;
t56 = t16 * t26;
t57 = t15 * t28;
t58 = t16 * t27;
t59 = t11 * t26 * 2.0;
t65 = t12 * t27 * 2.0;
t73 = t13 * t28 * 2.0;
t35 = t11 * t11 * 2.0;
t36 = t12 * t12 * 2.0;
t37 = t13 * t13 * 2.0;
t38 = t26 * t26 * 2.0;
t39 = t27 * t27 * 2.0;
t40 = t28 * t28 * 2.0;
t98 = t11 * t15 + -(t12 * t14);
t99 = t11 * t16 + -(t13 * t14);
t100 = t12 * t16 + -(t13 * t15);
t101 = t47 + -t48;
t103 = t49 + -t50;
t105 = t51 + -t52;
t107 = t53 + -t54;
t108 = t55 + -t56;
t109 = t57 + -t58;
t137 = t98 + t101;
t138 = t99 + t103;
t139 = t100 + t105;
t140 = (t54 + -t53) + t101;
t141 = (t56 + -t55) + t103;
t142 = (t58 + -t57) + t105;
t143 = t12 * t101 * 2.0 + t13 * t103 * 2.0;
t144 = t11 * t103 * 2.0 + t12 * t105 * 2.0;
t145 = t27 * t101 * 2.0 + t28 * t103 * 2.0;
t146 = t26 * t103 * 2.0 + t27 * t105 * 2.0;
t147 = t11 * t101 * 2.0 + -(t13 * t105 * 2.0);
t148 = t26 * t101 * 2.0 + -(t28 * t105 * 2.0);
t156 = 1.0 / ((t101 * t101 + t103 * t103) + t105 * t105);
t159 = (t16 * t101 + t14 * t105) + -(t15 * t103);
t157 = t156 * t156;
t57 = pow(t156, 3.0);
t58 = t159 * t159;
t262 = t11 * t156 * t159 * 2.0;
t263 = t12 * t156 * t159 * 2.0;
t264 = t13 * t156 * t159 * 2.0;
t265 = t14 * t156 * t159 * 2.0;
t266 = t15 * t156 * t159 * 2.0;
t267 = t16 * t156 * t159 * 2.0;
t268 = (-v31 + v01) * t156 * t159 * 2.0;
t269 = (-v21 + v11) * t156 * t159 * 2.0;
t270 = (-v32 + v02) * t156 * t159 * 2.0;
t271 = (-v22 + v12) * t156 * t159 * 2.0;
t272 = (-v33 + v03) * t156 * t159 * 2.0;
t273 = (-v23 + v13) * t156 * t159 * 2.0;
t274 = (-v31 + v11) * t156 * t159 * 2.0;
t275 = (-v32 + v12) * t156 * t159 * 2.0;
t276 = (-v33 + v13) * t156 * t159 * 2.0;
t277 = t26 * t156 * t159 * 2.0;
t278 = t27 * t156 * t159 * 2.0;
t279 = t28 * t156 * t159 * 2.0;
t298 = t11 * t12 * t157 * t58 * 2.0;
t299 = t11 * t13 * t157 * t58 * 2.0;
t300 = t12 * t13 * t157 * t58 * 2.0;
t301 = t26 * t27 * t157 * t58 * 2.0;
t302 = t26 * t28 * t157 * t58 * 2.0;
t303 = t27 * t28 * t157 * t58 * 2.0;
t310 = (t35 + t36) * t157 * t58;
t311 = (t35 + t37) * t157 * t58;
t312 = (t36 + t37) * t157 * t58;
t313 = (t38 + t39) * t157 * t58;
t314 = (t38 + t40) * t157 * t58;
t315 = (t39 + t40) * t157 * t58;
t322 = (t59 + t65) * t157 * t58;
t323 = (t59 + t73) * t157 * t58;
t59 = (t65 + t73) * t157 * t58;
t325 = (t47 * 2.0 + -(t48 * 4.0)) * t157 * t58;
t53 = -t157 * t58;
t56 = t48 * 2.0 - t47 * 4.0;
t326 = t53 * t56;
t327 = (t49 * 2.0 + -(t50 * 4.0)) * t157 * t58;
t55 = t50 * 2.0 - t49 * 4.0;
t328 = t53 * t55;
t329 = (t51 * 2.0 + -(t52 * 4.0)) * t157 * t58;
t54 = t52 * 2.0 - t51 * 4.0;
t330 = t53 * t54;
t53 = t157 * t58;
t335 = t53 * t56;
t337 = t53 * t55;
t339 = t53 * t54;
t340 = t143 * t143 * t57 * t58 * 2.0;
t341 = t144 * t144 * t57 * t58 * 2.0;
t342 = t145 * t145 * t57 * t58 * 2.0;
t343 = t146 * t146 * t57 * t58 * 2.0;
t345 = t147 * t147 * t57 * t58 * 2.0;
t348 = t148 * t148 * t57 * t58 * 2.0;
t36 = t98 * t143 * t157 * t159 * 2.0;
t353 = t99 * t143 * t157 * t159 * 2.0;
t356 = t99 * t144 * t157 * t159 * 2.0;
t65 = t100 * t144 * t157 * t159 * 2.0;
t358 = t107 * t143 * t157 * t159 * 2.0;
t359 = t98 * t145 * t157 * t159 * 2.0;
t360 = t108 * t143 * t157 * t159 * 2.0;
t54 = t107 * t144 * t157 * t159 * 2.0;
t362 = t99 * t145 * t157 * t159 * 2.0;
t53 = t98 * t146 * t157 * t159 * 2.0;
t56 = t109 * t143 * t157 * t159 * 2.0;
t27 = t108 * t144 * t157 * t159 * 2.0;
t55 = t100 * t145 * t157 * t159 * 2.0;
t367 = t99 * t146 * t157 * t159 * 2.0;
t368 = t109 * t144 * t157 * t159 * 2.0;
t369 = t100 * t146 * t157 * t159 * 2.0;
t38 = t107 * t145 * t157 * t159 * 2.0;
t371 = t108 * t145 * t157 * t159 * 2.0;
t374 = t108 * t146 * t157 * t159 * 2.0;
t28 = t109 * t146 * t157 * t159 * 2.0;
t377 = t98 * t147 * t157 * t159 * 2.0;
t382 = t100 * t147 * t157 * t159 * 2.0;
t386 = t107 * t147 * t157 * t159 * 2.0;
t387 = t98 * t148 * t157 * t159 * 2.0;
t103 = t108 * t147 * t157 * t159 * 2.0;
t101 = t99 * t148 * t157 * t159 * 2.0;
t398 = t109 * t147 * t157 * t159 * 2.0;
t399 = t100 * t148 * t157 * t159 * 2.0;
t403 = t107 * t148 * t157 * t159 * 2.0;
t408 = t109 * t148 * t157 * t159 * 2.0;
t73 = t137 * t143 * t157 * t159 * 2.0;
t423 = t138 * t143 * t157 * t159 * 2.0;
t424 = t138 * t144 * t157 * t159 * 2.0;
t37 = t139 * t144 * t157 * t159 * 2.0;
t427 = t140 * t143 * t157 * t159 * 2.0;
t428 = t137 * t145 * t157 * t159 * 2.0;
t16 = t140 * t144 * t157 * t159 * 2.0;
t11 = t137 * t146 * t157 * t159 * 2.0;
t431 = t141 * t143 * t157 * t159 * 2.0;
t432 = t138 * t145 * t157 * t159 * 2.0;
t433 = t141 * t144 * t157 * t159 * 2.0;
t434 = t138 * t146 * t157 * t159 * 2.0;
t105 = t142 * t143 * t157 * t159 * 2.0;
t14 = t139 * t145 * t157 * t159 * 2.0;
t437 = t142 * t144 * t157 * t159 * 2.0;
t438 = t139 * t146 * t157 * t159 * 2.0;
t35 = t140 * t145 * t157 * t159 * 2.0;
t441 = t141 * t145 * t157 * t159 * 2.0;
t442 = t141 * t146 * t157 * t159 * 2.0;
t39 = t142 * t146 * t157 * t159 * 2.0;
t446 = t137 * t147 * t157 * t159 * 2.0;
t451 = t139 * t147 * t157 * t159 * 2.0;
t455 = t140 * t147 * t157 * t159 * 2.0;
t456 = t137 * t148 * t157 * t159 * 2.0;
t13 = t141 * t147 * t157 * t159 * 2.0;
t26 = t138 * t148 * t157 * t159 * 2.0;
t467 = t142 * t147 * t157 * t159 * 2.0;
t468 = t139 * t148 * t157 * t159 * 2.0;
t472 = t140 * t148 * t157 * t159 * 2.0;
t477 = t142 * t148 * t157 * t159 * 2.0;
t47 = t143 * t144 * t57 * t58 * 2.0;
t15 = t143 * t145 * t57 * t58 * 2.0;
t491 = t143 * t146 * t57 * t58 * 2.0;
t492 = t144 * t145 * t57 * t58 * 2.0;
t12 = t144 * t146 * t57 * t58 * 2.0;
t40 = t145 * t146 * t57 * t58 * 2.0;
t495 = t143 * t147 * t57 * t58 * 2.0;
t497 = t144 * t147 * t57 * t58 * 2.0;
t499 = t143 * t148 * t57 * t58 * 2.0;
t500 = t145 * t147 * t57 * t58 * 2.0;
t503 = t146 * t147 * t57 * t58 * 2.0;
t504 = t144 * t148 * t57 * t58 * 2.0;
t506 = t145 * t148 * t57 * t58 * 2.0;
t508 = t146 * t148 * t57 * t58 * 2.0;
t57 = t147 * t148 * t57 * t58 * 2.0;
t550 = ((((t98 * t109 * t156 * 2.0 + -t266) + t337) + t359) + t368) + t492;
t568 = ((((t108 * t137 * t156 * 2.0 + -t268) + t330) + t27) + t456) + t504;
t519_tmp = t139 * t143 * t157 * t159;
b_t519_tmp = t100 * t143 * t157 * t159;
t519 = (((-(t100 * t139 * t156 * 2.0) + t312) + -t340) + b_t519_tmp * 2.0) + t519_tmp * 2.0;
t520_tmp = t140 * t146 * t157 * t159;
b_t520_tmp = t107 * t146 * t157 * t159;
t520 = (((t107 * t140 * t156 * 2.0 + t313) + -t343) + b_t520_tmp * 2.0) + -(t520_tmp * 2.0);
t521_tmp = t142 * t145 * t157 * t159;
b_t521_tmp = t109 * t145 * t157 * t159;
t521 = (((t109 * t142 * t156 * 2.0 + t315) + -t342) + -(b_t521_tmp * 2.0)) + t521_tmp * 2.0;
t522_tmp = t137 * t144 * t157 * t159;
b_t522_tmp = t98 * t144 * t157 * t159;
t522 = (((-(t98 * t137 * t156 * 2.0) + t310) + -t341) + -(b_t522_tmp * 2.0)) + -(t522_tmp * 2.0);
t523_tmp = t138 * t147 * t157 * t159;
b_t523_tmp = t99 * t147 * t157 * t159;
t523 = (((-(t99 * t138 * t156 * 2.0) + t311) + -t345) + b_t523_tmp * 2.0) + t523_tmp * 2.0;
t524_tmp = t141 * t148 * t157 * t159;
b_t524_tmp = t108 * t148 * t157 * t159;
t524 = (((t108 * t141 * t156 * 2.0 + t314) + -t348) + -(b_t524_tmp * 2.0)) + t524_tmp * 2.0;
t525 = (((t98 * t100 * t156 * 2.0 + t299) + t65) + -t36) + -t47;
t526 = (((t107 * t109 * t156 * 2.0 + t302) + t38) + -t28) + -t40;
t527 = (((-(t98 * t99 * t156 * 2.0) + t300) + t377) + -t356) + t497;
t528 = (((-(t99 * t100 * t156 * 2.0) + t298) + t353) + t382) + -t495;
t529 = (((-(t107 * t108 * t156 * 2.0) + t303) + t374) + -t403) + t508;
t530 = (((-(t108 * t109 * t156 * 2.0) + t301) + -t371) + -t408) + -t506;
t531 = (((t98 * t107 * t156 * 2.0 + t322) + t54) + -t53) + -t12;
t532 = (((t100 * t109 * t156 * 2.0 + t59) + t55) + -t56) + -t15;
t533 = (((t99 * t108 * t156 * 2.0 + t323) + t101) + -t103) + -t57;
t534 = (((t98 * t140 * t156 * 2.0 + -t322) + t53) + t16) + t12;
t535 = (((-(t107 * t137 * t156 * 2.0) + -t322) + -t54) + t11) + t12;
t536 = (((t100 * t142 * t156 * 2.0 + -t59) + -t55) + -t105) + t15;
t537 = (((-(t109 * t139 * t156 * 2.0) + -t59) + t56) + -t14) + t15;
t538 = (((t99 * t141 * t156 * 2.0 + -t323) + -t101) + -t13) + t57;
t539 = (((-(t108 * t138 * t156 * 2.0) + -t323) + t103) + -t26) + t57;
t540 = (((t137 * t139 * t156 * 2.0 + t299) + t37) + -t73) + -t47;
t148 = (((t140 * t142 * t156 * 2.0 + t302) + t39) + -t35) + -t40;
t542 = (((-(t137 * t138 * t156 * 2.0) + t300) + t446) + -t424) + t497;
t543 = (((-(t138 * t139 * t156 * 2.0) + t298) + t423) + t451) + -t495;
t544 = (((-(t140 * t141 * t156 * 2.0) + t303) + t472) + -t442) + t508;
t53 = (((-(t141 * t142 * t156 * 2.0) + t301) + t441) + t477) + -t506;
t157 = (((-(t139 * t142 * t156 * 2.0) + t59) + t105) + t14) + -t15;
t159 = (((-(t137 * t140 * t156 * 2.0) + t322) + -t16) + -t11) + -t12;
t147 = (((-(t138 * t141 * t156 * 2.0) + t323) + t13) + t26) + -t57;
t146 = ((((t100 * t107 * t156 * 2.0 + t266) + t327) + -t358) + -t369) + t491;
t145 = ((((-(t99 * t107 * t156 * 2.0) + -t265) + t329) + t367) + t386) + -t503;
t144 = ((((-(t100 * t108 * t156 * 2.0) + -t267) + t325) + t360) + -t399) + t499;
t143 = ((((-(t99 * t109 * t156 * 2.0) + t267) + t335) + -t362) + t398) + t500;
t52 = ((((-(t98 * t108 * t156 * 2.0) + t265) + t339) + -t27) + -t387) + -t504;
t51 = ((((t109 * t140 * t156 * 2.0 + -t278) + -t302) + t28) + t35) + t40;
t50 = ((((-(t98 * t139 * t156 * 2.0) + t263) + -t299) + t36) + -t37) + t47;
t49 = ((((t107 * t142 * t156 * 2.0 + t278) + -t302) + -t38) + -t39) + t40;
t48 = ((((-(t100 * t137 * t156 * 2.0) + -t263) + -t299) + -t65) + t73) + t47;
t47 = ((((t99 * t137 * t156 * 2.0 + t262) + -t300) + t356) + -t446) + -t497;
t73 = ((((t100 * t138 * t156 * 2.0 + t264) + -t298) + -t382) + -t423) + t495;
t65 = ((((-(t109 * t141 * t156 * 2.0) + t279) + -t301) + t408) + -t441) + t506;
t59 = ((((t98 * t138 * t156 * 2.0 + -t262) + -t300) + -t377) + t424) + -t497;
t40 = ((((t99 * t139 * t156 * 2.0 + -t264) + -t298) + -t353) + -t451) + t495;
t39 = ((((-(t107 * t141 * t156 * 2.0) + -t277) + -t303) + t403) + t442) + -t508;
t38 = ((((-(t108 * t142 * t156 * 2.0) + -t279) + -t301) + t371) + -t477) + t506;
t37 = ((((-(t108 * t140 * t156 * 2.0) + t277) + -t303) + -t374) + -t472) + -t508;
t36 = ((((t98 * t142 * t156 * 2.0 + t271) + t328) + -t359) + t437) + -t492;
t35 = ((((-(t109 * t137 * t156 * 2.0) + t270) + t328) + -t368) + -t428) + -t492;
t28 = ((((t100 * t140 * t156 * 2.0 + -t271) + -t327) + t369) + -t427) + -t491;
t27 = ((((-(t98 * t141 * t156 * 2.0) + -t269) + t330) + t387) + -t433) + t504;
t26 = ((((t109 * t138 * t156 * 2.0 + -t272) + t326) + -t398) + t432) + -t500;
t13 = ((((-(t107 * t139 * t156 * 2.0) + -t270) + -t327) + t358) + t438) + -t491;
t12 = ((((-(t99 * t142 * t156 * 2.0) + -t273) + t326) + t362) + t467) + -t500;
t11 = ((((-(t99 * t140 * t156 * 2.0) + t269) + -t329) + -t367) + t455) + t503;
t16 = ((((t107 * t138 * t156 * 2.0 + t268) + -t329) + -t386) + -t434) + t503;
t15 = ((((-(t100 * t141 * t156 * 2.0) + t273) + -t325) + t399) + t431) + -t499;
t14 = ((((t108 * t139 * t156 * 2.0 + t272) + -t325) + -t360) + t468) + -t499;
t105 = ((((-(t139 * t140 * t156 * 2.0) + t275) + t327) + t427) + -t438) + t491;
t103 = ((((t138 * t140 * t156 * 2.0 + -t274) + t329) + t434) + -t455) + -t503;
t101 = ((((-(t137 * t142 * t156 * 2.0) + -t275) + t337) + t428) + -t437) + t492;
t58 = ((((t139 * t141 * t156 * 2.0 + -t276) + t325) + -t431) + -t468) + t499;
t57 = ((((t137 * t141 * t156 * 2.0 + t274) + t339) + t433) + -t456) + -t504;
t56 = ((((t138 * t142 * t156 * 2.0 + t276) + t335) + -t432) + -t467) + t500;
t55 = -t315 + t342;
H[0] = (t55 + t142 * t142 * t156 * 2.0) - t521_tmp * 4.0;
H[1] = t53;
H[2] = t148;
H[3] = t521;
H[4] = t38;
H[5] = t49;
H[6] = t157;
H[7] = t56;
H[8] = t101;
H[9] = t536;
H[10] = t12;
H[11] = t36;
H[12] = t53;
t54 = -t314 + t348;
H[13] = (t54 + t141 * t141 * t156 * 2.0) - t524_tmp * 4.0;
H[14] = t544;
H[15] = t65;
H[16] = t524;
H[17] = t39;
H[18] = t58;
H[19] = t147;
H[20] = t57;
H[21] = t15;
H[22] = t538;
H[23] = t27;
H[24] = t148;
H[25] = t544;
t53 = -t313 + t343;
H[26] = (t53 + t140 * t140 * t156 * 2.0) + t520_tmp * 4.0;
H[27] = t51;
H[28] = t37;
H[29] = t520;
H[30] = t105;
H[31] = t103;
H[32] = t159;
H[33] = t28;
H[34] = t11;
H[35] = t534;
H[36] = t521;
H[37] = t65;
H[38] = t51;
H[39] = (t55 + t109 * t109 * t156 * 2.0) + b_t521_tmp * 4.0;
H[40] = t530;
H[41] = t526;
H[42] = t537;
H[43] = t26;
H[44] = t35;
H[45] = t532;
H[46] = t143;
H[47] = t550;
H[48] = t38;
H[49] = t524;
H[50] = t37;
H[51] = t530;
H[52] = (t54 + t108 * t108 * t156 * 2.0) + b_t524_tmp * 4.0;
H[53] = t529;
H[54] = t14;
H[55] = t539;
H[56] = t568;
H[57] = t144;
H[58] = t533;
H[59] = t52;
H[60] = t49;
H[61] = t39;
H[62] = t520;
H[63] = t526;
H[64] = t529;
H[65] = (t53 + t107 * t107 * t156 * 2.0) - b_t520_tmp * 4.0;
H[66] = t13;
H[67] = t16;
H[68] = t535;
H[69] = t146;
H[70] = t145;
H[71] = t531;
H[72] = t157;
H[73] = t58;
H[74] = t105;
H[75] = t537;
H[76] = t14;
H[77] = t13;
t55 = -t312 + t340;
H[78] = (t55 + t139 * t139 * t156 * 2.0) - t519_tmp * 4.0;
H[79] = t543;
H[80] = t540;
H[81] = t519;
H[82] = t40;
H[83] = t50;
H[84] = t56;
H[85] = t147;
H[86] = t103;
H[87] = t26;
H[88] = t539;
H[89] = t16;
H[90] = t543;
t54 = -t311 + t345;
H[91] = (t54 + t138 * t138 * t156 * 2.0) - t523_tmp * 4.0;
H[92] = t542;
H[93] = t73;
H[94] = t523;
H[95] = t59;
H[96] = t101;
H[97] = t57;
H[98] = t159;
H[99] = t35;
H[100] = t568;
H[101] = t535;
H[102] = t540;
H[103] = t542;
t53 = -t310 + t341;
H[104] = (t53 + t137 * t137 * t156 * 2.0) + t522_tmp * 4.0;
H[105] = t48;
H[106] = t47;
H[107] = t522;
H[108] = t536;
H[109] = t15;
H[110] = t28;
H[111] = t532;
H[112] = t144;
H[113] = t146;
H[114] = t519;
H[115] = t73;
H[116] = t48;
H[117] = (t55 + t100 * t100 * t156 * 2.0) - b_t519_tmp * 4.0;
H[118] = t528;
H[119] = t525;
H[120] = t12;
H[121] = t538;
H[122] = t11;
H[123] = t143;
H[124] = t533;
H[125] = t145;
H[126] = t40;
H[127] = t523;
H[128] = t47;
H[129] = t528;
H[130] = (t54 + t99 * t99 * t156 * 2.0) - b_t523_tmp * 4.0;
H[131] = t527;
H[132] = t36;
H[133] = t27;
H[134] = t534;
H[135] = t550;
H[136] = t52;
H[137] = t531;
H[138] = t50;
H[139] = t59;
H[140] = t522;
H[141] = t525;
H[142] = t527;
H[143] = (t53 + t98 * t98 * t156 * 2.0) + b_t522_tmp * 4.0;
}
inline void H_EE(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
Eigen::Matrix<double, 12, 12>& H)
{
H_EE(v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
v3[0], v3[1], v3[2],
H.data());
}
inline void derivTest_EE(void)
{
Eigen::RowVector3d v[4];
v[0] << 0.0, 0.0, 0.0;
v[1] << 1.0, 0.1, 0.0;
v[2] << 0.0, 1.1, -0.1;
v[3] << 0.0, 0.1, -1.1;
double d0;
d_EE(v[0], v[1], v[2], v[3], d0);
double eps = 1.0e-6;
Eigen::Matrix<double, 12, 1> fd, s;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
double d;
d_EE(vv[0], vv[1], vv[2], vv[3], d);
fd[i * 3 + j] = (d - d0) / eps;
}
}
g_EE(v[0], v[1], v[2], v[3], s);
std::cout << s.transpose() << std::endl;
std::cout << fd.transpose() << std::endl;
std::cout << "relError = " << (s - fd).norm() / fd.norm() << std::endl;
Eigen::Matrix<double, 12, 12> Hfd, Hs;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
Eigen::Matrix<double, 12, 1> g;
g_EE(vv[0], vv[1], vv[2], vv[3], g);
Hfd.col(i * 3 + j) = (g - s) / eps;
}
}
H_EE(v[0], v[1], v[2], v[3], Hs);
std::cout << Hs.transpose() << std::endl;
std::cout << Hfd.transpose() << std::endl;
std::cout << "relError = " << (Hs - Hfd).norm() / Hfd.norm() << std::endl;
}
// http://geomalgorithms.com/a07-_distance.html
inline int dType_EE(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3)
{
Eigen::RowVector3d u = v1 - v0;
Eigen::RowVector3d v = v3 - v2;
Eigen::RowVector3d w = v0 - v2;
double a = u.squaredNorm(); // always >= 0
double b = u.dot(v);
double c = v.squaredNorm(); // always >= 0
double d = u.dot(w);
double e = v.dot(w);
double D = a * c - b * b; // always >= 0
double tD = D; // tc = tN / tD, default tD = D >= 0
double sN, tN;
int defaultCase = 8;
// compute the line parameters of the two closest points
// const double SMALL_NUM = 0.0;
// if (D <= SMALL_NUM) { // the lines are almost parallel
// tN = e;
// tD = c;
// defaultCase = 2;
// }
// else { // get the closest points on the infinite lines
sN = (b * e - c * d);
if (sN <= 0.0) { // sc < 0 => the s=0 edge is visible
tN = e;
tD = c;
defaultCase = 2;
}
else if (sN >= D) { // sc > 1 => the s=1 edge is visible
tN = e + b;
tD = c;
defaultCase = 5;
}
else {
tN = (a * e - b * d);
if (tN > 0.0 && tN < tD && (u.cross(v).dot(w) == 0.0 || u.cross(v).squaredNorm() < 1.0e-20 * a * c)) {
// if (tN > 0.0 && tN < tD && (u.cross(v).dot(w) == 0.0 || u.cross(v).squaredNorm() == 0.0)) {
// std::cout << u.cross(v).squaredNorm() / (a * c) << ": " << sN << " " << D << ", " << tN << " " << tD << std::endl;
// avoid coplanar or nearly parallel EE
if (sN < D / 2) {
tN = e;
tD = c;
defaultCase = 2;
}
else {
tN = e + b;
tD = c;
defaultCase = 5;
}
}
// else defaultCase stays as 8
}
// }
if (tN <= 0.0) { // tc < 0 => the t=0 edge is visible
// recompute sc for this edge
if (-d <= 0.0) {
return 0;
}
else if (-d >= a) {
return 3;
}
else {
return 6;
}
}
else if (tN >= tD) { // tc > 1 => the t=1 edge is visible
// recompute sc for this edge
if ((-d + b) <= 0.0) {
return 1;
}
else if ((-d + b) >= a) {
return 4;
}
else {
return 7;
}
}
return defaultCase;
}
inline int dType_PT(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3)
{
Eigen::Matrix<double, 2, 3> basis;
basis.row(0) = v2 - v1;
basis.row(1) = v3 - v1;
const Eigen::RowVector3d nVec = basis.row(0).cross(basis.row(1));
Eigen::Matrix<double, 2, 3> param;
basis.row(1) = basis.row(0).cross(nVec);
param.col(0) = (basis * basis.transpose()).ldlt().solve(basis * (v0 - v1).transpose());
if (param(0, 0) > 0.0 && param(0, 0) < 1.0 && param(1, 0) >= 0.0) {
return 3; // PE v1v2
}
else {
basis.row(0) = v3 - v2;
basis.row(1) = basis.row(0).cross(nVec);
param.col(1) = (basis * basis.transpose()).ldlt().solve(basis * (v0 - v2).transpose());
if (param(0, 1) > 0.0 && param(0, 1) < 1.0 && param(1, 1) >= 0.0) {
return 4; // PE v2v3
}
else {
basis.row(0) = v1 - v3;
basis.row(1) = basis.row(0).cross(nVec);
param.col(2) = (basis * basis.transpose()).ldlt().solve(basis * (v0 - v3).transpose());
if (param(0, 2) > 0.0 && param(0, 2) < 1.0 && param(1, 2) >= 0.0) {
return 5; // PE v3v1
}
else {
if (param(0, 0) <= 0.0 && param(0, 2) >= 1.0) {
return 0; // PP v1
}
else if (param(0, 1) <= 0.0 && param(0, 0) >= 1.0) {
return 1; // PP v2
}
else if (param(0, 2) <= 0.0 && param(0, 1) >= 1.0) {
return 2; // PP v3
}
else {
return 6; // PT
}
}
}
}
}
inline void checkDType(void)
{
std::vector<std::vector<Eigen::RowVector3d>> testData;
testData.resize(testData.size() + 1);
testData.back().resize(4);
testData.back()[0] << 0.0, 0.0, 1.0;
testData.back()[1] << 0.0, 0.0, 0.0;
testData.back()[2] << 1.0, 0.0, 0.0;
testData.back()[3] << 0.0, 1.0, 0.0;
testData.resize(testData.size() + 1);
testData.back().resize(4);
testData.back()[0] << 0.0, 0.0, 0.0;
testData.back()[1] << 0.0, 0.0, 0.0;
testData.back()[2] << 1.0, 0.0, 0.0;
testData.back()[3] << 0.0, 1.0, 0.0;
srand((unsigned int)time(0));
for (int i = 0; i < 6; ++i) {
testData.resize(testData.size() + 1);
testData.back().resize(4);
testData.back()[0].setRandom();
testData.back()[1].setRandom();
testData.back()[2].setRandom();
testData.back()[3].setRandom();
}
int i = 0;
for (const auto& testI : testData) {
std::cout << ">>>>>> Test " << i << " >>>>>>" << std::endl;
std::cout << testI[0] << std::endl;
std::cout << testI[1] << std::endl;
std::cout << testI[2] << std::endl;
std::cout << testI[3] << std::endl;
std::cout << "PT: " << dType_PT(testI[0], testI[1], testI[2], testI[3]) << std::endl;
std::cout << "EE: " << dType_EE(testI[0], testI[1], testI[2], testI[3]) << std::endl;
++i;
}
}
// http://geomalgorithms.com/a02-_lines.html
inline void computePointEdgeD(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
double& d)
{
Eigen::RowVector3d v = v2 - v1;
Eigen::RowVector3d w = v0 - v1;
double c1 = w.dot(v);
if (c1 <= 0.0) {
d_PP(v0, v1, d);
}
else {
double c2 = v.squaredNorm();
if (c2 <= c1) {
d_PP(v0, v2, d);
}
else {
double b = c1 / c2;
d_PP(v0, v1 + b * v, d);
}
}
}
inline void computePointTriD(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double& d)
{
switch (dType_PT(v0, v1, v2, v3)) {
case 0: {
d_PP(v0, v1, d);
break;
}
case 1: {
d_PP(v0, v2, d);
break;
}
case 2: {
d_PP(v0, v3, d);
break;
}
case 3: {
d_PE(v0, v1, v2, d);
break;
}
case 4: {
d_PE(v0, v2, v3, d);
break;
}
case 5: {
d_PE(v0, v3, v1, d);
break;
}
case 6: {
d_PT(v0, v1, v2, v3, d);
break;
}
default:
d = -1.0;
break;
}
}
inline void computeEdgeEdgeD(const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double& d)
{
switch (dType_EE(v0, v1, v2, v3)) {
case 0: {
d_PP(v0, v2, d);
break;
}
case 1: {
d_PP(v0, v3, d);
break;
}
case 2: {
d_PE(v0, v2, v3, d);
break;
}
case 3: {
d_PP(v1, v2, d);
break;
}
case 4: {
d_PP(v1, v3, d);
break;
}
case 5: {
d_PE(v1, v2, v3, d);
break;
}
case 6: {
d_PE(v2, v0, v1, d);
break;
}
case 7: {
d_PE(v3, v0, v1, d);
break;
}
case 8: {
d_EE(v0, v1, v2, v3, d);
break;
}
default:
d = -1.0;
break;
}
}
inline void checkEdgeEdgeD(void)
{
Eigen::RowVector3d v0, v1, v20, v3t, v2t;
v0 << 0.0, 0.0, 0.0;
v1 << 1.0, 0.0, 0.0;
v20 << -0.1, 1.0, 1.0;
v3t << 1.0, 0.0, -1.0;
v2t << 0.0, 0.0, -1.0;
Eigen::RowVector3d v30 = v20 + 0.01 * (v3t - v20);
double step = 0.01;
for (double t = 0.0; t < 1.0; t += step) {
double d;
computeEdgeEdgeD(v0, v1, v20, v30 + t * (v3t - v30), d);
std::cout << t << " " << d << std::endl;
}
for (double t = 1.0; t <= 2.0; t += step) {
double d;
computeEdgeEdgeD(v0, v1, v20 + (t - 1.0) * (v2t - v20), v3t, d);
std::cout << t << " " << d << std::endl;
}
}
// for fixing tiny step size issue
inline void computeEECrossSqNorm(
const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double& result)
{
result = (v1 - v0).cross(v3 - v2).squaredNorm();
}
inline void computeEECrossSqNormGradient(double v01, double v02, double v03, double v11,
double v12, double v13, double v21, double v22, double v23, double v31, double v32, double v33, double g[12])
{
double t8;
double t9;
double t10;
double t11;
double t12;
double t13;
double t23;
double t24;
double t25;
double t26;
double t27;
double t28;
double t29;
double t30;
double t31;
double t32;
double t33;
/* COMPUTEEECROSSSQNORMGRADIENT */
/* G = COMPUTEEECROSSSQNORMGRADIENT(V01,V02,V03,V11,V12,V13,V21,V22,V23,V31,V32,V33) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 01-Nov-2019 16:54:23 */
t8 = -v11 + v01;
t9 = -v12 + v02;
t10 = -v13 + v03;
t11 = -v31 + v21;
t12 = -v32 + v22;
t13 = -v33 + v23;
t23 = t8 * t12 + -(t9 * t11);
t24 = t8 * t13 + -(t10 * t11);
t25 = t9 * t13 + -(t10 * t12);
t26 = t8 * t23 * 2.0;
t27 = t9 * t23 * 2.0;
t28 = t8 * t24 * 2.0;
t29 = t10 * t24 * 2.0;
t30 = t9 * t25 * 2.0;
t31 = t10 * t25 * 2.0;
t32 = t11 * t23 * 2.0;
t33 = t12 * t23 * 2.0;
t23 = t11 * t24 * 2.0;
t10 = t13 * t24 * 2.0;
t9 = t12 * t25 * 2.0;
t8 = t13 * t25 * 2.0;
g[0] = t33 + t10;
g[1] = -t32 + t8;
g[2] = -t23 - t9;
g[3] = -t33 - t10;
g[4] = t32 - t8;
g[5] = t23 + t9;
g[6] = -t27 - t29;
g[7] = t26 - t31;
g[8] = t28 + t30;
g[9] = t27 + t29;
g[10] = -t26 + t31;
g[11] = -t28 - t30;
}
inline void computeEECrossSqNormGradient(
const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
Eigen::Matrix<double, 12, 1>& grad)
{
computeEECrossSqNormGradient(
v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
v3[0], v3[1], v3[2],
grad.data());
}
inline void computeEECrossSqNormHessian(double v01, double v02, double v03, double v11,
double v12, double v13, double v21, double v22, double v23, double v31, double v32, double v33, double H[144])
{
double t8;
double t9;
double t10;
double t11;
double t12;
double t13;
double t32;
double t33;
double t34;
double t35;
double t48;
double t36;
double t49;
double t37;
double t38;
double t39;
double t40;
double t41;
double t42;
double t43;
double t44;
double t45;
double t46;
double t47;
double t50;
double t51;
double t52;
double t20;
double t23;
double t24;
double t25;
double t86;
double t87;
double t88;
double t74;
double t75;
double t76;
double t77;
double t78;
double t79;
double t89;
double t90;
double t91;
double t92;
double t93;
double t94;
double t95;
/* COMPUTEEECROSSSQNORMHESSIAN */
/* H = COMPUTEEECROSSSQNORMHESSIAN(V01,V02,V03,V11,V12,V13,V21,V22,V23,V31,V32,V33) */
/* This function was generated by the Symbolic Math Toolbox version 8.3. */
/* 01-Nov-2019 16:54:23 */
t8 = -v11 + v01;
t9 = -v12 + v02;
t10 = -v13 + v03;
t11 = -v31 + v21;
t12 = -v32 + v22;
t13 = -v33 + v23;
t32 = t8 * t9 * 2.0;
t33 = t8 * t10 * 2.0;
t34 = t9 * t10 * 2.0;
t35 = t8 * t11 * 2.0;
t48 = t8 * t12;
t36 = t48 * 2.0;
t49 = t9 * t11;
t37 = t49 * 2.0;
t38 = t48 * 4.0;
t48 = t8 * t13;
t39 = t48 * 2.0;
t40 = t49 * 4.0;
t41 = t9 * t12 * 2.0;
t49 = t10 * t11;
t42 = t49 * 2.0;
t43 = t48 * 4.0;
t48 = t9 * t13;
t44 = t48 * 2.0;
t45 = t49 * 4.0;
t49 = t10 * t12;
t46 = t49 * 2.0;
t47 = t48 * 4.0;
t48 = t49 * 4.0;
t49 = t10 * t13 * 2.0;
t50 = t11 * t12 * 2.0;
t51 = t11 * t13 * 2.0;
t52 = t12 * t13 * 2.0;
t20 = t8 * t8 * 2.0;
t9 = t9 * t9 * 2.0;
t8 = t10 * t10 * 2.0;
t23 = t11 * t11 * 2.0;
t24 = t12 * t12 * 2.0;
t25 = t13 * t13 * 2.0;
t86 = t35 + t41;
t87 = t35 + t49;
t88 = t41 + t49;
t74 = t20 + t9;
t75 = t20 + t8;
t76 = t9 + t8;
t77 = t23 + t24;
t78 = t23 + t25;
t79 = t24 + t25;
t89 = t40 + -t36;
t90 = t36 + -t40;
t91 = t37 + -t38;
t92 = t38 + -t37;
t93 = t45 + -t39;
t94 = t39 + -t45;
t95 = t42 + -t43;
t37 = t43 + -t42;
t39 = t48 + -t44;
t45 = t44 + -t48;
t38 = t46 + -t47;
t40 = t47 + -t46;
t36 = -t35 + -t41;
t13 = -t35 + -t49;
t11 = -t41 + -t49;
t12 = -t20 + -t9;
t10 = -t20 + -t8;
t8 = -t9 + -t8;
t9 = -t23 + -t24;
t49 = -t23 + -t25;
t48 = -t24 + -t25;
H[0] = t79;
H[1] = -t50;
H[2] = -t51;
H[3] = t48;
H[4] = t50;
H[5] = t51;
H[6] = t11;
H[7] = t92;
H[8] = t37;
H[9] = t88;
H[10] = t91;
H[11] = t95;
H[12] = -t50;
H[13] = t78;
H[14] = -t52;
H[15] = t50;
H[16] = t49;
H[17] = t52;
H[18] = t89;
H[19] = t13;
H[20] = t40;
H[21] = t90;
H[22] = t87;
H[23] = t38;
H[24] = -t51;
H[25] = -t52;
H[26] = t77;
H[27] = t51;
H[28] = t52;
H[29] = t9;
H[30] = t93;
H[31] = t39;
H[32] = t36;
H[33] = t94;
H[34] = t45;
H[35] = t86;
H[36] = t48;
H[37] = t50;
H[38] = t51;
H[39] = t79;
H[40] = -t50;
H[41] = -t51;
H[42] = t88;
H[43] = t91;
H[44] = t95;
H[45] = t11;
H[46] = t92;
H[47] = t37;
H[48] = t50;
H[49] = t49;
H[50] = t52;
H[51] = -t50;
H[52] = t78;
H[53] = -t52;
H[54] = t90;
H[55] = t87;
H[56] = t38;
H[57] = t89;
H[58] = t13;
H[59] = t40;
H[60] = t51;
H[61] = t52;
H[62] = t9;
H[63] = -t51;
H[64] = -t52;
H[65] = t77;
H[66] = t94;
H[67] = t45;
H[68] = t86;
H[69] = t93;
H[70] = t39;
H[71] = t36;
H[72] = t11;
H[73] = t89;
H[74] = t93;
H[75] = t88;
H[76] = t90;
H[77] = t94;
H[78] = t76;
H[79] = -t32;
H[80] = -t33;
H[81] = t8;
H[82] = t32;
H[83] = t33;
H[84] = t92;
H[85] = t13;
H[86] = t39;
H[87] = t91;
H[88] = t87;
H[89] = t45;
H[90] = -t32;
H[91] = t75;
H[92] = -t34;
H[93] = t32;
H[94] = t10;
H[95] = t34;
H[96] = t37;
H[97] = t40;
H[98] = t36;
H[99] = t95;
H[100] = t38;
H[101] = t86;
H[102] = -t33;
H[103] = -t34;
H[104] = t74;
H[105] = t33;
H[106] = t34;
H[107] = t12;
H[108] = t88;
H[109] = t90;
H[110] = t94;
H[111] = t11;
H[112] = t89;
H[113] = t93;
H[114] = t8;
H[115] = t32;
H[116] = t33;
H[117] = t76;
H[118] = -t32;
H[119] = -t33;
H[120] = t91;
H[121] = t87;
H[122] = t45;
H[123] = t92;
H[124] = t13;
H[125] = t39;
H[126] = t32;
H[127] = t10;
H[128] = t34;
H[129] = -t32;
H[130] = t75;
H[131] = -t34;
H[132] = t95;
H[133] = t38;
H[134] = t86;
H[135] = t37;
H[136] = t40;
H[137] = t36;
H[138] = t33;
H[139] = t34;
H[140] = t12;
H[141] = -t33;
H[142] = -t34;
H[143] = t74;
}
inline void computeEECrossSqNormHessian(
const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
Eigen::Matrix<double, 12, 12>& Hessian)
{
computeEECrossSqNormHessian(
v0[0], v0[1], v0[2],
v1[0], v1[1], v1[2],
v2[0], v2[1], v2[2],
v3[0], v3[1], v3[2],
Hessian.data());
}
inline void derivTest_EECross(void)
{
Eigen::RowVector3d v[4];
v[0] << 0.0, 0.0, 0.0;
v[1] << 1.0, 0.1, 0.0;
v[2] << 0.0, 1.1, -0.1;
v[3] << 0.0, 0.1, -1.1;
double f0;
computeEECrossSqNorm(v[0], v[1], v[2], v[3], f0);
double eps = 1.0e-6;
Eigen::Matrix<double, 12, 1> fd, s;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
double f;
computeEECrossSqNorm(vv[0], vv[1], vv[2], vv[3], f);
fd[i * 3 + j] = (f - f0) / eps;
}
}
computeEECrossSqNormGradient(v[0], v[1], v[2], v[3], s);
std::cout << s.transpose() << std::endl;
std::cout << fd.transpose() << std::endl;
std::cout << "relError = " << (s - fd).norm() / fd.norm() << std::endl;
Eigen::Matrix<double, 12, 12> Hfd, Hs;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
Eigen::Matrix<double, 12, 1> g;
computeEECrossSqNormGradient(vv[0], vv[1], vv[2], vv[3], g);
Hfd.col(i * 3 + j) = (g - s) / eps;
}
}
computeEECrossSqNormHessian(v[0], v[1], v[2], v[3], Hs);
std::cout << Hs.transpose() << std::endl;
std::cout << Hfd.transpose() << std::endl;
std::cout << "relError = " << (Hs - Hfd).norm() / Hfd.norm() << std::endl;
}
inline void compute_q(double input, double eps_x, double& e)
{
double input_div_eps_x = input / eps_x;
e = (-input_div_eps_x + 2.0) * input_div_eps_x;
}
inline void compute_q_g(double input, double eps_x, double& g)
{
double one_div_eps_x = 1.0 / eps_x;
g = 2.0 * one_div_eps_x * (-one_div_eps_x * input + 1.0);
}
inline void compute_q_H(double input, double eps_x, double& H)
{
H = -2.0 / (eps_x * eps_x);
}
inline void compute_e(
const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double eps_x, double& e)
{
double EECrossSqNorm;
computeEECrossSqNorm(v0, v1, v2, v3, EECrossSqNorm);
if (EECrossSqNorm < eps_x) {
compute_q(EECrossSqNorm, eps_x, e);
}
else {
e = 1.0;
}
}
inline void compute_e_g(
const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double eps_x, Eigen::Matrix<double, 12, 1>& g)
{
double EECrossSqNorm;
computeEECrossSqNorm(v0, v1, v2, v3, EECrossSqNorm);
if (EECrossSqNorm < eps_x) {
double q_g;
compute_q_g(EECrossSqNorm, eps_x, q_g);
computeEECrossSqNormGradient(v0, v1, v2, v3, g);
g *= q_g;
}
else {
g.setZero();
}
}
inline void compute_e_H(
const Eigen::RowVector3d& v0,
const Eigen::RowVector3d& v1,
const Eigen::RowVector3d& v2,
const Eigen::RowVector3d& v3,
double eps_x, Eigen::Matrix<double, 12, 12>& H)
{
double EECrossSqNorm;
computeEECrossSqNorm(v0, v1, v2, v3, EECrossSqNorm);
if (EECrossSqNorm < eps_x) {
double q_g, q_H;
compute_q_g(EECrossSqNorm, eps_x, q_g);
compute_q_H(EECrossSqNorm, eps_x, q_H);
Eigen::Matrix<double, 12, 1> g;
computeEECrossSqNormGradient(v0, v1, v2, v3, g);
computeEECrossSqNormHessian(v0, v1, v2, v3, H);
H *= q_g;
H += (q_H * g) * g.transpose();
}
else {
H.setZero();
}
}
inline void derivTest_e(double eps_x = 10.0)
{
Eigen::RowVector3d v[4];
v[0] << 0.0, 0.0, 0.0;
v[1] << 1.0, 0.1, 0.0;
v[2] << 0.0, 1.1, -0.1;
v[3] << 0.0, 0.1, -1.1;
double f0;
compute_e(v[0], v[1], v[2], v[3], eps_x, f0);
double eps = 1.0e-6;
Eigen::Matrix<double, 12, 1> fd, s;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
double f;
compute_e(vv[0], vv[1], vv[2], vv[3], eps_x, f);
fd[i * 3 + j] = (f - f0) / eps;
}
}
compute_e_g(v[0], v[1], v[2], v[3], eps_x, s);
std::cout << s.transpose() << std::endl;
std::cout << fd.transpose() << std::endl;
std::cout << "relError = " << (s - fd).norm() / fd.norm() << std::endl;
Eigen::Matrix<double, 12, 12> Hfd, Hs;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
Eigen::RowVector3d vv[4];
vv[0] = v[0];
vv[1] = v[1];
vv[2] = v[2];
vv[3] = v[3];
vv[i][j] += eps;
Eigen::Matrix<double, 12, 1> g;
compute_e_g(vv[0], vv[1], vv[2], vv[3], eps_x, g);
Hfd.col(i * 3 + j) = (g - s) / eps;
}
}
compute_e_H(v[0], v[1], v[2], v[3], eps_x, Hs);
std::cout << Hs.transpose() << std::endl;
std::cout << Hfd.transpose() << std::endl;
std::cout << "relError = " << (Hs - Hfd).norm() / Hfd.norm() << std::endl;
}
template <int dim>
inline void compute_eps_x(const Mesh<dim>& mesh,
int eI0, int eI1, int eJ0, int eJ1, double& eps_x)
{
eps_x = 1.0e-3 * (mesh.V_rest.row(eI0) - mesh.V_rest.row(eI1)).squaredNorm() * (mesh.V_rest.row(eJ0) - mesh.V_rest.row(eJ1)).squaredNorm();
}
template <int dim>
inline void compute_eps_x(const Mesh<dim>& mesh, const Eigen::MatrixXd& V_MCO,
int eI0, int eI1, int eJ0, int eJ1, double& eps_x)
{
eps_x = 1.0e-3 * (mesh.V_rest.row(eI0) - mesh.V_rest.row(eI1)).squaredNorm() * (V_MCO.row(eJ0) - V_MCO.row(eJ1)).squaredNorm();
}
// broad phase collision detection
// inline bool broadPhaseCollision(const Eigen::Matrix<double, Eigen::Dynamic, 3>& obj0,
// const Eigen::Matrix<double, Eigen::Dynamic, 3>& obj1)
// {
// Eigen::Matrix<double, 1, 3> min0 = obj0.colwise().minCoeff();
// Eigen::Matrix<double, 1, 3> max0 = obj0.colwise().maxCoeff();
// Eigen::Matrix<double, 1, 3> min1 = obj1.colwise().minCoeff();
// Eigen::Matrix<double, 1, 3> max1 = obj1.colwise().maxCoeff();
// return ((min0 - max1).array() < 0).all() && ((min1 - max0).array() < 0).all();
// }
} // namespace IPC
#endif /* MeshCollisionUtils_hpp */
| [
"minchernl@gmail.com"
] | minchernl@gmail.com |
38263ad48ecd11cbba0e4f6881d2a8662513cd95 | c776476e9d06b3779d744641e758ac3a2c15cddc | /examples/litmus/c/run-scripts/tmp_5/MP+dmb.sy+addr-rfi-ctrl-ctrl-rfi.c.cbmc.cpp | 22b38834767c0fe00c442015b7e3544fdb6867a2 | [] | no_license | ashutosh0gupta/llvm_bmc | aaac7961c723ba6f7ffd77a39559e0e52432eade | 0287c4fb180244e6b3c599a9902507f05c8a7234 | refs/heads/master | 2023-08-02T17:14:06.178723 | 2023-07-31T10:46:53 | 2023-07-31T10:46:53 | 143,100,825 | 3 | 4 | null | 2023-05-25T05:50:55 | 2018-08-01T03:47:00 | C++ | UTF-8 | C++ | false | false | 52,423 | cpp | // Global variabls:
// 0:vars:4
// 4:atom_1_X0_1:1
// 5:atom_1_X5_1:1
// 6:atom_1_X10_1:1
// Local global variabls:
// 0:thr0:1
// 1:thr1:1
#define ADDRSIZE 7
#define LOCALADDRSIZE 2
#define NTHREAD 3
#define NCONTEXT 5
#define ASSUME(stmt) __CPROVER_assume(stmt)
#define ASSERT(stmt) __CPROVER_assert(stmt, "error")
#define max(a,b) (a>b?a:b)
char __get_rng();
char get_rng( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
char get_rng_th( char from, char to ) {
char ret = __get_rng();
ASSUME(ret >= from && ret <= to);
return ret;
}
int main(int argc, char **argv) {
// Declare arrays for intial value version in contexts
int local_mem[LOCALADDRSIZE];
// Dumping initializations
local_mem[0+0] = 0;
local_mem[1+0] = 0;
int cstart[NTHREAD];
int creturn[NTHREAD];
// declare arrays for contexts activity
int active[NCONTEXT];
int ctx_used[NCONTEXT];
// declare arrays for intial value version in contexts
int meminit_[ADDRSIZE*NCONTEXT];
#define meminit(x,k) meminit_[(x)*NCONTEXT+k]
int coinit_[ADDRSIZE*NCONTEXT];
#define coinit(x,k) coinit_[(x)*NCONTEXT+k]
int deltainit_[ADDRSIZE*NCONTEXT];
#define deltainit(x,k) deltainit_[(x)*NCONTEXT+k]
// declare arrays for running value version in contexts
int mem_[ADDRSIZE*NCONTEXT];
#define mem(x,k) mem_[(x)*NCONTEXT+k]
int co_[ADDRSIZE*NCONTEXT];
#define co(x,k) co_[(x)*NCONTEXT+k]
int delta_[ADDRSIZE*NCONTEXT];
#define delta(x,k) delta_[(x)*NCONTEXT+k]
// declare arrays for local buffer and observed writes
int buff_[NTHREAD*ADDRSIZE];
#define buff(x,k) buff_[(x)*ADDRSIZE+k]
int pw_[NTHREAD*ADDRSIZE];
#define pw(x,k) pw_[(x)*ADDRSIZE+k]
// declare arrays for context stamps
char cr_[NTHREAD*ADDRSIZE];
#define cr(x,k) cr_[(x)*ADDRSIZE+k]
char iw_[NTHREAD*ADDRSIZE];
#define iw(x,k) iw_[(x)*ADDRSIZE+k]
char cw_[NTHREAD*ADDRSIZE];
#define cw(x,k) cw_[(x)*ADDRSIZE+k]
char cx_[NTHREAD*ADDRSIZE];
#define cx(x,k) cx_[(x)*ADDRSIZE+k]
char is_[NTHREAD*ADDRSIZE];
#define is(x,k) is_[(x)*ADDRSIZE+k]
char cs_[NTHREAD*ADDRSIZE];
#define cs(x,k) cs_[(x)*ADDRSIZE+k]
char crmax_[NTHREAD*ADDRSIZE];
#define crmax(x,k) crmax_[(x)*ADDRSIZE+k]
char sforbid_[ADDRSIZE*NCONTEXT];
#define sforbid(x,k) sforbid_[(x)*NCONTEXT+k]
// declare arrays for synchronizations
int cl[NTHREAD];
int cdy[NTHREAD];
int cds[NTHREAD];
int cdl[NTHREAD];
int cisb[NTHREAD];
int caddr[NTHREAD];
int cctrl[NTHREAD];
__LOCALS__
buff(0,0) = 0;
pw(0,0) = 0;
cr(0,0) = 0;
iw(0,0) = 0;
cw(0,0) = 0;
cx(0,0) = 0;
is(0,0) = 0;
cs(0,0) = 0;
crmax(0,0) = 0;
buff(0,1) = 0;
pw(0,1) = 0;
cr(0,1) = 0;
iw(0,1) = 0;
cw(0,1) = 0;
cx(0,1) = 0;
is(0,1) = 0;
cs(0,1) = 0;
crmax(0,1) = 0;
buff(0,2) = 0;
pw(0,2) = 0;
cr(0,2) = 0;
iw(0,2) = 0;
cw(0,2) = 0;
cx(0,2) = 0;
is(0,2) = 0;
cs(0,2) = 0;
crmax(0,2) = 0;
buff(0,3) = 0;
pw(0,3) = 0;
cr(0,3) = 0;
iw(0,3) = 0;
cw(0,3) = 0;
cx(0,3) = 0;
is(0,3) = 0;
cs(0,3) = 0;
crmax(0,3) = 0;
buff(0,4) = 0;
pw(0,4) = 0;
cr(0,4) = 0;
iw(0,4) = 0;
cw(0,4) = 0;
cx(0,4) = 0;
is(0,4) = 0;
cs(0,4) = 0;
crmax(0,4) = 0;
buff(0,5) = 0;
pw(0,5) = 0;
cr(0,5) = 0;
iw(0,5) = 0;
cw(0,5) = 0;
cx(0,5) = 0;
is(0,5) = 0;
cs(0,5) = 0;
crmax(0,5) = 0;
buff(0,6) = 0;
pw(0,6) = 0;
cr(0,6) = 0;
iw(0,6) = 0;
cw(0,6) = 0;
cx(0,6) = 0;
is(0,6) = 0;
cs(0,6) = 0;
crmax(0,6) = 0;
cl[0] = 0;
cdy[0] = 0;
cds[0] = 0;
cdl[0] = 0;
cisb[0] = 0;
caddr[0] = 0;
cctrl[0] = 0;
cstart[0] = get_rng(0,NCONTEXT-1);
creturn[0] = get_rng(0,NCONTEXT-1);
buff(1,0) = 0;
pw(1,0) = 0;
cr(1,0) = 0;
iw(1,0) = 0;
cw(1,0) = 0;
cx(1,0) = 0;
is(1,0) = 0;
cs(1,0) = 0;
crmax(1,0) = 0;
buff(1,1) = 0;
pw(1,1) = 0;
cr(1,1) = 0;
iw(1,1) = 0;
cw(1,1) = 0;
cx(1,1) = 0;
is(1,1) = 0;
cs(1,1) = 0;
crmax(1,1) = 0;
buff(1,2) = 0;
pw(1,2) = 0;
cr(1,2) = 0;
iw(1,2) = 0;
cw(1,2) = 0;
cx(1,2) = 0;
is(1,2) = 0;
cs(1,2) = 0;
crmax(1,2) = 0;
buff(1,3) = 0;
pw(1,3) = 0;
cr(1,3) = 0;
iw(1,3) = 0;
cw(1,3) = 0;
cx(1,3) = 0;
is(1,3) = 0;
cs(1,3) = 0;
crmax(1,3) = 0;
buff(1,4) = 0;
pw(1,4) = 0;
cr(1,4) = 0;
iw(1,4) = 0;
cw(1,4) = 0;
cx(1,4) = 0;
is(1,4) = 0;
cs(1,4) = 0;
crmax(1,4) = 0;
buff(1,5) = 0;
pw(1,5) = 0;
cr(1,5) = 0;
iw(1,5) = 0;
cw(1,5) = 0;
cx(1,5) = 0;
is(1,5) = 0;
cs(1,5) = 0;
crmax(1,5) = 0;
buff(1,6) = 0;
pw(1,6) = 0;
cr(1,6) = 0;
iw(1,6) = 0;
cw(1,6) = 0;
cx(1,6) = 0;
is(1,6) = 0;
cs(1,6) = 0;
crmax(1,6) = 0;
cl[1] = 0;
cdy[1] = 0;
cds[1] = 0;
cdl[1] = 0;
cisb[1] = 0;
caddr[1] = 0;
cctrl[1] = 0;
cstart[1] = get_rng(0,NCONTEXT-1);
creturn[1] = get_rng(0,NCONTEXT-1);
buff(2,0) = 0;
pw(2,0) = 0;
cr(2,0) = 0;
iw(2,0) = 0;
cw(2,0) = 0;
cx(2,0) = 0;
is(2,0) = 0;
cs(2,0) = 0;
crmax(2,0) = 0;
buff(2,1) = 0;
pw(2,1) = 0;
cr(2,1) = 0;
iw(2,1) = 0;
cw(2,1) = 0;
cx(2,1) = 0;
is(2,1) = 0;
cs(2,1) = 0;
crmax(2,1) = 0;
buff(2,2) = 0;
pw(2,2) = 0;
cr(2,2) = 0;
iw(2,2) = 0;
cw(2,2) = 0;
cx(2,2) = 0;
is(2,2) = 0;
cs(2,2) = 0;
crmax(2,2) = 0;
buff(2,3) = 0;
pw(2,3) = 0;
cr(2,3) = 0;
iw(2,3) = 0;
cw(2,3) = 0;
cx(2,3) = 0;
is(2,3) = 0;
cs(2,3) = 0;
crmax(2,3) = 0;
buff(2,4) = 0;
pw(2,4) = 0;
cr(2,4) = 0;
iw(2,4) = 0;
cw(2,4) = 0;
cx(2,4) = 0;
is(2,4) = 0;
cs(2,4) = 0;
crmax(2,4) = 0;
buff(2,5) = 0;
pw(2,5) = 0;
cr(2,5) = 0;
iw(2,5) = 0;
cw(2,5) = 0;
cx(2,5) = 0;
is(2,5) = 0;
cs(2,5) = 0;
crmax(2,5) = 0;
buff(2,6) = 0;
pw(2,6) = 0;
cr(2,6) = 0;
iw(2,6) = 0;
cw(2,6) = 0;
cx(2,6) = 0;
is(2,6) = 0;
cs(2,6) = 0;
crmax(2,6) = 0;
cl[2] = 0;
cdy[2] = 0;
cds[2] = 0;
cdl[2] = 0;
cisb[2] = 0;
caddr[2] = 0;
cctrl[2] = 0;
cstart[2] = get_rng(0,NCONTEXT-1);
creturn[2] = get_rng(0,NCONTEXT-1);
// Dumping initializations
mem(0+0,0) = 0;
mem(0+1,0) = 0;
mem(0+2,0) = 0;
mem(0+3,0) = 0;
mem(4+0,0) = 0;
mem(5+0,0) = 0;
mem(6+0,0) = 0;
// Dumping context matching equalities
co(0,0) = 0;
delta(0,0) = -1;
mem(0,1) = meminit(0,1);
co(0,1) = coinit(0,1);
delta(0,1) = deltainit(0,1);
mem(0,2) = meminit(0,2);
co(0,2) = coinit(0,2);
delta(0,2) = deltainit(0,2);
mem(0,3) = meminit(0,3);
co(0,3) = coinit(0,3);
delta(0,3) = deltainit(0,3);
mem(0,4) = meminit(0,4);
co(0,4) = coinit(0,4);
delta(0,4) = deltainit(0,4);
co(1,0) = 0;
delta(1,0) = -1;
mem(1,1) = meminit(1,1);
co(1,1) = coinit(1,1);
delta(1,1) = deltainit(1,1);
mem(1,2) = meminit(1,2);
co(1,2) = coinit(1,2);
delta(1,2) = deltainit(1,2);
mem(1,3) = meminit(1,3);
co(1,3) = coinit(1,3);
delta(1,3) = deltainit(1,3);
mem(1,4) = meminit(1,4);
co(1,4) = coinit(1,4);
delta(1,4) = deltainit(1,4);
co(2,0) = 0;
delta(2,0) = -1;
mem(2,1) = meminit(2,1);
co(2,1) = coinit(2,1);
delta(2,1) = deltainit(2,1);
mem(2,2) = meminit(2,2);
co(2,2) = coinit(2,2);
delta(2,2) = deltainit(2,2);
mem(2,3) = meminit(2,3);
co(2,3) = coinit(2,3);
delta(2,3) = deltainit(2,3);
mem(2,4) = meminit(2,4);
co(2,4) = coinit(2,4);
delta(2,4) = deltainit(2,4);
co(3,0) = 0;
delta(3,0) = -1;
mem(3,1) = meminit(3,1);
co(3,1) = coinit(3,1);
delta(3,1) = deltainit(3,1);
mem(3,2) = meminit(3,2);
co(3,2) = coinit(3,2);
delta(3,2) = deltainit(3,2);
mem(3,3) = meminit(3,3);
co(3,3) = coinit(3,3);
delta(3,3) = deltainit(3,3);
mem(3,4) = meminit(3,4);
co(3,4) = coinit(3,4);
delta(3,4) = deltainit(3,4);
co(4,0) = 0;
delta(4,0) = -1;
mem(4,1) = meminit(4,1);
co(4,1) = coinit(4,1);
delta(4,1) = deltainit(4,1);
mem(4,2) = meminit(4,2);
co(4,2) = coinit(4,2);
delta(4,2) = deltainit(4,2);
mem(4,3) = meminit(4,3);
co(4,3) = coinit(4,3);
delta(4,3) = deltainit(4,3);
mem(4,4) = meminit(4,4);
co(4,4) = coinit(4,4);
delta(4,4) = deltainit(4,4);
co(5,0) = 0;
delta(5,0) = -1;
mem(5,1) = meminit(5,1);
co(5,1) = coinit(5,1);
delta(5,1) = deltainit(5,1);
mem(5,2) = meminit(5,2);
co(5,2) = coinit(5,2);
delta(5,2) = deltainit(5,2);
mem(5,3) = meminit(5,3);
co(5,3) = coinit(5,3);
delta(5,3) = deltainit(5,3);
mem(5,4) = meminit(5,4);
co(5,4) = coinit(5,4);
delta(5,4) = deltainit(5,4);
co(6,0) = 0;
delta(6,0) = -1;
mem(6,1) = meminit(6,1);
co(6,1) = coinit(6,1);
delta(6,1) = deltainit(6,1);
mem(6,2) = meminit(6,2);
co(6,2) = coinit(6,2);
delta(6,2) = deltainit(6,2);
mem(6,3) = meminit(6,3);
co(6,3) = coinit(6,3);
delta(6,3) = deltainit(6,3);
mem(6,4) = meminit(6,4);
co(6,4) = coinit(6,4);
delta(6,4) = deltainit(6,4);
// Dumping thread 1
int ret_thread_1 = 0;
cdy[1] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[1] >= cstart[1]);
T1BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !38, metadata !DIExpression()), !dbg !47
// br label %label_1, !dbg !48
goto T1BLOCK1;
T1BLOCK1:
// call void @llvm.dbg.label(metadata !46), !dbg !49
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !39, metadata !DIExpression()), !dbg !50
// call void @llvm.dbg.value(metadata i64 2, metadata !42, metadata !DIExpression()), !dbg !50
// store atomic i64 2, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !51
// ST: Guess
iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l21_c3
old_cw = cw(1,0);
cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l21_c3
// Check
ASSUME(active[iw(1,0)] == 1);
ASSUME(active[cw(1,0)] == 1);
ASSUME(sforbid(0,cw(1,0))== 0);
ASSUME(iw(1,0) >= 0);
ASSUME(iw(1,0) >= 0);
ASSUME(cw(1,0) >= iw(1,0));
ASSUME(cw(1,0) >= old_cw);
ASSUME(cw(1,0) >= cr(1,0));
ASSUME(cw(1,0) >= cl[1]);
ASSUME(cw(1,0) >= cisb[1]);
ASSUME(cw(1,0) >= cdy[1]);
ASSUME(cw(1,0) >= cdl[1]);
ASSUME(cw(1,0) >= cds[1]);
ASSUME(cw(1,0) >= cctrl[1]);
ASSUME(cw(1,0) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0) = 2;
mem(0,cw(1,0)) = 2;
co(0,cw(1,0))+=1;
delta(0,cw(1,0)) = -1;
ASSUME(creturn[1] >= cw(1,0));
// call void (...) @dmbsy(), !dbg !52
// dumbsy: Guess
old_cdy = cdy[1];
cdy[1] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[1] >= old_cdy);
ASSUME(cdy[1] >= cisb[1]);
ASSUME(cdy[1] >= cdl[1]);
ASSUME(cdy[1] >= cds[1]);
ASSUME(cdy[1] >= cctrl[1]);
ASSUME(cdy[1] >= cw(1,0+0));
ASSUME(cdy[1] >= cw(1,0+1));
ASSUME(cdy[1] >= cw(1,0+2));
ASSUME(cdy[1] >= cw(1,0+3));
ASSUME(cdy[1] >= cw(1,4+0));
ASSUME(cdy[1] >= cw(1,5+0));
ASSUME(cdy[1] >= cw(1,6+0));
ASSUME(cdy[1] >= cr(1,0+0));
ASSUME(cdy[1] >= cr(1,0+1));
ASSUME(cdy[1] >= cr(1,0+2));
ASSUME(cdy[1] >= cr(1,0+3));
ASSUME(cdy[1] >= cr(1,4+0));
ASSUME(cdy[1] >= cr(1,5+0));
ASSUME(cdy[1] >= cr(1,6+0));
ASSUME(creturn[1] >= cdy[1]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !43, metadata !DIExpression()), !dbg !53
// call void @llvm.dbg.value(metadata i64 1, metadata !45, metadata !DIExpression()), !dbg !53
// store atomic i64 1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !54
// ST: Guess
iw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW _l23_c3
old_cw = cw(1,0+1*1);
cw(1,0+1*1) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM _l23_c3
// Check
ASSUME(active[iw(1,0+1*1)] == 1);
ASSUME(active[cw(1,0+1*1)] == 1);
ASSUME(sforbid(0+1*1,cw(1,0+1*1))== 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(iw(1,0+1*1) >= 0);
ASSUME(cw(1,0+1*1) >= iw(1,0+1*1));
ASSUME(cw(1,0+1*1) >= old_cw);
ASSUME(cw(1,0+1*1) >= cr(1,0+1*1));
ASSUME(cw(1,0+1*1) >= cl[1]);
ASSUME(cw(1,0+1*1) >= cisb[1]);
ASSUME(cw(1,0+1*1) >= cdy[1]);
ASSUME(cw(1,0+1*1) >= cdl[1]);
ASSUME(cw(1,0+1*1) >= cds[1]);
ASSUME(cw(1,0+1*1) >= cctrl[1]);
ASSUME(cw(1,0+1*1) >= caddr[1]);
// Update
caddr[1] = max(caddr[1],0);
buff(1,0+1*1) = 1;
mem(0+1*1,cw(1,0+1*1)) = 1;
co(0+1*1,cw(1,0+1*1))+=1;
delta(0+1*1,cw(1,0+1*1)) = -1;
ASSUME(creturn[1] >= cw(1,0+1*1));
// ret i8* null, !dbg !55
ret_thread_1 = (- 1);
goto T1BLOCK_END;
T1BLOCK_END:
// Dumping thread 2
int ret_thread_2 = 0;
cdy[2] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[2] >= cstart[2]);
T2BLOCK0:
// call void @llvm.dbg.value(metadata i8* %arg, metadata !58, metadata !DIExpression()), !dbg !88
// br label %label_2, !dbg !70
goto T2BLOCK1;
T2BLOCK1:
// call void @llvm.dbg.label(metadata !85), !dbg !90
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !60, metadata !DIExpression()), !dbg !91
// %0 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !73
// LD: Guess
old_cr = cr(2,0+1*1);
cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l29_c15
// Check
ASSUME(active[cr(2,0+1*1)] == 2);
ASSUME(cr(2,0+1*1) >= iw(2,0+1*1));
ASSUME(cr(2,0+1*1) >= 0);
ASSUME(cr(2,0+1*1) >= cdy[2]);
ASSUME(cr(2,0+1*1) >= cisb[2]);
ASSUME(cr(2,0+1*1) >= cdl[2]);
ASSUME(cr(2,0+1*1) >= cl[2]);
// Update
creg_r0 = cr(2,0+1*1);
crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+1*1) < cw(2,0+1*1)) {
r0 = buff(2,0+1*1);
ASSUME((!(( (cw(2,0+1*1) < 1) && (1 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(2,0+1*1) < 2) && (2 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(2,0+1*1) < 3) && (3 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(2,0+1*1) < 4) && (4 < crmax(2,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) {
ASSUME(cr(2,0+1*1) >= old_cr);
}
pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1));
r0 = mem(0+1*1,cr(2,0+1*1));
}
ASSUME(creturn[2] >= cr(2,0+1*1));
// call void @llvm.dbg.value(metadata i64 %0, metadata !62, metadata !DIExpression()), !dbg !91
// %conv = trunc i64 %0 to i32, !dbg !74
// call void @llvm.dbg.value(metadata i32 %conv, metadata !59, metadata !DIExpression()), !dbg !88
// %xor = xor i32 %conv, %conv, !dbg !75
creg_r1 = creg_r0;
r1 = r0 ^ r0;
// call void @llvm.dbg.value(metadata i32 %xor, metadata !63, metadata !DIExpression()), !dbg !88
// %add = add nsw i32 2, %xor, !dbg !76
creg_r2 = max(0,creg_r1);
r2 = 2 + r1;
// %idxprom = sext i32 %add to i64, !dbg !76
// %arrayidx = getelementptr inbounds [4 x i64], [4 x i64]* @vars, i64 0, i64 %idxprom, !dbg !76
r3 = 0+r2*1;
creg_r3 = creg_r2;
// call void @llvm.dbg.value(metadata i64* %arrayidx, metadata !64, metadata !DIExpression()), !dbg !96
// call void @llvm.dbg.value(metadata i64 1, metadata !66, metadata !DIExpression()), !dbg !96
// store atomic i64 1, i64* %arrayidx monotonic, align 8, !dbg !76
// ST: Guess
iw(2,r3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l31_c3
old_cw = cw(2,r3);
cw(2,r3) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l31_c3
// Check
ASSUME(active[iw(2,r3)] == 2);
ASSUME(active[cw(2,r3)] == 2);
ASSUME(sforbid(r3,cw(2,r3))== 0);
ASSUME(iw(2,r3) >= 0);
ASSUME(iw(2,r3) >= creg_r3);
ASSUME(cw(2,r3) >= iw(2,r3));
ASSUME(cw(2,r3) >= old_cw);
ASSUME(cw(2,r3) >= cr(2,r3));
ASSUME(cw(2,r3) >= cl[2]);
ASSUME(cw(2,r3) >= cisb[2]);
ASSUME(cw(2,r3) >= cdy[2]);
ASSUME(cw(2,r3) >= cdl[2]);
ASSUME(cw(2,r3) >= cds[2]);
ASSUME(cw(2,r3) >= cctrl[2]);
ASSUME(cw(2,r3) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],creg_r3);
buff(2,r3) = 1;
mem(r3,cw(2,r3)) = 1;
co(r3,cw(2,r3))+=1;
delta(r3,cw(2,r3)) = -1;
ASSUME(creturn[2] >= cw(2,r3));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2), metadata !68, metadata !DIExpression()), !dbg !97
// %1 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !79
// LD: Guess
old_cr = cr(2,0+2*1);
cr(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l32_c15
// Check
ASSUME(active[cr(2,0+2*1)] == 2);
ASSUME(cr(2,0+2*1) >= iw(2,0+2*1));
ASSUME(cr(2,0+2*1) >= 0);
ASSUME(cr(2,0+2*1) >= cdy[2]);
ASSUME(cr(2,0+2*1) >= cisb[2]);
ASSUME(cr(2,0+2*1) >= cdl[2]);
ASSUME(cr(2,0+2*1) >= cl[2]);
// Update
creg_r4 = cr(2,0+2*1);
crmax(2,0+2*1) = max(crmax(2,0+2*1),cr(2,0+2*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+2*1) < cw(2,0+2*1)) {
r4 = buff(2,0+2*1);
ASSUME((!(( (cw(2,0+2*1) < 1) && (1 < crmax(2,0+2*1)) )))||(sforbid(0+2*1,1)> 0));
ASSUME((!(( (cw(2,0+2*1) < 2) && (2 < crmax(2,0+2*1)) )))||(sforbid(0+2*1,2)> 0));
ASSUME((!(( (cw(2,0+2*1) < 3) && (3 < crmax(2,0+2*1)) )))||(sforbid(0+2*1,3)> 0));
ASSUME((!(( (cw(2,0+2*1) < 4) && (4 < crmax(2,0+2*1)) )))||(sforbid(0+2*1,4)> 0));
} else {
if(pw(2,0+2*1) != co(0+2*1,cr(2,0+2*1))) {
ASSUME(cr(2,0+2*1) >= old_cr);
}
pw(2,0+2*1) = co(0+2*1,cr(2,0+2*1));
r4 = mem(0+2*1,cr(2,0+2*1));
}
ASSUME(creturn[2] >= cr(2,0+2*1));
// call void @llvm.dbg.value(metadata i64 %1, metadata !70, metadata !DIExpression()), !dbg !97
// %conv4 = trunc i64 %1 to i32, !dbg !80
// call void @llvm.dbg.value(metadata i32 %conv4, metadata !67, metadata !DIExpression()), !dbg !88
// %tobool = icmp ne i32 %conv4, 0, !dbg !81
creg__r4__0_ = max(0,creg_r4);
// br i1 %tobool, label %if.then, label %if.else, !dbg !83
old_cctrl = cctrl[2];
cctrl[2] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[2] >= old_cctrl);
ASSUME(cctrl[2] >= creg__r4__0_);
if((r4!=0)) {
goto T2BLOCK2;
} else {
goto T2BLOCK3;
}
T2BLOCK2:
// br label %lbl_LC00, !dbg !84
goto T2BLOCK4;
T2BLOCK3:
// br label %lbl_LC00, !dbg !85
goto T2BLOCK4;
T2BLOCK4:
// call void @llvm.dbg.label(metadata !86), !dbg !105
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3), metadata !72, metadata !DIExpression()), !dbg !106
// %2 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3) monotonic, align 8, !dbg !88
// LD: Guess
old_cr = cr(2,0+3*1);
cr(2,0+3*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l35_c16
// Check
ASSUME(active[cr(2,0+3*1)] == 2);
ASSUME(cr(2,0+3*1) >= iw(2,0+3*1));
ASSUME(cr(2,0+3*1) >= 0);
ASSUME(cr(2,0+3*1) >= cdy[2]);
ASSUME(cr(2,0+3*1) >= cisb[2]);
ASSUME(cr(2,0+3*1) >= cdl[2]);
ASSUME(cr(2,0+3*1) >= cl[2]);
// Update
creg_r5 = cr(2,0+3*1);
crmax(2,0+3*1) = max(crmax(2,0+3*1),cr(2,0+3*1));
caddr[2] = max(caddr[2],0);
if(cr(2,0+3*1) < cw(2,0+3*1)) {
r5 = buff(2,0+3*1);
ASSUME((!(( (cw(2,0+3*1) < 1) && (1 < crmax(2,0+3*1)) )))||(sforbid(0+3*1,1)> 0));
ASSUME((!(( (cw(2,0+3*1) < 2) && (2 < crmax(2,0+3*1)) )))||(sforbid(0+3*1,2)> 0));
ASSUME((!(( (cw(2,0+3*1) < 3) && (3 < crmax(2,0+3*1)) )))||(sforbid(0+3*1,3)> 0));
ASSUME((!(( (cw(2,0+3*1) < 4) && (4 < crmax(2,0+3*1)) )))||(sforbid(0+3*1,4)> 0));
} else {
if(pw(2,0+3*1) != co(0+3*1,cr(2,0+3*1))) {
ASSUME(cr(2,0+3*1) >= old_cr);
}
pw(2,0+3*1) = co(0+3*1,cr(2,0+3*1));
r5 = mem(0+3*1,cr(2,0+3*1));
}
ASSUME(creturn[2] >= cr(2,0+3*1));
// call void @llvm.dbg.value(metadata i64 %2, metadata !74, metadata !DIExpression()), !dbg !106
// %conv8 = trunc i64 %2 to i32, !dbg !89
// call void @llvm.dbg.value(metadata i32 %conv8, metadata !71, metadata !DIExpression()), !dbg !88
// %tobool9 = icmp ne i32 %conv8, 0, !dbg !90
creg__r5__0_ = max(0,creg_r5);
// br i1 %tobool9, label %if.then10, label %if.else11, !dbg !92
old_cctrl = cctrl[2];
cctrl[2] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[2] >= old_cctrl);
ASSUME(cctrl[2] >= creg__r5__0_);
if((r5!=0)) {
goto T2BLOCK5;
} else {
goto T2BLOCK6;
}
T2BLOCK5:
// br label %lbl_LC01, !dbg !93
goto T2BLOCK7;
T2BLOCK6:
// br label %lbl_LC01, !dbg !94
goto T2BLOCK7;
T2BLOCK7:
// call void @llvm.dbg.label(metadata !87), !dbg !114
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !75, metadata !DIExpression()), !dbg !115
// call void @llvm.dbg.value(metadata i64 1, metadata !77, metadata !DIExpression()), !dbg !115
// store atomic i64 1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !97
// ST: Guess
iw(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l38_c3
old_cw = cw(2,0);
cw(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l38_c3
// Check
ASSUME(active[iw(2,0)] == 2);
ASSUME(active[cw(2,0)] == 2);
ASSUME(sforbid(0,cw(2,0))== 0);
ASSUME(iw(2,0) >= 0);
ASSUME(iw(2,0) >= 0);
ASSUME(cw(2,0) >= iw(2,0));
ASSUME(cw(2,0) >= old_cw);
ASSUME(cw(2,0) >= cr(2,0));
ASSUME(cw(2,0) >= cl[2]);
ASSUME(cw(2,0) >= cisb[2]);
ASSUME(cw(2,0) >= cdy[2]);
ASSUME(cw(2,0) >= cdl[2]);
ASSUME(cw(2,0) >= cds[2]);
ASSUME(cw(2,0) >= cctrl[2]);
ASSUME(cw(2,0) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,0) = 1;
mem(0,cw(2,0)) = 1;
co(0,cw(2,0))+=1;
delta(0,cw(2,0)) = -1;
ASSUME(creturn[2] >= cw(2,0));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !79, metadata !DIExpression()), !dbg !117
// %3 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !99
// LD: Guess
old_cr = cr(2,0);
cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM _l39_c17
// Check
ASSUME(active[cr(2,0)] == 2);
ASSUME(cr(2,0) >= iw(2,0));
ASSUME(cr(2,0) >= 0);
ASSUME(cr(2,0) >= cdy[2]);
ASSUME(cr(2,0) >= cisb[2]);
ASSUME(cr(2,0) >= cdl[2]);
ASSUME(cr(2,0) >= cl[2]);
// Update
creg_r6 = cr(2,0);
crmax(2,0) = max(crmax(2,0),cr(2,0));
caddr[2] = max(caddr[2],0);
if(cr(2,0) < cw(2,0)) {
r6 = buff(2,0);
ASSUME((!(( (cw(2,0) < 1) && (1 < crmax(2,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(2,0) < 2) && (2 < crmax(2,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(2,0) < 3) && (3 < crmax(2,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(2,0) < 4) && (4 < crmax(2,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(2,0) != co(0,cr(2,0))) {
ASSUME(cr(2,0) >= old_cr);
}
pw(2,0) = co(0,cr(2,0));
r6 = mem(0,cr(2,0));
}
ASSUME(creturn[2] >= cr(2,0));
// call void @llvm.dbg.value(metadata i64 %3, metadata !81, metadata !DIExpression()), !dbg !117
// %conv17 = trunc i64 %3 to i32, !dbg !100
// call void @llvm.dbg.value(metadata i32 %conv17, metadata !78, metadata !DIExpression()), !dbg !88
// %cmp = icmp eq i32 %conv, 1, !dbg !101
creg__r0__1_ = max(0,creg_r0);
// %conv18 = zext i1 %cmp to i32, !dbg !101
// call void @llvm.dbg.value(metadata i32 %conv18, metadata !82, metadata !DIExpression()), !dbg !88
// store i32 %conv18, i32* @atom_1_X0_1, align 4, !dbg !102, !tbaa !103
// ST: Guess
iw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l41_c15
old_cw = cw(2,4);
cw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l41_c15
// Check
ASSUME(active[iw(2,4)] == 2);
ASSUME(active[cw(2,4)] == 2);
ASSUME(sforbid(4,cw(2,4))== 0);
ASSUME(iw(2,4) >= creg__r0__1_);
ASSUME(iw(2,4) >= 0);
ASSUME(cw(2,4) >= iw(2,4));
ASSUME(cw(2,4) >= old_cw);
ASSUME(cw(2,4) >= cr(2,4));
ASSUME(cw(2,4) >= cl[2]);
ASSUME(cw(2,4) >= cisb[2]);
ASSUME(cw(2,4) >= cdy[2]);
ASSUME(cw(2,4) >= cdl[2]);
ASSUME(cw(2,4) >= cds[2]);
ASSUME(cw(2,4) >= cctrl[2]);
ASSUME(cw(2,4) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,4) = (r0==1);
mem(4,cw(2,4)) = (r0==1);
co(4,cw(2,4))+=1;
delta(4,cw(2,4)) = -1;
ASSUME(creturn[2] >= cw(2,4));
// %cmp19 = icmp eq i32 %conv4, 1, !dbg !107
creg__r4__1_ = max(0,creg_r4);
// %conv20 = zext i1 %cmp19 to i32, !dbg !107
// call void @llvm.dbg.value(metadata i32 %conv20, metadata !83, metadata !DIExpression()), !dbg !88
// store i32 %conv20, i32* @atom_1_X5_1, align 4, !dbg !108, !tbaa !103
// ST: Guess
iw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l43_c15
old_cw = cw(2,5);
cw(2,5) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l43_c15
// Check
ASSUME(active[iw(2,5)] == 2);
ASSUME(active[cw(2,5)] == 2);
ASSUME(sforbid(5,cw(2,5))== 0);
ASSUME(iw(2,5) >= creg__r4__1_);
ASSUME(iw(2,5) >= 0);
ASSUME(cw(2,5) >= iw(2,5));
ASSUME(cw(2,5) >= old_cw);
ASSUME(cw(2,5) >= cr(2,5));
ASSUME(cw(2,5) >= cl[2]);
ASSUME(cw(2,5) >= cisb[2]);
ASSUME(cw(2,5) >= cdy[2]);
ASSUME(cw(2,5) >= cdl[2]);
ASSUME(cw(2,5) >= cds[2]);
ASSUME(cw(2,5) >= cctrl[2]);
ASSUME(cw(2,5) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,5) = (r4==1);
mem(5,cw(2,5)) = (r4==1);
co(5,cw(2,5))+=1;
delta(5,cw(2,5)) = -1;
ASSUME(creturn[2] >= cw(2,5));
// %cmp21 = icmp eq i32 %conv17, 1, !dbg !109
creg__r6__1_ = max(0,creg_r6);
// %conv22 = zext i1 %cmp21 to i32, !dbg !109
// call void @llvm.dbg.value(metadata i32 %conv22, metadata !84, metadata !DIExpression()), !dbg !88
// store i32 %conv22, i32* @atom_1_X10_1, align 4, !dbg !110, !tbaa !103
// ST: Guess
iw(2,6) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW _l45_c16
old_cw = cw(2,6);
cw(2,6) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM _l45_c16
// Check
ASSUME(active[iw(2,6)] == 2);
ASSUME(active[cw(2,6)] == 2);
ASSUME(sforbid(6,cw(2,6))== 0);
ASSUME(iw(2,6) >= creg__r6__1_);
ASSUME(iw(2,6) >= 0);
ASSUME(cw(2,6) >= iw(2,6));
ASSUME(cw(2,6) >= old_cw);
ASSUME(cw(2,6) >= cr(2,6));
ASSUME(cw(2,6) >= cl[2]);
ASSUME(cw(2,6) >= cisb[2]);
ASSUME(cw(2,6) >= cdy[2]);
ASSUME(cw(2,6) >= cdl[2]);
ASSUME(cw(2,6) >= cds[2]);
ASSUME(cw(2,6) >= cctrl[2]);
ASSUME(cw(2,6) >= caddr[2]);
// Update
caddr[2] = max(caddr[2],0);
buff(2,6) = (r6==1);
mem(6,cw(2,6)) = (r6==1);
co(6,cw(2,6))+=1;
delta(6,cw(2,6)) = -1;
ASSUME(creturn[2] >= cw(2,6));
// ret i8* null, !dbg !111
ret_thread_2 = (- 1);
goto T2BLOCK_END;
T2BLOCK_END:
// Dumping thread 0
int ret_thread_0 = 0;
cdy[0] = get_rng(0,NCONTEXT-1);
ASSUME(cdy[0] >= cstart[0]);
T0BLOCK0:
// %thr0 = alloca i64, align 8
// %thr1 = alloca i64, align 8
// call void @llvm.dbg.value(metadata i32 %argc, metadata !138, metadata !DIExpression()), !dbg !180
// call void @llvm.dbg.value(metadata i8** %argv, metadata !139, metadata !DIExpression()), !dbg !180
// %0 = bitcast i64* %thr0 to i8*, !dbg !85
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !85
// call void @llvm.dbg.declare(metadata i64* %thr0, metadata !140, metadata !DIExpression()), !dbg !182
// %1 = bitcast i64* %thr1 to i8*, !dbg !87
// call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !87
// call void @llvm.dbg.declare(metadata i64* %thr1, metadata !144, metadata !DIExpression()), !dbg !184
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3), metadata !145, metadata !DIExpression()), !dbg !185
// call void @llvm.dbg.value(metadata i64 0, metadata !147, metadata !DIExpression()), !dbg !185
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 3) monotonic, align 8, !dbg !90
// ST: Guess
iw(0,0+3*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l53_c3
old_cw = cw(0,0+3*1);
cw(0,0+3*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l53_c3
// Check
ASSUME(active[iw(0,0+3*1)] == 0);
ASSUME(active[cw(0,0+3*1)] == 0);
ASSUME(sforbid(0+3*1,cw(0,0+3*1))== 0);
ASSUME(iw(0,0+3*1) >= 0);
ASSUME(iw(0,0+3*1) >= 0);
ASSUME(cw(0,0+3*1) >= iw(0,0+3*1));
ASSUME(cw(0,0+3*1) >= old_cw);
ASSUME(cw(0,0+3*1) >= cr(0,0+3*1));
ASSUME(cw(0,0+3*1) >= cl[0]);
ASSUME(cw(0,0+3*1) >= cisb[0]);
ASSUME(cw(0,0+3*1) >= cdy[0]);
ASSUME(cw(0,0+3*1) >= cdl[0]);
ASSUME(cw(0,0+3*1) >= cds[0]);
ASSUME(cw(0,0+3*1) >= cctrl[0]);
ASSUME(cw(0,0+3*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+3*1) = 0;
mem(0+3*1,cw(0,0+3*1)) = 0;
co(0+3*1,cw(0,0+3*1))+=1;
delta(0+3*1,cw(0,0+3*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+3*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2), metadata !148, metadata !DIExpression()), !dbg !187
// call void @llvm.dbg.value(metadata i64 0, metadata !150, metadata !DIExpression()), !dbg !187
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !92
// ST: Guess
iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l54_c3
old_cw = cw(0,0+2*1);
cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l54_c3
// Check
ASSUME(active[iw(0,0+2*1)] == 0);
ASSUME(active[cw(0,0+2*1)] == 0);
ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(iw(0,0+2*1) >= 0);
ASSUME(cw(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cw(0,0+2*1) >= old_cw);
ASSUME(cw(0,0+2*1) >= cr(0,0+2*1));
ASSUME(cw(0,0+2*1) >= cl[0]);
ASSUME(cw(0,0+2*1) >= cisb[0]);
ASSUME(cw(0,0+2*1) >= cdy[0]);
ASSUME(cw(0,0+2*1) >= cdl[0]);
ASSUME(cw(0,0+2*1) >= cds[0]);
ASSUME(cw(0,0+2*1) >= cctrl[0]);
ASSUME(cw(0,0+2*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+2*1) = 0;
mem(0+2*1,cw(0,0+2*1)) = 0;
co(0+2*1,cw(0,0+2*1))+=1;
delta(0+2*1,cw(0,0+2*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+2*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !151, metadata !DIExpression()), !dbg !189
// call void @llvm.dbg.value(metadata i64 0, metadata !153, metadata !DIExpression()), !dbg !189
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !94
// ST: Guess
iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l55_c3
old_cw = cw(0,0+1*1);
cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l55_c3
// Check
ASSUME(active[iw(0,0+1*1)] == 0);
ASSUME(active[cw(0,0+1*1)] == 0);
ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(iw(0,0+1*1) >= 0);
ASSUME(cw(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cw(0,0+1*1) >= old_cw);
ASSUME(cw(0,0+1*1) >= cr(0,0+1*1));
ASSUME(cw(0,0+1*1) >= cl[0]);
ASSUME(cw(0,0+1*1) >= cisb[0]);
ASSUME(cw(0,0+1*1) >= cdy[0]);
ASSUME(cw(0,0+1*1) >= cdl[0]);
ASSUME(cw(0,0+1*1) >= cds[0]);
ASSUME(cw(0,0+1*1) >= cctrl[0]);
ASSUME(cw(0,0+1*1) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0+1*1) = 0;
mem(0+1*1,cw(0,0+1*1)) = 0;
co(0+1*1,cw(0,0+1*1))+=1;
delta(0+1*1,cw(0,0+1*1)) = -1;
ASSUME(creturn[0] >= cw(0,0+1*1));
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !154, metadata !DIExpression()), !dbg !191
// call void @llvm.dbg.value(metadata i64 0, metadata !156, metadata !DIExpression()), !dbg !191
// store atomic i64 0, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !96
// ST: Guess
iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l56_c3
old_cw = cw(0,0);
cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l56_c3
// Check
ASSUME(active[iw(0,0)] == 0);
ASSUME(active[cw(0,0)] == 0);
ASSUME(sforbid(0,cw(0,0))== 0);
ASSUME(iw(0,0) >= 0);
ASSUME(iw(0,0) >= 0);
ASSUME(cw(0,0) >= iw(0,0));
ASSUME(cw(0,0) >= old_cw);
ASSUME(cw(0,0) >= cr(0,0));
ASSUME(cw(0,0) >= cl[0]);
ASSUME(cw(0,0) >= cisb[0]);
ASSUME(cw(0,0) >= cdy[0]);
ASSUME(cw(0,0) >= cdl[0]);
ASSUME(cw(0,0) >= cds[0]);
ASSUME(cw(0,0) >= cctrl[0]);
ASSUME(cw(0,0) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,0) = 0;
mem(0,cw(0,0)) = 0;
co(0,cw(0,0))+=1;
delta(0,cw(0,0)) = -1;
ASSUME(creturn[0] >= cw(0,0));
// store i32 0, i32* @atom_1_X0_1, align 4, !dbg !97, !tbaa !98
// ST: Guess
iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l57_c15
old_cw = cw(0,4);
cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l57_c15
// Check
ASSUME(active[iw(0,4)] == 0);
ASSUME(active[cw(0,4)] == 0);
ASSUME(sforbid(4,cw(0,4))== 0);
ASSUME(iw(0,4) >= 0);
ASSUME(iw(0,4) >= 0);
ASSUME(cw(0,4) >= iw(0,4));
ASSUME(cw(0,4) >= old_cw);
ASSUME(cw(0,4) >= cr(0,4));
ASSUME(cw(0,4) >= cl[0]);
ASSUME(cw(0,4) >= cisb[0]);
ASSUME(cw(0,4) >= cdy[0]);
ASSUME(cw(0,4) >= cdl[0]);
ASSUME(cw(0,4) >= cds[0]);
ASSUME(cw(0,4) >= cctrl[0]);
ASSUME(cw(0,4) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,4) = 0;
mem(4,cw(0,4)) = 0;
co(4,cw(0,4))+=1;
delta(4,cw(0,4)) = -1;
ASSUME(creturn[0] >= cw(0,4));
// store i32 0, i32* @atom_1_X5_1, align 4, !dbg !102, !tbaa !98
// ST: Guess
iw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l58_c15
old_cw = cw(0,5);
cw(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l58_c15
// Check
ASSUME(active[iw(0,5)] == 0);
ASSUME(active[cw(0,5)] == 0);
ASSUME(sforbid(5,cw(0,5))== 0);
ASSUME(iw(0,5) >= 0);
ASSUME(iw(0,5) >= 0);
ASSUME(cw(0,5) >= iw(0,5));
ASSUME(cw(0,5) >= old_cw);
ASSUME(cw(0,5) >= cr(0,5));
ASSUME(cw(0,5) >= cl[0]);
ASSUME(cw(0,5) >= cisb[0]);
ASSUME(cw(0,5) >= cdy[0]);
ASSUME(cw(0,5) >= cdl[0]);
ASSUME(cw(0,5) >= cds[0]);
ASSUME(cw(0,5) >= cctrl[0]);
ASSUME(cw(0,5) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,5) = 0;
mem(5,cw(0,5)) = 0;
co(5,cw(0,5))+=1;
delta(5,cw(0,5)) = -1;
ASSUME(creturn[0] >= cw(0,5));
// store i32 0, i32* @atom_1_X10_1, align 4, !dbg !103, !tbaa !98
// ST: Guess
iw(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW _l59_c16
old_cw = cw(0,6);
cw(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM _l59_c16
// Check
ASSUME(active[iw(0,6)] == 0);
ASSUME(active[cw(0,6)] == 0);
ASSUME(sforbid(6,cw(0,6))== 0);
ASSUME(iw(0,6) >= 0);
ASSUME(iw(0,6) >= 0);
ASSUME(cw(0,6) >= iw(0,6));
ASSUME(cw(0,6) >= old_cw);
ASSUME(cw(0,6) >= cr(0,6));
ASSUME(cw(0,6) >= cl[0]);
ASSUME(cw(0,6) >= cisb[0]);
ASSUME(cw(0,6) >= cdy[0]);
ASSUME(cw(0,6) >= cdl[0]);
ASSUME(cw(0,6) >= cds[0]);
ASSUME(cw(0,6) >= cctrl[0]);
ASSUME(cw(0,6) >= caddr[0]);
// Update
caddr[0] = max(caddr[0],0);
buff(0,6) = 0;
mem(6,cw(0,6)) = 0;
co(6,cw(0,6))+=1;
delta(6,cw(0,6)) = -1;
ASSUME(creturn[0] >= cw(0,6));
// %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !104
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[1] >= cdy[0]);
// %call7 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !105
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cstart[2] >= cdy[0]);
// %2 = load i64, i64* %thr0, align 8, !dbg !106, !tbaa !107
r8 = local_mem[0];
// %call8 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !109
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[1]);
// %3 = load i64, i64* %thr1, align 8, !dbg !110, !tbaa !107
r9 = local_mem[1];
// %call9 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !111
// dumbsy: Guess
old_cdy = cdy[0];
cdy[0] = get_rng(0,NCONTEXT-1);
// Check
ASSUME(cdy[0] >= old_cdy);
ASSUME(cdy[0] >= cisb[0]);
ASSUME(cdy[0] >= cdl[0]);
ASSUME(cdy[0] >= cds[0]);
ASSUME(cdy[0] >= cctrl[0]);
ASSUME(cdy[0] >= cw(0,0+0));
ASSUME(cdy[0] >= cw(0,0+1));
ASSUME(cdy[0] >= cw(0,0+2));
ASSUME(cdy[0] >= cw(0,0+3));
ASSUME(cdy[0] >= cw(0,4+0));
ASSUME(cdy[0] >= cw(0,5+0));
ASSUME(cdy[0] >= cw(0,6+0));
ASSUME(cdy[0] >= cr(0,0+0));
ASSUME(cdy[0] >= cr(0,0+1));
ASSUME(cdy[0] >= cr(0,0+2));
ASSUME(cdy[0] >= cr(0,0+3));
ASSUME(cdy[0] >= cr(0,4+0));
ASSUME(cdy[0] >= cr(0,5+0));
ASSUME(cdy[0] >= cr(0,6+0));
ASSUME(creturn[0] >= cdy[0]);
ASSUME(cdy[0] >= creturn[2]);
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0), metadata !158, metadata !DIExpression()), !dbg !204
// %4 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !113
// LD: Guess
old_cr = cr(0,0);
cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l67_c13
// Check
ASSUME(active[cr(0,0)] == 0);
ASSUME(cr(0,0) >= iw(0,0));
ASSUME(cr(0,0) >= 0);
ASSUME(cr(0,0) >= cdy[0]);
ASSUME(cr(0,0) >= cisb[0]);
ASSUME(cr(0,0) >= cdl[0]);
ASSUME(cr(0,0) >= cl[0]);
// Update
creg_r10 = cr(0,0);
crmax(0,0) = max(crmax(0,0),cr(0,0));
caddr[0] = max(caddr[0],0);
if(cr(0,0) < cw(0,0)) {
r10 = buff(0,0);
ASSUME((!(( (cw(0,0) < 1) && (1 < crmax(0,0)) )))||(sforbid(0,1)> 0));
ASSUME((!(( (cw(0,0) < 2) && (2 < crmax(0,0)) )))||(sforbid(0,2)> 0));
ASSUME((!(( (cw(0,0) < 3) && (3 < crmax(0,0)) )))||(sforbid(0,3)> 0));
ASSUME((!(( (cw(0,0) < 4) && (4 < crmax(0,0)) )))||(sforbid(0,4)> 0));
} else {
if(pw(0,0) != co(0,cr(0,0))) {
ASSUME(cr(0,0) >= old_cr);
}
pw(0,0) = co(0,cr(0,0));
r10 = mem(0,cr(0,0));
}
ASSUME(creturn[0] >= cr(0,0));
// call void @llvm.dbg.value(metadata i64 %4, metadata !160, metadata !DIExpression()), !dbg !204
// %conv = trunc i64 %4 to i32, !dbg !114
// call void @llvm.dbg.value(metadata i32 %conv, metadata !157, metadata !DIExpression()), !dbg !180
// %cmp = icmp eq i32 %conv, 2, !dbg !115
creg__r10__2_ = max(0,creg_r10);
// %conv10 = zext i1 %cmp to i32, !dbg !115
// call void @llvm.dbg.value(metadata i32 %conv10, metadata !161, metadata !DIExpression()), !dbg !180
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1), metadata !163, metadata !DIExpression()), !dbg !208
// %5 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !117
// LD: Guess
old_cr = cr(0,0+1*1);
cr(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l69_c13
// Check
ASSUME(active[cr(0,0+1*1)] == 0);
ASSUME(cr(0,0+1*1) >= iw(0,0+1*1));
ASSUME(cr(0,0+1*1) >= 0);
ASSUME(cr(0,0+1*1) >= cdy[0]);
ASSUME(cr(0,0+1*1) >= cisb[0]);
ASSUME(cr(0,0+1*1) >= cdl[0]);
ASSUME(cr(0,0+1*1) >= cl[0]);
// Update
creg_r11 = cr(0,0+1*1);
crmax(0,0+1*1) = max(crmax(0,0+1*1),cr(0,0+1*1));
caddr[0] = max(caddr[0],0);
if(cr(0,0+1*1) < cw(0,0+1*1)) {
r11 = buff(0,0+1*1);
ASSUME((!(( (cw(0,0+1*1) < 1) && (1 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,1)> 0));
ASSUME((!(( (cw(0,0+1*1) < 2) && (2 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,2)> 0));
ASSUME((!(( (cw(0,0+1*1) < 3) && (3 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,3)> 0));
ASSUME((!(( (cw(0,0+1*1) < 4) && (4 < crmax(0,0+1*1)) )))||(sforbid(0+1*1,4)> 0));
} else {
if(pw(0,0+1*1) != co(0+1*1,cr(0,0+1*1))) {
ASSUME(cr(0,0+1*1) >= old_cr);
}
pw(0,0+1*1) = co(0+1*1,cr(0,0+1*1));
r11 = mem(0+1*1,cr(0,0+1*1));
}
ASSUME(creturn[0] >= cr(0,0+1*1));
// call void @llvm.dbg.value(metadata i64 %5, metadata !165, metadata !DIExpression()), !dbg !208
// %conv14 = trunc i64 %5 to i32, !dbg !118
// call void @llvm.dbg.value(metadata i32 %conv14, metadata !162, metadata !DIExpression()), !dbg !180
// %cmp15 = icmp eq i32 %conv14, 1, !dbg !119
creg__r11__1_ = max(0,creg_r11);
// %conv16 = zext i1 %cmp15 to i32, !dbg !119
// call void @llvm.dbg.value(metadata i32 %conv16, metadata !166, metadata !DIExpression()), !dbg !180
// call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2), metadata !168, metadata !DIExpression()), !dbg !212
// %6 = load atomic i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !121
// LD: Guess
old_cr = cr(0,0+2*1);
cr(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l71_c13
// Check
ASSUME(active[cr(0,0+2*1)] == 0);
ASSUME(cr(0,0+2*1) >= iw(0,0+2*1));
ASSUME(cr(0,0+2*1) >= 0);
ASSUME(cr(0,0+2*1) >= cdy[0]);
ASSUME(cr(0,0+2*1) >= cisb[0]);
ASSUME(cr(0,0+2*1) >= cdl[0]);
ASSUME(cr(0,0+2*1) >= cl[0]);
// Update
creg_r12 = cr(0,0+2*1);
crmax(0,0+2*1) = max(crmax(0,0+2*1),cr(0,0+2*1));
caddr[0] = max(caddr[0],0);
if(cr(0,0+2*1) < cw(0,0+2*1)) {
r12 = buff(0,0+2*1);
ASSUME((!(( (cw(0,0+2*1) < 1) && (1 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,1)> 0));
ASSUME((!(( (cw(0,0+2*1) < 2) && (2 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,2)> 0));
ASSUME((!(( (cw(0,0+2*1) < 3) && (3 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,3)> 0));
ASSUME((!(( (cw(0,0+2*1) < 4) && (4 < crmax(0,0+2*1)) )))||(sforbid(0+2*1,4)> 0));
} else {
if(pw(0,0+2*1) != co(0+2*1,cr(0,0+2*1))) {
ASSUME(cr(0,0+2*1) >= old_cr);
}
pw(0,0+2*1) = co(0+2*1,cr(0,0+2*1));
r12 = mem(0+2*1,cr(0,0+2*1));
}
ASSUME(creturn[0] >= cr(0,0+2*1));
// call void @llvm.dbg.value(metadata i64 %6, metadata !170, metadata !DIExpression()), !dbg !212
// %conv20 = trunc i64 %6 to i32, !dbg !122
// call void @llvm.dbg.value(metadata i32 %conv20, metadata !167, metadata !DIExpression()), !dbg !180
// %cmp21 = icmp eq i32 %conv20, 1, !dbg !123
creg__r12__1_ = max(0,creg_r12);
// %conv22 = zext i1 %cmp21 to i32, !dbg !123
// call void @llvm.dbg.value(metadata i32 %conv22, metadata !171, metadata !DIExpression()), !dbg !180
// %7 = load i32, i32* @atom_1_X0_1, align 4, !dbg !124, !tbaa !98
// LD: Guess
old_cr = cr(0,4);
cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l73_c13
// Check
ASSUME(active[cr(0,4)] == 0);
ASSUME(cr(0,4) >= iw(0,4));
ASSUME(cr(0,4) >= 0);
ASSUME(cr(0,4) >= cdy[0]);
ASSUME(cr(0,4) >= cisb[0]);
ASSUME(cr(0,4) >= cdl[0]);
ASSUME(cr(0,4) >= cl[0]);
// Update
creg_r13 = cr(0,4);
crmax(0,4) = max(crmax(0,4),cr(0,4));
caddr[0] = max(caddr[0],0);
if(cr(0,4) < cw(0,4)) {
r13 = buff(0,4);
ASSUME((!(( (cw(0,4) < 1) && (1 < crmax(0,4)) )))||(sforbid(4,1)> 0));
ASSUME((!(( (cw(0,4) < 2) && (2 < crmax(0,4)) )))||(sforbid(4,2)> 0));
ASSUME((!(( (cw(0,4) < 3) && (3 < crmax(0,4)) )))||(sforbid(4,3)> 0));
ASSUME((!(( (cw(0,4) < 4) && (4 < crmax(0,4)) )))||(sforbid(4,4)> 0));
} else {
if(pw(0,4) != co(4,cr(0,4))) {
ASSUME(cr(0,4) >= old_cr);
}
pw(0,4) = co(4,cr(0,4));
r13 = mem(4,cr(0,4));
}
ASSUME(creturn[0] >= cr(0,4));
// call void @llvm.dbg.value(metadata i32 %7, metadata !172, metadata !DIExpression()), !dbg !180
// %8 = load i32, i32* @atom_1_X5_1, align 4, !dbg !125, !tbaa !98
// LD: Guess
old_cr = cr(0,5);
cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l74_c13
// Check
ASSUME(active[cr(0,5)] == 0);
ASSUME(cr(0,5) >= iw(0,5));
ASSUME(cr(0,5) >= 0);
ASSUME(cr(0,5) >= cdy[0]);
ASSUME(cr(0,5) >= cisb[0]);
ASSUME(cr(0,5) >= cdl[0]);
ASSUME(cr(0,5) >= cl[0]);
// Update
creg_r14 = cr(0,5);
crmax(0,5) = max(crmax(0,5),cr(0,5));
caddr[0] = max(caddr[0],0);
if(cr(0,5) < cw(0,5)) {
r14 = buff(0,5);
ASSUME((!(( (cw(0,5) < 1) && (1 < crmax(0,5)) )))||(sforbid(5,1)> 0));
ASSUME((!(( (cw(0,5) < 2) && (2 < crmax(0,5)) )))||(sforbid(5,2)> 0));
ASSUME((!(( (cw(0,5) < 3) && (3 < crmax(0,5)) )))||(sforbid(5,3)> 0));
ASSUME((!(( (cw(0,5) < 4) && (4 < crmax(0,5)) )))||(sforbid(5,4)> 0));
} else {
if(pw(0,5) != co(5,cr(0,5))) {
ASSUME(cr(0,5) >= old_cr);
}
pw(0,5) = co(5,cr(0,5));
r14 = mem(5,cr(0,5));
}
ASSUME(creturn[0] >= cr(0,5));
// call void @llvm.dbg.value(metadata i32 %8, metadata !173, metadata !DIExpression()), !dbg !180
// %9 = load i32, i32* @atom_1_X10_1, align 4, !dbg !126, !tbaa !98
// LD: Guess
old_cr = cr(0,6);
cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM _l75_c13
// Check
ASSUME(active[cr(0,6)] == 0);
ASSUME(cr(0,6) >= iw(0,6));
ASSUME(cr(0,6) >= 0);
ASSUME(cr(0,6) >= cdy[0]);
ASSUME(cr(0,6) >= cisb[0]);
ASSUME(cr(0,6) >= cdl[0]);
ASSUME(cr(0,6) >= cl[0]);
// Update
creg_r15 = cr(0,6);
crmax(0,6) = max(crmax(0,6),cr(0,6));
caddr[0] = max(caddr[0],0);
if(cr(0,6) < cw(0,6)) {
r15 = buff(0,6);
ASSUME((!(( (cw(0,6) < 1) && (1 < crmax(0,6)) )))||(sforbid(6,1)> 0));
ASSUME((!(( (cw(0,6) < 2) && (2 < crmax(0,6)) )))||(sforbid(6,2)> 0));
ASSUME((!(( (cw(0,6) < 3) && (3 < crmax(0,6)) )))||(sforbid(6,3)> 0));
ASSUME((!(( (cw(0,6) < 4) && (4 < crmax(0,6)) )))||(sforbid(6,4)> 0));
} else {
if(pw(0,6) != co(6,cr(0,6))) {
ASSUME(cr(0,6) >= old_cr);
}
pw(0,6) = co(6,cr(0,6));
r15 = mem(6,cr(0,6));
}
ASSUME(creturn[0] >= cr(0,6));
// call void @llvm.dbg.value(metadata i32 %9, metadata !174, metadata !DIExpression()), !dbg !180
// %and = and i32 %8, %9, !dbg !127
creg_r16 = max(creg_r14,creg_r15);
r16 = r14 & r15;
// call void @llvm.dbg.value(metadata i32 %and, metadata !175, metadata !DIExpression()), !dbg !180
// %and23 = and i32 %7, %and, !dbg !128
creg_r17 = max(creg_r13,creg_r16);
r17 = r13 & r16;
// call void @llvm.dbg.value(metadata i32 %and23, metadata !176, metadata !DIExpression()), !dbg !180
// %and24 = and i32 %conv22, %and23, !dbg !129
creg_r18 = max(creg__r12__1_,creg_r17);
r18 = (r12==1) & r17;
// call void @llvm.dbg.value(metadata i32 %and24, metadata !177, metadata !DIExpression()), !dbg !180
// %and25 = and i32 %conv16, %and24, !dbg !130
creg_r19 = max(creg__r11__1_,creg_r18);
r19 = (r11==1) & r18;
// call void @llvm.dbg.value(metadata i32 %and25, metadata !178, metadata !DIExpression()), !dbg !180
// %and26 = and i32 %conv10, %and25, !dbg !131
creg_r20 = max(creg__r10__2_,creg_r19);
r20 = (r10==2) & r19;
// call void @llvm.dbg.value(metadata i32 %and26, metadata !179, metadata !DIExpression()), !dbg !180
// %cmp27 = icmp eq i32 %and26, 1, !dbg !132
creg__r20__1_ = max(0,creg_r20);
// br i1 %cmp27, label %if.then, label %if.end, !dbg !134
old_cctrl = cctrl[0];
cctrl[0] = get_rng(0,NCONTEXT-1);
ASSUME(cctrl[0] >= old_cctrl);
ASSUME(cctrl[0] >= creg__r20__1_);
if((r20==1)) {
goto T0BLOCK1;
} else {
goto T0BLOCK2;
}
T0BLOCK1:
// call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([117 x i8], [117 x i8]* @.str.1, i64 0, i64 0), i32 noundef 81, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !135
// unreachable, !dbg !135
r21 = 1;
goto T0BLOCK_END;
T0BLOCK2:
// %10 = bitcast i64* %thr1 to i8*, !dbg !138
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %10) #7, !dbg !138
// %11 = bitcast i64* %thr0 to i8*, !dbg !138
// call void @llvm.lifetime.end.p0i8(i64 8, i8* %11) #7, !dbg !138
// ret i32 0, !dbg !139
ret_thread_0 = 0;
goto T0BLOCK_END;
T0BLOCK_END:
ASSUME(meminit(0,1) == mem(0,0));
ASSUME(coinit(0,1) == co(0,0));
ASSUME(deltainit(0,1) == delta(0,0));
ASSUME(meminit(0,2) == mem(0,1));
ASSUME(coinit(0,2) == co(0,1));
ASSUME(deltainit(0,2) == delta(0,1));
ASSUME(meminit(0,3) == mem(0,2));
ASSUME(coinit(0,3) == co(0,2));
ASSUME(deltainit(0,3) == delta(0,2));
ASSUME(meminit(0,4) == mem(0,3));
ASSUME(coinit(0,4) == co(0,3));
ASSUME(deltainit(0,4) == delta(0,3));
ASSUME(meminit(1,1) == mem(1,0));
ASSUME(coinit(1,1) == co(1,0));
ASSUME(deltainit(1,1) == delta(1,0));
ASSUME(meminit(1,2) == mem(1,1));
ASSUME(coinit(1,2) == co(1,1));
ASSUME(deltainit(1,2) == delta(1,1));
ASSUME(meminit(1,3) == mem(1,2));
ASSUME(coinit(1,3) == co(1,2));
ASSUME(deltainit(1,3) == delta(1,2));
ASSUME(meminit(1,4) == mem(1,3));
ASSUME(coinit(1,4) == co(1,3));
ASSUME(deltainit(1,4) == delta(1,3));
ASSUME(meminit(2,1) == mem(2,0));
ASSUME(coinit(2,1) == co(2,0));
ASSUME(deltainit(2,1) == delta(2,0));
ASSUME(meminit(2,2) == mem(2,1));
ASSUME(coinit(2,2) == co(2,1));
ASSUME(deltainit(2,2) == delta(2,1));
ASSUME(meminit(2,3) == mem(2,2));
ASSUME(coinit(2,3) == co(2,2));
ASSUME(deltainit(2,3) == delta(2,2));
ASSUME(meminit(2,4) == mem(2,3));
ASSUME(coinit(2,4) == co(2,3));
ASSUME(deltainit(2,4) == delta(2,3));
ASSUME(meminit(3,1) == mem(3,0));
ASSUME(coinit(3,1) == co(3,0));
ASSUME(deltainit(3,1) == delta(3,0));
ASSUME(meminit(3,2) == mem(3,1));
ASSUME(coinit(3,2) == co(3,1));
ASSUME(deltainit(3,2) == delta(3,1));
ASSUME(meminit(3,3) == mem(3,2));
ASSUME(coinit(3,3) == co(3,2));
ASSUME(deltainit(3,3) == delta(3,2));
ASSUME(meminit(3,4) == mem(3,3));
ASSUME(coinit(3,4) == co(3,3));
ASSUME(deltainit(3,4) == delta(3,3));
ASSUME(meminit(4,1) == mem(4,0));
ASSUME(coinit(4,1) == co(4,0));
ASSUME(deltainit(4,1) == delta(4,0));
ASSUME(meminit(4,2) == mem(4,1));
ASSUME(coinit(4,2) == co(4,1));
ASSUME(deltainit(4,2) == delta(4,1));
ASSUME(meminit(4,3) == mem(4,2));
ASSUME(coinit(4,3) == co(4,2));
ASSUME(deltainit(4,3) == delta(4,2));
ASSUME(meminit(4,4) == mem(4,3));
ASSUME(coinit(4,4) == co(4,3));
ASSUME(deltainit(4,4) == delta(4,3));
ASSUME(meminit(5,1) == mem(5,0));
ASSUME(coinit(5,1) == co(5,0));
ASSUME(deltainit(5,1) == delta(5,0));
ASSUME(meminit(5,2) == mem(5,1));
ASSUME(coinit(5,2) == co(5,1));
ASSUME(deltainit(5,2) == delta(5,1));
ASSUME(meminit(5,3) == mem(5,2));
ASSUME(coinit(5,3) == co(5,2));
ASSUME(deltainit(5,3) == delta(5,2));
ASSUME(meminit(5,4) == mem(5,3));
ASSUME(coinit(5,4) == co(5,3));
ASSUME(deltainit(5,4) == delta(5,3));
ASSUME(meminit(6,1) == mem(6,0));
ASSUME(coinit(6,1) == co(6,0));
ASSUME(deltainit(6,1) == delta(6,0));
ASSUME(meminit(6,2) == mem(6,1));
ASSUME(coinit(6,2) == co(6,1));
ASSUME(deltainit(6,2) == delta(6,1));
ASSUME(meminit(6,3) == mem(6,2));
ASSUME(coinit(6,3) == co(6,2));
ASSUME(deltainit(6,3) == delta(6,2));
ASSUME(meminit(6,4) == mem(6,3));
ASSUME(coinit(6,4) == co(6,3));
ASSUME(deltainit(6,4) == delta(6,3));
ASSERT(r21== 0);
}
| [
"tuan-phong.ngo@it.uu.se"
] | tuan-phong.ngo@it.uu.se |
53dcc9cc87fa44e83d7c4a45220f68a92c7425dc | c3a0f82e6d0fb3e8fb49afc042560e5787e42141 | /codeforces/1374/C.cpp | 314358ac5dc52713c936d073118bbc78631312f4 | [] | no_license | SahajGupta11/Codeforces-submissions | 04abcd8b0632e7cdd2748d8b475eed152d00ed1b | 632f87705ebe421f954a59d99428e7009d021db1 | refs/heads/master | 2023-02-05T08:06:53.500395 | 2019-09-18T16:16:00 | 2020-12-22T14:32:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,653 | cpp | /**
* the_hyp0cr1t3
* 29.06.2020 00:21:19
**/
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
// #define int long long
using namespace std;
#define e "\n"
#define endl "\n"
#define Tp template<class T>
#define Tp2 template<class T1, class T2>
#define Tps template<class T, class... Ts>
#define Tps2 template<class T1, class T2, class... Ts>
#define Tp4 template<class T1, class T2, class T3, class T4>
#define ff first
#define ss second
#define rev(Aa) reverse(Aa.begin(),Aa.end())
#define all(Aa) Aa.begin(),Aa.end()
#define lb lower_bound
#define ub upper_bound
#define rsz resize
#define ins insert
#define mp make_pair
#define pb emplace_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define sz(Xx) (int)(Xx).size()
typedef long long ll;
typedef long double ld;
typedef double db;
using pii = pair<int, int>;
const int MOD = 1000000007; //1e9 + 7
const int INF = 2000000000; //2e9
const ll DESPACITO = 1000000000000000000; //1e18
namespace minmax {
Tp T maxx(const T& A) { return A; }
Tp T minn(const T& A) { return A; }
Tp2 T1 maxx(const T1& A, const T2& B) { return A>B?A:B; }
Tp2 T1 minn(const T1& A, const T2& B) { return A<B?A:B; }
Tps T maxx(const T& A, const Ts&... ts) { T B = maxx(ts...); return A>B?A:B; }
Tps T minn(const T& A, const Ts&... ts) { T B = minn(ts...); return A<B?A:B; }
Tps T chmax(T& A, const Ts&... ts) { A = maxx(A, ts...); return A; }
Tps T chmin(T& A, const Ts&... ts) { A = minn(A, ts...); return A; }
Tp4 void chmax2(T1& A, T2& Aa, const T3& B, const T4& Bb) { if(B > A) A = B, Aa = Bb; }
Tp4 void chmin2(T1& A, T2& Aa, const T3& B, const T4& Bb) { if(B < A) A = B, Aa = Bb; }
}
namespace input {
Tp void re(T&& Xx) { cin >> Xx; }
Tp2 void re(pair<T1,T2>& Pp) { re(Pp.first); re(Pp.second); }
Tp void re(vector<T>& Aa) { for(int i = 0; i < sz(Aa); i++) re(Aa[i]); }
Tp2 void rea(T1&& Aa, T2 t) { for(int i = 0; i < t; i++) re(Aa[i]); }
Tps2 void rea(T1&& Aa, T2 t, Ts&&... ts) { rea(Aa, t); rea(ts...); }
Tp2 void rea1(T1&& Aa, T2 t) { for(int i = 1; i <= t; i++) re(Aa[i]); }
Tps2 void rea1(T1&& Aa, T2 t, Ts&... ts) { rea1(Aa, t); rea1(ts...); }
Tps void re(T&& t, Ts&... ts) { re(t); re(ts...); }
}
namespace output {
void pr(int32_t Xx) { cout << Xx; }
// void pr(num Xx) { cout << Xx; }
void pr(bool Xx) { cout << Xx; }
void pr(long long Xx) { cout << Xx; }
void pr(long long unsigned Xx) { cout << Xx; }
void pr(double Xx) { cout << Xx; }
void pr(char Xx) { cout << Xx; }
void pr(const string& Xx) { cout << Xx; }
void pr(const char* Xx) { cout << Xx; }
void pr(const char* Xx, size_t len) { cout << string(Xx, len); }
void ps() { cout << endl; }
void pn() { /*do nothing*/ }
void pw() { pr(" "); }
void pc() { pr("]"); ps(); }
Tp2 void pr(const pair<T1,T2>& Xx) { pr(Xx.first); pw(); pr(Xx.second);}
Tp void pr(const T&);
bool parse(const char* t) { if(t == e) return true; return false;}
Tp bool parse(T&& t) { return false;}
Tp2 bool parsepair(const pair<T1,T2>& Xx) { return true; }
Tp bool parsepair(T&& t) { return false;}
Tp2 void psa(T1&& Aa, T2 t) { for(int i = 0; i < t; i++) pr(Aa[i]), pw(); ps(); }
Tp2 void pna(T1&& Aa, T2 t) { for(int i = 0; i < t; i++) pr(Aa[i]), ps(); }
Tp2 void psa2(T1&& Aa, T2 t1, T2 t2) { for(int i = 0; i < t1; i++) {for(int j = 0; j < t2; j++) pr(Aa[i][j]), pw(); ps();} }
Tp void pr(const T& Xx) { if(!sz(Xx)) return; bool fst = 1; bool op = 0; if (parsepair(*Xx.begin())) op = 1; for (const auto& Aa: Xx) {if(!fst) pw(); if(op) pr("{"); pr(Aa), fst = 0; if(op) pr("}"); } }
Tps void pr(const T& t, const Ts&... ts) { pr(t); pr(ts...); }
Tps void ps(const T& t, const Ts&... ts) { pr(t); if (sizeof...(ts)) {if (!parse(t)) pw(); } ps(ts...); }
Tp void pn(const T& t) { for (const auto& Aa: t) ps(Aa); }
Tps void pw(const T& t, const Ts&... ts) { pr(t); if (sizeof...(ts)) pw(); pw(ts...); }
Tps void pc(const T& t, const Ts&... ts) { bool op = 0; if (parsepair(t)) op = 1; if(op) pr("{"); pr(t); if(op) pr("}"); if (sizeof...(ts)) pr(", "); pc(ts...); }
namespace trace {
#define tr(Xx...) pr("[",#Xx,"] = ["), pc(Xx);
#define tra(Xx, y...) __f0(#Xx, Xx, y)
#define tran(Xx, n) __fn(n, #Xx, Xx) // TO DO~ variadic multidimensional
Tp2 void __f(const char* name, const T1& Xx, const T2& y){ pr("[",y,"] = "); ps(Xx); }
Tps2 void __f(const char* name, const T1& Xx, const T2& y, const Ts&... rest){ const char *open = strchr(name, '['); pr("[",y,"]"); __f(open+1, Xx, rest...); }
Tps2 void __f0(const char* name, const T1& Xx, const T2& y, const Ts&... rest){ const char *open = strchr(name, '['); pr(name, size_t(open-name)); __f(name, Xx, y, rest...); }
Tp void __fn(int n, const char* name, const T& Xx) { for(int i = 0; i < n; i++) pr(name), __f(name, Xx[i], i); }
}
}
using namespace minmax;
using namespace input;
using namespace output;
using namespace output::trace;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 5;
int solve () {
int i, n, bal = 0, ans = 0; string s;
re(n, s);
for(i = 0; i < n; i++) {
bal += s[i] == '('? 1 : -1;
if(bal < 0) ans++, bal++;
}
ps(ans);
return 0;
}
int32_t main() {
IOS;
int Q;
for(cin >> Q; Q; Q--)
solve();
return 0;
}
/**
T&e CockrhaIh King sits pn his jhro#e
WmtB t^e Midas toXcs a$d a heaet of ftone
An empirC build o, Euile and gHHed
A bleediRg grLtnd for IhosO eh. heeM
**/ | [
"ghriday.bits@gmail.com"
] | ghriday.bits@gmail.com |
f4e0e2ea541334ae4d91599cfb7e28598aee2305 | a4524acb1145cbcfd6b437a0b94ae9ea8f8da984 | /packages/wall_following/src/WallFollowing2.cpp | f141c6842abcd81e6d426013a83759f91c5ccfec | [] | no_license | vladakolic/robot2013 | a291a981f37b42bc51262d087d071c39ee805fc1 | c1c41bcbf18651fec0271af5d29d07518c84a1a2 | refs/heads/master | 2021-01-01T16:19:11.087714 | 2014-04-09T22:17:44 | 2014-04-09T22:17:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,828 | cpp | #include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstdlib>
#include "ros/ros.h"
#include <ir_obstacle_detection/IRObstacleSignal.h>
ros::Subscriber g_WallDetection;
// information received from IR sensors
float g_CanMoveForward;
float g_CanMoveBack;
float g_CanTurnLeft;
float g_CanTurnRight;
float g_fThetaLeft;
float g_fThetaRight;
float g_fLeftHypoLength;
float g_fRightHypoLength;
int g_iTurningDegrees;
bool g_bCheckTurningDirection;
void receiveObstacleData(const ir_obstacle_detection::IRObstacleSignal::ConstPtr& pMsg){
/*
ROS_INFO("front: %d", pMsg->front);
ROS_INFO("front left : %d", pMsg->front_left);
ROS_INFO("front right : %d", pMsg->front_right);
ROS_INFO("rear left : %d", pMsg->rear_left);
ROS_INFO("rear right : %d", pMsg->rear_right);
ROS_INFO("back: %d", pMsg->back);
*/
// checks which way we can turn... More solid approach is turn slightly to the right if
// pMsg->front_left is closer to the wall than pMsg->rear_left, etc. Then input message
// should be float, not boolean.
g_CanMoveForward = !pMsg->front;
g_CanMoveBack = !pMsg->back;
g_CanTurnLeft = !(pMsg->front_left || pMsg->rear_left);
g_CanTurnRight = !(pMsg->front_right || pMsg->rear_right);
g_fThetaLeft = pMsg->left_theta;
g_fThetaRight = pMsg->right_theta;
g_fLeftHypoLength = pMsg->left_hypo_length;
g_fRightHypoLength = pMsg->right_hypo_length;
ROS_INFO("left hypotenuse length = %f", g_fLeftHypoLength);
ROS_INFO("right hypotenuse length = %f", g_fRightHypoLength);
ROS_INFO("theta left = %f", 360*g_fThetaLeft/(2*M_PI));
ROS_INFO("theta right = %f", 360*g_fThetaRight/(2*M_PI));
}
/**
* Method that decides the moving direction of the robot. This should only
* be checked before deciding a moving direction, not during.
* @return
* the direction (in degrees) to turn, i.e.
* 0 -> move forward
* 90 -> turn left 90 degrees
* -90 -> turn right 90 degrees
* 180 -> turn around 180 degrees
* number higher than 360 -> no available direction to turn
*/
int calculateMovingDirection(){
bool left = true, right = true;
if (g_fLeftHypoLength != 0 && g_fRightHypoLength != 0){
float r = static_cast <float> (rand()) / static_cast <float> (RAND_MAX);
if(r > 0.5f)
right = false;
else
left = false;
} else if (g_fLeftHypoLength != 0 && left){
return 180*g_fThetaLeft/M_PI;
} else if(g_fRightHypoLength != 0 && right){
return -180*g_fThetaRight/M_PI;
} else {
return 0; // move forwards
}
}
void debugPrint(){
int decision = calculateMovingDirection();
ROS_INFO("moving direction: %d", decision);
//ROS_INFO("check turning direction? %d", g_bCheckTurningDirection);
}
void moveRobot(){
debugPrint();
if (g_bCheckTurningDirection) {
g_iTurningDegrees = calculateMovingDirection();
}
if (g_iTurningDegrees == 0){
// keep moving forward
g_bCheckTurningDirection = true;
} else if (g_iTurningDegrees > 360) {
// dont know what to do here. try turning 45 degrees maybe?
// in this case we might be able to twist and turn our way out of this mess.
} else {
// turn the robot degrees_to_turn degrees.
g_bCheckTurningDirection = false; // have to finish this turn before we check what direction to turn again
// TODO: TURN THE ROBOT g_TurningDirection DEGREES HERE.
// SET g_bCheckTurningDirection TO TRUE WHEN THIS IS DONE.
}
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "wall_following");
ros::NodeHandle n;
g_WallDetection = n.subscribe("/ir_obstacle_detection/IRObstacleSignal", 100, receiveObstacleData); // message from ir sensors
ros::Rate loop_rate(50);
while (ros::ok())
{
moveRobot();
loop_rate.sleep();
ros::spinOnce();
}
return EXIT_SUCCESS;
} | [
"vladann@kth.se"
] | vladann@kth.se |
c9ca3400eb5fb289cf202e19ebc8a5e859429743 | e037bb10c54ee4f60fbcfd99eddd3f486cd77fb1 | /blaze/math/Column.h | 4c66f268e10203910dc7d1de301f417bdf9d46b8 | [
"BSD-3-Clause"
] | permissive | nimerix/blaze | 5361a69cebd63377d35aa0fe0fbdde6530464cd1 | 55424cc652a7d9af8daa93252e80e70d0581a319 | refs/heads/master | 2021-08-19T07:10:01.018036 | 2017-11-08T09:40:20 | 2017-11-08T09:40:20 | 111,974,363 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,711 | h | //=================================================================================================
/*!
// \file blaze/math/Column.h
// \brief Header file for the complete Column implementation
//
// Copyright (C) 2012-2017 Klaus Iglberger - All Rights Reserved
//
// This file is part of the Blaze library. You can redistribute it and/or modify it under
// the terms of the New (Revised) BSD License. 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.
// 3. Neither the names of the Blaze development group nor the names of its contributors
// may be used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
*/
//=================================================================================================
#ifndef _BLAZE_MATH_COLUMN_H_
#define _BLAZE_MATH_COLUMN_H_
//*************************************************************************************************
// Includes
//*************************************************************************************************
#include <blaze/math/Aliases.h>
#include <blaze/math/constraints/Column.h>
#include <blaze/math/constraints/DenseVector.h>
#include <blaze/math/constraints/SparseVector.h>
#include <blaze/math/Exception.h>
#include <blaze/math/smp/DenseVector.h>
#include <blaze/math/smp/SparseVector.h>
#include <blaze/math/views/Column.h>
#include <blaze/math/views/Row.h>
#include <blaze/util/Random.h>
#include <blaze/util/typetraits/RemoveReference.h>
namespace blaze {
//=================================================================================================
//
// RAND SPECIALIZATION FOR DENSE COLUMNS
//
//=================================================================================================
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Specialization of the Rand class template for dense columns.
// \ingroup random
//
// This specialization of the Rand class randomizes dense columns.
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
class Rand< Column<MT,SO,true,SF,CCAs...> >
{
public:
//**Randomize functions*************************************************************************
/*!\name Randomize functions */
//@{
template< typename CT >
inline void randomize( CT&& column ) const;
template< typename CT, typename Arg >
inline void randomize( CT&& column, const Arg& min, const Arg& max ) const;
//@}
//**********************************************************************************************
};
/*! \endcond */
//*************************************************************************************************
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Randomization of a dense column.
//
// \param column The column to be randomized.
// \return void
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
template< typename CT > // Type of the column
inline void Rand< Column<MT,SO,true,SF,CCAs...> >::randomize( CT&& column ) const
{
using blaze::randomize;
using ColumnType = RemoveReference_<CT>;
BLAZE_CONSTRAINT_MUST_BE_COLUMN_TYPE( ColumnType );
BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE( ColumnType );
for( size_t i=0UL; i<column.size(); ++i ) {
randomize( column[i] );
}
}
/*! \endcond */
//*************************************************************************************************
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Randomization of a dense column.
//
// \param column The column to be randomized.
// \param min The smallest possible value for a column element.
// \param max The largest possible value for a column element.
// \return void
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
template< typename CT // Type of the column
, typename Arg > // Min/max argument type
inline void Rand< Column<MT,SO,true,SF,CCAs...> >::randomize( CT&& column, const Arg& min, const Arg& max ) const
{
using blaze::randomize;
using ColumnType = RemoveReference_<CT>;
BLAZE_CONSTRAINT_MUST_BE_COLUMN_TYPE( ColumnType );
BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE( ColumnType );
for( size_t i=0UL; i<column.size(); ++i ) {
randomize( column[i], min, max );
}
}
/*! \endcond */
//*************************************************************************************************
//=================================================================================================
//
// RAND SPECIALIZATION FOR SPARSE COLUMNS
//
//=================================================================================================
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Specialization of the Rand class template for sparse columns.
// \ingroup random
//
// This specialization of the Rand class randomizes sparse columns.
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
class Rand< Column<MT,SO,false,SF,CCAs...> >
{
public:
//**Randomize functions*************************************************************************
/*!\name Randomize functions */
//@{
template< typename CT >
inline void randomize( CT&& column ) const;
template< typename CT >
inline void randomize( CT&& column, size_t nonzeros ) const;
template< typename CT, typename Arg >
inline void randomize( CT&& column, const Arg& min, const Arg& max ) const;
template< typename CT, typename Arg >
inline void randomize( CT&& column, size_t nonzeros, const Arg& min, const Arg& max ) const;
//@}
//**********************************************************************************************
};
/*! \endcond */
//*************************************************************************************************
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Randomization of a sparse column.
//
// \param column The column to be randomized.
// \return void
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
template< typename CT > // Type of the column
inline void Rand< Column<MT,SO,false,SF,CCAs...> >::randomize( CT&& column ) const
{
using ColumnType = RemoveReference_<CT>;
using ElementType = ElementType_<ColumnType>;
BLAZE_CONSTRAINT_MUST_BE_COLUMN_TYPE( ColumnType );
BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE( ColumnType );
const size_t size( column.size() );
if( size == 0UL ) return;
const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*size ) ) );
column.reset();
column.reserve( nonzeros );
while( column.nonZeros() < nonzeros ) {
column[ rand<size_t>( 0UL, size-1UL ) ] = rand<ElementType>();
}
}
/*! \endcond */
//*************************************************************************************************
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Randomization of a sparse column.
//
// \param column The column to be randomized.
// \param nonzeros The number of non-zero elements of the random column.
// \return void
// \exception std::invalid_argument Invalid number of non-zero elements.
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
template< typename CT > // Type of the column
inline void Rand< Column<MT,SO,false,SF,CCAs...> >::randomize( CT&& column, size_t nonzeros ) const
{
using ColumnType = RemoveReference_<CT>;
using ElementType = ElementType_<ColumnType>;
BLAZE_CONSTRAINT_MUST_BE_COLUMN_TYPE( ColumnType );
BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE( ColumnType );
const size_t size( column.size() );
if( nonzeros > size ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid number of non-zero elements" );
}
if( size == 0UL ) return;
column.reset();
column.reserve( nonzeros );
while( column.nonZeros() < nonzeros ) {
column[ rand<size_t>( 0UL, size-1UL ) ] = rand<ElementType>();
}
}
/*! \endcond */
//*************************************************************************************************
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Randomization of a sparse column.
//
// \param column The column to be randomized.
// \param min The smallest possible value for a column element.
// \param max The largest possible value for a column element.
// \return void
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
template< typename CT // Type of the column
, typename Arg > // Min/max argument type
inline void Rand< Column<MT,SO,false,SF,CCAs...> >::randomize( CT&& column, const Arg& min, const Arg& max ) const
{
using ColumnType = RemoveReference_<CT>;
using ElementType = ElementType_<ColumnType>;
BLAZE_CONSTRAINT_MUST_BE_COLUMN_TYPE( ColumnType );
BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE( ColumnType );
const size_t size( column.size() );
if( size == 0UL ) return;
const size_t nonzeros( rand<size_t>( 1UL, std::ceil( 0.5*size ) ) );
column.reset();
column.reserve( nonzeros );
while( column.nonZeros() < nonzeros ) {
column[ rand<size_t>( 0UL, size-1UL ) ] = rand<ElementType>( min, max );
}
}
/*! \endcond */
//*************************************************************************************************
//*************************************************************************************************
/*! \cond BLAZE_INTERNAL */
/*!\brief Randomization of a sparse column.
//
// \param column The column to be randomized.
// \param nonzeros The number of non-zero elements of the random column.
// \param min The smallest possible value for a column element.
// \param max The largest possible value for a column element.
// \return void
// \exception std::invalid_argument Invalid number of non-zero elements.
*/
template< typename MT // Type of the matrix
, bool SO // Storage order
, bool SF // Symmetry flag
, size_t... CCAs > // Compile time column arguments
template< typename CT // Type of the column
, typename Arg > // Min/max argument type
inline void Rand< Column<MT,SO,false,SF,CCAs...> >::randomize( CT&& column, size_t nonzeros,
const Arg& min, const Arg& max ) const
{
using ColumnType = RemoveReference_<CT>;
using ElementType = ElementType_<ColumnType>;
BLAZE_CONSTRAINT_MUST_BE_COLUMN_TYPE( ColumnType );
BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE( ColumnType );
const size_t size( column.size() );
if( nonzeros > size ) {
BLAZE_THROW_INVALID_ARGUMENT( "Invalid number of non-zero elements" );
}
if( size == 0UL ) return;
column.reset();
column.reserve( nonzeros );
while( column.nonZeros() < nonzeros ) {
column[ rand<size_t>( 0UL, size-1UL ) ] = rand<ElementType>( min, max );
}
}
/*! \endcond */
//*************************************************************************************************
} // namespace blaze
#endif
| [
"klaus.iglberger@gmail.com"
] | klaus.iglberger@gmail.com |
88b76a4fac088d3fce38ff8d647ce08f44c883a4 | 2ba3b252d820fd9c7934c4a6fcc8d3b6c044a83f | /node.cpp | b1bde97d795ecc8be0fe1628f600964346dbcd12 | [] | no_license | ChiruBogdan99/POO-BST | e360797a12b7092f45ef846dacfe43a971e970b2 | 8557c150c95c1acd466c661c1027af512ac7d2ba | refs/heads/master | 2020-05-01T23:41:42.971316 | 2019-03-25T21:31:32 | 2019-03-25T21:31:32 | 177,667,459 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 70 | cpp | #include "node.h"
node::node()
{
}
node::~node()
{
}
| [
"noreply@github.com"
] | noreply@github.com |
428c6c057f6abd512e08b7be5121d795326faefe | 6ccff9f0cc190526f55bc8b1fce5f646c87308d7 | /adRec-9/src/ofApp.cpp | ed4b22157e8117bbfd0a4f2cc8d21a63b50ae902 | [] | no_license | khniehaus/Assembling-Desire | f57842bb0ffce9d6301ae80b96cc6126f9214a2f | 1cb5dcc1cdefbdcd38862587919a532727d6d2e2 | refs/heads/master | 2020-07-20T12:51:16.633160 | 2016-09-11T19:30:06 | 2016-09-11T19:30:06 | 67,947,988 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,620 | cpp | #include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
receiver.setup(PORT); //set up osc receiver
string vPath1 = ofToDataPath("../../../adRec/bin/data/1.mov",true); //set up data path for sequence 1
string vPath2 = ofToDataPath("../../../adRec/bin/data/2.mov",true); //set up data path for sequence 2
string vPath3 = ofToDataPath("../../../adRec/bin/data/3.mov",true); //set up data path for sequence 3
sound1.load("breathe8.wav"); //load sound
sound1.setLoop(true); //loop the sound file
sound1.setSpeed(1.0); //set normal speed for sound (range 0-2.0)
sound1.setVolume(0.6f); //set volume (0-1)
player1.loadMovie(vPath1); //load sequence 1 via data path
player2.loadMovie(vPath2); //load sequence 2 via data path
player3.loadMovie(vPath3); //load sequence 3 via data path
im1.loadImage("4.jpg"); //load sequence 4 image
im2.loadImage("5.jpg"); //load sequence 5 image
im1.resize(ofGetWidth(), ofGetHeight()); //resize image 4 to screen
im2.resize(ofGetWidth(), ofGetHeight()); //resize image 5 to screen
sound1.play(); //play the sound file
}
//--------------------------------------------------------------
void ofApp::update(){
while(receiver.hasWaitingMessages()){ //while there are osc messages coming in
ofxOscMessage v; //osc message variable
receiver.getNextMessage(&v); //receive next message at osc variable address
if(v.getAddress()=="/touch"){ //if the osc message received is prefixed 'touch'
//don't receive messages without the correct prefix
val=v.getArgAsInt32(0); //data should be int
}
if(val >= 3){ //if incoming data is 3 or above (10 possible)
sound1.setSpeed(val/5.0); //increase speed according to data value (0-2.0)
}
}
}
//--------------------------------------------------------------
void ofApp::draw(){
im2.draw(0,0,ofGetWidth(), ofGetHeight()); //play on start
if (val == 2){ //if val is 2
im1.draw(0,0, ofGetWidth(), ofGetHeight()); //sequence 4
}
if (val == 3){ //if val is 3
im2.draw(0,0, ofGetWidth(), ofGetHeight()); //sequence 5
}
if (val == 5){ // if val is 5
player1.draw(0,0,ofGetWidth(), ofGetHeight()); //sequence 1
}
if (val == 7){ //if val is 7
player2.draw(0,0, ofGetWidth(), ofGetHeight()); //sequence 2
}
if (val == 8){ //if val is 8
player3.draw(0,0, ofGetWidth(), ofGetHeight()); //sequence 3
}
if (val == 10){ //if val is 10
sound1.setVolume(1.0); //play sound full volume
//each sound is contained in the individual code for the Pi it runs on and has a separate trigger area
//while all of them have the image and video sequence, though each is different
}
}
| [
"KHNiehaus@kiona.eduroam.campus"
] | KHNiehaus@kiona.eduroam.campus |
a61387131ea080bd07b209624f7a7048577beb40 | 3a4e2d550cabad0cd7a6951c8da8e9afe877a20c | /ofxHTTP/libs/ofxHTTP/include/ofx/HTTP/ServerEvents.h | c30c90cd90447bc44a40a7ba754db542e01eaad5 | [] | no_license | Hiroki11x/ofxCustomAddons | cc792c0718ee487d66e97331d0039fd9e14e2b87 | 7949d05ca2cb5615671567a4bb3fc4c637b6e885 | refs/heads/master | 2020-12-25T09:08:57.995731 | 2016-08-06T10:20:48 | 2016-08-06T10:20:48 | 59,759,850 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,590 | h | // =============================================================================
//
// Copyright (c) 2013-2015 Christopher Baker <http://christopherbaker.net>
//
// 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.
//
// =============================================================================
#pragma once
#include "Poco/UUID.h"
#include "Poco/Net/MediaType.h"
#include "Poco/Net/NameValueCollection.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "ofEvents.h"
#include "ofx/HTTP/AbstractServerTypes.h"
namespace ofx {
namespace HTTP {
/// \brief An event describing a server request.
class ServerEventArgs: public ofEventArgs
{
public:
/// \brief Construct the ServerEventArgs.
/// \param request the Poco::Net::HTTPServerRequest.
/// \param response the Poco::Net::HTTPServerResponse.
/// \param session The AbstractSession associated with this event.
ServerEventArgs(Poco::Net::HTTPServerRequest& request,
Poco::Net::HTTPServerResponse& response,
AbstractSession& session):
_request(request),
_response(response),
_session(session)
{
}
/// \brief Destroy the ServerEventArgs.
virtual ~ServerEventArgs()
{
}
/// \brief Get the Poco::Net::HTTPServerRequest.
/// \return the Poco::Net::HTTPServerRequest.
Poco::Net::HTTPServerRequest& getRequest()
{
return _request;
}
/// \brief Get the Poco::Net::HTTPServerResponse.
/// \return the Poco::Net::HTTPServerResponse.
Poco::Net::HTTPServerResponse& getResponse()
{
return _response;
}
/// \brief Get the session associated with this event.
/// \returns the session associated with this event.
AbstractSession& getSession()
{
return _session;
}
protected:
/// \brief A reference to the server request.
Poco::Net::HTTPServerRequest& _request;
/// \brief Callbacks are permitted to set the response.
///
/// \warning Before working with the response, the callback must check the
/// HTTPServerResponse::sent() method to ensure that the response stream
/// is still available available.
Poco::Net::HTTPServerResponse& _response;
/// \brief The session associated with the event.
AbstractSession& _session;
};
/// \brief A class describing a set of low level HTTP server events.
class ServerEvents
{
public:
/// \brief The onHTTPServerEvent event.
ofEvent<ServerEventArgs> onHTTPServerEvent;
};
} } // namespace ofx::HTTP
| [
"hiroki11x@gmail.com"
] | hiroki11x@gmail.com |
878b091c89e1d70a38af365e8658ae2f43037ebd | 7195ef5a7df65115eef2225ca44ea85587917195 | /gengine_lib/src/gcore/components/extent_component.cpp | f254d933d6833131a8bd3cc6bb041cf2ca2224bf | [] | no_license | GuillaumeArruda/GEngine | dd4f645cc92730aa76040550d355fba5b41c6e1c | 8be545426d90b57bda184864e73e1329907ace65 | refs/heads/main | 2023-08-08T00:33:17.431719 | 2023-07-19T21:25:36 | 2023-07-19T21:25:36 | 321,533,177 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 220 | cpp | #include "stdafx.h"
#include "extent_component.h"
GSERIALIZER_DEFINE_SUBCLASS_FACTORY_REGISTRATION(gcore::extent_component);
namespace gcore
{
void extent_component::process(gserializer::serializer&)
{
}
}
| [
"guillaume.arruda@gmail.com"
] | guillaume.arruda@gmail.com |
6d51c80436d4a6d0b856654b6cabfc6839a9cf16 | 9a04d2dd7bed9ea3655850448f8f33df3ff0884f | /Расчёт зарплаты/Worker.cpp | fc12d76fa7a595d6f2fec64b87dbbe117fb1f492 | [] | no_license | SergeyRoznyuk/Calculating-the-parameters-of-the-working-day | a61db43ca8f6b77c40b2b5af68fe2f113ce75146 | 06e514c5a3b27cfb8f9b8c12817889515c803de6 | refs/heads/master | 2020-06-24T01:44:48.817748 | 2019-07-25T10:42:00 | 2019-07-25T10:42:00 | 198,812,455 | 0 | 0 | null | null | null | null | WINDOWS-1251 | C++ | false | false | 24,054 | cpp | #include<iostream>
#include<math.h>
#include<string>
#include "Worker.h"
using std::cout;
using std::cin;
void enterTheText(char *&mas)
{
char str[256];
cin >> str;
int size = strlen(str) + 1;
if (mas != nullptr)
{
delete mas;
}
mas = new char[size];
for (int i = 0; i < size; i++)
{
mas[i] = str[i];
}
}
Time::Time()
{
hour = 0;
minute = 0;
}
Time::Time(int hour, int minute)
{
this->hour = hour;
this->minute = minute;
}
int Time::getHour()
{
return hour;
}
int Time::getMinute()
{
return minute;
}
void Time::setHour(int hour)
{
this->hour = hour;
}
void Time::setMinute(int minute)
{
this->minute = minute;
}
Time Time::operator+(const Time &obj)
{
Time tmp;
tmp.minute = minute + obj.minute;
tmp.hour = hour + obj.hour+tmp.minute/60;
tmp.minute %= 60;
return tmp;
}
Time Time:: operator-(const Time &obj)
{
Time tmp;
int adjustment = 1;
if (*this > obj)
{
adjustment = -1;
}
if (adjustment*minute>adjustment*obj.minute)
{
tmp.hour = obj.hour*adjustment - hour*adjustment - 1;
tmp.minute = 60-(minute * adjustment - obj.minute*adjustment);
}
else
{
tmp.hour = obj.hour*adjustment - hour*adjustment;
tmp.minute = obj.minute * adjustment - minute*adjustment;
}
return tmp;
}
bool Time:: operator>(const Time &obj)
{
if ((hour * 60 + minute) > (obj.hour * 60 + obj.minute))
{
return true;
}
else
{
return false;
}
}
bool Time:: operator<(const Time &obj)
{
if ((hour * 60 + minute) < (obj.hour * 60 + obj.minute))
{
return true;
}
else
{
return false;
}
}
bool Time::operator==(const Time &obj)
{
if (hour == obj.hour && minute == obj.minute)
{
return true;
}
else
{
return false;
}
}
bool Time::operator>=(const Time &obj)
{
if ((hour * 60 + minute) >= (obj.hour * 60 + obj.minute))
{
return true;
}
else
{
return false;
}
}
bool Time::operator<=(const Time &obj)
{
if ((hour * 60 + minute) <= (obj.hour * 60 + obj.minute))
{
return true;
}
else
{
return false;
}
}
void Time::Print()
{
if (hour < 10)
{
cout << "0" << hour;
}
else
{
cout << hour;
}
cout << ":";
if (minute < 10)
{
cout << "0" << minute;
}
else
{
cout << minute;
}
}
float Time::convertInHour()
{
float tmp;
tmp = hour + minute / 60.0;
return tmp;
}
Time::~Time(){}
WorkDay::WorkDay()
{
double_work_day=0;
work_day_before_holiday=0;
work_day_holiday=0;
work_hours=0;
work_evening_hours=0;
work_nite_hours=0;
work_holiday_hours=0;
}
Time WorkDay::getBeginWorkDay()
{
return begin_work_day;
}
Time WorkDay::getBeginBreak()
{
return begin_break;
}
Time WorkDay::getEndBreak()
{
return end_break;
}
Time WorkDay::getEndWorkDay()
{
return end_work_day;
}
Time WorkDay::getEveningTime()
{
return evening_time;
}
Time WorkDay::getNiteTime()
{
return nite_time;
}
Time WorkDay::getEndNiteTime()
{
return end_nite_time;
}
void WorkDay::setBeginWorkDay(int hour, int minute)
{
bool control = 1;
do
{
if ((hour > -1 && hour<25) && (minute>-1 && minute < 61))
{
begin_work_day.setHour(hour);
begin_work_day.setMinute(minute);
control = 0;
}
else if (hour < 0 || hour>24)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-hour: ";
cin >> hour;
}
else if (minute<0 || minute > 60)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-minute: ";
cin >> minute;
}
} while (control == 1);
}
void WorkDay::setBeginBreak(int hour, int minute)
{
bool control = 1;
do
{
if ((hour > -1 && hour<25) && (minute>-1 && minute < 61))
{
begin_break.setHour(hour);
begin_break.setMinute(minute);
control = 0;
}
else if (hour < 0 || hour>24)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-hour: ";
cin >> hour;
}
else if (minute<0 || minute > 60)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-minute: ";
cin >> minute;
}
} while (control == 1);
}
void WorkDay::setEndWorkDay(int hour, int minute)
{
bool control = 1;
do
{
if ((hour > -1 && hour<25) && (minute>-1 && minute < 61))
{
end_work_day.setHour(hour);
end_work_day.setMinute(minute);
control = 0;
}
else if (hour < 0 || hour>24)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-hour: ";
cin >> hour;
}
else if (minute<0 || minute > 60)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-minute: ";
cin >> minute;
}
} while (control == 1);
}
void WorkDay::setEndBreak(int hour, int minute)
{
bool control = 1;
do
{
if ((hour > -1 && hour<25) && (minute>-1 && minute < 61))
{
end_break.setHour(hour);
end_break.setMinute(minute);
control = 0;
}
else if (hour < 0 || hour>24)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-hour: ";
cin >> hour;
}
else if (minute<0 || minute > 60)
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "-minute: ";
cin >> minute;
}
} while (control == 1);
}
void WorkDay::setAll()
{
bool control = 1;
char choice;
cout << "Does the work day move on to the next day?(y/n)\n";
do
{
choice = getchar();
if (choice == 'y')
{
double_work_day =1;
control = 0;
}
else if (choice == 'n')
{
double_work_day = 0;
control = 0;
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
}
} while (control == 1);
int adjustment = 1; //переменная для контроля начала и окончания рабочей смены (не позволяет начало смены записать в конец и наоборот)
if (double_work_day == 1)
{
adjustment = -1;
}
int hour, minute;
cout << "Enter the begining of the work day:\n";
cout << "-hour - ";
cin >> hour;
cout << "-minute - ";
cin >> minute;
setBeginWorkDay(hour, minute);
control = 1;
do
{
cout << "Enter the ending of the work day:\n";
cout << "-hour - ";
cin >> hour;
cout << "-minute - ";
cin >> minute;
if (begin_work_day.convertInHour()*adjustment <= (hour + minute / 60.0) * adjustment)
{
control = 0;
setEndWorkDay(hour, minute);
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "1. Change the begining of the work day;\n";
cout << "2. Change the ending of the work day;\n";
int select;
cin >> select;
if (select == 1)
{
cout << "Enter the begining of the work day:\n";
cout << "-hour - ";
cin >> hour;
cout << "-minute - ";
cin >> minute;
setBeginWorkDay(hour, minute);
}
}
} while (control == 1);
cout << "Does the work day have a break?(y/n)\n";
control = 1;
do
{
cin >> choice;
if (choice == 'y')
{
do
{
cout << "Enter the begining of the break:\n";
cout << "-hour - ";
cin >> hour;
cout << "-minute - ";
cin >> minute;
if ((double_work_day == 0 && (Time(hour, minute) > begin_work_day && Time(hour, minute) < end_work_day)) || (double_work_day == 1 && ((Time(hour, minute) > begin_work_day && Time(hour, minute)<=Time(24,0)) || (Time(hour, minute)>=Time(0, 0) && Time(hour, minute) < end_work_day))))
{
setBeginBreak(hour, minute);
control = 0;
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
}
} while (control == 1);
control = 1;
do
{
cout << "Enter the ending of the break:\n";
cout << "-hour - ";
cin >> hour;
cout << "-minute - ";
cin >> minute;
if ((double_work_day == 0 && (Time(hour, minute) > begin_break && Time(hour, minute) < end_work_day)) || (double_work_day == 1 && ((Time(hour, minute) > begin_break && Time(hour, minute)<=Time(24, 0)) || (Time(hour, minute)>=Time(0, 0) && Time(hour, minute) < end_work_day))))
{
control = 0;
setEndBreak(hour, minute);
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
}
} while (control == 1);
}
else if (choice == 'n')
{
control = 0;
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
}
} while (control == 1);
calculateAllTypeHours();
}
void WorkDay::setWorkDayBeforeHoliday(bool a)
{
work_day_before_holiday = a;
}
void WorkDay::setWorkDayHoliday(bool a)
{
work_day_holiday = a;
}
float WorkDay::timeInsideWorkDay(Time begin, Time begin_inside, Time end_inside, Time end)
{
float tmp=0.0;
for (int i = begin.getHour(); i <= end.getHour(); i++)
{
if (begin.getHour() <= begin_inside.getHour())
{
if (i > begin_inside.getHour() && i <= end_inside.getHour())
{
tmp++;
}
}
else if (i > begin.getHour() && i <= end_inside.getHour())
{
tmp++;
}
}
if (begin_inside <= begin && begin <= end_inside)
{
tmp -= (begin.getMinute() / 60.0);
}
if (begin_inside <= end && end <= end_inside)
{
tmp += (end.getMinute() / 60.0);
}
return tmp;
}
void WorkDay::calculateWorkHours()
{
if (double_work_day == 0)
{
work_hours = (end_work_day - begin_work_day).convertInHour() - (end_break - begin_break).convertInHour();
}
else
{
if (begin_break<=end_break)
{
work_hours = (Time(24, 0) - begin_work_day + end_work_day).convertInHour() - (end_break - begin_break).convertInHour();
}
else
{
work_hours = (Time(24, 0) - begin_work_day + end_work_day).convertInHour() - (Time(24, 0) - begin_break+end_break).convertInHour();
}
}
}
void WorkDay::calculateWorkEveningHours()
{
if (begin_work_day < end_work_day)
{
work_evening_hours = timeInsideWorkDay(begin_work_day, evening_time, nite_time, end_work_day) - timeInsideWorkDay(begin_break, evening_time, nite_time, end_break);
}
else if (begin_work_day >= end_work_day)
{
work_evening_hours = timeInsideWorkDay(begin_work_day, evening_time, nite_time, Time(24,0));
if (begin_break < end_break)
{
work_evening_hours -= timeInsideWorkDay(begin_break, evening_time, nite_time, end_break);
}
else if (begin_break >= end_break)
{
work_evening_hours -= timeInsideWorkDay(begin_break, evening_time, nite_time, Time(24,0));
}
}
/*if (double_work_day == 0 && begin_work_day<=nite_time && end_work_day>evening_time)
{
if (begin_work_day<=evening_time && end_work_day>=nite_time)
{
work_evening_hours = (nite_time - evening_time).convertInHour();
}
else if (begin_work_day >= evening_time && end_work_day >= nite_time)
{
work_evening_hours = (nite_time-begin_work_day).convertInHour();
}
else if (begin_work_day >= evening_time && end_work_day <= nite_time)
{
work_evening_hours = (end_work_day-begin_work_day).convertInHour();
}
else if (begin_work_day <= evening_time && end_work_day <= nite_time)
{
work_evening_hours = (end_work_day - evening_time).convertInHour();
}
}
else if (double_work_day == 1)
{
if (begin_work_day <= evening_time)
{
work_evening_hours = (nite_time - evening_time).convertInHour();
}
else if (begin_work_day >= evening_time && begin_work_day <= nite_time)
{
work_evening_hours = (nite_time - begin_work_day).convertInHour();
}
}
else
{
work_evening_hours = 0;
}*/
}
void WorkDay::calculateWorkNiteHours()
{
if (begin_work_day < end_work_day)
{
work_nite_hours = timeInsideWorkDay(begin_work_day, nite_time, Time(24, 0), end_work_day) - timeInsideWorkDay(begin_break, nite_time, Time(24, 0), end_break);
}
else if (begin_work_day >= end_work_day)
{
work_nite_hours = timeInsideWorkDay(begin_work_day, nite_time, Time(24, 0), Time(24, 0));
work_nite_hours += timeInsideWorkDay(Time(0, 0), Time(0, 0), end_nite_time, end_work_day);
if (begin_break < end_break)
{
work_nite_hours -= timeInsideWorkDay(begin_break, evening_time, Time(24, 0), end_break);
}
else if (begin_break >= end_break)
{
work_nite_hours -= timeInsideWorkDay(begin_break, nite_time, Time(24, 0), Time(24, 0));
work_nite_hours -= timeInsideWorkDay(Time(0, 0), Time(0, 0), end_nite_time, end_break);
}
}
/*if (double_work_day == 0 && end_work_day>=nite_time)
{
if (begin_work_day <= nite_time)
{
work_nite_hours = (end_work_day-nite_time).convertInHour();
}
else if (begin_work_day >= nite_time)
{
work_nite_hours = (end_work_day - begin_work_day).convertInHour();
}
}
else if (double_work_day == 1)
{
if (begin_work_day <= nite_time && end_work_day <= end_nite_time)
{
work_nite_hours = (Time(24,0)-nite_time).convertInHour()+end_work_day.convertInHour();
}
else if (begin_work_day >= nite_time && end_work_day <= end_nite_time)
{
work_nite_hours = (Time(24, 0) - begin_work_day).convertInHour() + end_work_day.convertInHour();
}
else if (begin_work_day <= nite_time && end_work_day >= end_nite_time)
{
work_nite_hours = (Time(24, 0) - nite_time).convertInHour() + end_nite_time.convertInHour();
}
else if (begin_work_day >= nite_time && end_work_day >= end_nite_time)
{
work_nite_hours = (Time(24, 0) - begin_work_day).convertInHour() + end_nite_time.convertInHour();
}
}
else
{
work_nite_hours = 0;
}*/
}
void WorkDay::calculateWorkHolidayHours()
{
if (double_work_day == 1)
{
if (work_day_holiday == 1)
{
work_holiday_hours = (Time(24, 0) - begin_work_day).convertInHour();
}
if (work_day_before_holiday == 1)
{
work_holiday_hours += end_work_day.convertInHour();
}
}
else if (double_work_day == 0 && work_day_holiday == 1)
{
work_holiday_hours = (end_work_day-begin_work_day).convertInHour();
}
}
void WorkDay::calculateAllTypeHours()
{
calculateWorkHours();
calculateWorkEveningHours();
calculateWorkNiteHours();
calculateWorkHolidayHours();
}
float WorkDay::getWorkHours()
{
return work_hours;
}
float WorkDay::getWorkEveningHours(){
return work_evening_hours;
}
float WorkDay::getWorkNiteHours()
{
return work_nite_hours;
}
float WorkDay::getWorkHolidayHours()
{
return work_holiday_hours;
}
void WorkDay::Print()
{
char symbol = 37;
begin_work_day.Print();
cout << symbol;
begin_break.Print();
cout << " - ";
end_break.Print();
cout << symbol;
end_work_day.Print();
cout << "\nHours:\n";
cout << "- work - " << work_hours << ";\n";
cout << "- evening - " << work_evening_hours << ";\n";
cout << "- nite - " << work_nite_hours << ";\n";
cout << "- holiday - " << work_holiday_hours << ";\n";
}
WorkDay::~WorkDay(){}
Date::Date()
{
day = 0;
month = 0;
year = 0;
}
Date::Date(int year, int month, int day)
{
this->year = year;
this->month = month;
this->day = day;
}
void Date::setDay(int day)
{
bool control = 1;
do
{
if (day > 0 && day<(getDaysInMonth()+1))
{
this->day=day;
control = 0;
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "Day: ";
cin >> day;
}
} while (control == 1);
}
void Date::setMonth(int month)
{
bool control = 1;
do
{
if (month > 0 && month<13)
{
this->month = month;
control = 0;
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
cout << "Month: ";
cin >> month;
}
} while (control == 1);
}
void Date::setYear(int year)
{
this->year = year;
}
void Date::setDate()
{
int y, m, d;
cout << "Enter the year: ";
cin >> y;
setYear(y);
cout << "Enter the month: ";
cin >> m;
setMonth(m);
cout << "Enter the day: ";
cin >> d;
setDay(d);
}
void Date::setDate(int y, int m, int d)
{
setYear(y);
setMonth(m);
setDay(d);
}
void Date::Print()
{
if (day < 10)
{
cout << "0" << day;
}
else
{
cout << day;
}
cout << ".";
if (month < 10)
{
cout << "0" << month;
}
else
{
cout << month;
}
cout << "." << year;
}
int Date::getDay() const
{
return day;
}
int Date::getMonth()
{
return month;
}
int Date::getYear()
{
return year;
}
int Date::getDaysInMonth()
{
if ((year % 4 == 0 || year % 100 != 0 && year % 400 == 0) && month==2)
{
return days_in_month[month-1]+1;
}
else
{
return days_in_month[month - 1];
}
}
int Date::operator-(const Date &a)
{
int vis_years = 0;
int mas_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
for (int i = (year<a.year ? year : a.year); i <= (year>a.year ? year : a.year); i++)
{
if (i % 4 == 0 || i % 100 != 0 && i % 400 == 0)
{
vis_years++;
}
}
int days_in_years = abs(year - a.year) * 365 + vis_years;
int days_in_month = 0;
if (year<a.year ? month<a.month : a.month<month)
{
for (int i = ((year<a.year ? month : a.month) - 1); i<((year<a.year ? a.month : month) - 1); i++)
{
days_in_month += mas_month[i];
}
}
if (year<a.year ? month>a.month:a.month>month)
{
for (int i = ((year<a.year ? a.month : month) - 1); i<((year<a.year ? month : a.month) - 1); i++)
{
days_in_month -= mas_month[i];
}
}
int days = abs(day - a.day);
int sum_days = days_in_years + days_in_month + days;
return sum_days;
}
bool Date::operator==(const Date &obj)
{
if (month == obj.month && day == obj.day && year == obj.year)
{
return true;
}
else
{
return false;
}
}
Date Date::operator+(int a)
{
Date tmp=*this;
int sum = 0;
int mas_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
while (true)
{
while (tmp.month <= 12 && sum < a)
{
while (tmp.day <= mas_month[month - 1] && sum < a)
{
tmp.day++;
sum++;
}
if (sum == a)
{
if (tmp.day>mas_month[month - 1])
{
tmp.day = 1;
tmp.month++;
}
break;
}
tmp.day = 1;
tmp.month++;
}
if (sum == a)
{
if (tmp.month > 12)
{
tmp.month = 1;
tmp.year++;
}
break;
}
tmp.month = 1;
tmp.year++;
}
return tmp;
}
Date::~Date(){}
Holiday::Holiday()
{
size = 11;
//mas = new Date[size]{Date(2017, 1, 1), Date(2017, 1, 7), Date(2017, 3, 8), Date(2017, 4, 16), Date(2017, 5, 1), Date(2017, 5, 2), Date(2017, 5, 9), Date(2017, 6, 4), Date(2017, 6, 28), Date(2017, 8, 24), Date(2017, 10, 14)};
mas = new Date[size];
mas[0] = Date(2017, 1, 1);
mas[1] = Date(2017, 1, 7);
mas[2] = Date(2017, 3, 8);
mas[3] = Date(2017, 4, 16);
mas[4] = Date(2017, 5, 1);
mas[5] = Date(2017, 5, 2);
mas[6] = Date(2017, 5, 9);
mas[7]= Date(2017, 6, 4);
mas[8] = Date(2017, 6, 28);
mas[9] = Date(2017, 8, 24);
mas[10] = Date(2017, 10, 14);
}
Date Holiday::getHoliday(int i)
{
if (i >= 0 && i < size)
{
return mas[i];
}
else
{
return Date(0, 0, 0);
}
}
int Holiday::getSize()
{
return size;
}
Holiday::~Holiday(){}
WorkShedule::WorkShedule()
{
size_shedule=24;
counter_size_shedule=0;
name_work_shedule = nullptr;
//*date_shedule = nullptr;
date_shedule = nullptr;
//*shedule=nullptr;
shedule = nullptr;
template_shedule = nullptr;
number_of_shift = 1;
lenght_reiteration_work_day = nullptr;
lenght_reiteration_rest_day = nullptr;
memory[0]=0;
memory[1] = 0;
memory[2] = 0;
number_of_brigades = 1;
}
void WorkShedule::setNumberOfShift(int number)
{
number_of_shift = number;
}
void WorkShedule::setNumberOfBrigades(int number)
{
number_of_brigades = number;
}
void WorkShedule::setMemory(int a, int b, int c)
{
memory[0] = a;
memory[1] = b;
memory[2] = c;
}
int WorkShedule:: operator[](int position)
{
return memory[position];
}
void WorkShedule::createTemplateShedule()
{
int number;
cout << "How much shifts do work day have?\n";
cin>>number;
setNumberOfShift(number);
template_shedule = new WorkDay[number_of_shift];
lenght_reiteration_work_day = new int[number_of_shift];
lenght_reiteration_rest_day = new int[number_of_shift];
for (int i = 0; i < number_of_shift; i++)
{
cout << i + 1 << "'st shift:\n";
template_shedule[i].setAll();
template_shedule[i].calculateAllTypeHours();
cout << "Number reiterations this work day: ";
cin >> lenght_reiteration_work_day[i];
cout << "Number reiterations rest day after this work day: ";
cin >> lenght_reiteration_rest_day[i];
}
}
void WorkShedule::manualCreateShedule()
{
int tmp;
if (counter_size_shedule == 0)
{
cout << "Enter the name of this shedule: ";
enterTheText(name_work_shedule);
cin.ignore();
cout << "Enter the current year: ";
cin >> tmp;
sample.setYear(tmp);
cout << "Enter the current month: ";
cin >> tmp;
sample.setMonth(tmp);
createTemplateShedule();
}
date_shedule = new Date*[size_shedule];
shedule = new WorkDay*[size_shedule];
date_shedule[counter_size_shedule] = new Date[sample.getDaysInMonth()];
shedule[counter_size_shedule] = new WorkDay[sample.getDaysInMonth()];
for (int i = 0; i < sample.getDaysInMonth(); i++)
{
date_shedule[counter_size_shedule][i].setDate(sample.getYear(), sample.getMonth(), i + 1);
date_shedule[counter_size_shedule][i].Print();
cout << "\n";
bool control = 1;
do
{
cout << "Enter a shift:";
cin>>tmp;
if (tmp>=1 && tmp<=number_of_shift)
{
shedule[counter_size_shedule][i] = template_shedule[tmp - 1];
shedule[counter_size_shedule][i].setWorkDayHoliday(search(date_shedule[counter_size_shedule][i]));
shedule[counter_size_shedule][i].setWorkDayBeforeHoliday(search(date_shedule[counter_size_shedule][i] + 1));
shedule[counter_size_shedule][i].calculateAllTypeHours();
control = 0;
}
else if (tmp == 0)
{
shedule[counter_size_shedule][i] = WorkDay();
control = 0;
}
else
{
cout << "You entered uncorrect value!!! Try again.\n";
}
} while (control == 1);
}
}
void WorkShedule::autoCreateShedule()
{
if (counter_size_shedule == 0)
{
cout << "Enter the name of this shedule: ";
enterTheText(name_work_shedule);
cin.ignore();
int tmp;
cout << "Enter the current year: ";
cin >> tmp;
sample.setYear(tmp);
cout << "Enter the current month: ";
cin >> tmp;
sample.setMonth(tmp);
createTemplateShedule();
}
int number_work_day = memory[0];
int position_of_the_work_day_in_shelter = memory[1];
date_shedule = new Date*[size_shedule];
shedule = new WorkDay*[size_shedule];
date_shedule[counter_size_shedule] = new Date[sample.getDaysInMonth()];
shedule[counter_size_shedule] = new WorkDay[sample.getDaysInMonth()];
for (int i = 0; i < sample.getDaysInMonth();)
{
date_shedule[counter_size_shedule][i].setDate(sample.getYear(), sample.getMonth(), i + 1);
if (memory[2] == 0 || (memory[2] == 1 && (memory[1] + 1) == lenght_reiteration_rest_day[memory[0]])) //???????????????
{
for (; position_of_the_work_day_in_shelter < lenght_reiteration_work_day[number_work_day] && i < sample.getDaysInMonth(); position_of_the_work_day_in_shelter++)
{
shedule[counter_size_shedule][i] = template_shedule[number_work_day];
shedule[counter_size_shedule][i].setWorkDayHoliday(search(date_shedule[counter_size_shedule][i]));
shedule[counter_size_shedule][i].setWorkDayBeforeHoliday(search(date_shedule[counter_size_shedule][i] + 1));
shedule[counter_size_shedule][i].calculateAllTypeHours();
i++;
}
setMemory(number_work_day, position_of_the_work_day_in_shelter - 1, 0);
position_of_the_work_day_in_shelter = 0;
}
if (memory[2] == 1 || (memory[2] == 0 && (memory[1] + 1) == lenght_reiteration_work_day[memory[0]]))
{
for (; position_of_the_work_day_in_shelter < lenght_reiteration_rest_day[number_work_day] && i < sample.getDaysInMonth(); position_of_the_work_day_in_shelter++)
{
shedule[counter_size_shedule][i] = WorkDay();
shedule[counter_size_shedule][i].setWorkDayHoliday(search(date_shedule[counter_size_shedule][i]));
shedule[counter_size_shedule][i].setWorkDayBeforeHoliday(search(date_shedule[counter_size_shedule][i] + 1));
//shedule[counter_size_shedule][i].calculateAllTypeHours();
shedule[counter_size_shedule][i].calculateWorkHolidayHours();
i++;
}
}
if ((number_work_day + 1) < number_of_shift)
{
number_work_day++;
}
else
{
number_work_day = 0;
}
}
counter_size_shedule++;
}
bool WorkShedule::search(Date obj)
{
for (int i = 0; i<holiday.getSize(); i++)
{
if (obj == holiday.getHoliday(i))
{
return true;
}
}
return false;
}
void WorkShedule::Print()
{
for (int i = 0; i < sample.getDaysInMonth(); i++)
{
date_shedule[counter_size_shedule][i].Print();
cout << "\n";
shedule[counter_size_shedule][i].Print();
cout << "\n";
}
cout << "---------------------------------\n";
}
WorkShedule::~WorkShedule()
{
}
Worker::Worker()
{
}
Worker::~Worker()
{
}
| [
"32791402+SergeyRoznyuk@users.noreply.github.com"
] | 32791402+SergeyRoznyuk@users.noreply.github.com |
b4b8a738800948cb8757357caf2c912c27a1580c | 93176e72508a8b04769ee55bece71095d814ec38 | /Utilities/InsightJournal/itkBinaryStatisticsOpeningImageFilter.h | 74b267497ca8124f0c67392f0d0a394894c418b2 | [] | no_license | inglada/OTB | a0171a19be1428c0f3654c48fe5c35442934cf13 | 8b6d8a7df9d54c2b13189e00ba8fcb070e78e916 | refs/heads/master | 2021-01-19T09:23:47.919676 | 2011-06-29T17:29:21 | 2011-06-29T17:29:21 | 1,982,100 | 4 | 5 | null | null | null | null | ISO-8859-2 | C++ | false | false | 8,215 | h | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: $RCSfile: itkBinaryStatisticsOpeningImageFilter.h,v $
Language: C++
Date: $Date: 2006/03/28 19:59:05 $
Version: $Revision: 1.6 $
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/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 notices for more information.
=========================================================================*/
#ifndef __itkBinaryStatisticsOpeningImageFilter_h
#define __itkBinaryStatisticsOpeningImageFilter_h
#include "itkImageToImageFilter.h"
#include "itkStatisticsLabelObject.h"
#include "itkLabelMap.h"
#include "itkBinaryImageToLabelMapFilter.h"
#include "itkStatisticsLabelMapFilter.h"
#include "itkStatisticsOpeningLabelMapFilter.h"
#include "itkLabelMapToBinaryImageFilter.h"
namespace itk {
/** \class BinaryStatisticsOpeningImageFilter
* \brief remove the objects according to the value of their statistics attribute
*
* BinaryStatisticsOpeningImageFilter removes the objects in a binary image
* with an attribute value smaller or greater than a threshold called Lambda.
* The attributes are the ones of the StatisticsLabelObject.
*
* \author Gaëtan Lehmann. Biologie du Développement et de la Reproduction, INRA de Jouy-en-Josas, France.
*
* \sa StatisticsLabelObject, LabelStatisticsOpeningImageFilter, BinaryShapeOpeningImageFilter
* \ingroup ImageEnhancement MathematicalMorphologyImageFilters
*/
template<class TInputImage, class TFeatureImage>
class ITK_EXPORT BinaryStatisticsOpeningImageFilter :
public ImageToImageFilter<TInputImage, TInputImage>
{
public:
/** Standard class typedefs. */
typedef BinaryStatisticsOpeningImageFilter Self;
typedef ImageToImageFilter<TInputImage, TInputImage>
Superclass;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
/** Some convenient typedefs. */
typedef TInputImage InputImageType;
typedef TInputImage OutputImageType;
typedef typename InputImageType::Pointer InputImagePointer;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
typedef typename OutputImageType::RegionType OutputImageRegionType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
typedef TFeatureImage FeatureImageType;
typedef typename FeatureImageType::Pointer FeatureImagePointer;
typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
typedef typename FeatureImageType::PixelType FeatureImagePixelType;
/** ImageDimension constants */
itkStaticConstMacro(InputImageDimension, unsigned int,
TInputImage::ImageDimension);
itkStaticConstMacro(OutputImageDimension, unsigned int,
TInputImage::ImageDimension);
itkStaticConstMacro(ImageDimension, unsigned int,
TInputImage::ImageDimension);
typedef StatisticsLabelObject<unsigned long, ImageDimension> LabelObjectType;
typedef typename itk::LabelMap< LabelObjectType > LabelMapType;
typedef typename itk::BinaryImageToLabelMapFilter< InputImageType, LabelMapType > LabelizerType;
typedef typename itk::StatisticsLabelMapFilter< LabelMapType, TFeatureImage > LabelObjectValuatorType;
typedef typename LabelObjectType::AttributeType AttributeType;
typedef typename itk::StatisticsOpeningLabelMapFilter< LabelMapType > OpeningType;
typedef typename itk::LabelMapToBinaryImageFilter< LabelMapType, OutputImageType > BinarizerType;
/** Standard New method. */
itkNewMacro(Self);
/** Runtime information support. */
itkTypeMacro(BinaryStatisticsOpeningImageFilter,
ImageToImageFilter);
/**
* Set/Get whether the connected components are defined strictly by
* face connectivity or by face+edge+vertex connectivity. Default is
* FullyConnectedOff. For objects that are 1 pixel wide, use
* FullyConnectedOn.
*/
itkSetMacro(FullyConnected, bool);
itkGetConstReferenceMacro(FullyConnected, bool);
itkBooleanMacro(FullyConnected);
#ifdef ITK_USE_CONCEPT_CHECKING
/** Begin concept checking */
itkConceptMacro(InputEqualityComparableCheck,
(Concept::EqualityComparable<InputImagePixelType>));
itkConceptMacro(IntConvertibleToInputCheck,
(Concept::Convertible<int, InputImagePixelType>));
itkConceptMacro(InputOStreamWritableCheck,
(Concept::OStreamWritable<InputImagePixelType>));
/** End concept checking */
#endif
/**
* Set/Get the value used as "background" in the output image.
* Defaults to NumericTraits<PixelType>::NonpositiveMin().
*/
itkSetMacro(BackgroundValue, OutputImagePixelType);
itkGetConstMacro(BackgroundValue, OutputImagePixelType);
/**
* Set/Get the value used as "foreground" in the output image.
* Defaults to NumericTraits<PixelType>::max().
*/
itkSetMacro(ForegroundValue, OutputImagePixelType);
itkGetConstMacro(ForegroundValue, OutputImagePixelType);
/**
* Set/Get the threshold used to keep or remove the objects.
*/
itkGetConstMacro(Lambda, double);
itkSetMacro(Lambda, double);
/**
* Set/Get the ordering of the objects. By default, the objects with
* an attribute value smaller than Lamba are removed. Turning ReverseOrdering
* to true make this filter remove the object with an attribute value greater
* than Lambda instead.
*/
itkGetConstMacro( ReverseOrdering, bool );
itkSetMacro( ReverseOrdering, bool );
itkBooleanMacro( ReverseOrdering );
/**
* Set/Get the attribute to use to select the object to remove. The default
* is "Mean".
*/
itkGetConstMacro( Attribute, AttributeType );
itkSetMacro( Attribute, AttributeType );
void SetAttribute( const std::string & s )
{
this->SetAttribute( LabelObjectType::GetAttributeFromName( s ) );
}
/** Set the feature image */
void SetFeatureImage(TFeatureImage *input)
{
// Process object is not const-correct so the const casting is required.
this->SetNthInput( 1, const_cast<TFeatureImage *>(input) );
}
/** Get the feature image */
FeatureImageType * GetFeatureImage()
{
return static_cast<FeatureImageType*>(const_cast<DataObject *>(this->ProcessObject::GetInput(1)));
}
/** Set the input image */
void SetInput1(InputImageType *input)
{
this->SetInput( input );
}
/** Set the feature image */
void SetInput2(FeatureImageType *input)
{
this->SetFeatureImage( input );
}
protected:
BinaryStatisticsOpeningImageFilter();
~BinaryStatisticsOpeningImageFilter() {};
void PrintSelf(std::ostream& os, Indent indent) const;
/** BinaryStatisticsOpeningImageFilter needs the entire input be
* available. Thus, it needs to provide an implementation of
* GenerateInputRequestedRegion(). */
void GenerateInputRequestedRegion() ;
/** BinaryStatisticsOpeningImageFilter will produce the entire output. */
void EnlargeOutputRequestedRegion(DataObject *itkNotUsed(output));
/** Single-threaded version of GenerateData. This filter delegates
* to GrayscaleGeodesicErodeImageFilter. */
void GenerateData();
private:
BinaryStatisticsOpeningImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
bool m_FullyConnected;
OutputImagePixelType m_BackgroundValue;
OutputImagePixelType m_ForegroundValue;
double m_Lambda;
bool m_ReverseOrdering;
AttributeType m_Attribute;
} ; // end of class
} // end namespace itk
#ifndef ITK_MANUAL_INSTANTIATION
#include "itkBinaryStatisticsOpeningImageFilter.txx"
#endif
#endif
| [
"manuel.grizonnet@gmail.com"
] | manuel.grizonnet@gmail.com |
e737aa212f737a514b1b6adc644b4f3a8f475a96 | dbcddaf982c464646f063ba53aa0fa8414bbaa1e | /Source/SpaceTradersBP/PlayerInteraction.cpp | 9e1369a6954f888420104a6995ae05cd1b8abf1d | [] | no_license | UEProjectXmples/SpaceTradersBP | 1dc963dca5ca842157382cdc87bcf1132b8b914e | 81fb34cccecab1985414f7f86e4a947b7bf053be | refs/heads/main | 2023-04-22T04:19:15.187182 | 2021-03-03T01:54:27 | 2021-03-03T01:54:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 772 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "PlayerInteraction.h"
// Sets default values for this component's properties
UPlayerInteraction::UPlayerInteraction()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UPlayerInteraction::BeginPlay()
{
Super::BeginPlay();
// ...
}
// Called every frame
void UPlayerInteraction::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
| [
"aaronlampole@gmail.com"
] | aaronlampole@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.