blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905
values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 10.4M | extension stringclasses 115
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b3f4ad043148fa5b0a9792c72f2b3997587b9133 | 8e59bcdb86e69ba319c94d14a5ff2bd2c965a78e | /libs/cuteLogger/src/AbstractStringAppender.cpp | 7167863d3e5eccb709a85d64ad7ea8fde78b6fa7 | [
"MIT"
] | permissive | knopkem/pacsnode-server | 00fb5fd8bff57b3fff04b2f6f491b9d304d0ec80 | 0f31d08dd68810ea7525200ef5663879633758cb | refs/heads/master | 2022-04-25T09:53:38.572962 | 2020-04-27T22:18:48 | 2020-04-27T22:18:48 | 259,465,018 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 14,419 | cpp | /*
Copyright (c) 2010 Boris Moiseev (cyberbobs at gmail dot com) Nikolay Matyunin (matyunin.n at gmail dot com)
Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1
as published by the Free Software Foundation and appearing in the file
LICENSE.LGPL included in the packaging of this file.
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 Lesser General Public License for more details.
*/
// Local
#include "AbstractStringAppender.h"
// Qt
#include <QReadLocker>
#include <QWriteLocker>
#include <QDateTime>
#include <QRegExp>
#include <QCoreApplication>
#include <QThread>
/**
* \class AbstractStringAppender
*
* \brief The AbstractStringAppender class provides a convinient base for appenders working with plain text formatted
* logs.
*
* AbstractSringAppender is the simple extension of the AbstractAppender class providing the convinient way to create
* custom log appenders working with a plain text formatted log targets.
*
* It have the formattedString() protected function that formats the logging arguments according to a format set with
* setFormat().
*
* This class can not be directly instantiated because it contains pure virtual function inherited from AbstractAppender
* class.
*
* For more detailed description of customizing the log output format see the documentation on the setFormat() function.
*/
namespace cuteLogger {
const char formattingMarker = '%';
//! Constructs a new string appender object
AbstractStringAppender::AbstractStringAppender()
: m_format(QLatin1String("%{time}{yyyy-MM-ddTHH:mm:ss.zzz} [%{type:-7}] <%{function}> %{message}\n"))
{}
//! Returns the current log format string.
/**
* The default format is set to "%{time}{yyyy-MM-ddTHH:mm:ss.zzz} [%{type:-7}] <%{function}> %{message}\n". You can set a different log record
* format using the setFormat() function.
*
* \sa setFormat(const QString&)
*/
QString AbstractStringAppender::format() const
{
QReadLocker locker(&m_formatLock);
return m_format;
}
//! Sets the logging format for writing strings to the log target with this appender.
/**
* The string format seems to be very common to those developers who have used a standart sprintf function.
*
* Log output format is a simple QString with the special markers (starting with % sign) which will be replaced with
* it's internal meaning when writing a log record.
*
* Controlling marker begins with the percent sign (%) which is followed by the command inside {} brackets
* (the command describes, what will be put to log record instead of marker).
* Optional field width argument may be specified right after the command (through the colon symbol before the closing bracket)
* Some commands requires an additional formatting argument (in the second {} brackets).
*
* Field width argument works almost identically to the \c QString::arg() \c fieldWidth argument (and uses it
* internally). For example, \c "%{type:-7}" will be replaced with the left padded debug level of the message
* (\c "Debug ") or something. For the more detailed description of it you may consider to look to the Qt
* Reference Documentation.
*
* Supported marker commands are:
* \arg \c %{time} - timestamp. You may specify your custom timestamp format using the second {} brackets after the marker,
* timestamp format here will be similiar to those used in QDateTime::toString() function. For example,
* "%{time}{dd-MM-yyyy, HH:mm}" may be replaced with "17-12-2010, 20:17" depending on current date and time.
* The default format used here is "HH:mm:ss.zzz".
* \arg \c %{type} - Log level. Possible log levels are shown in the Logger::LogLevel enumerator.
* \arg \c %{Type} - Uppercased log level.
* \arg \c %{File} - Full source file name (with path) of the file that requested log recording. Uses the \c __FILE__
* preprocessor macro.
* \arg \c %{file} - Short file name (with stripped path).
* \arg \c %{line} - Line number in the source file. Uses the \c __LINE__ preprocessor macro.
* \arg \c %{Function} - Name of function that called on of the LOG_* macros. Uses the \c Q_FUNC_INFO macro provided with
* Qt.
* \arg \c %{function} - Similiar to the %{Function}, but the function name is stripped using stripFunctionName
* \arg \c %{message} - The log message sent by the caller.
* \arg \c %{category} - The log category.
* \arg \c %{appname} - Application name (returned by QCoreApplication::applicationName() function).
* \arg \c %{pid} - Application pid (returned by QCoreApplication::applicationPid() function).
* \arg \c %{threadid} - ID of current thread.
* \arg \c %% - Convinient marker that is replaced with the single \c % mark.
*
* \note Format doesn't add \c '\\n' to the end of the format line. Please consider adding it manually.
*
* \sa format()
* \sa stripFunctionName()
* \sa Logger::LogLevel
*/
void AbstractStringAppender::setFormat(const QString& format)
{
QWriteLocker locker(&m_formatLock);
m_format = format;
}
//! Strips the long function signature (as added by Q_FUNC_INFO macro)
/**
* The string processing drops the returning type, arguments and template parameters of function. It is definitely
* useful for enchancing the log output readability.
* \return stripped function name
*/
QString AbstractStringAppender::stripFunctionName(const char* name)
{
return QString::fromLatin1(qCleanupFuncinfo(name));
}
// The function was backported from Qt5 sources (qlogging.h)
QByteArray AbstractStringAppender::qCleanupFuncinfo(const char* name)
{
QByteArray info(name);
// Strip the function info down to the base function name
// note that this throws away the template definitions,
// the parameter types (overloads) and any const/volatile qualifiers.
if (info.isEmpty())
return info;
int pos;
// skip trailing [with XXX] for templates (gcc)
pos = info.size() - 1;
if (info.endsWith(']')) {
while (--pos) {
if (info.at(pos) == '[')
info.truncate(pos);
}
}
bool hasLambda = false;
QRegExp lambdaRegex("::<lambda\\(.*\\)>");
int lambdaIndex = lambdaRegex.indexIn(QString::fromLatin1(info));
if (lambdaIndex != -1)
{
hasLambda = true;
info.remove(lambdaIndex, lambdaRegex.matchedLength());
}
// operator names with '(', ')', '<', '>' in it
static const char operator_call[] = "operator()";
static const char operator_lessThan[] = "operator<";
static const char operator_greaterThan[] = "operator>";
static const char operator_lessThanEqual[] = "operator<=";
static const char operator_greaterThanEqual[] = "operator>=";
// canonize operator names
info.replace("operator ", "operator");
// remove argument list
forever {
int parencount = 0;
pos = info.lastIndexOf(')');
if (pos == -1) {
// Don't know how to parse this function name
return info;
}
// find the beginning of the argument list
--pos;
++parencount;
while (pos && parencount) {
if (info.at(pos) == ')')
++parencount;
else if (info.at(pos) == '(')
--parencount;
--pos;
}
if (parencount != 0)
return info;
info.truncate(++pos);
if (info.at(pos - 1) == ')') {
if (info.indexOf(operator_call) == pos - (int)strlen(operator_call))
break;
// this function returns a pointer to a function
// and we matched the arguments of the return type's parameter list
// try again
info.remove(0, info.indexOf('('));
info.chop(1);
continue;
} else {
break;
}
}
if (hasLambda)
info.append("::lambda");
// find the beginning of the function name
int parencount = 0;
int templatecount = 0;
--pos;
// make sure special characters in operator names are kept
if (pos > -1) {
switch (info.at(pos)) {
case ')':
if (info.indexOf(operator_call) == pos - (int)strlen(operator_call) + 1)
pos -= 2;
break;
case '<':
if (info.indexOf(operator_lessThan) == pos - (int)strlen(operator_lessThan) + 1)
--pos;
break;
case '>':
if (info.indexOf(operator_greaterThan) == pos - (int)strlen(operator_greaterThan) + 1)
--pos;
break;
case '=': {
int operatorLength = (int)strlen(operator_lessThanEqual);
if (info.indexOf(operator_lessThanEqual) == pos - operatorLength + 1)
pos -= 2;
else if (info.indexOf(operator_greaterThanEqual) == pos - operatorLength + 1)
pos -= 2;
break;
}
default:
break;
}
}
while (pos > -1) {
if (parencount < 0 || templatecount < 0)
return info;
char c = info.at(pos);
if (c == ')')
++parencount;
else if (c == '(')
--parencount;
else if (c == '>')
++templatecount;
else if (c == '<')
--templatecount;
else if (c == ' ' && templatecount == 0 && parencount == 0)
break;
--pos;
}
info = info.mid(pos + 1);
// remove trailing '*', '&' that are part of the return argument
while ((info.at(0) == '*')
|| (info.at(0) == '&'))
info = info.mid(1);
// we have the full function name now.
// clean up the templates
while ((pos = info.lastIndexOf('>')) != -1) {
if (!info.contains('<'))
break;
// find the matching close
int end = pos;
templatecount = 1;
--pos;
while (pos && templatecount) {
register char c = info.at(pos);
if (c == '>')
++templatecount;
else if (c == '<')
--templatecount;
--pos;
}
++pos;
info.remove(pos, end - pos + 1);
}
return info;
}
//! Returns the string to record to the logging target, formatted according to the format().
/**
* \sa format()
* \sa setFormat(const QString&)
*/
QString AbstractStringAppender::formattedString(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file,
int line, const char* function, const QString& category, const QString& message) const
{
QString f = format();
const int size = f.size();
QString result;
int i = 0;
while (i < f.size())
{
QChar c = f.at(i);
// We will silently ignore the broken % marker at the end of string
if (c != QLatin1Char(formattingMarker) || (i + 2) >= size)
{
result.append(c);
}
else
{
i += 2;
QChar currentChar = f.at(i);
QString command;
int fieldWidth = 0;
if (currentChar.isLetter())
{
command.append(currentChar);
int j = 1;
while ((i + j) < size && f.at(i + j).isLetter())
{
command.append(f.at(i+j));
j++;
}
i+=j;
currentChar = f.at(i);
// Check for the padding instruction
if (currentChar == QLatin1Char(':'))
{
currentChar = f.at(++i);
if (currentChar.isDigit() || currentChar.category() == QChar::Punctuation_Dash)
{
int j = 1;
while ((i + j) < size && f.at(i + j).isDigit())
j++;
fieldWidth = f.mid(i, j).toInt();
i += j;
}
}
}
// Log record chunk to insert instead of formatting instruction
QString chunk;
// Time stamp
if (command == QLatin1String("time"))
{
if (f.at(i + 1) == QLatin1Char('{'))
{
int j = 1;
while ((i + 2 + j) < size && f.at(i + 2 + j) != QLatin1Char('}'))
j++;
if ((i + 2 + j) < size)
{
chunk = timeStamp.toString(f.mid(i + 2, j));
i += j;
i += 2;
}
}
if (chunk.isNull())
chunk = timeStamp.toString(QLatin1String("HH:mm:ss.zzz"));
}
// Log level
else if (command == QLatin1String("type"))
chunk = Logger::levelToString(logLevel);
// Uppercased log level
else if (command == QLatin1String("Type"))
chunk = Logger::levelToString(logLevel).toUpper();
// Filename
else if (command == QLatin1String("File"))
chunk = QLatin1String(file);
// Filename without a path
else if (command == QLatin1String("file"))
chunk = QString(QLatin1String(file)).section('/', -1);
// Source line number
else if (command == QLatin1String("line"))
chunk = QString::number(line);
// Function name, as returned by Q_FUNC_INFO
else if (command == QLatin1String("Function"))
chunk = QString::fromLatin1(function);
// Stripped function name
else if (command == QLatin1String("function"))
chunk = stripFunctionName(function);
// Log message
else if (command == QLatin1String("message"))
chunk = message;
else if (command == QLatin1String("category"))
chunk = category;
// Application pid
else if (command == QLatin1String("pid"))
chunk = QString::number(QCoreApplication::applicationPid());
// Appplication name
else if (command == QLatin1String("appname"))
chunk = QCoreApplication::applicationName();
// Thread ID (duplicates Qt5 threadid debbuging way)
else if (command == QLatin1String("threadid"))
chunk = QLatin1String("0x") + QString::number(qlonglong(QThread::currentThread()->currentThread()), 16);
// We simply replace the double formatting marker (%) with one
else if (command == QString(formattingMarker))
chunk = QLatin1Char(formattingMarker);
// Do not process any unknown commands
else
{
chunk = QString(formattingMarker);
chunk.append(command);
}
result.append(QString(QLatin1String("%1")).arg(chunk, fieldWidth));
}
++i;
}
return result;
}
}
| [
"knopkem@gmail.com"
] | knopkem@gmail.com |
c28b3a65b53f6244f8a1769a3b1917fc3cbd6dee | d6dd5db888a40b101f8129e1e75d5159de3c33d4 | /src/slg/engines/pathoclbase/pathoclbaseoclthreadinit.cpp | f8076f5f9171aff3edd6fff237fa6b639817612a | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | neuroradiology/LuxCore | e27b6213ea0cad9f71ca109458cbc81413061a37 | 77f02c37964ac44e266915f9a52322fcca91c41c | refs/heads/master | 2022-04-27T19:50:06.635711 | 2020-05-01T15:53:47 | 2020-05-01T15:53:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,738 | cpp | /***************************************************************************
* Copyright 1998-2020 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxCoreRender. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#if defined(LUXRAYS_ENABLE_OPENCL)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string/replace.hpp>
#include "luxcore/cfg.h"
#include "luxrays/core/geometry/transform.h"
#include "luxrays/utils/ocl.h"
#include "luxrays/devices/ocldevice.h"
#include "luxrays/kernels/kernels.h"
#include "slg/slg.h"
#include "slg/kernels/kernels.h"
#include "slg/renderconfig.h"
#include "slg/engines/pathoclbase/pathoclbase.h"
#include "slg/samplers/sobol.h"
#include "slg/utils/pathinfo.h"
using namespace std;
using namespace luxrays;
using namespace slg;
//------------------------------------------------------------------------------
// PathOCLBaseOCLRenderThread initialization methods
//------------------------------------------------------------------------------
void PathOCLBaseOCLRenderThread::InitFilm() {
if (threadFilms.size() == 0)
IncThreadFilms();
u_int threadFilmWidth, threadFilmHeight, threadFilmSubRegion[4];
GetThreadFilmSize(&threadFilmWidth, &threadFilmHeight, threadFilmSubRegion);
BOOST_FOREACH(ThreadFilm *threadFilm, threadFilms)
threadFilm->Init(renderEngine->film, threadFilmWidth, threadFilmHeight,
threadFilmSubRegion);
}
void PathOCLBaseOCLRenderThread::InitCamera() {
intersectionDevice->AllocBufferRO(&cameraBuff, &renderEngine->compiledScene->camera,
sizeof(slg::ocl::Camera), "Camera");
}
void PathOCLBaseOCLRenderThread::InitGeometry() {
CompiledScene *cscene = renderEngine->compiledScene;
const BufferType memTypeFlags = renderEngine->ctx->GetUseOutOfCoreBuffers() ?
((BufferType)(BUFFER_TYPE_READ_ONLY | BUFFER_TYPE_OUT_OF_CORE)) :
BUFFER_TYPE_READ_ONLY;
if (cscene->normals.size() > 0)
intersectionDevice->AllocBuffer(&normalsBuff,
memTypeFlags,
&cscene->normals[0],
sizeof(Normal) * cscene->normals.size(), "Normals");
else
intersectionDevice->FreeBuffer(&normalsBuff);
if (cscene->uvs.size() > 0)
intersectionDevice->AllocBuffer(&uvsBuff,
memTypeFlags,
&cscene->uvs[0],
sizeof(UV) * cscene->uvs.size(), "UVs");
else
intersectionDevice->FreeBuffer(&uvsBuff);
if (cscene->cols.size() > 0)
intersectionDevice->AllocBuffer(&colsBuff,
memTypeFlags,
&cscene->cols[0],
sizeof(Spectrum) * cscene->cols.size(), "Colors");
else
intersectionDevice->FreeBuffer(&colsBuff);
if (cscene->alphas.size() > 0)
intersectionDevice->AllocBuffer(&alphasBuff,
memTypeFlags,
&cscene->alphas[0],
sizeof(float) * cscene->alphas.size(), "Alphas");
else
intersectionDevice->FreeBuffer(&alphasBuff);
if (cscene->vertexAOVs.size() > 0)
intersectionDevice->AllocBuffer(&vertexAOVBuff,
memTypeFlags,
&cscene->vertexAOVs[0],
sizeof(float) * cscene->vertexAOVs.size(), "Vertex AOVs");
else
intersectionDevice->FreeBuffer(&vertexAOVBuff);
if (cscene->triAOVs.size() > 0)
intersectionDevice->AllocBuffer(&triAOVBuff,
memTypeFlags,
&cscene->triAOVs[0],
sizeof(float) * cscene->triAOVs.size(), "Triangle AOVs");
else
intersectionDevice->FreeBuffer(&triAOVBuff);
intersectionDevice->AllocBuffer(&triNormalsBuff,
memTypeFlags,
&cscene->triNormals[0],
sizeof(Normal) * cscene->triNormals.size(), "Triangle normals");
intersectionDevice->AllocBuffer(&vertsBuff,
memTypeFlags,
&cscene->verts[0],
sizeof(Point) * cscene->verts.size(), "Vertices");
intersectionDevice->AllocBuffer(&trianglesBuff,
memTypeFlags,
&cscene->tris[0],
sizeof(Triangle) * cscene->tris.size(), "Triangles");
if (cscene->interpolatedTransforms.size() > 0) {
intersectionDevice->AllocBuffer(&interpolatedTransformsBuff,
memTypeFlags,
&cscene->interpolatedTransforms[0],
sizeof(luxrays::ocl::InterpolatedTransform) * cscene->interpolatedTransforms.size(), "Interpolated transformations");
} else
intersectionDevice->FreeBuffer(&interpolatedTransformsBuff);
intersectionDevice->AllocBufferRO(&meshDescsBuff, &cscene->meshDescs[0],
sizeof(slg::ocl::ExtMesh) * cscene->meshDescs.size(), "Mesh description");
}
void PathOCLBaseOCLRenderThread::InitMaterials() {
const size_t materialsCount = renderEngine->compiledScene->mats.size();
intersectionDevice->AllocBufferRO(&materialsBuff, &renderEngine->compiledScene->mats[0],
sizeof(slg::ocl::Material) * materialsCount, "Materials");
intersectionDevice->AllocBufferRO(&materialEvalOpsBuff, &renderEngine->compiledScene->matEvalOps[0],
sizeof(slg::ocl::MaterialEvalOp) * renderEngine->compiledScene->matEvalOps.size(), "Material evaluation ops");
const u_int taskCount = renderEngine->taskCount;
intersectionDevice->AllocBufferRW(&materialEvalStackBuff,
nullptr, sizeof(float) * renderEngine->compiledScene->maxMaterialEvalStackSize *
taskCount, "Material evaluation stacks");
}
void PathOCLBaseOCLRenderThread::InitSceneObjects() {
const BufferType memTypeFlags = renderEngine->ctx->GetUseOutOfCoreBuffers() ?
((BufferType)(BUFFER_TYPE_READ_ONLY | BUFFER_TYPE_OUT_OF_CORE)) :
BUFFER_TYPE_READ_ONLY;
const u_int sceneObjsCount = renderEngine->compiledScene->sceneObjs.size();
intersectionDevice->AllocBuffer(&scnObjsBuff, memTypeFlags,
&renderEngine->compiledScene->sceneObjs[0],
sizeof(slg::ocl::SceneObject) * sceneObjsCount, "Scene objects");
}
void PathOCLBaseOCLRenderThread::InitTextures() {
const size_t texturesCount = renderEngine->compiledScene->texs.size();
intersectionDevice->AllocBufferRO(&texturesBuff, &renderEngine->compiledScene->texs[0],
sizeof(slg::ocl::Texture) * texturesCount, "Textures");
intersectionDevice->AllocBufferRO(&textureEvalOpsBuff, &renderEngine->compiledScene->texEvalOps[0],
sizeof(slg::ocl::TextureEvalOp) * renderEngine->compiledScene->texEvalOps.size(), "Texture evaluation ops");
const u_int taskCount = renderEngine->taskCount;
intersectionDevice->AllocBufferRW(&textureEvalStackBuff,
nullptr, sizeof(float) * renderEngine->compiledScene->maxTextureEvalStackSize *
taskCount, "Texture evaluation stacks");
}
void PathOCLBaseOCLRenderThread::InitLights() {
CompiledScene *cscene = renderEngine->compiledScene;
intersectionDevice->AllocBufferRO(&lightsBuff, &cscene->lightDefs[0],
sizeof(slg::ocl::LightSource) * cscene->lightDefs.size(), "Lights");
if (cscene->envLightIndices.size() > 0) {
intersectionDevice->AllocBufferRO(&envLightIndicesBuff, &cscene->envLightIndices[0],
sizeof(u_int) * cscene->envLightIndices.size(), "Env. light indices");
} else
intersectionDevice->FreeBuffer(&envLightIndicesBuff);
intersectionDevice->AllocBufferRO(&lightIndexOffsetByMeshIndexBuff, &cscene->lightIndexOffsetByMeshIndex[0],
sizeof(u_int) * cscene->lightIndexOffsetByMeshIndex.size(), "Light offsets (Part I)");
intersectionDevice->AllocBufferRO(&lightIndexByTriIndexBuff, &cscene->lightIndexByTriIndex[0],
sizeof(u_int) * cscene->lightIndexByTriIndex.size(), "Light offsets (Part II)");
if (cscene->envLightDistributions.size() > 0) {
intersectionDevice->AllocBufferRO(&envLightDistributionsBuff, &cscene->envLightDistributions[0],
sizeof(float) * cscene->envLightDistributions.size(), "Env. light distributions");
} else
intersectionDevice->FreeBuffer(&envLightDistributionsBuff);
intersectionDevice->AllocBufferRO(&lightsDistributionBuff, cscene->lightsDistribution,
cscene->lightsDistributionSize, "LightsDistribution");
intersectionDevice->AllocBufferRO(&infiniteLightSourcesDistributionBuff, cscene->infiniteLightSourcesDistribution,
cscene->infiniteLightSourcesDistributionSize, "InfiniteLightSourcesDistribution");
if (cscene->dlscAllEntries.size() > 0) {
intersectionDevice->AllocBufferRO(&dlscAllEntriesBuff, &cscene->dlscAllEntries[0],
cscene->dlscAllEntries.size() * sizeof(slg::ocl::DLSCacheEntry), "DLSC all entries");
intersectionDevice->AllocBufferRO(&dlscDistributionsBuff, &cscene->dlscDistributions[0],
cscene->dlscDistributions.size() * sizeof(float), "DLSC distributions table");
intersectionDevice->AllocBufferRO(&dlscBVHNodesBuff, &cscene->dlscBVHArrayNode[0],
cscene->dlscBVHArrayNode.size() * sizeof(slg::ocl::IndexBVHArrayNode), "DLSC BVH nodes");
} else {
intersectionDevice->FreeBuffer(&dlscAllEntriesBuff);
intersectionDevice->FreeBuffer(&dlscDistributionsBuff);
intersectionDevice->FreeBuffer(&dlscBVHNodesBuff);
}
if (cscene->elvcAllEntries.size() > 0) {
intersectionDevice->AllocBufferRO(&elvcAllEntriesBuff, &cscene->elvcAllEntries[0],
cscene->elvcAllEntries.size() * sizeof(slg::ocl::ELVCacheEntry), "ELVC all entries");
intersectionDevice->AllocBufferRO(&elvcDistributionsBuff, &cscene->elvcDistributions[0],
cscene->elvcDistributions.size() * sizeof(float), "ELVC distributions table");
if (cscene->elvcTileDistributionOffsets.size() > 0) {
intersectionDevice->AllocBufferRO(&elvcTileDistributionOffsetsBuff, &cscene->elvcTileDistributionOffsets[0],
cscene->elvcTileDistributionOffsets.size() * sizeof(u_int), "ELVC tile distribution offsets table");
} else
intersectionDevice->FreeBuffer(&elvcTileDistributionOffsetsBuff);
intersectionDevice->AllocBufferRO(&elvcBVHNodesBuff, &cscene->elvcBVHArrayNode[0],
cscene->elvcBVHArrayNode.size() * sizeof(slg::ocl::IndexBVHArrayNode), "ELVC BVH nodes");
} else {
intersectionDevice->FreeBuffer(&elvcAllEntriesBuff);
intersectionDevice->FreeBuffer(&elvcDistributionsBuff);
intersectionDevice->FreeBuffer(&elvcTileDistributionOffsetsBuff);
intersectionDevice->FreeBuffer(&elvcBVHNodesBuff);
}
}
void PathOCLBaseOCLRenderThread::InitPhotonGI() {
CompiledScene *cscene = renderEngine->compiledScene;
const BufferType memTypeFlags = renderEngine->ctx->GetUseOutOfCoreBuffers() ?
((BufferType)(BUFFER_TYPE_READ_ONLY | BUFFER_TYPE_OUT_OF_CORE)) :
BUFFER_TYPE_READ_ONLY;
if (cscene->pgicRadiancePhotons.size() > 0) {
intersectionDevice->AllocBuffer(&pgicRadiancePhotonsBuff, memTypeFlags, &cscene->pgicRadiancePhotons[0],
cscene->pgicRadiancePhotons.size() * sizeof(slg::ocl::RadiancePhoton), "PhotonGI indirect cache all entries");
intersectionDevice->AllocBuffer(&pgicRadiancePhotonsValuesBuff, memTypeFlags, &cscene->pgicRadiancePhotonsValues[0],
cscene->pgicRadiancePhotonsValues.size() * sizeof(slg::ocl::Spectrum), "PhotonGI indirect cache all entry values");
intersectionDevice->AllocBuffer(&pgicRadiancePhotonsBVHNodesBuff, memTypeFlags, &cscene->pgicRadiancePhotonsBVHArrayNode[0],
cscene->pgicRadiancePhotonsBVHArrayNode.size() * sizeof(slg::ocl::IndexBVHArrayNode), "PhotonGI indirect cache BVH nodes");
} else {
intersectionDevice->FreeBuffer(&pgicRadiancePhotonsBuff);
intersectionDevice->FreeBuffer(&pgicRadiancePhotonsValuesBuff);
intersectionDevice->FreeBuffer(&pgicRadiancePhotonsBVHNodesBuff);
}
if (cscene->pgicCausticPhotons.size() > 0) {
intersectionDevice->AllocBuffer(&pgicCausticPhotonsBuff, memTypeFlags, &cscene->pgicCausticPhotons[0],
cscene->pgicCausticPhotons.size() * sizeof(slg::ocl::Photon), "PhotonGI caustic cache all entries");
intersectionDevice->AllocBuffer(&pgicCausticPhotonsBVHNodesBuff, memTypeFlags, &cscene->pgicCausticPhotonsBVHArrayNode[0],
cscene->pgicCausticPhotonsBVHArrayNode.size() * sizeof(slg::ocl::IndexBVHArrayNode), "PhotonGI caustic cache BVH nodes");
} else {
intersectionDevice->FreeBuffer(&pgicCausticPhotonsBuff);
intersectionDevice->FreeBuffer(&pgicCausticPhotonsBVHNodesBuff);
}
}
void PathOCLBaseOCLRenderThread::InitImageMaps() {
CompiledScene *cscene = renderEngine->compiledScene;
if (cscene->imageMapDescs.size() > 0) {
intersectionDevice->AllocBufferRO(&imageMapDescsBuff,
&cscene->imageMapDescs[0],
sizeof(slg::ocl::ImageMap) * cscene->imageMapDescs.size(), "ImageMap descriptions");
// Free unused pages
for (u_int i = cscene->imageMapMemBlocks.size(); i < imageMapsBuff.size(); ++i)
intersectionDevice->FreeBuffer(&imageMapsBuff[i]);
imageMapsBuff.resize(cscene->imageMapMemBlocks.size(), NULL);
const BufferType memTypeFlags = renderEngine->ctx->GetUseOutOfCoreBuffers() ?
((BufferType)(BUFFER_TYPE_READ_ONLY | BUFFER_TYPE_OUT_OF_CORE)) :
BUFFER_TYPE_READ_ONLY;
for (u_int i = 0; i < imageMapsBuff.size(); ++i) {
intersectionDevice->AllocBuffer(&(imageMapsBuff[i]),
memTypeFlags,
&(cscene->imageMapMemBlocks[i][0]),
sizeof(float) * cscene->imageMapMemBlocks[i].size(), "ImageMaps");
}
} else {
intersectionDevice->FreeBuffer(&imageMapDescsBuff);
for (u_int i = 0; i < imageMapsBuff.size(); ++i)
intersectionDevice->FreeBuffer(&imageMapsBuff[i]);
imageMapsBuff.resize(0);
}
}
void PathOCLBaseOCLRenderThread::InitGPUTaskBuffer() {
const u_int taskCount = renderEngine->taskCount;
//--------------------------------------------------------------------------
// Allocate tasksConfigBuff
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRO(&taskConfigBuff, &renderEngine->taskConfig, sizeof(slg::ocl::pathoclbase::GPUTaskConfiguration), "GPUTaskConfiguration");
//--------------------------------------------------------------------------
// Allocate tasksBuff
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRW(&tasksBuff, nullptr, sizeof(slg::ocl::pathoclbase::GPUTask) * taskCount, "GPUTask");
//--------------------------------------------------------------------------
// Allocate tasksDirectLightBuff
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRW(&tasksDirectLightBuff, nullptr, sizeof(slg::ocl::pathoclbase::GPUTaskDirectLight) * taskCount, "GPUTaskDirectLight");
//--------------------------------------------------------------------------
// Allocate tasksStateBuff
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRW(&tasksStateBuff, nullptr, sizeof(slg::ocl::pathoclbase::GPUTaskState) * taskCount, "GPUTaskState");
}
void PathOCLBaseOCLRenderThread::InitSamplerSharedDataBuffer() {
const u_int *subRegion = renderEngine->film->GetSubRegion();
const u_int filmRegionPixelCount = (subRegion[1] - subRegion[0] + 1) * (subRegion[3] - subRegion[2] + 1);
size_t size = 0;
if (renderEngine->oclSampler->type == slg::ocl::RANDOM) {
size += sizeof(slg::ocl::RandomSamplerSharedData);
} else if (renderEngine->oclSampler->type == slg::ocl::METROPOLIS) {
// Nothing
} else if (renderEngine->oclSampler->type == slg::ocl::SOBOL) {
size += sizeof(slg::ocl::SobolSamplerSharedData);
// Plus the a pass field for each pixel
size += sizeof(u_int) * filmRegionPixelCount;
// Plus the Sobol directions array
size += sizeof(u_int) * renderEngine->pathTracer.eyeSampleSize * SOBOL_BITS;
} else if (renderEngine->oclSampler->type == slg::ocl::TILEPATHSAMPLER) {
size += sizeof(slg::ocl::TilePathSamplerSharedData);
switch (renderEngine->GetType()) {
case TILEPATHOCL:
size += sizeof(u_int) * renderEngine->pathTracer.eyeSampleSize * SOBOL_BITS;
break;
case RTPATHOCL:
break;
default:
throw runtime_error("Unknown render engine in PathOCLBaseRenderThread::InitSamplerSharedDataBuffer(): " +
boost::lexical_cast<string>(renderEngine->GetType()));
}
} else
throw runtime_error("Unknown sampler.type in PathOCLBaseRenderThread::InitSamplerSharedDataBuffer(): " +
boost::lexical_cast<string>(renderEngine->oclSampler->type));
if (size == 0)
intersectionDevice->FreeBuffer(&samplerSharedDataBuff);
else
intersectionDevice->AllocBufferRW(&samplerSharedDataBuff, nullptr, size, "SamplerSharedData");
// Initialize the sampler shared data
if (renderEngine->oclSampler->type == slg::ocl::RANDOM) {
slg::ocl::RandomSamplerSharedData rssd;
rssd.bucketIndex = 0;
intersectionDevice->EnqueueWriteBuffer(samplerSharedDataBuff, CL_TRUE, size, &rssd);
} else if (renderEngine->oclSampler->type == slg::ocl::SOBOL) {
char *buffer = new char[size];
// Initialize SobolSamplerSharedData fields
slg::ocl::SobolSamplerSharedData *sssd = (slg::ocl::SobolSamplerSharedData *)buffer;
sssd->seedBase = renderEngine->seedBase;
sssd->bucketIndex = 0;
sssd->filmRegionPixelCount = filmRegionPixelCount;
// Initialize all pass values. The pass buffer is attached at the
// end of slg::ocl::SobolSamplerSharedData
u_int *passBuffer = (u_int *)(buffer + sizeof(slg::ocl::SobolSamplerSharedData));
fill(passBuffer, passBuffer + filmRegionPixelCount, SOBOL_STARTOFFSET);
// Initialize the Sobol directions array values. The pass buffer is attached at the
// end of slg::ocl::SobolSamplerSharedData + all pass values
u_int *sobolDirections = (u_int *)(buffer + sizeof(slg::ocl::SobolSamplerSharedData) + sizeof(u_int) * filmRegionPixelCount);
SobolSequence::GenerateDirectionVectors(sobolDirections, renderEngine->pathTracer.eyeSampleSize);
// Write the data
intersectionDevice->EnqueueWriteBuffer(samplerSharedDataBuff, CL_TRUE, size, buffer);
delete[] buffer;
} else if (renderEngine->oclSampler->type == slg::ocl::TILEPATHSAMPLER) {
// TilePathSamplerSharedData is updated in PathOCLBaseOCLRenderThread::UpdateSamplerData()
switch (renderEngine->GetType()) {
case TILEPATHOCL: {
char *buffer = new char[size];
// Initialize the Sobol directions array values
u_int *sobolDirections = (u_int *)(buffer + sizeof(slg::ocl::TilePathSamplerSharedData));
SobolSequence::GenerateDirectionVectors(sobolDirections, renderEngine->pathTracer.eyeSampleSize);
intersectionDevice->EnqueueWriteBuffer(samplerSharedDataBuff, CL_TRUE, size, &buffer[0]);
delete [] buffer;
break;
}
case RTPATHOCL:
break;
default:
throw runtime_error("Unknown render engine in PathOCLBaseRenderThread::InitSamplerSharedDataBuffer(): " +
boost::lexical_cast<string>(renderEngine->GetType()));
}
}
}
void PathOCLBaseOCLRenderThread::InitSamplesBuffer() {
const u_int taskCount = renderEngine->taskCount;
//--------------------------------------------------------------------------
// Sample size
//--------------------------------------------------------------------------
size_t sampleSize = 0;
// Add Sample memory size
switch (renderEngine->oclSampler->type) {
case slg::ocl::RANDOM: {
// pixelIndexBase, pixelIndexOffset and pixelIndexRandomStart fields
sampleSize += sizeof(slg::ocl::RandomSample);
break;
}
case slg::ocl::METROPOLIS: {
const size_t sampleResultSize = sizeof(slg::ocl::SampleResult);
sampleSize += 2 * sizeof(float) + 5 * sizeof(u_int) + sampleResultSize;
break;
}
case slg::ocl::SOBOL: {
sampleSize += sizeof(slg::ocl::SobolSample);
break;
}
case slg::ocl::TILEPATHSAMPLER: {
sampleSize += sizeof(slg::ocl::TilePathSample);
break;
}
default:
throw runtime_error("Unknown sampler.type in PathOCLBaseRenderThread::InitSamplesBuffer(): " +
boost::lexical_cast<string>(renderEngine->oclSampler->type));
}
SLG_LOG("[PathOCLBaseRenderThread::" << threadIndex << "] Size of a Sample: " << sampleSize << "bytes");
intersectionDevice->AllocBufferRW(&samplesBuff, nullptr, sampleSize * taskCount, "Sample");
}
void PathOCLBaseOCLRenderThread::InitSampleResultsBuffer() {
const u_int taskCount = renderEngine->taskCount;
const size_t sampleResultSize = sizeof(slg::ocl::SampleResult);
SLG_LOG("[PathOCLBaseRenderThread::" << threadIndex << "] Size of a SampleResult: " << sampleResultSize << "bytes");
intersectionDevice->AllocBufferRW(&sampleResultsBuff, nullptr, sampleResultSize * taskCount, "Sample");
}
void PathOCLBaseOCLRenderThread::InitSampleDataBuffer() {
const u_int taskCount = renderEngine->taskCount;
size_t uDataSize;
if (renderEngine->oclSampler->type == slg::ocl::RANDOM) {
// To store IDX_SCREEN_X and IDX_SCREEN_Y
uDataSize = 2 * sizeof(float);
} else if (renderEngine->oclSampler->type == slg::ocl::SOBOL) {
// To store IDX_SCREEN_X and IDX_SCREEN_Y
uDataSize = 2 * sizeof(float);
} else if (renderEngine->oclSampler->type == slg::ocl::METROPOLIS) {
// Metropolis needs 2 sets of samples, the current and the proposed mutation
uDataSize = 2 * sizeof(float) * renderEngine->pathTracer.eyeSampleSize;
} else if (renderEngine->oclSampler->type == slg::ocl::TILEPATHSAMPLER) {
// To store IDX_SCREEN_X and IDX_SCREEN_Y
uDataSize = 2 * sizeof(float);
} else
throw runtime_error("Unknown sampler.type in PathOCLBaseRenderThread::InitSampleDataBuffer(): " + boost::lexical_cast<string>(renderEngine->oclSampler->type));
SLG_LOG("[PathOCLBaseRenderThread::" << threadIndex << "] Size of a SampleData: " << uDataSize << "bytes");
intersectionDevice->AllocBufferRW(&sampleDataBuff, nullptr, uDataSize * taskCount, "SampleData");
}
void PathOCLBaseOCLRenderThread::InitRender() {
//--------------------------------------------------------------------------
// Film definition
//--------------------------------------------------------------------------
InitFilm();
//--------------------------------------------------------------------------
// Camera definition
//--------------------------------------------------------------------------
InitCamera();
//--------------------------------------------------------------------------
// Scene geometry
//--------------------------------------------------------------------------
InitGeometry();
//--------------------------------------------------------------------------
// Image maps
//--------------------------------------------------------------------------
InitImageMaps();
//--------------------------------------------------------------------------
// Texture definitions
//--------------------------------------------------------------------------
InitTextures();
//--------------------------------------------------------------------------
// Material definitions
//--------------------------------------------------------------------------
InitMaterials();
//--------------------------------------------------------------------------
// Mesh <=> Material links
//--------------------------------------------------------------------------
InitSceneObjects();
//--------------------------------------------------------------------------
// Light definitions
//--------------------------------------------------------------------------
InitLights();
//--------------------------------------------------------------------------
// Light definitions
//--------------------------------------------------------------------------
InitPhotonGI();
//--------------------------------------------------------------------------
// GPUTaskStats
//--------------------------------------------------------------------------
const u_int taskCount = renderEngine->taskCount;
// In case renderEngine->taskCount has changed
delete[] gpuTaskStats;
gpuTaskStats = new slg::ocl::pathoclbase::GPUTaskStats[taskCount];
for (u_int i = 0; i < taskCount; ++i)
gpuTaskStats[i].sampleCount = 0;
//--------------------------------------------------------------------------
// Allocate Ray/RayHit buffers
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRW(&raysBuff, nullptr, sizeof(Ray) * taskCount, "Ray");
intersectionDevice->AllocBufferRW(&hitsBuff, nullptr, sizeof(RayHit) * taskCount, "RayHit");
//--------------------------------------------------------------------------
// Allocate GPU task buffers
//--------------------------------------------------------------------------
InitGPUTaskBuffer();
//--------------------------------------------------------------------------
// Allocate GPU task statistic buffers
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRW(&taskStatsBuff, nullptr, sizeof(slg::ocl::pathoclbase::GPUTaskStats) * taskCount, "GPUTask Stats");
//--------------------------------------------------------------------------
// Allocate sampler shared data buffer
//--------------------------------------------------------------------------
InitSamplerSharedDataBuffer();
//--------------------------------------------------------------------------
// Allocate sample buffers
//--------------------------------------------------------------------------
InitSamplesBuffer();
//--------------------------------------------------------------------------
// Allocate sample data buffers
//--------------------------------------------------------------------------
InitSampleDataBuffer();
//--------------------------------------------------------------------------
// Allocate sample result buffers
//--------------------------------------------------------------------------
InitSampleResultsBuffer();
//--------------------------------------------------------------------------
// Allocate volume info buffers if required
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRW(&eyePathInfosBuff, nullptr, sizeof(slg::ocl::EyePathInfo) * taskCount, "PathInfo");
//--------------------------------------------------------------------------
// Allocate volume info buffers if required
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRW(&directLightVolInfosBuff, nullptr, sizeof(slg::ocl::PathVolumeInfo) * taskCount, "DirectLightVolumeInfo");
//--------------------------------------------------------------------------
// Allocate GPU pixel filter distribution
//--------------------------------------------------------------------------
intersectionDevice->AllocBufferRO(&pixelFilterBuff, renderEngine->pixelFilterDistribution,
renderEngine->pixelFilterDistributionSize, "Pixel Filter Distribution");
//--------------------------------------------------------------------------
// Compile kernels
//--------------------------------------------------------------------------
InitKernels();
//--------------------------------------------------------------------------
// Initialize
//--------------------------------------------------------------------------
// Set kernel arguments
SetKernelArgs();
// Clear all thread films
BOOST_FOREACH(ThreadFilm *threadFilm, threadFilms)
threadFilm->ClearFilm(intersectionDevice, filmClearKernel, filmClearWorkGroupSize);
intersectionDevice->FinishQueue();
// Reset statistics in order to be more accurate
intersectionDevice->ResetPerformaceStats();
}
#endif
| [
"dade916@gmail.com"
] | dade916@gmail.com |
10cffeb8d909b647520127dd694a9c305eeb0606 | a06123a57340a602a225cf1d07fa90914d80409e | /adventOfCode2018/day21/day21.cpp | 7f51cfbd299bc068bd530c495cd3c0622a130df5 | [] | no_license | swolecoder/competitive-programming | 9ec5146a97d914743ab4604f702806b1e1bd33ee | 66168be2cdf0db9aa1cdcf14440f11e5af9e4737 | refs/heads/master | 2022-04-27T05:16:00.719362 | 2020-04-23T21:19:18 | 2020-04-23T21:19:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 982 | cpp | /**
* C++ solution for Day21 - Advent of code 2018
*
* link - https://adventofcode.com/2018/day/21
* author - Oussa Zaki <zaki.oussama@gmail.com>
*/
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <iterator>
#include <chrono>
#include <algorithm>
#include <regex>
using namespace std;
#define START_TIMING auto start = std::chrono::high_resolution_clock::now();
#define END_TIMING \
chrono::duration<double> elapsed = std::chrono::high_resolution_clock::now() - start; \
cout << "Execution time: " << elapsed.count() << " s\n";
vector<int> get_input()
{
vector<int> inputs;
string line;
while (getline(cin, line))
{
// TODO parse input
inputs.push_back(0);
}
return inputs;
}
int day21_part1(vector<int> input)
{
return 0;
}
int day21_part2(vector<int> input)
{
return 0;
}
int main()
{
vector<int> input = get_input();
cout << day21_part1(input) << endl;
cout << day21_part2(input) << endl;
}
| [
"oussama.zaki@klarna.com"
] | oussama.zaki@klarna.com |
ae7ad68fe2169bbddd7e0594934c18331baca6df | a9b82319f728c950032d46f57cb776a801f80ac8 | /include/Script/ScriptEventManager.h | e6b2639c16b07024d0a00855aa6778eebf8df76c | [] | no_license | shikang/BlackHole-Engine | eebea87a2b06be27601804470e26441ff1f1e0b1 | 8dc2324d7ac4c3b553d67ae04231e6438cf81af0 | refs/heads/master | 2021-01-20T17:06:22.647627 | 2016-08-08T09:38:22 | 2016-08-08T09:38:22 | 60,777,549 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,045 | h | #ifndef BH_SCRIPT_EVENTMANAGER_H
#define BH_SCRIPT_EVENTMANAGER_H
#include "Core/CoreEssential.h"
#include "Core/FunctionsFramework.h"
#include "Platform/Keybind.h"
#include "Script/ScriptConfig.h"
#include "Script/ScriptMethod.h"
#include "Script/ScriptObject.h"
namespace BH
{
// Script Event Manager that raise C# event in C++
class BH_API ScriptEventManager
{
public:
// Constructor
ScriptEventManager();
// Destructor
~ScriptEventManager();
public:
// Key Event callback
void RaiseScriptKeyTriggeredEvent( Key::KeyCode keycode );
void RaiseScriptKeyReleasedEvent( Key::KeyCode keycode );
void RaiseScriptKeyPressedEvent( Key::KeyCode keycode );
// Mouse Event callback
void RaiseScriptMouseTriggeredEvent( s32 x,s32 y, Mouse::Button mousecode );
void RaiseScriptMouseReleasedEvent( s32 x, s32 y, Mouse::Button mousecode );
void RaiseScriptMousePressedEvent( s32 x, s32 y, Mouse::Button mousecode );
private:
ScriptObject mScriptEventManager; //!< Instance of ScriptEventManager in Script
};
}
#endif | [
"shikang.n@digipen.edu"
] | shikang.n@digipen.edu |
eca4a21dbcab37912aec181a14e738a85b5e2b2f | 8681c91756b2941035db515b621e32480d35ec11 | /xr_3da/IGame_Level.cpp | 54d581943595fd9ae17d32966dba6c6c7fbc3dd9 | [] | no_license | MaoZeDongXiJinping/xray-2212 | 1f3206c803c5fbc506114606424e2e834ffc51c0 | e143f01368c67b997f4be0dcdafb22f792bf485c | refs/heads/main | 2023-07-17T09:53:01.301852 | 2021-09-06T17:00:23 | 2021-09-06T17:00:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,024 | cpp | #include "stdafx.h"
#include "igame_level.h"
#include "igame_persistent.h"
#include "x_ray.h"
#include "std_classes.h"
#include "customHUD.h"
#include "render.h"
#include "gamefont.h"
#include "xrLevel.h"
#include "ps_instance.h"
ENGINE_API IGame_Level* g_pGameLevel = NULL;
IGame_Level::IGame_Level ()
{
g_pGameLevel = this;
pLevel = NULL;
bReady = false;
pCurrentEntity = NULL;
pCurrentViewEntity = NULL;
}
IGame_Level::~IGame_Level ()
{
// Cleanup particles, some of them can be still active
while (!ps_active.empty())
xr_delete ( *ps_active.begin() );
//
DEL_INSTANCE ( pHUD );
xr_delete ( pLevel );
// Render-level unload
Render->level_Unload ();
// Unload sounds
for (u32 i=0; i<Sounds.size(); i++)
Sound->destroy (Sounds[i]);
Sounds.clear();
// Unregister
Device.seqRender.Remove (this);
Device.seqFrame.Remove (this);
}
void IGame_Level::net_Stop ()
{
// Destroy all objects
Objects.Unload ( );
IR_Release ( );
bReady = false;
}
//-------------------------------------------------------------------------------------------
extern CStatTimer tscreate;
BOOL IGame_Level::Load (u32 dwNum)
{
// Initialize level data
pApp->Level_Set ( dwNum );
string256 temp;
if (!FS.exist(temp, "$level$", "level.ltx"))
Debug.fatal ("Can't find level configuration file '%s'.",temp);
pLevel = xr_new<CInifile> ( temp );
// Open
pApp->LoadTitle ("Opening stream...");
IReader* LL_Stream = FS.r_open ("$level$","level");
IReader &fs = *LL_Stream;
// HUD + Environment
pHUD = (CCustomHUD*)NEW_INSTANCE (CLSID_HUDMANAGER);
// Header
hdrLEVEL H;
fs.r_chunk_safe (fsL_HEADER2,&H,sizeof(H));
R_ASSERT2 (XRCL_PRODUCTION_VERSION==H.XRLC_version,"Incompatible level version.");
// CForms
pApp->LoadTitle ("Loading CFORM...");
ObjectSpace.Load ();
pApp->LoadSwitch ();
// Render-level Load
Render->level_Load (LL_Stream);
tscreate.FrameEnd ();
// Msg ("* S-CREATE: %f ms, %d times",tscreate.result,tscreate.count);
// Objects
pApp->LoadTitle ("Loading game...");
g_pGamePersistent->Environment.mods_load ();
R_ASSERT (Load_GameSpecific_Before());
Objects.Load ();
R_ASSERT (Load_GameSpecific_After ());
// Done
pApp->LoadTitle ("Syncronizing...");
FS.r_close ( LL_Stream );
bReady = true;
if (!g_pGamePersistent->bDedicatedServer) IR_Capture();
Device.seqRender.Add (this);
Device.seqFrame.Add (this);
return TRUE;
}
int psNET_DedicatedSleep = 5;
void IGame_Level::OnRender ( )
{
// if (_abs(Device.fTimeDelta)<EPS_S) return;
// Level render, only when no client output required
if (!g_pGamePersistent->bDedicatedServer) {
Render->Calculate ();
Render->Render ();
} else {
Sleep (psNET_DedicatedSleep);
}
// Font
pApp->pFontSystem->OnRender ();
}
void IGame_Level::OnFrame ( )
{
// Log ("- level:on-frame: ",u32(Device.dwFrame));
// if (_abs(Device.fTimeDelta)<EPS_S) return;
// Play req particle systems
while (ps_needtoplay.size())
{
CPS_Instance* psi = ps_needtoplay.back ();
ps_needtoplay.pop_back ();
psi->Play ();
}
// Update all objects
::Sound->update_events ( );
VERIFY (bReady);
// Engine.Sheduler.Update ( );
Objects.Update ( );
pHUD->OnFrame ( );
// Destroy inactive particle systems
while (ps_destroy.size())
{
CPS_Instance* psi = ps_destroy.back ();
if (psi->Locked()) break;
ps_destroy.pop_back ();
xr_delete (psi);
}
// Ambience
if (Sounds_Random.size() && (Device.dwTimeGlobal > Sounds_Random_dwNextTime))
{
Sounds_Random_dwNextTime = Device.dwTimeGlobal + ::Random.randI (10000,20000);
Fvector pos;
pos.random_dir().normalize().mul(::Random.randF(30,100)).add (Device.vCameraPosition);
int id = ::Random.randI(Sounds_Random.size());
if (Sounds_Random_Enabled) {
Sounds_Random[id].play_at_pos (0,pos,0);
Sounds_Random[id].set_volume (1.f);
Sounds_Random[id].set_range (10,200);
}
}
}
| [
"47507219+ugozapad@users.noreply.github.com"
] | 47507219+ugozapad@users.noreply.github.com |
c1f7f5219881112720e016c1dfdc6e02bc35b80d | 05e6a6cf34af24ac3cc03af28b5cd57a0ad53722 | /PA/skel-lab06/C++/p1/nim.h | 53b92f174b8723d6bd889a17380ac4abffd7cf45 | [] | no_license | KaynRO/Teme-Poli | ff5c64b5deadee816af6dbdf2204790a0a7e75f5 | 3c487ede03fb290b13ef000ff075749f4b342a3c | refs/heads/main | 2023-06-14T02:41:07.313066 | 2021-07-06T20:17:04 | 2021-07-06T20:17:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,221 | h | // skel PA 2017
#pragma once
#define Inf 123456789
#include <vector>
/**
* Reprezinta o mutare efectuata de un jucator
*/
class Move
{
public:
int amount; /* Cantitatea extrasa (1, 2 sau 3) */
int heap; /* Indicile multimii din care se face extragerea */
Move(int amount, int heap);
};
/**
* Reprezinta starea jocului
*/
class Nim
{
public:
int heaps[3];
Nim();
/**
* Returneaza o lista cu mutarile posibile
* care pot fi efectuate de player
*/
std::vector<Move> get_moves(int player);
/**
* Intoarce true daca jocul este intr-o stare finala
*/
bool ended();
/**
* Functia de evaluare a starii curente a jocului
* Evaluarea se face din perspectiva jucatorului
* aflat curent la mutare (player)
*/
int eval(int player);
/**
* Aplica o mutarea a jucatorului asupra starii curente
* Returneaza false daca mutarea e invalida
*/
bool apply_move(const Move &move);
bool undo_move(const Move &move);
/**
* Afiseaza starea jocului
*/
void print();
};
| [
"andrei.grigoras2015@gmail.com"
] | andrei.grigoras2015@gmail.com |
3ad61da3594da801385a405f3767a603f4f490af | 5bd54df4929d1f4f39bf6d93fcc5d4544d4617ce | /src/search/search/stringList.cpp | 7e210ffedfc7129690d20a54ed14b8603f4fde11 | [] | no_license | hairleng/text-retrieval-based-on-Zhihu-Daily | 43737fb7a741c0ad420f930f9f97a38953687187 | 75fbaf93ccbba371d0145cb475bc88020f36a803 | refs/heads/master | 2020-04-14T10:27:00.888493 | 2019-01-02T09:36:04 | 2019-01-02T09:36:04 | 163,787,288 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,612 | cpp | #include "CharString.h"
#include <fstream>
#include "StringList.h"
StringList::StringList()
{
head = new Node;
tail = head;
head->next = nullptr;
}
StringList::~StringList()
{
Node *p;
while (head != nullptr)
{
p = head;
head = head->next;
delete p;
}
}
bool StringList::add(CharString m)//添加节点
{
Node *p = new Node;
p->data = m;
p->next = nullptr;
if (head->next == nullptr)
{
head->next = p;
tail = p;
}
else
{
tail->next = p;
tail = p;
}
return true;
}
bool StringList::removeLast(CharString &m)
{
if (tail == head)
return false;
m = tail->data;
Node *p = head;
while (p->next != tail)
{
p = p->next;
}
delete tail;
tail = p;
tail->next = nullptr;
return true;
}
bool StringList::removeFirst(CharString &m)
{
if (tail == head)
return false;
m = head->next->data;
Node *p = head->next;
head->next = p->next;
if (p == tail)
{
tail = head;
head->next = nullptr;
}
delete p;
return true;
}
void StringList::out(fstream &out)//将节点信息输入到文件中
{
Node *p = head->next;
while (p != nullptr)
{
out << p->data << endl;
p = p->next;
}
}
StringList::StringList(StringList & m)
{
head = new Node;
tail = head;
head->next = nullptr;
Node *q = m.head->next;
while (q != nullptr)
{
add(q->data);
q = q->next;
}
}
StringList & StringList::operator=(StringList m)
{
head = new Node;
tail = head;
head->next = nullptr;
Node *q = m.head->next;
while (q != nullptr)
{
add(q->data);
q = q->next;
}
return *this;
} | [
"annmjy@hotmail.com"
] | annmjy@hotmail.com |
9005c7610a26416242b4c7e53f1929a50d40d4e1 | 1da3f575d8e31e4b6198f173cee53721fbc111a1 | /include/cps/requests/StatusRequest.hpp | 7d53878f68646ec467a1ee979d1d31cada140f48 | [
"MIT"
] | permissive | clusterpoint/cpp-client-api | 4a41f1a1a3508c1a2ca7b1c72dfe1d1d9c735215 | 605825f0d46678c1ebdabb006bc0c138e4b0b7f3 | refs/heads/master | 2021-01-18T23:14:33.136008 | 2017-02-16T12:29:27 | 2017-02-16T12:29:27 | 38,151,345 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 364 | hpp | #ifndef CPS_STATUSREQUEST_HPP
#define CPS_STATUSREQUEST_HPP
#include <string>
#include <vector>
#include <map>
#include "../Request.hpp"
#include "../Utils.hpp"
namespace CPS
{
class StatusRequest: public Request
{
public:
StatusRequest() :
Request("status") {
}
virtual ~StatusRequest() {
}
};
}
#endif //#ifndef CPS_STATUSREQUEST_HPP
| [
"aigars@clusterpoint.com"
] | aigars@clusterpoint.com |
711253ac433fe52d14cc07598a37e73008e524a4 | 45cc90eb9a9753c50e01ea5c0aebf53b3a8fb1b2 | /UHVWorker/serialportinforequest.h | 5b1a499960f64af5d99ad2d3f76808af3a56cae9 | [] | no_license | anphan2410/UHVWorker | 535ab7c7824dde4d6e0e8f51b5b19f2325c8ee22 | 221e1672672028c76f6764a97a6985641d0d1fbb | refs/heads/master | 2021-06-29T22:32:46.564580 | 2017-09-18T04:25:22 | 2017-09-18T04:25:22 | 103,042,207 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 483 | h | #ifndef SERIALPORTINFOREQUEST_H
#define SERIALPORTINFOREQUEST_H
#include <QState>
#include <QTimer>
#include "anlogger.h"
#include "uhvworkervarset.h"
class SerialPortInfoRequest : public QState
{
public:
SerialPortInfoRequest(UHVWorkerVarSet *VarSet, quint32 TimerIntervalInMilisecond = 0);
protected:
void onEntry(QEvent *) override;
void onExit(QEvent *) override;
private:
QTimer timer;
quint32 TimerIntervalMSecs = 0;
};
#endif // SERIALPORTINFOREQUEST_H
| [
"an.phan@ascenx.com"
] | an.phan@ascenx.com |
2cacd83f7ce174baac3cbc5f0f509837245a12d2 | 872bf37c48d5c28c7cc019c0293f66a3cd023f1f | /client/Source/Nova/Public/Gameplay/NovaCharacterHpBarWidget.h | 33b36c2e6270fafc3f2c772f112704f3f11538ea | [
"MIT"
] | permissive | yjun1806/JDefence | 21dbc3a87ca906ec8dc4d0f588feac55d6f4e96a | 72456e15c574bb495df872309e2db42e45f872fa | refs/heads/master | 2022-11-21T22:10:44.034583 | 2020-07-29T12:22:02 | 2020-07-29T12:22:02 | 283,390,900 | 0 | 0 | MIT | 2020-07-29T10:51:11 | 2020-07-29T03:43:32 | C++ | UTF-8 | C++ | false | false | 508 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Nova.h"
#include "Blueprint/UserWidget.h"
#include "NovaCharacter.h"
#include "NovaCharacterHpBarWidget.generated.h"
/**
*
*/
UCLASS()
class NOVA_API UNovaCharacterHpBarWidget : public UUserWidget
{
GENERATED_BODY()
public:
virtual void NativeConstruct() override;
UPROPERTY()
class UProgressBar* HpProgressbar;
public:
UFUNCTION()
void UpdateProgressBar(const ANovaCharacter* chr);
};
| [
"68216755+yjun1806@users.noreply.github.com"
] | 68216755+yjun1806@users.noreply.github.com |
971d5d3b75eb03250b5ee14f71c86b3977aec920 | 897b47032e4658f4861f539ccb837bd594d33bc1 | /src/harjoitus_19.cpp | 525e2d7631d6c33752a25d2cefa5af49d173c3fa | [] | no_license | VABAS/ohjelmoinnin_perusteet_2015S | b6677b1e91cbdae33a60496128c2fab214534605 | b5beabd800ad18992d44fc8c470fadc6ca848c50 | refs/heads/master | 2020-12-24T11:53:13.792503 | 2016-06-28T15:49:04 | 2016-06-28T15:49:04 | 73,104,973 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 679 | cpp | #include <iostream>
using namespace std;
int nopeudet[5];
int nopeus;
int main() {
while (true) {
cout << "Anna nopeus: ";
cin >> nopeus;//Pyydetään uusi nopeus
if (nopeus < 0) {//Lopetetaan jos nopeus on negatiivinen
cout << " => loppu" << endl;
break;
}
for (int i=3;i >= 0;i--) {//Siirretään taulukon arvoja yhdellä eteenpäin
nopeudet[i + 1] = nopeudet[i];
}
nopeudet[0]=nopeus;//Laitetaan ensimmäinen arvo kuten syötetty
int yhteensa = 0;
for (int i = 0;i < 5;i++) {//Lasketaan paljonko nopeudet on yhteenlaskettuna
yhteensa += nopeudet[i];
}
cout << " => " << yhteensa / 5 << " km/h" << endl;//Tulostetaan keskiarvo
}
return 0;
} | [
"jesse.siekkinen@gmail.com"
] | jesse.siekkinen@gmail.com |
15140229726a220d5cece2a4e8bd770129f9eb17 | 32189778fc862030432b8521e94456e3aa947e34 | /Documents/GitHub/repo_bergerb_fawcettm_shawcw_tomatsur/BeeProject/GUIPackage/hiveowner.cpp | 0ef920dd20d25ad92d0b609e4f2005de740fd1a6 | [] | no_license | raytomatsu/minishell | 9b00806665036d18434d7ff9a886aed148b806b7 | fdb953d2c98fd4b921ea313a602ade0cade33849 | refs/heads/main | 2023-03-23T22:05:14.045367 | 2021-03-15T14:04:26 | 2021-03-15T14:04:26 | 347,989,635 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 661 | cpp | #include "hiveowner.h"
#include "ui_hiveowner.h"
HiveOwner::HiveOwner(Controller _cont,QWidget *parent) :
QDialog(parent),
ui(new Ui::HiveOwner)
{
ui->setupUi(this);
cont = _cont;
}
HiveOwner::~HiveOwner()
{
delete ui;
}
/**
* HiveOwner can either request info or configure a hive. Configuring would mean to simulate their hive, and update hive would show them
* the sim of their hives activity
*/
void HiveOwner::on_NewHive_Button_clicked()
{
ConfigHive *cH = new ConfigHive(cont);
cH->show();
}
void HiveOwner::on_UpdateHive_Button_clicked()
{
RequestInfoOneHive *uH = new RequestInfoOneHive(cont);
uH->show();
}
| [
"tomatsur@lafayette.edu"
] | tomatsur@lafayette.edu |
c3ef902354060690e73206e2a6caf29fd3156a47 | a5edf8b84ae791d0c48f2da0a3056c23f595c2ce | /ground_station/3D/GroundStation/GroundStation.cpp | e9bdbff641ec601c74b35b5922762a157ba148fa | [] | no_license | clementnuss/gs_matterhorn | cb9b3910b070fde22062cdbfaacc0bbd71c74108 | d6e9c213c722e26594675b9d4ef28faef39a93b9 | refs/heads/master | 2021-03-27T14:12:58.238039 | 2018-05-18T11:46:28 | 2018-05-18T11:46:28 | 112,453,156 | 2 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 987 | cpp | #include <QtGui/QFont>
#include <QtGui/QFontMetrics>
#include <Qt3DCore/QTransform>
#include "3D/Utils.h"
#include "3D/Billboards/Marker.h"
#include "3D/Billboards/Tracker.h"
#include "3D/ForwardRenderer/LayerManager.h"
#include "GroundStation.h"
GroundStation::GroundStation(QVector3D position, const QString &texture, Qt3DRender::QCamera *camera,
Qt3DCore::QNode *parent)
: Qt3DCore::QEntity(parent),
position_{position},
transform_{new Qt3DCore::QTransform()} {
QMatrix4x4 m{};
m.translate(position_);
transform_->setMatrix(m);
this->addComponent(transform_);
this->addComponent(LayerManager::getInstance().getLayer(LayerType::VISIBLE));
new Tracker(QVector3D{0, 10, 0}, camera, texture, QStringLiteral("GROUND STATION"), TextType::BOLD, this,
{0, 0, 0},
{-8, 1.25, 0});
}
Qt3DCore::QTransform *
GroundStation::getObjectTransform() const {
return transform_;
}
| [
"leandro.kieliger@epfl.ch"
] | leandro.kieliger@epfl.ch |
47a5302b1d3a3aa2cb1d9bc4a1bf9db6195918a9 | d4dba3cb04d83c59a753222d0cefaa479f661aa9 | /자구프/patricia.cpp | 4107ff998d3f57282dd25235827ac7a6149b6660 | [] | no_license | youngsuk0304/algorithm | 5dca6af028b8391eab1240ef23cb2ef6e7a50f55 | d9ad3f68a72d6f8dc612862b93f012f14e6bb992 | refs/heads/master | 2023-04-28T16:32:00.182313 | 2021-05-24T06:47:36 | 2021-05-24T06:47:36 | 197,145,042 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 3,927 | cpp | #include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <queue>
#define length 4
using namespace std;
typedef struct element {
unsigned key;
}element;
typedef struct patriciaTree * Patricia;
typedef struct patriciaTree {
int bitNumber;
int print_check;
element data;
Patricia leftChild, rightChild;
}patriciaTree;
Patricia root;
queue<Patricia> q;
// 해당 key 값에서 bitNumber번 째 값 반환
int bit(unsigned key, int bitNumber) {
unsigned a = 1 << length - 1; // 1000
unsigned b = a >> bitNumber - 1; // 몇번쨰 비트인가
// 해당 bit값 반환
return key & (1 << bitNumber);
}
// 탐색 함수 주어진 key 값을 찾는다
Patricia search(Patricia t, unsigned k)
{
Patricia currentNode, nextNode;
// 루트가 비어있으면 에러처리
if (!t) return NULL; /*empty tree */
// 다음 노드 가지고와서
nextNode = t->leftChild;
currentNode = t;
//찾을때까지 가서 비교한번 후 반환
while (nextNode->bitNumber > currentNode->bitNumber) {
//다음 노드 이동
currentNode = nextNode;
nextNode = (bit(k, nextNode->bitNumber)) ?
nextNode->rightChild : nextNode->leftChild;
}
//찾은 노드 반환
return nextNode;
}
void insert(Patricia *t, element theElement)
{ /* insert theElement into the Patricia tree *t */
Patricia current, parent, lastNode, newNode;
int i;
//트리가 비어있다면
if (!(*t)) {
// 할당 후 첫 노드
*t = (Patricia)calloc(1, sizeof(patriciaTree));
(*t)->bitNumber = 0; (*t)->data = theElement;
(*t)->leftChild = *t; // lch는 자기 자신
return;
}
// 만약 값이 있을 경우
lastNode = search(*t, theElement.key);
if (theElement.key == lastNode->data.key) {
printf("해당 키가 이미 존재합니다!\n");
//success = 0;
return;
}
//처음으로 다른 비트값의 위치 찾아오기
for (i = 1; bit(theElement.key, i) == bit(lastNode->data.key, i); i++);
// 탐색을 위한 세팅
current = (*t)->leftChild;
parent = *t;
// 탐색
while (current->bitNumber > parent->bitNumber && current->bitNumber < i) {
parent = current;
current = (bit(theElement.key, current->bitNumber)) ?
current->rightChild : current->leftChild;
}
// 새로운 노드를 할당한 후
newNode = (Patricia)calloc(1, sizeof(patriciaTree));
newNode->data = theElement;
newNode->bitNumber = i; // 위에서 체크한 값
newNode->leftChild = (bit(theElement.key, i)) ? current : newNode;
newNode->rightChild = (bit(theElement.key, i)) ? newNode : current;
// 어디 연결할지 체크 후 연결
if (current == parent->leftChild)
parent->leftChild = newNode;
else
parent->rightChild = newNode;
}
void printLevelOrder(Patricia root) {
while (!q.empty()) {
Patricia cur;
cur = q.front();
q.pop();
if (cur->leftChild && cur->leftChild->print_check == 0) {
q.push(cur->leftChild);
printf("%d(%d %d %d) ", cur->leftChild->data.key, cur->leftChild->bitNumber, cur->leftChild->leftChild != NULL ? cur->leftChild->leftChild->data.key : -1, cur->leftChild->rightChild != NULL ? cur->leftChild->rightChild->data.key : -1);
cur->leftChild->print_check = 1;
}
if (cur->rightChild &&cur->rightChild->print_check == 0) {
q.push(cur->rightChild);
printf("%d(%d %d %d) ", cur->rightChild->data.key, cur->rightChild->bitNumber, cur->rightChild->leftChild != NULL ? cur->rightChild->leftChild->data.key : -1, cur->rightChild->rightChild != NULL ? cur->rightChild->rightChild->data.key : -1);
cur->rightChild->print_check = 1;
}
}
}
int main() {
int n_input;
cin >> n_input;
for (int i = 0; i < n_input; i++) {
element input;
cin >> input.key;
insert(&root, input);
}
q.push(root);
printf("%d(%d %d %d)\n", root->data.key, root->bitNumber, root->leftChild != NULL ? root->leftChild->data.key : -1, root->rightChild != NULL ? root->rightChild->data.key : -1);
root->print_check = 1;
printLevelOrder(root);
} | [
"djfls0304@naver.com"
] | djfls0304@naver.com |
07de417bd2532742233e64cc5bf9aec2a67fc5e0 | 562643394fa1fbcf7cafcb27abe2dcf53f389639 | /Queues/backdoor.cpp | 87a28f546ce79522c3e65a31d83d12d2f28692fb | [
"Apache-2.0"
] | permissive | jli860/tnvme | 198e03508ba73e6714aa73d37ac073c22fee87f2 | 208943be96c0fe073ed97a7098c0b00a2776ebf9 | refs/heads/master | 2020-03-20T22:14:44.825157 | 2018-06-18T21:47:53 | 2018-06-18T21:47:53 | 137,787,763 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,201 | cpp | /*
* Copyright (c) 2011, Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "backdoor.h"
#include "../Exception/frmwkEx.h"
Backdoor::Backdoor()
{
throw FrmwkEx(HERE, "Illegal constructor");
}
Backdoor::Backdoor(int fd)
{
mFD = fd;
if (mFD < 0)
throw FrmwkEx(HERE, "Object created with a bad FD=%d", fd);
}
Backdoor::~Backdoor()
{
}
void
Backdoor::SetToxicCmdValue(struct backdoor_inject &injectReq)
{
int ret;
// This is volatile, see class level header comment.
if ((ret = ioctl(mFD, NVME_IOCTL_TOXIC_64B_DWORD, &injectReq)) < 0)
throw FrmwkEx(HERE, "Backdoor toxic injection failed: 0x%02X", ret);
}
| [
"todd.rentmeester@intel.com"
] | todd.rentmeester@intel.com |
6deb72af027f0f46fdd5420c4312f04bb03cc2fb | 9259f0e6387e85f4198931f0c489beea8e580bf9 | /10.0.15063.0/winrt/internal/Windows.Security.Authentication.Identity.3.h | 2ee441398a06f7d79e07c6ff9506cf8a606099e5 | [
"MIT",
"LicenseRef-scancode-generic-cla"
] | permissive | part-machine/cppwinrt | 68fdd6ff4be685b9626451e94a113a7c1827fc23 | 5086290db972a5ed15d1a3e3438b57ce2f6eecd2 | refs/heads/master | 2021-01-16T18:39:49.206730 | 2017-07-29T17:54:09 | 2017-07-29T17:54:09 | 100,108,083 | 0 | 0 | null | 2017-08-12T11:28:45 | 2017-08-12T11:28:45 | null | UTF-8 | C++ | false | false | 877 | h | // C++ for the Windows Runtime v1.0.170406.6
// Copyright (c) 2017 Microsoft Corporation. All rights reserved.
#pragma once
#include "Windows.Security.Authentication.Identity.2.h"
WINRT_EXPORT namespace winrt {
namespace Windows::Security::Authentication::Identity {
struct WINRT_EBO EnterpriseKeyCredentialRegistrationInfo :
Windows::Security::Authentication::Identity::IEnterpriseKeyCredentialRegistrationInfo
{
EnterpriseKeyCredentialRegistrationInfo(std::nullptr_t) noexcept {}
};
struct WINRT_EBO EnterpriseKeyCredentialRegistrationManager :
Windows::Security::Authentication::Identity::IEnterpriseKeyCredentialRegistrationManager
{
EnterpriseKeyCredentialRegistrationManager(std::nullptr_t) noexcept {}
static Windows::Security::Authentication::Identity::EnterpriseKeyCredentialRegistrationManager Current();
};
}
}
| [
"kwelton@microsoft.com"
] | kwelton@microsoft.com |
035597aef88bd0667f9e84b1d6196afe6ad2cf78 | 0eaa1053074590eab4585b8eab034cf708dea6b6 | /src/utility/T4Timer.h | 607542006bc7bb7dd7224b03db3db8fe4edbfc7d | [] | no_license | scavallero/T4Stack | 7a03f949701a0150320791c26b4d75d1f3742d1f | 22d15182ce1af6f6c4c5c86057fe8bf69e787e36 | refs/heads/master | 2020-07-30T06:30:13.737558 | 2019-09-29T13:19:21 | 2019-09-29T13:19:21 | 210,118,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,582 | h | #ifndef T4Timer_H
#define T4Timer_H
#include <functional>
#include <Arduino.h>
typedef std::function<void(void)> timer_callback;
class T4Timer {
public:
// maximum number of timers
const static int MAX_TIMERS = 10;
// setTimer() constants
const static int RUN_FOREVER = 0;
const static int RUN_ONCE = 1;
// constructor
T4Timer();
// this function must be called inside loop()
void run();
// call function f every d milliseconds
int setInterval(long d, timer_callback f);
// call function f once after d milliseconds
int setTimeout(long d, timer_callback f);
// call function f every d milliseconds for n times
int setTimer(long d, timer_callback f, int n);
// destroy the specified timer
void deleteTimer(int numTimer);
// restart the specified timer
void restartTimer(int numTimer);
// returns true if the specified timer is enabled
boolean isEnabled(int numTimer);
// enables the specified timer
void enable(int numTimer);
// disables the specified timer
void disable(int numTimer);
// enables the specified timer if it's currently disabled,
// and vice-versa
void toggle(int numTimer);
// returns the number of used timers
int getNumTimers();
// returns the number of available timers
int getNumAvailableTimers() { return MAX_TIMERS - numTimers; };
private:
// deferred call constants
const static int DEFCALL_DONTRUN = 0; // don't call the callback function
const static int DEFCALL_RUNONLY = 1; // call the callback function but don't delete the timer
const static int DEFCALL_RUNANDDEL = 2; // call the callback function and delete the timer
// find the first available slot
int findFirstFreeSlot();
// value returned by the millis() function
// in the previous run() call
unsigned long prev_millis[MAX_TIMERS];
// pointers to the callback functions
timer_callback callbacks[MAX_TIMERS];
// delay values
long delays[MAX_TIMERS];
// number of runs to be executed for each timer
int maxNumRuns[MAX_TIMERS];
// number of executed runs for each timer
int numRuns[MAX_TIMERS];
// which timers are enabled
boolean enabled[MAX_TIMERS];
// deferred function call (sort of) - N.B.: this array is only used in run()
int toBeCalled[MAX_TIMERS];
// actual number of timers in use
int numTimers;
};
#endif
| [
"massimiliano.petra@gmail.com"
] | massimiliano.petra@gmail.com |
e39698642b99e1c39173e0e39f38a693ac034f11 | 95b94c4d2768d5e194792060fa1ac4229cd7ea5a | /code/common/StateMachine/test/StateTest.cpp | 31055daabe6a66b711b87e94089a23e2ccf886ed | [] | no_license | blockspacer/r-type.tek | 06c0efd3b27fe9e3f985263b45979702fd350b69 | 34476f6d29ba1015bb36d68db60bb89bba3f83af | refs/heads/master | 2020-11-24T09:23:15.937589 | 2017-03-05T02:14:45 | 2017-03-05T02:14:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,368 | cpp | //
// Created by tookie on 12/22/16.
//
#include "gtest/gtest.h"
#include "State.hpp"
TEST(State, ConstructState)
{
state_machine::State<std::string> state("s0");
ASSERT_EQ(state.getEdges().size(), 0);
ASSERT_FALSE(state.has("salut"));
}
TEST(State, LinkTwoState)
{
state_machine::State<std::string> state0("s0");
state_machine::State<std::string> state1("s1");
state0.addLink("login", state1);
ASSERT_TRUE(state0.has("login"));
ASSERT_EQ(state0.getEdges().size(), 1);
ASSERT_EQ(state0.getLink("login"), state1.getName());
}
TEST(State, StateMultipleLink)
{
state_machine::State<std::string> init("s0");
state_machine::State<std::string> login("s1");
state_machine::State<std::string> signup("s2");
init.addLink("login", login);
init.addLink("signup", signup);
signup.addLink("ok", init);
ASSERT_TRUE(init.has("login"));
ASSERT_TRUE(init.has("signup"));
ASSERT_FALSE(init.has("ok"));
ASSERT_TRUE(signup.has("ok"));
ASSERT_EQ(init.getEdges().size(), 2);
ASSERT_EQ(signup.getEdges().size(), 1);
ASSERT_EQ(login.getEdges().size(), 0);
ASSERT_EQ(init.getLink("login"), login.getName());
ASSERT_EQ(init.getLink("signup"), signup.getName());
ASSERT_EQ(signup.getLink("ok"), init.getName());
ASSERT_THROW(login.getLink("signup"), std::out_of_range);
} | [
"david.galy@epitech.eu"
] | david.galy@epitech.eu |
c7853f364c9ba7203576a884de82f421c232aaa0 | 09538b228402514c16a32b3fb9b1b0b2c61d6c5d | /include/sec21/units/dimensions/acceleration.h | 4df933bfcef55b99fe72ef8782ffbb4f9e44871a | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | MichaelMiller-/sec21 | f89ff198012f37e051e38ad88bbfc19c656921a0 | 3c436a8ee9d5f9bdb6648d4a6df715d1f0cba766 | refs/heads/master | 2023-08-25T03:40:02.321622 | 2023-08-05T07:36:54 | 2023-08-05T07:36:54 | 35,878,024 | 4 | 1 | null | 2022-12-15T19:14:07 | 2015-05-19T11:27:52 | C++ | UTF-8 | C++ | false | false | 656 | h | #pragma once
#include <sec21/units/dimensions/base_dimensions.h>
#include <sec21/units/quantity.h>
namespace sec21::units
{
using acceleration = dimension<exponent<base_dimension_length, 1>, exponent<base_dimension_time, -2>>;
struct meter_per_second_squared : derived_unit<meter_per_second_squared, acceleration, base_unit> {};
inline namespace literals
{
constexpr auto operator "" _mps_sq(unsigned long long v) noexcept { return quantity<meter_per_second_squared, unsigned long long>{ v }; }
constexpr auto operator "" _mps_sq(long double v) noexcept { return quantity<meter_per_second_squared, long double>{ v }; }
}
}
| [
"miller.michael@gmx.de"
] | miller.michael@gmx.de |
1eecab7282fb3f095c7a04d6136c01afe3ffcfdb | 76b5f9ee57b38bbf99130b5a556a07d733e30cc8 | /tk_hardware_interface/node/arm_hardware_node.cpp | 37192e495e92126305b0785307974e518492bc96 | [] | no_license | tinkerfuroc/tk2_control | 9ab1081986f3818544960323d0ad80a0f9ee9550 | b291c41c55a44a4d768c06260dfb9064c8d623d1 | refs/heads/master | 2021-01-17T09:34:21.643585 | 2017-07-16T11:41:52 | 2017-07-16T11:41:52 | 55,253,889 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 868 | cpp | #include <ros/ros.h>
#include "tk_hardware_interface/arm_hardware.h"
#include <controller_manager/controller_manager.h>
using namespace tinker::control;
int main(int argc, char *argv[]) {
ros::init(argc, argv, "tinker_arm_hardware");
ros::NodeHandle private_nh("~");
ros::NodeHandle n;
XmlRpc::XmlRpcValue arm_info;
private_nh.getParam("arm_info", arm_info);
ArmHardware arm(arm_info);
controller_manager::ControllerManager cm(&arm);
ros::Rate r(10);
ros::Time last_time, now_time;
last_time = ros::Time::now();
ros::AsyncSpinner spinner(4);
spinner.start();
ROS_DEBUG("working...");
while(ros::ok()) {
arm.Read();
now_time = ros::Time::now();
cm.update(ros::Time::now(), now_time-last_time);
arm.Write();
last_time = now_time;
r.sleep();
}
return 0;
}
| [
"amtcmp@126.com"
] | amtcmp@126.com |
85011c10baf542940599d3bd9eb227b2492e4eb4 | 950ec9dd55dc32975c46b3b61b98434edc9b2d0c | /Main/StateManager.cpp | 38c3ea97a95bbaa3a6bad8f70576427b92f93b18 | [] | no_license | aSaul2006/GameEngineProject | a99bb0f73d74388f99758c84ca1215093eba972f | 3b3c5ada569aa1fc86383f90a078ecd439247ad1 | refs/heads/master | 2021-01-10T14:41:14.269844 | 2013-03-04T15:58:13 | 2013-03-04T15:58:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,820 | cpp | /*
This file defines the StateManager class. When running, we do a game loop, passing control to specific methods to handle each loop's processing, while we can
switch states at any time. The time elapsed since the last processing cycle is passed in, so that the new cycle will know how much real time has passed to account for.
We will be replacing most of the console filler with the use of the cores. At first I thought a whole CoreManager class would be necessary, but on second thought, all we need
are includes for each other core's interface class. A CoreManager class is redundant if the cores are already offering up public methods through an interface to use what we
need from them.
*/
#include "StdAfx.h" // Standard library... I think
#include "StateManager.h" // Our StateManager class
#include <iostream> // Now we can work with I/O
#include "MainInterface.h"
#include "..\Render\EngineMain.h"
using namespace std; // Standard namespace in standard library
EngineMain* app;
StateManager::StateManager(void)
{
}
StateManager::StateManager(HINSTANCE h) // Constructor initializing to STARTUP state
{
hInstance = h;
currentState = STARTUP; // Default our current state to STARTUP
cout << "StateManager Created\n"; // Write success to console
}
void StateManager::Run() // Start the game loop
{
bool running = true; // The game is running
DWORD startTime = GetTickCount(); // Returns the amount of milliseconds since system startup, effectively the current time
DWORD elapsedTime = startTime; // No time has passed since the last cycle, on the first cycle
while (running) //Loop each processing cycle until time to shut down StateManager
{
switch (currentState)
{
case STARTUP:
StartUp(elapsedTime);
break;
case TITLE:
Title(elapsedTime);
break;
case MAINMENU:
MainMenu(elapsedTime);
break;
case INGAME:
InGame(elapsedTime);
break;
case PAUSE:
Pause(elapsedTime);
case SHUTDOWN:
ShutDown(elapsedTime);
running = false;
break;
default:
cout << "Error: In unrecognized game state. This is likely caused by a coder adding a new state to the currentState enum without putting a corresponding case in the main game loop.";
cin.ignore(1);
running = false;
break;
}
elapsedTime = GetTickCount() - startTime; // Elapsed time in last cycle is the current time, minus the time when we started
}
}
void StateManager::StartUp(DWORD elapsedTime)
{
//cout << "Elapsed time since last cycle: " + (int) elapsedTime; //TODO: Fix this. I can't currently figure out how to print it out, simple boxing attempts just lead to memory access violations. It's fine in the debugger though, showing like 16 ms to iterate once through start up.
cout << "\nStarting up...\n";
InitRenderingCore(hInstance);
cout << "Startup complete.\n";
currentState = TITLE;
}
//Initialize the rendering core. TODO: Currently just a copy of rendering core's main test method
void StateManager::InitRenderingCore(HINSTANCE hInstance)
{
// Enable run-time memory check for debug builds.
#if defined(DEBUG) | defined(_DEBUG)
_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
app = new EngineMain(hInstance, L"GSP420 CAGE", D3DDEVTYPE_HAL, D3DCREATE_HARDWARE_VERTEXPROCESSING);
g_d3dApp = app;
g_d3dApp->initRender();
}
void StateManager::Title(DWORD elapsedTime)
{
cout << "Title screen displaying.\n";
//STUB: We need to actually draw the title screen and use the proper I/O
cout << "Press enter to simulate pressing the button to move on to main menu.";
cin.ignore(1);
currentState = MAINMENU;
}
void StateManager::MainMenu(DWORD elapsedTime)
{
cout << "Main menu displaying.\n";
//STUB: We need to actually draw the title screen and use the proper I/O
cout << "Press enter to simulate choosing new game.";
cin.ignore(1);
currentState = INGAME;
}
void StateManager::InGame(DWORD elapsedTime)
{
cout << "Game is running.\n";
g_d3dApp->render();
if (app->msg.message == WM_QUIT)
currentState = SHUTDOWN;
//cout << "Press enter to simulate opening pause menu.";
//cin.ignore(1);
//currentState = PAUSE;
}
void StateManager::Pause(DWORD elapsedTime)
{
cout << "Game is paused.\n";
//STUB: We need to draw the pause menu, use the proper I/O.
cout << "Press any key to simulate choosing to quit to desktop.";
cin.ignore(1);
currentState = SHUTDOWN;
}
void StateManager::ShutDown(DWORD elapsedTime)
{
cout << "Shutting down...\n";
//STUB: Prepare to shut down the program.
cout << "Shut down procedures complete. Press any key to close.\n";
cin.ignore(1); // Wait for key
}
StateManager::~StateManager(void) // Destructs the StateManager class
{
//TODO: Insert any needed cleanup code here
cout << "StateManager Destroyed"; //Report success
}
| [
"aaron.saul@PEND-2370.cayusetechnologies.com"
] | aaron.saul@PEND-2370.cayusetechnologies.com |
f7d0a898198aa0231363d93a2252f56bc6ebf826 | a6763ea11cfc1a04ad30212d1f5aa6d7a8905056 | /MagicTowerProject/Classes/candypunk/components/AnimationComponent.cpp | 12d088d7880ef34f4983ec1cc1b55d85b547ac22 | [
"MIT"
] | permissive | Tuuben/MagicTower | bdb8d949103b81fe54a6a5d145c1f2819b50f636 | 6d8740e882bc331644deb0eaf57e5df817618f01 | refs/heads/master | 2021-06-17T04:55:26.676916 | 2017-06-01T10:18:33 | 2017-06-01T10:18:33 | 87,349,063 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,835 | cpp | //
// AnimationComponent.cpp
// MagicTowerProject
//
// Created by Tobias Helsing on 18/02/16.
//
//
#include "AnimationComponent.h"
using namespace cocos2d;
AnimationComponent* AnimationComponent::createComponent(cocos2d::Sprite* animateSprite)
{
AnimationComponent* _animComp = new AnimationComponent();
if(_animComp && _animComp->init(animateSprite))
{
_animComp->autorelease();
return _animComp;
}
CC_SAFE_DELETE(_animComp);
return NULL;
}
bool AnimationComponent::init(cocos2d::Sprite* animateSprite)
{
Component::init();
_animSprite = animateSprite;
this->setName("AnimationComponent");
return true;
}
void AnimationComponent::update(float dt)
{
// CCLOG("===================");
// CCLOG("delta time %f", dt);
// CCLOG("time elapsed %f", _timeElapsed);
// CCLOG("frame index %d", _frameIndex);
// CCLOG("frame rate %d", _frameRate);
// CCLOG("cur animation name %s", _curAnimationName.c_str());
// CCLOG("cur animation size %lu", _currentAnimation.size());
// CCLOG("==================");
if(_currentAnimation.size() <= 0) return;
float frameTime = (1.0f / _frameRate);
_timeElapsed += dt;
if(_timeElapsed >= frameTime)
{
_animSprite->setSpriteFrame(_currentAnimation.at(_frameIndex).c_str());
_timeElapsed = 0;
_frameIndex++;
if( _frameIndex == _currentAnimation.size() && _onAnimFinished != nullptr ) _onAnimFinished();
if(_loop && _frameIndex == _currentAnimation.size() ) _frameIndex = 0;
_frameIndex = (int)clampf(_frameIndex, 0, (_currentAnimation.size() - 1) );
}
}
void AnimationComponent::addAnimation( std::string animationName, std::vector<std::string> frames)
{
_animationsData.insert( std::pair< std::string, std::vector<std::string> >( animationName, frames ) );
}
void AnimationComponent::playAnimation(std::string animationName, int frameRate, bool loop, bool randStart)
{
for(auto itr = _animationsData.begin(); itr != _animationsData.end(); itr++)
{
if(animationName.compare( itr->first ) == 0 )
{
_currentAnimation = itr->second;
}
}
_curAnimationName = animationName;
_loop = loop;
_frameRate = frameRate;
_frameIndex = (!randStart) ? 0 : _currentAnimation.size() * CCRANDOM_0_1();
}
void AnimationComponent::stopAnimation()
{
_timeElapsed = 0;
_frameIndex = 0;
_frameRate = 0;
_loop = false;
_curAnimationName = "";
_currentAnimation.clear();
}
void AnimationComponent::onAnimationFinished(std::function<void ()> onFinnished)
{
_onAnimFinished = onFinnished;
}
std::string AnimationComponent::getCurrentAnimationName()
{
return _curAnimationName;
}
| [
"tobias.helsing@appcandy.com"
] | tobias.helsing@appcandy.com |
28c4f2167567fe26137f9f320f6e484e596ea112 | 4a13e5f02fdce8b67197c7864cd24785320f568b | /stereogramsolver.h | fa2a79d1f5c8cba9b4af8f158458f65da6fd3902 | [] | no_license | silentz/Stegsolve | 7d25aa6f9343bf3250dc787982daa362c7797224 | b65c34d25d01a7d31a7e90c41c45a47bca2312c7 | refs/heads/master | 2021-09-20T16:00:42.886764 | 2018-08-11T15:33:14 | 2018-08-11T15:33:14 | 144,396,508 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 703 | h | #ifndef STEREOGRAMSOLVER_H
#define STEREOGRAMSOLVER_H
#include <QDialog>
#include <QImage>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QScrollArea>
#include <QFileDialog>
#include "imagewidget.h"
class StereogramSolver : public QDialog
{
Q_OBJECT
private:
int offset;
QImage image;
ImageWidget *screen;
void init_interface();
void paint_with_offset();
QImage get_with_offset();
QColor get_new_color(QColor a, QColor b);
private slots:
void left_slot();
void right_slot();
void save_slot();
public:
StereogramSolver(QImage image, QWidget *parent = nullptr);
~StereogramSolver();
};
#endif // STEREOGRAMSOLVER_H
| [
"maxim.pershin@protonmail.com"
] | maxim.pershin@protonmail.com |
140c7384172bb566e4edfed695fddcbdf9b8774a | 7dbb9e7aeb9a189f4533647dfea6d30b6c3bd0ba | /examples/get-started/Serial_Test/main/Serial.cpp | a8b6c2b656c78145db0e53c56a150c8df416e106 | [
"Apache-2.0"
] | permissive | sunischit1/esp-idf | 10f22408423bdb7169129cee73c865269784ef1a | 7593ee2d38c63643be026259e0ab1707b633b0c0 | refs/heads/master | 2021-05-18T18:56:47.227235 | 2020-04-29T15:34:36 | 2020-04-29T15:34:36 | 251,368,604 | 0 | 0 | Apache-2.0 | 2020-03-30T16:47:04 | 2020-03-30T16:47:03 | null | UTF-8 | C++ | false | false | 721 | cpp | #include <esp_log.h>
#include <string>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "Cpp_Uitil.h"
//---------------------------- GPIO Config ---------------//
#define BLINK_GPIO CONFIG_BLINK_GPIO
//--------------------------------------------------------//
static char tag[]="cpp_helloworld";
Cpp_Uitil Debug;
//------------ CPP Interface-----------------------------//
extern "C" {
void app_main(void);
}
//-----------------------------------------------------//
//----------------------------------------------------//
void app_main(void)
{
while(1)
{
ESP_LOGD(tag, "Hello1 %s", "debug1");
Debug.delay(1000);
}
} | [
"sunischitj@gmail.com"
] | sunischitj@gmail.com |
171896e5ab8d25cfb6f35eb20aeab90f97db6ac1 | 8f095f6652c361e8fa9f6593249089b8f444690a | /QuickCreator/main.cpp | 3af3320e85d5f0ecd958fb0b36663a8113e7077d | [
"MIT"
] | permissive | fuzongjian/Qt-demos | 383232cfac6622a750d8bf89b1272363b7feb590 | a869a818ce2863c2b1578e8fb3a02a726a1dcd18 | refs/heads/master | 2021-05-14T01:44:19.215616 | 2019-02-19T11:26:57 | 2019-02-19T11:26:57 | 116,574,936 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 448 | cpp | #include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include "manager.h"
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
//4个参数的含义是:包名、主版本号、此版本号、QML类型名
qmlRegisterType<Manager>("MainManager.module",1,0,"CommonManager");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
| [
"fu_zongjian@163.com"
] | fu_zongjian@163.com |
b0f76bba1da18baa00a0ea1ef3f994b219bfeb0a | c6d6be9062c0664f96dba5a3716bc939f2a3a9de | /src/gamebryo/gamebryomoddatachecker.cpp | ccda8eb910c6d00cbf7d328bc038187853c1a345 | [] | no_license | isanae/modorganizer-game_gamebryo | a09f49b88f85ed71c5dbc4fa51f378ac5e852a58 | 547873b9846b6443eb8054f4fe8c2ff7be631d59 | refs/heads/master | 2021-07-02T20:57:07.593814 | 2020-11-10T16:52:59 | 2020-11-10T16:52:59 | 195,133,095 | 0 | 0 | null | 2019-07-03T22:17:26 | 2019-07-03T22:17:25 | null | UTF-8 | C++ | false | false | 1,516 | cpp | #include <ifiletree.h>
#include "gamebryomoddatachecker.h"
/**
* @return the list of possible folder names in data.
*/
auto GamebryoModDataChecker::possibleFolderNames() const -> const FileNameSet& {
static FileNameSet result{
"fonts", "interface", "menus", "meshes", "music", "scripts", "shaders",
"sound", "strings", "textures", "trees", "video", "facegen", "materials",
"skse", "obse", "mwse", "nvse", "fose", "f4se", "distantlod", "asi",
"SkyProc Patchers", "Tools", "MCM", "icons", "bookart", "distantland",
"mits", "splash", "dllplugins", "CalienteTools", "NetScriptFramework",
"shadersfx"
};
return result;
}
/**
* @return the extensions of possible files in data.
*/
auto GamebryoModDataChecker::possibleFileExtensions() const -> const FileNameSet& {
static FileNameSet result{
"esp", "esm", "esl", "bsa", "ba2", "modgroups"
};
return result;
}
GamebryoModDataChecker::GamebryoModDataChecker(const GameGamebryo* game) : m_Game(game) { }
GamebryoModDataChecker::CheckReturn GamebryoModDataChecker::dataLooksValid(std::shared_ptr<const MOBase::IFileTree> fileTree) const {
auto& folders = possibleFolderNames();
auto& suffixes = possibleFileExtensions();
for (auto entry : *fileTree) {
if (entry->isDir()) {
if (folders.count(entry->name()) > 0) {
return CheckReturn::VALID;
}
}
else {
if (suffixes.count(entry->suffix()) > 0) {
return CheckReturn::VALID;
}
}
}
return CheckReturn::INVALID;
}
| [
"capelle.mikael@gmail.com"
] | capelle.mikael@gmail.com |
9a2760edecd03d7d149c30a6531e3b42e46d58b4 | 05e1f94ae1a5513a222d38dfe4c3c6737cb84251 | /Mulberry/branches/users/shared/externals/v4.1d1/XMLLib/Source/CStreamBuffer.h | c93a1130b4626ce0f1a49331c18e05b88378d2a5 | [
"Apache-2.0"
] | permissive | eskilblomfeldt/mulberry-svn | 16ca9d4d6ec05cbbbd18045c7b59943b0aca9335 | 7ed26b61244e47d4d4d50a1c7cc2d31efa548ad7 | refs/heads/master | 2020-05-20T12:35:42.340160 | 2014-12-24T18:03:50 | 2014-12-24T18:03:50 | 29,127,476 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,560 | h | /*
Copyright (c) 2007 Cyrus Daboo. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef CStreamBuffer_H
#define CStreamBuffer_H
#include <stdint.h>
#include <istream>
class CStreamBuffer
{
public:
CStreamBuffer();
virtual ~CStreamBuffer();
void SetStream(std::istream& is);
void SetData(const char* data);
char operator*()
{
return *bnext;
}
const char* operator++(); // ++p
const char* operator++(int); // p++
CStreamBuffer& operator+=(uint32_t bump);
bool HasData() const
{
return bnext != bbegin;
}
void NeedData(uint32_t amount);
const char* next()
{
return bnext;
}
uint32_t count() const
{
return bcount;
}
uint32_t Remaining()
{
return beof - bnext;
}
bool fail() const
{
return bfail;
}
private:
std::istream* mStream;
const char* mData;
const char* bbegin;
const char* bnext;
const char* beof;
const char* bend;
bool bfail;
uint32_t bcount;
char get();
void ReadMore();
void FillFromStream();
};
#endif // CStreamBuffer_H
| [
"svnusers@a91246af-f21b-0410-bd1c-c3c7fc455132"
] | svnusers@a91246af-f21b-0410-bd1c-c3c7fc455132 |
e039e4df4878ca347b9891c13629f782ac3b4e42 | 05d2f1f01a9d817d4c26dca5d700ab5b3ea86945 | /src/pow/test/test_flt.cpp | 8ee043810f80d94a9734ddbe36b9582782ce8942 | [] | no_license | datavetaren/dipper_pow | 1661f7c24069affea8b8fcd95403da73d9c0d1d5 | 546f069aa5a518086426f4e96f946b0d436c99db | refs/heads/master | 2020-04-16T00:53:50.838654 | 2019-10-03T07:26:15 | 2019-10-03T07:26:15 | 165,154,091 | 4 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,521 | cpp | #include <iostream>
#include <sstream>
#include <assert.h>
#include <math.h>
#include <cmath>
#include <iomanip>
#include "../flt.hpp"
#include <boost/algorithm/string.hpp>
using namespace prologcoin::pow;
static void header( const std::string &str )
{
std::cout << "\n";
std::cout << "--- [" + str + "] " + std::string(60 - str.length(), '-') << "\n";
std::cout << "\n";
}
static bool tol_check(double d, flt1648 v, double tol=0.00001)
{
double vd = v.to_double();
assert((d < 0) == (vd < 0));
if (vd == d) {
return true;
}
double rel = fabs(0.5 - fabs(vd) / (fabs(d)+fabs(vd)));
assert(rel < tol);
return true;
}
const size_t N = 10;
const double db[N] = { 2.3e-7, 2.134e+10, -5.91352e+5, 2.12345e-3, 2e+256,
123.456e-127, 42e-42, -99e+42, -5e-17, -4.321e+19 };
flt1648 fl[N];
class next_count {
public:
friend std::ostream & operator << (std::ostream &out, const next_count &nc);
};
static int cnt = 0;
inline std::ostream & operator << (std::ostream &out, const next_count &nc) {
cnt++;
out << "[" << cnt << "]: ";
return out;
}
static void test_flt_init()
{
std::cout.precision(17);
for (size_t i = 0; i < N; i++) {
int exp = 0;
double frac = frexp(db[i], &exp);
fl[i] = flt1648( exp, fxp1648(frac));
std::cout << next_count() << "db[" << i << "]=" << db[i] << std::endl;
std::cout << next_count() << "fl[" << i << "]=" << fl[i] << std::endl;
tol_check(db[i], fl[i]);
}
}
static void test_flt_add()
{
header("test_flt_add");
for (size_t i = 0; i < N; i++) {
for (size_t j = 0; j < N; j++) {
double ad = db[i], bd = db[j];
flt1648 af = fl[i], bf = fl[j];
std::cout << next_count() << ad << "+" << bd << "=" << (ad+bd) << std::endl;
std::cout << next_count() << af << "+" << bf << "=" << (af+bf) << std::endl;
tol_check((ad+bd), (af+bf));
}
}
}
static void test_flt_sub()
{
header("test_flt_sub");
for (size_t i = 0; i < N; i++) {
for (size_t j = 0; j < N; j++) {
double ad = db[i], bd = db[j];
flt1648 af = fl[i], bf = fl[j];
std::cout << next_count() << ad << "-" << bd << "=" << (ad-bd) << std::endl;
std::cout << next_count() << af << "-" << bf << "=" << (af-bf) << std::endl;
tol_check((ad-bd), (af-bf));
}
}
}
static void test_flt_mul()
{
header("test_flt_mul");
for (size_t i = 0; i < N; i++) {
for (size_t j = 0; j < N; j++) {
double ad = db[i], bd = db[j];
flt1648 af = fl[i], bf = fl[j];
std::cout << next_count() << ad << "*" << bd << "=" << (ad*bd) << std::endl;
std::cout << next_count() << af << "*" << bf << "=" << (af*bf) << std::endl;
tol_check((ad*bd), (af*bf));
}
}
}
static void test_flt_div()
{
header("test_flt_div");
for (size_t i = 0; i < N; i++) {
for (size_t j = 0; j < N; j++) {
double ad = db[i], bd = db[j];
flt1648 af = fl[i], bf = fl[j];
std::cout << next_count() << ad << "/" << bd << "=" << (ad/bd) << std::endl;
std::cout << next_count() << af << "/" << bf << "=" << (af/bf) << std::endl;
tol_check((ad/bd), (af/bf));
}
}
}
static void test_flt_reciprocal()
{
header("test_flt_reciprocal");
for (size_t i = 0; i < N; i++) {
double ad = db[i];
flt1648 af = fl[i];
double ad_reciprocal = 1.0 / ad;
flt1648 af_reciprocal = af.reciprocal();
std::cout << next_count() << ad << " reciprocal=" << ad_reciprocal << std::endl;
std::cout << next_count() << af << " reciprocal=" << af_reciprocal << std::endl;
tol_check(ad_reciprocal, af_reciprocal);
}
}
static void test_flt_values()
{
header("test_flt_values");
auto v = flt1648::from(12, 1234567);
std::cout << "VALUE: " << v.to_double() << std::endl;
tol_check(12.1234567, v);
}
static void test_bitcoin_difficulty()
{
header("test_bitcoin_difficulty");
auto base_value = flt1648(0x0404cb);
auto mult_value = flt1648(1) << (8*(0x1b - 3));
auto target_value = base_value * mult_value;
std::string expect = "0x00000000000404CB000000000000000000000000000000000000000000000000";
auto target = "0x" + boost::to_upper_copy(target_value.to_integer_string(32));
std::cout << "TARGET: " << target << std::endl;
std::cout << "EXPECT: " << expect << std::endl;
assert( expect == target );
auto max_value = flt1648(0x00ffff) * (flt1648(1) << (8*(0x1d - 3)));
auto difficulty = max_value / target_value;
std::cout << "Difficulty: " << difficulty.to_double() << std::endl;
std::cout << "Expect : 16307.42..." << std::endl;
assert(abs(difficulty.to_double() - 16307.42) < 0.01);
}
static void test_our_difficulty()
{
header("test_out_difficulty");
auto base_value = flt1648(16307) << 32;
auto target_value = flt1648(1) / base_value;
auto difficulty = flt1648(1) - target_value;
std::cout << "DIFFICULTY: " << difficulty.to_double() << std::endl;
auto rel_target = flt1648(1) - difficulty;
std::cout << "REL TARGET: " << rel_target.to_double() << std::endl;
auto max_target = flt1648(1) << 256;
auto target = rel_target * max_target;
std::cout << "TARGET : " << target.to_double() << std::endl;
std::cout << "TARGET INT: 0x" << target.to_integer_string(32) << std::endl;
}
int main(int argc, char *argv[])
{
test_flt_init();
test_flt_add();
test_flt_sub();
test_flt_mul();
test_flt_div();
test_flt_reciprocal();
test_flt_values();
test_bitcoin_difficulty();
test_our_difficulty();
return 0;
}
| [
"datavetaren@datavetaren.se"
] | datavetaren@datavetaren.se |
6f5a742284f0c5d8c1b0f8ce1f6d3ce67f0b3faf | c9d185c5b6fa17ad5bb282de0983dc331ea729f6 | /src/Client/GUI3/Widgets/Controls/TextField.cpp | c382fe2a52535d45a3cb0a28fd7083f36b0c51ce | [
"MIT"
] | permissive | Marukyu/RankCheck | 4812011d7bf2499dbec86d0d269b07947f78b847 | cf3005a2ba6f66bd66f27e0e42ca6b0ccb907014 | refs/heads/master | 2021-05-02T10:48:50.875640 | 2020-04-20T17:33:45 | 2020-04-20T17:33:45 | 120,764,636 | 12 | 3 | null | 2020-04-20T22:52:45 | 2018-02-08T13:26:48 | C++ | UTF-8 | C++ | false | false | 7,521 | cpp | #include <Client/GUI3/Events/Key.hpp>
#include <Client/GUI3/Events/KeyEvent.hpp>
#include <Client/GUI3/Events/MouseEvent.hpp>
#include <Client/GUI3/Events/StateEvent.hpp>
#include <Client/GUI3/Pieces/Text.hpp>
#include <Client/GUI3/Rendering/Primitives/Box.hpp>
#include <Client/GUI3/Rendering/Primitives/Gradient.hpp>
#include <Client/GUI3/Rendering/Primitives/Outline.hpp>
#include <Client/GUI3/Utils/Canvas.hpp>
#include <Client/GUI3/Widgets/Controls/TextField.hpp>
#include <SFML/System/Vector2.hpp>
#include <SFML/Window/Keyboard.hpp>
#include <Shared/Config/CompositeTypes.hpp>
#include <Shared/Config/Config.hpp>
#include <Shared/Utils/MiscMath.hpp>
#include <algorithm>
namespace gui3
{
TextField::TextField() :
myMouseMonitor(*this)
{
myText = addPiece<pieces::Text>();
myText->setAlignment(pieces::Text::ALIGN_LEFT, pieces::Text::ALIGN_CENTER);
addStateCallback([this](StateEvent event)
{
repaint();
}, StateEvent::FocusGained | StateEvent::FocusLost);
addStateCallback([this](StateEvent event)
{
updateConfig();
}, StateEvent::ConfigChanged);
addMouseCallback([this](MouseEvent event)
{
if (event.button == MouseEvent::Left)
{
std::size_t pos = myText->getCharacterAtPosition(event.position);
if (pos != std::string::npos)
{
handleAbsoluteMove(pos);
}
}
}, MouseEvent::ButtonDown);
addMouseCallback([this](MouseEvent event)
{
if (myMouseMonitor.isMouseDown(MouseEvent::Left))
{
std::size_t pos = myText->getCharacterAtPosition(event.position);
if (pos != std::string::npos)
{
setSelectionEnd(pos);
}
}
}, MouseEvent::Move);
addKeyboardCallback([this](KeyEvent event)
{
handleKeyEvent(event);
}, KeyEvent::Any);
}
TextField::TextField(std::string text) :
TextField()
{
setText(text);
}
TextField::~TextField()
{
}
void TextField::setText(std::string text)
{
myText->setString(text);
setSelection(getSelectionStart(), getSelectionEnd());
fireEvent(Event::Changed);
}
const std::string & TextField::getText() const
{
return myText->getString();
}
void TextField::setSelection(std::size_t start, std::size_t end)
{
start = std::min(start, getText().size());
end = std::min(end, getText().size());
if (mySelection.start != start || mySelection.end != end)
{
mySelection.start = start;
mySelection.end = end;
fireEvent(Event::SelectionChanged);
repaint();
}
}
void TextField::setCursorPosition(std::size_t position)
{
setSelection(position, position);
}
void TextField::setSelectionStart(std::size_t start)
{
setSelection(start, getSelectionEnd());
}
void TextField::setSelectionEnd(std::size_t end)
{
setSelection(getSelectionStart(), end);
}
std::size_t TextField::getSelectionStart() const
{
return mySelection.start;
}
std::size_t TextField::getSelectionEnd() const
{
return mySelection.end;
}
std::size_t TextField::getSelectionLeft() const
{
return isSelectionLeft() ? getSelectionEnd() : getSelectionStart();
}
std::size_t TextField::getSelectionRight() const
{
return isSelectionLeft() ? getSelectionStart() : getSelectionEnd();
}
std::size_t TextField::getSelectionLength() const
{
return getSelectionRight() - getSelectionLeft();
}
bool TextField::isSelectionLeft() const
{
return getSelectionStart() > getSelectionEnd();
}
bool TextField::isTextSelected() const
{
return getSelectionStart() != getSelectionEnd();
}
CallbackHandle<TextField::Event> TextField::addEventCallback(EventFunc<Event> func, int typeFilter, int order)
{
return myEventCallbacks.addCallback(func, typeFilter, order);
}
void TextField::fireEvent(Event event)
{
myEventCallbacks.fireCallback(event.type, event);
}
void TextField::onRepaint(Canvas& canvas)
{
int flags = primitives::Box::Background | primitives::Box::Dark;
if (isFocused())
{
flags |= primitives::Box::Focused;
}
canvas.draw(primitives::Box(getBaseRect(), flags));
if (isFocused())
{
static cfg::Color topColor("gui.widgets.textField.selection.topColor");
static cfg::Color bottomColor("gui.widgets.textField.selection.bottomColor");
static cfg::Color outlineColor("gui.widgets.textField.selection.outlineColor");
static cfg::Float outlineThickness("gui.widgets.textField.selection.outlineThickness");
sf::FloatRect selectRect = myText->getSelectionBox(getSelectionLeft(), getSelectionLength());
primitives::Gradient selectionGradient(selectRect, primitives::Gradient::Vertical, config().get(topColor),
config().get(bottomColor));
primitives::Outline selectionOutline(selectRect, -config().get(outlineThickness), config().get(outlineColor));
if (!isTextSelected())
{
myText->paint(canvas);
}
canvas.draw(selectionGradient);
canvas.draw(selectionOutline);
if (isTextSelected())
{
myText->paint(canvas);
}
}
else
{
myText->paint(canvas);
}
}
void TextField::updateConfig()
{
static cfg::Vector2f configMargins("gui.widgets.textField.margins");
sf::Vector2f margins = config().get(configMargins);
myText->setResizeFunction(Piece::generateResizeFunction(margins.x, margins.y));
}
void TextField::handleKeyEvent(KeyEvent event)
{
switch (event.type)
{
case KeyEvent::Input:
{
// TODO: Handle unicode better.
char enteredCharacter = 0;
if (event.character >= 32 && event.character < 256 && event.character != 127)
{
enteredCharacter = (unsigned char) event.character;
}
if (enteredCharacter != 0)
{
replaceSelectedText(std::string(1, enteredCharacter));
setCursorPosition(getSelectionLeft() + 1);
}
break;
}
case KeyEvent::Press:
if (event.key.isShift())
{
myIsSelectModifierPressed = true;
}
if (event.key.isControl())
{
myIsWordModifierPressed = true;
}
switch (Key::toSFML(event.key))
{
case sf::Keyboard::Left:
handleRelativeMove(-1);
break;
case sf::Keyboard::Right:
handleRelativeMove(1);
break;
case sf::Keyboard::Up:
break;
case sf::Keyboard::Down:
break;
case sf::Keyboard::Delete:
handleDelete();
break;
case sf::Keyboard::BackSpace:
handleBackspace();
break;
default:
break;
}
break;
case KeyEvent::Release:
if (event.key.isShift())
{
myIsSelectModifierPressed = false;
}
if (event.key.isControl())
{
myIsWordModifierPressed = false;
}
break;
default:
break;
}
}
void TextField::replaceSelectedText(std::string replacement)
{
std::string textPieceLeft = getText().substr(0, getSelectionLeft());
std::string textPieceRight = getText().substr(getSelectionRight());
setText(textPieceLeft + replacement + textPieceRight);
fireEvent(Event::UserChanged);
setCursorPosition(getSelectionLeft());
}
void TextField::handleRelativeMove(int offset)
{
handleAbsoluteMove(getSelectionEnd() + offset);
}
void TextField::handleAbsoluteMove(int index)
{
index = clamp<int>(0, index, getText().size());
if (myIsSelectModifierPressed)
{
setSelectionEnd(index);
}
else
{
setCursorPosition(index);
}
fireEvent(Event::UserSelectionChanged);
}
void TextField::handleDelete()
{
if (isTextSelected())
{
replaceSelectedText("");
}
else if (getSelectionRight() < getText().size())
{
std::string text = getText();
text.erase(getSelectionLeft(), 1);
setText(text);
fireEvent(Event::UserChanged);
}
}
void TextField::handleBackspace()
{
if (isTextSelected())
{
replaceSelectedText("");
}
else if (getSelectionLeft() != 0)
{
std::size_t pos = getSelectionLeft() - 1;
std::string text = getText();
text.erase(pos, 1);
setText(text);
fireEvent(Event::UserChanged);
setCursorPosition(pos);
}
}
}
| [
"defmenge@googlemail.com"
] | defmenge@googlemail.com |
7d0380c1ad557742abc9fe1ed7ab74a0ed30da90 | b20e78f18d43591b63553e81905d8c100f63d68c | /src/libtsduck/tsTargetIPv6SlashDescriptor.cpp | ab7476de2b9d19d739ab1d58effcc19fa00e8170 | [
"WTFPL",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | kxp/tsduck | c221f72734c411cdcb8bbad6c385797560dac58f | 53063b35be048c2945a206a22bd1c72d1d178fda | refs/heads/master | 2020-04-23T12:34:11.657348 | 2019-02-16T15:02:31 | 2019-02-16T15:02:31 | 171,173,582 | 1 | 0 | null | 2019-02-17T21:18:02 | 2019-02-17T21:18:01 | null | UTF-8 | C++ | false | false | 5,920 | cpp | //----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2019, Thierry Lelegard
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
//
//----------------------------------------------------------------------------
#include "tsTargetIPv6SlashDescriptor.h"
#include "tsTablesDisplay.h"
#include "tsTablesFactory.h"
#include "tsxmlElement.h"
TSDUCK_SOURCE;
#define MY_XML_NAME u"target_IPv6_slash_descriptor"
#define MY_DID ts::DID_INT_IPV6_SLASH
#define MY_TID ts::TID_INT
TS_XML_TABSPEC_DESCRIPTOR_FACTORY(ts::TargetIPv6SlashDescriptor, MY_XML_NAME, MY_TID);
TS_ID_DESCRIPTOR_FACTORY(ts::TargetIPv6SlashDescriptor, ts::EDID::TableSpecific(MY_DID, MY_TID));
TS_ID_DESCRIPTOR_DISPLAY(ts::TargetIPv6SlashDescriptor::DisplayDescriptor, ts::EDID::TableSpecific(MY_DID, MY_TID));
//----------------------------------------------------------------------------
// Constructors
//----------------------------------------------------------------------------
ts::TargetIPv6SlashDescriptor::TargetIPv6SlashDescriptor() :
AbstractDescriptor(MY_DID, MY_XML_NAME),
addresses()
{
_is_valid = true;
}
ts::TargetIPv6SlashDescriptor::TargetIPv6SlashDescriptor(const Descriptor& desc, const DVBCharset* charset) :
TargetIPv6SlashDescriptor()
{
deserialize(desc, charset);
}
ts::TargetIPv6SlashDescriptor::Address::Address(const IPv6Address& addr, uint8_t mask) :
IPv6_addr(addr),
IPv6_slash_mask(mask)
{
}
//----------------------------------------------------------------------------
// Serialization
//----------------------------------------------------------------------------
void ts::TargetIPv6SlashDescriptor::serialize(Descriptor& desc, const DVBCharset* charset) const
{
ByteBlockPtr bbp(serializeStart());
for (auto it = addresses.begin(); it != addresses.end(); ++it) {
bbp->append(it->IPv6_addr.toBytes());
bbp->appendUInt8(it->IPv6_slash_mask);
}
serializeEnd(desc, bbp);
}
//----------------------------------------------------------------------------
// Deserialization
//----------------------------------------------------------------------------
void ts::TargetIPv6SlashDescriptor::deserialize(const Descriptor& desc, const DVBCharset* charset)
{
const uint8_t* data = desc.payload();
size_t size = desc.payloadSize();
_is_valid = desc.isValid() && desc.tag() == _tag && size % 17 == 0;
addresses.clear();
if (_is_valid) {
while (size >= 17) {
addresses.push_back(Address(IPv6Address(data, 16), data[16]));
data += 17; size -= 17;
}
}
}
//----------------------------------------------------------------------------
// Static method to display a descriptor.
//----------------------------------------------------------------------------
void ts::TargetIPv6SlashDescriptor::DisplayDescriptor(TablesDisplay& display, DID did, const uint8_t* data, size_t size, int indent, TID tid, PDS pds)
{
std::ostream& strm(display.out());
const std::string margin(indent, ' ');
while (size >= 17) {
strm << margin << "Address/mask: " << IPv6Address(data, 16) << "/" << int(data[16]) << std::endl;
data += 17; size -= 17;
}
display.displayExtraData(data, size, indent);
}
//----------------------------------------------------------------------------
// XML serialization
//----------------------------------------------------------------------------
void ts::TargetIPv6SlashDescriptor::buildXML(xml::Element* root) const
{
for (auto it = addresses.begin(); it != addresses.end(); ++it) {
xml::Element* e = root->addElement(u"address");
e->setIPv6Attribute(u"IPv6_addr", it->IPv6_addr);
e->setIntAttribute(u"IPv6_slash_mask", it->IPv6_slash_mask);
}
}
//----------------------------------------------------------------------------
// XML deserialization
//----------------------------------------------------------------------------
void ts::TargetIPv6SlashDescriptor::fromXML(const xml::Element* element)
{
addresses.clear();
xml::ElementVector children;
_is_valid =
checkXMLName(element) &&
element->getChildren(children, u"address", 0, MAX_ENTRIES);
for (size_t i = 0; _is_valid && i < children.size(); ++i) {
Address addr;
_is_valid =
children[i]->getIPv6Attribute(addr.IPv6_addr, u"IPv6_addr", true) &&
children[i]->getIntAttribute(addr.IPv6_slash_mask, u"IPv6_slash_mask", true);
if (_is_valid) {
addresses.push_back(addr);
}
}
}
| [
"thierry@lelegard.fr"
] | thierry@lelegard.fr |
6c19496510420a78f7ff22cecdfc0e7f4ff9e9fb | 6f8d5ceb7ab4118490b530f536b65b7f1b3fb5c1 | /PGRproject/src/VertexBuffer.cpp | 8ac45bcc49665ceef07ccc1f2c3268f277859a7d | [] | no_license | Mizumaky/PGRproject | 64a441d6731e4bcdec7a40f130b62df67af060bc | 39af64841a1a88ec030c36be5b7ca9f06f65f60e | refs/heads/master | 2020-05-21T18:28:11.968835 | 2019-05-26T21:53:30 | 2019-05-26T21:53:30 | 186,133,390 | 0 | 0 | null | 2019-05-26T21:53:31 | 2019-05-11T12:59:54 | C++ | UTF-8 | C++ | false | false | 757 | cpp | #include "VertexBuffer.h"
#include "pgr.h"
namespace mullemi5 {
VertexBuffer::VertexBuffer(const void* data, unsigned int size) {
//prepare an array buffer
glGenBuffers(1, &m_rendererId); //generate
bind(); //bind - this is the buffer we will be currently setting stuff to
glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW); //prepare the storage for data, also STATIC DRAW indicates to opengl that the data will be written only like once, but read often, and will be used for drawing
unbind();
}
VertexBuffer::~VertexBuffer() {
glDeleteBuffers(1, &m_rendererId);
}
void VertexBuffer::bind() const {
glBindBuffer(GL_ARRAY_BUFFER, m_rendererId);
}
void VertexBuffer::unbind() const {
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
} | [
"mullemi5@fel.cvut.cz"
] | mullemi5@fel.cvut.cz |
8c861c2112e5f2a477598873af736875c92c02aa | 57bb8e46197961214fad2ad9ee4fb9116e9f39ec | /DPPIR/sockets/server_socket.cc | 1eb532ef892bd7c86babb142fc2878aabdc249ee | [
"MIT"
] | permissive | multiparty/DP-PIR | aa33a11c9e230ddca3df79330d58df42b6a64544 | dce32d2f69bef59318adb662161c29553d3660b5 | refs/heads/master | 2023-03-07T11:45:32.219948 | 2022-08-23T20:04:29 | 2022-08-23T20:04:29 | 167,214,670 | 7 | 0 | MIT | 2022-12-15T22:33:01 | 2019-01-23T16:26:26 | C++ | UTF-8 | C++ | false | false | 1,447 | cc | #include "DPPIR/sockets/server_socket.h"
#include <iostream>
#include "DPPIR/sockets/common.h"
namespace DPPIR {
namespace sockets {
// Listen on port and accept connection.
void ServerSocket::Initialize(int port) {
std::cout << "Creating server and accepting connections..." << std::endl;
std::cout << "On port " << port << std::endl;
common::ListenOn(port, &this->sockfd_, 1);
std::cout << "Client connected!" << std::endl;
}
// Logistics.
index_t ServerSocket::ReadCount() {
index_t count = 0;
common::Read(this->sockfd_, reinterpret_cast<char*>(&count), sizeof(count));
return count;
}
void ServerSocket::SendReady() {
char ready = 1;
common::Send(this->sockfd_, &ready, sizeof(ready));
}
// Buffered reads.
CipherLogicalBuffer& ServerSocket::ReadCiphers(index_t read_count) {
common::Read(this->sockfd_, read_count, &this->cipher_rbuf_);
return this->cipher_rbuf_;
}
LogicalBuffer<Query>& ServerSocket::ReadQueries(index_t read_count) {
common::Read(this->sockfd_, read_count, &this->query_rbuf_);
return this->query_rbuf_;
}
// Buffered send.
void ServerSocket::SendResponse(const Response& response) {
this->response_wbuf_.PushBack(response);
if (this->response_wbuf_.Full()) {
this->FlushResponses();
}
}
// Buffer flush.
void ServerSocket::FlushResponses() {
common::Send(this->sockfd_, &this->response_wbuf_);
this->response_wbuf_.Clear();
}
} // namespace sockets
} // namespace DPPIR
| [
"kinan.bab.14@gmail.com"
] | kinan.bab.14@gmail.com |
97d7d07913eb4fe148a06df1fe9ef695b644aaec | c90e66dee3abc7d59308e005a814e4fdc499d914 | /DLL_FORM_TEMPLATE/MainForm.h | 66b4ec6a9d62f69522d456e1025fc508f69da107 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | sh1nu11bi/pandora_injection_downloader_gui_cpp_cli | 65299a36f5edfd9fc93346d6ba408e4c89256cfe | 177ca107805ef60346829ad85a82ac48e5a8926d | refs/heads/master | 2021-05-08T20:10:16.117010 | 2016-02-05T00:22:04 | 2016-02-05T00:22:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,703 | h | #pragma once
#include "unmanaged.h"
#pragma managed
namespace DLL_FORM_TEMPLATE
{
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::IO;
using namespace System::Net;
using namespace System::Drawing;
using namespace System::Diagnostics;
using namespace System::Runtime::InteropServices;
public ref class MainForm : public System::Windows::Forms::Form
{
public:
MainForm(void)
{
FilesDownloaded = 0;
InitializeComponent();
}
protected:
~MainForm(void)
{
if( components )
{
delete components;
}
}
#pragma region Windows Form Designer generated code
private:
System::Windows::Forms::Timer^ UpdateData_Timer;
CheckBox^ chkbxSaveMusic;
GroupBox^ grpbxMain;
ProgressBar^ progressbar;
Label^ lblStatus;
Label^ lblGellin;
IContainer^ components;
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->chkbxSaveMusic = (gcnew System::Windows::Forms::CheckBox());
this->UpdateData_Timer = (gcnew System::Windows::Forms::Timer(this->components));
this->grpbxMain = (gcnew System::Windows::Forms::GroupBox());
this->lblStatus = (gcnew System::Windows::Forms::Label());
this->progressbar = (gcnew System::Windows::Forms::ProgressBar());
this->lblGellin = (gcnew System::Windows::Forms::Label());
this->grpbxMain->SuspendLayout();
this->SuspendLayout();
//
// chkbxSaveMusic
//
this->chkbxSaveMusic->AutoSize = true;
this->chkbxSaveMusic->BackColor = System::Drawing::Color::Transparent;
this->chkbxSaveMusic->Checked = true;
this->chkbxSaveMusic->CheckState = System::Windows::Forms::CheckState::Checked;
this->chkbxSaveMusic->ForeColor = System::Drawing::Color::Black;
this->chkbxSaveMusic->Location = System::Drawing::Point(44, 22);
this->chkbxSaveMusic->Name = L"chkbxSaveMusic";
this->chkbxSaveMusic->Size = System::Drawing::Size(15, 14);
this->chkbxSaveMusic->TabIndex = 10;
this->chkbxSaveMusic->UseVisualStyleBackColor = false;
//
// UpdateData_Timer
//
this->UpdateData_Timer->Enabled = true;
this->UpdateData_Timer->Interval = 500;
this->UpdateData_Timer->Tick += gcnew System::EventHandler(this, &MainForm::UpdateData_Timer_Tick);
//
// grpbxMain
//
this->grpbxMain->BackColor = System::Drawing::Color::WhiteSmoke;
this->grpbxMain->Controls->Add(this->lblStatus);
this->grpbxMain->Controls->Add(this->progressbar);
this->grpbxMain->Controls->Add(this->chkbxSaveMusic);
this->grpbxMain->ForeColor = System::Drawing::Color::Black;
this->grpbxMain->Location = System::Drawing::Point(14, 7);
this->grpbxMain->Name = L"grpbxMain";
this->grpbxMain->Size = System::Drawing::Size(171, 86);
this->grpbxMain->TabIndex = 4;
this->grpbxMain->TabStop = false;
//
// lblStatus
//
this->lblStatus->AutoSize = true;
this->lblStatus->BackColor = System::Drawing::Color::Transparent;
this->lblStatus->ForeColor = System::Drawing::Color::Black;
this->lblStatus->Location = System::Drawing::Point(42, 68);
this->lblStatus->Name = L"lblStatus";
this->lblStatus->Size = System::Drawing::Size(0, 13);
this->lblStatus->TabIndex = 12;
this->lblStatus->SizeChanged += gcnew System::EventHandler(this, &MainForm::lblStatus_SizeChanged);
//
// progressbar
//
this->progressbar->Location = System::Drawing::Point(35, 45);
this->progressbar->Name = L"progressbar";
this->progressbar->Size = System::Drawing::Size(100, 13);
this->progressbar->TabIndex = 11;
//
// lblGellin
//
this->lblGellin->AutoSize = true;
this->lblGellin->BackColor = System::Drawing::Color::Transparent;
this->lblGellin->ForeColor = System::Drawing::Color::Black;
this->lblGellin->Location = System::Drawing::Point(33, 98);
this->lblGellin->Name = L"lblGellin";
this->lblGellin->Size = System::Drawing::Size(134, 13);
this->lblGellin->TabIndex = 10;
this->lblGellin->Text = L"Developed By: Team Zeus";
//
// MainForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->BackColor = System::Drawing::Color::WhiteSmoke;
this->ClientSize = System::Drawing::Size(199, 116);
this->Controls->Add(this->lblGellin);
this->Controls->Add(this->grpbxMain);
this->ForeColor = System::Drawing::Color::Transparent;
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
this->MaximizeBox = false;
this->MinimizeBox = false;
this->Name = L"MainForm";
this->ShowIcon = false;
this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
this->TopMost = true;
this->Load += gcnew System::EventHandler(this, &MainForm::MainForm_Load);
this->grpbxMain->ResumeLayout(false);
this->grpbxMain->PerformLayout();
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
Int32 FilesDownloaded;
Void MainForm_Load(System::Object^ sender, System::EventArgs^ e)
{
unmanaged->EncryptStrings();
Text = gcnew String( unmanaged->szTitle );
//lblGellin->Text = gcnew String( unmanaged->szDev );
lblStatus->Text = gcnew String( unmanaged->szStatus );
grpbxMain->Text = gcnew String( unmanaged->szGrpbx );
chkbxSaveMusic->Text = gcnew String( unmanaged->szChkbx );
unmanaged->DestroyInitStrings();
unmanaged->sGuiCreated = 1;
}
Void CenterLabelinGroupbox( Control^ o, Label^ l )
{
Point Pos = l->Location;
Pos.X = ( o->Size.Width / 2 ) - ( l->Size.Width / 2 );
l->Location = Pos;
}
Void SuspendDrawing(HWND handle)
{
::SendMessage( handle, WM_SETREDRAW, (WPARAM)FALSE, NULL );
}
Void ResumeDrawing(HWND handle)
{
::SendMessage( handle, WM_SETREDRAW, (WPARAM)TRUE, NULL );
}
Void DownloadFileCompleted(System::Object ^sender, AsyncCompletedEventArgs ^e)
{
progressbar->Value = 0;
lblStatus->Text = "Download Complete, Waiting";
}
Void DownloadProgressChanged(System::Object ^sender, DownloadProgressChangedEventArgs ^e)
{
progressbar->Value = e->ProgressPercentage;
}
Void Download(String^ url, String^ Location)
{
WebClient^ _WebClient = gcnew WebClient();
_WebClient->DownloadFileCompleted += gcnew AsyncCompletedEventHandler( this, &MainForm::DownloadFileCompleted );
_WebClient->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler( this, &MainForm::DownloadProgressChanged );
_WebClient->DownloadFileAsync( gcnew Uri( url ), Location );
}
Void UpdateData_Timer_Tick(System::Object^ sender, System::EventArgs^ e)
{
if( chkbxSaveMusic->Checked )
{
if( unmanaged->isFiletoDownload )
{
unmanaged->isFiletoDownload = FALSE;
FilesDownloaded += 1;
String^ Location = gcnew String( unmanaged->szLocation );
String^ SongName/* = gcnew String( unmanaged->szSongName )*/;
//if( SongName == "" )
SongName = "Unknown" + FilesDownloaded.ToString();
if( !Directory::Exists( "C:\\Pandora" ) )
Directory::CreateDirectory( "C:\\Pandora" );
Download( Location, "C:\\Pandora\\" + SongName + ".mp4" );
lblStatus->Text = "File Downloading";
}
}
}
Void lblStatus_SizeChanged(System::Object^ sender, System::EventArgs^ e)
{
SuspendDrawing( (HWND)Handle.ToPointer() );
CenterLabelinGroupbox( grpbxMain, lblStatus );
ResumeDrawing( (HWND)Handle.ToPointer() );
Refresh();
}
};
}
#pragma endregion | [
"cjack.tx@gmail.com"
] | cjack.tx@gmail.com |
af70a8bda0602699bfe4df974a9dd367838dcdfa | 667786dd8dacdf6828ff329419f377f9a2112c0b | /Problems/CodeForces Contests/Sunday Contests/09:04:2016/hw.cpp | 1de7484fd8b1891231df604420840915060f53ec | [] | no_license | BedirT/Algorithms_and_DS | 50de96c8e707422f51510eda0e155880d76eed0e | 083a6325b8be70108832eda1bf43eb9f3b9eb011 | refs/heads/master | 2022-09-09T22:29:55.090031 | 2022-09-06T22:04:06 | 2022-09-06T22:04:06 | 51,181,386 | 45 | 27 | null | 2020-03-06T10:36:26 | 2016-02-05T23:46:56 | C++ | UTF-8 | C++ | false | false | 862 | cpp | #include <iostream>
#include <cstring>
using namespace std;
int t;
long long a, b, k;
long long cellsv[10000001];
bool cellsw[10000001];
void primes(long long n){
memset(cellsw, true, sizeof cellsw);
long long i,j;
for (i = 2; i <= n; i++)
if (cellsw[i]){
for (j = i; j <= n ; j+=i ){
cellsw[j] = false;
cellsv[j]++;
}
}
}
int main()
{
cin >> t;
primes(10000001);
int ct = t;
while (t--) {
scanf("%lld %lld %lld", &a, &b, &k);
// cin >> a >> b >> k;
long long counter = 0;
for (long long i = a; i <= b; ++i) {
if (cellsv[i] == k) {
counter++;
}
}
printf("Case #%d: %lld\n", ct-t, counter);
// cout << "Case #" << ct - t << ": " << counter << endl;
}
} | [
"bedir.tapkan.53@gmail.com"
] | bedir.tapkan.53@gmail.com |
cbcf673f8edf4aff2eb5acacf568241dfe5b0d3f | 46e1a1a0ddb28eaf4486f86bd16357cf865ea448 | /GameEngineV3/GameEngine3D/Core/Game3D.cpp | a9f9ddf407e2b68b7fd90889e94ed2992a96dc6c | [
"MIT"
] | permissive | adgalad/GameEngineV2 | 0b85446f1e63df7719fd281088d120cb044b3f03 | 1aaa1a510556584e0179ad691cc42de12545abef | refs/heads/master | 2021-05-04T10:41:16.516625 | 2017-10-06T04:18:08 | 2017-10-06T04:18:08 | 47,952,114 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 161 | cpp | //
// Game3D.cpp
// GameEngineV3
//
// Created by Carlos Spaggiari Roa on 5/19/17.
// Copyright © 2017 ARSC. All rights reserved.
//
#include "Game3D.hpp"
| [
"carlos.25896@gmail.com"
] | carlos.25896@gmail.com |
eeb36444ea4c281344b6487e7eca9d1ce8358a33 | b4660cc8fa3ce045508105fa52228a98fa19a87d | /src/converter/converter.cc | 976f6ce9e48a521944ee0d378c97b0b0591e219f | [
"BSD-3-Clause",
"LicenseRef-scancode-unicode",
"LicenseRef-scancode-public-domain"
] | permissive | hnakamur/mozc-deb | 81e9b561863e57da73aa9ba90d24ff5d0bca480b | a0d6db21786ae7fc54806714cbeca6c7c74cbd36 | refs/heads/master | 2021-04-15T09:32:03.635220 | 2018-05-04T10:09:23 | 2018-05-04T10:09:23 | 126,575,465 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 36,500 | cc | // Copyright 2010-2016, Google Inc.
// 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 Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "converter/converter.h"
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include "base/logging.h"
#include "base/number_util.h"
#include "base/port.h"
#include "base/util.h"
#include "composer/composer.h"
#include "converter/immutable_converter_interface.h"
#include "converter/segments.h"
#include "dictionary/dictionary_interface.h"
#include "dictionary/pos_matcher.h"
#include "dictionary/suppression_dictionary.h"
#include "prediction/predictor_interface.h"
#include "request/conversion_request.h"
#include "rewriter/rewriter_interface.h"
#include "transliteration/transliteration.h"
#include "usage_stats/usage_stats.h"
using mozc::dictionary::POSMatcher;
using mozc::dictionary::SuppressionDictionary;
using mozc::usage_stats::UsageStats;
namespace mozc {
namespace {
const size_t kErrorIndex = static_cast<size_t>(-1);
size_t GetSegmentIndex(const Segments *segments,
size_t segment_index) {
const size_t history_segments_size = segments->history_segments_size();
const size_t result = history_segments_size + segment_index;
if (result >= segments->segments_size()) {
return kErrorIndex;
}
return result;
}
void SetKey(Segments *segments, const string &key) {
segments->set_max_history_segments_size(4);
segments->clear_conversion_segments();
mozc::Segment *seg = segments->add_segment();
DCHECK(seg);
seg->Clear();
seg->set_key(key);
seg->set_segment_type(mozc::Segment::FREE);
VLOG(2) << segments->DebugString();
}
bool IsMobile(const ConversionRequest &request) {
return request.request().zero_query_suggestion() &&
request.request().mixed_conversion();
}
bool IsValidSegments(const ConversionRequest &request,
const Segments &segments) {
// All segments should have candidate
for (size_t i = 0; i < segments.segments_size(); ++i) {
if (segments.segment(i).candidates_size() != 0) {
continue;
}
// On mobile, we don't distinguish candidates and meta candidates
// So it's ok if we have meta candidates even if we don't have candidates
// TODO(team): we may remove mobile check if other platforms accept
// meta candidate only segment
if (IsMobile(request) && segments.segment(i).meta_candidates_size() != 0) {
continue;
}
return false;
}
return true;
}
// Extracts the last substring that consists of the same script type.
// Returns true if the last substring is successfully extracted.
// Examples:
// - "" -> false
// - "x " -> "x" / ALPHABET
// - "x " -> false
// - "C60" -> "60" / NUMBER
// - "200x" -> "x" / ALPHABET
// (currently only NUMBER and ALPHABET are supported)
bool ExtractLastTokenWithScriptType(const string &text,
string *last_token,
Util::ScriptType *last_script_type) {
last_token->clear();
*last_script_type = Util::SCRIPT_TYPE_SIZE;
ConstChar32ReverseIterator iter(text);
if (iter.Done()) {
return false;
}
// Allow one whitespace at the end.
if (iter.Get() == ' ') {
iter.Next();
if (iter.Done()) {
return false;
}
if (iter.Get() == ' ') {
return false;
}
}
std::vector<char32> reverse_last_token;
Util::ScriptType last_script_type_found = Util::GetScriptType(iter.Get());
for (; !iter.Done(); iter.Next()) {
const char32 w = iter.Get();
if ((w == ' ') || (Util::GetScriptType(w) != last_script_type_found)) {
break;
}
reverse_last_token.push_back(w);
}
*last_script_type = last_script_type_found;
// TODO(yukawa): Replace reverse_iterator with const_reverse_iterator when
// build failure on Android is fixed.
for (std::vector<char32>::reverse_iterator it = reverse_last_token.rbegin();
it != reverse_last_token.rend(); ++it) {
Util::UCS4ToUTF8Append(*it, last_token);
}
return true;
}
// Tries normalizing input text as a math expression, where full-width numbers
// and math symbols are converted to their half-width equivalents except for
// some special symbols, e.g., "×", "÷", and "・". Returns false if the input
// string contains non-math characters.
bool TryNormalizingKeyAsMathExpression(StringPiece s, string *key) {
key->reserve(s.size());
for (ConstChar32Iterator iter(s); !iter.Done(); iter.Next()) {
// Half-width arabic numbers.
if ('0' <= iter.Get() && iter.Get() <= '9') {
key->append(1, static_cast<char>(iter.Get()));
continue;
}
// Full-width arabic numbers ("0" -- "9")
if (0xFF10 <= iter.Get() && iter.Get() <= 0xFF19) {
const char c = iter.Get() - 0xFF10 + '0';
key->append(1, c);
continue;
}
switch (iter.Get()) {
case 0x002B: case 0xFF0B: // "+", "+"
key->append(1, '+');
break;
case 0x002D: case 0x30FC: // "-", "ー"
key->append(1, '-');
break;
case 0x002A: case 0xFF0A: case 0x00D7: // "*", "*", "×"
key->append(1, '*');
break;
case 0x002F: case 0xFF0F: case 0x30FB: case 0x00F7:
// "/", "/", "・", "÷"
key->append(1, '/');
break;
case 0x0028: case 0xFF08: // "(", "("
key->append(1, '(');
break;
case 0x0029: case 0xFF09: // ")", ")"
key->append(1, ')');
break;
case 0x003D: case 0xFF1D: // "=", "="
key->append(1, '=');
break;
default:
return false;
}
}
return true;
}
} // namespace
ConverterImpl::ConverterImpl() : pos_matcher_(NULL),
immutable_converter_(NULL),
general_noun_id_(kuint16max) {
}
ConverterImpl::~ConverterImpl() {}
void ConverterImpl::Init(const POSMatcher *pos_matcher,
const SuppressionDictionary *suppression_dictionary,
PredictorInterface *predictor,
RewriterInterface *rewriter,
ImmutableConverterInterface *immutable_converter) {
// Initializes in order of declaration.
pos_matcher_ = pos_matcher;
suppression_dictionary_ = suppression_dictionary;
predictor_.reset(predictor);
rewriter_.reset(rewriter);
immutable_converter_ = immutable_converter;
general_noun_id_ = pos_matcher_->GetGeneralNounId();
}
bool ConverterImpl::StartConversionForRequest(const ConversionRequest &request,
Segments *segments) const {
if (!request.has_composer()) {
LOG(ERROR) << "Request doesn't have composer";
return false;
}
string conversion_key;
switch (request.composer_key_selection()) {
case ConversionRequest::CONVERSION_KEY:
request.composer().GetQueryForConversion(&conversion_key);
break;
case ConversionRequest::PREDICTION_KEY:
request.composer().GetQueryForPrediction(&conversion_key);
break;
default:
LOG(FATAL) << "Should never reach here";
}
if (conversion_key.empty()) {
return false;
}
SetKey(segments, conversion_key);
segments->set_request_type(Segments::CONVERSION);
immutable_converter_->ConvertForRequest(request, segments);
RewriteAndSuppressCandidates(request, segments);
TrimCandidates(request, segments);
return IsValidSegments(request, *segments);
}
bool ConverterImpl::StartConversion(Segments *segments,
const string &key) const {
if (key.empty()) {
return false;
}
SetKey(segments, key);
segments->set_request_type(Segments::CONVERSION);
const ConversionRequest default_request;
immutable_converter_->ConvertForRequest(default_request, segments);
RewriteAndSuppressCandidates(default_request, segments);
TrimCandidates(default_request, segments);
return IsValidSegments(default_request, *segments);
}
bool ConverterImpl::StartReverseConversion(Segments *segments,
const string &key) const {
segments->Clear();
if (key.empty()) {
return false;
}
SetKey(segments, key);
// Check if |key| looks like a math expression. In such case, there's no
// chance to get the correct reading by the immutable converter. Rather,
// simply returns normalized value.
{
string value;
if (TryNormalizingKeyAsMathExpression(key, &value)) {
Segment::Candidate *cand =
segments->mutable_segment(0)->push_back_candidate();
cand->Init();
cand->key = key;
cand->value.swap(value);
return true;
}
}
segments->set_request_type(Segments::REVERSE_CONVERSION);
if (!immutable_converter_->Convert(segments)) {
return false;
}
if (segments->segments_size() == 0) {
LOG(WARNING) << "no segments from reverse conversion";
return false;
}
for (int i = 0; i < segments->segments_size(); ++i) {
const mozc::Segment &seg = segments->segment(i);
if (seg.candidates_size() == 0 ||
seg.candidate(0).value.empty()) {
segments->Clear();
LOG(WARNING) << "got an empty segment from reverse conversion";
return false;
}
}
return true;
}
// static
void ConverterImpl::MaybeSetConsumedKeySizeToCandidate(
size_t consumed_key_size, Segment::Candidate* candidate) {
if (candidate->attributes & Segment::Candidate::PARTIALLY_KEY_CONSUMED) {
// If PARTIALLY_KEY_CONSUMED is set already,
// the candidate has set appropriate attribute and size by predictor.
return;
}
candidate->attributes |= Segment::Candidate::PARTIALLY_KEY_CONSUMED;
candidate->consumed_key_size = consumed_key_size;
}
// static
void ConverterImpl::MaybeSetConsumedKeySizeToSegment(size_t consumed_key_size,
Segment* segment) {
for (size_t i = 0; i < segment->candidates_size(); ++i) {
MaybeSetConsumedKeySizeToCandidate(consumed_key_size,
segment->mutable_candidate(i));
}
for (size_t i = 0; i < segment->meta_candidates_size(); ++i) {
MaybeSetConsumedKeySizeToCandidate(consumed_key_size,
segment->mutable_meta_candidate(i));
}
}
// TODO(noriyukit): |key| can be a member of ConversionRequest.
bool ConverterImpl::Predict(const ConversionRequest &request,
const string &key,
const Segments::RequestType request_type,
Segments *segments) const {
const Segments::RequestType original_request_type = segments->request_type();
if ((original_request_type != Segments::PREDICTION &&
original_request_type != Segments::PARTIAL_PREDICTION) ||
segments->conversion_segments_size() == 0 ||
segments->conversion_segment(0).key() != key) {
// - If the original request is not prediction relating one
// (e.g. conversion), invoke SetKey because current segments has
// data for conversion, not prediction.
// - If the segment size is 0, invoke SetKey because the segments is not
// correctly prepared.
// - If the key of the segments differs from the input key,
// invoke SetKey because current segments should be completely reset.
// - Otherwise keep current key and candidates.
//
// This SetKey omitting is for mobile predictor.
// On normal inputting, we are showing suggestion results. When users
// push expansion button, we will add prediction results just after the
// suggestion results. For this, we don't reset segments for prediction.
// However, we don't have to do so for suggestion. Here, we are deciding
// whether the input key is changed or not by using segment key. This is not
// perfect because for roman input, conversion key is not updated by
// incomplete input, for example, conversion key is "あ" for the input "a",
// and will still be "あ" for the input "ak". For avoiding mis-reset of
// the results, we will reset always for suggestion request type.
SetKey(segments, key);
}
DCHECK_EQ(1, segments->conversion_segments_size());
DCHECK_EQ(key, segments->conversion_segment(0).key());
segments->set_request_type(request_type);
predictor_->PredictForRequest(request, segments);
RewriteAndSuppressCandidates(request, segments);
TrimCandidates(request, segments);
if (request_type == Segments::PARTIAL_SUGGESTION ||
request_type == Segments::PARTIAL_PREDICTION) {
// Here 1st segment's key is the query string of
// the partial prediction/suggestion.
// e.g. If the composition is "わた|しは", the key is "わた".
// If partial prediction/suggestion candidate is submitted,
// all the characters which are located from the head to the cursor
// should be submitted (in above case "わた" should be submitted).
// To do this, PARTIALLY_KEY_CONSUMED and consumed_key_sizconsumed_key_size
// should be set.
// Note that this process should be done in a predictor because
// we have to do this on the candidates created by rewriters.
MaybeSetConsumedKeySizeToSegment(
Util::CharsLen(key), segments->mutable_conversion_segment(0));
}
return IsValidSegments(request, *segments);
}
bool ConverterImpl::StartPredictionForRequest(const ConversionRequest &request,
Segments *segments) const {
if (!request.has_composer()) {
LOG(ERROR) << "Composer is NULL";
return false;
}
string prediction_key;
request.composer().GetQueryForPrediction(&prediction_key);
return Predict(request, prediction_key, Segments::PREDICTION, segments);
}
bool ConverterImpl::StartPrediction(Segments *segments,
const string &key) const {
const ConversionRequest default_request;
return Predict(default_request, key, Segments::PREDICTION, segments);
}
bool ConverterImpl::StartSuggestion(Segments *segments,
const string &key) const {
const ConversionRequest default_request;
return Predict(default_request, key, Segments::SUGGESTION, segments);
}
bool ConverterImpl::StartSuggestionForRequest(const ConversionRequest &request,
Segments *segments) const {
DCHECK(request.has_composer());
string prediction_key;
request.composer().GetQueryForPrediction(&prediction_key);
return Predict(request, prediction_key, Segments::SUGGESTION, segments);
}
bool ConverterImpl::StartPartialSuggestion(Segments *segments,
const string &key) const {
const ConversionRequest default_request;
return Predict(default_request, key, Segments::PARTIAL_SUGGESTION, segments);
}
bool ConverterImpl::StartPartialSuggestionForRequest(
const ConversionRequest &request, Segments *segments) const {
DCHECK(request.has_composer());
const size_t cursor = request.composer().GetCursor();
if (cursor == 0 || cursor == request.composer().GetLength()) {
return StartSuggestionForRequest(request, segments);
}
string conversion_key;
request.composer().GetQueryForConversion(&conversion_key);
conversion_key = Util::SubString(conversion_key, 0, cursor);
return Predict(request, conversion_key,
Segments::PARTIAL_SUGGESTION, segments);
}
bool ConverterImpl::StartPartialPrediction(Segments *segments,
const string &key) const {
const ConversionRequest default_request;
return Predict(default_request, key, Segments::PARTIAL_PREDICTION, segments);
}
bool ConverterImpl::StartPartialPredictionForRequest(
const ConversionRequest &request, Segments *segments) const {
DCHECK(request.has_composer());
const size_t cursor = request.composer().GetCursor();
if (cursor == 0 || cursor == request.composer().GetLength()) {
return StartPredictionForRequest(request, segments);
}
string conversion_key;
request.composer().GetQueryForConversion(&conversion_key);
conversion_key = Util::SubString(conversion_key, 0, cursor);
return Predict(request, conversion_key,
Segments::PARTIAL_PREDICTION, segments);
}
bool ConverterImpl::FinishConversion(const ConversionRequest &request,
Segments *segments) const {
CommitUsageStats(segments, segments->history_segments_size(),
segments->conversion_segments_size());
for (size_t i = 0; i < segments->segments_size(); ++i) {
Segment *seg = segments->mutable_segment(i);
DCHECK(seg);
// revert SUBMITTED segments to FIXED_VALUE
// SUBMITTED segments are created by "submit first segment" operation
// (ctrl+N for ATOK keymap).
// To learn the conversion result, we should change the segment types
// to FIXED_VALUE.
if (seg->segment_type() == Segment::SUBMITTED) {
seg->set_segment_type(Segment::FIXED_VALUE);
}
if (seg->candidates_size() > 0) {
CompletePOSIds(seg->mutable_candidate(0));
}
}
segments->clear_revert_entries();
rewriter_->Finish(request, segments);
predictor_->Finish(request, segments);
// Remove the front segments except for some segments which will be
// used as history segments.
const int start_index = max(
0,
static_cast<int>(segments->segments_size()
- segments->max_history_segments_size()));
for (int i = 0; i < start_index; ++i) {
segments->pop_front_segment();
}
// Remaining segments are used as history segments.
for (size_t i = 0; i < segments->segments_size(); ++i) {
Segment *seg = segments->mutable_segment(i);
DCHECK(seg);
seg->set_segment_type(Segment::HISTORY);
}
return true;
}
bool ConverterImpl::CancelConversion(Segments *segments) const {
segments->clear_conversion_segments();
return true;
}
bool ConverterImpl::ResetConversion(Segments *segments) const {
segments->Clear();
return true;
}
bool ConverterImpl::RevertConversion(Segments *segments) const {
if (segments->revert_entries_size() == 0) {
return true;
}
predictor_->Revert(segments);
segments->clear_revert_entries();
return true;
}
bool ConverterImpl::ReconstructHistory(Segments *segments,
const string &preceding_text) const {
segments->Clear();
string key;
string value;
uint16 id;
if (!GetLastConnectivePart(preceding_text, &key, &value, &id)) {
return false;
}
Segment *segment = segments->add_segment();
segment->set_key(key);
segment->set_segment_type(Segment::HISTORY);
Segment::Candidate *candidate = segment->push_back_candidate();
candidate->rid = id;
candidate->lid = id;
candidate->content_key = key;
candidate->key = key;
candidate->content_value = value;
candidate->value = value;
candidate->attributes = Segment::Candidate::NO_LEARNING;
return true;
}
bool ConverterImpl::CommitSegmentValueInternal(
Segments *segments, size_t segment_index, int candidate_index,
Segment::SegmentType segment_type) const {
segment_index = GetSegmentIndex(segments, segment_index);
if (segment_index == kErrorIndex) {
return false;
}
Segment *segment = segments->mutable_segment(segment_index);
const int values_size = static_cast<int>(segment->candidates_size());
if (candidate_index < -transliteration::NUM_T13N_TYPES ||
candidate_index >= values_size) {
return false;
}
segment->set_segment_type(segment_type);
segment->move_candidate(candidate_index, 0);
if (candidate_index != 0) {
segment->mutable_candidate(0)->attributes |= Segment::Candidate::RERANKED;
}
return true;
}
bool ConverterImpl::CommitSegmentValue(Segments *segments, size_t segment_index,
int candidate_index) const {
return CommitSegmentValueInternal(segments, segment_index, candidate_index,
Segment::FIXED_VALUE);
}
bool ConverterImpl::CommitPartialSuggestionSegmentValue(
Segments *segments, size_t segment_index, int candidate_index,
const string ¤t_segment_key, const string &new_segment_key) const {
DCHECK_GT(segments->conversion_segments_size(), 0);
const size_t raw_segment_index = GetSegmentIndex(segments, segment_index);
if (!CommitSegmentValueInternal(segments, segment_index, candidate_index,
Segment::SUBMITTED)) {
return false;
}
CommitUsageStats(segments, raw_segment_index, 1);
Segment *segment = segments->mutable_segment(raw_segment_index);
DCHECK_LT(0, segment->candidates_size());
const Segment::Candidate &submitted_candidate = segment->candidate(0);
const bool auto_partial_suggestion =
Util::CharsLen(submitted_candidate.key) != Util::CharsLen(segment->key());
segment->set_key(current_segment_key);
Segment *new_segment = segments->insert_segment(raw_segment_index + 1);
new_segment->set_key(new_segment_key);
DCHECK_GT(segments->conversion_segments_size(), 0);
if (auto_partial_suggestion) {
UsageStats::IncrementCount("CommitAutoPartialSuggestion");
} else {
UsageStats::IncrementCount("CommitPartialSuggestion");
}
return true;
}
bool ConverterImpl::FocusSegmentValue(Segments *segments,
size_t segment_index,
int candidate_index) const {
segment_index = GetSegmentIndex(segments, segment_index);
if (segment_index == kErrorIndex) {
return false;
}
return rewriter_->Focus(segments, segment_index, candidate_index);
}
bool ConverterImpl::FreeSegmentValue(Segments *segments,
size_t segment_index) const {
segment_index = GetSegmentIndex(segments, segment_index);
if (segment_index == kErrorIndex) {
return false;
}
Segment *segment = segments->mutable_segment(segment_index);
segment->set_segment_type(Segment::FREE);
if (segments->request_type() != Segments::CONVERSION) {
return false;
}
return immutable_converter_->Convert(segments);
}
bool ConverterImpl::CommitSegments(
Segments *segments,
const std::vector<size_t> &candidate_index) const {
const size_t conversion_segment_index = segments->history_segments_size();
for (size_t i = 0; i < candidate_index.size(); ++i) {
// 2nd argument must always be 0 because on each iteration
// 1st segment is submitted.
// Using 0 means submitting 1st segment iteratively.
if (!CommitSegmentValueInternal(segments, 0, candidate_index[i],
Segment::SUBMITTED)) {
return false;
}
}
CommitUsageStats(segments, conversion_segment_index, candidate_index.size());
return true;
}
bool ConverterImpl::ResizeSegment(Segments *segments,
const ConversionRequest &request,
size_t segment_index,
int offset_length) const {
if (segments->request_type() != Segments::CONVERSION) {
return false;
}
// invalid request
if (offset_length == 0) {
return false;
}
segment_index = GetSegmentIndex(segments, segment_index);
if (segment_index == kErrorIndex) {
return false;
}
// the last segments cannot become longer
if (offset_length > 0 && segment_index == segments->segments_size() - 1) {
return false;
}
const Segment &cur_segment = segments->segment(segment_index);
const size_t cur_length = Util::CharsLen(cur_segment.key());
// length cannot become 0
if (cur_length + offset_length == 0) {
return false;
}
const string cur_segment_key = cur_segment.key();
if (offset_length > 0) {
int length = offset_length;
string last_key;
size_t last_clen = 0;
{
string new_key = cur_segment_key;
while (segment_index + 1 < segments->segments_size()) {
last_key = segments->segment(segment_index + 1).key();
segments->erase_segment(segment_index + 1);
last_clen = Util::CharsLen(last_key.c_str(), last_key.size());
length -= static_cast<int>(last_clen);
if (length <= 0) {
string tmp;
Util::SubString(last_key, 0, length + last_clen, &tmp);
new_key += tmp;
break;
}
new_key += last_key;
}
Segment *segment = segments->mutable_segment(segment_index);
segment->Clear();
segment->set_segment_type(Segment::FIXED_BOUNDARY);
segment->set_key(new_key);
} // scope out |segment|, |new_key|
if (length < 0) { // remaining part
Segment *segment = segments->insert_segment(segment_index + 1);
segment->set_segment_type(Segment::FREE);
string new_key;
Util::SubString(last_key,
static_cast<size_t>(length + last_clen),
static_cast<size_t>(-length), &new_key);
segment->set_key(new_key);
}
} else if (offset_length < 0) {
if (cur_length + offset_length > 0) {
Segment *segment1 = segments->mutable_segment(segment_index);
segment1->Clear();
segment1->set_segment_type(Segment::FIXED_BOUNDARY);
string new_key;
Util::SubString(cur_segment_key,
0,
cur_length + offset_length,
&new_key);
segment1->set_key(new_key);
}
if (segment_index + 1 < segments->segments_size()) {
Segment *segment2 = segments->mutable_segment(segment_index + 1);
segment2->set_segment_type(Segment::FREE);
string tmp;
Util::SubString(cur_segment_key,
max(static_cast<size_t>(0), cur_length + offset_length),
cur_length,
&tmp);
tmp += segment2->key();
segment2->set_key(tmp);
} else {
Segment *segment2 = segments->add_segment();
segment2->set_segment_type(Segment::FREE);
string new_key;
Util::SubString(cur_segment_key,
max(static_cast<size_t>(0), cur_length + offset_length),
cur_length,
&new_key);
segment2->set_key(new_key);
}
}
segments->set_resized(true);
immutable_converter_->ConvertForRequest(request, segments);
RewriteAndSuppressCandidates(request, segments);
TrimCandidates(request, segments);
return true;
}
bool ConverterImpl::ResizeSegment(Segments *segments,
const ConversionRequest &request,
size_t start_segment_index,
size_t segments_size,
const uint8 *new_size_array,
size_t array_size) const {
if (segments->request_type() != Segments::CONVERSION) {
return false;
}
const size_t kMaxArraySize = 256;
start_segment_index = GetSegmentIndex(segments, start_segment_index);
const size_t end_segment_index = start_segment_index + segments_size;
if (start_segment_index == kErrorIndex ||
end_segment_index <= start_segment_index ||
end_segment_index > segments->segments_size() ||
array_size > kMaxArraySize) {
return false;
}
string key;
for (size_t i = start_segment_index; i < end_segment_index; ++i) {
key += segments->segment(i).key();
}
if (key.empty()) {
return false;
}
size_t consumed = 0;
const size_t key_len = Util::CharsLen(key);
std::vector<string> new_keys;
new_keys.reserve(array_size + 1);
for (size_t i = 0; i < array_size; ++i) {
if (new_size_array[i] != 0 && consumed < key_len) {
new_keys.push_back(Util::SubString(key, consumed, new_size_array[i]));
consumed += new_size_array[i];
}
}
if (consumed < key_len) {
new_keys.push_back(Util::SubString(key, consumed, key_len - consumed));
}
segments->erase_segments(start_segment_index, segments_size);
for (size_t i = 0; i < new_keys.size(); ++i) {
Segment *seg = segments->insert_segment(start_segment_index + i);
seg->set_segment_type(Segment::FIXED_BOUNDARY);
seg->set_key(new_keys[i]);
}
segments->set_resized(true);
immutable_converter_->ConvertForRequest(request, segments);
RewriteAndSuppressCandidates(request, segments);
TrimCandidates(request, segments);
return true;
}
void ConverterImpl::CompletePOSIds(Segment::Candidate *candidate) const {
DCHECK(candidate);
if (candidate->value.empty() || candidate->key.empty()) {
return;
}
if (candidate->lid != 0 && candidate->rid != 0) {
return;
}
// Use general noun, unknown word ("サ変") tend to produce
// "する" "して", which are not always acceptable for non-sahen words.
candidate->lid = general_noun_id_;
candidate->rid = general_noun_id_;
const size_t kExpandSizeStart = 5;
const size_t kExpandSizeDiff = 50;
const size_t kExpandSizeMax = 80;
// In almost all cases, user choses the top candidate.
// In order to reduce the latency, first, expand 5 candidates.
// If no valid candidates are found within 5 candidates, expand
// candidates step-by-step.
for (size_t size = kExpandSizeStart; size < kExpandSizeMax;
size += kExpandSizeDiff) {
Segments segments;
SetKey(&segments, candidate->key);
// use PREDICTION mode, as the size of segments after
// PREDICTION mode is always 1, thanks to real time conversion.
// However, PREDICTION mode produces "predictions", meaning
// that keys of result candidate are not always the same as
// query key. It would be nice to have PREDICTION_REALTIME_CONVERSION_ONLY.
segments.set_request_type(Segments::PREDICTION);
segments.set_max_prediction_candidates_size(size);
// In order to complete POSIds, call ImmutableConverter again.
if (!immutable_converter_->Convert(&segments)) {
LOG(ERROR) << "ImmutableConverter::Convert() failed";
return;
}
for (size_t i = 0; i < segments.segment(0).candidates_size(); ++i) {
const Segment::Candidate &ref_candidate =
segments.segment(0).candidate(i);
if (ref_candidate.value == candidate->value) {
candidate->lid = ref_candidate.lid;
candidate->rid = ref_candidate.rid;
candidate->cost = ref_candidate.cost;
candidate->wcost = ref_candidate.wcost;
candidate->structure_cost = ref_candidate.structure_cost;
VLOG(1) << "Set LID: " << candidate->lid;
VLOG(1) << "Set RID: " << candidate->rid;
return;
}
}
}
DVLOG(2) << "Cannot set lid/rid. use default value. "
<< "key: " << candidate->key << ", "
<< "value: " << candidate->value << ", "
<< "lid: " << candidate->lid << ", "
<< "rid: " << candidate->rid;
}
void ConverterImpl::RewriteAndSuppressCandidates(
const ConversionRequest &request, Segments *segments) const {
if (!rewriter_->Rewrite(request, segments)) {
return;
}
// Optimization for common use case: Since most of users don't use suppression
// dictionary and we can skip the subsequent check.
if (suppression_dictionary_->IsEmpty()) {
return;
}
// Although the suppression dictionary is applied at node-level in dictionary
// layer, there's possibility that bad words are generated from multiple nodes
// and by rewriters. Hence, we need to apply it again at the last stage of
// converter.
for (size_t i = 0; i < segments->conversion_segments_size(); ++i) {
Segment *seg = segments->mutable_conversion_segment(i);
for (size_t j = 0; j < seg->candidates_size(); ) {
const Segment::Candidate &cand = seg->candidate(j);
if (suppression_dictionary_->SuppressEntry(cand.key, cand.value)) {
seg->erase_candidate(j);
} else {
++j;
}
}
}
}
void ConverterImpl::TrimCandidates(const ConversionRequest &request,
Segments *segments) const {
const mozc::commands::Request &request_proto = request.request();
if (!request_proto.has_candidates_size_limit()) {
return;
}
const int limit = request_proto.candidates_size_limit();
for (size_t segment_index = 0;
segment_index < segments->conversion_segments_size(); ++segment_index) {
Segment *seg = segments->mutable_conversion_segment(segment_index);
const int candidates_size = seg->candidates_size();
// A segment should have at least one candidate.
const int candidates_limit =
max(1, limit - static_cast<int>(seg->meta_candidates_size()));
if (candidates_size < candidates_limit) {
continue;
}
seg->erase_candidates(candidates_limit, candidates_size - candidates_limit);
}
}
void ConverterImpl::CommitUsageStats(const Segments *segments,
size_t begin_segment_index,
size_t segment_length) const {
if (segment_length == 0) {
return;
}
if (begin_segment_index + segment_length > segments->segments_size()) {
LOG(ERROR) << "Invalid state. segments size: " << segments->segments_size()
<< " required size: " << begin_segment_index + segment_length;
return;
}
// Timing stats are scaled by 1,000 to improve the accuracy of average values.
uint64 submitted_total_length = 0;
for (size_t i = 0; i < segment_length; ++i) {
const Segment &segment = segments->segment(begin_segment_index + i);
const uint32 submitted_length = Util::CharsLen(segment.candidate(0).value);
UsageStats::UpdateTiming("SubmittedSegmentLengthx1000",
submitted_length * 1000);
submitted_total_length += submitted_length;
}
UsageStats::UpdateTiming("SubmittedLengthx1000",
submitted_total_length * 1000);
UsageStats::UpdateTiming("SubmittedSegmentNumberx1000",
segment_length * 1000);
UsageStats::IncrementCountBy("SubmittedTotalLength", submitted_total_length);
}
bool ConverterImpl::GetLastConnectivePart(const string &preceding_text,
string *key,
string *value,
uint16 *id) const {
key->clear();
value->clear();
*id = general_noun_id_;
Util::ScriptType last_script_type = Util::SCRIPT_TYPE_SIZE;
string last_token;
if (!ExtractLastTokenWithScriptType(preceding_text,
&last_token,
&last_script_type)) {
return false;
}
// Currently only NUMBER and ALPHABET are supported.
switch (last_script_type) {
case Util::NUMBER: {
Util::FullWidthAsciiToHalfWidthAscii(last_token, key);
swap(*value, last_token);
*id = pos_matcher_->GetNumberId();
return true;
}
case Util::ALPHABET: {
Util::FullWidthAsciiToHalfWidthAscii(last_token, key);
swap(*value, last_token);
*id = pos_matcher_->GetUniqueNounId();
return true;
}
default:
return false;
}
}
} // namespace mozc
| [
"hnakamur@gmail.com"
] | hnakamur@gmail.com |
35a0806ec674e60044d4a98486f322ee988b5e8c | 9f9038d285ae8e3d3772e49a8b3115f06e0a4f89 | /src/include/parallelCholesky.h | 47d1ce1961d36d251b7a3ff6e1f32d83e8ba3a8f | [] | no_license | isglobal-brge/BigDataStatMeth | e09bfcb2ca7e1abce253083177a30167e694a2af | 27948557f53ec6fa26450272339c7788b6c6bc54 | refs/heads/master | 2023-06-24T23:56:06.548394 | 2022-10-09T20:03:25 | 2022-10-09T20:03:25 | 147,813,286 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 731 | h | #ifndef parallelCholesky
#define parallelCholesky
#include <RcppEigen.h>
#include <iostream>
#include <cstdlib>
#include <chrono>
#include "BigDataStatMeth.h"
#include "pkg_omp.h"
#include <thread>
#include <cmath>
Eigen::MatrixXd Cholesky_decomposition_parallel( Eigen::MatrixXd& A, Rcpp::Nullable<int> threads );
Eigen::VectorXd Forward_Substituion_parallel(Eigen::MatrixXd L, Eigen::VectorXd y, Rcpp::Nullable<int> threads);
Eigen::MatrixXd Inverse_Matrix_Cholesky_parallel( Eigen::MatrixXd InvCh, Rcpp::Nullable<int> threads );
Eigen::MatrixXd Inverse_of_Cholesky_decomposition_parallel( int dimensionSize, Eigen::MatrixXd& L, Rcpp::Nullable<int> threads );
#endif
| [
"43083225+dpelegri@users.noreply.github.com"
] | 43083225+dpelegri@users.noreply.github.com |
15995b492f88634827098667e669e2b2d0bdf564 | 697a751b80ac05a73a3ff38aa56e0f71359bf58e | /test/function/TapeSort/src/sortBuffer.cpp | 65d53d7e74524d63d663f41a0a30b2542ae43993 | [
"GPL-2.0-only",
"BSD-3-Clause",
"Apache-2.0"
] | permissive | HashDataInc/Gopherwood | e06203fb8b5ceeb726d30dd07b9e63f3aa3f4ef7 | 4e06e575b0b4a5efdc378a6d6652c9bfb478e5f2 | refs/heads/master | 2021-05-06T06:35:16.744434 | 2018-06-29T08:00:50 | 2018-06-29T10:04:40 | 113,868,415 | 12 | 6 | Apache-2.0 | 2018-06-29T10:07:51 | 2017-12-11T14:25:09 | C++ | UTF-8 | C++ | false | false | 7,523 | cpp | /*
* DBMS Implementation
* Copyright (C) 2013 George Piskas, George Economides
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Contact: geopiskas@gmail.com
*/
#include "sortBuffer.h"
#include <math.h>
#include "recordPtr.h"
#include "recordOps.h"
// insertionsort sorting algorithm implementation
void insertionSort(block_t *buffer, recordPtr left, recordPtr right, unsigned char field) {
for (recordPtr i = left + 1; i <= right; incr(i)) {
record_t target = getRecord(buffer, i);
recordPtr holePos = i;
while (holePos > left && compareRecords(target, getRecord(buffer, holePos - 1), field) < 0) {
setRecord(buffer, getRecord(buffer, holePos - 1), holePos);
decr(holePos);
}
setRecord(buffer, target, holePos);
}
}
// after a change in the heap, gives it again heap structure
void siftDown(block_t *buffer, uint offset, recordPtr left, recordPtr right, unsigned char field) {
recordPtr root = copyPtr(left);
while (newPtr((root.block * MAX_RECORDS_PER_BLOCK + root.record) * 2 + 1) <= right) {
recordPtr child = newPtr((root.block * MAX_RECORDS_PER_BLOCK + root.record) * 2 + 1 + offset);
recordPtr swap = root + offset;
if (compareRecords(getRecord(buffer, swap), getRecord(buffer, child), field) < 0) {
swap = copyPtr(child);
}
if (child + 1 <= right + offset && compareRecords(getRecord(buffer, swap), getRecord(buffer, child + 1), field) < 0) {
swap = child + 1;
}
if (swap != root + offset) {
swapRecords(buffer, root + offset, swap);
root = swap - offset;
} else {
return;
}
}
}
// reorganises records so that heap structure is achieved
void heapify(block_t *buffer, uint offset, recordPtr right, unsigned char field) {
recordPtr zero = newPtr(0);
recordPtr start = newPtr(getOffset(right) / 2);
while (start >= zero) {
siftDown(buffer, offset, start, right, field);
if (start == zero) {
break;
}
decr(start);
}
}
// heapsort sorting algorithm implementation
void heapSort(block_t *buffer, recordPtr left, recordPtr right, unsigned char field) {
recordPtr zero = newPtr(0);
uint offset = getOffset(left);
recordPtr end = right - offset;
heapify(buffer, offset, end, field);
while (end > zero) {
swapRecords(buffer, end + offset, zero + offset);
decr(end);
siftDown(buffer, offset, zero, end, field);
}
}
// introsort sorting algorithm implementation.
// uses quicksort until either the records to be sorted are <=10, where insertion
// sort is used, or the recursion depth exceeds a limit, where heapsort is used
void introSort(block_t *buffer, recordPtr left, recordPtr right, unsigned char field, uint depth) {
if (left < right) {
if (right - left < 10) {
insertionSort(buffer, left, right, field);
} else if (depth == 0) {
heapSort(buffer, left, right, field);
} else {
record_t pivot = getRecord(buffer, left + (right - left) / 2);
recordPtr start = copyPtr(left);
recordPtr end = copyPtr(right);
while (left <= right) {
while (compareRecords(getRecord(buffer, left), pivot, field) < 0) {
incr(left);
}
while (compareRecords(getRecord(buffer, right), pivot, field) > 0) {
decr(right);
}
if (left <= right) {
swapRecords(buffer, left, right);
incr(left);
decr(right);
}
}
depth -= 1;
introSort(buffer, start, right, field, depth);
introSort(buffer, left, end, field, depth);
}
}
}
// arranges the blocks in the buffer by placing the non-valid ones at the end of it
// returns the number of valid blocks (<=nmem_blocks)
// linear cost achieved using horspool algorithm
uint arrangeBlocks(block_t* buffer, uint bufferSize) {
uint start = 0;
uint end = bufferSize - 1;
for (; start < end; start++) {
if (!buffer[start].valid) {
while (!buffer[end].valid && end > start) {
end -= 1;
}
if (start == end) {
break;
}
block_t temp = buffer[start];
buffer[start] = buffer[end];
buffer[end] = temp;
end -= 1;
}
}
if (buffer[start].valid) {
start += 1;
}
return start;
}
// arranges the records in a segment of valid blocks by placing the non-valid records
// at the end of the segment
// returns the number of valid records and sets requiredBlocks to the number of blocks
// required to store just the valid records
// linear cost achieved using horspool algorithm
uint arrangeRecords(block_t* buffer, uint bufferSize, recordPtr &lastRecord) {
if (bufferSize == 0) {
return 0;
}
recordPtr start = newPtr(0);
recordPtr end = newPtr(bufferSize * MAX_RECORDS_PER_BLOCK - 1);
for (; start < end; incr(start)) {
if (!getRecord(buffer, start).valid) {
while (!getRecord(buffer, end).valid && end > start) {
decr(end);
}
if (start == end) {
break;
}
swapRecords(buffer, start, end);
decr(end);
}
}
if (getRecord(buffer, start).valid) {
incr(start);
}
if (start.record == 0) {
lastRecord.block = start.block - 1;
lastRecord.record = MAX_RECORDS_PER_BLOCK - 1;
} else {
lastRecord.block = start.block;
lastRecord.record = start.record - 1;
}
return 1;
}
// creates a sorted segment of records in buffer
// returns false if the buffer has no valid records, true otherwise
bool sortBuffer(block_t* buffer, uint bufferSize, unsigned char field) {
// all the valid records of all tha valid blocks are gathered at the beginning
// of the buffer and are then sorted using introsort. the remaining blocks
// are invalidated.
recordPtr end;
if (arrangeRecords(buffer, arrangeBlocks(buffer, bufferSize), end) == 0) {
return false;
}
introSort(buffer, newPtr(0), end, field, 2 * ((uint) floor(log2(end.block * MAX_RECORDS_PER_BLOCK + end.record + 1))));
uint i = 0;
for (; i < end.block; i++) {
buffer[i].nreserved = MAX_RECORDS_PER_BLOCK;
buffer[i].blockid = i;
}
buffer[end.block].nreserved = end.record + 1;
buffer[end.block].blockid = i;
for (i += 1; i < bufferSize; i++) {
buffer[i].valid = false;
buffer[i].nreserved = 0;
buffer[i].blockid = i;
}
return true;
} | [
"492960551@qq.com"
] | 492960551@qq.com |
e646791347bdf9e490dc3261db4a66d138a23e2c | 1e636fe0e92256920a5804494b44342e20050285 | /Day5/2_perfect_forwarding_solution_2_2.cpp | 42c5c1ad04dd1844e743384e012c865335862f68 | [] | no_license | JaeminShim/NCUAdvancedCPP | 4c65e8218bd8c6ef1e4318ad1739739a72a49ae1 | 399c7a805fccc6f1b8eef52cdc717bc87ed539f1 | refs/heads/master | 2021-01-10T16:31:01.431020 | 2015-11-25T08:51:34 | 2015-11-25T08:51:34 | 43,853,480 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 679 | cpp | // 2. 완벽한 전달자 - 해결책 2-2 - 145page
#include <iostream>
using namespace std;
void foo(int n) { cout << "foo : " << n << endl; }
void goo(int &n) { cout << "goo : " << n << endl; n = 20; }
template <typename F, typename T> void logTime(F f, T a)
{
f(a);
}
// 참조로 변환 가능한 포인터 역할의 객체
template <typename T> class xreference_wrapper
{
T* obj;
public:
xreference_wrapper(T& a) : obj(&a) {}
// T&로 암시적 변환이 되게 하자.
operator T&() { return *obj; }
};
int main()
{
int x = 10;
xreference_wrapper<int> r = x; // x메모리를 가리키는 새로운 개념의 참조 r
logTime(goo, r);
cout << x << endl;
}
| [
""
] | |
3bc59f87e3222d4fbbb768a1a50eb7444dfd5e2f | dfa1dad373a896b62fb7542f2352c0cfb1dae49a | /perf/gnu/command_line.cpp | 40a5091898c4932d2665d6006e28e1c78ca3ce42 | [
"Apache-2.0"
] | permissive | zhoulipeng/cppwork | b04faccf9c8160cb694df1195d12aba6d42ed3ce | da3e62bd74bbb3e8b723472ee407926fcd01137e | refs/heads/master | 2023-04-07T20:26:21.191240 | 2023-03-21T08:36:41 | 2023-03-21T08:36:41 | 31,721,277 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 529 | cpp | #include "command_options.h"
#include "perfecthash.hpp"
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
for (int i = 1; i < argc; i++) {
const CommandOption* opt = Perfect_Hash::IsValidCommandLineOption(argv[i], strlen(argv[i]));
if (opt != NULL) {
fprintf(stderr, "ValidOption: %s, %d\n", opt->Option, opt->OptionCode);
} else {
fprintf(stderr, "InvalidOption: %s\n", argv[i]);
}
}
return 0;
}
| [
"zhoulpg@gmail.com"
] | zhoulpg@gmail.com |
babec505a2863319d6a03436069952ad2c523519 | fef5c44650e219e690130e0d8372bd6f364052c8 | /算法提高/C++/ADV-11 算法提高 Torry的困惑(提高型).cpp | 6c2cf79b905cc6895b4f6e10df58a94b9badad2a | [] | no_license | gggdttt/Lanqiao | ba0ec670ffd5590638e3462792194bc2ecc421f1 | 0403ed4c96dca1b6c17d1238dcdcd175a8b2461f | refs/heads/master | 2020-04-30T20:07:37.161472 | 2019-03-18T04:54:28 | 2019-03-18T04:54:28 | 177,057,182 | 3 | 0 | null | 2019-03-22T02:22:42 | 2019-03-22T02:22:41 | null | UTF-8 | C++ | false | false | 571 | cpp | #include <iostream>
#define MOD 50000
using namespace std;
int v[2000000];
int main() {
int n;
cin >> n;
for(int i = 2; i * i < 2000000; i++) {
if(v[i] == 1)
continue;
for(int j = i * i; j < 2000000; j = j + i) {
if(j % i == 0)
v[j] = 1;
}
}
long long int ans = 1;
int cnt = 0;
for(int i = 2; i < 2000000; i++) {
if(v[i] == 0) {
ans = (ans * i) % MOD;
cnt++;
}
if(cnt == n)
break;
}
cout << ans;
return 0;
} | [
"95323362@qq.com"
] | 95323362@qq.com |
714bc8594298133ed9696f562f6db9fa2e938622 | daa94b6984e5f866e3b847945ad6e793187f9b92 | /include/matcher/matcher.hpp | 8a347c55463e99ce6325ccd87116bf5d5baaa9e7 | [
"MIT"
] | permissive | KaunilD/deep_image_mosaicing | 3c2f9cb0d1517d6e85c91c1dad08260cdb930a3b | 8504ee12fd1c9ca8ea0c23ac4efffe5fa88d9050 | refs/heads/master | 2021-05-23T19:03:51.486955 | 2020-04-29T03:54:43 | 2020-04-29T03:54:43 | 253,428,114 | 5 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 291 | hpp | #ifndef MATCHER_H
#define MATCHER_H
#include "libs.hpp"
#include "dtypes/features.hpp"
#include "dtypes/matchpair.hpp"
class Matcher {
public:
Matcher();
virtual std::vector<MatchPair> run(const std::vector<Descriptor>& d1, const std::vector<Descriptor>& d2) = 0;
};
#endif MATCHER_H | [
"dhruv.kaunil@gmail.com"
] | dhruv.kaunil@gmail.com |
a2d99dbc1b93ee22e89652c44ffcc69a2ef418d7 | 2e1689127c9cec827f79325c6458b5f2dce134ac | /src/rpcdump.cpp | d49a15b9b7df0afc020747a2c28ddb5759b465a8 | [
"MIT"
] | permissive | syariahcoin01/SyariahCoin01 | a4f41454ea2e16e79800c3ffa947e21320ac0d53 | 85a2b621ae5a8675fb75e11567dba4bc217aaf53 | refs/heads/master | 2020-03-07T02:50:17.568152 | 2018-03-31T19:53:56 | 2018-03-31T19:53:56 | 127,218,938 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,728 | cpp | // Copyright (c) 2009-2012 Bitcoin Developers
// Copyright (c) 2011-2012 Litecoin Developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "init.h" // for pwalletMain
#include "bitcoinrpc.h"
#include "ui_interface.h"
#include "base58.h"
#include <boost/lexical_cast.hpp>
#define printf OutputDebugStringF
using namespace json_spirit;
using namespace std;
class CTxDump
{
public:
CBlockIndex *pindex;
int64 nValue;
bool fSpent;
CWalletTx* ptx;
int nOut;
CTxDump(CWalletTx* ptx = NULL, int nOut = -1)
{
pindex = NULL;
nValue = 0;
fSpent = false;
this->ptx = ptx;
this->nOut = nOut;
}
};
Value importprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 2)
throw runtime_error(
"importprivkey <SyariahCoin01 private key> [label]\n"
"Adds a private key (as returned by dumpprivkey) to your wallet.");
string strSecret = params[0].get_str();
string strLabel = "";
if (params.size() > 1)
strLabel = params[1].get_str();
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);
if (!fGood) throw JSONRPCError(-5,"Invalid private key");
CKey key;
bool fCompressed;
CSecret secret = vchSecret.GetSecret(fCompressed);
key.SetSecret(secret, fCompressed);
CKeyID vchAddress = key.GetPubKey().GetID();
{
LOCK2(cs_main, pwalletMain->cs_wallet);
pwalletMain->MarkDirty();
pwalletMain->SetAddressBookName(vchAddress, strLabel);
if (!pwalletMain->AddKey(key))
throw JSONRPCError(-4,"Error adding key to wallet");
pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true);
pwalletMain->ReacceptWalletTransactions();
}
return Value::null;
}
Value dumpprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpprivkey <SyariahCoin01 address>\n"
"Reveals the private key corresponding to <SyariahCoin01 address>.");
string strAddress = params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(-5, "Invalid SyariahCoin01 address");
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw JSONRPCError(-3, "Address does not refer to a key");
CSecret vchSecret;
bool fCompressed;
if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed))
throw JSONRPCError(-4,"Private key for address " + strAddress + " is not known");
return CBitcoinSecret(vchSecret, fCompressed).ToString();
}
| [
"root@syariahcoin01.server"
] | root@syariahcoin01.server |
3ed376a2c418192adfeb1ed3cef61c847ff306c7 | 27c9270d4af72abac0d8b4e1a7a29cfd965c2bd4 | /cluster/tools/DBTableStrictChecker.cpp | ee77b8a0acd74daf26cbb83f9d86cb6a35973def | [] | no_license | highras/dbproxy | 0eb346ed93cd36c989447b298e4f8f72695e19d1 | ba4ecea9a499183b3cc018376bc85f261cfca18f | refs/heads/master | 2022-06-13T15:35:14.170582 | 2022-05-30T08:19:33 | 2022-05-30T08:19:33 | 136,270,409 | 37 | 24 | null | null | null | null | UTF-8 | C++ | false | false | 12,377 | cpp | #include <iostream>
#include <set>
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#include "ignoreSignals.h"
#include "TCPClient.h"
#include "FPWriter.h"
#include "FPReader.h"
using namespace fpnn;
void timeCalc(struct timeval start, struct timeval finish)
{
int sec = finish.tv_sec - start.tv_sec;
int usec;
if (finish.tv_usec >= start.tv_usec)
usec = finish.tv_usec - start.tv_usec;
else
{
usec = 100 * 10000 + finish.tv_usec - start.tv_usec;
sec -= 1;
}
std::cout<<"time cost "<< (sec * 1000 + usec / 1000) << "."<<(usec % 1000)<<" ms"<<std::endl;
}
bool checkException(FPAReader &ar, bool openTail = false)
{
if (ar.status())
{
if (openTail)
std::cout<<"[Error]"<<std::endl;
std::cout<<"Query error!"<<std::endl;
std::cout<<"Raiser: "<<ar.wantString("raiser")<<std::endl;
std::cout<<"Error code: "<<ar.wantInt("code")<<std::endl;
std::cout<<"Expection: "<<ar.wantString("ex")<<std::endl;
return false;
}
return true;
}
std::set<int64_t> getHintIds(std::shared_ptr<TCPClient> client, const std::string& tableName, const std::string& cluster)
{
std::cout<<"Query interface 'allSplitHintIds' ..."<<std::endl;
FPQWriter qw(2, "allSplitHintIds");
qw.param("tableName", tableName);
qw.param("cluster", cluster);
std::set<int64_t> hintIds;
FPAnswerPtr answer = client->sendQuest(qw.take());
FPAReader ar(answer);
if (checkException(ar))
hintIds = ar.want("hintIds", std::set<int64_t>());
return hintIds;
}
void printErrorInfos(std::vector<std::string> &errorInfos, std::set<int64_t> &hintIds)
{
std::cout<<"----------------------------------"<<std::endl;
if (errorInfos.empty() && hintIds.empty())
{
std::cout<<"All sub-tables are OK!"<<std::endl;
return;
}
if (!errorInfos.empty())
{
std::cout<<std::endl<<"Error Infos ("<<errorInfos.size()<<"):"<<std::endl;
for (size_t i = 0; i < errorInfos.size(); i++)
std::cout<<errorInfos[i]<<std::endl;
}
if (!hintIds.empty())
{
std::cout<<std::endl<<"Remained "<<hintIds.size()<<" hintIds returned by interface 'allSplitHintIds'."<<std::endl;
for (int64_t id: hintIds)
std::cout<<" "<<id<<std::endl;
std::cout<<std::endl;
}
}
void checkTable(std::shared_ptr<TCPClient> client, int64_t hintId, const std::string &tableName, const std::string& cluster,
const std::string &sql, int &standardTableIdx, std::string indexInfo, std::set<int64_t> &hintIds,
std::vector<std::vector<std::string>> &columsDefinitions, std::vector<std::string> &errorInfos)
{
std::cout<<"... checking sub-table "<<indexInfo<<" by hintId: "<<hintId<<" ... ";
bool openTail = true;
FPQWriter qw(4, "query");
qw.param("hintId", hintId);
qw.param("tableName", tableName);
qw.param("cluster", cluster);
qw.param("sql", sql);
FPAnswerPtr answer = client->sendQuest(qw.take());
FPAReader ar(answer);
if (!checkException(ar, openTail))
{
std::string errorInfo("Check sub-table ");
errorInfo.append(indexInfo).append(" by hintId: ");
errorInfo.append(std::to_string(hintId)).append(" failed.");
errorInfos.push_back(errorInfo);
std::cout<<errorInfo<<std::endl;
return;
}
if (hintIds.find(hintId) != hintIds.end())
hintIds.erase(hintId);
else
{
if (openTail)
{
openTail = false;
std::cout<<"[Error]"<<std::endl;
}
std::string errorInfo("Hint id ");
errorInfo.append(std::to_string(hintId)).append(" cannot be found in 'allSplitHintIds' set.");
errorInfos.push_back(errorInfo);
std::cout<<errorInfo<<std::endl;
}
if (columsDefinitions.size())
{
std::vector<std::vector<std::string>> colums = ar.get("rows", std::vector<std::vector<std::string>>());
if (columsDefinitions.size() != colums.size())
{
std::string errorInfo("Sub-table ");
errorInfo.append(indexInfo).append(" (hintId: ");
errorInfo.append(std::to_string(hintId)).append(") has different column count from sub-table hintId: ");
errorInfo.append(std::to_string(standardTableIdx));
if (openTail)
{
openTail = false;
std::cout<<"[Error]"<<std::endl;
}
std::cout<<errorInfo<<std::endl;
errorInfos.push_back(errorInfo);
}
else
{
bool columnOk = true;
for (size_t j = 0; j < colums.size(); j++)
{
const std::vector<std::string>& row = colums[j];
std::vector<std::string>& stdRow = columsDefinitions[j];
for (int k = 0; k < (int)row.size(); k++)
{
if (row[k] != stdRow[k])
{
columnOk = false;
std::string errorInfo("Sub-table ");
errorInfo.append(indexInfo);
errorInfo.append(" (hintId: ");
errorInfo.append(std::to_string(hintId));
errorInfo.append(") column '");
errorInfo.append(row[k]);
errorInfo.append("' is different from sub-table hintId: ");
errorInfo.append(std::to_string(standardTableIdx));
if (openTail)
{
openTail = false;
std::cout<<"[Error]"<<std::endl;
}
std::cout<<errorInfo<<std::endl;
errorInfos.push_back(errorInfo);
}
}
}
if (columnOk)
std::cout<<"[OK]"<<std::endl;
}
}
else
{
columsDefinitions = ar.get("rows", columsDefinitions);
std::cout<<"[OK]"<<std::endl;
standardTableIdx = hintId;
}
}
void hashTableCheck(std::shared_ptr<TCPClient> client, const std::string& tableName, const std::string& cluster, FPAReader &splitInfoAnswerReader)
{
int tableCount = splitInfoAnswerReader.wantInt("tableCount");
std::cout<<"Split type: Hash"<<std::endl;
std::cout<<"Table Count: "<<tableCount<<std::endl;
std::cout<<"Split Hint: "<<splitInfoAnswerReader.wantString("splitHint")<<std::endl;
std::cout<<"----------------------------------"<<std::endl;
std::set<int64_t> hintIds = getHintIds(client, tableName, cluster);
if ((int)hintIds.size() != tableCount)
{
std::cout<<"Error!"<<std::endl;
std::cout<<"Interface splitInfo return "<<tableCount<<" tables, but allSplitHintIds return "<<hintIds.size()<<" tables.\n";
return;
}
std::string descSQL("desc ");
descSQL.append(tableName);
int standardTableIdx = 0;
std::vector<std::string> errorInfos;
std::vector<std::vector<std::string>> columsDefinitions;
for (int i = 0; i < tableCount; i++)
checkTable(client, i, tableName, cluster, descSQL, standardTableIdx, std::to_string(i), hintIds, columsDefinitions, errorInfos);
printErrorInfos(errorInfos, hintIds);
}
void rangeTableCheck(std::shared_ptr<TCPClient> client, const std::string& tableName, const std::string& cluster, FPAReader &splitInfoAnswerReader)
{
int rangeCount = splitInfoAnswerReader.wantInt("count");
std::string databaseCategory = splitInfoAnswerReader.wantString("databaseCategory");
int rangeSpan = splitInfoAnswerReader.wantInt("span");
std::cout<<"Split type: Range"<<std::endl;
std::cout<<"Range Span: "<<rangeSpan<<std::endl;
std::cout<<"Range Count: "<<rangeCount<<std::endl;
std::cout<<"Database Category: "<<databaseCategory<<std::endl;
std::cout<<"Split Hint: "<<splitInfoAnswerReader.wantString("splitHint")<<std::endl;
bool secondarySplit = splitInfoAnswerReader.wantBool("secondarySplit");
int secondarySplitSpan = 0;
if (secondarySplit)
{
secondarySplitSpan = splitInfoAnswerReader.wantInt("secondarySplitSpan");
std::cout<<"SecondarySplit: Yes"<<std::endl;
std::cout<<"Secondary Split Span: "<<secondarySplitSpan<<std::endl;
}
else
std::cout<<"SecondarySplit: No"<<std::endl;
int totalRangeCount = rangeCount;
std::set<int> oddEvenRanges;
{
FPQWriter qw(2, "categoryInfo");
qw.param("databaseCategory", databaseCategory);
qw.param("cluster", cluster);
std::cout<<"Query interface 'categoryInfo' ..."<<std::endl;
FPAnswerPtr answer = client->sendQuest(qw.take());
FPAReader ar(answer);
if (!checkException(ar))
return;
if (ar.wantInt("splitCount") != rangeCount)
{
std::cout<<"Error!\nInterface splitInfo return "<<rangeCount<<" ranges, but categoryInfo return "<<ar.wantInt("splitCount")<<" ranges.\n";
return;
}
int oddEvenCount = ar.wantInt("oddEvenCount");
if (oddEvenCount)
{
totalRangeCount += oddEvenCount;
std::cout<<"Total Range Span count "<<totalRangeCount<<", include "<<oddEvenCount<<" odd-even ranges."<<std::endl;
std::cout<<"Odd-even ranges are : ";
oddEvenRanges = ar.want("oddEvenIndexes", std::set<int>());
for (int id: oddEvenRanges)
std::cout<<id<<" ";
std::cout<<"."<<std::endl;
}
}
std::cout<<"----------------------------------"<<std::endl;
int secondaryTableCountInFirstSpan = 1;
int tableCount = totalRangeCount;
if (secondarySplit)
{
int count = rangeSpan / secondarySplitSpan;
if (rangeSpan % secondarySplitSpan)
count += 1;
tableCount *= count;
secondaryTableCountInFirstSpan = count;
}
std::set<int64_t> hintIds = getHintIds(client, tableName, cluster);
if ((int)hintIds.size() != tableCount)
{
std::cout<<"Error!"<<std::endl;
std::cout<<"Interface allSplitHintIds return "<<hintIds.size()<<" tables, but "<<tableCount<<" tables is right.\n";
return;
}
std::cout<<"----------------------------------"<<std::endl;
std::string descSQL("desc ");
descSQL.append(tableName);
int standardTableIdx = 0;
std::vector<std::string> errorInfos;
std::vector<std::vector<std::string>> columsDefinitions;
for (int i = 0; i < rangeCount; i++)
{
int rangeHintId = i * rangeSpan;
if (oddEvenRanges.find(i) != oddEvenRanges.end())
{
if (secondarySplit)
{
std::string indexInfo;
indexInfo.append(" in range ").append(std::to_string(i));
for (int j = 0; j < secondaryTableCountInFirstSpan; j++)
{
std::string addedInfo(" secondary idx ");
addedInfo.append(std::to_string(j));
checkTable(client, rangeHintId + j * secondarySplitSpan , tableName, cluster, descSQL, standardTableIdx,
indexInfo + addedInfo + " (even-sub)", hintIds, columsDefinitions, errorInfos);
checkTable(client, rangeHintId + j * secondarySplitSpan + 1, tableName, cluster, descSQL, standardTableIdx,
indexInfo + addedInfo + " (odd-sub)" , hintIds, columsDefinitions, errorInfos);
}
}
else
{
std::string indexInfo;
indexInfo.append(" in range ").append(std::to_string(i));
checkTable(client, rangeHintId , tableName, cluster, descSQL, standardTableIdx, indexInfo + " (even-sub)", hintIds, columsDefinitions, errorInfos);
checkTable(client, rangeHintId + 1, tableName, cluster, descSQL, standardTableIdx, indexInfo + " (odd-sub)" , hintIds, columsDefinitions, errorInfos);
}
}
else
{
if (secondarySplit)
{
std::string indexInfo;
indexInfo.append(" in range ").append(std::to_string(i));
for (int j = 0; j < secondaryTableCountInFirstSpan; j++)
{
std::string addedInfo(" secondary idx ");
addedInfo.append(std::to_string(j));
checkTable(client, rangeHintId + j * secondarySplitSpan, tableName, cluster, descSQL, standardTableIdx,
indexInfo + addedInfo, hintIds, columsDefinitions, errorInfos);
}
}
else
{
std::string indexInfo;
indexInfo.append(" in range ").append(std::to_string(i));
checkTable(client, rangeHintId, tableName, cluster, descSQL, standardTableIdx, indexInfo, hintIds, columsDefinitions, errorInfos);
}
}
}
printErrorInfos(errorInfos, hintIds);
}
void check(const std::string& host, int port, const std::string& tableName, const std::string& cluster)
{
std::shared_ptr<TCPClient> client = TCPClient::createClient(host, port);
struct timeval start, finish;
gettimeofday(&start, NULL);
FPQWriter qw(2, "splitInfo");
qw.param("tableName", tableName);
qw.param("cluster", cluster);
std::cout<<std::endl<<"Query interface 'splitInfo' ..."<<std::endl;
FPAnswerPtr answer = client->sendQuest(qw.take());
FPAReader ar(answer);
if (checkException(ar))
{
std::cout<<"----------------------------------"<<std::endl;
if (ar.wantBool("splitByRange"))
rangeTableCheck(client, tableName, cluster, ar);
else
hashTableCheck(client, tableName, cluster, ar);
}
gettimeofday(&finish, NULL);
std::cout<<std::endl;
timeCalc(start, finish);
}
int main(int argc, const char* argv[])
{
if (argc == 5)
{
const char* host = argv[1];
int port = atoi(argv[2]);
const char* tablename = argv[3];
const char* cluster = argv[4];
ignoreSignals();
check(host, port, tablename, cluster);
}
else
{
std::cout<<"Usage: "<<std::endl;
std::cout<<"\t"<<argv[0]<<" DBProxy_host DBProxy_port table_name cluster"<<std::endl;
}
return 0;
}
| [
"wangxing.shi@funplus.com"
] | wangxing.shi@funplus.com |
730bbcd165bae58fa500ea5621ff3e7d1a2f58cc | c2a38875a016957209e75b7386bc55d9b349d60d | /main.cpp | c718b93b45d9a2c06f0f0a5265d46725b54509b7 | [] | no_license | Crazyhamada10/SIC-Assembler | e1a8106031b7bd7b1c177de980cbcd487a18b683 | 3ff24c987add0d5f8971d57cbf000b94f28f2fa1 | refs/heads/master | 2021-01-20T13:10:45.586215 | 2017-05-06T10:56:26 | 2017-05-06T10:56:26 | 90,456,582 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 560 | cpp | /*
* main.cpp
*
* Created on: Apr 22, 2017
* Author: crazyhamada10
*/
#include "Assembler.h"
#include <iostream>
#include <string>
using namespace std;
int main() {
try {
if (Assembler::Instance()->run("/home/crazyhamada10/Desktop/testing/", "test12")) {
cout << "Done";
} else cout << "Error";
} catch (string& msg) {
cout << msg ;
} catch (...) {
cout << "Exception";
}
return 0;
}
/*
SIC
SIC2
SIC-Example-spaces
SIC-Example-true3
SIC-Example-true-again3
SIC-test3'abii
SIC-test23'ba
SIC-test23'ba2
test12
*/
| [
"crazyhamada10@gmail.com"
] | crazyhamada10@gmail.com |
1da1761243bf32ca6b0eb99dda918d3f2c18084b | 601e9f409ec1c5de2d5a56331979db3bcb41dc8f | /Code/InfernoEngine/Inc/Core/Private/Components/AudioListener.cpp | 37f5a2bf61ff21f4e754a721d9fda2047afbd379 | [] | no_license | bmclaine/ProtoTowers | 1f12cd6e299be6771188e8b0738db5e6f8301b50 | c9bbe2896591f456c5fde6595d7d76f9031fd2f4 | refs/heads/master | 2020-04-17T07:10:05.522159 | 2016-08-31T01:07:14 | 2016-08-31T01:07:14 | 66,881,935 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,295 | cpp | #include "Components\AudioListener.h"
#include "../../Interface/Public/Engine.h"
AudioListener::AudioListener(GameObject* const gameObject, Transform* const transform) : IComponent(gameObject, transform){
m_bRegistered = false;
}
IComponent& AudioListener::operator=(IComponent& _rhs){
AudioListener* rhsLlstener = dynamic_cast<AudioListener*>(&_rhs);
if (rhsLlstener == nullptr) {
return *this;
}
return operator=(*rhsLlstener);
}
AudioListener& AudioListener::operator=(const AudioListener& _rhs){
return *this;
}
IComponent* AudioListener::CreateCopy(GameObject* const gameObject, Transform* const transform){
AudioListener* listener = new AudioListener(gameObject, transform);
return listener;
}
// IN: void
// OUT: map<unsigned int,Object*> - map of all the gameobjects and components in the scene
//
// Initializes any private, non object variables
void AudioListener::Init(){
}
// IN: void
// OUT: map<unsigned int,Object*> - map of all the gameobjects and components in the scene
//
// Initializes object variables
void AudioListener::PostInit(std::map<unsigned int, Object*>& objectMap, std::map<unsigned int, ObjectData*>& dataMap){
}
void AudioListener::OnEnable(){
if (!m_bRegistered){
Inferno::RegisterAudioListener(gameObject);
m_bRegistered = true;
}
}
| [
"bizzy18@gmail.com"
] | bizzy18@gmail.com |
8de7ca0555320bc6e33ef258f9c4571e737069e6 | 6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849 | /sstd_boost/sstd/libs/vmd/test/test_after_type_elem.cpp | 00c1a902a4e1cd74aa8dc69c9ab56d93baa81ccf | [
"BSL-1.0"
] | permissive | KqSMea8/sstd_library | 9e4e622e1b01bed5de7322c2682539400d13dd58 | 0fcb815f50d538517e70a788914da7fbbe786ce1 | refs/heads/master | 2020-05-03T21:07:01.650034 | 2019-04-01T00:10:47 | 2019-04-01T00:10:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 290 | cpp |
// (C) Copyright Edward Diener 2011-2015
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt).
#include <libs/vmd/test/test_after_type_elem.cxx>
| [
"zhaixueqiang@hotmail.com"
] | zhaixueqiang@hotmail.com |
3a3c94adefb74b04db0c1c4c1aa677156a96f51c | 302f4bda84739593ab952f01c9e38d512b0a7d73 | /ext/Vc-1.3.2/sse/intrinsics.h | 651e2db583a3edb4bdc817230143a2c8291bce96 | [
"BSD-3-Clause",
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"ICU",
"BSL-1.0",
"X11",
"Beerware"
] | permissive | thomaskrause/graphANNIS | 649ae23dd74b57bcd8a699c1e309e74096be9db2 | 66d12bcfb0e0b9bfcdc2df8ffaa5ae8c84cc569c | refs/heads/develop | 2020-04-11T01:28:47.589724 | 2018-03-15T18:16:50 | 2018-03-15T18:16:50 | 40,169,698 | 9 | 3 | Apache-2.0 | 2018-07-28T20:18:41 | 2015-08-04T07:24:49 | C++ | UTF-8 | C++ | false | false | 29,913 | h | /* This file is part of the Vc library. {{{
Copyright © 2009-2015 Matthias Kretz <kretz@kde.org>
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 names of contributing organizations 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 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 VC_SSE_INTRINSICS_H_
#define VC_SSE_INTRINSICS_H_
#ifdef Vc_MSVC
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
#include "../common/storage.h"
#include "const_data.h"
#include <cstdlib>
#include "types.h"
#include "debug.h"
#if defined(Vc_GCC) && !defined(__OPTIMIZE__)
// GCC uses lots of old-style-casts in macros that disguise as intrinsics
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
namespace Vc_VERSIONED_NAMESPACE
{
namespace SseIntrinsics
{
using SSE::c_general;
constexpr std::size_t VectorAlignment = 16;
#if defined(Vc_GCC) && Vc_GCC < 0x40600 && !defined(Vc_DONT_FIX_SSE_SHIFT)
static Vc_INTRINSIC Vc_CONST __m128i _mm_sll_epi16(__m128i a, __m128i count) { __asm__("psllw %1,%0" : "+x"(a) : "x"(count)); return a; }
static Vc_INTRINSIC Vc_CONST __m128i _mm_sll_epi32(__m128i a, __m128i count) { __asm__("pslld %1,%0" : "+x"(a) : "x"(count)); return a; }
static Vc_INTRINSIC Vc_CONST __m128i _mm_sll_epi64(__m128i a, __m128i count) { __asm__("psllq %1,%0" : "+x"(a) : "x"(count)); return a; }
static Vc_INTRINSIC Vc_CONST __m128i _mm_srl_epi16(__m128i a, __m128i count) { __asm__("psrlw %1,%0" : "+x"(a) : "x"(count)); return a; }
static Vc_INTRINSIC Vc_CONST __m128i _mm_srl_epi32(__m128i a, __m128i count) { __asm__("psrld %1,%0" : "+x"(a) : "x"(count)); return a; }
static Vc_INTRINSIC Vc_CONST __m128i _mm_srl_epi64(__m128i a, __m128i count) { __asm__("psrlq %1,%0" : "+x"(a) : "x"(count)); return a; }
#endif
#ifdef Vc_GCC
// Redefine the mul/add/sub intrinsics to use GCC-specific operators instead of builtin
// functions. This way the fp-contraction optimization step kicks in and creates FMAs! :)
static Vc_INTRINSIC Vc_CONST __m128d _mm_mul_pd(__m128d a, __m128d b) { return static_cast<__m128d>(static_cast<__v2df>(a) * static_cast<__v2df>(b)); }
static Vc_INTRINSIC Vc_CONST __m128d _mm_add_pd(__m128d a, __m128d b) { return static_cast<__m128d>(static_cast<__v2df>(a) + static_cast<__v2df>(b)); }
static Vc_INTRINSIC Vc_CONST __m128d _mm_sub_pd(__m128d a, __m128d b) { return static_cast<__m128d>(static_cast<__v2df>(a) - static_cast<__v2df>(b)); }
static Vc_INTRINSIC Vc_CONST __m128 _mm_mul_ps(__m128 a, __m128 b) { return static_cast<__m128 >(static_cast<__v4sf>(a) * static_cast<__v4sf>(b)); }
static Vc_INTRINSIC Vc_CONST __m128 _mm_add_ps(__m128 a, __m128 b) { return static_cast<__m128 >(static_cast<__v4sf>(a) + static_cast<__v4sf>(b)); }
static Vc_INTRINSIC Vc_CONST __m128 _mm_sub_ps(__m128 a, __m128 b) { return static_cast<__m128 >(static_cast<__v4sf>(a) - static_cast<__v4sf>(b)); }
#endif
static Vc_INTRINSIC Vc_CONST __m128i _mm_setallone_si128() { return _mm_load_si128(reinterpret_cast<const __m128i *>(Common::AllBitsSet)); }
static Vc_INTRINSIC Vc_CONST __m128d _mm_setallone_pd() { return _mm_load_pd(reinterpret_cast<const double *>(Common::AllBitsSet)); }
static Vc_INTRINSIC Vc_CONST __m128 _mm_setallone_ps() { return _mm_load_ps(reinterpret_cast<const float *>(Common::AllBitsSet)); }
static Vc_INTRINSIC __m128i Vc_CONST _mm_setone_epi8 () { return _mm_set1_epi8(1); }
static Vc_INTRINSIC __m128i Vc_CONST _mm_setone_epu8 () { return _mm_setone_epi8(); }
static Vc_INTRINSIC __m128i Vc_CONST _mm_setone_epi16() { return _mm_load_si128(reinterpret_cast<const __m128i *>(c_general::one16)); }
static Vc_INTRINSIC __m128i Vc_CONST _mm_setone_epu16() { return _mm_setone_epi16(); }
static Vc_INTRINSIC __m128i Vc_CONST _mm_setone_epi32() { return _mm_load_si128(reinterpret_cast<const __m128i *>(c_general::one32)); }
static Vc_INTRINSIC __m128i Vc_CONST _mm_setone_epu32() { return _mm_setone_epi32(); }
static Vc_INTRINSIC __m128 Vc_CONST _mm_setone_ps() { return _mm_load_ps(c_general::oneFloat); }
static Vc_INTRINSIC __m128d Vc_CONST _mm_setone_pd() { return _mm_load_pd(c_general::oneDouble); }
static Vc_INTRINSIC __m128d Vc_CONST _mm_setabsmask_pd() { return _mm_load_pd(reinterpret_cast<const double *>(c_general::absMaskDouble)); }
static Vc_INTRINSIC __m128 Vc_CONST _mm_setabsmask_ps() { return _mm_load_ps(reinterpret_cast<const float *>(c_general::absMaskFloat)); }
static Vc_INTRINSIC __m128d Vc_CONST _mm_setsignmask_pd(){ return _mm_load_pd(reinterpret_cast<const double *>(c_general::signMaskDouble)); }
static Vc_INTRINSIC __m128 Vc_CONST _mm_setsignmask_ps(){ return _mm_load_ps(reinterpret_cast<const float *>(c_general::signMaskFloat)); }
static Vc_INTRINSIC __m128i Vc_CONST setmin_epi8 () { return _mm_set1_epi8(-0x80); }
static Vc_INTRINSIC __m128i Vc_CONST setmin_epi16() { return _mm_load_si128(reinterpret_cast<const __m128i *>(c_general::minShort)); }
static Vc_INTRINSIC __m128i Vc_CONST setmin_epi32() { return _mm_load_si128(reinterpret_cast<const __m128i *>(c_general::signMaskFloat)); }
static Vc_INTRINSIC __m128i Vc_CONST setmin_epi64() { return _mm_load_si128(reinterpret_cast<const __m128i *>(c_general::signMaskDouble)); }
#if defined(Vc_IMPL_XOP)
static Vc_INTRINSIC __m128i Vc_CONST cmplt_epu8(__m128i a, __m128i b) { return _mm_comlt_epu8(a, b); }
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu8(__m128i a, __m128i b) { return _mm_comgt_epu8(a, b); }
static Vc_INTRINSIC __m128i Vc_CONST cmplt_epu16(__m128i a, __m128i b) { return _mm_comlt_epu16(a, b); }
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu16(__m128i a, __m128i b) { return _mm_comgt_epu16(a, b); }
static Vc_INTRINSIC __m128i Vc_CONST cmplt_epu32(__m128i a, __m128i b) { return _mm_comlt_epu32(a, b); }
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu32(__m128i a, __m128i b) { return _mm_comgt_epu32(a, b); }
static Vc_INTRINSIC __m128i Vc_CONST cmplt_epu64(__m128i a, __m128i b) { return _mm_comlt_epu64(a, b); }
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu64(__m128i a, __m128i b) { return _mm_comgt_epu64(a, b); }
#else
static Vc_INTRINSIC __m128i Vc_CONST cmplt_epu8(__m128i a, __m128i b)
{
return _mm_cmplt_epi8(_mm_xor_si128(a, setmin_epi8()),
_mm_xor_si128(b, setmin_epi8()));
}
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu8(__m128i a, __m128i b)
{
return _mm_cmpgt_epi8(_mm_xor_si128(a, setmin_epi8()),
_mm_xor_si128(b, setmin_epi8()));
}
static Vc_INTRINSIC __m128i Vc_CONST cmplt_epu16(__m128i a, __m128i b)
{
return _mm_cmplt_epi16(_mm_xor_si128(a, setmin_epi16()),
_mm_xor_si128(b, setmin_epi16()));
}
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu16(__m128i a, __m128i b)
{
return _mm_cmpgt_epi16(_mm_xor_si128(a, setmin_epi16()),
_mm_xor_si128(b, setmin_epi16()));
}
static Vc_INTRINSIC __m128i Vc_CONST cmplt_epu32(__m128i a, __m128i b)
{
return _mm_cmplt_epi32(_mm_xor_si128(a, setmin_epi32()),
_mm_xor_si128(b, setmin_epi32()));
}
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu32(__m128i a, __m128i b)
{
return _mm_cmpgt_epi32(_mm_xor_si128(a, setmin_epi32()),
_mm_xor_si128(b, setmin_epi32()));
}
Vc_INTRINSIC __m128i Vc_CONST cmpgt_epi64(__m128i a, __m128i b)
{
#ifdef Vc_IMPL_SSE4_2
return _mm_cmpgt_epi64(a, b);
#else
const auto aa = _mm_xor_si128(a, _mm_srli_epi64(setmin_epi32(),32));
const auto bb = _mm_xor_si128(b, _mm_srli_epi64(setmin_epi32(),32));
const auto gt = _mm_cmpgt_epi32(aa, bb);
const auto eq = _mm_cmpeq_epi32(aa, bb);
// Algorithm:
// 1. if the high 32 bits of gt are true, make the full 64 bits true
// 2. if the high 32 bits of gt are false and the high 32 bits of eq are true,
// duplicate the low 32 bits of gt to the high 32 bits (note that this requires
// unsigned compare on the lower 32 bits, which is the reason for the xors
// above)
// 3. else make the full 64 bits false
const auto gt2 =
_mm_shuffle_epi32(gt, 0xf5); // dup the high 32 bits to the low 32 bits
const auto lo =
_mm_shuffle_epi32(_mm_and_si128(_mm_srli_epi64(eq, 32), gt), 0xa0);
return _mm_or_si128(gt2, lo);
#endif
}
static Vc_INTRINSIC __m128i Vc_CONST cmpgt_epu64(__m128i a, __m128i b)
{
return cmpgt_epi64(_mm_xor_si128(a, setmin_epi64()),
_mm_xor_si128(b, setmin_epi64()));
}
#endif
} // namespace SseIntrinsics
} // namespace Vc
// SSSE3
#ifdef Vc_IMPL_SSSE3
namespace Vc_VERSIONED_NAMESPACE
{
namespace SseIntrinsics
{
// not overriding _mm_set1_epi8 because this one should only be used for non-constants
Vc_INTRINSIC Vc_CONST __m128i abs_epi8(__m128i a) { return _mm_abs_epi8(a); }
Vc_INTRINSIC Vc_CONST __m128i abs_epi16(__m128i a) { return _mm_abs_epi16(a); }
Vc_INTRINSIC Vc_CONST __m128i abs_epi32(__m128i a) { return _mm_abs_epi32(a); }
template <int s> Vc_INTRINSIC Vc_CONST __m128i alignr_epi8(__m128i a, __m128i b)
{
return _mm_alignr_epi8(a, b, s & 0x1fu);
}
} // namespace SseIntrinsics
} // namespace Vc
#else
namespace Vc_VERSIONED_NAMESPACE
{
namespace SseIntrinsics
{
Vc_INTRINSIC Vc_CONST __m128i abs_epi8 (__m128i a) {
__m128i negative = _mm_cmplt_epi8 (a, _mm_setzero_si128());
return _mm_add_epi8 (_mm_xor_si128(a, negative), _mm_and_si128(negative, _mm_setone_epi8()));
}
// positive value:
// negative == 0
// a unchanged after xor
// 0 >> 31 -> 0
// a + 0 -> a
// negative value:
// negative == -1
// a xor -1 -> -a - 1
// -1 >> 31 -> 1
// -a - 1 + 1 -> -a
Vc_INTRINSIC Vc_CONST __m128i abs_epi16(__m128i a) {
__m128i negative = _mm_cmplt_epi16(a, _mm_setzero_si128());
return _mm_add_epi16(_mm_xor_si128(a, negative), _mm_srli_epi16(negative, 15));
}
Vc_INTRINSIC Vc_CONST __m128i abs_epi32(__m128i a) {
__m128i negative = _mm_cmplt_epi32(a, _mm_setzero_si128());
return _mm_add_epi32(_mm_xor_si128(a, negative), _mm_srli_epi32(negative, 31));
}
template <int s> Vc_INTRINSIC Vc_CONST __m128i alignr_epi8(__m128i a, __m128i b)
{
switch (s & 0x1fu) {
case 0: return b;
case 1: return _mm_or_si128(_mm_slli_si128(a, 15), _mm_srli_si128(b, 1));
case 2: return _mm_or_si128(_mm_slli_si128(a, 14), _mm_srli_si128(b, 2));
case 3: return _mm_or_si128(_mm_slli_si128(a, 13), _mm_srli_si128(b, 3));
case 4: return _mm_or_si128(_mm_slli_si128(a, 12), _mm_srli_si128(b, 4));
case 5: return _mm_or_si128(_mm_slli_si128(a, 11), _mm_srli_si128(b, 5));
case 6: return _mm_or_si128(_mm_slli_si128(a, 10), _mm_srli_si128(b, 6));
case 7: return _mm_or_si128(_mm_slli_si128(a, 9), _mm_srli_si128(b, 7));
case 8: return _mm_or_si128(_mm_slli_si128(a, 8), _mm_srli_si128(b, 8));
case 9: return _mm_or_si128(_mm_slli_si128(a, 7), _mm_srli_si128(b, 9));
case 10: return _mm_or_si128(_mm_slli_si128(a, 6), _mm_srli_si128(b, 10));
case 11: return _mm_or_si128(_mm_slli_si128(a, 5), _mm_srli_si128(b, 11));
case 12: return _mm_or_si128(_mm_slli_si128(a, 4), _mm_srli_si128(b, 12));
case 13: return _mm_or_si128(_mm_slli_si128(a, 3), _mm_srli_si128(b, 13));
case 14: return _mm_or_si128(_mm_slli_si128(a, 2), _mm_srli_si128(b, 14));
case 15: return _mm_or_si128(_mm_slli_si128(a, 1), _mm_srli_si128(b, 15));
case 16: return a;
case 17: return _mm_srli_si128(a, 1);
case 18: return _mm_srli_si128(a, 2);
case 19: return _mm_srli_si128(a, 3);
case 20: return _mm_srli_si128(a, 4);
case 21: return _mm_srli_si128(a, 5);
case 22: return _mm_srli_si128(a, 6);
case 23: return _mm_srli_si128(a, 7);
case 24: return _mm_srli_si128(a, 8);
case 25: return _mm_srli_si128(a, 9);
case 26: return _mm_srli_si128(a, 10);
case 27: return _mm_srli_si128(a, 11);
case 28: return _mm_srli_si128(a, 12);
case 29: return _mm_srli_si128(a, 13);
case 30: return _mm_srli_si128(a, 14);
case 31: return _mm_srli_si128(a, 15);
}
return _mm_setzero_si128();
}
} // namespace SseIntrinsics
} // namespace Vc
#endif
// SSE4.1
#ifdef Vc_IMPL_SSE4_1
namespace Vc_VERSIONED_NAMESPACE
{
namespace SseIntrinsics
{
Vc_INTRINSIC Vc_CONST __m128i cmpeq_epi64(__m128i a, __m128i b)
{
return _mm_cmpeq_epi64(a, b);
}
template <int index> Vc_INTRINSIC Vc_CONST int extract_epi32(__m128i v)
{
return _mm_extract_epi32(v, index);
}
Vc_INTRINSIC Vc_CONST __m128d blendv_pd(__m128d a, __m128d b, __m128d c)
{
return _mm_blendv_pd(a, b, c);
}
Vc_INTRINSIC Vc_CONST __m128 blendv_ps(__m128 a, __m128 b, __m128 c)
{
return _mm_blendv_ps(a, b, c);
}
Vc_INTRINSIC Vc_CONST __m128i blendv_epi8(__m128i a, __m128i b, __m128i c)
{
return _mm_blendv_epi8(a, b, c);
}
template <int mask> Vc_INTRINSIC Vc_CONST __m128d blend_pd(__m128d a, __m128d b)
{
return _mm_blend_pd(a, b, mask);
}
template <int mask> Vc_INTRINSIC Vc_CONST __m128 blend_ps(__m128 a, __m128 b)
{
return _mm_blend_ps(a, b, mask);
}
template <int mask> Vc_INTRINSIC Vc_CONST __m128i blend_epi16(__m128i a, __m128i b)
{
return _mm_blend_epi16(a, b, mask);
}
Vc_INTRINSIC Vc_CONST __m128i max_epi8(__m128i a, __m128i b)
{
return _mm_max_epi8(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i max_epi32(__m128i a, __m128i b)
{
return _mm_max_epi32(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i max_epu16(__m128i a, __m128i b)
{
return _mm_max_epu16(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i max_epu32(__m128i a, __m128i b)
{
return _mm_max_epu32(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i min_epu16(__m128i a, __m128i b)
{
return _mm_min_epu16(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i min_epu32(__m128i a, __m128i b)
{
return _mm_min_epu32(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i min_epi8(__m128i a, __m128i b)
{
return _mm_min_epi8(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i min_epi32(__m128i a, __m128i b)
{
return _mm_min_epi32(a, b);
}
Vc_INTRINSIC Vc_CONST __m128i cvtepu8_epi16(__m128i epu8)
{
return _mm_cvtepu8_epi16(epu8);
}
Vc_INTRINSIC Vc_CONST __m128i cvtepi8_epi16(__m128i epi8)
{
return _mm_cvtepi8_epi16(epi8);
}
Vc_INTRINSIC Vc_CONST __m128i cvtepu16_epi32(__m128i epu16)
{
return _mm_cvtepu16_epi32(epu16);
}
Vc_INTRINSIC Vc_CONST __m128i cvtepi16_epi32(__m128i epu16)
{
return _mm_cvtepi16_epi32(epu16);
}
Vc_INTRINSIC Vc_CONST __m128i cvtepu8_epi32(__m128i epu8)
{
return _mm_cvtepu8_epi32(epu8);
}
Vc_INTRINSIC Vc_CONST __m128i cvtepi8_epi32(__m128i epi8)
{
return _mm_cvtepi8_epi32(epi8);
}
Vc_INTRINSIC Vc_PURE __m128i stream_load_si128(__m128i *mem)
{
return _mm_stream_load_si128(mem);
}
} // namespace SseIntrinsics
} // namespace Vc
#else
namespace Vc_VERSIONED_NAMESPACE
{
namespace SseIntrinsics
{
Vc_INTRINSIC Vc_CONST __m128i cmpeq_epi64(__m128i a, __m128i b) {
auto tmp = _mm_cmpeq_epi32(a, b);
return _mm_and_si128(tmp, _mm_shuffle_epi32(tmp, 1*1 + 0*4 + 3*16 + 2*64));
}
template <int index> Vc_INTRINSIC Vc_CONST int extract_epi32(__m128i v)
{
#ifdef Vc_USE_BUILTIN_VECTOR_TYPES
typedef int int32v4 __attribute__((__vector_size__(16)));
return reinterpret_cast<const MayAlias<int32v4> &>(v)[index];
#else
return _mm_cvtsi128_si32(_mm_srli_si128(v, index * 4));
#endif
}
Vc_INTRINSIC Vc_CONST __m128d blendv_pd(__m128d a, __m128d b, __m128d c) {
return _mm_or_pd(_mm_andnot_pd(c, a), _mm_and_pd(c, b));
}
Vc_INTRINSIC Vc_CONST __m128 blendv_ps(__m128 a, __m128 b, __m128 c) {
return _mm_or_ps(_mm_andnot_ps(c, a), _mm_and_ps(c, b));
}
Vc_INTRINSIC Vc_CONST __m128i blendv_epi8(__m128i a, __m128i b, __m128i c) {
return _mm_or_si128(_mm_andnot_si128(c, a), _mm_and_si128(c, b));
}
// only use the following blend functions with immediates as mask and, of course, compiling
// with optimization
template <int mask> Vc_INTRINSIC Vc_CONST __m128d blend_pd(__m128d a, __m128d b)
{
switch (mask) {
case 0x0:
return a;
case 0x1:
return _mm_shuffle_pd(b, a, 2);
case 0x2:
return _mm_shuffle_pd(a, b, 2);
case 0x3:
return b;
default:
abort();
return a; // should never be reached, but MSVC needs it else it warns about 'not all control paths return a value'
}
}
template <int mask> Vc_INTRINSIC Vc_CONST __m128 blend_ps(__m128 a, __m128 b)
{
__m128i c;
switch (mask) {
case 0x0:
return a;
case 0x1:
c = _mm_srli_si128(_mm_setallone_si128(), 12);
break;
case 0x2:
c = _mm_slli_si128(_mm_srli_si128(_mm_setallone_si128(), 12), 4);
break;
case 0x3:
c = _mm_srli_si128(_mm_setallone_si128(), 8);
break;
case 0x4:
c = _mm_slli_si128(_mm_srli_si128(_mm_setallone_si128(), 12), 8);
break;
case 0x5:
c = _mm_set_epi32(0, -1, 0, -1);
break;
case 0x6:
c = _mm_slli_si128(_mm_srli_si128(_mm_setallone_si128(), 8), 4);
break;
case 0x7:
c = _mm_srli_si128(_mm_setallone_si128(), 4);
break;
case 0x8:
c = _mm_slli_si128(_mm_setallone_si128(), 12);
break;
case 0x9:
c = _mm_set_epi32(-1, 0, 0, -1);
break;
case 0xa:
c = _mm_set_epi32(-1, 0, -1, 0);
break;
case 0xb:
c = _mm_set_epi32(-1, 0, -1, -1);
break;
case 0xc:
c = _mm_slli_si128(_mm_setallone_si128(), 8);
break;
case 0xd:
c = _mm_set_epi32(-1, -1, 0, -1);
break;
case 0xe:
c = _mm_slli_si128(_mm_setallone_si128(), 4);
break;
case 0xf:
return b;
default: // may not happen
abort();
c = _mm_setzero_si128();
break;
}
__m128 _c = _mm_castsi128_ps(c);
return _mm_or_ps(_mm_andnot_ps(_c, a), _mm_and_ps(_c, b));
}
template <int mask> Vc_INTRINSIC Vc_CONST __m128i blend_epi16(__m128i a, __m128i b)
{
__m128i c;
switch (mask) {
case 0x00:
return a;
case 0x01:
c = _mm_srli_si128(_mm_setallone_si128(), 14);
break;
case 0x03:
c = _mm_srli_si128(_mm_setallone_si128(), 12);
break;
case 0x07:
c = _mm_srli_si128(_mm_setallone_si128(), 10);
break;
case 0x0f:
return _mm_unpackhi_epi64(_mm_slli_si128(b, 8), a);
case 0x1f:
c = _mm_srli_si128(_mm_setallone_si128(), 6);
break;
case 0x3f:
c = _mm_srli_si128(_mm_setallone_si128(), 4);
break;
case 0x7f:
c = _mm_srli_si128(_mm_setallone_si128(), 2);
break;
case 0x80:
c = _mm_slli_si128(_mm_setallone_si128(), 14);
break;
case 0xc0:
c = _mm_slli_si128(_mm_setallone_si128(), 12);
break;
case 0xe0:
c = _mm_slli_si128(_mm_setallone_si128(), 10);
break;
case 0xf0:
c = _mm_slli_si128(_mm_setallone_si128(), 8);
break;
case 0xf8:
c = _mm_slli_si128(_mm_setallone_si128(), 6);
break;
case 0xfc:
c = _mm_slli_si128(_mm_setallone_si128(), 4);
break;
case 0xfe:
c = _mm_slli_si128(_mm_setallone_si128(), 2);
break;
case 0xff:
return b;
case 0xcc:
return _mm_unpacklo_epi32(_mm_shuffle_epi32(a, _MM_SHUFFLE(2, 0, 2, 0)), _mm_shuffle_epi32(b, _MM_SHUFFLE(3, 1, 3, 1)));
case 0x33:
return _mm_unpacklo_epi32(_mm_shuffle_epi32(b, _MM_SHUFFLE(2, 0, 2, 0)), _mm_shuffle_epi32(a, _MM_SHUFFLE(3, 1, 3, 1)));
default:
const __m128i shift = _mm_set_epi16(0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000, -0x7fff);
c = _mm_srai_epi16(_mm_mullo_epi16(_mm_set1_epi16(mask), shift), 15);
break;
}
return _mm_or_si128(_mm_andnot_si128(c, a), _mm_and_si128(c, b));
}
Vc_INTRINSIC Vc_CONST __m128i max_epi8 (__m128i a, __m128i b) {
return blendv_epi8(b, a, _mm_cmpgt_epi8 (a, b));
}
Vc_INTRINSIC Vc_CONST __m128i max_epi32(__m128i a, __m128i b) {
return blendv_epi8(b, a, _mm_cmpgt_epi32(a, b));
}
//X Vc_INTRINSIC Vc_CONST __m128i max_epu8 (__m128i a, __m128i b) {
//X return _mm_blendv_epi8(b, a, cmpgt_epu8 (a, b));
//X }
Vc_INTRINSIC Vc_CONST __m128i max_epu16(__m128i a, __m128i b) {
return blendv_epi8(b, a, cmpgt_epu16(a, b));
}
Vc_INTRINSIC Vc_CONST __m128i max_epu32(__m128i a, __m128i b) {
return blendv_epi8(b, a, cmpgt_epu32(a, b));
}
//X Vc_INTRINSIC Vc_CONST __m128i _mm_min_epu8 (__m128i a, __m128i b) {
//X return _mm_blendv_epi8(a, b, cmpgt_epu8 (a, b));
//X }
Vc_INTRINSIC Vc_CONST __m128i min_epu16(__m128i a, __m128i b) {
return blendv_epi8(a, b, cmpgt_epu16(a, b));
}
Vc_INTRINSIC Vc_CONST __m128i min_epu32(__m128i a, __m128i b) {
return blendv_epi8(a, b, cmpgt_epu32(a, b));
}
Vc_INTRINSIC Vc_CONST __m128i min_epi8 (__m128i a, __m128i b) {
return blendv_epi8(a, b, _mm_cmpgt_epi8 (a, b));
}
Vc_INTRINSIC Vc_CONST __m128i min_epi32(__m128i a, __m128i b) {
return blendv_epi8(a, b, _mm_cmpgt_epi32(a, b));
}
Vc_INTRINSIC Vc_CONST __m128i cvtepu8_epi16(__m128i epu8) {
return _mm_unpacklo_epi8(epu8, _mm_setzero_si128());
}
Vc_INTRINSIC Vc_CONST __m128i cvtepi8_epi16(__m128i epi8) {
return _mm_unpacklo_epi8(epi8, _mm_cmplt_epi8(epi8, _mm_setzero_si128()));
}
Vc_INTRINSIC Vc_CONST __m128i cvtepu16_epi32(__m128i epu16) {
return _mm_unpacklo_epi16(epu16, _mm_setzero_si128());
}
Vc_INTRINSIC Vc_CONST __m128i cvtepi16_epi32(__m128i epu16) {
return _mm_unpacklo_epi16(epu16, _mm_cmplt_epi16(epu16, _mm_setzero_si128()));
}
Vc_INTRINSIC Vc_CONST __m128i cvtepu8_epi32(__m128i epu8) {
return cvtepu16_epi32(cvtepu8_epi16(epu8));
}
Vc_INTRINSIC Vc_CONST __m128i cvtepi8_epi32(__m128i epi8) {
const __m128i neg = _mm_cmplt_epi8(epi8, _mm_setzero_si128());
const __m128i epi16 = _mm_unpacklo_epi8(epi8, neg);
return _mm_unpacklo_epi16(epi16, _mm_unpacklo_epi8(neg, neg));
}
Vc_INTRINSIC Vc_PURE __m128i stream_load_si128(__m128i *mem) {
return _mm_load_si128(mem);
}
} // namespace SseIntrinsics
} // namespace Vc
#endif
// SSE4.2
namespace Vc_VERSIONED_NAMESPACE
{
namespace SseIntrinsics
{
static Vc_INTRINSIC Vc_CONST float extract_float_imm(const __m128 v, const size_t i) {
float f;
switch (i) {
case 0:
f = _mm_cvtss_f32(v);
break;
#if defined Vc_IMPL_SSE4_1 && !defined Vc_MSVC
default:
#ifdef Vc_GCC
f = __builtin_ia32_vec_ext_v4sf(static_cast<__v4sf>(v), (i));
#else
// MSVC fails to compile this because it can't optimize i to an immediate
_MM_EXTRACT_FLOAT(f, v, i);
#endif
break;
#else
case 1:
f = _mm_cvtss_f32(_mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(v), 4)));
break;
case 2:
f = _mm_cvtss_f32(_mm_movehl_ps(v, v));
break;
case 3:
f = _mm_cvtss_f32(_mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(v), 12)));
break;
#endif
}
return f;
}
static Vc_INTRINSIC Vc_CONST double extract_double_imm(const __m128d v, const size_t i) {
if (i == 0) {
return _mm_cvtsd_f64(v);
}
return _mm_cvtsd_f64(_mm_castps_pd(_mm_movehl_ps(_mm_castpd_ps(v), _mm_castpd_ps(v))));
}
static Vc_INTRINSIC Vc_CONST float extract_float(const __m128 v, const size_t i) {
#ifdef Vc_GCC
if (__builtin_constant_p(i)) {
return extract_float_imm(v, i);
//X if (index <= 1) {
//X unsigned long long tmp = _mm_cvtsi128_si64(_mm_castps_si128(v));
//X if (index == 0) tmp &= 0xFFFFFFFFull;
//X if (index == 1) tmp >>= 32;
//X return Common::AliasingEntryHelper<EntryType>(tmp);
//X }
} else {
typedef float float4[4] Vc_MAY_ALIAS;
const float4 &data = reinterpret_cast<const float4 &>(v);
return data[i];
}
#else
union { __m128 v; float m[4]; } u;
u.v = v;
return u.m[i];
#endif
}
static Vc_INTRINSIC Vc_PURE __m128 _mm_stream_load(const float *mem) {
#ifdef Vc_IMPL_SSE4_1
return _mm_castsi128_ps(_mm_stream_load_si128(reinterpret_cast<__m128i *>(const_cast<float *>(mem))));
#else
return _mm_load_ps(mem);
#endif
}
static Vc_INTRINSIC Vc_PURE __m128d _mm_stream_load(const double *mem) {
#ifdef Vc_IMPL_SSE4_1
return _mm_castsi128_pd(_mm_stream_load_si128(reinterpret_cast<__m128i *>(const_cast<double *>(mem))));
#else
return _mm_load_pd(mem);
#endif
}
static Vc_INTRINSIC Vc_PURE __m128i _mm_stream_load(const int *mem) {
#ifdef Vc_IMPL_SSE4_1
return _mm_stream_load_si128(reinterpret_cast<__m128i *>(const_cast<int *>(mem)));
#else
return _mm_load_si128(reinterpret_cast<const __m128i *>(mem));
#endif
}
static Vc_INTRINSIC Vc_PURE __m128i _mm_stream_load(const unsigned int *mem) {
return _mm_stream_load(reinterpret_cast<const int *>(mem));
}
static Vc_INTRINSIC Vc_PURE __m128i _mm_stream_load(const short *mem) {
return _mm_stream_load(reinterpret_cast<const int *>(mem));
}
static Vc_INTRINSIC Vc_PURE __m128i _mm_stream_load(const unsigned short *mem) {
return _mm_stream_load(reinterpret_cast<const int *>(mem));
}
static Vc_INTRINSIC Vc_PURE __m128i _mm_stream_load(const signed char *mem) {
return _mm_stream_load(reinterpret_cast<const int *>(mem));
}
static Vc_INTRINSIC Vc_PURE __m128i _mm_stream_load(const unsigned char *mem) {
return _mm_stream_load(reinterpret_cast<const int *>(mem));
}
#ifndef __x86_64__
Vc_INTRINSIC Vc_PURE __m128i _mm_cvtsi64_si128(int64_t x) {
return _mm_castpd_si128(_mm_load_sd(reinterpret_cast<const double *>(&x)));
}
#endif
} // namespace SseIntrinsics
} // namespace Vc
namespace Vc_VERSIONED_NAMESPACE
{
namespace SSE
{
using namespace SseIntrinsics;
template <typename T> struct ParameterHelper
{
typedef T ByValue;
typedef T &Reference;
typedef const T &ConstRef;
};
template <typename T> struct VectorHelper
{
};
template <typename T> struct VectorTypeHelper
{
typedef __m128i Type;
};
template <> struct VectorTypeHelper<double>
{
typedef __m128d Type;
};
template <> struct VectorTypeHelper<float>
{
typedef __m128 Type;
};
template <typename T> struct DetermineGatherMask
{
typedef T Type;
};
template <typename T> struct VectorTraits
{
typedef typename VectorTypeHelper<T>::Type VectorType;
using EntryType = typename Common::ensure_alignment_equals_sizeof<T>::type;
static constexpr size_t Size = sizeof(VectorType) / sizeof(EntryType);
enum Constants { HasVectorDivision = !std::is_integral<T>::value };
typedef Mask<T> MaskType;
typedef typename DetermineGatherMask<MaskType>::Type GatherMaskType;
typedef Common::VectorMemoryUnion<VectorType, EntryType> StorageType;
};
template <typename T> struct VectorHelperSize;
} // namespace SSE
} // namespace Vc
#if defined(Vc_GCC) && !defined(__OPTIMIZE__)
#pragma GCC diagnostic pop
#endif
#include "shuffle.h"
#endif // VC_SSE_INTRINSICS_H_
| [
"thomaskrause@posteo.de"
] | thomaskrause@posteo.de |
6db83f29649c5bd1a680c123faeb8b96089bbbb7 | de3b1258e85d2379f3a37a8f63e729cfebb9c65e | /lightoj/1403 - Air Raid.cpp | e464aa49e9e4d391cd8e0a00b64bad446d9a8f27 | [] | no_license | mamun4122/My-Online-Judge-Submission | a8223e92fb57bf009b878f3f29b0456366f21b97 | a96dffbef52f47d2cd3d769b00c557f8304b3f2f | refs/heads/master | 2020-04-04T06:02:50.042950 | 2017-11-27T03:37:07 | 2017-11-27T03:37:07 | 51,596,094 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,229 | cpp | #pragma comment(linker, "/stack:640000000")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
const double EPS = 1e-9;
const int INF = 0x7f7f7f7f;
const double PI=acos(-1.0);
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define MP(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define rep(i,n) for(int i = 1 ; i<=(n) ; i++)
#define repI(i,n) for(int i = 0 ; i<(n) ; i++)
#define FOR(i,L,R) for (int i = L; i <= R; i++)
#define ROF(i,L,R) for (int i = L; i >= R; i--)
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define ALL(p) p.begin(),p.end()
#define ALLR(p) p.rbegin(),p.rend()
#define SET(p) memset(p, -1, sizeof(p))
#define CLR(p) memset(p, 0, sizeof(p))
#define MEM(p, v) memset(p, v, sizeof(p))
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld%lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define getC(n) scanf("%c",&n)
#define getF(n) scanf("%lf",&n)
#define getS(n) scanf("%s",n)
#define bitCheck(a,k) ((bool)(a&(1<<(k))))
#define bitOff(a,k) (a&(~(1<<(k))))
#define bitOn(a,k) (a|(1<<(k)))
#define bitFlip(a,k) (a^(1<<(k)))
#define iseq(a,b) (fabs(a-b)<EPS)
#define vi vector < int >
#define vii vector < vector < int > >
#define pii pair< int, int >
#define ff first
#define ss second
#define ll long long
#define ull unsigned long long
template< class T > inline T gcd(T a, T b)
{
return (b) == 0 ? (a) : gcd((b), ((a) % (b)));
}
template< class T > inline T lcm(T a, T b)
{
return ((a) / gcd((a), (b)) * (b));
}
template <typename T> string NumberToString ( T Number )
{
ostringstream ss;
ss << Number;
return ss.str();
}
#ifdef mamun
#define debug(args...) {cerr<<"*: "; dbg,args; cerr<<endl;}
#else
#define debug(args...) // Just strip off all debug tokens
#endif
struct debugger
{
template<typename T> debugger& operator, (const T& v)
{
cerr<<v<<" ";
return *this;
}
} dbg;
///****************** template ends here ****************
int t,n,m;
#define MAX 1005
vector < int > edges[MAX];
bool visited[MAX];
int Left[MAX], Right[MAX];
bool dfs(int u)
{
if(visited[u]) return false;
visited[u] = true;
int len = edges[u].size(), i, v;
for(i=0; i<len; i++)
{
v = edges[u][i];
if(Right[v]==-1)
{
Right[v] = u, Left[u] = v;
return true;
}
}
for(i=0; i<len; i++)
{
v = edges[u][i];
if(dfs(Right[v]))
{
Right[v] = u, Left[u] = v;
return true;
}
}
return false;
}
int match(int n)
{
SET(Left);
SET(Right);
int i, ret = 0;
bool done;
do
{
done = true;
CLR(visited);
rep(i,n)if(Left[i]==-1 && dfs(i))done = false;
}while(!done);
rep(i,n) ret += (Left[i]!=-1);
return ret;
}
int main()
{
#ifdef mamun
READ("in.txt");
// WRITE("out.txt");
#endif // mamun
getI(t);
rep(cs,t)
{
getII(n,m);
// CLR(visited);
rep(i,n)edges[i].clear();
rep(i,m)
{
int u, v;
getII(u,v);
edges[u].push_back(v);
// edges[v].push_back(u);
}
// SET(par);
// SET(dp);
// int ans=0;
// ans = min(call(1, 1), call(1, 0));
printf("Case %d: %d\n",cs,n-match(n));
}
return 0;
}
| [
"mamun4122@gmail.com"
] | mamun4122@gmail.com |
ae8fd40dff952b29521afa2fcd4a7fed7078efc4 | d0a5224a19a87a5cedf357aa30a4e8e8af932adf | /SkeletonViewer opencv 2.1 skin detection/DrawDevice.cpp | b5046b248ecbb13fa6729652d2526150d278fdc1 | [] | no_license | shayekharjan/Skin-Detection | 84ad7e0c14f774cb911f392f4a7f807c423b7ade | f36569928a3fb0fc7beb22c6b41dd429fd26264d | refs/heads/master | 2021-01-25T05:36:00.251660 | 2013-01-06T22:11:25 | 2013-01-06T22:11:25 | 7,472,949 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,876 | cpp | //------------------------------------------------------------------------------
// <copyright file="DrawDevice.cpp" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
// Manages the drawing of bitmap data
#include "stdafx.h"
#include "DrawDevice.h"
int padding = 0;
inline LONG Width( const RECT& r )
{
return r.right - r.left;
}
inline LONG Height( const RECT& r )
{
return r.bottom - r.top;
}
//-------------------------------------------------------------------
// Constructor
//-------------------------------------------------------------------
DrawDevice::DrawDevice() :
m_hwnd(0),
m_sourceWidth(0),
m_sourceHeight(0),
m_stride(0),
m_pD2DFactory(NULL),
m_pRenderTarget(NULL),
m_pBitmap(0)
{
}
//-------------------------------------------------------------------
// Destructor
//-------------------------------------------------------------------
DrawDevice::~DrawDevice()
{
DiscardResources();
SafeRelease(m_pD2DFactory);
}
//-------------------------------------------------------------------
// EnsureResources
//
// Ensure necessary Direct2d resources are created
//-------------------------------------------------------------------
HRESULT DrawDevice::EnsureResources()
{
HRESULT hr = S_OK;
if ( !m_pRenderTarget )
{
D2D1_SIZE_U size = D2D1::SizeU( m_sourceWidth, m_sourceHeight );
D2D1_RENDER_TARGET_PROPERTIES rtProps = D2D1::RenderTargetProperties();
rtProps.pixelFormat = D2D1::PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE);
rtProps.usage = D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE;
// Create a Hwnd render target, in order to render to the window set in initialize
hr = m_pD2DFactory->CreateHwndRenderTarget(
rtProps,
D2D1::HwndRenderTargetProperties(m_hwnd, size),
&m_pRenderTarget
);
if ( FAILED( hr ) )
{
return hr;
}
// Create a bitmap that we can copy image data into and then render to the target
hr = m_pRenderTarget->CreateBitmap(
D2D1::SizeU( m_sourceWidth, m_sourceHeight ),
D2D1::BitmapProperties( D2D1::PixelFormat( DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE) ),
&m_pBitmap
);
if ( FAILED( hr ) )
{
SafeRelease( m_pRenderTarget );
return hr;
}
}
return hr;
}
//-------------------------------------------------------------------
// DiscardResources
//
// Dispose Direct2d resources
//-------------------------------------------------------------------
void DrawDevice::DiscardResources( )
{
SafeRelease(m_pRenderTarget);
SafeRelease(m_pBitmap);
}
//-------------------------------------------------------------------
// Initialize
//
// Set the window to draw to, video format, etc.
//-------------------------------------------------------------------
bool DrawDevice::Initialize( HWND hwnd, ID2D1Factory * pD2DFactory, int sourceWidth, int sourceHeight, int Stride )
{
m_hwnd = hwnd;
// One factory for the entire application so save a pointer here
m_pD2DFactory = pD2DFactory;
m_pD2DFactory->AddRef( );
// Get the frame size
m_stride = Stride;
m_sourceWidth = sourceWidth;
m_sourceHeight = sourceHeight;
return true;
}
//-------------------------------------------------------------------
// DrawFrame
//
// Draw the video frame.
//-------------------------------------------------------------------
bool DrawDevice::Draw( BYTE * pBits, unsigned long cbBits )
{
// incorrectly sized image data passed in
if ( cbBits < ((m_sourceHeight - 1) * m_stride) + (m_sourceWidth * 4) )
{
return false;
}
// create the resources for this draw device
// they will be recreated if previously lost
HRESULT hr = EnsureResources( );
if ( FAILED( hr ) )
{
return false;
}
// Copy the image that was passed in into the direct2d bitmap
hr = m_pBitmap->CopyFromMemory( NULL, pBits, m_stride );
if ( FAILED( hr ) )
{
return false;
}
m_pRenderTarget->BeginDraw();
// Draw the bitmap stretched to the size of the window
m_pRenderTarget->DrawBitmap( m_pBitmap );
hr = m_pRenderTarget->EndDraw();
// Device lost, need to recreate the render target
// We'll dispose it now and retry drawing
if ( hr == D2DERR_RECREATE_TARGET )
{
hr = S_OK;
DiscardResources();
}
return SUCCEEDED( hr );
}
bool DrawDevice::SaveBMP ( BYTE* Buffer, int width, int height, long paddedsize, LPCTSTR bmpfile )
{
// declare bmp structures
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER info;
// andinitialize them to zero
memset ( &bmfh, 0, sizeof (BITMAPFILEHEADER ) );
memset ( &info, 0, sizeof (BITMAPINFOHEADER ) );
// fill the fileheader with data
bmfh.bfType = 0x4d42; // 0x4d42 = 'BM'
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + paddedsize;
bmfh.bfOffBits = 0x36; // number of bytes to start of bitmap bits
// fill the infoheader
info.biSize = sizeof(BITMAPINFOHEADER);
info.biWidth = width;
info.biHeight = height;
info.biPlanes = 1; // we only have one bitplane
info.biBitCount = 24; // RGB mode is 24 bits
info.biCompression = BI_RGB;
info.biSizeImage = 0; // can be 0 for 24 bit images
info.biXPelsPerMeter = 0x0ec4; // paint and PSP use this values
info.biYPelsPerMeter = 0x0ec4;
info.biClrUsed = 0; // we are in RGB mode and have no palette
info.biClrImportant = 0; // all colors are important
// now we open the file to write to
HANDLE file = CreateFile ( bmpfile , GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if ( file == NULL )
{
CloseHandle ( file );
return false;
}
// write file header
unsigned long bwritten;
if ( WriteFile ( file, &bmfh, sizeof ( BITMAPFILEHEADER ), &bwritten, NULL ) == false )
{
CloseHandle ( file );
return false;
}
// write infoheader
if ( WriteFile ( file, &info, sizeof ( BITMAPINFOHEADER ), &bwritten, NULL ) == false )
{
CloseHandle ( file );
return false;
}
// write image data
if ( WriteFile ( file, Buffer, paddedsize, &bwritten, NULL ) == false )
{
CloseHandle ( file );
return false;
}
// and close file
CloseHandle ( file );
return true;
};
BYTE* DrawDevice::ConvertRGBToBMPBuffer ( BYTE* Buffer, int width, int height, long* newsize )
{
if ( ( NULL == Buffer ) || ( width == 0 ) || ( height == 0 ) )
return NULL;
int scanlinebytes = width * 3;
//while ( ( scanlinebytes + padding ) % 5 != 0 )
//padding++;
padding=0;
int psw = scanlinebytes + padding;
*newsize = height * psw;
BYTE* newbuf = new BYTE[*newsize];
memset ( newbuf, 0, *newsize );
long bufpos = 0;
long newpos = 0;
for ( int y = 0; y < height; y++ )
for ( int x = 0; x < 3 * width; x+=3 )
{
bufpos = y * 3 * width + x; // position in original buffer
newpos = ( height - y - 1 ) * psw + x; // position in padded buffer
newbuf[newpos] = 1.164*(Buffer[bufpos]-16)+2.018*(Buffer[bufpos+1]-128); // swap r and b
newbuf[newpos + 1] = 1.164*(Buffer[bufpos]-16)-0.813*(Buffer[bufpos+2]-128)-0.391*(Buffer[bufpos+1]-128); // g stays
newbuf[newpos + 2] = 1.164*(Buffer[bufpos]-16)+1.596*(Buffer[bufpos+2]-128); // swap b and r
}
return newbuf;
} | [
"shayekh.arjan.amit@gmail.com"
] | shayekh.arjan.amit@gmail.com |
7b7d2ca6f79258004875798475d36b438324641a | 40dcc3eb015c1e0b317e66a8f2616bec8ac59632 | /internal/engine/common/image_format.hpp | 8dbd9e66a8a666ba5226617d49115564ba76a133 | [] | no_license | VladislavKhudziakov/ogl_engine | 7d0fff6faca6e5ad7cafa134ad080fcf843fd673 | 245cd38c538d949a8a33d3a75fc80c31d66247b9 | refs/heads/master | 2020-08-07T00:40:37.550652 | 2019-12-28T16:05:03 | 2019-12-28T16:05:03 | 213,223,166 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 156 | hpp | //
// Created by movleaxedx on 2.11.19.
//
#pragma once
namespace engine
{
enum class image_format
{
rgb = 3,
rgba = 4
};
}
| [
"super.tawer.822@gmail.com"
] | super.tawer.822@gmail.com |
eaa3b6092406494545de99e95f27e263fbc9b842 | 7a4c15eae8d206ee51b978722b6c9a9cda523263 | /Past/Accelerometer/Accelerometer.ino | ed2532174b7092d9354c77af27d430890b6de86c | [] | no_license | 5Exploiters/LOTR | 12e2972fa7f999e4b8b8b5b257574efc52f0ff6d | 64b9643bd11e152900ff967e9de1dc175a4ff4c6 | refs/heads/master | 2021-01-23T21:57:21.805558 | 2017-11-06T16:51:30 | 2017-11-06T16:51:30 | 102,916,110 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 6,054 | ino | #include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include "Wire.h"
MPU6050 mpu(0x68);
MPU6050 mpu1(0x69); // <-- use for AD0 high
#define OUTPUT_READABLE_YAWPITCHROLL
#define INTERRUPT_PIN 2 // use pin 2 on Arduino Uno & most boards
bool blinkState = false;
bool dmpReady = false; // set true if DMP init was successful
bool dmpReady1=false;
uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU
uint8_t mpuIntStatus1;
uint8_t devStatus; // return status after each device operation (0 = success, !0 = error)
uint8_t devStatus1;
uint16_t packetSize; // expected DMP packet size (default is 42 bytes)
uint16_t packetSize1;
uint16_t fifoCount; // count of all bytes currently in FIFO
uint16_t fifoCount1;
uint8_t fifoBuffer[64]; // FIFO storage buffer
uint8_t fifoBuffer1[64];
// orientation/motion vars
Quaternion q; // [w, x, y, z] quaternion container
Quaternion q1;
VectorFloat gravity; // [x, y, z] gravity vector
float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector
float ypr1[3];
volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high
volatile bool mpuInterrupt1=false;
void dmpDataReady() {
mpuInterrupt = true;
}
void dmpDataReady1() {
mpuInterrupt1=true;
}
void setup() {
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Wire.begin();
Wire.setClock(400000); // 400kHz I2C clock. Comment this line if having compilation difficulties
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
Fastwire::setup(400, true);
#endif
Serial.begin(115200);
while (!Serial); // wait for Leonardo enumeration, others continue immediately
Serial.println(F("Initializing I2C devices..."));
mpu.initialize();
mpu1.initialize();
pinMode(INTERRUPT_PIN, INPUT);
pinMode(3,INPUT);
// verify connection
Serial.println(F("Testing device connections..."));
Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
devStatus = mpu.dmpInitialize();
devStatus1=mpu1.dmpInitialize();
// supply your own gyro offsets here, scaled for min sensitivity
mpu.setXGyroOffset(220);
mpu.setYGyroOffset(76);
mpu.setZGyroOffset(-85);
mpu.setZAccelOffset(1788); // 1688 factory default for my test chip
mpu1.setXGyroOffset(220);
mpu1.setYGyroOffset(76);
mpu1.setZGyroOffset(-85);
mpu1.setZAccelOffset(1788); // 1688 factory default for my test chip
// make sure it worked (returns 0 if so)
if (devStatus == 0) {
// turn on the DMP, now that it's ready
Serial.println(F("Enabling DMP..."));
mpu.setDMPEnabled(true);
mpu1.setDMPEnabled(true);
// enable Arduino interrupt detection
Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), dmpDataReady, RISING);
attachInterrupt(digitalPinToInterrupt(3), dmpDataReady1, RISING);
mpuIntStatus = mpu.getIntStatus();
mpuIntStatus1 = mpu1.getIntStatus();
// set our DMP Ready flag so the main loop() function knows it's okay to use it
Serial.println(F("DMP ready! Waiting for first interrupt..."));
dmpReady = true;
dmpReady1=true;
// get expected DMP packet size for later comparison
packetSize = mpu.dmpGetFIFOPacketSize();
packetSize1=mpu1.dmpGetFIFOPacketSize();
} else {
// ERROR!
// 1 = initial memory load failed
// 2 = DMP configuration updates failed
// (if it's going to break, usually the code will be 1)
Serial.print(F("DMP Initialization failed (code "));
Serial.print(devStatus);
Serial.println(F(")"));
}
}
void loop() {
if (!dmpReady) return;
while (!mpuInterrupt && fifoCount < packetSize) {
}
mpuInterrupt = false;
mpuInterrupt1=false;
mpuIntStatus = mpu.getIntStatus();
mpuIntStatus1=mpu.getIntStatus();
fifoCount = mpu.getFIFOCount();
fifoCount1=mpu1.getFIFOCount();
if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
// reset so we can continue cleanly
mpu.resetFIFO();
Serial.println(F("FIFO overflow!"));
// otherwise, check for DMP data ready interrupt (this should happen frequently)
} else if (mpuIntStatus & 0x02) {
// wait for correct available data length, should be a VERY short wait
while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();
// read a packet from FIFO
mpu.getFIFOBytes(fifoBuffer, packetSize);
fifoCount -= packetSize;
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
Serial.print("ypr\t");
Serial.print(ypr[0] * 180/M_PI);
Serial.print("\t");
Serial.print(ypr[1] * 180/M_PI);
Serial.print("\t");
Serial.print(ypr[2] * 180/M_PI);
}
if ((mpuIntStatus1 & 0x10) || fifoCount1 == 1024) {
// reset so we can continue cleanly
mpu1.resetFIFO();
Serial.println(F("FIFO overflow!"));
}
else if (mpuIntStatus1 & 0x02) {
// wait for correct available data length, should be a VERY short wait
while (fifoCount1 < packetSize1) fifoCount1 = mpu1.getFIFOCount();
// read a packet from FIFO
mpu1.getFIFOBytes(fifoBuffer1, packetSize1);
fifoCount1 -= packetSize1;
mpu1.dmpGetQuaternion(&q1, fifoBuffer1);
mpu1.dmpGetGravity(&gravity, &q1);
mpu1.dmpGetYawPitchRoll(ypr1, &q1, &gravity);
}
Serial.print("ypr\t");
Serial.print(ypr1[0] * 180/M_PI);
Serial.print("\t");
Serial.print(ypr1[1] * 180/M_PI);
Serial.print("\t");
Serial.println(ypr1[2] * 180/M_PI);
// otherwise, check for DMP data ready interrupt (this should happen frequently)
}
| [
"risalwi@ctemc.org"
] | risalwi@ctemc.org |
f430c8afeb4672b58eac88bd6e85028ecae64d7e | 7018861379591d10d10ac413a70c2bbeb8660da0 | /NKEngineUnitTest/NKUnitTest.cpp | 0be9654e1360dc4654433462e15bd2bcdff51d7b | [] | no_license | nolimitk/NKEngine | 9e0fc60c8df2a603986c3bf9df1569897ae9d26e | fc1d9fde440be0b6be35ea9a59729b1b986ead1d | refs/heads/master | 2021-10-10T07:24:52.031824 | 2021-09-28T11:20:42 | 2021-09-28T11:20:42 | 59,344,216 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,688 | cpp | #include "NKUnitTest.h"
#include <thread>
bool NKUnitTest::NKUnitQueue::run(bool benchmark_execute)
{
while (_queue.empty() == false)
{
TestNode test_node = _queue.front();
_queue.pop();
if (benchmark_execute == false && test_node._benchmark == true)
{
continue;
}
test_node._func();
}
return true;
}
bool NKUnitTest::NKReporter::print(void)
{
while (_queue.empty() == false)
{
TestResult test_result = _queue.front();
_queue.pop();
NKUNITTESTLOG_ERROR(L"unittest failed, %s, %d, %s", test_result._filename.c_str(), test_result._line, test_result._msg.c_str());
}
return false;
}
bool NKUnitTest::NKUnitTestFramework::run(bool benchmark_execute)
{
NKUNITTESTLOG_INFO(L"nkunittest has started");
if (_unit_queue.run(benchmark_execute) == false)
{
NKUNITTESTLOG_ERROR(L"nkunittest failed to run");
_ASSERT(false);
return false;
}
_reporter.print();
NKUNITTESTLOG_INFO(L"nkunittest has ended");
NKUnittestLogSingleton::destroy();
return true;
}
NKUnitTest::NKUnitTestFramework& NKUnitTest::getInstance(void)
{
static NKUnitTest::NKUnitTestFramework instance;
return instance;
}
void NKUnitTest::thread_test(const uint32_t count, std::function<void(void)> func)
{
std::thread* t = new std::thread[count];
for (uint32_t i = 0; i < count; ++i)
{
t[i] = std::thread(func);
}
for (uint32_t i = 0; i < count; ++i)
{
t[i].join();
}
SAFE_DELETE_ARRAY(t);
}
bool NKUnitTest::register_test(NKUnitQueue::UNITTEST_FUNC func, bool benchmark)
{
return getInstance().pushUnit(func, benchmark);
}
bool NKUnitTest::register_result(NKWString filename, int line, NKWString msg)
{
return getInstance().pushResult(filename, line, msg);
}
| [
"kizz@naver.com"
] | kizz@naver.com |
add88037f084a184546861194cab991dc8ae9cb7 | 108b143e471b91f216d579ea86c8d83a4e0cf861 | /Source/NewComponent(2).h | a174345bad1ac39b0c2fb32e0358c918f5012abc | [] | no_license | timothybarraclough/motionSickness | 8b4c9392fcb0bc64f184f2da8961fb7902765eaa | 3d67e1ce356bfd8630ea037485063d81c090b21a | refs/heads/master | 2021-01-22T06:40:30.770652 | 2015-03-02T22:45:15 | 2015-03-02T22:45:15 | 31,567,570 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,169 | h | /*
==============================================================================
This is an automatically generated GUI class created by the Introjucer!
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Introjucer version: 3.1.0
------------------------------------------------------------------------------
The Introjucer is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-13 by Raw Material Software Ltd.
==============================================================================
*/
#ifndef __JUCE_HEADER_AB996719044DDC55__
#define __JUCE_HEADER_AB996719044DDC55__
//[Headers] -- You can add your own extra header files here --
#include "JuceHeader.h"
//[/Headers]
//==============================================================================
/**
//[Comments]
An auto-generated component, created by the Introjucer.
Describe your class and how it works here!
//[/Comments]
*/
class NewComponent : public Component
{
public:
//==============================================================================
NewComponent ();
~NewComponent();
//==============================================================================
//[UserMethods] -- You can add your own custom methods in this section.
//[/UserMethods]
void paint (Graphics& g);
void resized();
private:
//[UserVariables] -- You can add your own custom variables in this section.
//[/UserVariables]
//==============================================================================
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (NewComponent)
};
//[EndFile] You can add extra defines here...
//[/EndFile]
#endif // __JUCE_HEADER_AB996719044DDC55__
| [
"barraclough.tim@gmail.com"
] | barraclough.tim@gmail.com |
c52e3f0000f116ff1da8c2a5ed1f986b72c4dbf4 | 79209377759c737e2c6bab57efe551d88847cddc | /abstract-factory/main.cpp | 5e401e982ce5a39536158c35acafc7bde2ccb33c | [] | no_license | neptune46/design-pattern-cpp | a47e6701450d9c85d5e2414255f7ecdc64beb6da | 85c9a8a5c94359d083ca53a9b82b5a3a37d9c6fb | refs/heads/master | 2021-05-07T09:19:08.748893 | 2017-11-05T03:20:24 | 2017-11-05T03:20:24 | 109,496,513 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 133 | cpp | // abstractfactory.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int main()
{
return 0;
}
| [
"neptune46@outlook.com"
] | neptune46@outlook.com |
40eb3cf69a5dd67dad58ee29a2d50c4cce4d868c | 24b818534f3149889e9e9eee507ec9dce508cc9c | /src/qt/transactiondesc.cpp | c983ebc5c79621a10a4967bf78dbdc8a4dd3aafa | [
"MIT"
] | permissive | cplayio/cplay | dad9b9c8287aded3ba708da922927c4db9ceb3bb | 497911c04321a1d2e8209c13ab3a69afb985befc | refs/heads/master | 2020-03-24T21:30:05.434540 | 2018-07-31T21:31:01 | 2018-07-31T21:31:01 | 143,008,105 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,893 | cpp | #include "transactiondesc.h"
#include "bitcoinunits.h"
#include "guiutil.h"
#include "base58.h"
#include "main.h"
#include "paymentserver.h"
#include "transactionrecord.h"
#include "util.h"
#include "ui_interface.h"
#include "wallet.h"
#include "txdb.h"
#include <string>
QString TransactionDesc::FormatTxStatus(const CWalletTx& wtx)
{
AssertLockHeld(cs_main);
if (!IsFinalTx(wtx, nBestHeight + 1))
{
if (wtx.nLockTime < LOCKTIME_THRESHOLD)
return tr("Open for %n more block(s)", "", wtx.nLockTime - nBestHeight);
else
return tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx.nLockTime));
}
else
{
int signatures = wtx.GetTransactionLockSignatures();
QString strUsingIX = "";
if(signatures >= 0){
if(signatures >= INSTANTX_SIGNATURES_REQUIRED){
int nDepth = wtx.GetDepthInMainChain();
if (nDepth < 0)
return tr("conflicted");
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
return tr("%1/offline (verified via instantx)").arg(nDepth);
else if (nDepth < 10)
return tr("%1/confirmed (verified via instantx)").arg(nDepth);
else
return tr("%1 confirmations (verified via instantx)").arg(nDepth);
} else {
if(!wtx.IsTransactionLockTimedOut()){
int nDepth = wtx.GetDepthInMainChain();
if (nDepth < 0)
return tr("conflicted");
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
return tr("%1/offline (InstantX verification in progress - %2 of %3 signatures)").arg(nDepth).arg(signatures).arg(INSTANTX_SIGNATURES_TOTAL);
else if (nDepth < 10)
return tr("%1/confirmed (InstantX verification in progress - %2 of %3 signatures )").arg(nDepth).arg(signatures).arg(INSTANTX_SIGNATURES_TOTAL);
else
return tr("%1 confirmations (InstantX verification in progress - %2 of %3 signatures)").arg(nDepth).arg(signatures).arg(INSTANTX_SIGNATURES_TOTAL);
} else {
int nDepth = wtx.GetDepthInMainChain();
if (nDepth < 0)
return tr("conflicted");
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
return tr("%1/offline (InstantX verification failed)").arg(nDepth);
else if (nDepth < 10)
return tr("%1/confirmed (InstantX verification failed)").arg(nDepth);
else
return tr("%1 confirmations").arg(nDepth);
}
}
} else {
int nDepth = wtx.GetDepthInMainChain();
if (nDepth < 0)
return tr("conflicted");
else if (GetAdjustedTime() - wtx.nTimeReceived > 2 * 60 && wtx.GetRequestCount() == 0)
return tr("%1/offline").arg(nDepth);
else if (nDepth < 10)
return tr("%1/unconfirmed").arg(nDepth);
else
return tr("%1 confirmations").arg(nDepth);
}
}
}
QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionRecord *rec, int unit)
{
QString strHTML;
LOCK2(cs_main, wallet->cs_wallet);
strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
int64_t nTime = wtx.GetTxTime();
CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
CAmount nNet = nCredit - nDebit;
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx);
int nRequests = wtx.GetRequestCount();
if (nRequests != -1)
{
if (nRequests == 0)
strHTML += tr(", has not been successfully broadcast yet");
else if (nRequests > 0)
strHTML += tr(", broadcast through %n node(s)", "", nRequests);
}
strHTML += "<br>";
strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "") + "<br>";
//
// From
//
if (wtx.IsCoinBase() || wtx.IsCoinStake())
{
strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
}
else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty())
{
// Online transaction
strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "<br>";
}
else
{
// Offline transaction
if (nNet > 0)
{
// Credit
if (CcPlayAddress(rec->address).IsValid())
{
CTxDestination address = CcPlayAddress(rec->address).Get();
if (wallet->mapAddressBook.count(address))
{
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
strHTML += "<b>" + tr("To") + ":</b> ";
strHTML += GUIUtil::HtmlEscape(rec->address);
QString addressOwned = (::IsMine(*wallet, address) == ISMINE_SPENDABLE) ? tr("own address") : tr("watch-only");
if (!wallet->mapAddressBook[address].empty())
strHTML += " (" + addressOwned + ", " + tr("label") + ": " + GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + ")";
else
strHTML += " (" + addressOwned + ")";
strHTML += "<br>";
}
}
}
}
//
// To
//
if (wtx.mapValue.count("to") && !wtx.mapValue["to"].empty())
{
// Online transaction
std::string strAddress = wtx.mapValue["to"];
strHTML += "<b>" + tr("To") + ":</b> ";
CTxDestination dest = CcPlayAddress(strAddress).Get();
if (wallet->mapAddressBook.count(dest) && !wallet->mapAddressBook[dest].empty())
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[dest]) + " ";
strHTML += GUIUtil::HtmlEscape(strAddress) + "<br>";
}
//
// Amount
//
if (wtx.IsCoinBase() && nCredit == 0)
{
//
// Coinbase
//
CAmount nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
nUnmatured += wallet->GetCredit(txout, ISMINE_ALL);
strHTML += "<b>" + tr("Credit") + ":</b> ";
if (wtx.IsInMainChain())
strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured)+ " (" + tr("matures in %n more block(s)", "", wtx.GetBlocksToMaturity()) + ")";
else
strHTML += "(" + tr("not accepted") + ")";
strHTML += "<br>";
}
else if (nNet > 0)
{
//
// Credit
//
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, nNet) + "<br>";
}
else
{
isminetype fAllFromMe = ISMINE_SPENDABLE;
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
{
isminetype mine = wallet->IsMine(txin);
if(fAllFromMe > mine) fAllFromMe = mine;
}
isminetype fAllToMe = ISMINE_SPENDABLE;
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
isminetype mine = wallet->IsMine(txout);
if(fAllToMe > mine) fAllToMe = mine;
}
if (fAllFromMe)
{
if(fAllFromMe == ISMINE_WATCH_ONLY)
strHTML += "<b>" + tr("From") + ":</b> " + tr("watch-only") + "<br>";
//
// Debit
//
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
{
// Ignore change
isminetype toSelf = wallet->IsMine(txout);
if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE))
continue;
if (!wtx.mapValue.count("to") || wtx.mapValue["to"].empty())
{
// Offline transaction
CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address))
{
strHTML += "<b>" + tr("To") + ":</b> ";
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " ";
strHTML += GUIUtil::HtmlEscape(CcPlayAddress(address).ToString());
if(toSelf == ISMINE_SPENDABLE)
strHTML += " (own address)";
else if(toSelf == ISMINE_WATCH_ONLY)
strHTML += " (watch-only)";
strHTML += "<br>";
}
}
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -txout.nValue) + "<br>";
if(toSelf)
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, txout.nValue) + "<br>";
}
if (fAllToMe)
{
// Payment to self
CAmount nChange = wtx.GetChange();
CAmount nValue = nCredit - nChange;
strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nValue) + "<br>";
strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, nValue) + "<br>";
}
CAmount nTxFee = nDebit - wtx.GetValueOut();
if (nTxFee > 0)
strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -nTxFee) + "<br>";
}
else
{
//
// Mixed debit transaction
//
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if (wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if (wallet->IsMine(txout))
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
}
}
strHTML += "<b>" + tr("Net amount") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, nNet, true) + "<br>";
//
// Message
//
if (wtx.mapValue.count("message") && !wtx.mapValue["message"].empty())
strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["message"], true) + "<br>";
if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty())
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "<br>";
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + TransactionRecord::formatSubTxId(wtx.GetHash(), rec->idx) + "<br>";
if (wtx.IsCoinBase() || wtx.IsCoinStake())
{
strHTML += "<br>" + tr("Generated coins must mature 80 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.") + "<br>";
}
//
// Debug view
//
if (fDebug)
{
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
if(wallet->IsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, -wallet->GetDebit(txin, ISMINE_ALL)) + "<br>";
BOOST_FOREACH(const CTxOut& txout, wtx.vout)
if(wallet->IsMine(txout))
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(unit, wallet->GetCredit(txout, ISMINE_ALL)) + "<br>";
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>";
strHTML += GUIUtil::HtmlEscape(wtx.ToString(), true);
CTxDB txdb("r"); // To fetch source txouts
strHTML += "<br><b>" + tr("Inputs") + ":</b>";
strHTML += "<ul>";
BOOST_FOREACH(const CTxIn& txin, wtx.vin)
{
COutPoint prevout = txin.prevout;
CTransaction prev;
if(txdb.ReadDiskTx(prevout.hash, prev))
{
if (prevout.n < prev.vout.size())
{
strHTML += "<li>";
const CTxOut &vout = prev.vout[prevout.n];
CTxDestination address;
if (ExtractDestination(vout.scriptPubKey, address))
{
if (wallet->mapAddressBook.count(address) && !wallet->mapAddressBook[address].empty())
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[address]) + " ";
strHTML += QString::fromStdString(CcPlayAddress(address).ToString());
}
strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatWithUnit(unit, vout.nValue);
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) & ISMINE_SPENDABLE ? tr("true") : tr("false"));
strHTML = strHTML + " IsWatchOnly=" + (wallet->IsMine(vout) & ISMINE_WATCH_ONLY ? tr("true") : tr("false")) + "</li>";
}
}
}
strHTML += "</ul>";
}
strHTML += "</font></html>";
return strHTML;
}
| [
"aaleksandru@gmail.com"
] | aaleksandru@gmail.com |
8b3dc219f033ca26145df0c83d21b6c2246f0e36 | 9af47b4b5c4839cca7fe35e50ca058fe35a84fc4 | /MFC/day07/day07/MFCData/StdAfx.h | 2d35d755c70baec8bc48642d3c136c8d6296c6a0 | [
"MIT"
] | permissive | presscad/WindowsNotes | 2b765e99eff6b52cef59b7776fe99659bfdbb630 | e18485cd9516bab11c51c66511c40055ae33df23 | refs/heads/master | 2021-03-10T20:30:55.201993 | 2019-03-24T12:15:51 | 2019-03-24T12:15:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,078 | h | // stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__71BE3807_19AB_4A35_B1D2_F18860A9015B__INCLUDED_)
#define AFX_STDAFX_H__71BE3807_19AB_4A35_B1D2_F18860A9015B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afx.h>
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <iostream>
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__71BE3807_19AB_4A35_B1D2_F18860A9015B__INCLUDED_)
| [
"youngqqcn@163.com"
] | youngqqcn@163.com |
a78410b3ce4208e5d06db472514ae134a19573c9 | ca256106b9c952615f954766f2e884fdd9b3e341 | /save/FRISC/FRISCSelectionDAGInfo.h | 75663b58f826a4423cf16b3fec42727767f46d96 | [] | no_license | zjurelinac/CFC | eba850aaad5b2a35a7e32dc5467e79498438bd53 | 036946ddd90a2ca15e2e190606ea5b4cb1da7d7d | refs/heads/master | 2021-09-07T15:48:38.852072 | 2018-02-25T12:06:20 | 2018-02-25T12:06:20 | 111,987,442 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 739 | h | //===-- FRISCSelectionDAGInfo.h - FRISC SelectionDAG Info -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the FRISC subclass for TargetSelectionDAGInfo.
//
//===----------------------------------------------------------------------===//
#ifndef FRISCSELECTIONDAGINFO_H
#define FRISCSELECTIONDAGINFO_H
#include "llvm/Target/TargetSelectionDAGInfo.h"
namespace llvm {
class FRISCSelectionDAGInfo : public TargetSelectionDAGInfo {
public:
~FRISCSelectionDAGInfo();
};
}
#endif | [
"matija.cavrag@fer.hr"
] | matija.cavrag@fer.hr |
85385645977c39e0fa77b7c713b59fbb7caffb09 | 88ae8695987ada722184307301e221e1ba3cc2fa | /third_party/blink/renderer/core/html/forms/file_input_type_test.cc | 981372a91b4453ac113ba7d845109be3ba9a47c0 | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"Apache-2.0",
"MIT"
] | permissive | iridium-browser/iridium-browser | 71d9c5ff76e014e6900b825f67389ab0ccd01329 | 5ee297f53dc7f8e70183031cff62f37b0f19d25f | refs/heads/master | 2023-08-03T16:44:16.844552 | 2023-07-20T15:17:00 | 2023-07-23T16:09:30 | 220,016,632 | 341 | 40 | BSD-3-Clause | 2021-08-13T13:54:45 | 2019-11-06T14:32:31 | null | UTF-8 | C++ | false | false | 17,942 | cc | // Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/core/html/forms/file_input_type.h"
#include "base/run_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/clipboard/data_object.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/fileapi/file_list.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/mock_file_chooser.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/loader/empty_clients.h"
#include "third_party/blink/renderer/core/page/drag_data.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/core/testing/null_execution_context.h"
#include "third_party/blink/renderer/core/testing/wait_for_event.h"
#include "third_party/blink/renderer/platform/file_metadata.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/wtf/date_math.h"
namespace blink {
namespace {
class MockEventListener final : public NativeEventListener {
public:
bool invoked = false;
void Invoke(ExecutionContext*, Event*) override { invoked = true; }
void ClearInvoked() { invoked = false; }
};
class WebKitDirectoryChromeClient : public EmptyChromeClient {
public:
void RegisterPopupOpeningObserver(PopupOpeningObserver*) override {
NOTREACHED() << "RegisterPopupOpeningObserver should not be called.";
}
void UnregisterPopupOpeningObserver(PopupOpeningObserver*) override {
NOTREACHED() << "UnregisterPopupOpeningObserver should not be called.";
}
};
} // namespace
TEST(FileInputTypeTest, createFileList) {
FileChooserFileInfoList files;
// Native file.
files.push_back(CreateFileChooserFileInfoNative("/native/path/native-file",
"display-name"));
// Non-native file.
KURL url("filesystem:http://example.com/isolated/hash/non-native-file");
files.push_back(CreateFileChooserFileInfoFileSystem(
url, base::Time::FromJsTime(1.0 * kMsPerDay + 3), 64));
ScopedNullExecutionContext execution_context;
FileList* list = FileInputType::CreateFileList(
execution_context.GetExecutionContext(), files, base::FilePath());
ASSERT_TRUE(list);
ASSERT_EQ(2u, list->length());
EXPECT_EQ("/native/path/native-file", list->item(0)->GetPath());
EXPECT_EQ("display-name", list->item(0)->name());
EXPECT_TRUE(list->item(0)->FileSystemURL().IsEmpty());
EXPECT_TRUE(list->item(1)->GetPath().empty());
EXPECT_EQ("non-native-file", list->item(1)->name());
EXPECT_EQ(url, list->item(1)->FileSystemURL());
EXPECT_EQ(64u, list->item(1)->size());
EXPECT_EQ(1.0 * kMsPerDay + 3, list->item(1)->lastModified());
}
TEST(FileInputTypeTest, ignoreDroppedNonNativeFiles) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
DataObject* native_file_raw_drag_data = DataObject::Create();
const DragData native_file_drag_data(native_file_raw_drag_data, gfx::PointF(),
gfx::PointF(), kDragOperationCopy);
native_file_drag_data.PlatformData()->Add(
MakeGarbageCollected<File>("/native/path"));
native_file_drag_data.PlatformData()->SetFilesystemId("fileSystemId");
file_input->ReceiveDroppedFiles(&native_file_drag_data);
EXPECT_EQ("fileSystemId", file_input->DroppedFileSystemId());
ASSERT_EQ(1u, file_input->Files()->length());
EXPECT_EQ(String("/native/path"), file_input->Files()->item(0)->GetPath());
DataObject* non_native_file_raw_drag_data = DataObject::Create();
const DragData non_native_file_drag_data(non_native_file_raw_drag_data,
gfx::PointF(), gfx::PointF(),
kDragOperationCopy);
FileMetadata metadata;
metadata.length = 1234;
const KURL url("filesystem:http://example.com/isolated/hash/non-native-file");
non_native_file_drag_data.PlatformData()->Add(File::CreateForFileSystemFile(
url, metadata, File::kIsUserVisible, BlobDataHandle::Create()));
non_native_file_drag_data.PlatformData()->SetFilesystemId("fileSystemId");
file_input->ReceiveDroppedFiles(&non_native_file_drag_data);
// Dropping non-native files should not change the existing files.
EXPECT_EQ("fileSystemId", file_input->DroppedFileSystemId());
ASSERT_EQ(1u, file_input->Files()->length());
EXPECT_EQ(String("/native/path"), file_input->Files()->item(0)->GetPath());
}
TEST(FileInputTypeTest, setFilesFromPaths) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
Vector<String> paths;
paths.push_back("/native/path");
paths.push_back("/native/path2");
file_input->SetFilesFromPaths(paths);
ASSERT_EQ(1u, file_input->Files()->length());
EXPECT_EQ(String("/native/path"), file_input->Files()->item(0)->GetPath());
// Try to upload multiple files without multipleAttr
paths.clear();
paths.push_back("/native/path1");
paths.push_back("/native/path2");
file_input->SetFilesFromPaths(paths);
ASSERT_EQ(1u, file_input->Files()->length());
EXPECT_EQ(String("/native/path1"), file_input->Files()->item(0)->GetPath());
// Try to upload multiple files with multipleAttr
input->SetBooleanAttribute(html_names::kMultipleAttr, true);
paths.clear();
paths.push_back("/native/real/path1");
paths.push_back("/native/real/path2");
file_input->SetFilesFromPaths(paths);
ASSERT_EQ(2u, file_input->Files()->length());
EXPECT_EQ(String("/native/real/path1"),
file_input->Files()->item(0)->GetPath());
EXPECT_EQ(String("/native/real/path2"),
file_input->Files()->item(1)->GetPath());
}
TEST(FileInputTypeTest, DropTouchesNoPopupOpeningObserver) {
auto* chrome_client = MakeGarbageCollected<WebKitDirectoryChromeClient>();
auto page_holder =
std::make_unique<DummyPageHolder>(gfx::Size(), chrome_client);
Document& doc = page_holder->GetDocument();
doc.body()->setInnerHTML("<input type=file webkitdirectory>");
auto& input = *To<HTMLInputElement>(doc.body()->firstChild());
base::RunLoop run_loop;
MockFileChooser chooser(doc.GetFrame()->GetBrowserInterfaceBroker(),
run_loop.QuitClosure());
DragData drag_data(DataObject::Create(), gfx::PointF(), gfx::PointF(),
kDragOperationCopy);
drag_data.PlatformData()->Add(MakeGarbageCollected<File>("/foo/bar"));
input.ReceiveDroppedFiles(&drag_data);
run_loop.Run();
chooser.ResponseOnOpenFileChooser(FileChooserFileInfoList());
// The test passes if WebKitDirectoryChromeClient::
// UnregisterPopupOpeningObserver() was not called.
}
TEST(FileInputTypeTest, BeforePseudoCrash) {
std::unique_ptr<DummyPageHolder> page_holder =
std::make_unique<DummyPageHolder>(gfx::Size(800, 600));
Document& doc = page_holder->GetDocument();
doc.documentElement()->setInnerHTML(R"HTML(
<style>
.c6 {
zoom: 0.01;
}
.c6::first-letter {
position: fixed;
border-style: groove;
}
.c6::before {
content: 'c6';
}
.c7 {
zoom: 0.1;
}
.c7::first-letter {
position: fixed;
border-style: groove;
}
.c7::before {
content: 'c7';
}
</style>
<input type=file class=c6>
<input type=file class=c7>
)HTML");
doc.View()->UpdateAllLifecyclePhasesForTest();
// The test passes if no CHECK failures and no null pointer dereferences.
}
TEST(FileInputTypeTest, ChangeTypeDuringOpeningFileChooser) {
// We use WebViewHelper instead of DummyPageHolder, in order to use
// ChromeClientImpl.
frame_test_helpers::WebViewHelper helper;
helper.Initialize();
LocalFrame* frame = helper.LocalMainFrame()->GetFrame();
Document& doc = *frame->GetDocument();
doc.body()->setInnerHTML("<input type=file>");
auto& input = *To<HTMLInputElement>(doc.body()->firstChild());
base::RunLoop run_loop;
MockFileChooser chooser(frame->GetBrowserInterfaceBroker(),
run_loop.QuitClosure());
// Calls MockFileChooser::OpenFileChooser().
LocalFrame::NotifyUserActivation(
frame, mojom::blink::UserActivationNotificationType::kInteraction);
input.click();
run_loop.Run();
input.setType(input_type_names::kColor);
FileChooserFileInfoList list;
list.push_back(CreateFileChooserFileInfoNative("/path/to/file.txt", ""));
chooser.ResponseOnOpenFileChooser(std::move(list));
// Receiving a FileChooser response should not alter a shadow tree
// for another type.
EXPECT_TRUE(IsA<HTMLElement>(
input.EnsureShadowSubtree()->firstChild()->firstChild()));
}
// Tests selecting same file twice should fire cancel event second time.
TEST(FileInputTypeTest, SetFilesFireCorrectEventsForSameFile) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
auto* listener_change = MakeGarbageCollected<MockEventListener>();
auto* listener_cancel = MakeGarbageCollected<MockEventListener>();
input->addEventListener(event_type_names::kChange, listener_change);
input->addEventListener(event_type_names::kCancel, listener_cancel);
auto reset = [&] {
listener_change->ClearInvoked();
listener_cancel->ClearInvoked();
};
auto* const selection_1 = MakeGarbageCollected<FileList>();
selection_1->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
file_input->SetFilesAndDispatchEvents(selection_1);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
reset();
auto* const selection_2 = MakeGarbageCollected<FileList>();
selection_2->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
file_input->SetFilesAndDispatchEvents(selection_2);
EXPECT_FALSE(listener_change->invoked);
EXPECT_TRUE(listener_cancel->invoked);
}
// Tests selecting same files twice should fire cancel event second time.
TEST(FileInputTypeTest, SetFilesFireCorrectEventsForSameFiles) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
auto* listener_change = MakeGarbageCollected<MockEventListener>();
auto* listener_cancel = MakeGarbageCollected<MockEventListener>();
input->addEventListener(event_type_names::kChange, listener_change);
input->addEventListener(event_type_names::kCancel, listener_cancel);
input->SetBooleanAttribute(html_names::kMultipleAttr, true);
auto reset = [&] {
listener_change->ClearInvoked();
listener_cancel->ClearInvoked();
};
auto* const selection_1 = MakeGarbageCollected<FileList>();
selection_1->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
selection_1->Append(MakeGarbageCollected<File>("/path/to/B.txt"));
file_input->SetFilesAndDispatchEvents(selection_1);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
reset();
auto* const selection_2 = MakeGarbageCollected<FileList>();
selection_2->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
selection_2->Append(MakeGarbageCollected<File>("/path/to/B.txt"));
file_input->SetFilesAndDispatchEvents(selection_2);
EXPECT_FALSE(listener_change->invoked);
EXPECT_TRUE(listener_cancel->invoked);
}
// Tests selecting different file after first selection should fire change
// event.
TEST(FileInputTypeTest, SetFilesFireCorrectEventsForDifferentFile) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
auto* listener_change = MakeGarbageCollected<MockEventListener>();
auto* listener_cancel = MakeGarbageCollected<MockEventListener>();
input->addEventListener(event_type_names::kChange, listener_change);
input->addEventListener(event_type_names::kCancel, listener_cancel);
auto reset = [&] {
listener_change->ClearInvoked();
listener_cancel->ClearInvoked();
};
auto* const selection_1 = MakeGarbageCollected<FileList>();
selection_1->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
file_input->SetFilesAndDispatchEvents(selection_1);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
reset();
auto* const selection_2 = MakeGarbageCollected<FileList>();
selection_2->Append(MakeGarbageCollected<File>("/path/to/B.txt"));
file_input->SetFilesAndDispatchEvents(selection_2);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
}
// Tests selecting different files after first selection should fire change
// event.
TEST(FileInputTypeTest, SetFilesFireCorrectEventsForDifferentFiles) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
auto* listener_change = MakeGarbageCollected<MockEventListener>();
auto* listener_cancel = MakeGarbageCollected<MockEventListener>();
input->addEventListener(event_type_names::kChange, listener_change);
input->addEventListener(event_type_names::kCancel, listener_cancel);
input->SetBooleanAttribute(html_names::kMultipleAttr, true);
auto reset = [&] {
listener_change->ClearInvoked();
listener_cancel->ClearInvoked();
};
auto* const selection_1 = MakeGarbageCollected<FileList>();
selection_1->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
selection_1->Append(MakeGarbageCollected<File>("/path/to/B.txt"));
file_input->SetFilesAndDispatchEvents(selection_1);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
reset();
auto* const selection_2 = MakeGarbageCollected<FileList>();
selection_2->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
file_input->SetFilesAndDispatchEvents(selection_2);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
}
// Tests clearing selection (click cancel in file chooser) after selection
// should fire change event.
TEST(FileInputTypeTest, SetFilesFireCorrectEventsCancelWithSelection) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
auto* listener_change = MakeGarbageCollected<MockEventListener>();
auto* listener_cancel = MakeGarbageCollected<MockEventListener>();
input->addEventListener(event_type_names::kChange, listener_change);
input->addEventListener(event_type_names::kCancel, listener_cancel);
input->SetBooleanAttribute(html_names::kMultipleAttr, true);
auto reset = [&] {
listener_change->ClearInvoked();
listener_cancel->ClearInvoked();
};
auto* const selection_1 = MakeGarbageCollected<FileList>();
selection_1->Append(MakeGarbageCollected<File>("/path/to/A.txt"));
selection_1->Append(MakeGarbageCollected<File>("/path/to/B.txt"));
file_input->SetFilesAndDispatchEvents(selection_1);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
reset();
auto* const selection_2 = MakeGarbageCollected<FileList>();
file_input->SetFilesAndDispatchEvents(selection_2);
EXPECT_TRUE(listener_change->invoked);
EXPECT_FALSE(listener_cancel->invoked);
}
// Tests clearing selection (click cancel in file chooser) without selection
// should fire cancel event.
TEST(FileInputTypeTest, SetFilesFireCorrectEventsCancelWithoutSelection) {
ScopedNullExecutionContext execution_context;
auto* document =
Document::CreateForTest(execution_context.GetExecutionContext());
auto* input =
MakeGarbageCollected<HTMLInputElement>(*document, CreateElementFlags());
InputType* file_input = MakeGarbageCollected<FileInputType>(*input);
auto* listener_change = MakeGarbageCollected<MockEventListener>();
auto* listener_cancel = MakeGarbageCollected<MockEventListener>();
input->addEventListener(event_type_names::kChange, listener_change);
input->addEventListener(event_type_names::kCancel, listener_cancel);
input->SetBooleanAttribute(html_names::kMultipleAttr, true);
auto* const selection = MakeGarbageCollected<FileList>();
file_input->SetFilesAndDispatchEvents(selection);
EXPECT_FALSE(listener_change->invoked);
EXPECT_TRUE(listener_cancel->invoked);
}
} // namespace blink
| [
"jengelh@inai.de"
] | jengelh@inai.de |
7e31c621a84e21e656ffd6b2bea14f08740d8cdc | 11e0f7a97e256930b59506876c274790782a3ee7 | /Source/cppTest13/meshsizActor.h | 5b6970b925b934c1bf5c0e8b1cf97820fd679f24 | [] | no_license | polimeraus/cppTest13 | 2aa79fd8c2040db5cb5324d5ea1113a40d51944d | efca835abb47f3c89afe55bdc74f5420d5d70f60 | refs/heads/master | 2023-02-16T23:58:54.870685 | 2021-01-01T12:44:21 | 2021-01-01T12:44:21 | 290,037,370 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 528 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "meshsizActor.generated.h"
UCLASS()
class CPPTEST13_API AmeshsizActor : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AmeshsizActor();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
| [
"methodologist@msn.com"
] | methodologist@msn.com |
447fd96d88109077d508d9f01566084ddefeaf02 | 58937b58ed9f934ff0156e89890f5d4b77fe537d | /_Common/SkillInfluence.h | 81204bf6fc46dc72947b95a42d3126e38e0e30ee | [] | no_license | HowlTheHusky/SRC | 92a2c624b7547c52e3d5efdcd998878da75f3d8d | a2a04419c319d79748b1b09ee6335d1db89cffdd | refs/heads/master | 2021-06-30T15:31:57.260438 | 2017-09-21T20:10:15 | 2017-09-21T20:10:15 | 103,934,173 | 1 | 0 | null | null | null | null | UHC | C++ | false | false | 5,556 | h | #ifndef __SKILLINFLUENCE_H__
#define __SKILLINFLUENCE_H__
#define BUFF_ITEM 0
#define BUFF_SKILL 1
#define BUFF_PET 2
#define BUFF_ITEM2 3
#define BUFF_EQUIP 4 // 장착류 아이템에 특정 DST(DST_GIFTBOX)에 대해 버프 아이콘만 출력
#define BUFF_NULL_ID (WORD)0xFFFF
#define MAX_SKILLINFLUENCE 64
#define MAX_SKILLBUFF_COUNT 14 //cuvvvie
#ifndef __BUFF_1107
#include "ar.h"
typedef struct tagSKILLINFLUENCE
{
WORD wType; // 0:아이템 1:스킬 2:기타?
WORD wID; // 아이템이나 스킬의 프로퍼티 ID
DWORD dwLevel; // 스킬 레벨 - 저장
DWORD tmCount; // 남은 시간(카운트). - 저장
DWORD tmTime; // 시작 타이머.
BOOL bEffect; // 지속효과이펙트를 가지고 있을때 그것이 로딩됐는지.. FALSE면 로딩해야한다.
#ifdef __PVPDEBUFSKILL
DWORD dwAttackerID; // 스킬 시전자 ID
#endif // __PVPDEBUFSKILL
}
SKILLINFLUENCE, * LPSKILLINFLUENCE;
class CMover;
class CSkillInfluence
{
private:
#if __VER < 8 //__CSC_VER8_3
SKILLINFLUENCE *m_pEmptyNode; // 비어있는 공간의 인덱스.
#endif //__CSC_VER8_3
CMover* m_pMover;
// CRIT_SEC m_AddRemoveLock;
void RemoveSkillInfluence( SKILLINFLUENCE* pSkillInfluence );
public:
// BOOL IsEmpty();
#if !( defined( __CORESERVER ) || defined( __DBSERVER ) )
#ifdef __PVPDEBUFSKILL
BOOL RemoveSkillInfluenceFromID( OBJID dwAttackerID );
#endif // __PVPDEBUFSKILL
BOOL RemoveSkillInfluence( WORD wType, WORD wID );
BOOL RemoveSkillInfluenceState( DWORD dwChrState );
#if __VER >= 11 // __MA_VER11_06 // 확율스킬 효과수정 world,neuz
BOOL RemoveSkillInfluenceDestParam( DWORD dwDestParam );
#endif // __MA_VER11_06 // 확율스킬 효과수정 world,neuz
BOOL RemoveAllSkillInfluence();
BOOL RemoveAllSkillDebuff( void );
BOOL RemoveAllSkillBuff( void );
#if __VER >= 11 // __MA_VER11_05 // 케릭터 봉인 거래 기능 world,database,neuz
BOOL RemoveAllBuff( void );
#endif // __MA_VER11_05 // 케릭터 봉인 거래 기능 world,database,neuz
BOOL RemoveOneSkillBuff( void );
#endif // #if !( defined( __CORESERVER ) || defined( __DBSERVER ) )
// Constructions
CSkillInfluence();
virtual ~CSkillInfluence();
SKILLINFLUENCE m_aSkillInfluence[ MAX_SKILLINFLUENCE ];
LPSKILLINFLUENCE FindPtr( WORD wType, WORD wID );
void Init( void );
void Destroy( void ) {}
void Serialize( CAr & ar );
// Operations
void SetMover( CMover* pMover );
#ifdef __PVPDEBUFSKILL
BOOL Set( WORD wType, WORD wID, DWORD dwLevel, DWORD dwTime, DWORD dwAttackerID = NULL_ID );
BOOL Set( SKILLINFLUENCE *pNode, WORD wType, WORD wID, DWORD dwLevel, DWORD dwTime, DWORD dwAttackerID );
#else // __PVPDEBUFSKILL
BOOL Set( WORD wType, WORD wID, DWORD dwLevel, DWORD dwTime );
BOOL Set( SKILLINFLUENCE *pNode, WORD wType, WORD wID, DWORD dwLevel, DWORD dwTime );
#endif // __PVPDEBUFSKILL
LPSKILLINFLUENCE Get( int nIdx );
#if !( defined( __CORESERVER ) || defined( __DBSERVER ) )
void Process( void );
#endif // #if !( defined( __CORESERVER ) || defined( __DBSERVER ) )
void Reset( void ); // 클라로 버프정보를 다시 갱신하도록 타이머를 클리어 시킴.
BOOL HasSkill( WORD wType, WORD wID );
#if __VER >= 9 // __PET_0410
BOOL HasPet( void ) { return FindPet() != NULL; }
SKILLINFLUENCE * FindPet( void );
BOOL RemovePet( void );
#endif // __PET_0410
#ifdef __CLIENT
DWORD GetDisguise( void );
#endif // __CLIENT
BOOL HasLikeItemBuf( DWORD dwItemKind3 );
void RemoveLikeItemBuf( DWORD dwItemKind3 );
SKILLINFLUENCE *Find( WORD wType, WORD wID );
SKILLINFLUENCE *GetItemBuf( DWORD dwItemKind3 );
private:
// Attributes
void Remove( SKILLINFLUENCE *pNode );
BOOL LikeItemBuf( DWORD dwItemKind3 );
#if __VER >= 8 //__CSC_VER8_3
SKILLINFLUENCE* SortSkillArray();
#ifdef __PVPDEBUFSKILL
BOOL InsertBuff(SKILLINFLUENCE *pNode, WORD wType, WORD wID, DWORD dwLevel, DWORD dwTime, DWORD dwAttackerID);
#else // __PVPDEBUFSKILL
BOOL InsertBuff(SKILLINFLUENCE *pNode, WORD wType, WORD wID, DWORD dwLevel, DWORD dwTime );
#endif // __PVPDEBUFSKILL
#endif //__CSC_VER8_3
};
//
inline void CSkillInfluence::SetMover( CMover* pMover )
{ m_pMover = pMover; }
//
inline SKILLINFLUENCE* CSkillInfluence::Find( WORD wType, WORD wID )
{
int i = MAX_SKILLINFLUENCE;
SKILLINFLUENCE *pList = m_aSkillInfluence, *pNode;
while( i-- )
{
pNode = pList++;
if( pNode->wType == wType && pNode->wID == wID ) // 같은걸 찾음.
return pNode;
}
return NULL;
}
#if __VER >= 9 // __PET_0410
inline SKILLINFLUENCE* CSkillInfluence::FindPet( void )
{
int i = MAX_SKILLINFLUENCE;
SKILLINFLUENCE *pList = m_aSkillInfluence, *pNode;
while( i-- )
{
pNode = pList++;
if( pNode->wType == BUFF_PET )
return pNode;
}
return NULL;
}
#endif // __PET_0410
//
inline BOOL CSkillInfluence::HasSkill( WORD wType, WORD wID )
{
return Find( wType, wID ) != NULL;
}
//
inline LPSKILLINFLUENCE CSkillInfluence::FindPtr( WORD wType, WORD wID )
{
return( Find( wType, wID ) );
}
//
inline LPSKILLINFLUENCE CSkillInfluence::Get( int nIdx )
{
if( nIdx < 0 || nIdx >= MAX_SKILLINFLUENCE )
{
Error( "SKILLINFLUENCE::Get() : 범위를 넘어섬 %d", nIdx );
return( NULL );
}
return( m_aSkillInfluence + nIdx );
}
//
inline void CSkillInfluence::Remove( SKILLINFLUENCE *pNode )
{
pNode->wType = 0;
pNode->wID = 0;
pNode->bEffect = 0;
pNode->tmTime = 0;
pNode->tmCount = 0;
#if __VER < 8 //__CSC_VER8_3
m_pEmptyNode = pNode; // 지운 노드는 비어있으므로 그것을 받아둠.
#endif //__CSC_VER8_3
}
#endif // __BUFF_1107
#endif // __SKILLINFLUENCE_H__ | [
"32062494+HowlTheHusky@users.noreply.github.com"
] | 32062494+HowlTheHusky@users.noreply.github.com |
697da17f7357d02a57552f09b6f73fe0307c77c1 | 468b08d6adbd52857574491f66e390271e5b0b08 | /sun/Endian.h | 3ac44da90000c780080140b00d08353e5f720fd7 | [] | no_license | old-windbell/SunComm | e7922cae7477ca235cefc4743a4c6ad69b71dc84 | 0f5f70736c51006f9457871eae25658fd396dcb8 | refs/heads/master | 2021-05-16T05:08:14.520634 | 2017-10-16T16:50:30 | 2017-10-16T16:50:30 | 106,299,821 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,090 | h | #pragma once
#include "GlobalDef.h"
#include "Types.h"
_SUN_BEGIN
class Endian
{
public:
Endian() = default;
virtual ~Endian() {}
public:
static uint16 swap16(uint16 val) {
return (val << 8 | val >> 8);
}
static uint32 swap32(uint32 val) {
return ((val << 24) | (val >> 24) \
| ((val << 8) & 0x00ff0000) \
| ((val >> 8) & 0x0000ff00));
}
public:
virtual uint16 value16(uint16 val) = 0;
virtual uint32 value32(uint32 val) = 0;
};
class BigEndian : public Endian
{
public:
uint16 value16(uint16 val) override {
#ifdef ARCH_BIG_ENDIAN
return val;
#else
return swap16(val);
#endif // ARCH_BIG_ENDIAN
}
uint32 value32(uint32 val) override {
#ifdef ARCH_BIG_ENDIAN
return val;
#else
return swap32(val);
#endif // ARCH_BIG_ENDIAN
}
};
class LittleEndian : public Endian
{
public:
uint16 value16(uint16 val) override {
#ifdef ARCH_BIG_ENDIAN
return swap16(val);
#else
return val;
#endif // ARCH_BIG_ENDIAN
}
uint32 value32(uint32 val) override {
#ifdef ARCH_BIG_ENDIAN
return swap32(val);
#else
return val;
#endif // ARCH_BIG_ENDIAN
}
};
_SUN_END | [
"616228745@qq.com"
] | 616228745@qq.com |
70441cdc9d703388a9d633467c54f2a0f8a83567 | a3c3c90e0c234cf09ef826601a7d9909d5808fe9 | /OJ_Problem/GCJ2016/B.cpp | 35b767b74846925a88e363a04525842f8ce077db | [] | no_license | luyuncheng/Exercise | 3842248513bef501515504d74a795cd197801460 | db31a7872518c5c1ab8afa80dff736cf03a12561 | refs/heads/master | 2021-01-18T23:43:43.051878 | 2016-11-15T13:22:42 | 2016-11-15T13:22:42 | 54,616,691 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 975 | cpp | ////
//// Created by 鲁蕴铖 on 16/4/9.
////
//
//#include <iostream>
//#include <cstring>
//#include <queue>
//#include <vector>
//using namespace std;
//int main()
//{
////#ifndef ONLINE_JUDGE
// freopen("/Users/luyuncheng/ClionProjects/CPP_lyc/OJ_Problem/GCJ2016/B-large.in", "r", stdin);
// freopen("/Users/luyuncheng/ClionProjects/CPP_lyc/OJ_Problem/GCJ2016/B-large.out", "w", stdout);
////#endif
// int T;
// while(cin>>T) {
// int cas = 0;
// while(T--) {
//
// string str;
// cin>>str;
// int con = 0;
// char pre = str[0];
// int bz = 0;
// for(int i=1;i<str.size();i++) {
// if(str[i] == pre) continue;
// else {
// con ++ ;
// pre = str[i];
// }
// }
// if(pre == '-') con++;
//
// cout << "Case #" << ++cas << ": "<< con << endl;
// }
// }
//} | [
"luyuncheng@sina.com"
] | luyuncheng@sina.com |
e8ffa6f78d1d454bc19d4ee606f440d54cad4e48 | a1cc8e0976f296192b1002e279d66a6a3dada28f | /cv_blobs/src/BlobResult.cc | e88321baa6eb19f5f34ba63fee10e32151dfc643 | [
"MIT"
] | permissive | MRSD2018/reefbot-1 | 40ef435ac4e1664858f225fde1d9ee995d55f235 | a595ca718d0cda277726894a3105815cef000475 | refs/heads/master | 2021-04-09T10:26:25.455651 | 2018-04-01T19:13:43 | 2018-04-01T19:13:43 | 125,381,499 | 0 | 0 | MIT | 2018-04-01T15:24:29 | 2018-03-15T14:41:59 | C++ | UTF-8 | C++ | false | false | 3,013 | cc | // Copyright 2011 ReefBot
// Author: Mark Desnoyer (mdesnoyer@gmail.com)
//
// BlobResult.cpp
//
// Stores a set of results for a blob detection algorithm
#include "cv_blobs/BlobResult-Inline.h"
#include <assert.h>
namespace cv_blobs {
void FindBlobsFromPoints(STD_NAMESPACE::hash_set<Point2i>* points,
std::vector<boost::shared_ptr<Blob> >* output,
Blob::ConnectionType connectionType,
int nRows,
int nCols) {
assert(points && output);
// Build up the blobs one by one
Rect frameBounds(0, 0, nCols, nRows);
int curId = 0;
stack<Point2i> curStack;
Blob* curBlob = NULL;
while (!points->empty()) {
// See if we need to create a new blob
if (curStack.empty()) {
// Create a new blob
curBlob = new Blob(curId++, connectionType);
output->push_back(boost::shared_ptr<Blob>(curBlob));
// Add the next point to the stack
curStack.push(*points->begin());
}
// Take a point off the top of the stack and add it to the current blob
const Point2i curElem = curStack.top();
curStack.pop();
STD_NAMESPACE::hash_set<Point2i>::iterator unusedIter =
points->find(curElem);
if (unusedIter != points->end() && curBlob->AddPoint(curElem)) {
GetConnectedPoints(&curStack, frameBounds, curElem, connectionType);
}
points->erase(unusedIter);
}
}
// Pushes any connected points that aren't in the blob onto the top
// of the stack.
//
// Inputs:
// stack - The stack to add points to
// frameBounds - Image bounds
// curPoint - The point around which to add adjacent ones to
void GetConnectedPoints(stack<Point2i>* stack,
const Rect& frameBounds,
const Point2i& curPoint,
Blob::ConnectionType connectionType) {
assert(stack);
if (connectionType == Blob::EIGHT_CONNECTED) {
// Add the diagonals
AddSafeConnected(stack, frameBounds,
Point2i(curPoint.x - 1, curPoint.y - 1));
AddSafeConnected(stack, frameBounds,
Point2i(curPoint.x - 1, curPoint.y + 1));
AddSafeConnected(stack, frameBounds,
Point2i(curPoint.x + 1, curPoint.y - 1));
AddSafeConnected(stack, frameBounds,
Point2i(curPoint.x + 1, curPoint.y + 1));
}
// Add the adjacent pixels
AddSafeConnected(stack, frameBounds, Point2i(curPoint.x - 1, curPoint.y));
AddSafeConnected(stack, frameBounds, Point2i(curPoint.x + 1, curPoint.y));
AddSafeConnected(stack, frameBounds, Point2i(curPoint.x, curPoint.y - 1));
AddSafeConnected(stack, frameBounds, Point2i(curPoint.x, curPoint.y + 1));
}
// Adds a point to the stack if it could be inside the frame.
void AddSafeConnected(stack<cv::Point2i>* stack,
const Rect& frameBounds,
const cv::Point2i& point) {
if (frameBounds.contains(point)) {
stack->push(point);
}
}
} // namespace
| [
"mdesnoyer@gmail.com"
] | mdesnoyer@gmail.com |
8e90fca4622b2baba4c73eed1d1b56e03a5eb265 | 922c59257258455c8436630b116659b868bcbb29 | /algo/Functions/function2/CONVERSION/decimalToBinary.cpp | 21e010d8f563464d056c86f7e1f5870775ce0db5 | [] | no_license | iamsubratabiswas/importantcplusplus | 50bdd4eb9538f02700ae834f12c629700968571d | aa4155cde90395981bcc4082b805ce83955f68ef | refs/heads/master | 2023-06-20T12:42:41.883082 | 2021-07-23T05:55:57 | 2021-07-23T05:55:57 | 384,930,749 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 775 | cpp | #include<bits/stdc++.h>
using namespace std;
int decimalToBinary(int n){ //suppose n=12
int ans=0;
int x=1;
while(x<=n){
x*=2; //x=16
}
x/=2; //x=8
while(x>0){ // Step1 //next //next //next
int quotient=n/x; // 12/8 = 1 4/4=1 0 0
n-=quotient*x; // n=12-1*8 =4 4-4=0 0 0
x/=2; // x = 8/2 =4 x=2 1 0
ans =ans*10 + quotient; //ans=0+1=1 1*10 + 1=11 11*10=110 1100
}
return ans;
}
int32_t main()
{
int n;
cin>>n;
cout<<decimalToBinary(n);
} | [
"86493733+iamsubratabiswas@users.noreply.github.com"
] | 86493733+iamsubratabiswas@users.noreply.github.com |
f05f560c3935fcd3ea27c552e2ce747e913c9726 | 2b5f3f4b7e75233965b476879bbb092ab16bb9e6 | /OOP/Templates/Case_Project_1.5/main.cpp | 88350f99d891c74c5d85e7b06bf66ffb4ef44069 | [] | no_license | ViktorTsekov/CPP | 1d61b8b645012b362f8c6b0213961ee18049c034 | 31463d6e78b0487f6e114c4ef18f9b79dcc8064f | refs/heads/master | 2023-05-17T22:29:29.355214 | 2021-06-06T23:08:38 | 2021-06-06T23:08:38 | 331,327,352 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 542 | cpp | #include "MathProblemTemplate.h"
#include "Fraction.h"
int main() {
Fraction fracA(2, 3, 2);
Fraction fracB(4, 5, 8);
MathProblemTemplate<int> integerProblem;
MathProblemTemplate<double> doubleProblem;
MathProblemTemplate<Fraction> fractionProblem;
integerProblem.setProblem(5, '+', 4);
integerProblem.displayProblem();
doubleProblem.setProblem(5.2, '-', 5.4);
doubleProblem.displayProblem();
fractionProblem.setProblem(fracA, '-', fracB);
fractionProblem.displayProblem();
return 0;
} | [
"gy001040@student.reading.ac.uk"
] | gy001040@student.reading.ac.uk |
88e9bd53ce66dc6b8a611c1fda650937fb21e94c | 6809b41d5a01ccf11a57a87c84b208f63ecffc0e | /Practice/Miscellaneous/redblacktrees.cpp | 06723755b7e56533c5edd29c560dad8e6e4fce54 | [] | no_license | dalalsunil1986/InterviewPrep-CP | 59d0a5605d4061eb0b7fda5d255b44c978d7e70a | bb920c22abbc0167a097b8540e612c3b937b9874 | refs/heads/master | 2023-03-09T21:33:28.692151 | 2021-02-21T03:37:05 | 2021-02-21T03:37:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,966 | cpp | #include <iostream>
#include <queue>
using namespace std;
class Node {
public:
int val;
char color;
Node *left, *right, *parent;
Node(int val) : val(val) {
parent = left = right = NULL;
color = 'R';
}
Node *uncle() {
if (parent == NULL or parent->parent == NULL)
return NULL;
if (parent->isOnLeft())
return parent->parent->right;
else
return parent->parent->left;
}
bool isOnLeft() { return this == parent->left; }
Node *sibling() {
if (parent == NULL)
return NULL;
if (isOnLeft())
return parent->right;
return parent->left;
}
void moveDown(Node *nParent) {
if (parent != NULL) {
if (isOnLeft()) {
parent->left = nParent;
} else {
parent->right = nParent;
}
}
nParent->parent = parent;
parent = nParent;
}
bool hasRedChild() {
return (left != NULL and left->color == 'R') or
(right != NULL and right->color == 'R');
}
};
class RBTree {
Node *root;
void leftRotate(Node *x) {
Node *nParent = x->right;
if (x == root)
root = nParent;
x->moveDown(nParent);
x->right = nParent->left;
if (nParent->left != NULL)
nParent->left->parent = x;
nParent->left = x;
}
void rightRotate(Node *x) {
Node *nParent = x->left;
// update root if current node is root
if (x == root)
root = nParent;
x->moveDown(nParent);
x->left = nParent->right;
if (nParent->right != NULL)
nParent->right->parent = x;
nParent->right = x;
}
void swapColors(Node *x1, Node *x2) {
char temp;
temp = x1->color;
x1->color = x2->color;
x2->color = temp;
}
void swapValues(Node *u, Node *v) {
int temp;
temp = u->val;
u->val = v->val;
v->val = temp;
}
void fixRedRed(Node *x) {
if (x == root) {
x->color = 'B';
return;
}
Node *parent = x->parent, *grandparent = parent->parent,
*uncle = x->uncle();
if (parent->color != 'B') {
if (uncle != NULL && uncle->color == 'R') {
parent->color = 'B';
uncle->color = 'B';
grandparent->color = 'R';
fixRedRed(grandparent);
} else {
if (parent->isOnLeft()) {
if (x->isOnLeft()) {
swapColors(parent, grandparent);
} else {
leftRotate(parent);
swapColors(x, grandparent);
}
// for left left and left right
rightRotate(grandparent);
} else {
if (x->isOnLeft()) {
// for right left
rightRotate(parent);
swapColors(x, grandparent);
} else {
swapColors(parent, grandparent);
}
// for right right and right left
leftRotate(grandparent);
}
}
}
}
// find node that do not have a left child
// in the subtree of the given node
Node *successor(Node *x) {
Node *temp = x;
while (temp->left != NULL)
temp = temp->left;
return temp;
}
// find node that replaces a deleted node in BST
Node *BSTreplace(Node *x) {
// when node have 2 children
if (x->left != NULL and x->right != NULL)
return successor(x->right);
// when leaf
if (x->left == NULL and x->right == NULL)
return NULL;
// when single child
if (x->left != NULL)
return x->left;
else
return x->right;
}
// deletes the given node
void deleteNode(Node *v) {
Node *u = BSTreplace(v);
// True when u and v are both black
bool uvBlack = ((u == NULL or u->color == 'B') and (v->color == 'B'));
Node *parent = v->parent;
if (u == NULL) {
// u is NULL therefore v is leaf
if (v == root) {
// v is root, making root null
root = NULL;
} else {
if (uvBlack) {
// u and v both black
// v is leaf, fix double black at v
fixDoubleBlack(v);
} else {
// u or v is red
if (v->sibling() != NULL)
// sibling is not null, make it red"
v->sibling()->color = 'R';
}
// delete v from the tree
if (v->isOnLeft()) {
parent->left = NULL;
} else {
parent->right = NULL;
}
}
delete v;
return;
}
if (v->left == NULL or v->right == NULL) {
// v has 1 child
if (v == root) {
// v is root, assign the value of u to v, and delete u
v->val = u->val;
v->left = v->right = NULL;
delete u;
} else {
// Detach v from tree and move u up
if (v->isOnLeft()) {
parent->left = u;
} else {
parent->right = u;
}
delete v;
u->parent = parent;
if (uvBlack) {
// u and v both black, fix double black at u
fixDoubleBlack(u);
} else {
// u or v red, color u black
u->color = 'B';
}
}
return;
}
// v has 2 children, swap values with successor and recurse
swapValues(u, v);
deleteNode(u);
}
void fixDoubleBlack(Node *x) {
if (x == root)
// Reached root
return;
Node *sibling = x->sibling(), *parent = x->parent;
if (sibling == NULL) {
// No sibiling, double black pushed up
fixDoubleBlack(parent);
} else {
if (sibling->color == 'R') {
// Sibling red
parent->color = 'R';
sibling->color = 'B';
if (sibling->isOnLeft()) {
// left case
rightRotate(parent);
} else {
// right case
leftRotate(parent);
}
fixDoubleBlack(x);
} else {
// Sibling black
if (sibling->hasRedChild()) {
// at least 1 red children
if (sibling->left != NULL and sibling->left->color == 'R') {
if (sibling->isOnLeft()) {
// left left
sibling->left->color = sibling->color;
sibling->color = parent->color;
rightRotate(parent);
} else {
// right left
sibling->left->color = parent->color;
rightRotate(sibling);
leftRotate(parent);
}
} else {
if (sibling->isOnLeft()) {
// left right
sibling->right->color = parent->color;
leftRotate(sibling);
rightRotate(parent);
} else {
// right right
sibling->right->color = sibling->color;
sibling->color = parent->color;
leftRotate(parent);
}
}
parent->color = 'B';
} else {
// 2 black children
sibling->color = 'R';
if (parent->color == 'B')
fixDoubleBlack(parent);
else
parent->color = 'B';
}
}
}
}
// prints inorder recursively
void inorder(Node *x) {
if (x == NULL)
return;
inorder(x->left);
cout << x->val << " "<<x->color<<" ";
inorder(x->right);
}
void preorder(Node *x) {
if (x == NULL)
return;
cout << x->val << " "<<x->color<<" ";
preorder(x->left);
preorder(x->right);
}
void postorder(Node *x) {
if (x == NULL)
return;
postorder(x->left);
postorder(x->right);
cout << x->val << " "<<x->color<<" ";
}
public:
// constructor
// initialize root
RBTree() { root = NULL; }
Node *getRoot() { return root; }
// searches for given value
// if found returns the node (used for delete)
// else returns the last node while traversing (used in insert)
Node *search(int n) {
Node *temp = root;
while (temp != NULL) {
if (n < temp->val) {
if (temp->left == NULL)
break;
else
temp = temp->left;
} else if (n == temp->val) {
break;
} else {
if (temp->right == NULL)
break;
else
temp = temp->right;
}
}
return temp;
}
// inserts the given value to tree
void insert(int n) {
Node *newNode = new Node(n);
if (root == NULL) {
// when root is null
// simply insert value at root
newNode->color = 'B';
root = newNode;
} else {
Node *temp = search(n);
if (temp->val == n) {
// return if value already exists
return;
}
// if value is not found, search returns the node
// where the value is to be inserted
// connect new node to correct node
newNode->parent = temp;
if (n < temp->val)
temp->left = newNode;
else
temp->right = newNode;
// fix red red voilaton if exists
fixRedRed(newNode);
}
}
// utility function that deletes the node with given value
void deleteByVal(int n) {
if (root == NULL)
// Tree is empty
return;
Node *v = search(n), *u;
if (v->val != n) {
cout << "No node found to delete with value:" << n << endl;
return;
}
deleteNode(v);
}
// prints inorder of the tree
void printInOrder() {
if (root == NULL)
cout << "Tree is empty" << endl;
else
inorder(root);
cout << endl;
}
void printPostOrder() {
if (root == NULL)
cout << "Tree is empty" << endl;
else
postorder(root);
cout << endl;
}
void printPreOrder() {
if (root == NULL)
cout << "Tree is empty" << endl;
else
preorder(root);
cout << endl;
}
};
int main() {
int t;
cin>>t;
RBTree tree;
char q;
int x;
while(t--)
{
cin>>q>>x;
if(q=='i')
tree.insert(x);
else if(q=='d')
tree.deleteByVal(x);
}
tree.printPreOrder();
tree.printInOrder();
tree.printPostOrder();
return 0;
}
| [
"abhishekmaira1999@gmail.com"
] | abhishekmaira1999@gmail.com |
26174dd1f6d50db4301e2fe83e5a7e2de0eb731b | 393320d4dc9463ae7047390e4afe6f3e25fd70b9 | /tek3/C++/cpp_rtype/shared/rnetwork_extended/packet/UDPHostPacket.cpp | e04dffc5bacfb6426e5c16e1fe3397d1d534ab7c | [] | no_license | Lime5005/epitech-1 | d1c4f3739716173c8083ea4e6a04260d6dc92775 | cb25df1fa5d540624b9e7fd58de6e458cd5cc250 | refs/heads/master | 2023-02-09T07:38:57.850357 | 2019-10-14T15:03:44 | 2019-10-14T15:03:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,648 | cpp | #include <cstring>
#include "UDPHostPacket.hpp"
#include "Opcodes.hpp"
rnetwork::packet::UDPHostPacket::UDPHostPacket() :
PacketBase(op::UdpHostPacket, this->Size),
_endpoint("0.0.0.0", 00)
{
updatePacket();
}
rnetwork::packet::UDPHostPacket::UDPHostPacket(const rnetwork::Endpoint &endpoint) :
PacketBase(op::UdpHostPacket, this->Size),
_endpoint(endpoint)
{
updatePacket();
}
void rnetwork::packet::UDPHostPacket::setEndpoint(const rnetwork::Endpoint &endpoint) {
_endpoint = endpoint;
updatePacket();
}
const rnetwork::Endpoint &rnetwork::packet::UDPHostPacket::getEndpoint() const {
return _endpoint;
}
void rnetwork::packet::UDPHostPacket::updatePacket() {
uint16_t *port;
unsigned long length = 2 + _endpoint.host().length();
delete[] _raw;
_raw = new unsigned char[length + HEADER_SIZE];
_size = length + HEADER_SIZE;
port = reinterpret_cast<uint16_t *>(&_raw[HEADER_SIZE]);
setOp(op::UdpHostPacket);
setLength(static_cast<uint16_t>(length));
*port = ntohs(_endpoint.port());
std::memcpy(&_raw[HEADER_SIZE + 2], _endpoint.host().c_str(), _endpoint.host().length());
}
std::string rnetwork::packet::UDPHostPacket::getRawHost() const {
return std::move(std::string(reinterpret_cast<char *>(&_raw[HEADER_SIZE + 2]), getLength() - 2));
}
uint16_t rnetwork::packet::UDPHostPacket::getRawPort() const {
return ntohs(*reinterpret_cast<uint16_t *>(&_raw[HEADER_SIZE]));
}
rnetwork::packet::UDPHostPacket::UDPHostPacket(const rnetwork::packet::PacketBase &base) :
PacketBase(base),
_endpoint(getRawHost(), getRawPort())
{
}
| [
"gauthier.cler@epitech.eu"
] | gauthier.cler@epitech.eu |
d955d4bde1f56115cc1cd68d0bfe3acec3bb075a | e398a585764f16511a70d0ef33a3b61da0733b69 | /7600.16385.1/src/print/XPSDrvSmpl/src/filters/common/xdrchflt.cpp | e337db46905f062487731946f4ecd970e67bb5d9 | [
"MIT"
] | permissive | MichaelDavidGK/WinDDK | f9e4fc6872741ee742f8eace04b2b3a30b049495 | eea187e357d61569e67292ff705550887c4df908 | refs/heads/master | 2020-05-30T12:26:40.125588 | 2019-06-01T13:28:10 | 2019-06-01T13:28:10 | 189,732,991 | 0 | 0 | null | 2019-06-01T12:58:11 | 2019-06-01T12:58:11 | null | UTF-8 | C++ | false | false | 9,667 | cpp | /*++
Copyright (c) 2005 Microsoft Corporation
All rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
File Name:
xdrchflt.cpp
Abstract:
Base Xps filter implementation. The CXDXpsFilter provides common filter
functionality for Xps filters. It provides default handlers for part
handlers that set print tickets appropriately through the PrintTicket
manager class. This allows derived classes to implement only the part
handlers that they require (for example, the watermark filter is only
interested in the fixed page, and leaves all other parts to be handled
by this class). The class implements IPrintPipelineFilter::StartOperation
which is responsible for retrieving parts from the Xps provider and
dispatching them to the relevant part handler. It is also responsible for
intialising the Xps provider and consumer.
--*/
#include "precomp.h"
#include "debug.h"
#include "globals.h"
#include "xdrchflt.h"
/*++
Routine Name:
CXDXpsFilter::CXDXpsFilter
Routine Description:
CXDXpsFilter class constructor
Arguments:
None
Return Value:
None
--*/
CXDXpsFilter::CXDXpsFilter() :
m_pXDReader(NULL),
m_pXDWriter(NULL)
{
VERBOSE("Constructing Xps filter\n");
}
/*++
Routine Name:
CXDXpsFilter::~CXDXpsFilter
Routine Description:
CXDXpsFilter class destructor
Arguments:
None
Return Value:
None
--*/
CXDXpsFilter::~CXDXpsFilter()
{
VERBOSE("Destroying Xps filter\n");
}
/*++
Routine Name:
CXDXpsFilter::StartOperation
Routine Description:
This is the XPS Doxument interface implementation of IPrintPipelineFilter::StartOperation
shared by all XPS Document filters
Arguments:
None
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CXDXpsFilter::StartOperation(
VOID
)
{
VERBOSE("Starting filter operation.\n");
HRESULT hr = S_OK;
if (SUCCEEDED(hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) &&
SUCCEEDED(hr = InitialiseXDIO()) &&
SUCCEEDED(hr = InitializePrintTicketManager()))
{
CComPtr<IUnknown> pUnk(NULL);
while (SUCCEEDED(hr) &&
SUCCEEDED(hr = m_pXDReader->GetXpsPart(&pUnk)) &&
pUnk != NULL &&
!m_bFilterFinished)
{
CComPtr<IXpsDocument> pXD(NULL);
CComPtr<IFixedDocumentSequence> pFDS(NULL);
CComPtr<IFixedDocument> pFD(NULL);
CComPtr<IFixedPage> pFP(NULL);
//
// Query interface to find the part type and pass to the
// appropriate part handler
//
if (SUCCEEDED(pUnk.QueryInterface(&pXD)))
{
hr = ProcessPart(pXD);
}
else if (SUCCEEDED(pUnk.QueryInterface(&pFDS)))
{
hr = ProcessPart(pFDS);
}
else if (SUCCEEDED(pUnk.QueryInterface(&pFD)))
{
hr = ProcessPart(pFD);
}
else if (SUCCEEDED(pUnk.QueryInterface(&pFP)))
{
hr = ProcessPart(pFP);
}
else
{
//
// Unrecognised part - send as unknown.
//
hr = m_pXDWriter->SendXpsUnknown(pUnk);
}
//
// Must call release since pUnk is declared outside of the while loop
//
pUnk.Release();
}
if (SUCCEEDED(hr))
{
//
// Call finalize letting derived classes know we have
// processed all parts
//
hr = Finalize();
}
//
// Close the xps package consumer
//
m_pXDWriter->CloseSender();
}
//
// If the filter failed make sure we shutdown the pipeline
//
if (FAILED(hr))
{
if (m_bFilterFinished)
{
//
// Filter is already closing down so report S_OK
//
hr = S_OK;
}
else
{
//
// Request the pipeline manager shutdown the filter
//
ERR("Requesting filter shutdown\n");
RequestShutdown(hr);
}
}
//
// Let the filter pipe manager know the filter is finished
//
CoUninitialize();
FilterFinished();
ERR_ON_HR(hr);
return hr;
}
/*++
Routine Name:
CXDXpsFilter::ProcessPart
Routine Description:
This routine is the default XPS document part handler
Arguments:
pXD - Pointer to the IXPSDocument interface
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CXDXpsFilter::ProcessPart(
__inout IXpsDocument* pXD
)
{
VERBOSE("Processing XPS Document part with default handler\n");
HRESULT hr = S_OK;
if (SUCCEEDED(hr = CHECK_POINTER(pXD, E_POINTER)))
{
hr = m_pXDWriter->SendXpsDocument(pXD);
}
ERR_ON_HR(hr);
return hr;
}
/*++
Routine Name:
CXDXpsFilter::ProcessPart
Routine Description:
This routine is the default fixed document sequence part handler
Arguments:
pFDS - Pointer to the IFixedDocumentSequence interface
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CXDXpsFilter::ProcessPart(
__inout IFixedDocumentSequence* pFDS
)
{
VERBOSE("Processing Fixed Document Sequence part with default handler\n");
HRESULT hr = S_OK;
if (SUCCEEDED(hr = CHECK_POINTER(pFDS, E_POINTER)))
{
//
// Default handler: Set the PT and send the doc sequence
//
if (SUCCEEDED(hr = m_ptManager.SetTicket(pFDS)))
{
hr = m_pXDWriter->SendFixedDocumentSequence(pFDS);
}
}
ERR_ON_HR(hr);
return hr;
}
/*++
Routine Name:
CXDXpsFilter::ProcessPart
Routine Description:
This routine is the default fixed document part handler
Arguments:
pFD - Pointer to the IFixedDocument interface
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CXDXpsFilter::ProcessPart(
__inout IFixedDocument* pFD
)
{
VERBOSE("Processing Fixed Document part with default handler\n");
HRESULT hr = S_OK;
if (SUCCEEDED(hr = CHECK_POINTER(pFD, E_POINTER)))
{
//
// Default handler: Set the PT and send the doc
//
if (SUCCEEDED(hr = m_ptManager.SetTicket(pFD)))
{
hr = m_pXDWriter->SendFixedDocument(pFD);
}
}
ERR_ON_HR(hr);
return hr;
}
/*++
Routine Name:
CXDXpsFilter::ProcessPart
Routine Description:
This routine is the default fixed page handler
Arguments:
pFP - Pointer to the IFixedPage interface
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CXDXpsFilter::ProcessPart(
__inout IFixedPage* pFP
)
{
VERBOSE("Processing Fixed Page part with default handler\n");
HRESULT hr = S_OK;
if (SUCCEEDED(hr = CHECK_POINTER(pFP, E_POINTER)))
{
//
// Default handler: No ticket required, just send the page
//
hr = m_pXDWriter->SendFixedPage(pFP);
}
ERR_ON_HR(hr);
return hr;
}
/*++
Routine Name:
CXDXpsFilter::Finalize
Routine Description:
This method is the default finalize method called when all parts in the XPS document
have been processed
Arguments:
None
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CXDXpsFilter::Finalize(
VOID
)
{
return S_OK;
}
/*++
Routine Name:
CXDXpsFilter::InitialiseXDIO
Routine Description:
This routine initialises the XPS producer and consumer interfaces used by
all XPS document filters
Arguments:
None
Return Value:
HRESULT
S_OK - On success
E_* - On error
--*/
HRESULT
CXDXpsFilter::InitialiseXDIO(
VOID
)
{
VERBOSE("Retrieving Xps producer and consumer.\n");
HRESULT hr = S_OK;
//
// Ensure the produver and consumer are released
//
m_pXDReader = NULL;
m_pXDWriter = NULL;
if (SUCCEEDED(hr = CHECK_POINTER(m_pInterFltrComm, E_PENDING)))
{
//
// Get the producer and consumer from the filter communicator
//
if (SUCCEEDED(hr = m_pInterFltrComm->RequestReader(reinterpret_cast<VOID**>(&m_pXDReader))))
{
hr = m_pInterFltrComm->RequestWriter(reinterpret_cast<VOID**>(&m_pXDWriter));
}
//
// If anything went wrong, ensure the produver and consumer are released
//
if (FAILED(hr))
{
m_pXDReader = NULL;
m_pXDWriter = NULL;
}
}
//
// Check interface is as expected. If not then it is likely that
// the wrong GUID has been defined in the filter configuration file
//
if (SUCCEEDED(hr))
{
CComPtr<IXpsDocumentProvider> pReaderCheck(NULL);
CComPtr<IXpsDocumentConsumer> pWriterCheck(NULL);
if (FAILED(m_pXDReader.QueryInterface(&pReaderCheck)) ||
FAILED(m_pXDWriter.QueryInterface(&pWriterCheck)))
{
RIP("Invalid reader and writer defined - check GUIDs in the filter configuration file\n");
//
// Request the pipeline manager shutsdown the filter
//
hr = E_FAIL;
RequestShutdown(hr);
}
}
ERR_ON_HR(hr);
return hr;
}
| [
"blindtiger@foxmail.com"
] | blindtiger@foxmail.com |
8da70f92446bcf2d133fb6ecc6cdf4e1b595574f | e73e42006c9e2833bf20447e1caf25a4903416c1 | /data-logger/src/alglib/alglibmisc.h | 1b6c53c1ea00891299dc02ade6497a8ceef87ae2 | [
"Apache-2.0"
] | permissive | dummyaccount123457/deepracing | bf099e3f98e7f1e4c287b393a6e24e473c8e9599 | cd70a0252b5cbfd1c45afc13f2eb774fa0aad1fe | refs/heads/master | 2020-04-18T05:13:25.467017 | 2019-01-23T23:09:48 | 2019-01-23T23:09:48 | 167,270,698 | 0 | 0 | Apache-2.0 | 2019-01-23T23:36:57 | 2019-01-23T23:36:57 | null | UTF-8 | C++ | false | false | 74,386 | h | /*************************************************************************
ALGLIB 3.13.0 (source code generated 2017-12-29)
Copyright (c) Sergey Bochkanov (ALGLIB project).
>>> SOURCE LICENSE >>>
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 (www.fsf.org); 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.
A copy of the GNU General Public License is available at
http://www.fsf.org/licensing/licenses
>>> END OF LICENSE >>>
*************************************************************************/
#ifndef _alglibmisc_pkg_h
#define _alglibmisc_pkg_h
#include "ap.h"
#include "alglibinternal.h"
/////////////////////////////////////////////////////////////////////////
//
// THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (DATATYPES)
//
/////////////////////////////////////////////////////////////////////////
namespace alglib_impl
{
#if defined(AE_COMPILE_NEARESTNEIGHBOR) || !defined(AE_PARTIAL_BUILD)
typedef struct
{
ae_vector x;
ae_vector boxmin;
ae_vector boxmax;
ae_int_t kneeded;
double rneeded;
ae_bool selfmatch;
double approxf;
ae_int_t kcur;
ae_vector idx;
ae_vector r;
ae_vector buf;
ae_vector curboxmin;
ae_vector curboxmax;
double curdist;
} kdtreerequestbuffer;
typedef struct
{
ae_int_t n;
ae_int_t nx;
ae_int_t ny;
ae_int_t normtype;
ae_matrix xy;
ae_vector tags;
ae_vector boxmin;
ae_vector boxmax;
ae_vector nodes;
ae_vector splits;
kdtreerequestbuffer innerbuf;
ae_int_t debugcounter;
} kdtree;
#endif
#if defined(AE_COMPILE_HQRND) || !defined(AE_PARTIAL_BUILD)
typedef struct
{
ae_int_t s1;
ae_int_t s2;
ae_int_t magicv;
} hqrndstate;
#endif
#if defined(AE_COMPILE_XDEBUG) || !defined(AE_PARTIAL_BUILD)
typedef struct
{
ae_int_t i;
ae_complex c;
ae_vector a;
} xdebugrecord1;
#endif
}
/////////////////////////////////////////////////////////////////////////
//
// THIS SECTION CONTAINS C++ INTERFACE
//
/////////////////////////////////////////////////////////////////////////
namespace alglib
{
#if defined(AE_COMPILE_NEARESTNEIGHBOR) || !defined(AE_PARTIAL_BUILD)
/*************************************************************************
Buffer object which is used to perform nearest neighbor requests in the
multithreaded mode (multiple threads working with same KD-tree object).
This object should be created with KDTreeCreateBuffer().
*************************************************************************/
class _kdtreerequestbuffer_owner
{
public:
_kdtreerequestbuffer_owner();
_kdtreerequestbuffer_owner(const _kdtreerequestbuffer_owner &rhs);
_kdtreerequestbuffer_owner& operator=(const _kdtreerequestbuffer_owner &rhs);
virtual ~_kdtreerequestbuffer_owner();
alglib_impl::kdtreerequestbuffer* c_ptr();
alglib_impl::kdtreerequestbuffer* c_ptr() const;
protected:
alglib_impl::kdtreerequestbuffer *p_struct;
};
class kdtreerequestbuffer : public _kdtreerequestbuffer_owner
{
public:
kdtreerequestbuffer();
kdtreerequestbuffer(const kdtreerequestbuffer &rhs);
kdtreerequestbuffer& operator=(const kdtreerequestbuffer &rhs);
virtual ~kdtreerequestbuffer();
};
/*************************************************************************
KD-tree object.
*************************************************************************/
class _kdtree_owner
{
public:
_kdtree_owner();
_kdtree_owner(const _kdtree_owner &rhs);
_kdtree_owner& operator=(const _kdtree_owner &rhs);
virtual ~_kdtree_owner();
alglib_impl::kdtree* c_ptr();
alglib_impl::kdtree* c_ptr() const;
protected:
alglib_impl::kdtree *p_struct;
};
class kdtree : public _kdtree_owner
{
public:
kdtree();
kdtree(const kdtree &rhs);
kdtree& operator=(const kdtree &rhs);
virtual ~kdtree();
};
#endif
#if defined(AE_COMPILE_HQRND) || !defined(AE_PARTIAL_BUILD)
/*************************************************************************
Portable high quality random number generator state.
Initialized with HQRNDRandomize() or HQRNDSeed().
Fields:
S1, S2 - seed values
V - precomputed value
MagicV - 'magic' value used to determine whether State structure
was correctly initialized.
*************************************************************************/
class _hqrndstate_owner
{
public:
_hqrndstate_owner();
_hqrndstate_owner(const _hqrndstate_owner &rhs);
_hqrndstate_owner& operator=(const _hqrndstate_owner &rhs);
virtual ~_hqrndstate_owner();
alglib_impl::hqrndstate* c_ptr();
alglib_impl::hqrndstate* c_ptr() const;
protected:
alglib_impl::hqrndstate *p_struct;
};
class hqrndstate : public _hqrndstate_owner
{
public:
hqrndstate();
hqrndstate(const hqrndstate &rhs);
hqrndstate& operator=(const hqrndstate &rhs);
virtual ~hqrndstate();
};
#endif
#if defined(AE_COMPILE_XDEBUG) || !defined(AE_PARTIAL_BUILD)
/*************************************************************************
*************************************************************************/
class _xdebugrecord1_owner
{
public:
_xdebugrecord1_owner();
_xdebugrecord1_owner(const _xdebugrecord1_owner &rhs);
_xdebugrecord1_owner& operator=(const _xdebugrecord1_owner &rhs);
virtual ~_xdebugrecord1_owner();
alglib_impl::xdebugrecord1* c_ptr();
alglib_impl::xdebugrecord1* c_ptr() const;
protected:
alglib_impl::xdebugrecord1 *p_struct;
};
class xdebugrecord1 : public _xdebugrecord1_owner
{
public:
xdebugrecord1();
xdebugrecord1(const xdebugrecord1 &rhs);
xdebugrecord1& operator=(const xdebugrecord1 &rhs);
virtual ~xdebugrecord1();
ae_int_t &i;
alglib::complex &c;
real_1d_array a;
};
#endif
#if defined(AE_COMPILE_NEARESTNEIGHBOR) || !defined(AE_PARTIAL_BUILD)
/*************************************************************************
This function serializes data structure to string.
Important properties of s_out:
* it contains alphanumeric characters, dots, underscores, minus signs
* these symbols are grouped into words, which are separated by spaces
and Windows-style (CR+LF) newlines
* although serializer uses spaces and CR+LF as separators, you can
replace any separator character by arbitrary combination of spaces,
tabs, Windows or Unix newlines. It allows flexible reformatting of
the string in case you want to include it into text or XML file.
But you should not insert separators into the middle of the "words"
nor you should change case of letters.
* s_out can be freely moved between 32-bit and 64-bit systems, little
and big endian machines, and so on. You can serialize structure on
32-bit machine and unserialize it on 64-bit one (or vice versa), or
serialize it on SPARC and unserialize on x86. You can also
serialize it in C++ version of ALGLIB and unserialize in C# one,
and vice versa.
*************************************************************************/
void kdtreeserialize(kdtree &obj, std::string &s_out);
/*************************************************************************
This function unserializes data structure from string.
*************************************************************************/
void kdtreeunserialize(const std::string &s_in, kdtree &obj);
/*************************************************************************
This function serializes data structure to C++ stream.
Data stream generated by this function is same as string representation
generated by string version of serializer - alphanumeric characters,
dots, underscores, minus signs, which are grouped into words separated by
spaces and CR+LF.
We recommend you to read comments on string version of serializer to find
out more about serialization of AlGLIB objects.
*************************************************************************/
void kdtreeserialize(kdtree &obj, std::ostream &s_out);
/*************************************************************************
This function unserializes data structure from stream.
*************************************************************************/
void kdtreeunserialize(const std::istream &s_in, kdtree &obj);
/*************************************************************************
KD-tree creation
This subroutine creates KD-tree from set of X-values and optional Y-values
INPUT PARAMETERS
XY - dataset, array[0..N-1,0..NX+NY-1].
one row corresponds to one point.
first NX columns contain X-values, next NY (NY may be zero)
columns may contain associated Y-values
N - number of points, N>=0.
NX - space dimension, NX>=1.
NY - number of optional Y-values, NY>=0.
NormType- norm type:
* 0 denotes infinity-norm
* 1 denotes 1-norm
* 2 denotes 2-norm (Euclidean norm)
OUTPUT PARAMETERS
KDT - KD-tree
NOTES
1. KD-tree creation have O(N*logN) complexity and O(N*(2*NX+NY)) memory
requirements.
2. Although KD-trees may be used with any combination of N and NX, they
are more efficient than brute-force search only when N >> 4^NX. So they
are most useful in low-dimensional tasks (NX=2, NX=3). NX=1 is another
inefficient case, because simple binary search (without additional
structures) is much more efficient in such tasks than KD-trees.
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreebuild(const real_2d_array &xy, const ae_int_t n, const ae_int_t nx, const ae_int_t ny, const ae_int_t normtype, kdtree &kdt);
void kdtreebuild(const real_2d_array &xy, const ae_int_t nx, const ae_int_t ny, const ae_int_t normtype, kdtree &kdt);
/*************************************************************************
KD-tree creation
This subroutine creates KD-tree from set of X-values, integer tags and
optional Y-values
INPUT PARAMETERS
XY - dataset, array[0..N-1,0..NX+NY-1].
one row corresponds to one point.
first NX columns contain X-values, next NY (NY may be zero)
columns may contain associated Y-values
Tags - tags, array[0..N-1], contains integer tags associated
with points.
N - number of points, N>=0
NX - space dimension, NX>=1.
NY - number of optional Y-values, NY>=0.
NormType- norm type:
* 0 denotes infinity-norm
* 1 denotes 1-norm
* 2 denotes 2-norm (Euclidean norm)
OUTPUT PARAMETERS
KDT - KD-tree
NOTES
1. KD-tree creation have O(N*logN) complexity and O(N*(2*NX+NY)) memory
requirements.
2. Although KD-trees may be used with any combination of N and NX, they
are more efficient than brute-force search only when N >> 4^NX. So they
are most useful in low-dimensional tasks (NX=2, NX=3). NX=1 is another
inefficient case, because simple binary search (without additional
structures) is much more efficient in such tasks than KD-trees.
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreebuildtagged(const real_2d_array &xy, const integer_1d_array &tags, const ae_int_t n, const ae_int_t nx, const ae_int_t ny, const ae_int_t normtype, kdtree &kdt);
void kdtreebuildtagged(const real_2d_array &xy, const integer_1d_array &tags, const ae_int_t nx, const ae_int_t ny, const ae_int_t normtype, kdtree &kdt);
/*************************************************************************
This function creates buffer structure which can be used to perform
parallel KD-tree requests.
KD-tree subpackage provides two sets of request functions - ones which use
internal buffer of KD-tree object (these functions are single-threaded
because they use same buffer, which can not shared between threads), and
ones which use external buffer.
This function is used to initialize external buffer.
INPUT PARAMETERS
KDT - KD-tree which is associated with newly created buffer
OUTPUT PARAMETERS
Buf - external buffer.
IMPORTANT: KD-tree buffer should be used only with KD-tree object which
was used to initialize buffer. Any attempt to use biffer with
different object is dangerous - you may get integrity check
failure (exception) because sizes of internal arrays do not fit
to dimensions of KD-tree structure.
-- ALGLIB --
Copyright 18.03.2016 by Bochkanov Sergey
*************************************************************************/
void kdtreecreaterequestbuffer(const kdtree &kdt, kdtreerequestbuffer &buf);
/*************************************************************************
K-NN query: K nearest neighbors
IMPORTANT: this function can not be used in multithreaded code because it
uses internal temporary buffer of kd-tree object, which can not
be shared between multiple threads. If you want to perform
parallel requests, use function which uses external request
buffer: KDTreeTsQueryKNN() ("Ts" stands for "thread-safe").
INPUT PARAMETERS
KDT - KD-tree
X - point, array[0..NX-1].
K - number of neighbors to return, K>=1
SelfMatch - whether self-matches are allowed:
* if True, nearest neighbor may be the point itself
(if it exists in original dataset)
* if False, then only points with non-zero distance
are returned
* if not given, considered True
RESULT
number of actual neighbors found (either K or N, if K>N).
This subroutine performs query and stores its result in the internal
structures of the KD-tree. You can use following subroutines to obtain
these results:
* KDTreeQueryResultsX() to get X-values
* KDTreeQueryResultsXY() to get X- and Y-values
* KDTreeQueryResultsTags() to get tag values
* KDTreeQueryResultsDistances() to get distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreequeryknn(const kdtree &kdt, const real_1d_array &x, const ae_int_t k, const bool selfmatch);
ae_int_t kdtreequeryknn(const kdtree &kdt, const real_1d_array &x, const ae_int_t k);
/*************************************************************************
K-NN query: K nearest neighbors, using external thread-local buffer.
You can call this function from multiple threads for same kd-tree instance,
assuming that different instances of buffer object are passed to different
threads.
INPUT PARAMETERS
KDT - kd-tree
Buf - request buffer object created for this particular
instance of kd-tree structure with kdtreecreaterequestbuffer()
function.
X - point, array[0..NX-1].
K - number of neighbors to return, K>=1
SelfMatch - whether self-matches are allowed:
* if True, nearest neighbor may be the point itself
(if it exists in original dataset)
* if False, then only points with non-zero distance
are returned
* if not given, considered True
RESULT
number of actual neighbors found (either K or N, if K>N).
This subroutine performs query and stores its result in the internal
structures of the buffer object. You can use following subroutines to
obtain these results (pay attention to "buf" in their names):
* KDTreeTsQueryResultsX() to get X-values
* KDTreeTsQueryResultsXY() to get X- and Y-values
* KDTreeTsQueryResultsTags() to get tag values
* KDTreeTsQueryResultsDistances() to get distances
IMPORTANT: kd-tree buffer should be used only with KD-tree object which
was used to initialize buffer. Any attempt to use biffer with
different object is dangerous - you may get integrity check
failure (exception) because sizes of internal arrays do not fit
to dimensions of KD-tree structure.
-- ALGLIB --
Copyright 18.03.2016 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreetsqueryknn(const kdtree &kdt, const kdtreerequestbuffer &buf, const real_1d_array &x, const ae_int_t k, const bool selfmatch);
ae_int_t kdtreetsqueryknn(const kdtree &kdt, const kdtreerequestbuffer &buf, const real_1d_array &x, const ae_int_t k);
/*************************************************************************
R-NN query: all points within R-sphere centered at X
IMPORTANT: this function can not be used in multithreaded code because it
uses internal temporary buffer of kd-tree object, which can not
be shared between multiple threads. If you want to perform
parallel requests, use function which uses external request
buffer: KDTreeTsQueryRNN() ("Ts" stands for "thread-safe").
INPUT PARAMETERS
KDT - KD-tree
X - point, array[0..NX-1].
R - radius of sphere (in corresponding norm), R>0
SelfMatch - whether self-matches are allowed:
* if True, nearest neighbor may be the point itself
(if it exists in original dataset)
* if False, then only points with non-zero distance
are returned
* if not given, considered True
RESULT
number of neighbors found, >=0
This subroutine performs query and stores its result in the internal
structures of the KD-tree. You can use following subroutines to obtain
actual results:
* KDTreeQueryResultsX() to get X-values
* KDTreeQueryResultsXY() to get X- and Y-values
* KDTreeQueryResultsTags() to get tag values
* KDTreeQueryResultsDistances() to get distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreequeryrnn(const kdtree &kdt, const real_1d_array &x, const double r, const bool selfmatch);
ae_int_t kdtreequeryrnn(const kdtree &kdt, const real_1d_array &x, const double r);
/*************************************************************************
R-NN query: all points within R-sphere centered at X, using external
thread-local buffer.
You can call this function from multiple threads for same kd-tree instance,
assuming that different instances of buffer object are passed to different
threads.
INPUT PARAMETERS
KDT - KD-tree
Buf - request buffer object created for this particular
instance of kd-tree structure with kdtreecreaterequestbuffer()
function.
X - point, array[0..NX-1].
R - radius of sphere (in corresponding norm), R>0
SelfMatch - whether self-matches are allowed:
* if True, nearest neighbor may be the point itself
(if it exists in original dataset)
* if False, then only points with non-zero distance
are returned
* if not given, considered True
RESULT
number of neighbors found, >=0
This subroutine performs query and stores its result in the internal
structures of the buffer object. You can use following subroutines to
obtain these results (pay attention to "buf" in their names):
* KDTreeTsQueryResultsX() to get X-values
* KDTreeTsQueryResultsXY() to get X- and Y-values
* KDTreeTsQueryResultsTags() to get tag values
* KDTreeTsQueryResultsDistances() to get distances
IMPORTANT: kd-tree buffer should be used only with KD-tree object which
was used to initialize buffer. Any attempt to use biffer with
different object is dangerous - you may get integrity check
failure (exception) because sizes of internal arrays do not fit
to dimensions of KD-tree structure.
-- ALGLIB --
Copyright 18.03.2016 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreetsqueryrnn(const kdtree &kdt, const kdtreerequestbuffer &buf, const real_1d_array &x, const double r, const bool selfmatch);
ae_int_t kdtreetsqueryrnn(const kdtree &kdt, const kdtreerequestbuffer &buf, const real_1d_array &x, const double r);
/*************************************************************************
K-NN query: approximate K nearest neighbors
IMPORTANT: this function can not be used in multithreaded code because it
uses internal temporary buffer of kd-tree object, which can not
be shared between multiple threads. If you want to perform
parallel requests, use function which uses external request
buffer: KDTreeTsQueryAKNN() ("Ts" stands for "thread-safe").
INPUT PARAMETERS
KDT - KD-tree
X - point, array[0..NX-1].
K - number of neighbors to return, K>=1
SelfMatch - whether self-matches are allowed:
* if True, nearest neighbor may be the point itself
(if it exists in original dataset)
* if False, then only points with non-zero distance
are returned
* if not given, considered True
Eps - approximation factor, Eps>=0. eps-approximate nearest
neighbor is a neighbor whose distance from X is at
most (1+eps) times distance of true nearest neighbor.
RESULT
number of actual neighbors found (either K or N, if K>N).
NOTES
significant performance gain may be achieved only when Eps is is on
the order of magnitude of 1 or larger.
This subroutine performs query and stores its result in the internal
structures of the KD-tree. You can use following subroutines to obtain
these results:
* KDTreeQueryResultsX() to get X-values
* KDTreeQueryResultsXY() to get X- and Y-values
* KDTreeQueryResultsTags() to get tag values
* KDTreeQueryResultsDistances() to get distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreequeryaknn(const kdtree &kdt, const real_1d_array &x, const ae_int_t k, const bool selfmatch, const double eps);
ae_int_t kdtreequeryaknn(const kdtree &kdt, const real_1d_array &x, const ae_int_t k, const double eps);
/*************************************************************************
K-NN query: approximate K nearest neighbors, using thread-local buffer.
You can call this function from multiple threads for same kd-tree instance,
assuming that different instances of buffer object are passed to different
threads.
INPUT PARAMETERS
KDT - KD-tree
Buf - request buffer object created for this particular
instance of kd-tree structure with kdtreecreaterequestbuffer()
function.
X - point, array[0..NX-1].
K - number of neighbors to return, K>=1
SelfMatch - whether self-matches are allowed:
* if True, nearest neighbor may be the point itself
(if it exists in original dataset)
* if False, then only points with non-zero distance
are returned
* if not given, considered True
Eps - approximation factor, Eps>=0. eps-approximate nearest
neighbor is a neighbor whose distance from X is at
most (1+eps) times distance of true nearest neighbor.
RESULT
number of actual neighbors found (either K or N, if K>N).
NOTES
significant performance gain may be achieved only when Eps is is on
the order of magnitude of 1 or larger.
This subroutine performs query and stores its result in the internal
structures of the buffer object. You can use following subroutines to
obtain these results (pay attention to "buf" in their names):
* KDTreeTsQueryResultsX() to get X-values
* KDTreeTsQueryResultsXY() to get X- and Y-values
* KDTreeTsQueryResultsTags() to get tag values
* KDTreeTsQueryResultsDistances() to get distances
IMPORTANT: kd-tree buffer should be used only with KD-tree object which
was used to initialize buffer. Any attempt to use biffer with
different object is dangerous - you may get integrity check
failure (exception) because sizes of internal arrays do not fit
to dimensions of KD-tree structure.
-- ALGLIB --
Copyright 18.03.2016 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreetsqueryaknn(const kdtree &kdt, const kdtreerequestbuffer &buf, const real_1d_array &x, const ae_int_t k, const bool selfmatch, const double eps);
ae_int_t kdtreetsqueryaknn(const kdtree &kdt, const kdtreerequestbuffer &buf, const real_1d_array &x, const ae_int_t k, const double eps);
/*************************************************************************
Box query: all points within user-specified box.
IMPORTANT: this function can not be used in multithreaded code because it
uses internal temporary buffer of kd-tree object, which can not
be shared between multiple threads. If you want to perform
parallel requests, use function which uses external request
buffer: KDTreeTsQueryBox() ("Ts" stands for "thread-safe").
INPUT PARAMETERS
KDT - KD-tree
BoxMin - lower bounds, array[0..NX-1].
BoxMax - upper bounds, array[0..NX-1].
RESULT
number of actual neighbors found (in [0,N]).
This subroutine performs query and stores its result in the internal
structures of the KD-tree. You can use following subroutines to obtain
these results:
* KDTreeQueryResultsX() to get X-values
* KDTreeQueryResultsXY() to get X- and Y-values
* KDTreeQueryResultsTags() to get tag values
* KDTreeQueryResultsDistances() returns zeros for this request
NOTE: this particular query returns unordered results, because there is no
meaningful way of ordering points. Furthermore, no 'distance' is
associated with points - it is either INSIDE or OUTSIDE (so request
for distances will return zeros).
-- ALGLIB --
Copyright 14.05.2016 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreequerybox(const kdtree &kdt, const real_1d_array &boxmin, const real_1d_array &boxmax);
/*************************************************************************
Box query: all points within user-specified box, using thread-local buffer.
You can call this function from multiple threads for same kd-tree instance,
assuming that different instances of buffer object are passed to different
threads.
INPUT PARAMETERS
KDT - KD-tree
Buf - request buffer object created for this particular
instance of kd-tree structure with kdtreecreaterequestbuffer()
function.
BoxMin - lower bounds, array[0..NX-1].
BoxMax - upper bounds, array[0..NX-1].
RESULT
number of actual neighbors found (in [0,N]).
This subroutine performs query and stores its result in the internal
structures of the buffer object. You can use following subroutines to
obtain these results (pay attention to "ts" in their names):
* KDTreeTsQueryResultsX() to get X-values
* KDTreeTsQueryResultsXY() to get X- and Y-values
* KDTreeTsQueryResultsTags() to get tag values
* KDTreeTsQueryResultsDistances() returns zeros for this query
NOTE: this particular query returns unordered results, because there is no
meaningful way of ordering points. Furthermore, no 'distance' is
associated with points - it is either INSIDE or OUTSIDE (so request
for distances will return zeros).
IMPORTANT: kd-tree buffer should be used only with KD-tree object which
was used to initialize buffer. Any attempt to use biffer with
different object is dangerous - you may get integrity check
failure (exception) because sizes of internal arrays do not fit
to dimensions of KD-tree structure.
-- ALGLIB --
Copyright 14.05.2016 by Bochkanov Sergey
*************************************************************************/
ae_int_t kdtreetsquerybox(const kdtree &kdt, const kdtreerequestbuffer &buf, const real_1d_array &boxmin, const real_1d_array &boxmax);
/*************************************************************************
X-values from last query.
This function retuns results stored in the internal buffer of kd-tree
object. If you performed buffered requests (ones which use instances of
kdtreerequestbuffer class), you should call buffered version of this
function - kdtreetsqueryresultsx().
INPUT PARAMETERS
KDT - KD-tree
X - possibly pre-allocated buffer. If X is too small to store
result, it is resized. If size(X) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
X - rows are filled with X-values
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsXY() X- and Y-values
* KDTreeQueryResultsTags() tag values
* KDTreeQueryResultsDistances() distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultsx(const kdtree &kdt, real_2d_array &x);
/*************************************************************************
X- and Y-values from last query
This function retuns results stored in the internal buffer of kd-tree
object. If you performed buffered requests (ones which use instances of
kdtreerequestbuffer class), you should call buffered version of this
function - kdtreetsqueryresultsxy().
INPUT PARAMETERS
KDT - KD-tree
XY - possibly pre-allocated buffer. If XY is too small to store
result, it is resized. If size(XY) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
XY - rows are filled with points: first NX columns with
X-values, next NY columns - with Y-values.
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsX() X-values
* KDTreeQueryResultsTags() tag values
* KDTreeQueryResultsDistances() distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultsxy(const kdtree &kdt, real_2d_array &xy);
/*************************************************************************
Tags from last query
This function retuns results stored in the internal buffer of kd-tree
object. If you performed buffered requests (ones which use instances of
kdtreerequestbuffer class), you should call buffered version of this
function - kdtreetsqueryresultstags().
INPUT PARAMETERS
KDT - KD-tree
Tags - possibly pre-allocated buffer. If X is too small to store
result, it is resized. If size(X) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
Tags - filled with tags associated with points,
or, when no tags were supplied, with zeros
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsX() X-values
* KDTreeQueryResultsXY() X- and Y-values
* KDTreeQueryResultsDistances() distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultstags(const kdtree &kdt, integer_1d_array &tags);
/*************************************************************************
Distances from last query
This function retuns results stored in the internal buffer of kd-tree
object. If you performed buffered requests (ones which use instances of
kdtreerequestbuffer class), you should call buffered version of this
function - kdtreetsqueryresultsdistances().
INPUT PARAMETERS
KDT - KD-tree
R - possibly pre-allocated buffer. If X is too small to store
result, it is resized. If size(X) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
R - filled with distances (in corresponding norm)
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsX() X-values
* KDTreeQueryResultsXY() X- and Y-values
* KDTreeQueryResultsTags() tag values
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultsdistances(const kdtree &kdt, real_1d_array &r);
/*************************************************************************
X-values from last query associated with kdtreerequestbuffer object.
INPUT PARAMETERS
KDT - KD-tree
Buf - request buffer object created for this particular
instance of kd-tree structure.
X - possibly pre-allocated buffer. If X is too small to store
result, it is resized. If size(X) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
X - rows are filled with X-values
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsXY() X- and Y-values
* KDTreeQueryResultsTags() tag values
* KDTreeQueryResultsDistances() distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreetsqueryresultsx(const kdtree &kdt, const kdtreerequestbuffer &buf, real_2d_array &x);
/*************************************************************************
X- and Y-values from last query associated with kdtreerequestbuffer object.
INPUT PARAMETERS
KDT - KD-tree
Buf - request buffer object created for this particular
instance of kd-tree structure.
XY - possibly pre-allocated buffer. If XY is too small to store
result, it is resized. If size(XY) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
XY - rows are filled with points: first NX columns with
X-values, next NY columns - with Y-values.
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsX() X-values
* KDTreeQueryResultsTags() tag values
* KDTreeQueryResultsDistances() distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreetsqueryresultsxy(const kdtree &kdt, const kdtreerequestbuffer &buf, real_2d_array &xy);
/*************************************************************************
Tags from last query associated with kdtreerequestbuffer object.
This function retuns results stored in the internal buffer of kd-tree
object. If you performed buffered requests (ones which use instances of
kdtreerequestbuffer class), you should call buffered version of this
function - KDTreeTsqueryresultstags().
INPUT PARAMETERS
KDT - KD-tree
Buf - request buffer object created for this particular
instance of kd-tree structure.
Tags - possibly pre-allocated buffer. If X is too small to store
result, it is resized. If size(X) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
Tags - filled with tags associated with points,
or, when no tags were supplied, with zeros
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsX() X-values
* KDTreeQueryResultsXY() X- and Y-values
* KDTreeQueryResultsDistances() distances
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreetsqueryresultstags(const kdtree &kdt, const kdtreerequestbuffer &buf, integer_1d_array &tags);
/*************************************************************************
Distances from last query associated with kdtreerequestbuffer object.
This function retuns results stored in the internal buffer of kd-tree
object. If you performed buffered requests (ones which use instances of
kdtreerequestbuffer class), you should call buffered version of this
function - KDTreeTsqueryresultsdistances().
INPUT PARAMETERS
KDT - KD-tree
Buf - request buffer object created for this particular
instance of kd-tree structure.
R - possibly pre-allocated buffer. If X is too small to store
result, it is resized. If size(X) is enough to store
result, it is left unchanged.
OUTPUT PARAMETERS
R - filled with distances (in corresponding norm)
NOTES
1. points are ordered by distance from the query point (first = closest)
2. if XY is larger than required to store result, only leading part will
be overwritten; trailing part will be left unchanged. So if on input
XY = [[A,B],[C,D]], and result is [1,2], then on exit we will get
XY = [[1,2],[C,D]]. This is done purposely to increase performance; if
you want function to resize array according to result size, use
function with same name and suffix 'I'.
SEE ALSO
* KDTreeQueryResultsX() X-values
* KDTreeQueryResultsXY() X- and Y-values
* KDTreeQueryResultsTags() tag values
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreetsqueryresultsdistances(const kdtree &kdt, const kdtreerequestbuffer &buf, real_1d_array &r);
/*************************************************************************
X-values from last query; 'interactive' variant for languages like Python
which support constructs like "X = KDTreeQueryResultsXI(KDT)" and
interactive mode of interpreter.
This function allocates new array on each call, so it is significantly
slower than its 'non-interactive' counterpart, but it is more convenient
when you call it from command line.
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultsxi(const kdtree &kdt, real_2d_array &x);
/*************************************************************************
XY-values from last query; 'interactive' variant for languages like Python
which support constructs like "XY = KDTreeQueryResultsXYI(KDT)" and
interactive mode of interpreter.
This function allocates new array on each call, so it is significantly
slower than its 'non-interactive' counterpart, but it is more convenient
when you call it from command line.
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultsxyi(const kdtree &kdt, real_2d_array &xy);
/*************************************************************************
Tags from last query; 'interactive' variant for languages like Python
which support constructs like "Tags = KDTreeQueryResultsTagsI(KDT)" and
interactive mode of interpreter.
This function allocates new array on each call, so it is significantly
slower than its 'non-interactive' counterpart, but it is more convenient
when you call it from command line.
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultstagsi(const kdtree &kdt, integer_1d_array &tags);
/*************************************************************************
Distances from last query; 'interactive' variant for languages like Python
which support constructs like "R = KDTreeQueryResultsDistancesI(KDT)"
and interactive mode of interpreter.
This function allocates new array on each call, so it is significantly
slower than its 'non-interactive' counterpart, but it is more convenient
when you call it from command line.
-- ALGLIB --
Copyright 28.02.2010 by Bochkanov Sergey
*************************************************************************/
void kdtreequeryresultsdistancesi(const kdtree &kdt, real_1d_array &r);
#endif
#if defined(AE_COMPILE_HQRND) || !defined(AE_PARTIAL_BUILD)
/*************************************************************************
HQRNDState initialization with random values which come from standard
RNG.
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
void hqrndrandomize(hqrndstate &state);
/*************************************************************************
HQRNDState initialization with seed values
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
void hqrndseed(const ae_int_t s1, const ae_int_t s2, hqrndstate &state);
/*************************************************************************
This function generates random real number in (0,1),
not including interval boundaries
State structure must be initialized with HQRNDRandomize() or HQRNDSeed().
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
double hqrnduniformr(const hqrndstate &state);
/*************************************************************************
This function generates random integer number in [0, N)
1. State structure must be initialized with HQRNDRandomize() or HQRNDSeed()
2. N can be any positive number except for very large numbers:
* close to 2^31 on 32-bit systems
* close to 2^62 on 64-bit systems
An exception will be generated if N is too large.
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
ae_int_t hqrnduniformi(const hqrndstate &state, const ae_int_t n);
/*************************************************************************
Random number generator: normal numbers
This function generates one random number from normal distribution.
Its performance is equal to that of HQRNDNormal2()
State structure must be initialized with HQRNDRandomize() or HQRNDSeed().
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
double hqrndnormal(const hqrndstate &state);
/*************************************************************************
Random number generator: random X and Y such that X^2+Y^2=1
State structure must be initialized with HQRNDRandomize() or HQRNDSeed().
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
void hqrndunit2(const hqrndstate &state, double &x, double &y);
/*************************************************************************
Random number generator: normal numbers
This function generates two independent random numbers from normal
distribution. Its performance is equal to that of HQRNDNormal()
State structure must be initialized with HQRNDRandomize() or HQRNDSeed().
-- ALGLIB --
Copyright 02.12.2009 by Bochkanov Sergey
*************************************************************************/
void hqrndnormal2(const hqrndstate &state, double &x1, double &x2);
/*************************************************************************
Random number generator: exponential distribution
State structure must be initialized with HQRNDRandomize() or HQRNDSeed().
-- ALGLIB --
Copyright 11.08.2007 by Bochkanov Sergey
*************************************************************************/
double hqrndexponential(const hqrndstate &state, const double lambdav);
/*************************************************************************
This function generates random number from discrete distribution given by
finite sample X.
INPUT PARAMETERS
State - high quality random number generator, must be
initialized with HQRNDRandomize() or HQRNDSeed().
X - finite sample
N - number of elements to use, N>=1
RESULT
this function returns one of the X[i] for random i=0..N-1
-- ALGLIB --
Copyright 08.11.2011 by Bochkanov Sergey
*************************************************************************/
double hqrnddiscrete(const hqrndstate &state, const real_1d_array &x, const ae_int_t n);
/*************************************************************************
This function generates random number from continuous distribution given
by finite sample X.
INPUT PARAMETERS
State - high quality random number generator, must be
initialized with HQRNDRandomize() or HQRNDSeed().
X - finite sample, array[N] (can be larger, in this case only
leading N elements are used). THIS ARRAY MUST BE SORTED BY
ASCENDING.
N - number of elements to use, N>=1
RESULT
this function returns random number from continuous distribution which
tries to approximate X as mush as possible. min(X)<=Result<=max(X).
-- ALGLIB --
Copyright 08.11.2011 by Bochkanov Sergey
*************************************************************************/
double hqrndcontinuous(const hqrndstate &state, const real_1d_array &x, const ae_int_t n);
#endif
#if defined(AE_COMPILE_XDEBUG) || !defined(AE_PARTIAL_BUILD)
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Creates and returns XDebugRecord1 structure:
* integer and complex fields of Rec1 are set to 1 and 1+i correspondingly
* array field of Rec1 is set to [2,3]
-- ALGLIB --
Copyright 27.05.2014 by Bochkanov Sergey
*************************************************************************/
void xdebuginitrecord1(xdebugrecord1 &rec1);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Counts number of True values in the boolean 1D array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
ae_int_t xdebugb1count(const boolean_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by NOT(a[i]).
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugb1not(const boolean_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Appends copy of array to itself.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugb1appendcopy(boolean_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate N-element array with even-numbered elements set to True.
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugb1outeven(const ae_int_t n, boolean_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Returns sum of elements in the array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
ae_int_t xdebugi1sum(const integer_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by -A[I]
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugi1neg(const integer_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Appends copy of array to itself.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugi1appendcopy(integer_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate N-element array with even-numbered A[I] set to I, and odd-numbered
ones set to 0.
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugi1outeven(const ae_int_t n, integer_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Returns sum of elements in the array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
double xdebugr1sum(const real_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by -A[I]
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugr1neg(const real_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Appends copy of array to itself.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugr1appendcopy(real_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate N-element array with even-numbered A[I] set to I*0.25,
and odd-numbered ones are set to 0.
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugr1outeven(const ae_int_t n, real_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Returns sum of elements in the array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
alglib::complex xdebugc1sum(const complex_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by -A[I]
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugc1neg(const complex_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Appends copy of array to itself.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugc1appendcopy(complex_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate N-element array with even-numbered A[K] set to (x,y) = (K*0.25, K*0.125)
and odd-numbered ones are set to 0.
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugc1outeven(const ae_int_t n, complex_1d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Counts number of True values in the boolean 2D array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
ae_int_t xdebugb2count(const boolean_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by NOT(a[i]).
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugb2not(const boolean_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Transposes array.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugb2transpose(boolean_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate MxN matrix with elements set to "Sin(3*I+5*J)>0"
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugb2outsin(const ae_int_t m, const ae_int_t n, boolean_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Returns sum of elements in the array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
ae_int_t xdebugi2sum(const integer_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by -a[i,j]
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugi2neg(const integer_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Transposes array.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugi2transpose(integer_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate MxN matrix with elements set to "Sign(Sin(3*I+5*J))"
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugi2outsin(const ae_int_t m, const ae_int_t n, integer_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Returns sum of elements in the array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
double xdebugr2sum(const real_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by -a[i,j]
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugr2neg(const real_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Transposes array.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugr2transpose(real_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate MxN matrix with elements set to "Sin(3*I+5*J)"
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugr2outsin(const ae_int_t m, const ae_int_t n, real_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Returns sum of elements in the array.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
alglib::complex xdebugc2sum(const complex_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Replace all values in array by -a[i,j]
Array is passed using "shared" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugc2neg(const complex_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Transposes array.
Array is passed using "var" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugc2transpose(complex_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Generate MxN matrix with elements set to "Sin(3*I+5*J),Cos(3*I+5*J)"
Array is passed using "out" convention.
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
void xdebugc2outsincos(const ae_int_t m, const ae_int_t n, complex_2d_array &a);
/*************************************************************************
This is debug function intended for testing ALGLIB interface generator.
Never use it in any real life project.
Returns sum of a[i,j]*(1+b[i,j]) such that c[i,j] is True
-- ALGLIB --
Copyright 11.10.2013 by Bochkanov Sergey
*************************************************************************/
double xdebugmaskedbiasedproductsum(const ae_int_t m, const ae_int_t n, const real_2d_array &a, const real_2d_array &b, const boolean_2d_array &c);
#endif
}
/////////////////////////////////////////////////////////////////////////
//
// THIS SECTION CONTAINS COMPUTATIONAL CORE DECLARATIONS (FUNCTIONS)
//
/////////////////////////////////////////////////////////////////////////
namespace alglib_impl
{
#if defined(AE_COMPILE_NEARESTNEIGHBOR) || !defined(AE_PARTIAL_BUILD)
void kdtreebuild(/* Real */ ae_matrix* xy,
ae_int_t n,
ae_int_t nx,
ae_int_t ny,
ae_int_t normtype,
kdtree* kdt,
ae_state *_state);
void kdtreebuildtagged(/* Real */ ae_matrix* xy,
/* Integer */ ae_vector* tags,
ae_int_t n,
ae_int_t nx,
ae_int_t ny,
ae_int_t normtype,
kdtree* kdt,
ae_state *_state);
void kdtreecreaterequestbuffer(kdtree* kdt,
kdtreerequestbuffer* buf,
ae_state *_state);
ae_int_t kdtreequeryknn(kdtree* kdt,
/* Real */ ae_vector* x,
ae_int_t k,
ae_bool selfmatch,
ae_state *_state);
ae_int_t kdtreetsqueryknn(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Real */ ae_vector* x,
ae_int_t k,
ae_bool selfmatch,
ae_state *_state);
ae_int_t kdtreequeryrnn(kdtree* kdt,
/* Real */ ae_vector* x,
double r,
ae_bool selfmatch,
ae_state *_state);
ae_int_t kdtreetsqueryrnn(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Real */ ae_vector* x,
double r,
ae_bool selfmatch,
ae_state *_state);
ae_int_t kdtreequeryaknn(kdtree* kdt,
/* Real */ ae_vector* x,
ae_int_t k,
ae_bool selfmatch,
double eps,
ae_state *_state);
ae_int_t kdtreetsqueryaknn(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Real */ ae_vector* x,
ae_int_t k,
ae_bool selfmatch,
double eps,
ae_state *_state);
ae_int_t kdtreequerybox(kdtree* kdt,
/* Real */ ae_vector* boxmin,
/* Real */ ae_vector* boxmax,
ae_state *_state);
ae_int_t kdtreetsquerybox(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Real */ ae_vector* boxmin,
/* Real */ ae_vector* boxmax,
ae_state *_state);
void kdtreequeryresultsx(kdtree* kdt,
/* Real */ ae_matrix* x,
ae_state *_state);
void kdtreequeryresultsxy(kdtree* kdt,
/* Real */ ae_matrix* xy,
ae_state *_state);
void kdtreequeryresultstags(kdtree* kdt,
/* Integer */ ae_vector* tags,
ae_state *_state);
void kdtreequeryresultsdistances(kdtree* kdt,
/* Real */ ae_vector* r,
ae_state *_state);
void kdtreetsqueryresultsx(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Real */ ae_matrix* x,
ae_state *_state);
void kdtreetsqueryresultsxy(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Real */ ae_matrix* xy,
ae_state *_state);
void kdtreetsqueryresultstags(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Integer */ ae_vector* tags,
ae_state *_state);
void kdtreetsqueryresultsdistances(kdtree* kdt,
kdtreerequestbuffer* buf,
/* Real */ ae_vector* r,
ae_state *_state);
void kdtreequeryresultsxi(kdtree* kdt,
/* Real */ ae_matrix* x,
ae_state *_state);
void kdtreequeryresultsxyi(kdtree* kdt,
/* Real */ ae_matrix* xy,
ae_state *_state);
void kdtreequeryresultstagsi(kdtree* kdt,
/* Integer */ ae_vector* tags,
ae_state *_state);
void kdtreequeryresultsdistancesi(kdtree* kdt,
/* Real */ ae_vector* r,
ae_state *_state);
void kdtreeexplorebox(kdtree* kdt,
/* Real */ ae_vector* boxmin,
/* Real */ ae_vector* boxmax,
ae_state *_state);
void kdtreeexplorenodetype(kdtree* kdt,
ae_int_t node,
ae_int_t* nodetype,
ae_state *_state);
void kdtreeexploreleaf(kdtree* kdt,
ae_int_t node,
/* Real */ ae_matrix* xy,
ae_int_t* k,
ae_state *_state);
void kdtreeexploresplit(kdtree* kdt,
ae_int_t node,
ae_int_t* d,
double* s,
ae_int_t* nodele,
ae_int_t* nodege,
ae_state *_state);
void kdtreealloc(ae_serializer* s, kdtree* tree, ae_state *_state);
void kdtreeserialize(ae_serializer* s, kdtree* tree, ae_state *_state);
void kdtreeunserialize(ae_serializer* s, kdtree* tree, ae_state *_state);
void _kdtreerequestbuffer_init(void* _p, ae_state *_state, ae_bool make_automatic);
void _kdtreerequestbuffer_init_copy(void* _dst, void* _src, ae_state *_state, ae_bool make_automatic);
void _kdtreerequestbuffer_clear(void* _p);
void _kdtreerequestbuffer_destroy(void* _p);
void _kdtree_init(void* _p, ae_state *_state, ae_bool make_automatic);
void _kdtree_init_copy(void* _dst, void* _src, ae_state *_state, ae_bool make_automatic);
void _kdtree_clear(void* _p);
void _kdtree_destroy(void* _p);
#endif
#if defined(AE_COMPILE_HQRND) || !defined(AE_PARTIAL_BUILD)
void hqrndrandomize(hqrndstate* state, ae_state *_state);
void hqrndseed(ae_int_t s1,
ae_int_t s2,
hqrndstate* state,
ae_state *_state);
double hqrnduniformr(hqrndstate* state, ae_state *_state);
ae_int_t hqrnduniformi(hqrndstate* state, ae_int_t n, ae_state *_state);
double hqrndnormal(hqrndstate* state, ae_state *_state);
void hqrndunit2(hqrndstate* state, double* x, double* y, ae_state *_state);
void hqrndnormal2(hqrndstate* state,
double* x1,
double* x2,
ae_state *_state);
double hqrndexponential(hqrndstate* state,
double lambdav,
ae_state *_state);
double hqrnddiscrete(hqrndstate* state,
/* Real */ ae_vector* x,
ae_int_t n,
ae_state *_state);
double hqrndcontinuous(hqrndstate* state,
/* Real */ ae_vector* x,
ae_int_t n,
ae_state *_state);
void _hqrndstate_init(void* _p, ae_state *_state, ae_bool make_automatic);
void _hqrndstate_init_copy(void* _dst, void* _src, ae_state *_state, ae_bool make_automatic);
void _hqrndstate_clear(void* _p);
void _hqrndstate_destroy(void* _p);
#endif
#if defined(AE_COMPILE_XDEBUG) || !defined(AE_PARTIAL_BUILD)
void xdebuginitrecord1(xdebugrecord1* rec1, ae_state *_state);
ae_int_t xdebugb1count(/* Boolean */ ae_vector* a, ae_state *_state);
void xdebugb1not(/* Boolean */ ae_vector* a, ae_state *_state);
void xdebugb1appendcopy(/* Boolean */ ae_vector* a, ae_state *_state);
void xdebugb1outeven(ae_int_t n,
/* Boolean */ ae_vector* a,
ae_state *_state);
ae_int_t xdebugi1sum(/* Integer */ ae_vector* a, ae_state *_state);
void xdebugi1neg(/* Integer */ ae_vector* a, ae_state *_state);
void xdebugi1appendcopy(/* Integer */ ae_vector* a, ae_state *_state);
void xdebugi1outeven(ae_int_t n,
/* Integer */ ae_vector* a,
ae_state *_state);
double xdebugr1sum(/* Real */ ae_vector* a, ae_state *_state);
void xdebugr1neg(/* Real */ ae_vector* a, ae_state *_state);
void xdebugr1appendcopy(/* Real */ ae_vector* a, ae_state *_state);
void xdebugr1outeven(ae_int_t n,
/* Real */ ae_vector* a,
ae_state *_state);
ae_complex xdebugc1sum(/* Complex */ ae_vector* a, ae_state *_state);
void xdebugc1neg(/* Complex */ ae_vector* a, ae_state *_state);
void xdebugc1appendcopy(/* Complex */ ae_vector* a, ae_state *_state);
void xdebugc1outeven(ae_int_t n,
/* Complex */ ae_vector* a,
ae_state *_state);
ae_int_t xdebugb2count(/* Boolean */ ae_matrix* a, ae_state *_state);
void xdebugb2not(/* Boolean */ ae_matrix* a, ae_state *_state);
void xdebugb2transpose(/* Boolean */ ae_matrix* a, ae_state *_state);
void xdebugb2outsin(ae_int_t m,
ae_int_t n,
/* Boolean */ ae_matrix* a,
ae_state *_state);
ae_int_t xdebugi2sum(/* Integer */ ae_matrix* a, ae_state *_state);
void xdebugi2neg(/* Integer */ ae_matrix* a, ae_state *_state);
void xdebugi2transpose(/* Integer */ ae_matrix* a, ae_state *_state);
void xdebugi2outsin(ae_int_t m,
ae_int_t n,
/* Integer */ ae_matrix* a,
ae_state *_state);
double xdebugr2sum(/* Real */ ae_matrix* a, ae_state *_state);
void xdebugr2neg(/* Real */ ae_matrix* a, ae_state *_state);
void xdebugr2transpose(/* Real */ ae_matrix* a, ae_state *_state);
void xdebugr2outsin(ae_int_t m,
ae_int_t n,
/* Real */ ae_matrix* a,
ae_state *_state);
ae_complex xdebugc2sum(/* Complex */ ae_matrix* a, ae_state *_state);
void xdebugc2neg(/* Complex */ ae_matrix* a, ae_state *_state);
void xdebugc2transpose(/* Complex */ ae_matrix* a, ae_state *_state);
void xdebugc2outsincos(ae_int_t m,
ae_int_t n,
/* Complex */ ae_matrix* a,
ae_state *_state);
double xdebugmaskedbiasedproductsum(ae_int_t m,
ae_int_t n,
/* Real */ ae_matrix* a,
/* Real */ ae_matrix* b,
/* Boolean */ ae_matrix* c,
ae_state *_state);
void _xdebugrecord1_init(void* _p, ae_state *_state, ae_bool make_automatic);
void _xdebugrecord1_init_copy(void* _dst, void* _src, ae_state *_state, ae_bool make_automatic);
void _xdebugrecord1_clear(void* _p);
void _xdebugrecord1_destroy(void* _p);
#endif
}
#endif
| [
"ttw2xk@virginia.edu"
] | ttw2xk@virginia.edu |
7bc4c7a7918b4cc63c47503253a618f90092304c | 260eea6bebbd75f073d51e85e26b4da7c8334a5b | /sample/test_detect_with_of/Detect.cpp | 59c49c03cb2bcf8b8745682eb9e5a4d1c22469af | [] | no_license | lidongliangfly/3516a_sample | 19bb23713673f361114ce40a902c1011b94fb3e0 | 9f31644be03a5cd28a86b9dd855865bc31df5c27 | refs/heads/master | 2021-01-17T04:27:27.722677 | 2016-05-09T09:37:13 | 2016-05-09T09:37:13 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,324 | cpp | #include "Detect.h"
#include "utils.h"
Detect::Detect(KVConfig *cfg)
: cfg_(cfg)
{
debug_ = atoi(cfg->get_value("debug", "0")) == 1;
log_init = log_init_file;
log = log_file;
log_init(0);
od_ = new ObjectDetect(cfg_);
reset();
}
Detect::~Detect()
{
}
void Detect::reset()
{
cnt_ = 0;
max_duration_ = atof(cfg_->get_value("max_duration", "15.0"));
waiting_ = atof(cfg_->get_value("max_wait", "2.0"));
debug_ = atoi(cfg_->get_value("debug", "0")) == 1;
log_init = log_init_file;
log = log_file;
log("Detect config:\n");
log("\tmax_duration: %.2f\n", max_duration_);
log("\tmax_wait: %.2f\n", waiting_);
log("\n");
masked_ = build_mask(mask_);
standups_.clear();
gray_prev_.release();
gray_prev_.cols = 0;
gray_prev_.rows = 0;
}
void Detect::detect(const cv::Mat &origin, Detect::RCS &standups)
{
stamp_ = now();
cnt_++;
origin_ = origin;
if (masked_) {
cv::bitwise_and(origin, mask_, origin);
}
cv::cvtColor(origin, gray_curr_, cv::COLOR_BGR2GRAY);
if (gray_prev_.cols == 0) {
gray_prev_ = gray_curr_.clone();
}
RCS motions;
std::vector<Dir> dirs;
detect(motions, dirs);
cv::swap(gray_prev_, gray_curr_);
assert(dirs.size() == motions.size());
if (dirs.size() > 0) {
int a = 0;
}
// 处理 motions/dirs 对 standups_ 的影响 ...
for (size_t i = 0; i < dirs.size(); i++) {
STANDUPS::iterator it = find_crossed_target(motions[i]);
if (it == standups_.end()) {
// 新的活动区域 ...
// 如果是上升,则创建一个新的 standup
if (dirs[i] == UP) {
Standup s;
s.enable_od = od_->enabled();
std::vector<cv::Rect> faces;
if (s.enable_od) {
// 在 motions[i].pos 的上半部分进行头肩识别 ...
cv::Rect roi = motions[i];
roi.height /= 2; // FIXME:
faces = od_->detect(gray_curr_, roi);
if (faces.empty()) {
log("WRN: %u: 新目标:%s, 但是找不到头肩,失败\n", cnt_, pos2str(motions[i]).c_str());
continue;
}
else {
s.face = faces[0];
}
}
s.pos = motions[i];
s.stamp = stamp_;
s.waiting = false;
standups_.push_back(s);
if (s.enable_od) {
log("INFO: %u: 新目标:%s, 头肩位置: %s, %lu\n", cnt_, pos2str(s.pos).c_str(), pos2str(s.face).c_str(), faces.size());
}
else {
log("INFO: %u: 新目标:%s\n", cnt_, pos2str(s.pos).c_str());
}
}
}
else if (it->waiting) {
// 等待期,直接忽略新的活动 ...
log("WRN: %u: 忽略 Waiting 活动, %s: pos=%s\n", cnt_, DirDesc[dirs[i]], pos2str(it->pos).c_str());
}
else {
// 进入等待期 ...
it->waiting = true;
it->stamp = stamp_;
log("INFO: %u: 目标消失,进入Waiting,%s: pos=%s\n", cnt_, DirDesc[dirs[i]], pos2str(it->pos).c_str());
}
}
// 检查超时 ...
for (STANDUPS::iterator it = standups_.begin(); it != standups_.end();) {
if (stamp_ - it->stamp > max_duration_) {
log("WRN: %u: 删除超时站立: %s, max_duration=%.2f\n",
cnt_, pos2str(it->pos).c_str(), max_duration_);
it = standups_.erase(it); // 超时删除 ...
}
else if (it->waiting) {
if (stamp_ - it->stamp > waiting_) {
log("INFO: %u: 删除waiting区域: %s\n", cnt_, pos2str(it->pos).c_str());
it = standups_.erase(it); // 删除 waiting ...
}
else {
++it;
}
}
else {
standups.push_back(it->pos); // 有效目标 ...
++it;
}
}
}
| [
"root@Ubunut10.04"
] | root@Ubunut10.04 |
e4bead01089fd9d5e131229370d3826a4b9befdf | 59dc5d428e102bf72eb7245dbbe7a47a66728378 | /databases/Pixie/PixiePluginInfo.h | fee500e1de245d5d857112aa8ac3f19a846c4fb6 | [] | no_license | HarinarayanKrishnan/VisIt26RC_Trunk | 6716769694d1a309f994056209171f67e5131642 | 581a0825d81169572b48dd80c1946131c03d0858 | refs/heads/master | 2016-09-06T07:14:00.094983 | 2013-05-15T14:36:48 | 2013-05-15T14:36:48 | 7,009,345 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,358 | h | /*****************************************************************************
*
* Copyright (c) 2000 - 2012, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* 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 disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL 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 LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY 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.
*
*****************************************************************************/
// ****************************************************************************
// PixiePluginInfo.h
// ****************************************************************************
#ifndef PIXIE_PLUGIN_INFO_H
#define PIXIE_PLUGIN_INFO_H
#include <DatabasePluginInfo.h>
#include <database_plugin_exports.h>
class avtDatabase;
class avtDatabaseWriter;
// ****************************************************************************
// Class: PixieDatabasePluginInfo
//
// Purpose:
// Classes that provide all the information about the Pixie plugin.
// Portions are separated into pieces relevant to the appropriate
// components of VisIt.
//
// Programmer: generated by xml2info
// Creation: omitted
//
// Modifications:
//
// ****************************************************************************
class PixieGeneralPluginInfo : public virtual GeneralDatabasePluginInfo
{
public:
virtual const char *GetName() const;
virtual const char *GetVersion() const;
virtual const char *GetID() const;
virtual bool EnabledByDefault() const;
virtual bool HasWriter() const;
virtual std::vector<std::string> GetDefaultFilePatterns() const;
virtual bool AreDefaultFilePatternsStrict() const;
virtual bool OpensWholeDirectory() const;
};
class PixieCommonPluginInfo : public virtual CommonDatabasePluginInfo, public virtual PixieGeneralPluginInfo
{
public:
virtual DatabaseType GetDatabaseType();
virtual avtDatabase *SetupDatabase(const char * const *list,
int nList, int nBlock);
virtual DBOptionsAttributes *GetReadOptions() const;
virtual DBOptionsAttributes *GetWriteOptions() const;
};
class PixieMDServerPluginInfo : public virtual MDServerDatabasePluginInfo, public virtual PixieCommonPluginInfo
{
public:
// this makes compilers happy... remove if we ever have functions here
virtual void dummy();
};
class PixieEnginePluginInfo : public virtual EngineDatabasePluginInfo, public virtual PixieCommonPluginInfo
{
public:
virtual avtDatabaseWriter *GetWriter(void);
};
#endif
| [
"brugger@18c085ea-50e0-402c-830e-de6fd14e8384"
] | brugger@18c085ea-50e0-402c-830e-de6fd14e8384 |
f916a101fff6a2d408e9a71eb20adcd1de8394a5 | 4fcf2967da46f37c831b72b7b97f705d3364306d | /problems/acmicpc_17294.cpp | 5f8970ff34c727d7e4809b7173294b71de4c9759 | [
"MIT"
] | permissive | qawbecrdtey/BOJ-sol | e2be11e60c3c19e88439665d586cb69234f2e5db | 249b988225a8b4f52d27c5f526d7c8d3f4de557c | refs/heads/master | 2023-08-03T15:04:50.837332 | 2023-07-30T08:25:58 | 2023-07-30T08:25:58 | 205,078,469 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 304 | cpp | #include <cstdio>
#include <cstring>
int main() {
char c[20]; scanf("%s", c);
int d = c[0] - c[1];
auto const l = strlen(c);
for(int i = 2; i < l; i++) {
if(c[i - 1] - c[i] != d) {
printf("흥칫뿡!! <( ̄ ﹌  ̄)>");
return 0;
}
} printf("◝(⑅•ᴗ•⑅)◜..°♡ 뀌요미!!");
} | [
"qawbecrdtey@naver.com"
] | qawbecrdtey@naver.com |
45110d4999034ad67fce26494d81ed4a3de33ac2 | c6fb0ef5b9722fbce30283a5e72c67514899bbb6 | /courseraUnordered/graph_search/GraphSearchExercises.cpp | 8cc767500db847ca6189d19a500948e3a5bf03dc | [] | no_license | petrchovanec/cplusplus | 308d30c28bbebd19d1a58c2d04d78bfadd581919 | dab665f03ffe3d66781edc79b5086d882031f553 | refs/heads/main | 2023-05-13T19:38:17.879416 | 2021-06-05T13:38:52 | 2021-06-05T13:38:52 | 374,130,262 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,987 | cpp |
/**
* @file GraphSearchExercises.cpp
* University of Illinois CS 400, MOOC 3, Week 3: Graph Search
* Spring 2019
* STUDENT STARTER FILE
*
* @author Eric Huber - University of Illinois staff
*
**/
// Before beginning these exercises, you should read the instructions PDF,
// and look through the other code files in this directory for examples and
// hints. You only need to edit code in this file. There are comments here
// hinting at what you need to do, and "TODO" is written in various places
// where you need to edit some code in particular.
#include "GraphSearchCommon.h"
// =========================================================================
// EXERCISE 1: Adjacency List Utilities
//
// This exercise is based on the Week 3 lecture material.
//
// Our GridGraph class implements an "adjacency list" graph data structure,
// although it actually makes use of std::unordered_map and std::unordered_set
// to do this. You can read about GridGraph in the instructions PDF and by
// examining GridGraph.h. There are also various examples of GridGraph usage
// in the informal tests defined in main.cpp.
//
// Most of the GridGraph class is already implemented for you. For this
// exercise, you need to finish implementing two functions below:
//
// GridGraph::countEdges
// GridGraph::removePoint
//
// =========================================================================
// GridGraph::countEdges:
// This function should return the number of unique edges in the GridGraph.
// Remember that GridGraph doesn't explicitly store edge objects, but
// instead it stores point adjacency information. Since the graph edges are
// undirected, for any two vertices A and B, the edges (A,B) and (B,A) are the
// same edge. This means if we add up the sizes of the GridGraph::NeighborSet
// sets mapped in adjacencyMap, we'll be double-counting the number of edges.
// We can still use that to get the answer, or instead, the implementation of
// GridGraph::printDetails in GridGraph.h shows another method, by constructing
// a set of the unique edges only.
int GridGraph::countEdges() const {
int numEdges = 0;
//(adjacencyMap.size() + NeighborSet.size())/2;
// =======================================================================
// TODO: Your code here!
// =======================================================================
for (auto const& kk : adjacencyMap){
for (auto const& kk2 : kk.second){
numEdges++;
}
}
return numEdges/2;
}
// GridGraph::removePoint:
// This function takes a point (an IntPair) as input, and it should remove
// all references to the point from the data structure. That means it should
// remove the point's key from the adjacency map, and it should also remove
// other points' references to it in the map, if those other points had been
// connected to it by implicit edges. It shouldn't change anything else about
// the graph.
void GridGraph::removePoint(const IntPair& p1) {
// If the point p1 is not in the GridGraph, then do nothing and return.
// (We use GridGraph::hasPoint for convenience. GridGraph already has
// various functions that may be useful. It's okay for class member
// functions to delegate tasks to one another.)
if (!hasPoint(p1)) return;
// All of p1's original neighboring points (that p1 was connected to with
// edges, implicitly) have their own NeighborSet entries in adjacencyMap,
// under their own point keys. You need to make sure that none of those
// original neighbors refer to p1 any more.
//
// To help you, we've made a value copy of the original set of adjacencies
// associated with this point. Note that the function GridGraph::removeEdge
// alters the adjacencyMap entries for both of its input arguments. In
// general, it can be dangerous business to add or remove items on an STL
// structure while iterating over it, because this is prone to programming
// mistakes. (When you tackle more advanced C++ projects in the future, you
// can think about how to optimize your code so no unnecessary copies are
// ever made, but the small speed benefits of that might not be worth the
// risk of making mistakes! Until then, it's okay to make working copies
// of small pieces of data like this.)
const GridGraph::NeighborSet originalNeighbors = adjacencyMap.at(p1);
// =======================================================================
// TODO: Your code here!
// =======================================================================
for (auto const& kk : originalNeighbors){
adjacencyMap.at(kk).erase(p1);
}
adjacencyMap.erase(p1);
// Finally, for the one point we are removing, erase the point key itself
// from adjacencyMap directly. (There is no other GridGraph helper function
// for this, because that's what we're implementing right now! We need to
// use adjacencyMap's own erase function directly to erase the key.)
// =======================================================================
// TODO: Your code here!
// =======================================================================
}
// =========================================================================
// EXERCISE 2: graphBFS
//
// This exercise is based on the Week 4 lecture material.
//
// The graphBFS function below largely implements the "breadth-first search"
// algorithm for the GridGraph class. You'll be asked to edit a few parts of
// the function to complete it. Those parts are marked with "TODO".
// (Please read the instructions PDF in case these hints are expanded upon
// there.)
//
// Differences from the version of BFS discussed in lecture:
//
// - This implementation of BFS is geared toward finding the shortest path
// from a start point to a goal point. So, it only explores within a single
// connected component, and it may report that the goal is unreachable.
// As soon as the goal point is found, our algorithm stops searching.
//
// - Our implementation uses sets of points to implicitly "label" points with
// some status such as "visited", instead of assigning a label property to
// a point itself. This lets us associate more than one kind of status with
// any given point at the same time, by putting the point in several sets.
// It's convenient to do this with STL containers like unordered set, since
// we don't have to add some kind of status member variable to our own
// classes like IntPair this way. It also means we don't have to initialize
// a status for every vertex. In some graph search problems, such as later
// in Exercise 3, the number of vertices is extremely large, so we'd rather
// not have to initialize them all!
//
// - We use a map, "pred", to record the predecessor vertex of any newly-
// discovered vertex during the search. This implicitly records what the
// discovery edges are, as described in lecture. We can use that to rebuild
// the path from start to goal at the end.
//
// - We do not assign status directly to edges. However, the vertex
// predecessor information is basically recording the "discovery" edges.
//
// - We use a map, "dist", to record information about the shortest-path
// distance to any given node that has been discovered so far. This is
// similar to what Dijkstra's algorithm does, although with BFS graph search
// when the edge lengths are all equal to 1, we know that as soon as we
// discover a node, we have found the shortest path to it. We can still use
// this to detect if we've taken more steps than expected and quit.
//
// - Redundantly, we have created a "dequeued set" that we use to help you
// check for mistakes that could cause an infinite loop. This isn't normally
// part of the BFS algorithm itself. In a way, this is mirroring what the
// "visited set" is already supposed to accomplish.
//
// =========================================================================
// graphBFS:
// We use our GridGraph class where vertices are points (IntPair objects).
// The input consists of a start point, a goal point, and a GridGraph containing
// these points and the implicit edge information.
// We use BFS (breadth-first search) to find the shortest path from start to
// goal, if there exists any path at all. Then we return the path as a list of
// points. If there is no path, or if we take too many steps without success,
// then we return an empty list.
std::list<IntPair> graphBFS(const IntPair& start, const IntPair& goal, const GridGraph& graph) {
// Intialization details -------------------------------------------------
// maxDist failsafe:
//
// We'll hard-code a maximum distance for any shortest path through the graph
// that we will consider before giving up. This isn't strictly necessary for
// BFS to be correct; when a path can be found from start to goal, we'll find
// the shortest such path and we won't alwaysneed to visit all of the vertices
// before that happens anyway. But suppose the goal is unreachable from start;
// then if the graph has a very large number of vertices, an unrestricted BFS
// algorithm would have to explore all the reachable vertices before giving up
// anyway, which could require a lot of time and memory if the graph is huge.
// To avoid this issue, we can hard-code the maximum number of steps we will
// allow before giving up. Of course, we must ensure that it's a reasonable
// number. We might be able to estimate the maximum number of steps based on
// the number of edges in the graph, for example. In the case of puzzleBFS
// later in this assignment, there is a proven upper bound on the number of
// steps needed.
//
// This is not very important for the small GridGraph examples we have,
// but with a graph modeling problem like the puzzleBFS problem in this
// assignment, the number of states implied in the graph is extremely large,
// an exhaustive search could take a long time just to fail.
constexpr int maxDist = 100;
// Queue of graph vertices to explore next. This is an ordinary FIFO queue
// (first in, first out), not a priority queue. When we say "explore" a vertex
// in this assignment, we mean to dequeue it and loop over its adjacent vertices.
std::queue<IntPair> exploreQ;
// Map that associates a given point with its predecessor (the neighbor that discovered it first)
// This will allow us to reconstruct the path once the goal is found.
std::unordered_map<IntPair, IntPair> pred;
// Example usage: "pred[B] = A" records A as the predecessor of B, meaning that A discovered B.
// Map that associates a given point with its shortest-path distance from the starting point.
// This lets us see if we've taken too many steps (see the above comment about maxDist).
// The simplest implementations of BFS don't need a distance record like this,
// but it can be useful information, and other graph search algorithms like Dijkstra's
// algorithm do need to use such a record.
// Remember: with std::unordered_map, the first time we look up a key with [], it will be
// inserted if it doesn't exist yet. Also, its initial int value will be 0 by default.
std::unordered_map<IntPair, int> dist;
// Set of graph vertices that have already been visited. (In this case, by
// "visited", we mean the same thing as a vertex that has been "discovered"
// or "reached" -- that is, it has been added to the exploration queue,
// but not necessarily removed from the queue yet.) This lets us avoid
// re-enqueueing graph vertices that we've already enqueued for exploration.
// (For further optimization, we could just use pred to query whether a vertex
// has been discovered previously, but using this separate set is more explicit
// for the sake of explaining the concepts here.)
std::unordered_set<IntPair> visitedSet;
// This "dequeued" set isn't strictly part of the traditional BFS algorithm,
// but we'll use it for error checking, to make sure that no vertex is ever
// removed from the queue more than once. This is technically redundant,
// because we also have the visitedSet to use.
std::unordered_set<IntPair> dequeuedSet;
// Check for an erroneous problem specification, in case we made a simple mistake.
// (Note that for puzzleBFS, the PuzzleState constructors already check for obviously
// invalid configurations, so you don't need to do this.)
if (!graph.hasPoint(start)) throw std::runtime_error("Starting point doesn't exist in graph");
if (!graph.hasPoint(goal)) throw std::runtime_error("Goal point doesn't exist in graph");
// Initialize the predecessor of the start vertex as itself. You might
// wonder why we don't just leave pred[start] non-existent, because that's
// another way we could check the beginning of the path as we retrace the
// path steps later. It's because initializing pred[start] sanely here
// lets us make sure that the start vertex can be treated like any other
// vertex, which can help prevent subtle bugs in our implementation.
pred[start] = start;
// Initialize that the shortest-path distance from start to itself is 0.
// (This isn't strictly necessary because of how std::unordered_map works.
// It would default-initialize dist[start] to 0 later when we referred to it.
// However, this is more clear.)
dist[start] = 0;
// We begin at the start point, so mark it discovered by putting a copy of it
// in the visited set.
visitedSet.insert(start);
// We will begin searching from the start point. Push a copy of it into the exploration queue.
exploreQ.push(start);
// Below, a "flag" just means a variable for controlling a loop condition.
// foundGoal is a flag for controlling the loop below. It's initialized as false,
// unless we start at the goal, in which case it's initialized as true.
bool foundGoal = (start == goal);
// tooManySteps is a flag that will help us break out of the loop if we detect
// that we've already taken too many steps and probably need to give up searching.
bool tooManySteps = false;
// The main search loop --------------------------------------------------
// While the exploration queue isn't empty yet, there are still discovered points to explore.
// Also, we would want to stop looping if foundGoal or tooManySteps became true.
while (!exploreQ.empty() && !foundGoal && !tooManySteps) {
// Get a copy of the next point to explore from the front of the queue.
// This becomes the "current" point.
auto curPoint = exploreQ.front();
// Pop to remove the point from the queue.
exploreQ.pop();
// Error prevention: Check whether this vertex has ever been dequeued in the past.
// (Checking for vertices that are dequeued more than once isn't strictly considered
// part of the BFS algorithm, because in the loop below, you are meant to check for
// previously-visited vertices while considering the adjacent vertices. We do this
// here for additional sanity checking, in case you have made any mistakes that would
// cause an infinite loop.)
bool curPointWasPreviouslyDequeued = dequeuedSet.count(curPoint);
if (curPointWasPreviouslyDequeued) {
std::cout << "graphBFS ERROR: Dequeued a vertex that had already been dequeued before." << std::endl
<< " If you're using visitedSet correctly, then no vertex should ever be added" << std::endl
<< " to the explore qeueue more than once. [Returning an empty path now.]" << std::endl << std::endl;
return std::list<IntPair>();
}
else {
// We'll record that this vertex has been dequeued by adding a copy of it to the set.
dequeuedSet.insert(curPoint);
}
// =====================================================================
// TODO: Your code here!
// We'll need to loop over the neighbors that are the points adjacent to curPoint.
// Get a copy of the set of neighbors we're going to loop over.
GridGraph::NeighborSet neighbors= graph.adjacencyMap.at(curPoint); // Change this...
// =====================================================================
for (auto neighbor : neighbors) {
// ==================================================================
// TODO: Your code here!
// Check whether the neighbor has already been visited.
bool neighborWasAlreadyVisited = visitedSet.count(neighbor); // Change this...
// ==================================================================
// If this adjacent vertex has NOT been visited before, we will visit it now.
// If it HAS been visited before, we do nothing and continue to loop.
// This way, we avoid enqueueing the same vertex more than once.
if (!neighborWasAlreadyVisited) {
// ================================================================
// TODO: Your code here!
// Record that the curPoint is the predecessor of the neighbor point,
// since curPoint has just led to the discovery of this neighbor for
// the first time.
// ...
pred[neighbor] = curPoint;
// Add neighbor to the visited set.
// ...
visitedSet.insert(neighbor);
// Push neighbor into the exploration queue.
// ...
exploreQ.push(neighbor);
// ================================================================
// Check if we've taken too many steps so far.
// The shortest-path distance to this neighbor is the shortest-path distance
// to curPoint, plus one. (We know that dist[curPoint] has already been
// initialized because we previously reached curPoint from another point,
// and it was assigned a value at that time, or else curPoint is the
// start point that we explicitly initialized at the beginning.)
dist[neighbor] = dist[curPoint]+1;
if (dist[neighbor] > maxDist) {
// If the shortest path to this neighbor is a further distance than we
// are allowed to explore, then flag that we have taken too many steps,
// and break out of the nearest loop (the for loop). After that, the
// tooManySteps flag will cause the while loop to stop also.
// You may ask: How do we know to give up here? What if there are other
// paths we can still explore through the exploration queue, that are shorter?
// We know there are not, because in BFS, we identify all the reachable nodes
// of distance 1, and only after that, all the reachable nodes with distance 2, etc.
// So right now, if we need "too many" steps to reach this discovered neighbor,
// we'll also need "too many" steps to reach any other node later.
// This is the same reasoning that allows us to conclude we have found the
// shortest path, when we finally do reach the goal.
tooManySteps = true;
break;
}
// If we haven't taken too many steps yet, and if the neighbor is the goal,
// then flag that we have found the goal, and break out of the "for" loop.
// The foundGoal flag will then cause the "while" loop to stop, also.
if (neighbor == goal) {
foundGoal = true;
break;
}
} // end of handling the just-discovered neighbor
} // end of for loop
} // end of while loop
// Now that the looping is over, we can evaluate what the results were.
// If we took too many steps, we issue an error message and return an empty list.
if (tooManySteps) {
std::cout << "graphBFS warning: Could not reach goal within the maximum allowed steps.\n (This may be expected if no path exists.)" << std::endl << std::endl;
return std::list<IntPair>();
}
// If we never found the goal even after exploring the entire reachable graph,
// then issue an error message and return an empty list.
if (!foundGoal) {
std::cout << "graphBFS warning: Could not reach goal. (This may be expected\n if no path exists.)" << std::endl << std::endl;
return std::list<IntPair>();
}
// Otherwise, we must have found a path from start to goal, and it is as short as possible.
// (If there exist multiple shortest paths from start to goal that all have the same length,
// we have found ONE of these shortest paths.)
// Make a new, empty list of IntPairs in the stack memory at function scope.
// This will represent the path from start to goal. We'll return it by value at the end.
std::list<IntPair> path;
// We will walk back from the goal to the start using the predecessor records.
auto cur = goal;
// Push the currently-walked vertex onto the FRONT of the list, so that as we walk back
// from goal to start, the created list will be in order from start to goal.
path.push_front(cur);
// Make sure that there is a predecessor recorded for cur, and then while the
// predecessor of cur is not recorded as itself, keep looping. (The start vertex
// recorded itself as its predecessor, so then we know to stop.)
while (pred.count(cur) && pred[cur] != cur) {
// It's good to note here that the "&&" operator has "short circuiting" behavior,
// which means that in "A && B", if A is false, then B is never evaluated at all.
// The whole expression is immediately determined to be false. This way, the
// "A" part can be used as a safeguard on the "B" part, if "B" could cause problems.
// Push a copy of the predecessor onto the front of the list, as we reconstruct
// the path back to the start.
path.push_front(pred[cur]);
// Step backwards to the predecessor so we can continue looping.
cur = pred[cur];
}
// Return the reconstructed path from start to goal.
return path;
}
// =========================================================================
// EXERCISE 3: puzzleBFS
//
// This time, we will use BFS to solve a graph modeling problem. This is
// where we model a realistic problem in terms of an imaginary graph, and
// then we can use graph search concepts to solve the modeled problem.
//
// (Please see the instructions PDF for a detailed introduction to this
// problem, with illustrations.)
//
// The PuzzleState class represents one current state of the "8 puzzle",
// which is a puzzle played on a 3x3 grid containing 8 tiles, where a tile
// can slide into the blank space to shuffle the puzzle. Each state of the
// puzzle can be modeled as a vertex in an imaginary graph, where two states
// are virtually connected by an edge (adjacent) if a single tile move can
// transform the first state into the second state. We do not need a map
// structure for adjacencies since we can use the helper functions from the
// PuzzleState class to determine which states are adjacent at any given
// time. Therefore we also don't need an explicit graph class at all. It's
// important that we can use such an implicit graph representation, because
// the total number of vertices (states) and edges (moves) in the graph model
// for "8 puzzle" would be extremely large, and that would greatly impact the
// running time and memory usage. We don't need to examine every vertex or
// every edge in the graph model; we can just search from the start and quit
// after either finding the goal or giving up (in relatively few steps).
//
// This function is VERY similar to graphBFS, but now we are using the
// PuzzleState class to represent imaginary vertices instead of using IntPair
// to represent literal 2D points, and we do not use GridGraph. You should
// finish graphBFS first before trying this problem. The starter code shown
// below for puzzleBFS is so similar to graphBFS that the comments have mostly
// been removed.
//
// =========================================================================
// puzzleBFS:
// Given start and goal sates as PuzzleState objects, we perform BFS in the
// imaginary graph model implied by the start state, where the rest of the
// reachable vertices (states) and the edges leading to them (puzzle moves)
// can be figure out based on the tile sliding rules of the puzzle.
// If there exists any path from start to goal, then the puzzle can be solved,
// and we return the shortest path (which represents the solution steps).
// If there is no path to the goal, or if we take too many steps without
// success, then the puzzle cannot be solved, and we return an empty list.
std::list<PuzzleState> puzzleBFS(const PuzzleState& start, const PuzzleState& goal) {
// Intialization details -------------------------------------------------
// maxDist failsafe:
//
// For the 8-tile puzzle, it actually never takes as many as 35 steps to
// solve any given puzzle that has a solution. This has been proven in
// the past by brute force. So we can implement a failsafe measure:
// if we've explored all possible 35-move sequences and there's still no
// solution found, then the puzzle cannot be solved. Then we can give up
// and return early. (There do exist unreachable states for the 8 puzzle
// because the tiles can only be rearranged by following the sliding rule.
// So it's possible to specify some "goal" states that cannot be reached by
// sliding the tiles.)
constexpr int maxDist = 35;
std::queue<PuzzleState> exploreQ;
std::unordered_map<PuzzleState, PuzzleState> pred;
std::unordered_map<PuzzleState, int> dist;
std::unordered_set<PuzzleState> visitedSet;
std::unordered_set<PuzzleState> dequeuedSet;
pred[start] = start;
dist[start] = 0;
visitedSet.insert(start);
exploreQ.push(start);
bool foundGoal = (start == goal);
bool tooManySteps = false;
// The main search loop --------------------------------------------------
while (!exploreQ.empty() && !foundGoal && !tooManySteps) {
auto curState = exploreQ.front();
exploreQ.pop();
bool curPointWasPreviouslyDequeued = dequeuedSet.count(curState);
if (curPointWasPreviouslyDequeued) {
std::cout << "puzzleBFS ERROR: Dequeued a vertex that had already been dequeued before." << std::endl
<< " If you're using visitedSet correctly, then no vertex should ever be added" << std::endl
<< " to the explore qeueue more than once. [Returning an empty path now.]" << std::endl << std::endl;
return std::list<PuzzleState>();
}
else {
dequeuedSet.insert(curState);
}
// =====================================================================
// TODO: Your code here!
// We'll need to loop over the neighbors that are the points adjacent to curState.
// We need a collection of neighbors we're going to loop over.
std::vector<PuzzleState> neighbors=curState.getAdjacentStates(); // Change this! This line is totally wrong.
// Hint: Look at PuzzleState.h
// =====================================================================
for (auto neighbor : neighbors) {
// ==================================================================
// TODO: Your code here!
// Check whether the neighbor has already been visited.
bool neighborWasAlreadyVisited = visitedSet.count(neighbor); // Change this...
// ==================================================================
if (!neighborWasAlreadyVisited) {
// ================================================================
// TODO: Your code here!
// Record that the curState is the predecessor of the neighbor point,
// since curState has just led to the discovery of this neighbor for
// the first time.
// ...
pred[neighbor] = curState;
// Add neighbor to the visited set.
// ...
visitedSet.insert(neighbor);
// Push neighbor into the exploration queue.
// ...
exploreQ.push(neighbor);
// ================================================================
dist[neighbor] = dist[curState]+1;
if (dist[neighbor] > maxDist) {
tooManySteps = true;
break;
}
if (neighbor == goal) {
foundGoal = true;
break;
}
} // end of handling the just-discovered neighbor
} // end of for loop
} // end of while loop
if (tooManySteps) {
std::cout << "puzzleBFS warning: Could not reach goal within the maximum allowed steps.\n (This may be expected if no path exists.)" << std::endl << std::endl;
return std::list<PuzzleState>();
}
if (!foundGoal) {
std::cout << "puzzleBFS warning: Could not reach goal. (This may be expected\n if no path exists.)" << std::endl << std::endl;
return std::list<PuzzleState>();
}
std::list<PuzzleState> path;
auto cur = goal;
path.push_front(cur);
while (pred.count(cur) && pred[cur] != cur) {
path.push_front(pred[cur]);
cur = pred[cur];
}
return path;
}
| [
"chovanec@gmail.com"
] | chovanec@gmail.com |
99e231caad112d8df39d9afd0a2bbf2b0f9887c5 | 85aed0bcac5d6aea781dff64029c2d23fcba984b | /MfcExLib/ExceptionHandler.cpp | a284650432f162435f17b86608423ae5b68294ab | [] | no_license | youdontknowme17/ura | 3c76bf05eccd38b454b389841f1db49b59217e46 | e31bc9fd9c2312175d250dc4dc1f9c656c7f2004 | refs/heads/master | 2020-03-28T15:49:00.379682 | 2018-09-15T09:57:49 | 2018-09-15T09:57:49 | 148,628,762 | 0 | 2 | null | null | null | null | UHC | C++ | false | false | 27,052 | cpp | // ExceptionHandler.cpp Version 1.4
//
// Copyright ?1998 Bruce Dawson
//
// This source file contains the exception handler for recording error
// information after crashes. See ExceptionHandler.h for information
// on how to hook it in.
//
// Author: Bruce Dawson
// brucedawson@cygnus-software.com
//
// Modified by: Hans Dietrich
// hdietrich2@hotmail.com
//
// Version 1.4: - Added invocation of XCrashReport.exe
//
// Version 1.3: - Added minidump output
//
// Version 1.1: - reformatted output for XP-like error report
// - added ascii output to stack dump
//
// A paper by the original author can be found at:
// http://www.cygnus-software.com/papers/release_debugging.html
//
///////////////////////////////////////////////////////////////////////////////
// Disable warnings generated by the Windows header files.
#pragma warning(disable : 4514)
#pragma warning(disable : 4201)
#pragma warning(disable : 4995)
#define _WIN32_WINDOWS 0x0500 // for IsDebuggerPresent
// comment out this line if you don't want minidumps
#define XCRASHREPORT_WRITE_MINIDUMP
// does not require MFC; use 'Not using precompiled headers'
#include "windows.h"
#include <tchar.h>
#include "GetWinVer.h"
#include "miniversion.h"
#include "dbghelp.h"
#include "CrashFileNames.h"
#include "strsafe.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#ifndef _countof
#define _countof(array) (sizeof(array)/sizeof(array[0]))
#endif
const int NumCodeBytes = 16; // Number of code bytes to record.
const int MaxStackDump = 3072; // Maximum number of DWORDS in stack dumps.
const int StackColumns = 4; // Number of columns in stack dump.
#define ONEK 1024
#define SIXTYFOURK (64*ONEK)
#define ONEM (ONEK*ONEK)
#define ONEG (ONEK*ONEK*ONEK)
_MINIDUMP_TYPE g_emMiniDumpTYPE = MiniDumpNormal;
void _SETDUMPTYPE ( int nTYPE )
{
g_emMiniDumpTYPE = (_MINIDUMP_TYPE) nTYPE;
}
///////////////////////////////////////////////////////////////////////////////
// lstrrchr (avoid the C Runtime )
static TCHAR * lstrrchr(LPCTSTR string, int ch)
{
TCHAR *start = (TCHAR *)string;
while (*string++) /* find end of string */
;
/* search towards front */
while (--string != start && *string != (TCHAR) ch)
;
if (*string == (TCHAR) ch) /* char found ? */
return (TCHAR *)string;
return NULL;
}
///////////////////////////////////////////////////////////////////////////////
// hprintf behaves similarly to printf, with a few vital differences.
// It uses wvsprintf to do the formatting, which is a system routine,
// thus avoiding C run time interactions. For similar reasons it
// uses WriteFile rather than fwrite.
// The one limitation that this imposes is that wvsprintf, and
// therefore hprintf, cannot handle floating point numbers.
// Too many calls to WriteFile can take a long time, causing
// confusing delays when programs crash. Therefore I implemented
// a simple buffering scheme for hprintf
#define HPRINTF_BUFFER_SIZE (8*1024) // must be at least 2048
static TCHAR hprintf_buffer[HPRINTF_BUFFER_SIZE]; // wvsprintf never prints more than one K.
static int hprintf_index = 0;
///////////////////////////////////////////////////////////////////////////////
// hflush
static void hflush(HANDLE LogFile)
{
if (hprintf_index > 0)
{
DWORD NumBytes;
WriteFile(LogFile, hprintf_buffer, lstrlen(hprintf_buffer), &NumBytes, 0);
hprintf_index = 0;
}
}
///////////////////////////////////////////////////////////////////////////////
// hprintf
static void hprintf(HANDLE LogFile, LPCTSTR Format, ...)
{
if (hprintf_index > (HPRINTF_BUFFER_SIZE-1024))
{
DWORD NumBytes;
WriteFile(LogFile, hprintf_buffer, lstrlen(hprintf_buffer), &NumBytes, 0);
hprintf_index = 0;
}
va_list arglist;
va_start( arglist, Format);
hprintf_index += wvsprintf(&hprintf_buffer[hprintf_index], Format, arglist);
va_end( arglist);
}
#ifdef XCRASHREPORT_WRITE_MINIDUMP
///////////////////////////////////////////////////////////////////////////////
// DumpMiniDump
static void DumpMiniDump(HANDLE hFile, PEXCEPTION_POINTERS excpInfo)
{
if (excpInfo == NULL)
{
// Generate exception to get proper context in dump
__try
{
OutputDebugString(_T("raising exception\r\n"));
RaiseException(EXCEPTION_BREAKPOINT, 0, 0, NULL);
}
__except(DumpMiniDump(hFile, GetExceptionInformation()),
EXCEPTION_CONTINUE_EXECUTION)
{
}
}
else
{
OutputDebugString(_T("writing minidump\r\n"));
MINIDUMP_EXCEPTION_INFORMATION eInfo;
eInfo.ThreadId = GetCurrentThreadId();
eInfo.ExceptionPointers = excpInfo;
eInfo.ClientPointers = FALSE;
// note: MiniDumpWithIndirectlyReferencedMemory does not work on Win98
// Note : 다음 클라이언트는 메모리를 소량만 덤프함, 아닌 경우 모든 매모리 덤프.
//
MiniDumpWriteDump(
GetCurrentProcess(),
GetCurrentProcessId(),
hFile,
g_emMiniDumpTYPE,
excpInfo ? &eInfo : NULL,
NULL,
NULL);
}
}
#endif // XCRASHREPORT_WRITE_MINIDUMP
///////////////////////////////////////////////////////////////////////////////
// FormatTime
//
// Format the specified FILETIME to output in a human readable format,
// without using the C run time.
static void FormatTime(LPTSTR output, FILETIME TimeToPrint)
{
output[0] = _T('\0');
WORD Date, Time;
if (FileTimeToLocalFileTime(&TimeToPrint, &TimeToPrint) &&
FileTimeToDosDateTime(&TimeToPrint, &Date, &Time))
{
wsprintf(output, _T("%d/%d/%d %02d:%02d:%02d"),
(Date / 32) & 15, Date & 31, (Date / 512) + 1980,
(Time >> 11), (Time >> 5) & 0x3F, (Time & 0x1F) * 2);
}
}
///////////////////////////////////////////////////////////////////////////////
// DumpModuleInfo
//
// Print information about a code module (DLL or EXE) such as its size,
// location, time stamp, etc.
static bool DumpModuleInfo(HANDLE LogFile, HINSTANCE ModuleHandle, int nModuleNo)
{
bool rc = false;
TCHAR szModName[MAX_PATH*2];
SecureZeroMemory(szModName, sizeof(szModName));
__try
{
if (GetModuleFileName(ModuleHandle, szModName, sizeof(szModName)-2) > 0)
{
// If GetModuleFileName returns greater than zero then this must
// be a valid code module address. Therefore we can try to walk
// our way through its structures to find the link time stamp.
IMAGE_DOS_HEADER *DosHeader = (IMAGE_DOS_HEADER*)ModuleHandle;
if (IMAGE_DOS_SIGNATURE != DosHeader->e_magic)
return false;
IMAGE_NT_HEADERS *NTHeader = (IMAGE_NT_HEADERS*)((TCHAR *)DosHeader
+ DosHeader->e_lfanew);
if (IMAGE_NT_SIGNATURE != NTHeader->Signature)
return false;
// open the code module file so that we can get its file date and size
HANDLE ModuleFile = CreateFile(szModName, GENERIC_READ,
FILE_SHARE_READ, 0, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0);
TCHAR TimeBuffer[100];
TimeBuffer[0] = _T('\0');
DWORD FileSize = 0;
if (ModuleFile != INVALID_HANDLE_VALUE)
{
FileSize = GetFileSize(ModuleFile, 0);
FILETIME LastWriteTime;
if (GetFileTime(ModuleFile, 0, 0, &LastWriteTime))
{
FormatTime(TimeBuffer, LastWriteTime);
}
CloseHandle(ModuleFile);
}
hprintf(LogFile, _T("Module %d\r\n"), nModuleNo);
hprintf(LogFile, _T("%s\r\n"), szModName);
hprintf(LogFile, _T("Image Base: 0x%08x Image Size: 0x%08x\r\n"),
NTHeader->OptionalHeader.ImageBase,
NTHeader->OptionalHeader.SizeOfImage),
hprintf(LogFile, _T("Checksum: 0x%08x Time Stamp: 0x%08x\r\n"),
NTHeader->OptionalHeader.CheckSum,
NTHeader->FileHeader.TimeDateStamp);
hprintf(LogFile, _T("File Size: %-10d File Time: %s\r\n"),
FileSize, TimeBuffer);
hprintf(LogFile, _T("Version Information:\r\n"));
CMiniVersion ver(szModName);
TCHAR szBuf[200];
WORD dwBuf[4];
ver.GetCompanyName(szBuf, sizeof(szBuf)-1);
hprintf(LogFile, _T(" Company: %s\r\n"), szBuf);
ver.GetProductName(szBuf, sizeof(szBuf)-1);
hprintf(LogFile, _T(" Product: %s\r\n"), szBuf);
ver.GetFileDescription(szBuf, sizeof(szBuf)-1);
hprintf(LogFile, _T(" FileDesc: %s\r\n"), szBuf);
ver.GetFileVersion(dwBuf);
hprintf(LogFile, _T(" FileVer: %d.%d.%d.%d\r\n"),
dwBuf[0], dwBuf[1], dwBuf[2], dwBuf[3]);
ver.GetProductVersion(dwBuf);
hprintf(LogFile, _T(" ProdVer: %d.%d.%d.%d\r\n"),
dwBuf[0], dwBuf[1], dwBuf[2], dwBuf[3]);
ver.Release();
hprintf(LogFile, _T("\r\n"));
rc = true;
}
}
// Handle any exceptions by continuing from this point.
__except(EXCEPTION_EXECUTE_HANDLER)
{
}
return rc;
}
///////////////////////////////////////////////////////////////////////////////
// DumpModuleList
//
// Scan memory looking for code modules (DLLs or EXEs). VirtualQuery is used
// to find all the blocks of address space that were reserved or committed,
// and ShowModuleInfo will display module information if they are code
// modules.
static void DumpModuleList(HANDLE LogFile)
{
SYSTEM_INFO SystemInfo;
GetSystemInfo(&SystemInfo);
const size_t PageSize = SystemInfo.dwPageSize;
// Set NumPages to the number of pages in the 4GByte address space,
// while being careful to avoid overflowing ints
const size_t NumPages = 4 * size_t(ONEG / PageSize);
size_t pageNum = 0;
void *LastAllocationBase = 0;
int nModuleNo = 1;
while (pageNum < NumPages)
{
MEMORY_BASIC_INFORMATION MemInfo;
if (VirtualQuery((void *)(pageNum * PageSize), &MemInfo,
sizeof(MemInfo)))
{
if (MemInfo.RegionSize > 0)
{
// Adjust the page number to skip over this block of memory
pageNum += MemInfo.RegionSize / PageSize;
if (MemInfo.State == MEM_COMMIT && MemInfo.AllocationBase >
LastAllocationBase)
{
// Look for new blocks of committed memory, and try
// recording their module names - this will fail
// gracefully if they aren't code modules
LastAllocationBase = MemInfo.AllocationBase;
if (DumpModuleInfo(LogFile,
(HINSTANCE)LastAllocationBase,
nModuleNo))
{
nModuleNo++;
}
}
}
else
pageNum += SIXTYFOURK / PageSize;
}
else
pageNum += SIXTYFOURK / PageSize;
// If VirtualQuery fails we advance by 64K because that is the
// granularity of address space doled out by VirtualAlloc()
}
}
///////////////////////////////////////////////////////////////////////////////
// DumpSystemInformation
//
// Record information about the user's system, such as processor type, amount
// of memory, etc.
static void DumpSystemInformation(HANDLE LogFile)
{
FILETIME CurrentTime;
GetSystemTimeAsFileTime(&CurrentTime);
TCHAR szTimeBuffer[100];
FormatTime(szTimeBuffer, CurrentTime);
hprintf(LogFile, _T("Error occurred at %s.\r\n"), szTimeBuffer);
TCHAR szModuleName[MAX_PATH*2];
SecureZeroMemory(szModuleName, sizeof(szModuleName));
if (GetModuleFileName(0, szModuleName, _countof(szModuleName)-2) <= 0)
StringCchCopy ( szModuleName, MAX_PATH*2, _T("Unknown") );
TCHAR szUserName[200];
SecureZeroMemory(szUserName, sizeof(szUserName));
DWORD UserNameSize = _countof(szUserName)-2;
if (!GetUserName(szUserName, &UserNameSize))
StringCchCopy ( szUserName, 200, _T("Unknown"));
hprintf(LogFile, _T("%s, run by %s.\r\n"), szModuleName, szUserName);
// print out operating system
TCHAR szWinVer[50], szMajorMinorBuild[50];
int nWinVer;
GetWinVer(szWinVer, &nWinVer, szMajorMinorBuild);
hprintf(LogFile, _T("Operating system: %s (%s).\r\n"),
szWinVer, szMajorMinorBuild);
SYSTEM_INFO SystemInfo;
GetSystemInfo(&SystemInfo);
hprintf(LogFile, _T("%d processor(s), type %d.\r\n"),
SystemInfo.dwNumberOfProcessors, SystemInfo.dwProcessorType);
MEMORYSTATUS MemInfo;
MemInfo.dwLength = sizeof(MemInfo);
GlobalMemoryStatus(&MemInfo);
// Print out info on memory, rounded up.
hprintf(LogFile, _T("%d%% memory in use.\r\n"), MemInfo.dwMemoryLoad);
hprintf(LogFile, _T("%d MBytes physical memory.\r\n"), (MemInfo.dwTotalPhys +
ONEM - 1) / ONEM);
hprintf(LogFile, _T("%d MBytes physical memory free.\r\n"),
(MemInfo.dwAvailPhys + ONEM - 1) / ONEM);
hprintf(LogFile, _T("%d MBytes paging file.\r\n"), (MemInfo.dwTotalPageFile +
ONEM - 1) / ONEM);
hprintf(LogFile, _T("%d MBytes paging file free.\r\n"),
(MemInfo.dwAvailPageFile + ONEM - 1) / ONEM);
hprintf(LogFile, _T("%d MBytes user address space.\r\n"),
(MemInfo.dwTotalVirtual + ONEM - 1) / ONEM);
hprintf(LogFile, _T("%d MBytes user address space free.\r\n"),
(MemInfo.dwAvailVirtual + ONEM - 1) / ONEM);
}
///////////////////////////////////////////////////////////////////////////////
// GetExceptionDescription
//
// Translate the exception code into something human readable
static const TCHAR *GetExceptionDescription(DWORD ExceptionCode)
{
struct ExceptionNames
{
DWORD ExceptionCode;
TCHAR * ExceptionName;
};
#if 0 // from winnt.h
#define STATUS_WAIT_0 ((DWORD )0x00000000L)
#define STATUS_ABANDONED_WAIT_0 ((DWORD )0x00000080L)
#define STATUS_USER_APC ((DWORD )0x000000C0L)
#define STATUS_TIMEOUT ((DWORD )0x00000102L)
#define STATUS_PENDING ((DWORD )0x00000103L)
#define STATUS_SEGMENT_NOTIFICATION ((DWORD )0x40000005L)
#define STATUS_GUARD_PAGE_VIOLATION ((DWORD )0x80000001L)
#define STATUS_DATATYPE_MISALIGNMENT ((DWORD )0x80000002L)
#define STATUS_BREAKPOINT ((DWORD )0x80000003L)
#define STATUS_SINGLE_STEP ((DWORD )0x80000004L)
#define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L)
#define STATUS_IN_PAGE_ERROR ((DWORD )0xC0000006L)
#define STATUS_INVALID_HANDLE ((DWORD )0xC0000008L)
#define STATUS_NO_MEMORY ((DWORD )0xC0000017L)
#define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL)
#define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L)
#define STATUS_INVALID_DISPOSITION ((DWORD )0xC0000026L)
#define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD )0xC000008CL)
#define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD )0xC000008DL)
#define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD )0xC000008EL)
#define STATUS_FLOAT_INEXACT_RESULT ((DWORD )0xC000008FL)
#define STATUS_FLOAT_INVALID_OPERATION ((DWORD )0xC0000090L)
#define STATUS_FLOAT_OVERFLOW ((DWORD )0xC0000091L)
#define STATUS_FLOAT_STACK_CHECK ((DWORD )0xC0000092L)
#define STATUS_FLOAT_UNDERFLOW ((DWORD )0xC0000093L)
#define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD )0xC0000094L)
#define STATUS_INTEGER_OVERFLOW ((DWORD )0xC0000095L)
#define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L)
#define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL)
#define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL)
#define STATUS_FLOAT_MULTIPLE_FAULTS ((DWORD )0xC00002B4L)
#define STATUS_FLOAT_MULTIPLE_TRAPS ((DWORD )0xC00002B5L)
#define STATUS_ILLEGAL_VLM_REFERENCE ((DWORD )0xC00002C0L)
#endif
ExceptionNames ExceptionMap[] =
{
{0x40010005, _T("a Control-C")},
{0x40010008, _T("a Control-Break")},
{0x80000002, _T("a Datatype Misalignment")},
{0x80000003, _T("a Breakpoint")},
{0xc0000005, _T("an Access Violation")},
{0xc0000006, _T("an In Page Error")},
{0xc0000017, _T("a No Memory")},
{0xc000001d, _T("an Illegal Instruction")},
{0xc0000025, _T("a Noncontinuable Exception")},
{0xc0000026, _T("an Invalid Disposition")},
{0xc000008c, _T("a Array Bounds Exceeded")},
{0xc000008d, _T("a Float Denormal Operand")},
{0xc000008e, _T("a Float Divide by Zero")},
{0xc000008f, _T("a Float Inexact Result")},
{0xc0000090, _T("a Float Invalid Operation")},
{0xc0000091, _T("a Float Overflow")},
{0xc0000092, _T("a Float Stack Check")},
{0xc0000093, _T("a Float Underflow")},
{0xc0000094, _T("an Integer Divide by Zero")},
{0xc0000095, _T("an Integer Overflow")},
{0xc0000096, _T("a Privileged Instruction")},
{0xc00000fD, _T("a Stack Overflow")},
{0xc0000142, _T("a DLL Initialization Failed")},
{0xe06d7363, _T("a Microsoft C++ Exception")},
};
for (int i = 0; i < sizeof(ExceptionMap) / sizeof(ExceptionMap[0]); i++)
if (ExceptionCode == ExceptionMap[i].ExceptionCode)
return ExceptionMap[i].ExceptionName;
return _T("an Unknown exception type");
}
///////////////////////////////////////////////////////////////////////////////
// GetFilePart
static TCHAR * GetFilePart(LPCTSTR source)
{
TCHAR *result = lstrrchr(source, _T('\\'));
if (result)
result++;
else
result = (TCHAR *)source;
return result;
}
///////////////////////////////////////////////////////////////////////////////
// DumpStack
static void DumpStack(HANDLE LogFile, DWORD *pStack)
{
hprintf(LogFile, _T("\r\n\r\nStack:\r\n"));
__try
{
// Esp contains the bottom of the stack, or at least the bottom of
// the currently used area.
DWORD* pStackTop;
__asm
{
// Load the top (highest address) of the stack from the
// thread information block. It will be found there in
// Win9x and Windows NT.
mov eax, fs:[4]
mov pStackTop, eax
}
if (pStackTop > pStack + MaxStackDump)
pStackTop = pStack + MaxStackDump;
int Count = 0;
DWORD* pStackStart = pStack;
int nDwordsPrinted = 0;
while (pStack + 1 <= pStackTop)
{
if ((Count % StackColumns) == 0)
{
pStackStart = pStack;
nDwordsPrinted = 0;
hprintf(LogFile, _T("0x%08x: "), pStack);
}
if ((++Count % StackColumns) == 0 || pStack + 2 > pStackTop)
{
hprintf(LogFile, _T("%08x "), *pStack);
nDwordsPrinted++;
int n = nDwordsPrinted;
while (n < 4)
{
hprintf(LogFile, _T(" "));
n++;
}
for (int i = 0; i < nDwordsPrinted; ++i)
{
DWORD dwStack = *pStackStart;
for (int j = 0; j < 4; ++j)
{
char c = (char)(dwStack & 0xFF);
if (c < 0x20 || c > 0x7E)
c = '.';
#ifdef _UNICODE
WCHAR w = (WCHAR)c;
hprintf(LogFile, _T("%c"), w);
#else
hprintf(LogFile, _T("%c"), c);
#endif
dwStack = dwStack >> 8;
}
pStackStart++;
}
hprintf(LogFile, _T("\r\n"));
}
else
{
hprintf(LogFile, _T("%08x "), *pStack);
nDwordsPrinted++;
}
pStack++;
}
hprintf(LogFile, _T("\r\n"));
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
hprintf(LogFile, _T("Exception encountered during stack dump.\r\n"));
}
}
///////////////////////////////////////////////////////////////////////////////
// DumpRegisters
static void DumpRegisters(HANDLE LogFile, PCONTEXT Context)
{
// Print out the register values in an XP error window compatible format.
hprintf(LogFile, _T("\r\n"));
hprintf(LogFile, _T("Context:\r\n"));
hprintf(LogFile, _T("EDI: 0x%08x ESI: 0x%08x EAX: 0x%08x\r\n"),
Context->Edi, Context->Esi, Context->Eax);
hprintf(LogFile, _T("EBX: 0x%08x ECX: 0x%08x EDX: 0x%08x\r\n"),
Context->Ebx, Context->Ecx, Context->Edx);
hprintf(LogFile, _T("EIP: 0x%08x EBP: 0x%08x SegCs: 0x%08x\r\n"),
Context->Eip, Context->Ebp, Context->SegCs);
hprintf(LogFile, _T("EFlags: 0x%08x ESP: 0x%08x SegSs: 0x%08x\r\n"),
Context->EFlags, Context->Esp, Context->SegSs);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//
// RecordExceptionInfo
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
int __cdecl RecordExceptionInfo(PEXCEPTION_POINTERS pExceptPtrs,
LPCTSTR lpszMessage)
{
static bool bFirstTime = true;
if (!bFirstTime) // Going recursive! That must mean this routine crashed!
return EXCEPTION_CONTINUE_SEARCH;
bFirstTime = false;
// Create a filename to record the error information to.
// Storing it in the executable directory works well.
TCHAR szModuleName[MAX_PATH*2];
SecureZeroMemory(szModuleName, sizeof(szModuleName));
if (GetModuleFileName(0, szModuleName, _countof(szModuleName)-2) <= 0)
StringCchCopy ( szModuleName, MAX_PATH*2, _T("Unknown") );
TCHAR *pszFilePart = GetFilePart(szModuleName);
// Extract the file name portion and remove it's file extension
TCHAR szFileName[MAX_PATH*2];
StringCchCopy ( szFileName, MAX_PATH*2, pszFilePart );
TCHAR *lastperiod = lstrrchr(szFileName, _T('.'));
if (lastperiod)
lastperiod[0] = 0;
// Replace the executable filename with our error log file name
StringCchCopy ( pszFilePart, MAX_PATH*2, XCRASHREPORT_ERROR_LOG_FILE);
HANDLE hLogFile = CreateFile(szModuleName, GENERIC_WRITE, 0, 0,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, 0);
if (hLogFile == INVALID_HANDLE_VALUE)
{
OutputDebugString(_T("Error creating exception report\r\n"));
return EXCEPTION_CONTINUE_SEARCH;
}
// Append to the error log
SetFilePointer(hLogFile, 0, 0, FILE_END);
// Print out a blank line to separate this error log from any previous ones
//hprintf(hLogFile, _T("\r\n"));
PEXCEPTION_RECORD Exception = pExceptPtrs->ExceptionRecord;
PCONTEXT Context = pExceptPtrs->ContextRecord;
TCHAR szCrashModulePathName[MAX_PATH*2];
SecureZeroMemory(szCrashModulePathName, sizeof(szCrashModulePathName));
TCHAR *pszCrashModuleFileName = _T("Unknown");
MEMORY_BASIC_INFORMATION MemInfo;
// VirtualQuery can be used to get the allocation base associated with a
// code address, which is the same as the ModuleHandle. This can be used
// to get the filename of the module that the crash happened in.
if (VirtualQuery((void*)Context->Eip, &MemInfo, sizeof(MemInfo)) &&
(GetModuleFileName((HINSTANCE)MemInfo.AllocationBase,
szCrashModulePathName,
sizeof(szCrashModulePathName)-2) > 0))
{
pszCrashModuleFileName = GetFilePart(szCrashModulePathName);
}
// Print out the beginning of the error log in a Win95 error window
// compatible format.
hprintf(hLogFile, _T("%s caused %s (0x%08x) \r\nin module %s at %04x:%08x.\r\n\r\n"),
szFileName, GetExceptionDescription(Exception->ExceptionCode),
Exception->ExceptionCode,
pszCrashModuleFileName, Context->SegCs, Context->Eip);
hprintf(hLogFile, _T("Exception handler called in %s.\r\n"), lpszMessage);
DumpSystemInformation(hLogFile);
// If the exception was an access violation, print out some additional
// information, to the error log and the debugger.
if (Exception->ExceptionCode == STATUS_ACCESS_VIOLATION &&
Exception->NumberParameters >= 2)
{
TCHAR szDebugMessage[1000];
const TCHAR* readwrite = _T("Read from");
if (Exception->ExceptionInformation[0])
readwrite = _T("Write to");
wsprintf(szDebugMessage, _T("%s location %08x caused an access violation.\r\n"),
readwrite, Exception->ExceptionInformation[1]);
#ifdef _DEBUG
// The Visual C++ debugger doesn't actually tell you whether a read
// or a write caused the access violation, nor does it tell what
// address was being read or written. So I fixed that.
OutputDebugString(_T("Exception handler: "));
OutputDebugString(szDebugMessage);
#endif
hprintf(hLogFile, _T("%s"), szDebugMessage);
}
DumpRegisters(hLogFile, Context);
// Print out the bytes of code at the instruction pointer. Since the
// crash may have been caused by an instruction pointer that was bad,
// this code needs to be wrapped in an exception handler, in case there
// is no memory to read. If the dereferencing of code[] fails, the
// exception handler will print '??'.
hprintf(hLogFile, _T("\r\nBytes at CS:EIP:\r\n"));
BYTE * code = (BYTE *)Context->Eip;
for (int codebyte = 0; codebyte < NumCodeBytes; ++codebyte)
{
__try
{
hprintf(hLogFile, _T("%02x "), code[codebyte]);
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
hprintf(hLogFile, _T("?? "));
}
}
// Time to print part or all of the stack to the error log. This allows
// us to figure out the call stack, parameters, local variables, etc.
// Esp contains the bottom of the stack, or at least the bottom of
// the currently used area
DWORD* pStack = (DWORD *)Context->Esp;
DumpStack(hLogFile, pStack);
DumpModuleList(hLogFile);
hprintf(hLogFile, _T("\r\n===== [end of %s] =====\r\n"),
XCRASHREPORT_ERROR_LOG_FILE);
hflush(hLogFile);
CloseHandle(hLogFile);
///////////////////////////////////////////////////////////////////////////
//
// write minidump
//
///////////////////////////////////////////////////////////////////////////
#ifdef XCRASHREPORT_WRITE_MINIDUMP
// Replace the filename with our minidump file name
StringCchCopy ( pszFilePart, MAX_PATH*2, XCRASHREPORT_MINI_DUMP_FILE);
// Create the file
HANDLE hMiniDumpFile = CreateFile(
szModuleName,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH,
NULL);
// Write the minidump to the file
if (hMiniDumpFile != INVALID_HANDLE_VALUE)
{
DumpMiniDump(hMiniDumpFile, pExceptPtrs);
// Close file
CloseHandle(hMiniDumpFile);
}
#endif // XCRASHREPORT_WRITE_MINIDUMP
if (IsDebuggerPresent())
{
// let the debugger catch this -
// return the magic value which tells Win32 that this handler didn't
// actually handle the exception - so that things will proceed as per
// normal.
return EXCEPTION_CONTINUE_SEARCH;
}
else
{
///////////////////////////////////////////////////////////////////////
//
// pop up our crash report app
//
///////////////////////////////////////////////////////////////////////
// Replace the filename with our crash report exe file name
StringCchCopy ( pszFilePart, MAX_PATH*2, XCRASHREPORT_CRASH_REPORT_APP );
TCHAR szCommandLine[MAX_PATH] = {0};
StringCchCopy ( szCommandLine, MAX_PATH, szModuleName );
lstrcat(szCommandLine, _T(" \"")); // surround app name with quotes
SecureZeroMemory(szModuleName, sizeof(szModuleName));
GetModuleFileName(0, szModuleName, _countof(szModuleName)-2);
lstrcat(szCommandLine, GetFilePart(szModuleName));
lstrcat(szCommandLine, _T("\""));
STARTUPINFO si;
SecureZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
PROCESS_INFORMATION pi;
SecureZeroMemory(&pi, sizeof(pi));
if (CreateProcess(
NULL, // name of executable module
szCommandLine, // command line string
NULL, // process attributes
NULL, // thread attributes
FALSE, // handle inheritance option
0, // creation flags
NULL, // new environment block
NULL, // current directory name
&si, // startup information
&pi)) // process information
{
// XCrashReport.exe was successfully started, so
// suppress the standard crash dialog
return EXCEPTION_EXECUTE_HANDLER;
}
else
{
// XCrashReport.exe was not started - let
// the standard crash dialog appear
return EXCEPTION_CONTINUE_SEARCH;
}
}
}
| [
"markcalimosa@gmail.com"
] | markcalimosa@gmail.com |
db3da8ccf197d9374e51aea8d1fe7f369074f420 | a97b9ad50e283b4e930ab59547806eb303b52c6f | /class/4nov_plate_kwSST/180/k | 9e239d8066be6f7f0ae4083e1c3f5f2fa1881a20 | [] | no_license | harrisbk/OpenFOAM_run | fdcd4f81bd3205764988ea95c25fd2a5c130841b | 9591c98336561bcfb3b7259617b5363aacf48067 | refs/heads/master | 2016-09-05T08:45:27.965608 | 2015-11-16T19:08:34 | 2015-11-16T19:08:34 | 42,883,543 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 101,291 | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.4.0 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "180";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
10000
(
0.0700316
0.0663837
0.0634219
0.0609864
0.0589596
0.0572549
0.055811
0.0545825
0.0535324
0.052631
0.0518543
0.0511827
0.0506006
0.0500944
0.0496529
0.0492647
0.0489158
0.0485794
0.0481766
0.0472874
0.0700316
0.0663837
0.0634219
0.0609864
0.0589596
0.0572549
0.0558111
0.0545825
0.0535325
0.0526311
0.0518543
0.0511829
0.0506007
0.0500946
0.0496531
0.0492652
0.0489174
0.0485867
0.0482211
0.04768
0.0700316
0.0663837
0.0634219
0.0609863
0.0589596
0.057255
0.0558111
0.0545826
0.0535325
0.0526311
0.0518544
0.0511829
0.0506007
0.0500946
0.0496532
0.0492657
0.0489198
0.048597
0.0482657
0.0478729
0.0700316
0.0663837
0.0634219
0.0609863
0.0589596
0.057255
0.0558112
0.0545826
0.0535326
0.0526311
0.0518544
0.0511828
0.0506006
0.0500945
0.0496532
0.0492662
0.0489224
0.0486073
0.0483009
0.0479781
0.0700316
0.0663836
0.0634218
0.0609863
0.0589596
0.0572551
0.0558112
0.0545827
0.0535326
0.0526312
0.0518543
0.0511827
0.0506005
0.0500943
0.0496531
0.0492666
0.0489248
0.048616
0.0483264
0.0480411
0.0700316
0.0663836
0.0634218
0.0609862
0.0589596
0.0572551
0.0558113
0.0545828
0.0535327
0.0526312
0.0518543
0.0511827
0.0506003
0.0500941
0.0496529
0.0492669
0.0489266
0.0486225
0.048344
0.0480802
0.0700315
0.0663836
0.0634217
0.0609862
0.0589596
0.0572552
0.0558115
0.0545829
0.0535328
0.0526312
0.0518543
0.0511826
0.0506002
0.0500939
0.0496527
0.049267
0.0489279
0.048627
0.0483555
0.0481044
0.0700315
0.0663836
0.0634217
0.0609861
0.0589596
0.0572553
0.0558117
0.0545831
0.0535329
0.0526313
0.0518543
0.0511825
0.0506
0.0500937
0.0496525
0.049267
0.0489287
0.0486299
0.0483628
0.0481192
0.0700315
0.0663835
0.0634216
0.0609861
0.0589596
0.0572555
0.0558119
0.0545833
0.0535331
0.0526315
0.0518545
0.0511826
0.0506
0.0500935
0.0496523
0.0492669
0.0489291
0.0486316
0.0483671
0.048128
0.0700315
0.0663835
0.0634215
0.060986
0.0589596
0.0572557
0.0558122
0.0545836
0.0535334
0.0526318
0.0518546
0.0511827
0.0506
0.0500935
0.0496521
0.0492667
0.0489293
0.0486325
0.0483694
0.048133
0.0700314
0.0663834
0.0634215
0.0609859
0.0589596
0.0572559
0.0558125
0.054584
0.0535338
0.0526321
0.0518549
0.0511829
0.0506001
0.0500935
0.0496521
0.0492667
0.0489293
0.0486329
0.0483707
0.0481356
0.0700314
0.0663834
0.0634214
0.0609858
0.0589597
0.0572561
0.0558129
0.0545845
0.0535343
0.0526325
0.0518553
0.0511833
0.0506004
0.0500937
0.0496522
0.0492667
0.0489294
0.0486331
0.0483713
0.0481369
0.0700314
0.0663833
0.0634213
0.0609857
0.0589597
0.0572564
0.0558134
0.054585
0.0535348
0.0526331
0.0518559
0.0511838
0.0506008
0.050094
0.0496525
0.0492669
0.0489295
0.0486333
0.0483716
0.0481376
0.0700313
0.0663833
0.0634212
0.0609856
0.0589597
0.0572567
0.055814
0.0545857
0.0535355
0.0526338
0.0518566
0.0511844
0.0506014
0.0500946
0.0496529
0.0492673
0.0489298
0.0486335
0.0483718
0.0481379
0.0700313
0.0663832
0.0634211
0.0609855
0.0589598
0.0572571
0.0558146
0.0545864
0.0535363
0.0526346
0.0518574
0.0511852
0.0506022
0.0500953
0.0496536
0.0492679
0.0489303
0.0486339
0.0483722
0.0481382
0.0700312
0.0663831
0.063421
0.0609853
0.0589598
0.0572575
0.0558153
0.0545873
0.0535373
0.0526356
0.0518584
0.0511862
0.0506032
0.0500962
0.0496545
0.0492687
0.048931
0.0486346
0.0483727
0.0481387
0.0700312
0.066383
0.0634208
0.0609852
0.0589598
0.0572579
0.0558161
0.0545883
0.0535383
0.0526367
0.0518595
0.0511874
0.0506043
0.0500974
0.0496556
0.0492697
0.048932
0.0486355
0.0483735
0.0481394
0.0700311
0.0663829
0.0634207
0.0609851
0.0589598
0.0572583
0.055817
0.0545894
0.0535395
0.052638
0.0518608
0.0511887
0.0506057
0.0500987
0.0496569
0.049271
0.0489332
0.0486366
0.0483746
0.0481404
0.070031
0.0663828
0.0634206
0.0609849
0.0589598
0.0572588
0.0558179
0.0545906
0.0535409
0.0526394
0.0518623
0.0511902
0.0506073
0.0501003
0.0496585
0.0492726
0.0489348
0.0486381
0.048376
0.0481417
0.070031
0.0663827
0.0634204
0.0609847
0.0589598
0.0572592
0.0558188
0.0545919
0.0535423
0.052641
0.051864
0.051192
0.0506091
0.0501021
0.0496603
0.0492744
0.0489365
0.0486398
0.0483777
0.0481433
0.0700309
0.0663826
0.0634203
0.0609846
0.0589598
0.0572596
0.0558198
0.0545933
0.053544
0.0526428
0.0518659
0.0511939
0.050611
0.0501042
0.0496624
0.0492765
0.0489386
0.0486419
0.0483797
0.0481453
0.0700308
0.0663825
0.0634201
0.0609844
0.0589597
0.05726
0.0558209
0.0545948
0.0535457
0.0526447
0.0518679
0.0511961
0.0506133
0.0501064
0.0496647
0.0492788
0.048941
0.0486442
0.048382
0.0481476
0.0700307
0.0663824
0.06342
0.0609842
0.0589597
0.0572604
0.0558219
0.0545964
0.0535476
0.0526468
0.0518701
0.0511984
0.0506157
0.0501089
0.0496672
0.0492814
0.0489436
0.0486468
0.0483846
0.0481502
0.0700306
0.0663823
0.0634198
0.060984
0.0589596
0.0572607
0.0558229
0.054598
0.0535497
0.052649
0.0518726
0.051201
0.0506184
0.0501117
0.04967
0.0492843
0.0489465
0.0486498
0.0483876
0.0481531
0.0700305
0.0663822
0.0634196
0.0609838
0.0589594
0.057261
0.0558238
0.0545996
0.0535518
0.0526515
0.0518752
0.0512037
0.0506212
0.0501147
0.0496731
0.0492874
0.0489497
0.048653
0.0483908
0.0481564
0.0700304
0.0663821
0.0634195
0.0609836
0.0589593
0.0572612
0.0558247
0.0546012
0.053554
0.052654
0.051878
0.0512067
0.0506244
0.0501179
0.0496764
0.0492908
0.0489532
0.0486565
0.0483944
0.04816
0.0700303
0.0663819
0.0634193
0.0609834
0.0589592
0.0572613
0.0558254
0.0546028
0.0535562
0.0526567
0.051881
0.0512099
0.0506277
0.0501214
0.04968
0.0492945
0.0489569
0.0486604
0.0483983
0.0481639
0.0700302
0.0663818
0.0634191
0.0609832
0.058959
0.0572614
0.0558261
0.0546042
0.0535584
0.0526594
0.0518841
0.0512132
0.0506313
0.0501251
0.0496839
0.0492985
0.048961
0.0486645
0.0484025
0.0481682
0.0700301
0.0663817
0.063419
0.060983
0.0589588
0.0572615
0.0558267
0.0546055
0.0535604
0.0526621
0.0518872
0.0512167
0.050635
0.0501291
0.049688
0.0493027
0.0489653
0.0486689
0.048407
0.0481727
0.07003
0.0663816
0.0634188
0.0609828
0.0589587
0.0572615
0.0558272
0.0546067
0.0535624
0.0526647
0.0518904
0.0512203
0.0506389
0.0501332
0.0496923
0.0493072
0.0489699
0.0486736
0.0484118
0.0481776
0.0700299
0.0663814
0.0634187
0.0609826
0.0589585
0.0572615
0.0558275
0.0546077
0.0535641
0.0526672
0.0518935
0.0512239
0.0506428
0.0501374
0.0496968
0.0493118
0.0489747
0.0486786
0.0484168
0.0481827
0.0700298
0.0663813
0.0634186
0.0609825
0.0589584
0.0572615
0.0558278
0.0546085
0.0535656
0.0526694
0.0518963
0.0512273
0.0506467
0.0501416
0.0497013
0.0493166
0.0489796
0.0486836
0.048422
0.048188
0.0700297
0.0663812
0.0634184
0.0609823
0.0589582
0.0572614
0.0558281
0.0546092
0.0535669
0.0526714
0.051899
0.0512305
0.0506504
0.0501457
0.0497057
0.0493213
0.0489846
0.0486888
0.0484273
0.0481934
0.0700296
0.0663811
0.0634183
0.0609822
0.0589581
0.0572614
0.0558283
0.0546098
0.053568
0.0526731
0.0519013
0.0512334
0.0506538
0.0501496
0.04971
0.0493258
0.0489894
0.0486938
0.0484325
0.0481988
0.0700295
0.066381
0.0634182
0.0609821
0.0589581
0.0572614
0.0558285
0.0546103
0.053569
0.0526746
0.0519034
0.0512361
0.050657
0.0501532
0.049714
0.0493302
0.048994
0.0486986
0.0484375
0.0482039
0.0700294
0.0663809
0.0634181
0.060982
0.058958
0.0572615
0.0558287
0.0546108
0.0535698
0.0526759
0.0519052
0.0512384
0.0506598
0.0501564
0.0497176
0.0493341
0.0489983
0.0487032
0.0484422
0.0482088
0.0700293
0.0663808
0.063418
0.060982
0.058958
0.0572615
0.0558289
0.0546112
0.0535706
0.0526771
0.0519068
0.0512404
0.0506623
0.0501594
0.0497209
0.0493378
0.0490022
0.0487074
0.0484466
0.0482134
0.0700292
0.0663807
0.0634179
0.0609819
0.058958
0.0572616
0.0558291
0.0546117
0.0535714
0.0526782
0.0519083
0.0512423
0.0506645
0.050162
0.0497239
0.0493411
0.0490058
0.0487112
0.0484507
0.0482176
0.0700291
0.0663806
0.0634179
0.0609819
0.058958
0.0572618
0.0558294
0.0546121
0.0535721
0.0526792
0.0519096
0.051244
0.0506666
0.0501644
0.0497266
0.0493441
0.0490091
0.0487147
0.0484544
0.0482215
0.070029
0.0663805
0.0634178
0.0609819
0.0589581
0.0572619
0.0558297
0.0546126
0.0535728
0.0526802
0.0519109
0.0512456
0.0506685
0.0501666
0.0497291
0.0493469
0.0490121
0.0487179
0.0484577
0.048225
0.0700289
0.0663804
0.0634178
0.0609819
0.0589582
0.0572621
0.05583
0.0546131
0.0535735
0.0526811
0.0519121
0.051247
0.0506702
0.0501686
0.0497314
0.0493494
0.0490149
0.0487208
0.0484608
0.0482282
0.0700288
0.0663804
0.0634178
0.0609819
0.0589583
0.0572623
0.0558304
0.0546136
0.0535742
0.052682
0.0519132
0.0512484
0.0506719
0.0501705
0.0497335
0.0493517
0.0490174
0.0487235
0.0484637
0.0482312
0.0700287
0.0663803
0.0634177
0.060982
0.0589584
0.0572626
0.0558307
0.0546141
0.0535749
0.0526829
0.0519143
0.0512498
0.0506734
0.0501723
0.0497355
0.0493539
0.0490197
0.048726
0.0484663
0.0482339
0.0700286
0.0663802
0.0634177
0.060982
0.0589586
0.0572628
0.0558311
0.0546147
0.0535755
0.0526838
0.0519154
0.051251
0.0506749
0.0501739
0.0497373
0.0493559
0.0490219
0.0487283
0.0484687
0.0482364
0.0700285
0.0663802
0.0634177
0.0609821
0.0589587
0.057263
0.0558315
0.0546152
0.0535762
0.0526846
0.0519164
0.0512522
0.0506763
0.0501755
0.049739
0.0493578
0.0490239
0.0487304
0.0484709
0.0482387
0.0700284
0.0663801
0.0634177
0.0609822
0.0589589
0.0572633
0.0558318
0.0546157
0.0535769
0.0526854
0.0519174
0.0512534
0.0506776
0.0501769
0.0497406
0.0493595
0.0490257
0.0487324
0.0484729
0.0482409
0.0700284
0.0663801
0.0634177
0.0609822
0.058959
0.0572636
0.0558322
0.0546162
0.0535775
0.0526862
0.0519183
0.0512544
0.0506788
0.0501783
0.0497421
0.0493611
0.0490274
0.0487342
0.0484748
0.0482428
0.0700283
0.0663801
0.0634177
0.0609823
0.0589592
0.0572638
0.0558326
0.0546167
0.0535781
0.052687
0.0519192
0.0512554
0.0506799
0.0501795
0.0497435
0.0493626
0.049029
0.0487358
0.0484765
0.0482446
0.0700282
0.06638
0.0634178
0.0609824
0.0589593
0.0572641
0.0558329
0.0546171
0.0535787
0.0526877
0.05192
0.0512564
0.050681
0.0501807
0.0497447
0.0493639
0.0490304
0.0487373
0.0484781
0.0482462
0.0700282
0.06638
0.0634178
0.0609825
0.0589595
0.0572643
0.0558333
0.0546176
0.0535793
0.0526883
0.0519208
0.0512573
0.0506819
0.0501817
0.0497459
0.0493651
0.0490317
0.0487387
0.0484795
0.0482476
0.0700281
0.06638
0.0634178
0.0609826
0.0589597
0.0572646
0.0558336
0.054618
0.0535798
0.0526889
0.0519215
0.0512581
0.0506828
0.0501827
0.0497469
0.0493663
0.0490329
0.0487399
0.0484808
0.048249
0.0700281
0.06638
0.0634178
0.0609826
0.0589598
0.0572648
0.0558339
0.0546184
0.0535803
0.0526895
0.0519222
0.0512588
0.0506837
0.0501836
0.0497479
0.0493673
0.049034
0.0487411
0.048482
0.0482502
0.070028
0.0663799
0.0634179
0.0609827
0.05896
0.057265
0.0558342
0.0546188
0.0535807
0.0526901
0.0519228
0.0512595
0.0506844
0.0501845
0.0497488
0.0493682
0.049035
0.0487421
0.048483
0.0482513
0.070028
0.0663799
0.0634179
0.0609828
0.0589601
0.0572652
0.0558345
0.0546191
0.0535812
0.0526906
0.0519233
0.0512601
0.0506851
0.0501852
0.0497496
0.0493691
0.0490359
0.048743
0.048484
0.0482523
0.0700279
0.0663799
0.0634179
0.0609829
0.0589602
0.0572654
0.0558348
0.0546195
0.0535816
0.052691
0.0519239
0.0512607
0.0506857
0.0501859
0.0497503
0.0493699
0.0490367
0.0487439
0.0484849
0.0482532
0.0700279
0.0663799
0.0634179
0.060983
0.0589604
0.0572656
0.055835
0.0546198
0.0535819
0.0526914
0.0519243
0.0512612
0.0506863
0.0501865
0.049751
0.0493706
0.0490374
0.0487446
0.0484856
0.048254
0.0700278
0.0663799
0.063418
0.060983
0.0589605
0.0572658
0.0558352
0.05462
0.0535822
0.0526918
0.0519248
0.0512617
0.0506868
0.0501871
0.0497516
0.0493712
0.0490381
0.0487453
0.0484863
0.0482547
0.0700278
0.0663799
0.063418
0.0609831
0.0589606
0.0572659
0.0558354
0.0546203
0.0535825
0.0526922
0.0519251
0.0512621
0.0506873
0.0501876
0.0497521
0.0493717
0.0490387
0.0487459
0.048487
0.0482553
0.0700278
0.0663799
0.063418
0.0609831
0.0589607
0.0572661
0.0558356
0.0546205
0.0535828
0.0526925
0.0519255
0.0512625
0.0506877
0.050188
0.0497526
0.0493722
0.0490392
0.0487464
0.0484875
0.0482559
0.0700278
0.0663799
0.063418
0.0609832
0.0589608
0.0572662
0.0558358
0.0546207
0.0535831
0.0526928
0.0519258
0.0512629
0.0506881
0.0501884
0.049753
0.0493727
0.0490397
0.0487469
0.048488
0.0482564
0.0700277
0.0663799
0.063418
0.0609833
0.0589609
0.0572663
0.0558359
0.0546209
0.0535833
0.052693
0.0519261
0.0512632
0.0506884
0.0501888
0.0497534
0.0493731
0.0490401
0.0487474
0.0484885
0.0482569
0.0700277
0.0663798
0.0634181
0.0609833
0.0589609
0.0572664
0.0558361
0.0546211
0.0535835
0.0526932
0.0519264
0.0512635
0.0506887
0.0501891
0.0497537
0.0493735
0.0490405
0.0487478
0.0484889
0.0482573
0.0700277
0.0663798
0.0634181
0.0609834
0.058961
0.0572665
0.0558362
0.0546213
0.0535837
0.0526935
0.0519266
0.0512637
0.050689
0.0501894
0.049754
0.0493738
0.0490408
0.0487481
0.0484892
0.0482576
0.0700277
0.0663798
0.0634181
0.0609834
0.0589611
0.0572666
0.0558363
0.0546214
0.0535838
0.0526936
0.0519268
0.051264
0.0506893
0.0501897
0.0497543
0.0493741
0.0490411
0.0487484
0.0484895
0.0482579
0.0700277
0.0663798
0.0634181
0.0609834
0.0589612
0.0572667
0.0558364
0.0546215
0.053584
0.0526938
0.051927
0.0512642
0.0506895
0.0501899
0.0497546
0.0493743
0.0490414
0.0487487
0.0484898
0.0482582
0.0700276
0.0663798
0.0634181
0.0609835
0.0589612
0.0572668
0.0558365
0.0546217
0.0535841
0.052694
0.0519272
0.0512643
0.0506897
0.0501901
0.0497548
0.0493746
0.0490416
0.0487489
0.0484901
0.0482585
0.0700276
0.0663798
0.0634182
0.0609835
0.0589613
0.0572669
0.0558366
0.0546218
0.0535842
0.0526941
0.0519273
0.0512645
0.0506898
0.0501903
0.049755
0.0493748
0.0490418
0.0487491
0.0484903
0.0482587
0.0700276
0.0663798
0.0634182
0.0609835
0.0589613
0.0572669
0.0558367
0.0546218
0.0535844
0.0526942
0.0519274
0.0512646
0.05069
0.0501904
0.0497551
0.0493749
0.049042
0.0487493
0.0484905
0.0482589
0.0700276
0.0663798
0.0634182
0.0609836
0.0589613
0.057267
0.0558368
0.0546219
0.0535844
0.0526943
0.0519276
0.0512648
0.0506901
0.0501906
0.0497553
0.0493751
0.0490421
0.0487495
0.0484906
0.0482591
0.0700276
0.0663798
0.0634182
0.0609836
0.0589614
0.057267
0.0558368
0.054622
0.0535845
0.0526944
0.0519277
0.0512649
0.0506902
0.0501907
0.0497554
0.0493752
0.0490423
0.0487496
0.0484908
0.0482592
0.0700276
0.0663798
0.0634182
0.0609836
0.0589614
0.0572671
0.0558369
0.0546221
0.0535846
0.0526945
0.0519278
0.051265
0.0506903
0.0501908
0.0497555
0.0493753
0.0490424
0.0487498
0.0484909
0.0482594
0.0700276
0.0663798
0.0634182
0.0609836
0.0589614
0.0572671
0.0558369
0.0546221
0.0535847
0.0526946
0.0519278
0.0512651
0.0506904
0.0501909
0.0497556
0.0493755
0.0490425
0.0487499
0.048491
0.0482595
0.0700276
0.0663798
0.0634182
0.0609836
0.0589615
0.0572671
0.055837
0.0546222
0.0535847
0.0526946
0.0519279
0.0512651
0.0506905
0.050191
0.0497557
0.0493755
0.0490426
0.04875
0.0484911
0.0482596
0.0700276
0.0663798
0.0634182
0.0609837
0.0589615
0.0572672
0.055837
0.0546222
0.0535848
0.0526947
0.051928
0.0512652
0.0506906
0.0501911
0.0497558
0.0493756
0.0490427
0.0487501
0.0484912
0.0482597
0.0700275
0.0663798
0.0634182
0.0609837
0.0589615
0.0572672
0.0558371
0.0546223
0.0535848
0.0526947
0.051928
0.0512653
0.0506907
0.0501911
0.0497559
0.0493757
0.0490428
0.0487501
0.0484913
0.0482597
0.0700275
0.0663798
0.0634182
0.0609837
0.0589615
0.0572672
0.0558371
0.0546223
0.0535849
0.0526948
0.0519281
0.0512653
0.0506907
0.0501912
0.0497559
0.0493758
0.0490428
0.0487502
0.0484914
0.0482598
0.0700275
0.0663798
0.0634182
0.0609837
0.0589615
0.0572672
0.0558371
0.0546223
0.0535849
0.0526948
0.0519281
0.0512654
0.0506908
0.0501912
0.049756
0.0493758
0.0490429
0.0487503
0.0484914
0.0482599
0.0700275
0.0663798
0.0634182
0.0609837
0.0589616
0.0572673
0.0558371
0.0546224
0.0535849
0.0526949
0.0519281
0.0512654
0.0506908
0.0501913
0.049756
0.0493759
0.0490429
0.0487503
0.0484915
0.0482599
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572673
0.0558372
0.0546224
0.053585
0.0526949
0.0519282
0.0512654
0.0506908
0.0501913
0.0497561
0.0493759
0.049043
0.0487504
0.0484915
0.04826
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572673
0.0558372
0.0546224
0.053585
0.0526949
0.0519282
0.0512655
0.0506909
0.0501914
0.0497561
0.0493759
0.049043
0.0487504
0.0484916
0.04826
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572673
0.0558372
0.0546224
0.053585
0.0526949
0.0519282
0.0512655
0.0506909
0.0501914
0.0497561
0.049376
0.049043
0.0487504
0.0484916
0.04826
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572673
0.0558372
0.0546224
0.053585
0.052695
0.0519283
0.0512655
0.0506909
0.0501914
0.0497562
0.049376
0.0490431
0.0487504
0.0484916
0.0482601
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572673
0.0558372
0.0546225
0.053585
0.052695
0.0519283
0.0512655
0.0506909
0.0501914
0.0497562
0.049376
0.0490431
0.0487505
0.0484916
0.0482601
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572673
0.0558372
0.0546225
0.0535851
0.052695
0.0519283
0.0512656
0.050691
0.0501915
0.0497562
0.049376
0.0490431
0.0487505
0.0484917
0.0482601
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572673
0.0558372
0.0546225
0.0535851
0.052695
0.0519283
0.0512656
0.050691
0.0501915
0.0497562
0.049376
0.0490431
0.0487505
0.0484917
0.0482601
0.0700275
0.0663798
0.0634183
0.0609837
0.0589616
0.0572674
0.0558372
0.0546225
0.0535851
0.052695
0.0519283
0.0512656
0.050691
0.0501915
0.0497562
0.0493761
0.0490431
0.0487505
0.0484917
0.0482601
0.0700275
0.0663798
0.0634183
0.0609838
0.0589616
0.0572674
0.0558372
0.0546225
0.0535851
0.052695
0.0519283
0.0512656
0.050691
0.0501915
0.0497562
0.0493761
0.0490432
0.0487505
0.0484917
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589616
0.0572674
0.0558373
0.0546225
0.0535851
0.052695
0.0519283
0.0512656
0.050691
0.0501915
0.0497562
0.0493761
0.0490432
0.0487505
0.0484917
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589616
0.0572674
0.0558373
0.0546225
0.0535851
0.052695
0.0519283
0.0512656
0.050691
0.0501915
0.0497563
0.0493761
0.0490432
0.0487506
0.0484917
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546225
0.0535851
0.052695
0.0519283
0.0512656
0.050691
0.0501915
0.0497563
0.0493761
0.0490432
0.0487506
0.0484917
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546225
0.0535851
0.0526951
0.0519284
0.0512656
0.050691
0.0501915
0.0497563
0.0493761
0.0490432
0.0487506
0.0484917
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546225
0.0535851
0.0526951
0.0519284
0.0512656
0.050691
0.0501915
0.0497563
0.0493761
0.0490432
0.0487506
0.0484917
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546225
0.0535851
0.0526951
0.0519284
0.0512656
0.050691
0.0501916
0.0497563
0.0493761
0.0490432
0.0487506
0.0484918
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546225
0.0535851
0.0526951
0.0519284
0.0512656
0.0506911
0.0501916
0.0497563
0.0493761
0.0490432
0.0487506
0.0484918
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546225
0.0535851
0.0526951
0.0519284
0.0512657
0.0506911
0.0501916
0.0497563
0.0493762
0.0490432
0.0487506
0.0484918
0.0482602
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546226
0.0535852
0.0526951
0.0519284
0.0512657
0.0506911
0.0501916
0.0497563
0.0493762
0.0490433
0.0487506
0.0484918
0.0482603
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546226
0.0535852
0.0526951
0.0519284
0.0512657
0.0506911
0.0501916
0.0497564
0.0493762
0.0490433
0.0487507
0.0484918
0.0482603
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558373
0.0546226
0.0535852
0.0526951
0.0519285
0.0512657
0.0506911
0.0501916
0.0497564
0.0493762
0.0490433
0.0487507
0.0484919
0.0482603
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572674
0.0558374
0.0546226
0.0535852
0.0526952
0.0519285
0.0512658
0.0506912
0.0501917
0.0497564
0.0493763
0.0490434
0.0487507
0.0484919
0.0482604
0.0700275
0.0663798
0.0634183
0.0609838
0.0589617
0.0572675
0.0558374
0.0546227
0.0535853
0.0526952
0.0519286
0.0512658
0.0506913
0.0501918
0.0497565
0.0493764
0.0490435
0.0487508
0.048492
0.0482605
0.0414075
0.0363605
0.0323662
0.0291499
0.0265221
0.0243476
0.0225273
0.0209873
0.0196718
0.0185379
0.0175522
0.0166887
0.0159265
0.0152492
0.0146433
0.014098
0.0136044
0.0131552
0.0127443
0.0123667
0.0120182
0.0116953
0.0113948
0.0111144
0.0108519
0.0106053
0.0103731
0.010154
0.00994672
0.00975024
0.00956366
0.00938618
0.00921712
0.00905585
0.00890183
0.00875457
0.00861365
0.00847866
0.00834928
0.00822516
0.00810606
0.00799169
0.00788186
0.0077763
0.00767491
0.00757741
0.00748378
0.00739374
0.0073073
0.00722421
0.00714455
0.007068
0.00699475
0.00692444
0.00685733
0.00679297
0.00673178
0.00667316
0.00661769
0.00656458
0.00651462
0.00646673
0.00642201
0.00637898
0.00633912
0.00630046
0.00626502
0.00623011
0.00619859
0.00616682
0.0061388
0.00610967
0.00608508
0.00605844
0.00603774
0.00601404
0.00599853
0.00597883
0.00597069
0.00595608
0.0464858
0.0449134
0.0432259
0.0415192
0.039841
0.0382169
0.0366606
0.0351788
0.0337735
0.032444
0.0311881
0.0300024
0.0288833
0.0278267
0.0268285
0.025885
0.0249922
0.0241467
0.0233451
0.0225844
0.0218617
0.0211743
0.0205199
0.0198963
0.0193014
0.0187334
0.0181906
0.0176715
0.0171746
0.0166987
0.0162426
0.0158052
0.0153856
0.0149828
0.014596
0.0142246
0.0138676
0.0135247
0.0131951
0.0128784
0.0125741
0.0122817
0.0120008
0.0117312
0.0114724
0.0112241
0.0109861
0.0107583
0.0105401
0.0103318
0.0101328
0.00994333
0.00976289
0.00959175
0.00942938
0.00927616
0.00913142
0.00899568
0.00886806
0.00874926
0.00863807
0.00853539
0.00843962
0.0083519
0.0082701
0.00819579
0.00812617
0.00806346
0.00800409
0.00795132
0.00790065
0.00785693
0.00781444
0.00778038
0.00774728
0.00772574
0.00770535
0.0077019
0.00769903
0.00771892
0.0473118
0.0465744
0.0457108
0.0447602
0.0437514
0.0427052
0.0416379
0.0405618
0.0394863
0.038419
0.0373653
0.0363294
0.0353146
0.034323
0.0333562
0.0324152
0.0315007
0.0306127
0.0297513
0.0289163
0.0281072
0.0273236
0.0265648
0.0258303
0.0251193
0.0244312
0.0237652
0.0231207
0.0224969
0.0218932
0.021309
0.0207435
0.0201963
0.0196667
0.0191542
0.0186583
0.0181785
0.0177143
0.0172654
0.0168312
0.0164116
0.0160061
0.0156144
0.0152363
0.0148714
0.0145197
0.0141808
0.0138547
0.0135412
0.0132402
0.0129514
0.0126751
0.0124109
0.0121591
0.0119192
0.0116916
0.0114759
0.0112724
0.0110805
0.0109005
0.0107317
0.0105745
0.0104275
0.0102914
0.0101644
0.0100473
0.00993787
0.00983727
0.00974276
0.00965642
0.00957497
0.00950193
0.00943342
0.00937506
0.00932216
0.0092832
0.00925201
0.00924075
0.00924021
0.0092647
0.0475897
0.0471146
0.0465589
0.0459346
0.0452531
0.044525
0.0437595
0.0429646
0.0421472
0.0413133
0.0404681
0.0396163
0.0387616
0.0379074
0.0370566
0.0362116
0.0353744
0.0345468
0.0337302
0.0329257
0.0321344
0.0313569
0.030594
0.029846
0.0291134
0.0283963
0.027695
0.0270096
0.02634
0.0256863
0.0250484
0.0244262
0.0238197
0.0232286
0.0226529
0.0220924
0.021547
0.0210164
0.0205007
0.0199995
0.0195128
0.0190405
0.0185824
0.0181384
0.0177085
0.0172926
0.0168906
0.0165026
0.0161284
0.0157681
0.0154217
0.0150893
0.0147708
0.0144665
0.0141761
0.0138999
0.0136378
0.0133898
0.0131556
0.0129354
0.0127285
0.012535
0.0123539
0.0121853
0.0120278
0.0118815
0.0117446
0.0116177
0.0114985
0.0113885
0.0112852
0.0111914
0.0111047
0.0110296
0.0109636
0.0109136
0.0108768
0.0108628
0.0108669
0.0108983
0.0477255
0.0473609
0.0469451
0.04648
0.0459697
0.0454188
0.0448318
0.0442132
0.0435673
0.042898
0.042209
0.0415036
0.040785
0.0400561
0.0393194
0.0385774
0.0378323
0.037086
0.0363402
0.0355967
0.0348567
0.0341217
0.0333926
0.0326706
0.0319566
0.0312512
0.0305553
0.0298694
0.0291941
0.0285297
0.0278768
0.0272356
0.0266065
0.0259897
0.0253854
0.0247938
0.0242152
0.0236495
0.0230971
0.0225579
0.0220322
0.0215199
0.0210213
0.0205364
0.0200653
0.0196081
0.019165
0.0187361
0.0183215
0.0179214
0.0175359
0.0171653
0.0168095
0.016469
0.0161436
0.0158336
0.0155389
0.0152598
0.0149958
0.0147472
0.0145133
0.014294
0.0140884
0.0138964
0.0137167
0.013549
0.0133918
0.0132452
0.0131075
0.0129796
0.01286
0.0127507
0.0126506
0.0125635
0.0124886
0.012432
0.0123928
0.0123793
0.0123899
0.0124297
0.047802
0.0474939
0.0471518
0.0467746
0.0463629
0.0459181
0.0454422
0.0449376
0.0444065
0.0438514
0.0432746
0.0426785
0.0420652
0.0414369
0.0407957
0.0401435
0.0394822
0.0388135
0.0381391
0.0374605
0.0367793
0.0360967
0.035414
0.0347325
0.0340532
0.0333771
0.0327052
0.0320384
0.0313774
0.0307229
0.0300758
0.0294365
0.0288057
0.0281838
0.0275715
0.0269691
0.0263771
0.0257958
0.0252256
0.0246669
0.0241201
0.0235853
0.023063
0.0225534
0.0220568
0.0215736
0.0211039
0.0206482
0.0202067
0.0197798
0.0193676
0.0189705
0.0185888
0.0182228
0.0178726
0.0175385
0.0172206
0.0169189
0.0166334
0.016364
0.0161102
0.0158719
0.0156481
0.0154385
0.0152418
0.0150577
0.0148848
0.014723
0.0145708
0.014429
0.0142966
0.0141753
0.014065
0.0139692
0.0138883
0.0138278
0.0137885
0.0137777
0.0137956
0.0138446
0.0478474
0.047571
0.0472714
0.0469466
0.0465956
0.0462184
0.0458154
0.0453875
0.0449359
0.0444618
0.0439666
0.0434519
0.042919
0.0423696
0.0418051
0.041227
0.0406368
0.0400359
0.0394257
0.0388075
0.0381826
0.0375524
0.0369179
0.0362804
0.035641
0.0350008
0.0343607
0.0337217
0.0330848
0.0324508
0.0318205
0.0311947
0.0305742
0.0299596
0.0293516
0.0287509
0.028158
0.0275736
0.0269981
0.0264322
0.0258763
0.0253309
0.0247964
0.0242735
0.0237625
0.0232638
0.022778
0.0223055
0.0218468
0.0214022
0.0209722
0.0205572
0.0201577
0.019774
0.0194064
0.0190553
0.0187207
0.0184029
0.0181017
0.0178171
0.0175487
0.017296
0.0170585
0.0168355
0.0166258
0.0164291
0.0162439
0.01607
0.0159065
0.0157537
0.0156112
0.0154808
0.0153628
0.0152607
0.0151758
0.0151135
0.0150756
0.0150689
0.0150946
0.015153
0.0478745
0.0476166
0.0473425
0.0470502
0.0467381
0.0464055
0.0460519
0.0456773
0.0452821
0.0448668
0.0444321
0.0439788
0.0435079
0.0430204
0.0425172
0.0419995
0.0414684
0.0409249
0.0403701
0.0398053
0.0392314
0.0386495
0.0380608
0.0374663
0.0368669
0.0362638
0.0356579
0.0350501
0.0344414
0.0338327
0.0332249
0.0326188
0.0320153
0.031415
0.0308189
0.0302276
0.0296419
0.0290624
0.0284898
0.0279249
0.0273682
0.0268203
0.0262819
0.0257537
0.0252361
0.0247298
0.0242354
0.0237534
0.0232845
0.0228292
0.0223881
0.0219617
0.0215505
0.021155
0.0207757
0.0204128
0.0200666
0.0197374
0.019425
0.0191294
0.0188503
0.0185872
0.0183394
0.0181062
0.0178867
0.0176802
0.0174855
0.0173023
0.0171299
0.0169686
0.0168183
0.016681
0.0165574
0.0164511
0.016364
0.0163014
0.0162661
0.0162642
0.0162981
0.0163657
0.0478904
0.0476435
0.0473849
0.0471128
0.0468259
0.0465231
0.0462034
0.0458664
0.0455119
0.0451398
0.0447505
0.0443441
0.0439213
0.0434825
0.0430285
0.0425599
0.0420776
0.0415823
0.0410749
0.0405563
0.0400273
0.0394888
0.0389418
0.0383871
0.0378257
0.0372585
0.0366863
0.0361102
0.0355309
0.0349494
0.0343665
0.0337831
0.0332
0.0326181
0.0320381
0.0314609
0.0308873
0.0303179
0.0297536
0.0291952
0.0286433
0.0280987
0.0275621
0.0270342
0.0265158
0.0260075
0.02551
0.0250241
0.0245504
0.0240896
0.0236424
0.0232094
0.0227912
0.0223885
0.0220017
0.0216312
0.0212773
0.0209404
0.0206204
0.0203172
0.0200305
0.0197598
0.0195046
0.0192641
0.0190372
0.0188234
0.0186216
0.0184314
0.0182523
0.0180846
0.0179287
0.0177864
0.017659
0.0175501
0.0174623
0.0174007
0.0173687
0.0173725
0.0174145
0.0174909
0.0478995
0.047659
0.0474097
0.0471503
0.0468795
0.0465964
0.0462998
0.0459892
0.045664
0.0453238
0.0449685
0.0445981
0.0442126
0.0438125
0.0433979
0.0429693
0.0425272
0.0420723
0.041605
0.041126
0.040636
0.0401358
0.0396261
0.0391076
0.0385811
0.0380474
0.0375073
0.0369617
0.0364114
0.0358571
0.0352997
0.0347401
0.0341791
0.0336174
0.0330559
0.0324954
0.0319368
0.0313808
0.0308282
0.0302799
0.0297366
0.0291991
0.0286683
0.0281449
0.0276297
0.0271234
0.026627
0.0261411
0.0256666
0.0252042
0.0247548
0.0243189
0.0238974
0.0234909
0.0230999
0.022725
0.0223666
0.0220249
0.0217
0.0213918
0.0211001
0.0208244
0.0205641
0.0203184
0.0200864
0.0198674
0.0196605
0.0194654
0.0192815
0.0191095
0.0189497
0.0188042
0.0186747
0.0185647
0.0184774
0.0184178
0.0183898
0.0183994
0.0184495
0.0185342
0.0479045
0.0476677
0.0474238
0.0471721
0.0469115
0.0466411
0.0463601
0.0460677
0.0457633
0.0454462
0.0451163
0.0447731
0.0444166
0.0440468
0.0436637
0.0432675
0.0428586
0.0424371
0.0420036
0.0415585
0.0411022
0.0406354
0.0401586
0.0396724
0.0391775
0.0386745
0.0381642
0.0376473
0.0371245
0.0365966
0.0360642
0.0355283
0.0349896
0.0344488
0.0339068
0.0333644
0.0328224
0.0322816
0.0317428
0.0312069
0.0306746
0.0301469
0.0296245
0.0291083
0.0285992
0.028098
0.0276055
0.0271227
0.0266503
0.0261892
0.0257403
0.0253044
0.0248823
0.0244746
0.0240821
0.0237053
0.0233446
0.0230005
0.0226729
0.0223619
0.0220672
0.0217884
0.0215248
0.0212759
0.0210406
0.0208184
0.0206082
0.0204099
0.0202231
0.0200484
0.0198865
0.0197394
0.0196092
0.0194994
0.0194136
0.0193568
0.0193334
0.0193491
0.0194069
0.0194993
0.047907
0.0476723
0.0474316
0.0471843
0.0469299
0.0466676
0.0463967
0.0461165
0.0458265
0.0455259
0.0452144
0.0448916
0.0445571
0.0442108
0.0438526
0.0434824
0.0431003
0.0427066
0.0423013
0.0418847
0.0414573
0.0410193
0.0405713
0.0401137
0.039647
0.0391718
0.0386887
0.0381982
0.0377011
0.037198
0.0366896
0.0361766
0.0356597
0.0351397
0.0346173
0.0340934
0.0335686
0.0330439
0.03252
0.0319978
0.031478
0.0309617
0.0304495
0.0299424
0.0294413
0.0289471
0.0284607
0.0279829
0.0275148
0.0270572
0.026611
0.0261771
0.0257563
0.0253495
0.0249574
0.0245805
0.0242194
0.0238745
0.023546
0.0232337
0.0229377
0.0226574
0.0223923
0.0221416
0.0219047
0.0216806
0.0214689
0.021269
0.0210808
0.020905
0.0207425
0.0205953
0.0204656
0.0203572
0.0202738
0.0202206
0.020202
0.0202238
0.0202891
0.0203885
0.0479083
0.0476746
0.0474356
0.0471909
0.0469401
0.0466827
0.0464181
0.0461459
0.0458654
0.0455763
0.0452778
0.0449698
0.0446516
0.0443232
0.0439842
0.0436344
0.0432739
0.0429025
0.0425205
0.0421278
0.0417247
0.0413114
0.0408883
0.0404556
0.0400138
0.0395633
0.0391046
0.0386382
0.0381647
0.0376846
0.0371986
0.0367072
0.0362112
0.0357112
0.0352081
0.0347024
0.0341949
0.0336865
0.0331779
0.03267
0.0321635
0.0316594
0.0311584
0.0306616
0.0301698
0.0296839
0.0292049
0.0287337
0.0282712
0.0278185
0.0273765
0.0269461
0.0265282
0.0261236
0.0257332
0.0253577
0.0249975
0.0246531
0.0243249
0.0240127
0.0237165
0.0234359
0.0231704
0.0229194
0.022682
0.0224576
0.0222456
0.0220455
0.0218574
0.021682
0.0215201
0.021374
0.0212461
0.0211401
0.0210599
0.0210107
0.0209973
0.0210251
0.0210974
0.0212032
0.0479089
0.0476757
0.0474376
0.0471942
0.0469454
0.0466908
0.0464301
0.0461628
0.0458885
0.0456069
0.0453174
0.0450196
0.0447133
0.0443979
0.0440733
0.0437393
0.0433956
0.0430421
0.0426787
0.0423056
0.0419227
0.0415301
0.0411281
0.0407169
0.0402967
0.039868
0.0394309
0.0389861
0.0385339
0.0380748
0.0376093
0.0371381
0.0366616
0.0361807
0.0356958
0.0352076
0.034717
0.0342247
0.0337313
0.0332377
0.0327447
0.0322532
0.031764
0.031278
0.0307961
0.0303193
0.0298485
0.0293847
0.0289289
0.028482
0.0280451
0.0276191
0.027205
0.0268037
0.026416
0.0260427
0.0256843
0.0253415
0.0250143
0.0247031
0.0244077
0.0241278
0.0238629
0.0236124
0.0233756
0.023152
0.0229407
0.0227417
0.0225549
0.022381
0.022221
0.0220772
0.021952
0.0218492
0.0217729
0.0217282
0.0217199
0.0217537
0.0218326
0.021944
0.0479093
0.0476763
0.0474385
0.0471959
0.0469481
0.046695
0.0464365
0.0461721
0.0459016
0.0456247
0.045341
0.0450502
0.0447519
0.0444459
0.0441318
0.0438094
0.0434784
0.0431386
0.04279
0.0424325
0.0420659
0.0416904
0.0413061
0.0409129
0.0405112
0.0401012
0.039683
0.0392571
0.0388238
0.0383836
0.0379368
0.0374839
0.0370255
0.0365621
0.0360943
0.0356228
0.0351482
0.0346713
0.0341926
0.033713
0.0332333
0.0327544
0.0322769
0.0318019
0.0313302
0.0308628
0.0304007
0.0299447
0.029496
0.0290555
0.0286242
0.0282033
0.0277935
0.027396
0.0270116
0.026641
0.026285
0.0259441
0.0256187
0.025309
0.0250149
0.0247362
0.0244726
0.0242234
0.023988
0.0237659
0.0235564
0.0233593
0.0231747
0.0230033
0.0228463
0.0227056
0.022584
0.0224852
0.0224133
0.0223733
0.0223704
0.0224099
0.0224948
0.0226113
0.0479097
0.0476767
0.0474391
0.0471967
0.0469494
0.0466971
0.0464396
0.0461769
0.0459086
0.0456345
0.0453544
0.0450681
0.0447752
0.0444754
0.0441686
0.0438545
0.0435328
0.0432033
0.0428659
0.0425204
0.0421667
0.0418049
0.0414348
0.0410565
0.0406702
0.040276
0.0398739
0.0394644
0.0390476
0.0386239
0.0381936
0.0377572
0.0373151
0.0368678
0.0364158
0.0359596
0.0355
0.0350374
0.0345727
0.0341065
0.0336396
0.0331728
0.0327068
0.0322426
0.031781
0.0313229
0.0308694
0.0304214
0.0299799
0.029546
0.0291206
0.0287048
0.0282997
0.0279062
0.0275252
0.0271576
0.0268042
0.0264656
0.0261421
0.0258341
0.0255416
0.0252645
0.0250025
0.024755
0.0245215
0.0243014
0.0240943
0.0238999
0.0237183
0.0235503
0.0233968
0.0232601
0.0231428
0.0230485
0.0229813
0.0229464
0.0229488
0.0229937
0.0230842
0.023205
0.0479103
0.0476773
0.0474396
0.0471972
0.0469501
0.0466981
0.0464412
0.0461792
0.0459121
0.0456396
0.0453616
0.0450779
0.0447884
0.0444927
0.0441907
0.0438822
0.043567
0.0432449
0.0429156
0.0425791
0.0422353
0.0418839
0.0415251
0.0411587
0.0407849
0.0404036
0.040015
0.0396192
0.0392165
0.038807
0.0383912
0.0379692
0.0375415
0.0371085
0.0366706
0.0362284
0.0357824
0.0353332
0.0348814
0.0344277
0.0339728
0.0335174
0.0330623
0.0326084
0.0321565
0.0317075
0.0312624
0.0308221
0.0303877
0.0299601
0.0295405
0.0291299
0.0287293
0.0283397
0.0279622
0.0275976
0.0272467
0.0269102
0.0265886
0.0262823
0.0259914
0.0257159
0.0254555
0.0252099
0.0249785
0.0247608
0.0245564
0.0243651
0.024187
0.0240228
0.0238735
0.0237413
0.0236287
0.0235393
0.0234772
0.0234474
0.0234549
0.023505
0.0236005
0.0237251
0.0479112
0.0476781
0.0474403
0.0471979
0.0469507
0.0466988
0.0464421
0.0461804
0.0459138
0.0456421
0.0453652
0.045083
0.0447954
0.0445022
0.0442033
0.0438984
0.0435875
0.0432703
0.0429468
0.0426167
0.04228
0.0419365
0.0415862
0.041229
0.0408649
0.0404939
0.0401162
0.0397316
0.0393405
0.038943
0.0385393
0.0381297
0.0377144
0.0372939
0.0368685
0.0364387
0.0360049
0.0355676
0.0351275
0.0346852
0.0342413
0.0337964
0.0333515
0.0329072
0.0324643
0.0320238
0.0315866
0.0311536
0.0307259
0.0303044
0.0298902
0.0294844
0.029088
0.0287021
0.0283277
0.0279657
0.0276171
0.0272825
0.0269625
0.0266576
0.0263681
0.0260939
0.025835
0.025591
0.0253615
0.0251462
0.0249446
0.0247565
0.0245821
0.024422
0.0242773
0.0241499
0.0240423
0.023958
0.0239011
0.0238764
0.0238888
0.0239436
0.0240436
0.0241713
0.0479124
0.0476792
0.0474413
0.0471988
0.0469515
0.0466996
0.0464428
0.0461812
0.0459148
0.0456434
0.045367
0.0450856
0.044799
0.0445072
0.04421
0.0439073
0.043599
0.0432851
0.0429653
0.0426396
0.0423078
0.0419699
0.0416257
0.0412753
0.0409186
0.0405555
0.0401861
0.0398105
0.0394287
0.0390409
0.0386472
0.0382478
0.037843
0.0374331
0.0370184
0.0365992
0.036176
0.0357493
0.0353196
0.0348873
0.0344532
0.0340179
0.0335821
0.0331465
0.0327119
0.0322791
0.0318491
0.0314228
0.0310012
0.0305852
0.0301759
0.0297744
0.0293817
0.028999
0.0286272
0.0282673
0.0279204
0.0275871
0.0272682
0.0269642
0.0266755
0.0264021
0.0261442
0.0259014
0.0256736
0.0254603
0.0252612
0.0250762
0.0249054
0.0247494
0.0246092
0.0244867
0.0243842
0.024305
0.0242532
0.0242334
0.0242506
0.0243097
0.0244135
0.0245437
0.047914
0.0476806
0.0474427
0.0472
0.0469527
0.0467006
0.0464438
0.0461821
0.0459157
0.0456444
0.0453681
0.045087
0.0448008
0.0445097
0.0442134
0.0439119
0.0436052
0.0432931
0.0429756
0.0426527
0.0423241
0.04199
0.0416501
0.0413044
0.0409529
0.0405957
0.0402325
0.0398637
0.039489
0.0391088
0.038723
0.0383319
0.0379356
0.0375343
0.0371284
0.0367182
0.036304
0.0358863
0.0354654
0.0350419
0.0346164
0.0341894
0.0337615
0.0333336
0.0329063
0.0324804
0.0320568
0.0316363
0.03122
0.0308088
0.0304037
0.0300058
0.0296162
0.029236
0.0288661
0.0285078
0.0281618
0.0278292
0.0275106
0.0272067
0.0269181
0.0266448
0.0263871
0.0261449
0.025918
0.0257062
0.0255091
0.0253267
0.0251591
0.0250068
0.0248708
0.0247529
0.0246553
0.0245811
0.0245341
0.0245189
0.0245403
0.0246032
0.0247103
0.0248423
0.0479158
0.0476825
0.0474444
0.0472017
0.0469542
0.046702
0.0464451
0.0461833
0.0459168
0.0456454
0.0453692
0.045088
0.044802
0.0445111
0.0442152
0.0439142
0.0436083
0.0432972
0.0429811
0.0426597
0.0423331
0.0420013
0.0416641
0.0413216
0.0409737
0.0406204
0.0402618
0.0398977
0.0395284
0.0391538
0.038774
0.0383892
0.0379995
0.0376052
0.0372063
0.0368033
0.0363965
0.0359861
0.0355726
0.0351564
0.0347381
0.0343181
0.0338971
0.0334757
0.0330545
0.0326345
0.0322163
0.0318008
0.0313889
0.0309817
0.03058
0.0301849
0.0297976
0.029419
0.0290504
0.0286926
0.0283469
0.028014
0.0276949
0.0273903
0.0271007
0.0268266
0.0265682
0.0263256
0.0260987
0.0258873
0.0256913
0.0255107
0.0253456
0.0251964
0.0250641
0.0249502
0.024857
0.0247873
0.0247447
0.0247336
0.0247587
0.0248247
0.0249342
0.0250673
0.0479181
0.0476846
0.0474465
0.0472037
0.0469562
0.0467039
0.0464468
0.046185
0.0459183
0.0456468
0.0453705
0.0450893
0.0448032
0.0445122
0.0442164
0.0439157
0.04361
0.0432994
0.0429838
0.0426633
0.0423378
0.0420073
0.0416717
0.0413311
0.0409855
0.0406348
0.040279
0.0399183
0.0395526
0.039182
0.0388065
0.0384264
0.0380416
0.0376524
0.037259
0.0368616
0.0364605
0.0360559
0.0356483
0.035238
0.0348255
0.0344112
0.0339957
0.0335796
0.0331635
0.0327482
0.0323344
0.0319229
0.0315145
0.0311103
0.0307111
0.030318
0.029932
0.0295543
0.0291859
0.0288279
0.0284814
0.0281473
0.0278266
0.0275202
0.0272287
0.0269526
0.0266923
0.0264481
0.02622
0.0260079
0.0258119
0.0256319
0.0254681
0.025321
0.0251915
0.0250808
0.0249911
0.0249252
0.0248863
0.0248785
0.0249065
0.0249749
0.025086
0.0252195
0.0479207
0.0476872
0.0474491
0.0472062
0.0469586
0.0467062
0.0464491
0.0461871
0.0459203
0.0456487
0.0453722
0.0450909
0.0448047
0.0445137
0.0442177
0.043917
0.0436113
0.0433008
0.0429855
0.0426653
0.0423402
0.0420103
0.0416756
0.041336
0.0409917
0.0406425
0.0402885
0.0399299
0.0395665
0.0391985
0.038826
0.038449
0.0380677
0.0376822
0.0372927
0.0368994
0.0365025
0.0361023
0.0356991
0.0352932
0.0348852
0.0344753
0.0340641
0.0336521
0.0332399
0.0328282
0.0324177
0.0320091
0.0316033
0.0312011
0.0308034
0.0304114
0.0300259
0.0296481
0.029279
0.0289197
0.0285714
0.0282351
0.0279118
0.0276024
0.0273077
0.0270284
0.0267649
0.0265177
0.0262869
0.0260728
0.0258753
0.0256945
0.0255307
0.0253844
0.0252562
0.0251476
0.0250603
0.024997
0.0249608
0.0249554
0.0249854
0.025055
0.0251668
0.0252999
0.0479236
0.0476901
0.047452
0.0472091
0.0469614
0.046709
0.0464518
0.0461898
0.0459229
0.0456511
0.0453746
0.0450931
0.0448068
0.0445156
0.0442195
0.0439186
0.0436129
0.0433023
0.0429869
0.0426668
0.0423418
0.0420121
0.0416777
0.0413386
0.0409948
0.0406464
0.0402934
0.0399359
0.0395738
0.0392074
0.0388367
0.0384617
0.0380826
0.0376995
0.0373126
0.0369221
0.0365281
0.0361309
0.0357309
0.0353282
0.0349233
0.0345166
0.0341085
0.0336994
0.03329
0.0328808
0.0324726
0.0320659
0.0316616
0.0312605
0.0308634
0.0304714
0.0300855
0.0297066
0.0293359
0.0289745
0.0286234
0.0282838
0.0279567
0.0276431
0.0273439
0.02706
0.0267919
0.0265402
0.0263052
0.0260873
0.0258866
0.0257034
0.0255379
0.0253906
0.0252623
0.0251541
0.0250678
0.0250057
0.0249708
0.0249666
0.0249973
0.0250671
0.0251782
0.0253099
0.0479269
0.0476934
0.0474553
0.0472123
0.0469647
0.0467122
0.046455
0.0461929
0.045926
0.0456541
0.0453775
0.0450959
0.0448095
0.0445181
0.0442219
0.0439209
0.043615
0.0433043
0.0429888
0.0426685
0.0423434
0.0420137
0.0416793
0.0413403
0.0409966
0.0406485
0.0402959
0.0399388
0.0395775
0.0392118
0.038842
0.0384681
0.0380903
0.0377086
0.0373233
0.0369344
0.0365423
0.036147
0.035749
0.0353483
0.0349455
0.0345408
0.0341346
0.0337274
0.0333197
0.0329121
0.032505
0.0320993
0.0316955
0.0312946
0.0308973
0.0305045
0.0301171
0.0297363
0.0293631
0.0289985
0.0286436
0.0282997
0.0279677
0.0276488
0.0273439
0.0270539
0.0267797
0.0265219
0.026281
0.0260576
0.0258519
0.0256643
0.0254951
0.0253449
0.0252145
0.0251049
0.0250177
0.0249551
0.0249198
0.0249151
0.024945
0.0250135
0.0251226
0.0252516
0.0479305
0.0476971
0.0474589
0.047216
0.0469684
0.0467159
0.0464586
0.0461965
0.0459296
0.0456577
0.045381
0.0450993
0.0448128
0.0445214
0.044225
0.0439239
0.0436178
0.0433069
0.0429913
0.0426708
0.0423456
0.0420157
0.0416812
0.041342
0.0409983
0.0406501
0.0402975
0.0399406
0.0395794
0.039214
0.0388445
0.0384711
0.0380938
0.0377128
0.0373282
0.0369402
0.036549
0.0361548
0.0357578
0.0353582
0.0349565
0.0345529
0.0341477
0.0337414
0.0333345
0.0329274
0.0325207
0.032115
0.0317109
0.0313093
0.0309108
0.0305164
0.0301269
0.0297433
0.0293667
0.0289981
0.0286385
0.0282893
0.0279514
0.027626
0.0273141
0.0270168
0.026735
0.0264695
0.026221
0.0259902
0.0257775
0.0255834
0.0254084
0.0252531
0.0251183
0.025005
0.0249148
0.0248496
0.024812
0.0248049
0.0248322
0.0248976
0.025003
0.0251279
0.0479345
0.0477011
0.0474629
0.0472201
0.0469724
0.04672
0.0464627
0.0462006
0.0459337
0.0456618
0.045385
0.0451033
0.0448167
0.0445252
0.0442289
0.0439276
0.0436214
0.0433104
0.0429946
0.0426739
0.0423486
0.0420185
0.0416837
0.0413444
0.0410005
0.0406522
0.0402994
0.0399423
0.039581
0.0392156
0.0388461
0.0384727
0.0380955
0.0377146
0.0373302
0.0369424
0.0365515
0.0361576
0.0357609
0.0353617
0.0349603
0.034557
0.0341521
0.0337459
0.0333389
0.0329316
0.0325245
0.0321181
0.031713
0.03131
0.0309097
0.0305129
0.0301205
0.0297334
0.0293527
0.0289793
0.0286143
0.0282589
0.0279142
0.0275813
0.0272614
0.0269555
0.0266647
0.02639
0.0261322
0.0258921
0.0256704
0.0254676
0.0252845
0.0251218
0.0249802
0.0248608
0.0247651
0.0246949
0.0246525
0.0246409
0.0246633
0.0247235
0.0248233
0.0249424
0.0479388
0.0477054
0.0474673
0.0472245
0.0469769
0.0467245
0.0464673
0.0462052
0.0459382
0.0456664
0.0453896
0.0451079
0.0448213
0.0445298
0.0442334
0.043932
0.0436258
0.0433147
0.0429987
0.042678
0.0423525
0.0420222
0.0416873
0.0413477
0.0410037
0.0406551
0.0403021
0.0399448
0.0395832
0.0392175
0.0388478
0.0384742
0.0380968
0.0377157
0.0373311
0.0369432
0.0365521
0.0361581
0.0357612
0.0353619
0.0349602
0.0345566
0.0341513
0.0337447
0.0333371
0.032929
0.0325209
0.0321131
0.0317065
0.0313014
0.0308987
0.030499
0.0301032
0.0297121
0.0293266
0.0289479
0.0285768
0.0282146
0.0278623
0.0275211
0.0271922
0.0268767
0.0265757
0.0262904
0.0260218
0.0257706
0.0255379
0.0253244
0.0251309
0.0249582
0.0248073
0.0246792
0.0245753
0.0244973
0.0244476
0.0244287
0.0244438
0.0244963
0.0245881
0.0246996
0.0479434
0.0477101
0.0474721
0.0472293
0.0469818
0.0467294
0.0464723
0.0462102
0.0459433
0.0456715
0.0453948
0.0451131
0.0448265
0.044535
0.0442386
0.0439372
0.0436309
0.0433198
0.0430038
0.0426829
0.0423573
0.042027
0.0416919
0.0413522
0.0410079
0.0406591
0.0403059
0.0399483
0.0395865
0.0392205
0.0388505
0.0384766
0.0380988
0.0377174
0.0373324
0.0369441
0.0365526
0.0361581
0.0357608
0.0353609
0.0349587
0.0345544
0.0341484
0.0337409
0.0333322
0.0329229
0.0325133
0.0321039
0.0316951
0.0312877
0.0308821
0.0304791
0.0300795
0.029684
0.0292935
0.0289089
0.0285314
0.0281618
0.0278014
0.0274513
0.0271127
0.0267868
0.0264747
0.0261776
0.0258967
0.025633
0.0253875
0.0251613
0.0249551
0.0247701
0.0246072
0.0244676
0.0243527
0.0242642
0.0242042
0.0241751
0.0241801
0.0242223
0.0243034
0.0244049
0.0479484
0.0477151
0.0474772
0.0472345
0.046987
0.0467348
0.0464777
0.0462157
0.0459488
0.0456771
0.0454004
0.0451188
0.0448323
0.0445408
0.0442444
0.0439431
0.0436368
0.0433257
0.0430097
0.0426888
0.0423631
0.0420327
0.0416976
0.0413578
0.0410133
0.0406644
0.040311
0.0399532
0.0395912
0.0392249
0.0388546
0.0384803
0.0381022
0.0377204
0.037335
0.0369462
0.0365542
0.0361591
0.0357612
0.0353606
0.0349576
0.0345524
0.0341454
0.0337367
0.0333268
0.032916
0.0325047
0.0320932
0.0316822
0.0312721
0.0308635
0.030457
0.0300533
0.0296532
0.0292574
0.0288669
0.0284826
0.0281056
0.0277368
0.0273774
0.0270286
0.0266917
0.0263678
0.0260581
0.0257639
0.0254864
0.0252266
0.0249858
0.024765
0.0245654
0.0243881
0.0242343
0.0241055
0.0240035
0.0239301
0.0238879
0.0238797
0.0239085
0.023976
0.0240648
0.0479536
0.0477204
0.0474826
0.04724
0.0469926
0.0467405
0.0464834
0.0462216
0.0459548
0.0456832
0.0454066
0.0451251
0.0448386
0.0445472
0.0442509
0.0439496
0.0436435
0.0433324
0.0430164
0.0426956
0.0423699
0.0420395
0.0417043
0.0413645
0.04102
0.040671
0.0403175
0.0399595
0.0395973
0.0392308
0.0388603
0.0384857
0.0381073
0.0377251
0.0373393
0.03695
0.0365575
0.0361618
0.0357632
0.0353618
0.034958
0.0345519
0.0341438
0.0337339
0.0333226
0.0329102
0.0324971
0.0320836
0.0316702
0.0312574
0.0308457
0.0304356
0.0300279
0.0296231
0.0292221
0.0288256
0.0284345
0.0280499
0.0276727
0.027304
0.0269449
0.0265967
0.0262606
0.0259378
0.0256296
0.0253373
0.0250621
0.0248054
0.0245683
0.0243521
0.024158
0.0239876
0.0238422
0.0237237
0.023634
0.0235754
0.0235508
0.0235629
0.0236136
0.0236869
0.047959
0.047726
0.0474882
0.0472458
0.0469985
0.0467465
0.0464896
0.0462278
0.0459612
0.0456897
0.0454132
0.0451318
0.0448455
0.0445542
0.044258
0.0439569
0.0436508
0.0433398
0.0430239
0.0427032
0.0423776
0.0420472
0.0417121
0.0413723
0.0410278
0.0406788
0.0403252
0.0399672
0.0396049
0.0392383
0.0388676
0.0384928
0.0381142
0.0377317
0.0373455
0.0369559
0.0365628
0.0361666
0.0357674
0.0353654
0.0349607
0.0345537
0.0341445
0.0337335
0.0333208
0.0329069
0.032492
0.0320765
0.0316608
0.0312453
0.0308306
0.0304171
0.0300054
0.0295961
0.02919
0.0287877
0.0283902
0.0279982
0.0276127
0.0272348
0.0268656
0.0265062
0.0261579
0.0258218
0.0254993
0.0251917
0.0249004
0.0246268
0.024372
0.0241377
0.0239251
0.0237358
0.0235714
0.0234336
0.0233246
0.0232466
0.0232023
0.0231945
0.023225
0.0232798
0.0479645
0.0477316
0.047494
0.0472517
0.0470046
0.0467527
0.046496
0.0462344
0.0459679
0.0456966
0.0454203
0.045139
0.0448529
0.0445618
0.0442657
0.0439647
0.0436588
0.0433479
0.0430322
0.0427116
0.0423861
0.0420559
0.0417209
0.0413811
0.0410367
0.0406878
0.0403343
0.0399763
0.039614
0.0392474
0.0388766
0.0385017
0.0381228
0.0377402
0.0373538
0.0369638
0.0365704
0.0361738
0.0357741
0.0353714
0.0349661
0.0345583
0.0341482
0.0337361
0.0333222
0.0329068
0.0324903
0.032073
0.0316551
0.0312372
0.0308197
0.0304029
0.0299876
0.0295741
0.0291632
0.0287555
0.0283518
0.0279528
0.0275596
0.0271729
0.0267939
0.0264237
0.0260634
0.0257143
0.0253776
0.0250547
0.024747
0.0244559
0.0241828
0.0239292
0.0236967
0.0234868
0.0233013
0.023142
0.0230111
0.0229108
0.0228437
0.0228127
0.0228197
0.0228527
0.04797
0.0477373
0.0474999
0.0472578
0.0470109
0.0467591
0.0465026
0.0462412
0.0459749
0.0457037
0.0454276
0.0451466
0.0448606
0.0445697
0.0442738
0.043973
0.0436673
0.0433566
0.0430411
0.0427207
0.0423954
0.0420653
0.0417305
0.0413909
0.0410467
0.0406978
0.0403444
0.0399866
0.0396243
0.0392578
0.038887
0.0385121
0.0381332
0.0377505
0.037364
0.0369738
0.0365802
0.0361833
0.0357832
0.0353801
0.0349742
0.0345658
0.0341549
0.0337419
0.033327
0.0329104
0.0324925
0.0320735
0.0316537
0.0312337
0.0308136
0.030394
0.0299753
0.0295581
0.0291428
0.0287302
0.0283208
0.0279155
0.027515
0.0271202
0.0267321
0.0263517
0.0259801
0.0256184
0.025268
0.0249302
0.0246063
0.0242977
0.024006
0.0237327
0.0234794
0.0232478
0.0230397
0.0228571
0.0227021
0.022577
0.0224845
0.0224272
0.0224075
0.0224156
0.0479754
0.0477429
0.0475057
0.0472637
0.047017
0.0467655
0.0465092
0.046248
0.045982
0.045711
0.0454351
0.0451543
0.0448686
0.0445779
0.0442823
0.0439817
0.0436762
0.0433658
0.0430505
0.0427303
0.0424053
0.0420754
0.0417408
0.0414014
0.0410574
0.0407088
0.0403556
0.0399979
0.0396358
0.0392694
0.0388987
0.0385239
0.0381451
0.0377624
0.0373759
0.0369857
0.036592
0.0361949
0.0357946
0.0353912
0.0349849
0.034576
0.0341646
0.0337509
0.0333351
0.0329176
0.0324985
0.0320781
0.0316568
0.0312349
0.0308127
0.0303906
0.029969
0.0295485
0.0291294
0.0287124
0.0282981
0.027887
0.02748
0.0270779
0.0266815
0.0262917
0.0259096
0.0255363
0.025173
0.0248209
0.0244814
0.0241559
0.0238459
0.023553
0.0232787
0.023025
0.0227935
0.0225864
0.0224057
0.0222539
0.0221337
0.0220477
0.0219984
0.0219788
0.0479805
0.0477482
0.0475112
0.0472695
0.0470231
0.0467718
0.0465157
0.0462548
0.045989
0.0457183
0.0454427
0.0451621
0.0448766
0.0445862
0.0442909
0.0439906
0.0436854
0.0433752
0.0430602
0.0427403
0.0424155
0.0420859
0.0417516
0.0414125
0.0410687
0.0407204
0.0403674
0.04001
0.0396481
0.0392819
0.0389114
0.0385368
0.0381582
0.0377756
0.0373892
0.036999
0.0366054
0.0362082
0.0358079
0.0354043
0.0349979
0.0345887
0.0341769
0.0337627
0.0333463
0.0329281
0.0325081
0.0320867
0.0316641
0.0312407
0.0308167
0.0303926
0.0299686
0.0295453
0.029123
0.0287022
0.0282836
0.0278676
0.027455
0.0270463
0.0266426
0.0262444
0.0258529
0.0254691
0.0250939
0.0247287
0.0243746
0.0240331
0.0237056
0.0233936
0.0230989
0.0228231
0.0225681
0.022336
0.0221289
0.0219493
0.0217998
0.0216832
0.0216021
0.0215523
0.0479853
0.0477533
0.0475165
0.0472751
0.0470288
0.0467778
0.046522
0.0462613
0.0459958
0.0457254
0.04545
0.0451698
0.0448846
0.0445945
0.0442994
0.0439994
0.0436945
0.0433847
0.04307
0.0427504
0.0424259
0.0420966
0.0417626
0.0414238
0.0410804
0.0407323
0.0403797
0.0400225
0.039661
0.039295
0.0389249
0.0385505
0.0381721
0.0377897
0.0374035
0.0370136
0.03662
0.036223
0.0358227
0.0354192
0.0350127
0.0346033
0.0341914
0.0337769
0.0333602
0.0329414
0.0325208
0.0320986
0.0316751
0.0312506
0.0308253
0.0303995
0.0299736
0.029548
0.0291231
0.0286992
0.028277
0.0278569
0.0274394
0.0270253
0.0266151
0.0262098
0.02581
0.0254168
0.0250311
0.024654
0.0242867
0.0239304
0.0235867
0.0232568
0.0229425
0.0226455
0.0223676
0.0221108
0.0218773
0.0216695
0.02149
0.0213417
0.0212272
0.0211454
0.0479898
0.0477579
0.0475214
0.0472802
0.0470342
0.0467835
0.0465279
0.0462675
0.0460023
0.0457321
0.0454571
0.0451771
0.0448923
0.0446025
0.0443077
0.044008
0.0437035
0.043394
0.0430796
0.0427603
0.0424362
0.0421073
0.0417736
0.0414352
0.0410921
0.0407444
0.0403921
0.0400353
0.039674
0.0393085
0.0389386
0.0385646
0.0381865
0.0378044
0.0374185
0.0370288
0.0366355
0.0362387
0.0358385
0.0354352
0.0350288
0.0346195
0.0342075
0.0337929
0.0333761
0.032957
0.0325361
0.0321134
0.0316893
0.0312639
0.0308376
0.0304106
0.0299833
0.0295559
0.0291289
0.0287026
0.0282775
0.027854
0.0274326
0.0270138
0.0265984
0.0261869
0.0257801
0.0253788
0.024984
0.0245965
0.0242175
0.0238481
0.0234896
0.0231434
0.0228111
0.0224942
0.0221945
0.021914
0.0216549
0.0214193
0.02121
0.0210297
0.0208813
0.0207666
0.0479938
0.0477622
0.047526
0.047285
0.0470393
0.0467888
0.0465335
0.0462734
0.0460084
0.0457385
0.0454638
0.0451841
0.0448996
0.0446101
0.0443156
0.0440163
0.0437121
0.0434029
0.0430889
0.0427699
0.0424462
0.0421176
0.0417843
0.0414463
0.0411036
0.0407562
0.0404043
0.0400479
0.039687
0.0393218
0.0389524
0.0385787
0.038201
0.0378193
0.0374337
0.0370443
0.0366513
0.0362548
0.0358549
0.0354518
0.0350456
0.0346365
0.0342247
0.0338102
0.0333933
0.0329742
0.0325531
0.0321302
0.0317057
0.0312798
0.0308529
0.0304251
0.0299967
0.0295681
0.0291395
0.0287114
0.028284
0.0278578
0.0274333
0.0270109
0.0265911
0.0261746
0.025762
0.025354
0.0249514
0.0245551
0.024166
0.0237851
0.0234137
0.023053
0.0227044
0.0223695
0.0220498
0.0217472
0.0214638
0.0212018
0.0209637
0.0207521
0.0205702
0.0204224
0.0479976
0.0477662
0.0475301
0.0472894
0.0470439
0.0467937
0.0465386
0.0462788
0.0460141
0.0457445
0.04547
0.0451907
0.0449064
0.0446172
0.0443231
0.0440241
0.0437202
0.0434113
0.0430977
0.0427791
0.0424557
0.0421275
0.0417946
0.0414569
0.0411146
0.0407676
0.0404161
0.0400601
0.0396997
0.0393349
0.0389658
0.0385926
0.0382152
0.0378339
0.0374487
0.0370597
0.0366671
0.036271
0.0358715
0.0354687
0.0350628
0.034654
0.0342423
0.0338281
0.0334113
0.0329923
0.0325713
0.0321483
0.0317237
0.0312976
0.0308703
0.030442
0.0300129
0.0295835
0.0291538
0.0287243
0.0282953
0.0278671
0.0274402
0.0270149
0.0265918
0.0261713
0.025754
0.0253406
0.0249317
0.024528
0.0241304
0.0237399
0.0233575
0.0229842
0.0226214
0.0222705
0.0219329
0.0216104
0.0213048
0.0210183
0.0207531
0.0205119
0.0202976
0.0201178
0.048001
0.0477698
0.047534
0.0472934
0.0470482
0.0467982
0.0465434
0.0462837
0.0460193
0.04575
0.0454758
0.0451967
0.0449127
0.0446238
0.04433
0.0440313
0.0437277
0.0434192
0.0431059
0.0427877
0.0424647
0.0421368
0.0418043
0.041467
0.041125
0.0407785
0.0404273
0.0400717
0.0397117
0.0393473
0.0389787
0.0386059
0.0382289
0.037848
0.0374633
0.0370747
0.0366825
0.0362868
0.0358877
0.0354853
0.0350798
0.0346713
0.03426
0.033846
0.0334296
0.0330108
0.0325899
0.0321671
0.0317425
0.0313164
0.0308889
0.0304604
0.030031
0.029601
0.0291707
0.0287403
0.0283102
0.0278806
0.0274519
0.0270245
0.0265989
0.0261753
0.0257544
0.0253367
0.0249227
0.0245131
0.0241087
0.0237102
0.0233186
0.0229348
0.02256
0.0221953
0.0218422
0.0215021
0.0211768
0.0208682
0.0205784
0.0203098
0.0200655
0.0198553
0.0480041
0.0477731
0.0475375
0.0472971
0.0470521
0.0468023
0.0465477
0.0462883
0.0460241
0.045755
0.045481
0.0452022
0.0449185
0.0446299
0.0443364
0.044038
0.0437347
0.0434265
0.0431135
0.0427956
0.0424729
0.0421455
0.0418132
0.0414763
0.0411348
0.0407886
0.0404378
0.0400826
0.039723
0.039359
0.0389908
0.0386184
0.0382419
0.0378615
0.0374771
0.037089
0.0366973
0.036302
0.0359033
0.0355013
0.0350962
0.0346881
0.0342772
0.0338636
0.0334475
0.0330291
0.0326085
0.0321859
0.0317615
0.0313355
0.0309082
0.0304796
0.0300501
0.0296199
0.0291892
0.0287583
0.0283275
0.0278969
0.0274671
0.0270382
0.0266107
0.0261849
0.0257613
0.0253403
0.0249224
0.0245082
0.0240984
0.0236935
0.0232945
0.0229021
0.0225173
0.0221411
0.0217748
0.0214198
0.0210775
0.0207495
0.020438
0.0201449
0.0198734
0.0196354
0.048007
0.0477761
0.0475407
0.0473005
0.0470556
0.046806
0.0465516
0.0462924
0.0460284
0.0457596
0.0454858
0.0452073
0.0449238
0.0446354
0.0443422
0.044044
0.043741
0.0434332
0.0431204
0.0428029
0.0424805
0.0421534
0.0418215
0.0414849
0.0411437
0.0407979
0.0404475
0.0400927
0.0397335
0.0393699
0.0390021
0.0386301
0.0382541
0.037874
0.0374901
0.0371024
0.0367111
0.0363163
0.035918
0.0355165
0.0351119
0.0347042
0.0342937
0.0338806
0.0334649
0.0330468
0.0326266
0.0322043
0.0317802
0.0313545
0.0309274
0.030499
0.0300695
0.0296393
0.0292085
0.0287774
0.0283461
0.0279151
0.0274845
0.0270546
0.0266259
0.0261985
0.0257729
0.0253495
0.0249287
0.0245111
0.0240971
0.0236873
0.0232824
0.0228831
0.0224903
0.0221048
0.0217277
0.0213602
0.0210035
0.0206592
0.020329
0.0200146
0.0197192
0.0194566
0.0480096
0.0477789
0.0475436
0.0473036
0.0470589
0.0468094
0.0465552
0.0462962
0.0460324
0.0457637
0.0454902
0.0452118
0.0449286
0.0446404
0.0443474
0.0440496
0.0437468
0.0434392
0.0431267
0.0428094
0.0424874
0.0421605
0.041829
0.0414927
0.0411519
0.0408064
0.0404564
0.0401019
0.0397431
0.0393799
0.0390124
0.0386409
0.0382652
0.0378856
0.0375021
0.0371149
0.036724
0.0363296
0.0359318
0.0355307
0.0351265
0.0347193
0.0343092
0.0338965
0.0334813
0.0330636
0.0326438
0.0322219
0.0317982
0.0313729
0.030946
0.0305179
0.0300887
0.0296586
0.0292279
0.0287967
0.0283654
0.0279341
0.0275031
0.0270726
0.0266431
0.0262147
0.0257878
0.0253627
0.0249399
0.0245196
0.0241025
0.023689
0.0232796
0.0228751
0.0224759
0.0220831
0.0216973
0.0213197
0.0209513
0.0205934
0.0202475
0.0199152
0.0195993
0.0193155
0.0480121
0.0477815
0.0475463
0.0473064
0.0470618
0.0468125
0.0465584
0.0462996
0.0460359
0.0457675
0.0454941
0.0452159
0.0449329
0.044645
0.0443522
0.0440545
0.043752
0.0434446
0.0431324
0.0428154
0.0424936
0.042167
0.0418357
0.0414998
0.0411592
0.0408141
0.0404644
0.0401103
0.0397517
0.0393889
0.0390218
0.0386506
0.0382754
0.0378961
0.037513
0.0371262
0.0367357
0.0363417
0.0359444
0.0355437
0.03514
0.0347332
0.0343236
0.0339113
0.0334965
0.0330793
0.0326599
0.0322385
0.0318152
0.0313902
0.0309638
0.030536
0.0301071
0.0296773
0.0292468
0.0288158
0.0283845
0.0279532
0.027522
0.0270914
0.0266614
0.0262324
0.0258046
0.0253784
0.0249542
0.0245322
0.0241128
0.0236966
0.0232839
0.0228753
0.0224714
0.0220728
0.0216803
0.0212947
0.020917
0.0205481
0.0201894
0.0198423
0.0195093
0.0192078
0.0480143
0.0477838
0.0475487
0.0473089
0.0470645
0.0468153
0.0465614
0.0463027
0.0460392
0.0457709
0.0454977
0.0452197
0.0449368
0.044649
0.0443564
0.044059
0.0437567
0.0434495
0.0431375
0.0428207
0.0424991
0.0421728
0.0418418
0.0415061
0.0411658
0.040821
0.0404716
0.0401177
0.0397595
0.039397
0.0390303
0.0386594
0.0382845
0.0379056
0.0375229
0.0371365
0.0367464
0.0363528
0.0359558
0.0355556
0.0351523
0.0347459
0.0343368
0.0339249
0.0335106
0.0330938
0.0326748
0.0322538
0.031831
0.0314064
0.0309804
0.030553
0.0301244
0.029695
0.0292648
0.028834
0.028403
0.0279718
0.0275407
0.02711
0.0266799
0.0262506
0.0258224
0.0253955
0.0249704
0.0245472
0.0241263
0.0237082
0.0232931
0.0228816
0.0224741
0.0220713
0.0216736
0.0212818
0.0208967
0.0205192
0.0201503
0.0197913
0.0194445
0.0191285
0.0480163
0.0477859
0.0475509
0.0473113
0.0470669
0.0468179
0.0465641
0.0463055
0.0460421
0.0457739
0.0455009
0.045223
0.0449403
0.0446527
0.0443603
0.044063
0.0437608
0.0434539
0.0431421
0.0428255
0.0425041
0.042178
0.0418472
0.0415118
0.0411717
0.0408271
0.040478
0.0401244
0.0397665
0.0394043
0.0390379
0.0386673
0.0382927
0.0379142
0.0375318
0.0371457
0.036756
0.0363627
0.0359662
0.0355663
0.0351634
0.0347574
0.0343487
0.0339373
0.0335233
0.033107
0.0326884
0.0322679
0.0318454
0.0314213
0.0309957
0.0305687
0.0301406
0.0297115
0.0292816
0.0288512
0.0284205
0.0279895
0.0275587
0.0271281
0.026698
0.0262686
0.0258402
0.0254131
0.0249874
0.0245635
0.0241417
0.0237223
0.0233056
0.022892
0.022482
0.0220759
0.0216744
0.021278
0.0208873
0.0205032
0.0201263
0.0197579
0.0194001
0.0190725
0.0480181
0.0477878
0.0475529
0.0473134
0.0470691
0.0468202
0.0465665
0.046308
0.0460447
0.0457767
0.0455038
0.045226
0.0449434
0.044656
0.0443637
0.0440665
0.0437646
0.0434577
0.0431461
0.0428297
0.0425085
0.0421826
0.0418521
0.0415168
0.041177
0.0408326
0.0404837
0.0401304
0.0397727
0.0394107
0.0390446
0.0386743
0.0383
0.0379218
0.0375397
0.0371539
0.0367645
0.0363716
0.0359754
0.0355759
0.0351733
0.0347677
0.0343594
0.0339483
0.0335348
0.0331188
0.0327007
0.0322806
0.0318585
0.0314348
0.0310096
0.030583
0.0301553
0.0297266
0.0292972
0.0288671
0.0284367
0.0280061
0.0275755
0.0271452
0.0267153
0.026286
0.0258577
0.0254304
0.0250045
0.0245803
0.0241579
0.0237376
0.0233199
0.0229049
0.0224931
0.0220849
0.0216806
0.0212808
0.020886
0.0204968
0.0201139
0.0197382
0.0193719
0.0190353
0.0480198
0.0477896
0.0475548
0.0473153
0.0470711
0.0468223
0.0465686
0.0463103
0.0460471
0.0457791
0.0455063
0.0452287
0.0449462
0.0446589
0.0443667
0.0440697
0.0437679
0.0434612
0.0431497
0.0428335
0.0425125
0.0421867
0.0418563
0.0415213
0.0411816
0.0408374
0.0404887
0.0401356
0.0397782
0.0394165
0.0390505
0.0386805
0.0383064
0.0379285
0.0375467
0.0371612
0.0367721
0.0363795
0.0359835
0.0355844
0.0351821
0.0347769
0.0343689
0.0339582
0.033545
0.0331294
0.0327117
0.0322919
0.0318703
0.031447
0.0310221
0.030596
0.0301687
0.0297404
0.0293113
0.0288817
0.0284516
0.0280214
0.0275911
0.0271611
0.0267314
0.0263024
0.0258742
0.025447
0.0250211
0.0245967
0.0241741
0.0237534
0.023335
0.0229192
0.0225063
0.0220965
0.0216903
0.021288
0.0208902
0.0204973
0.0201099
0.0197288
0.0193559
0.0190125
0.0480214
0.0477912
0.0475564
0.047317
0.0470729
0.0468241
0.0465706
0.0463123
0.0460492
0.0457813
0.0455086
0.0452311
0.0449487
0.0446615
0.0443695
0.0440726
0.0437708
0.0434643
0.0431529
0.0428368
0.042516
0.0421904
0.0418601
0.0415252
0.0411857
0.0408417
0.0404932
0.0401403
0.039783
0.0394215
0.0390558
0.038686
0.0383121
0.0379344
0.0375528
0.0371676
0.0367787
0.0363864
0.0359907
0.0355919
0.0351899
0.034785
0.0343773
0.0339669
0.033554
0.0331388
0.0327214
0.032302
0.0318807
0.0314578
0.0310333
0.0306075
0.0301806
0.0297527
0.029324
0.0288948
0.0284651
0.0280352
0.0276053
0.0271756
0.0267463
0.0263175
0.0258896
0.0254626
0.0250368
0.0246125
0.0241898
0.023769
0.0233503
0.0229339
0.0225203
0.0221095
0.021702
0.0212981
0.0208982
0.0205027
0.020112
0.0197268
0.0193491
0.0190006
0.0480227
0.0477926
0.0475579
0.0473186
0.0470745
0.0468258
0.0465723
0.0463141
0.0460511
0.0457833
0.0455107
0.0452332
0.044951
0.0446638
0.0443719
0.0440751
0.0437735
0.043467
0.0431558
0.0428398
0.042519
0.0421936
0.0418635
0.0415287
0.0411893
0.0408455
0.0404971
0.0401444
0.0397873
0.0394259
0.0390604
0.0386908
0.0383171
0.0379396
0.0375582
0.0371732
0.0367846
0.0363925
0.0359971
0.0355984
0.0351967
0.0347921
0.0343846
0.0339746
0.033562
0.0331471
0.03273
0.0323109
0.0318899
0.0314673
0.0310432
0.0306178
0.0301912
0.0297637
0.0293354
0.0289065
0.0284771
0.0280476
0.0276181
0.0271887
0.0267597
0.0263313
0.0259036
0.0254769
0.0250513
0.0246272
0.0242046
0.0237838
0.023365
0.0229484
0.0225344
0.0221231
0.0217148
0.0213098
0.0209085
0.0205111
0.0201181
0.01973
0.0193488
0.0189966
0.048024
0.0477939
0.0475593
0.04732
0.047076
0.0468273
0.0465739
0.0463158
0.0460528
0.0457851
0.0455125
0.0452352
0.0449529
0.0446659
0.044374
0.0440773
0.0437758
0.0434694
0.0431583
0.0428424
0.0425218
0.0421964
0.0418664
0.0415318
0.0411925
0.0408488
0.0405006
0.040148
0.039791
0.0394298
0.0390644
0.038695
0.0383215
0.0379441
0.037563
0.0371781
0.0367897
0.0363978
0.0360026
0.0356042
0.0352027
0.0347983
0.0343911
0.0339813
0.033569
0.0331543
0.0327375
0.0323187
0.031898
0.0314757
0.0310519
0.0306268
0.0302005
0.0297733
0.0293454
0.0289168
0.0284878
0.0280587
0.0276295
0.0272004
0.0267718
0.0263437
0.0259163
0.0254899
0.0250646
0.0246406
0.0242182
0.0237976
0.0233788
0.0229623
0.0225481
0.0221365
0.0217277
0.0213221
0.0209199
0.0205213
0.0201267
0.0197366
0.0193529
0.0189981
0.0480251
0.0477951
0.0475605
0.0473212
0.0470773
0.0468287
0.0465753
0.0463172
0.0460543
0.0457867
0.0455142
0.0452369
0.0449547
0.0446677
0.0443759
0.0440793
0.0437778
0.0434716
0.0431605
0.0428447
0.0425242
0.0421989
0.041869
0.0415345
0.0411953
0.0408517
0.0405036
0.0401511
0.0397943
0.0394332
0.039068
0.0386986
0.0383253
0.0379481
0.0375671
0.0371824
0.0367942
0.0364025
0.0360074
0.0356092
0.0352079
0.0348037
0.0343967
0.0339871
0.033575
0.0331606
0.0327441
0.0323255
0.0319051
0.0314831
0.0310595
0.0306347
0.0302087
0.0297818
0.0293541
0.0289259
0.0284972
0.0280684
0.0276395
0.0272108
0.0267825
0.0263547
0.0259276
0.0255015
0.0250765
0.0246528
0.0242306
0.0238102
0.0233916
0.0229751
0.0225609
0.0221493
0.0217403
0.0213344
0.0209316
0.0205322
0.0201366
0.0197452
0.0193598
0.0190033
0.0480262
0.0477962
0.0475616
0.0473224
0.0470785
0.0468299
0.0465766
0.0463185
0.0460557
0.0457881
0.0455156
0.0452384
0.0449563
0.0446694
0.0443776
0.0440811
0.0437797
0.0434735
0.0431625
0.0428468
0.0425263
0.0422011
0.0418713
0.0415368
0.0411978
0.0408543
0.0405063
0.0401539
0.0397972
0.0394362
0.0390711
0.0387019
0.0383287
0.0379516
0.0375707
0.0371862
0.0367981
0.0364065
0.0360117
0.0356136
0.0352125
0.0348085
0.0344017
0.0339922
0.0335803
0.0331661
0.0327498
0.0323314
0.0319113
0.0314895
0.0310662
0.0306416
0.0302159
0.0297892
0.0293618
0.0289338
0.0285055
0.0280769
0.0276483
0.0272199
0.0267919
0.0263644
0.0259376
0.0255118
0.0250871
0.0246637
0.0242418
0.0238215
0.0234032
0.0229869
0.0225728
0.0221612
0.0217522
0.0213461
0.0209431
0.0205433
0.0201471
0.0197548
0.0193683
0.0190106
0.0480271
0.0477971
0.0475626
0.0473234
0.0470795
0.046831
0.0465777
0.0463197
0.0460569
0.0457893
0.0455169
0.0452397
0.0449577
0.0446708
0.0443791
0.0440826
0.0437813
0.0434751
0.0431642
0.0428486
0.0425282
0.0422031
0.0418733
0.0415389
0.0412
0.0408565
0.0405086
0.0401563
0.0397997
0.0394388
0.0390738
0.0387047
0.0383316
0.0379546
0.0375739
0.0371895
0.0368015
0.0364101
0.0360153
0.0356174
0.0352164
0.0348126
0.0344059
0.0339967
0.0335849
0.0331709
0.0327547
0.0323366
0.0319166
0.031495
0.0310719
0.0306475
0.0302221
0.0297956
0.0293685
0.0289407
0.0285126
0.0280843
0.027656
0.0272279
0.0268001
0.0263729
0.0259464
0.0255208
0.0250964
0.0246733
0.0242516
0.0238316
0.0234135
0.0229974
0.0225835
0.022172
0.0217632
0.021357
0.0209539
0.020554
0.0201574
0.0197646
0.0193774
0.0190191
0.0480279
0.047798
0.0475635
0.0473243
0.0470805
0.046832
0.0465787
0.0463207
0.046058
0.0457904
0.0455181
0.0452409
0.0449589
0.0446721
0.0443805
0.044084
0.0437827
0.0434766
0.0431658
0.0428502
0.0425298
0.0422048
0.0418751
0.0415408
0.0412019
0.0408585
0.0405107
0.0401584
0.0398019
0.0394411
0.0390762
0.0387071
0.0383342
0.0379573
0.0375766
0.0371923
0.0368044
0.0364131
0.0360185
0.0356207
0.0352199
0.0348161
0.0344096
0.0340005
0.0335889
0.033175
0.032759
0.032341
0.0319212
0.0314998
0.0310769
0.0306527
0.0302274
0.0298012
0.0293742
0.0289467
0.0285188
0.0280907
0.0276627
0.0272348
0.0268072
0.0263803
0.025954
0.0255287
0.0251046
0.0246817
0.0242603
0.0238405
0.0234226
0.0230068
0.0225931
0.0221818
0.0217731
0.021367
0.0209639
0.0205639
0.0201672
0.0197742
0.0193866
0.0190279
0.0480286
0.0477987
0.0475642
0.0473251
0.0470813
0.0468328
0.0465796
0.0463217
0.046059
0.0457914
0.0455191
0.045242
0.04496
0.0446732
0.0443816
0.0440852
0.043784
0.0434779
0.0431671
0.0428516
0.0425313
0.0422063
0.0418766
0.0415424
0.0412036
0.0408602
0.0405125
0.0401603
0.0398038
0.0394431
0.0390782
0.0387093
0.0383364
0.0379596
0.037579
0.0371948
0.036807
0.0364158
0.0360213
0.0356236
0.0352229
0.0348192
0.0344128
0.0340038
0.0335924
0.0331786
0.0327627
0.0323449
0.0319252
0.0315039
0.0310812
0.0306572
0.0302321
0.029806
0.0293792
0.0289519
0.0285242
0.0280963
0.0276684
0.0272407
0.0268134
0.0263867
0.0259607
0.0255356
0.0251116
0.024689
0.0242678
0.0238483
0.0234307
0.023015
0.0226015
0.0221904
0.0217819
0.021376
0.020973
0.0205731
0.0201764
0.0197832
0.0193954
0.0190366
0.0480293
0.0477994
0.0475649
0.0473258
0.0470821
0.0468336
0.0465804
0.0463225
0.0460598
0.0457923
0.04552
0.0452429
0.044961
0.0446742
0.0443827
0.0440863
0.0437851
0.0434791
0.0431683
0.0428528
0.0425325
0.0422076
0.041878
0.0415438
0.041205
0.0408617
0.040514
0.0401619
0.0398055
0.0394449
0.03908
0.0387112
0.0383383
0.0379616
0.0375811
0.037197
0.0368092
0.0364181
0.0360237
0.0356261
0.0352254
0.0348219
0.0344156
0.0340067
0.0335954
0.0331817
0.032766
0.0323482
0.0319287
0.0315075
0.0310849
0.030661
0.030236
0.0298101
0.0293835
0.0289563
0.0285288
0.0281011
0.0276734
0.0272459
0.0268187
0.0263922
0.0259664
0.0255415
0.0251178
0.0246953
0.0242744
0.0238551
0.0234376
0.0230222
0.0226089
0.022198
0.0217896
0.0213839
0.0209811
0.0205813
0.0201846
0.0197915
0.0194037
0.0190449
0.0480299
0.0478
0.0475656
0.0473265
0.0470827
0.0468343
0.0465811
0.0463232
0.0460606
0.0457931
0.0455208
0.0452438
0.0449619
0.0446751
0.0443836
0.0440872
0.0437861
0.0434801
0.0431694
0.0428539
0.0425337
0.0422088
0.0418792
0.041545
0.0412063
0.0408631
0.0405154
0.0401633
0.039807
0.0394464
0.0390816
0.0387128
0.03834
0.0379634
0.0375829
0.0371988
0.0368112
0.0364201
0.0360258
0.0356282
0.0352277
0.0348242
0.034418
0.0340092
0.0335979
0.0331844
0.0327687
0.0323511
0.0319317
0.0315106
0.0310881
0.0306643
0.0302395
0.0298137
0.0293872
0.0289602
0.0285328
0.0281052
0.0276776
0.0272503
0.0268233
0.0263969
0.0259713
0.0255466
0.025123
0.0247008
0.02428
0.0238609
0.0234437
0.0230284
0.0226154
0.0222046
0.0217964
0.0213909
0.0209882
0.0205885
0.020192
0.0197989
0.0194112
0.0190525
0.0480304
0.0478006
0.0475661
0.0473271
0.0470833
0.0468349
0.0465818
0.0463239
0.0460612
0.0457938
0.0455215
0.0452445
0.0449626
0.0446759
0.0443844
0.0440881
0.0437869
0.043481
0.0431703
0.0428548
0.0425346
0.0422098
0.0418803
0.0415461
0.0412074
0.0408642
0.0405166
0.0401646
0.0398083
0.0394477
0.039083
0.0387142
0.0383415
0.0379649
0.0375845
0.0372005
0.0368129
0.0364219
0.0360276
0.0356301
0.0352296
0.0348262
0.0344201
0.0340114
0.0336002
0.0331867
0.0327711
0.0323536
0.0319342
0.0315133
0.0310909
0.0306672
0.0302424
0.0298168
0.0293904
0.0289635
0.0285362
0.0281087
0.0276813
0.0272541
0.0268273
0.026401
0.0259755
0.025551
0.0251276
0.0247055
0.0242849
0.023866
0.0234489
0.0230338
0.0226209
0.0222104
0.0218023
0.021397
0.0209944
0.0205949
0.0201985
0.0198055
0.0194179
0.0190594
0.0480309
0.0478011
0.0475666
0.0473276
0.0470839
0.0468355
0.0465823
0.0463245
0.0460618
0.0457944
0.0455222
0.0452451
0.0449633
0.0446766
0.0443851
0.0440888
0.0437877
0.0434818
0.0431711
0.0428557
0.0425355
0.0422107
0.0418812
0.0415471
0.0412084
0.0408653
0.0405177
0.0401657
0.0398094
0.0394489
0.0390842
0.0387155
0.0383428
0.0379662
0.0375859
0.0372019
0.0368144
0.0364234
0.0360292
0.0356318
0.0352313
0.034828
0.0344219
0.0340132
0.0336021
0.0331887
0.0327732
0.0323557
0.0319365
0.0315156
0.0310933
0.0306697
0.030245
0.0298194
0.0293931
0.0289663
0.0285391
0.0281118
0.0276845
0.0272573
0.0268306
0.0264045
0.0259791
0.0255547
0.0251315
0.0247095
0.0242891
0.0238703
0.0234533
0.0230384
0.0226257
0.0222153
0.0218074
0.0214022
0.0209998
0.0206004
0.0202042
0.0198113
0.0194238
0.0190655
0.0480313
0.0478015
0.0475671
0.047328
0.0470843
0.0468359
0.0465828
0.046325
0.0460624
0.0457949
0.0455227
0.0452457
0.0449639
0.0446772
0.0443858
0.0440895
0.0437884
0.0434825
0.0431718
0.0428564
0.0425363
0.0422115
0.041882
0.0415479
0.0412093
0.0408662
0.0405186
0.0401666
0.0398104
0.0394499
0.0390853
0.0387166
0.0383439
0.0379674
0.0375871
0.0372031
0.0368156
0.0364247
0.0360305
0.0356332
0.0352328
0.0348295
0.0344235
0.0340148
0.0336038
0.0331904
0.032775
0.0323576
0.0319384
0.0315176
0.0310953
0.0306718
0.0302472
0.0298217
0.0293955
0.0289687
0.0285416
0.0281144
0.0276872
0.0272601
0.0268335
0.0264075
0.0259822
0.025558
0.0251348
0.024713
0.0242926
0.023874
0.0234571
0.0230424
0.0226298
0.0222195
0.0218118
0.0214067
0.0210045
0.0206052
0.0202091
0.0198164
0.019429
0.0190708
0.0480317
0.0478019
0.0475675
0.0473284
0.0470848
0.0468364
0.0465833
0.0463254
0.0460628
0.0457954
0.0455232
0.0452462
0.0449644
0.0446778
0.0443863
0.04409
0.043789
0.0434831
0.0431724
0.0428571
0.0425369
0.0422121
0.0418827
0.0415487
0.04121
0.0408669
0.0405194
0.0401675
0.0398112
0.0394508
0.0390862
0.0387175
0.0383449
0.0379684
0.0375881
0.0372042
0.0368168
0.0364259
0.0360317
0.0356344
0.035234
0.0348308
0.0344248
0.0340162
0.0336052
0.0331919
0.0327765
0.0323592
0.03194
0.0315193
0.0310971
0.0306736
0.0302491
0.0298236
0.0293975
0.0289708
0.0285438
0.0281166
0.0276895
0.0272625
0.026836
0.0264101
0.0259849
0.0255607
0.0251376
0.0247159
0.0242957
0.0238771
0.0234604
0.0230457
0.0226332
0.0222231
0.0218155
0.0214106
0.0210085
0.0206093
0.0202133
0.0198207
0.0194335
0.0190755
0.048032
0.0478022
0.0475678
0.0473288
0.0470851
0.0468368
0.0465837
0.0463258
0.0460632
0.0457959
0.0455237
0.0452467
0.0449649
0.0446782
0.0443868
0.0440905
0.0437895
0.0434836
0.043173
0.0428576
0.0425375
0.0422128
0.0418833
0.0415493
0.0412107
0.0408676
0.0405201
0.0401682
0.039812
0.0394516
0.039087
0.0387183
0.0383457
0.0379693
0.037589
0.0372051
0.0368177
0.0364269
0.0360327
0.0356355
0.0352351
0.0348319
0.034426
0.0340174
0.0336065
0.0331932
0.0327779
0.0323605
0.0319414
0.0315207
0.0310986
0.0306752
0.0302507
0.0298253
0.0293992
0.0289726
0.0285456
0.0281185
0.0276914
0.0272646
0.0268381
0.0264123
0.0259872
0.025563
0.0251401
0.0247184
0.0242983
0.0238798
0.0234632
0.0230486
0.0226362
0.0222262
0.0218187
0.0214139
0.0210119
0.0206128
0.020217
0.0198245
0.0194373
0.0190795
0.0480323
0.0478025
0.0475681
0.0473291
0.0470854
0.0468371
0.046584
0.0463262
0.0460636
0.0457962
0.0455241
0.0452471
0.0449653
0.0446787
0.0443872
0.044091
0.0437899
0.0434841
0.0431735
0.0428581
0.042538
0.0422133
0.0418839
0.0415499
0.0412113
0.0408682
0.0405207
0.0401688
0.0398126
0.0394522
0.0390877
0.0387191
0.0383465
0.03797
0.0375898
0.037206
0.0368186
0.0364277
0.0360336
0.0356364
0.0352361
0.0348329
0.034427
0.0340185
0.0336076
0.0331943
0.032779
0.0323617
0.0319427
0.031522
0.0310999
0.0306765
0.0302521
0.0298268
0.0294007
0.0289741
0.0285472
0.0281202
0.0276931
0.0272663
0.0268399
0.0264141
0.0259891
0.0255651
0.0251421
0.0247206
0.0243005
0.0238821
0.0234656
0.0230511
0.0226388
0.0222288
0.0218214
0.0214167
0.0210148
0.0206158
0.0202201
0.0198277
0.0194406
0.0190829
0.0480326
0.0478028
0.0475684
0.0473294
0.0470857
0.0468374
0.0465843
0.0463265
0.0460639
0.0457966
0.0455244
0.0452474
0.0449656
0.044679
0.0443876
0.0440914
0.0437903
0.0434845
0.0431739
0.0428586
0.0425385
0.0422137
0.0418843
0.0415503
0.0412118
0.0408687
0.0405212
0.0401694
0.0398132
0.0394528
0.0390883
0.0387197
0.0383471
0.0379707
0.0375905
0.0372067
0.0368193
0.0364285
0.0360344
0.0356372
0.0352369
0.0348338
0.0344279
0.0340194
0.0336085
0.0331953
0.03278
0.0323627
0.0319437
0.0315231
0.031101
0.0306777
0.0302533
0.029828
0.029402
0.0289755
0.0285486
0.0281216
0.0276946
0.0272678
0.0268415
0.0264157
0.0259908
0.0255668
0.0251439
0.0247224
0.0243024
0.0238841
0.0234676
0.0230532
0.0226409
0.0222311
0.0218237
0.0214191
0.0210172
0.0206184
0.0202227
0.0198304
0.0194434
0.0190859
0.0480328
0.047803
0.0475686
0.0473296
0.047086
0.0468376
0.0465846
0.0463268
0.0460642
0.0457968
0.0455247
0.0452477
0.044966
0.0446794
0.0443879
0.0440917
0.0437907
0.0434849
0.0431743
0.0428589
0.0425389
0.0422141
0.0418848
0.0415508
0.0412122
0.0408692
0.0405217
0.0401699
0.0398137
0.0394533
0.0390888
0.0387202
0.0383477
0.0379713
0.0375911
0.0372073
0.0368199
0.0364291
0.0360351
0.0356379
0.0352376
0.0348345
0.0344286
0.0340202
0.0336093
0.0331961
0.0327808
0.0323636
0.0319446
0.031524
0.031102
0.0306787
0.0302543
0.0298291
0.0294031
0.0289766
0.0285498
0.0281228
0.0276958
0.0272691
0.0268428
0.0264171
0.0259922
0.0255682
0.0251454
0.024724
0.024304
0.0238857
0.0234693
0.0230549
0.0226428
0.022233
0.0218257
0.0214211
0.0210193
0.0206206
0.0202249
0.0198327
0.0194458
0.0190884
0.048033
0.0478032
0.0475689
0.0473299
0.0470862
0.0468379
0.0465848
0.046327
0.0460644
0.0457971
0.045525
0.045248
0.0449662
0.0446796
0.0443882
0.044092
0.043791
0.0434852
0.0431746
0.0428593
0.0425392
0.0422145
0.0418851
0.0415512
0.0412126
0.0408696
0.0405221
0.0401703
0.0398141
0.0394538
0.0390893
0.0387207
0.0383482
0.0379718
0.0375916
0.0372078
0.0368205
0.0364297
0.0360357
0.0356384
0.0352382
0.0348351
0.0344293
0.0340208
0.03361
0.0331968
0.0327816
0.0323644
0.0319454
0.0315248
0.0311028
0.0306795
0.0302552
0.02983
0.029404
0.0289776
0.0285508
0.0281238
0.0276969
0.0272702
0.0268439
0.0264183
0.0259934
0.0255695
0.0251467
0.0247253
0.0243054
0.0238871
0.0234708
0.0230565
0.0226443
0.0222346
0.0218274
0.0214228
0.0210211
0.0206224
0.0202268
0.0198347
0.0194479
0.0190905
0.0480332
0.0478034
0.047569
0.0473301
0.0470864
0.0468381
0.046585
0.0463272
0.0460647
0.0457973
0.0455252
0.0452482
0.0449665
0.0446799
0.0443885
0.0440923
0.0437913
0.0434855
0.0431749
0.0428596
0.0425395
0.0422148
0.0418854
0.0415515
0.041213
0.0408699
0.0405225
0.0401706
0.0398145
0.0394542
0.0390897
0.0387211
0.0383486
0.0379722
0.037592
0.0372083
0.0368209
0.0364302
0.0360362
0.035639
0.0352387
0.0348357
0.0344298
0.0340214
0.0336106
0.0331974
0.0327822
0.032365
0.0319461
0.0315255
0.0311035
0.0306803
0.0302559
0.0298307
0.0294048
0.0289784
0.0285516
0.0281247
0.0276978
0.0272711
0.0268449
0.0264193
0.0259944
0.0255705
0.0251478
0.0247264
0.0243065
0.0238883
0.023472
0.0230577
0.0226457
0.022236
0.0218288
0.0214243
0.0210226
0.020624
0.0202285
0.0198364
0.0194496
0.0190923
0.0480333
0.0478036
0.0475692
0.0473302
0.0470866
0.0468382
0.0465852
0.0463274
0.0460649
0.0457975
0.0455254
0.0452484
0.0449667
0.0446801
0.0443887
0.0440925
0.0437915
0.0434857
0.0431751
0.0428598
0.0425398
0.0422151
0.0418857
0.0415518
0.0412132
0.0408702
0.0405228
0.040171
0.0398148
0.0394545
0.03909
0.0387214
0.0383489
0.0379726
0.0375924
0.0372086
0.0368213
0.0364306
0.0360366
0.0356394
0.0352392
0.0348361
0.0344303
0.0340219
0.0336111
0.033198
0.0327827
0.0323656
0.0319466
0.0315261
0.0311041
0.0306809
0.0302566
0.0298314
0.0294055
0.0289791
0.0285523
0.0281254
0.0276986
0.0272719
0.0268457
0.0264201
0.0259953
0.0255714
0.0251487
0.0247274
0.0243075
0.0238894
0.0234731
0.0230588
0.0226468
0.0222371
0.02183
0.0214255
0.0210239
0.0206253
0.0202298
0.0198378
0.0194511
0.0190939
0.0480335
0.0478037
0.0475693
0.0473304
0.0470867
0.0468384
0.0465854
0.0463276
0.046065
0.0457977
0.0455256
0.0452486
0.0449669
0.0446803
0.0443889
0.0440927
0.0437917
0.0434859
0.0431753
0.04286
0.04254
0.0422153
0.041886
0.041552
0.0412135
0.0408705
0.040523
0.0401712
0.0398151
0.0394548
0.0390903
0.0387218
0.0383492
0.0379729
0.0375928
0.037209
0.0368217
0.036431
0.0360369
0.0356398
0.0352396
0.0348365
0.0344307
0.0340223
0.0336115
0.0331984
0.0327832
0.0323661
0.0319471
0.0315266
0.0311046
0.0306814
0.0302571
0.029832
0.0294061
0.0289797
0.0285529
0.0281261
0.0276992
0.0272726
0.0268464
0.0264208
0.025996
0.0255722
0.0251495
0.0247282
0.0243083
0.0238902
0.023474
0.0230597
0.0226477
0.0222381
0.021831
0.0214266
0.021025
0.0206264
0.020231
0.019839
0.0194523
0.0190952
0.0480336
0.0478038
0.0475695
0.0473305
0.0470869
0.0468385
0.0465855
0.0463277
0.0460652
0.0457978
0.0455257
0.0452488
0.044967
0.0446805
0.0443891
0.0440929
0.0437919
0.0434861
0.0431755
0.0428602
0.0425402
0.0422155
0.0418862
0.0415522
0.0412137
0.0408707
0.0405233
0.0401715
0.0398154
0.039455
0.0390905
0.038722
0.0383495
0.0379732
0.037593
0.0372093
0.036822
0.0364313
0.0360373
0.0356401
0.0352399
0.0348369
0.0344311
0.0340227
0.0336119
0.0331988
0.0327836
0.0323665
0.0319475
0.031527
0.0311051
0.0306819
0.0302576
0.0298324
0.0294066
0.0289802
0.0285535
0.0281266
0.0276998
0.0272732
0.026847
0.0264214
0.0259966
0.0255728
0.0251502
0.0247289
0.0243091
0.023891
0.0234747
0.0230605
0.0226485
0.0222389
0.0218318
0.0214275
0.0210259
0.0206274
0.020232
0.01984
0.0194534
0.0190963
0.0480337
0.0478039
0.0475696
0.0473306
0.047087
0.0468387
0.0465856
0.0463278
0.0460653
0.045798
0.0455258
0.0452489
0.0449672
0.0446806
0.0443892
0.044093
0.043792
0.0434862
0.0431757
0.0428604
0.0425404
0.0422157
0.0418863
0.0415524
0.0412139
0.0408709
0.0405235
0.0401717
0.0398156
0.0394552
0.0390908
0.0387222
0.0383497
0.0379734
0.0375933
0.0372095
0.0368222
0.0364315
0.0360375
0.0356404
0.0352402
0.0348372
0.0344314
0.034023
0.0336122
0.0331991
0.0327839
0.0323668
0.0319479
0.0315274
0.0311054
0.0306823
0.030258
0.0298328
0.029407
0.0289806
0.0285539
0.0281271
0.0277002
0.0272737
0.0268475
0.0264219
0.0259972
0.0255734
0.0251507
0.0247294
0.0243096
0.0238916
0.0234753
0.0230612
0.0226492
0.0222396
0.0218326
0.0214282
0.0210267
0.0206282
0.0202328
0.0198408
0.0194542
0.0190972
0.0480338
0.047804
0.0475697
0.0473307
0.0470871
0.0468388
0.0465857
0.0463279
0.0460654
0.0457981
0.045526
0.045249
0.0449673
0.0446807
0.0443893
0.0440932
0.0437922
0.0434864
0.0431758
0.0428605
0.0425405
0.0422158
0.0418865
0.0415526
0.0412141
0.0408711
0.0405236
0.0401718
0.0398157
0.0394554
0.039091
0.0387224
0.0383499
0.0379736
0.0375935
0.0372097
0.0368225
0.0364318
0.0360378
0.0356406
0.0352405
0.0348374
0.0344316
0.0340233
0.0336125
0.0331994
0.0327842
0.0323671
0.0319482
0.0315277
0.0311058
0.0306826
0.0302583
0.0298332
0.0294073
0.028981
0.0285543
0.0281274
0.0277006
0.0272741
0.0268479
0.0264224
0.0259976
0.0255738
0.0251512
0.0247299
0.0243101
0.0238921
0.0234759
0.0230617
0.0226498
0.0222402
0.0218332
0.0214288
0.0210273
0.0206288
0.0202335
0.0198415
0.019455
0.019098
0.0480338
0.0478041
0.0475698
0.0473308
0.0470872
0.0468388
0.0465858
0.046328
0.0460655
0.0457982
0.0455261
0.0452491
0.0449674
0.0446808
0.0443894
0.0440933
0.0437923
0.0434865
0.043176
0.0428607
0.0425407
0.042216
0.0418866
0.0415527
0.0412142
0.0408712
0.0405238
0.040172
0.0398159
0.0394556
0.0390911
0.0387226
0.0383501
0.0379738
0.0375937
0.0372099
0.0368226
0.0364319
0.036038
0.0356408
0.0352407
0.0348376
0.0344318
0.0340235
0.0336127
0.0331996
0.0327845
0.0323673
0.0319484
0.0315279
0.031106
0.0306828
0.0302586
0.0298335
0.0294076
0.0289813
0.0285546
0.0281278
0.027701
0.0272744
0.0268483
0.0264227
0.025998
0.0255742
0.0251516
0.0247303
0.0243106
0.0238925
0.0234763
0.0230622
0.0226502
0.0222407
0.0218337
0.0214293
0.0210279
0.0206294
0.020234
0.0198421
0.0194556
0.0190986
0.0480339
0.0478042
0.0475698
0.0473309
0.0470872
0.0468389
0.0465859
0.0463281
0.0460656
0.0457983
0.0455261
0.0452492
0.0449675
0.0446809
0.0443895
0.0440934
0.0437924
0.0434866
0.0431761
0.0428608
0.0425408
0.0422161
0.0418867
0.0415528
0.0412143
0.0408713
0.0405239
0.0401721
0.039816
0.0394557
0.0390913
0.0387227
0.0383503
0.0379739
0.0375938
0.0372101
0.0368228
0.0364321
0.0360381
0.035641
0.0352408
0.0348378
0.034432
0.0340237
0.0336129
0.0331998
0.0327847
0.0323675
0.0319487
0.0315282
0.0311062
0.0306831
0.0302588
0.0298337
0.0294079
0.0289815
0.0285548
0.028128
0.0277012
0.0272747
0.0268485
0.026423
0.0259983
0.0255745
0.0251519
0.0247306
0.0243109
0.0238929
0.0234767
0.0230625
0.0226506
0.0222411
0.0218341
0.0214298
0.0210283
0.0206298
0.0202345
0.0198426
0.0194561
0.0190991
0.048034
0.0478042
0.0475699
0.0473309
0.0470873
0.046839
0.046586
0.0463282
0.0460656
0.0457983
0.0455262
0.0452493
0.0449676
0.044681
0.0443896
0.0440934
0.0437925
0.0434867
0.0431761
0.0428609
0.0425409
0.0422162
0.0418868
0.0415529
0.0412144
0.0408714
0.040524
0.0401722
0.0398161
0.0394558
0.0390914
0.0387229
0.0383504
0.037974
0.0375939
0.0372102
0.0368229
0.0364322
0.0360383
0.0356411
0.035241
0.0348379
0.0344322
0.0340238
0.033613
0.0332
0.0327848
0.0323677
0.0319488
0.0315283
0.0311064
0.0306833
0.030259
0.0298339
0.0294081
0.0289817
0.0285551
0.0281282
0.0277015
0.0272749
0.0268488
0.0264233
0.0259985
0.0255748
0.0251522
0.0247309
0.0243112
0.0238931
0.023477
0.0230629
0.0226509
0.0222414
0.0218344
0.0214301
0.0210287
0.0206302
0.0202349
0.019843
0.0194565
0.0190996
0.048034
0.0478043
0.0475699
0.047331
0.0470874
0.046839
0.046586
0.0463282
0.0460657
0.0457984
0.0455263
0.0452494
0.0449676
0.0446811
0.0443897
0.0440935
0.0437925
0.0434868
0.0431762
0.0428609
0.0425409
0.0422162
0.0418869
0.041553
0.0412145
0.0408715
0.0405241
0.0401723
0.0398162
0.0394559
0.0390915
0.038723
0.0383505
0.0379741
0.0375941
0.0372103
0.036823
0.0364324
0.0360384
0.0356413
0.0352411
0.0348381
0.0344323
0.034024
0.0336132
0.0332001
0.032785
0.0323679
0.031949
0.0315285
0.0311066
0.0306834
0.0302592
0.0298341
0.0294083
0.0289819
0.0285552
0.0281284
0.0277017
0.0272751
0.026849
0.0264235
0.0259987
0.025575
0.0251524
0.0247311
0.0243114
0.0238934
0.0234772
0.0230631
0.0226512
0.0222417
0.0218347
0.0214304
0.0210289
0.0206305
0.0202352
0.0198433
0.0194568
0.0190999
0.0480341
0.0478043
0.04757
0.047331
0.0470874
0.0468391
0.0465861
0.0463283
0.0460658
0.0457984
0.0455263
0.0452494
0.0449677
0.0446811
0.0443898
0.0440936
0.0437926
0.0434868
0.0431763
0.042861
0.042541
0.0422163
0.041887
0.0415531
0.0412146
0.0408716
0.0405242
0.0401724
0.0398163
0.039456
0.0390915
0.038723
0.0383506
0.0379742
0.0375941
0.0372104
0.0368231
0.0364325
0.0360385
0.0356414
0.0352412
0.0348382
0.0344324
0.0340241
0.0336133
0.0332002
0.0327851
0.032368
0.0319491
0.0315286
0.0311067
0.0306836
0.0302593
0.0298342
0.0294084
0.0289821
0.0285554
0.0281286
0.0277018
0.0272753
0.0268491
0.0264236
0.0259989
0.0255752
0.0251526
0.0247313
0.0243116
0.0238936
0.0234774
0.0230633
0.0226514
0.0222419
0.0218349
0.0214306
0.0210292
0.0206307
0.0202354
0.0198436
0.0194571
0.0191002
0.0480341
0.0478044
0.04757
0.0473311
0.0470874
0.0468391
0.0465861
0.0463283
0.0460658
0.0457985
0.0455264
0.0452495
0.0449677
0.0446812
0.0443898
0.0440936
0.0437926
0.0434869
0.0431763
0.0428611
0.0425411
0.0422164
0.041887
0.0415531
0.0412146
0.0408717
0.0405242
0.0401725
0.0398164
0.0394561
0.0390916
0.0387231
0.0383506
0.0379743
0.0375942
0.0372105
0.0368232
0.0364325
0.0360386
0.0356414
0.0352413
0.0348383
0.0344325
0.0340242
0.0336134
0.0332003
0.0327852
0.0323681
0.0319492
0.0315287
0.0311068
0.0306837
0.0302594
0.0298343
0.0294085
0.0289822
0.0285555
0.0281287
0.0277019
0.0272754
0.0268493
0.0264238
0.025999
0.0255753
0.0251527
0.0247315
0.0243117
0.0238937
0.0234776
0.0230635
0.0226516
0.0222421
0.0218351
0.0214308
0.0210294
0.0206309
0.0202357
0.0198438
0.0194573
0.0191005
0.0480341
0.0478044
0.0475701
0.0473311
0.0470875
0.0468392
0.0465861
0.0463284
0.0460658
0.0457985
0.0455264
0.0452495
0.0449678
0.0446812
0.0443898
0.0440937
0.0437927
0.0434869
0.0431764
0.0428611
0.0425411
0.0422164
0.0418871
0.0415532
0.0412147
0.0408717
0.0405243
0.0401725
0.0398164
0.0394561
0.0390917
0.0387232
0.0383507
0.0379744
0.0375943
0.0372105
0.0368233
0.0364326
0.0360386
0.0356415
0.0352414
0.0348383
0.0344326
0.0340242
0.0336135
0.0332004
0.0327853
0.0323682
0.0319493
0.0315288
0.0311069
0.0306837
0.0302595
0.0298344
0.0294086
0.0289823
0.0285556
0.0281288
0.027702
0.0272755
0.0268494
0.0264239
0.0259991
0.0255754
0.0251528
0.0247316
0.0243119
0.0238938
0.0234777
0.0230636
0.0226517
0.0222422
0.0218352
0.021431
0.0210295
0.0206311
0.0202358
0.019844
0.0194575
0.0191006
0.0480342
0.0478044
0.0475701
0.0473311
0.0470875
0.0468392
0.0465862
0.0463284
0.0460659
0.0457986
0.0455264
0.0452495
0.0449678
0.0446812
0.0443899
0.0440937
0.0437927
0.043487
0.0431764
0.0428611
0.0425411
0.0422165
0.0418871
0.0415532
0.0412147
0.0408718
0.0405243
0.0401726
0.0398165
0.0394562
0.0390917
0.0387232
0.0383507
0.0379744
0.0375943
0.0372106
0.0368233
0.0364326
0.0360387
0.0356416
0.0352414
0.0348384
0.0344326
0.0340243
0.0336135
0.0332005
0.0327853
0.0323682
0.0319493
0.0315289
0.031107
0.0306838
0.0302596
0.0298345
0.0294087
0.0289823
0.0285557
0.0281289
0.0277021
0.0272756
0.0268494
0.0264239
0.0259992
0.0255755
0.0251529
0.0247317
0.024312
0.0238939
0.0234778
0.0230637
0.0226518
0.0222423
0.0218353
0.0214311
0.0210296
0.0206312
0.0202359
0.0198441
0.0194576
0.0191008
0.0480342
0.0478045
0.0475701
0.0473312
0.0470875
0.0468392
0.0465862
0.0463284
0.0460659
0.0457986
0.0455265
0.0452496
0.0449678
0.0446813
0.0443899
0.0440937
0.0437928
0.043487
0.0431765
0.0428612
0.0425412
0.0422165
0.0418872
0.0415532
0.0412148
0.0408718
0.0405244
0.0401726
0.0398165
0.0394562
0.0390918
0.0387233
0.0383508
0.0379745
0.0375944
0.0372106
0.0368234
0.0364327
0.0360387
0.0356416
0.0352415
0.0348384
0.0344327
0.0340243
0.0336136
0.0332005
0.0327854
0.0323683
0.0319494
0.0315289
0.031107
0.0306839
0.0302596
0.0298345
0.0294087
0.0289824
0.0285557
0.0281289
0.0277022
0.0272756
0.0268495
0.026424
0.0259993
0.0255755
0.025153
0.0247317
0.024312
0.023894
0.0234779
0.0230638
0.0226519
0.0222424
0.0218354
0.0214311
0.0210297
0.0206313
0.020236
0.0198442
0.0194577
0.0191009
0.0480342
0.0478045
0.0475701
0.0473312
0.0470876
0.0468392
0.0465862
0.0463285
0.0460659
0.0457986
0.0455265
0.0452496
0.0449678
0.0446813
0.0443899
0.0440938
0.0437928
0.043487
0.0431765
0.0428612
0.0425412
0.0422165
0.0418872
0.0415533
0.0412148
0.0408718
0.0405244
0.0401726
0.0398165
0.0394562
0.0390918
0.0387233
0.0383508
0.0379745
0.0375944
0.0372107
0.0368234
0.0364327
0.0360388
0.0356416
0.0352415
0.0348385
0.0344327
0.0340244
0.0336136
0.0332006
0.0327854
0.0323683
0.0319494
0.031529
0.0311071
0.0306839
0.0302597
0.0298346
0.0294088
0.0289824
0.0285558
0.028129
0.0277022
0.0272757
0.0268495
0.026424
0.0259993
0.0255756
0.025153
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.0226519
0.0222424
0.0218355
0.0214312
0.0210298
0.0206314
0.0202361
0.0198442
0.0194578
0.019101
0.0480342
0.0478045
0.0475702
0.0473312
0.0470876
0.0468393
0.0465862
0.0463285
0.0460659
0.0457986
0.0455265
0.0452496
0.0449679
0.0446813
0.04439
0.0440938
0.0437928
0.043487
0.0431765
0.0428612
0.0425412
0.0422165
0.0418872
0.0415533
0.0412148
0.0408718
0.0405244
0.0401727
0.0398166
0.0394563
0.0390918
0.0387233
0.0383508
0.0379745
0.0375944
0.0372107
0.0368234
0.0364328
0.0360388
0.0356417
0.0352415
0.0348385
0.0344327
0.0340244
0.0336136
0.0332006
0.0327854
0.0323683
0.0319495
0.031529
0.0311071
0.0306839
0.0302597
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277022
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.025153
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.022652
0.0222425
0.0218355
0.0214312
0.0210298
0.0206314
0.0202361
0.0198443
0.0194578
0.019101
0.0480342
0.0478045
0.0475702
0.0473312
0.0470876
0.0468393
0.0465863
0.0463285
0.046066
0.0457986
0.0455265
0.0452496
0.0449679
0.0446813
0.04439
0.0440938
0.0437928
0.0434871
0.0431765
0.0428612
0.0425412
0.0422166
0.0418872
0.0415533
0.0412148
0.0408719
0.0405245
0.0401727
0.0398166
0.0394563
0.0390918
0.0387233
0.0383509
0.0379745
0.0375945
0.0372107
0.0368235
0.0364328
0.0360388
0.0356417
0.0352415
0.0348385
0.0344328
0.0340244
0.0336136
0.0332006
0.0327855
0.0323684
0.0319495
0.031529
0.0311071
0.0306839
0.0302597
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277022
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.0251531
0.0247318
0.0243121
0.0238941
0.023478
0.0230639
0.022652
0.0222425
0.0218355
0.0214313
0.0210298
0.0206314
0.0202361
0.0198443
0.0194579
0.019101
0.0480343
0.0478045
0.0475702
0.0473312
0.0470876
0.0468393
0.0465863
0.0463285
0.046066
0.0457987
0.0455265
0.0452496
0.0449679
0.0446814
0.04439
0.0440938
0.0437928
0.0434871
0.0431765
0.0428613
0.0425413
0.0422166
0.0418873
0.0415533
0.0412149
0.0408719
0.0405245
0.0401727
0.0398166
0.0394563
0.0390919
0.0387233
0.0383509
0.0379746
0.0375945
0.0372107
0.0368235
0.0364328
0.0360388
0.0356417
0.0352416
0.0348385
0.0344328
0.0340244
0.0336137
0.0332006
0.0327855
0.0323684
0.0319495
0.031529
0.0311071
0.030684
0.0302597
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.0251531
0.0247318
0.0243121
0.0238941
0.023478
0.0230639
0.022652
0.0222425
0.0218355
0.0214313
0.0210298
0.0206314
0.0202362
0.0198443
0.0194579
0.0191011
0.0480343
0.0478045
0.0475702
0.0473312
0.0470876
0.0468393
0.0465863
0.0463285
0.046066
0.0457987
0.0455266
0.0452496
0.0449679
0.0446814
0.04439
0.0440938
0.0437928
0.0434871
0.0431765
0.0428613
0.0425413
0.0422166
0.0418873
0.0415533
0.0412149
0.0408719
0.0405245
0.0401727
0.0398166
0.0394563
0.0390919
0.0387234
0.0383509
0.0379746
0.0375945
0.0372108
0.0368235
0.0364328
0.0360388
0.0356417
0.0352416
0.0348385
0.0344328
0.0340245
0.0336137
0.0332006
0.0327855
0.0323684
0.0319495
0.031529
0.0311071
0.030684
0.0302597
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.0251531
0.0247318
0.0243121
0.0238941
0.023478
0.0230639
0.022652
0.0222425
0.0218355
0.0214313
0.0210298
0.0206314
0.0202361
0.0198443
0.0194579
0.0191011
0.0480343
0.0478045
0.0475702
0.0473312
0.0470876
0.0468393
0.0465863
0.0463285
0.046066
0.0457987
0.0455266
0.0452497
0.0449679
0.0446814
0.04439
0.0440938
0.0437929
0.0434871
0.0431766
0.0428613
0.0425413
0.0422166
0.0418873
0.0415534
0.0412149
0.0408719
0.0405245
0.0401727
0.0398166
0.0394563
0.0390919
0.0387234
0.0383509
0.0379746
0.0375945
0.0372108
0.0368235
0.0364328
0.0360388
0.0356417
0.0352416
0.0348386
0.0344328
0.0340245
0.0336137
0.0332006
0.0327855
0.0323684
0.0319495
0.031529
0.0311071
0.030684
0.0302598
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.0251531
0.0247318
0.0243121
0.0238941
0.023478
0.0230639
0.022652
0.0222425
0.0218355
0.0214312
0.0210298
0.0206314
0.0202361
0.0198443
0.0194579
0.019101
0.0480343
0.0478045
0.0475702
0.0473313
0.0470876
0.0468393
0.0465863
0.0463285
0.046066
0.0457987
0.0455266
0.0452497
0.0449679
0.0446814
0.04439
0.0440938
0.0437929
0.0434871
0.0431766
0.0428613
0.0425413
0.0422166
0.0418873
0.0415534
0.0412149
0.0408719
0.0405245
0.0401727
0.0398166
0.0394563
0.0390919
0.0387234
0.0383509
0.0379746
0.0375945
0.0372108
0.0368235
0.0364328
0.0360389
0.0356417
0.0352416
0.0348386
0.0344328
0.0340245
0.0336137
0.0332006
0.0327855
0.0323684
0.0319495
0.031529
0.0311071
0.030684
0.0302598
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.0251531
0.0247318
0.0243121
0.0238941
0.0234779
0.0230639
0.022652
0.0222425
0.0218355
0.0214312
0.0210298
0.0206314
0.0202361
0.0198443
0.0194578
0.019101
0.0480343
0.0478046
0.0475702
0.0473313
0.0470876
0.0468393
0.0465863
0.0463285
0.046066
0.0457987
0.0455266
0.0452497
0.0449679
0.0446814
0.04439
0.0440939
0.0437929
0.0434871
0.0431766
0.0428613
0.0425413
0.0422166
0.0418873
0.0415534
0.0412149
0.0408719
0.0405245
0.0401727
0.0398167
0.0394564
0.0390919
0.0387234
0.0383509
0.0379746
0.0375945
0.0372108
0.0368235
0.0364328
0.0360389
0.0356417
0.0352416
0.0348386
0.0344328
0.0340245
0.0336137
0.0332007
0.0327855
0.0323684
0.0319495
0.031529
0.0311071
0.030684
0.0302598
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.025153
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.022652
0.0222424
0.0218355
0.0214312
0.0210298
0.0206314
0.0202361
0.0198443
0.0194578
0.019101
0.0480343
0.0478046
0.0475702
0.0473313
0.0470877
0.0468393
0.0465863
0.0463286
0.046066
0.0457987
0.0455266
0.0452497
0.044968
0.0446814
0.04439
0.0440939
0.0437929
0.0434871
0.0431766
0.0428613
0.0425413
0.0422166
0.0418873
0.0415534
0.0412149
0.0408719
0.0405245
0.0401728
0.0398167
0.0394564
0.0390919
0.0387234
0.0383509
0.0379746
0.0375945
0.0372108
0.0368235
0.0364328
0.0360389
0.0356418
0.0352416
0.0348386
0.0344328
0.0340245
0.0336137
0.0332007
0.0327855
0.0323684
0.0319495
0.0315291
0.0311071
0.030684
0.0302598
0.0298346
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.025153
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.0226519
0.0222424
0.0218355
0.0214312
0.0210298
0.0206313
0.0202361
0.0198442
0.0194578
0.019101
0.0480343
0.0478046
0.0475702
0.0473313
0.0470877
0.0468394
0.0465863
0.0463286
0.046066
0.0457987
0.0455266
0.0452497
0.044968
0.0446814
0.0443901
0.0440939
0.0437929
0.0434871
0.0431766
0.0428613
0.0425413
0.0422167
0.0418873
0.0415534
0.0412149
0.040872
0.0405245
0.0401728
0.0398167
0.0394564
0.0390919
0.0387234
0.038351
0.0379746
0.0375945
0.0372108
0.0368235
0.0364329
0.0360389
0.0356418
0.0352416
0.0348386
0.0344328
0.0340245
0.0336137
0.0332007
0.0327855
0.0323684
0.0319495
0.0315291
0.0311072
0.030684
0.0302598
0.0298347
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.025153
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.0226519
0.0222424
0.0218354
0.0214312
0.0210297
0.0206313
0.020236
0.0198442
0.0194578
0.019101
0.0480343
0.0478046
0.0475703
0.0473313
0.0470877
0.0468394
0.0465863
0.0463286
0.0460661
0.0457987
0.0455266
0.0452497
0.044968
0.0446814
0.0443901
0.0440939
0.0437929
0.0434872
0.0431766
0.0428613
0.0425413
0.0422167
0.0418873
0.0415534
0.0412149
0.040872
0.0405246
0.0401728
0.0398167
0.0394564
0.0390919
0.0387234
0.038351
0.0379746
0.0375946
0.0372108
0.0368236
0.0364329
0.0360389
0.0356418
0.0352416
0.0348386
0.0344329
0.0340245
0.0336137
0.0332007
0.0327855
0.0323684
0.0319496
0.0315291
0.0311072
0.030684
0.0302598
0.0298347
0.0294088
0.0289825
0.0285558
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.025153
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.0226519
0.0222424
0.0218354
0.0214312
0.0210297
0.0206313
0.020236
0.0198442
0.0194577
0.0191009
0.0480343
0.0478046
0.0475703
0.0473313
0.0470877
0.0468394
0.0465864
0.0463286
0.0460661
0.0457988
0.0455266
0.0452497
0.044968
0.0446815
0.0443901
0.0440939
0.0437929
0.0434872
0.0431766
0.0428614
0.0425414
0.0422167
0.0418874
0.0415534
0.041215
0.040872
0.0405246
0.0401728
0.0398167
0.0394564
0.039092
0.0387235
0.038351
0.0379747
0.0375946
0.0372108
0.0368236
0.0364329
0.0360389
0.0356418
0.0352417
0.0348386
0.0344329
0.0340245
0.0336138
0.0332007
0.0327856
0.0323685
0.0319496
0.0315291
0.0311072
0.030684
0.0302598
0.0298347
0.0294089
0.0289825
0.0285559
0.028129
0.0277023
0.0272757
0.0268496
0.0264241
0.0259994
0.0255756
0.025153
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.0226519
0.0222424
0.0218354
0.0214312
0.0210297
0.0206313
0.020236
0.0198442
0.0194577
0.0191009
0.0480344
0.0478046
0.0475703
0.0473313
0.0470877
0.0468394
0.0465864
0.0463286
0.0460661
0.0457988
0.0455267
0.0452498
0.044968
0.0446815
0.0443901
0.0440939
0.043793
0.0434872
0.0431767
0.0428614
0.0425414
0.0422167
0.0418874
0.0415535
0.041215
0.040872
0.0405246
0.0401728
0.0398168
0.0394564
0.039092
0.0387235
0.038351
0.0379747
0.0375946
0.0372109
0.0368236
0.0364329
0.036039
0.0356418
0.0352417
0.0348387
0.0344329
0.0340246
0.0336138
0.0332007
0.0327856
0.0323685
0.0319496
0.0315291
0.0311072
0.0306841
0.0302598
0.0298347
0.0294089
0.0289826
0.0285559
0.0281291
0.0277023
0.0272758
0.0268496
0.0264241
0.0259994
0.0255756
0.0251531
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.0226519
0.0222424
0.0218354
0.0214312
0.0210297
0.0206313
0.020236
0.0198442
0.0194577
0.0191009
0.0480344
0.0478047
0.0475703
0.0473314
0.0470877
0.0468394
0.0465864
0.0463286
0.0460661
0.0457988
0.0455267
0.0452498
0.0449681
0.0446815
0.0443901
0.044094
0.043793
0.0434872
0.0431767
0.0428614
0.0425414
0.0422168
0.0418874
0.0415535
0.041215
0.0408721
0.0405247
0.0401729
0.0398168
0.0394565
0.039092
0.0387235
0.0383511
0.0379747
0.0375947
0.0372109
0.0368237
0.036433
0.036039
0.0356419
0.0352417
0.0348387
0.034433
0.0340246
0.0336138
0.0332008
0.0327856
0.0323685
0.0319497
0.0315292
0.0311073
0.0306841
0.0302599
0.0298348
0.0294089
0.0289826
0.0285559
0.0281291
0.0277023
0.0272758
0.0268497
0.0264242
0.0259994
0.0255757
0.0251531
0.0247318
0.0243121
0.0238941
0.0234779
0.0230638
0.0226519
0.0222424
0.0218355
0.0214312
0.0210297
0.0206313
0.020236
0.0198442
0.0194577
0.0191009
0.0480344
0.0478047
0.0475704
0.0473314
0.0470878
0.0468395
0.0465865
0.0463287
0.0460662
0.0457989
0.0455268
0.0452498
0.0449681
0.0446816
0.0443902
0.044094
0.0437931
0.0434873
0.0431768
0.0428615
0.0425415
0.0422168
0.0418875
0.0415536
0.0412151
0.0408721
0.0405247
0.0401729
0.0398169
0.0394565
0.0390921
0.0387236
0.0383511
0.0379748
0.0375947
0.037211
0.0368237
0.036433
0.0360391
0.0356419
0.0352418
0.0348388
0.034433
0.0340247
0.0336139
0.0332009
0.0327857
0.0323686
0.0319497
0.0315292
0.0311073
0.0306842
0.0302599
0.0298348
0.029409
0.0289827
0.028556
0.0281292
0.0277024
0.0272758
0.0268497
0.0264242
0.0259995
0.0255757
0.0251531
0.0247319
0.0243122
0.0238941
0.023478
0.0230639
0.022652
0.0222425
0.0218355
0.0214312
0.0210298
0.0206313
0.020236
0.0198442
0.0194577
0.0191009
0.0480345
0.0478047
0.0475704
0.0473315
0.0470878
0.0468395
0.0465865
0.0463287
0.0460662
0.0457989
0.0455268
0.0452499
0.0449682
0.0446816
0.0443903
0.0440941
0.0437931
0.0434873
0.0431768
0.0428615
0.0425415
0.0422169
0.0418876
0.0415536
0.0412152
0.0408722
0.0405248
0.040173
0.0398169
0.0394566
0.0390922
0.0387237
0.0383512
0.0379749
0.0375948
0.0372111
0.0368238
0.0364331
0.0360391
0.035642
0.0352419
0.0348389
0.0344331
0.0340248
0.033614
0.0332009
0.0327858
0.0323687
0.0319498
0.0315293
0.0311074
0.0306842
0.03026
0.0298349
0.0294091
0.0289827
0.028556
0.0281292
0.0277025
0.0272759
0.0268498
0.0264243
0.0259995
0.0255758
0.0251532
0.0247319
0.0243122
0.0238942
0.023478
0.0230639
0.022652
0.0222425
0.0218355
0.0214312
0.0210298
0.0206313
0.0202361
0.0198442
0.0194577
0.0191009
0.0480346
0.0478048
0.0475705
0.0473315
0.0470879
0.0468396
0.0465866
0.0463288
0.0460663
0.045799
0.0455269
0.04525
0.0449683
0.0446817
0.0443904
0.0440942
0.0437932
0.0434874
0.0431769
0.0428616
0.0425416
0.042217
0.0418876
0.0415537
0.0412152
0.0408723
0.0405249
0.0401731
0.039817
0.0394567
0.0390923
0.0387238
0.0383513
0.037975
0.0375949
0.0372111
0.0368239
0.0364332
0.0360392
0.0356421
0.0352419
0.0348389
0.0344332
0.0340248
0.033614
0.033201
0.0327858
0.0323687
0.0319498
0.0315294
0.0311074
0.0306843
0.0302601
0.0298349
0.0294091
0.0289828
0.0285561
0.0281293
0.0277025
0.0272759
0.0268498
0.0264243
0.0259996
0.0255758
0.0251532
0.024732
0.0243122
0.0238942
0.023478
0.0230639
0.022652
0.0222425
0.0218355
0.0214312
0.0210298
0.0206314
0.0202361
0.0198442
0.0194577
0.0191009
)
;
boundaryField
{
inlet
{
type fixedValue;
value uniform 0.075;
}
outlet
{
type zeroGradient;
}
wall
{
type zeroGradient;
}
center
{
type symmetry;
}
plate
{
type kqRWallFunction;
value nonuniform List<scalar>
80
(
0.0414075
0.0363605
0.0323662
0.0291499
0.0265221
0.0243476
0.0225273
0.0209873
0.0196718
0.0185379
0.0175522
0.0166887
0.0159265
0.0152492
0.0146433
0.014098
0.0136044
0.0131552
0.0127443
0.0123667
0.0120182
0.0116953
0.0113948
0.0111144
0.0108519
0.0106053
0.0103731
0.010154
0.00994672
0.00975024
0.00956366
0.00938618
0.00921712
0.00905585
0.00890183
0.00875457
0.00861365
0.00847866
0.00834928
0.00822516
0.00810606
0.00799169
0.00788186
0.0077763
0.00767491
0.00757741
0.00748378
0.00739374
0.0073073
0.00722421
0.00714455
0.007068
0.00699475
0.00692444
0.00685733
0.00679297
0.00673178
0.00667316
0.00661769
0.00656458
0.00651462
0.00646673
0.00642201
0.00637898
0.00633912
0.00630046
0.00626502
0.00623011
0.00619859
0.00616682
0.0061388
0.00610967
0.00608508
0.00605844
0.00603774
0.00601404
0.00599853
0.00597883
0.00597069
0.00595608
)
;
}
defaultFaces
{
type empty;
}
}
// ************************************************************************* //
| [
"brennankharris@gmail.com"
] | brennankharris@gmail.com | |
fab6dfa1f7a2dae6f23d7e91dc03aee7becd5260 | ff224fbbf41b4fa23adeca9208a7f386e5eaf890 | /packages/2HDMC-1.7.0/src/CalcHMSSM.cpp | 126cc94635da846878c6f96eedf98e4672ec294e | [] | no_license | hep-magellan/THDM_T3PS_scanner | 90774baa6f6897503042c770c338f78bb1d1349c | 766c7fde94e351c1d8616aae1fc0bf5fa631cb26 | refs/heads/master | 2021-06-24T02:54:47.259633 | 2020-12-30T20:52:44 | 2020-12-30T20:52:44 | 182,444,947 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 841 | cpp | #include "THDM.h"
#include "Constraints.h"
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
if (argc < 4) {
cout << "Usage: ./CalcHMSSM Mh MA tanb output_filename\n";
return -1;
}
double mh_in = (double)atof(argv[1]);
double mA_in = (double)atof(argv[2]);
double tanb_in = (double)atof(argv[3]);
char* file = argv[4];
THDM model;
SM sm;
bool pset = model.set_hMSSM(mh_in,mA_in,tanb_in);
if (!pset) {
cerr << "The parameters you have specified were not valid\n";
return -1;
}
Constraints check(model);
model.print_param_phys();
model.print_param_gen();
model.print_param_hybrid();
// Reference SM Higgs mass for EW precision observables
double mh_ref = 125.;
check.print_all(mh_ref);
model.write_LesHouches(file,true,true,true,false);
}
| [
"englert.david@gmail.com"
] | englert.david@gmail.com |
b9a7fd533db3cbf21f800b267e0211ff4f5caa37 | 0f6132d7c310e8853dddf1a2363a5909bff98bb4 | /Quipo/src/Quipo/Renderer/Renderer.h | 8687f702a05912617c7404f39ec2ab30c48506ef | [] | no_license | SpiritSeeker/Quipo | 37b8c99bfea1878c3b6d5b260cb27df2910295f1 | c49a51646ce033163b334a75bcf4d70c4fb964d9 | refs/heads/master | 2022-12-07T14:35:50.098391 | 2020-08-01T20:35:23 | 2020-08-01T20:35:23 | 283,316,923 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 554 | h | #pragma once
#include "Quipo/Renderer/RenderCommand.h"
#include "Quipo/Renderer/Shader.h"
namespace Quipo {
class Renderer
{
public:
static void Init();
static void OnWindowResize(uint32_t width, uint32_t height);
static void Begin();
static void End();
static void Submit(const Ref<Shader>& shader, const Ref<VertexArray>& vertexArray, const glm::mat4& viewProjection = glm::mat4(1.0f), const glm::mat4& transform = glm::mat4(1.0f));
inline static RendererAPI::API GetAPI() { return RendererAPI::GetAPI(); }
};
}
| [
"sanjeet029@gmail.com"
] | sanjeet029@gmail.com |
43cf7fb1628a34f725456ecfc4950b20c17d3652 | 155f53e338b99454f7e5976efd353f3f22d3285d | /PAT_Basic_Level/1055. 集体照.cpp | f553842a60cbb15bb489f2ef676edad6de0d20fe | [] | no_license | astronaut0131/PAT | cb196622bf4693573e8f57d5b85f2d6dde915561 | f6564d8fc81ab2b8bd8bdfc58b447b170eaf4005 | refs/heads/master | 2021-09-20T12:47:12.142564 | 2018-08-10T02:19:46 | 2018-08-10T02:19:46 | 115,731,374 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 899 | cpp | #include <iostream>
#include <algorithm>
using namespace std;
struct student{
string name;
int height;
};
bool cmpInc(struct student A,struct student B){
if(A.height!=B.height){
return A.height>B.height;
}
else{
return A.name<B.name;
}
}
int main(){
int N,K,m;
cin>>N>>K;
int remainder = N%K;
int G[remainder][remainder];
struct student s[N];
for(int i=0;i<N;i++){
cin>>s[i].name>>s[i].height;
}
sort(s,s+N,cmpInc);
int t=0;
int row = K;
while(row){
if(row==K){
m=N-N/K*(K-1);
}
else{
m=N/K;
}
string x[m];
x[m/2]=s[t].name;
int j=m/2-1;
for(int i=t+1;i<t+m;i+=2){
x[j--]=s[i].name;
}
j=m/2+1;
for(int i=t+2;i<t+m;i+=2){
x[j++]=s[i].name;
}
for(int i=0;i<m;i++){
cout<<x[i];
if(i!=m-1){
cout<<" ";
}
else{
cout<<endl;
}
}
t+=m;
row--;
}
return 0;
}
| [
"519537870@qq.com"
] | 519537870@qq.com |
4c93623f37e0895bd0f311e96bf31dba938cac97 | 57610d90506f9b93d2097067bbe7658e7460c2e6 | /yoketoru-unity/Temp/StagingArea/Data/il2cppOutput/t2778572544.h | e238a60d87a92ec1e8b5ac93b44f7b331f42d6ae | [] | no_license | GEhikachu/GEhikachu.github.io | 4c10b77020b9face4d27a50e1a9f4a1434f390c1 | b9d6627a3d1145325f2a7b9cf02712fe17c8f334 | refs/heads/master | 2020-07-01T08:16:40.998434 | 2016-12-09T01:22:35 | 2016-12-09T01:22:35 | 74,089,233 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 446 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "t1145342165.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
struct t2778572544 : public t1145342165
{
public:
public:
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"hikapika911@gmail.com"
] | hikapika911@gmail.com |
6268bafcddbb2804f15d540c20f051c14062d5fa | 206e1eb53dce33d7aebb42c9c04c29cc3bd89817 | /torch/csrc/jit/register_prim_ops.cpp | d508395fea9c8cb6bc5cd14a09b344a4f5af568f | [
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | wangzichenking/pytorch | 132bab154a3a33549bdb667ca2b21b51785d3ca4 | 97b92eede1091005f7a77d1717555ae1da7990b5 | refs/heads/master | 2022-01-28T19:21:11.252116 | 2019-06-15T00:38:07 | 2019-06-15T00:41:30 | 192,023,902 | 1 | 0 | null | 2019-06-15T01:34:28 | 2019-06-15T01:34:27 | null | UTF-8 | C++ | false | false | 94,372 | cpp | #include <aten/src/ATen/Context.h>
#include <torch/csrc/autograd/edge.h>
#include <torch/csrc/autograd/function.h>
#include <torch/csrc/autograd/generated/variable_factories.h>
#include <torch/csrc/autograd/profiler.h>
#include <torch/csrc/autograd/variable.h>
#include <torch/csrc/jit/custom_operator.h>
#include <torch/csrc/jit/fuser/interface.h>
#include <torch/csrc/jit/graph_executor.h>
#include <torch/csrc/jit/ir.h>
#include <torch/csrc/jit/operator.h>
#include <torch/csrc/jit/pickler.h>
#include <torch/csrc/jit/print_handler.h>
#include <torch/csrc/jit/profiling_record.h>
#include <torch/csrc/jit/script/compilation_unit.h>
#include <torch/csrc/jit/script/error_report.h>
#include <torch/csrc/jit/script/jit_exception.h>
#include <torch/csrc/jit/script/logging.h>
#include <ATen/ExpandUtils.h>
#include <ATen/Parallel.h>
#include <ATen/WrapDimUtils.h>
#include <ATen/core/Dict.h>
#include <ATen/core/ivalue.h>
#include <c10/core/thread_pool.h>
#include <c10/util/SmallVector.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <exception>
#include <fstream>
#include <iostream>
#include <limits>
#include <memory>
#include <mutex>
#include <ostream>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
namespace torch {
namespace jit {
namespace {
Operation noop(const Node* n) {
return [](Stack& stack) { return 0; };
}
// using the rules from python_arg_parser FunctionParameter::check
// tensor cannot have grad set, tensor must be 0 dim,
// and if the dest is an int the source must be integral type
void checkImplicitTensorToNum(at::Tensor t, bool toInt) {
if (autograd::as_variable_ref(t).requires_grad()) {
throw std::runtime_error(
"Cannot input a tensor that requires grad as a scalar argument");
}
if (t.sizes().size() != 0) {
throw std::runtime_error(
"Cannot input a tensor of dimension other than 0 as a scalar argument");
}
if (toInt && !isIntegralType(t.scalar_type())) {
std::stringstream ss;
ss << "Cannot input a tensor of type " << t.scalar_type()
<< " as an integral argument";
throw std::runtime_error(ss.str());
}
}
template <typename dtype> // int64_t, bool, double
Operation listConstruct(int64_t num_inputs) {
return [=](Stack& stack) {
auto inputs = peekSlice(stack, 0, num_inputs, num_inputs);
std::vector<dtype> vals =
fmap(inputs, [](const IValue& v) { return v.to<dtype>(); });
drop(stack, num_inputs);
push(stack, std::move(vals));
return 0;
};
}
static int64_t floordiv(int64_t a, int64_t b) {
if (b == 0) {
throw std::runtime_error("division by 0");
}
if ((a > 0) == (b > 0)) {
// simple case, both have same sign
return a / b;
} else {
// in python division rounds down, it doesnt not truncate like in c++
auto r = lldiv(a, b);
return (r.rem) ? r.quot - 1 : r.quot;
}
}
void checkDoubleInRange(double a) {
if (std::isnan(a) || std::isinf(a) ||
a > double(std::numeric_limits<int64_t>::max()) ||
a < double(std::numeric_limits<int64_t>::min())) {
throw c10::Error(
"Cannot convert float " + std::to_string(a) + " to integer", "");
return;
}
}
static int64_t floor(double a) {
checkDoubleInRange(a);
return std::floor(a);
}
static int64_t ceil(double a) {
checkDoubleInRange(a);
return std::ceil(a);
}
static int64_t gcd(int64_t a, int64_t b) {
while (b != 0) {
int64_t r = a % b;
a = b;
b = r;
}
// in python gcd returns non-negative values
return std::abs(a);
}
int64_t partProduct(int n, int m) {
if (m <= (n + 1))
return (int64_t)n;
if (m == (n + 2))
return (int64_t)n * m;
int k = (n + m) / 2;
if ((k & 1) != 1)
k = k - 1;
return partProduct(n, k) * partProduct(k + 2, m);
}
void loop(int n, int64_t& p, int64_t& r) {
if (n <= 2)
return;
loop(n / 2, p, r);
p = p * partProduct(n / 2 + 1 + ((n / 2) & 1), n - 1 + (n & 1));
r = r * p;
}
int nminussumofbits(int v) {
long w = (long)v;
w -= (0xaaaaaaaa & w) >> 1;
w = (w & 0x33333333) + ((w >> 2) & 0x33333333);
w = (w + (w >> 4)) & 0x0f0f0f0f;
w += w >> 8;
w += w >> 16;
return v - (int)(w & 0xff);
}
int64_t factorial(int n) {
if (n < 0) {
throw std::runtime_error("factorial() not defined for negative values");
}
int64_t p = 1, r = 1;
loop(n, p, r);
return r << nminussumofbits(n);
}
static const double degToRad = std::acos(-1.0) / 180.0;
static const double radToDeg = 180.0 / std::acos(-1.0);
double degrees(double x) {
return x * radToDeg;
}
double radians(double x) {
return x * degToRad;
}
// reference function THPVariable_to in python_variable_methods.cpp
static at::Tensor to_dispatch(
at::Tensor self,
c10::optional<at::Device> device,
c10::optional<at::ScalarType> scalarType,
bool non_blocking,
bool copy) {
if (device && device->is_cuda()) {
at::globalContext().lazyInitCUDA();
}
if (!device && !scalarType && !copy) {
return self;
} else if (!device) {
return self.to(*scalarType, non_blocking, copy);
} else if (!scalarType) {
return self.to(*device, non_blocking, copy);
} else {
return self.to(*device, *scalarType, non_blocking, copy);
}
}
// Convert an python index (which may be negative) into an index usable for a
// C++ container
int64_t normalizeIndex(int64_t idx, int64_t list_size) {
if (idx < 0) {
// Handle negative indexing
idx = list_size + idx;
}
return idx;
}
RegisterOperators reg(
{Operator(
prim::profile,
[](const Node* node) {
auto callback = node->cast<ProfileOp>()->getCallback();
return [callback](Stack& stack) {
callback(stack);
return 0;
};
}),
Operator(
prim::FusionGroup,
[](const Node* node) {
const auto key = registerFusion(node);
return [key](Stack& stack) {
RECORD_FUNCTION("FusionGroup", std::vector<c10::IValue>());
runFusion(key, stack);
return 0;
};
}),
Operator(
"prim::Guard(Tensor(a) t) -> Tensor(a)",
[](const Node* node) {
return [](Stack& stack) {
AT_ERROR("Should be replaced by prim::BailOut");
return 0;
};
}),
Operator(
"prim::BailOut(...) -> Tensor(a)",
[](const Node* /* node */) {
return [](Stack& /* stack */) {
AT_ERROR("prim::BailOut not yet implemented"); // NOLINT
return 0;
};
}),
Operator(
"prim::rangelist(int n) -> int[]",
[](Stack& stack) {
int64_t n;
pop(stack, n);
c10::ListPtr<int64_t> elems = c10::make_list<int64_t>();
elems.reserve(n);
for (int i = 0; i < n; i++) {
elems.push_back(i);
}
push(stack, std::move(elems));
return 0;
}),
Operator(
"prim::Bool(Tensor a) -> bool",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.is_nonzero());
return 0;
}),
Operator(
"prim::Bool(int a) -> bool",
[](Stack& stack) {
int64_t i;
pop(stack, i);
push(stack, (bool)i);
return 0;
}),
Operator(
"prim::Bool(float a) -> bool",
[](Stack& stack) {
double d;
pop(stack, d);
push(stack, (bool)d);
return 0;
}),
Operator(
"prim::Int(Tensor a) -> int",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.item<int64_t>());
return 0;
}),
Operator(
"prim::Float(Tensor a) -> float",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.item<double>());
return 0;
}),
Operator(
"prim::ImplicitTensorToNum(Tensor a) -> Scalar",
[](const Node* node) -> Operation {
if (node->output()->type() == IntType::get()) {
return [](Stack& stack) {
at::Tensor a;
pop(stack, a);
checkImplicitTensorToNum(a, /*to int*/ true);
push(stack, a.item<int64_t>());
return 0;
};
} else {
return [](Stack& stack) {
at::Tensor a;
pop(stack, a);
checkImplicitTensorToNum(a, /*to int*/ false);
push(stack, a.item<double>());
return 0;
};
}
}),
Operator(
"prim::NumToTensor(Scalar a) -> Tensor",
[](Stack& stack) {
at::Scalar s;
pop(stack, s);
push(stack, autograd::make_variable(at::scalar_to_tensor(s)));
return 0;
}),
// note: this op needs to share a name with the Scalar -> Tensor conversion
// because all _to_tensor conversion have to have the same operator namet
Operator(
"prim::NumToTensor(bool a) -> Tensor",
[](Stack& stack) {
bool b;
pop(stack, b);
push(stack, autograd::make_variable(at::scalar_to_tensor(b)));
return 0;
}),
Operator(
"prim::Float(Scalar a) -> float",
[](Stack& stack) {
IValue scalar;
pop(stack, scalar);
if (scalar.isDouble()) {
push(stack, std::move(scalar));
} else {
push(stack, static_cast<double>(scalar.toInt()));
}
return 0;
}),
Operator(
"prim::Float(int a) -> float",
[](Stack& stack) {
int64_t i;
pop(stack, i);
push(stack, (float)i);
return 0;
}),
Operator(
"prim::Int(float a) -> int",
[](Stack& stack) {
double d;
pop(stack, d);
push(stack, (int64_t)d);
return 0;
}),
Operator(
"prim::Float(bool a) -> float",
[](Stack& stack) {
bool b;
pop(stack, b);
push(stack, (float)b);
return 0;
}),
Operator(
"prim::Int(bool a) -> int",
[](Stack& stack) {
bool b;
pop(stack, b);
push(stack, (int)b);
return 0;
}),
Operator(
"prim::Int(Scalar a) -> int",
[](Stack& stack) {
IValue scalar;
pop(stack, scalar);
if (scalar.isInt()) {
push(stack, std::move(scalar));
} else {
push(stack, static_cast<int64_t>(scalar.toDouble()));
}
return 0;
}),
Operator(
"prim::Float(str a) -> float",
[](Stack& stack) {
auto s = pop(stack).toString();
if (s->string() == "inf")
push(stack, std::numeric_limits<double>::infinity());
else if (s->string() == "-inf")
push(stack, -std::numeric_limits<double>::infinity());
else
AT_ERROR(
"Only 'inf' or '-inf' can be cast to a float, but got '",
s->string(),
"'");
return 0;
}),
Operator(
"aten::device(str a) -> Device",
[](Stack& stack) {
push(stack, c10::Device(pop(stack).toStringRef()));
return 0;
}),
// reference function parse_to_conversion in python_arg_parsing.h
Operator(
"aten::to(Tensor(a) self, Device? device, int? dtype=None, bool non_blocking=False, bool copy=False) -> Tensor(a|b)",
[](Stack& stack) {
bool non_blocking;
bool copy;
pop(stack, non_blocking, copy);
c10::optional<at::ScalarType> scalarType =
pop(stack).toOptional<at::ScalarType>();
c10::optional<c10::Device> device =
pop(stack).toOptional<c10::Device>();
at::Tensor self = pop(stack).toTensor();
push(
stack,
to_dispatch(self, device, scalarType, non_blocking, copy));
return 0;
}),
Operator(
"aten::to(Tensor(a) self, int? dtype=None, bool non_blocking=False, bool copy=False) -> Tensor(a|b)",
[](Stack& stack) {
bool non_blocking;
bool copy;
pop(stack, non_blocking, copy);
c10::optional<at::ScalarType> scalarType =
pop(stack).toOptional<at::ScalarType>();
c10::optional<c10::Device> device = c10::nullopt;
at::Tensor self = pop(stack).toTensor();
push(
stack,
to_dispatch(self, device, scalarType, non_blocking, copy));
return 0;
}),
Operator(
"aten::to(Tensor(a) self, bool non_blocking=False, bool copy=False) -> Tensor(a|b)",
[](Stack& stack) {
at::Tensor self;
bool non_blocking;
bool copy;
pop(stack, self, non_blocking, copy);
c10::optional<c10::Device> device = c10::nullopt;
c10::optional<at::ScalarType> scalarType = c10::nullopt;
push(
stack,
to_dispatch(self, device, scalarType, non_blocking, copy));
return 0;
}),
Operator(
"aten::eq(Device a, Device b) -> bool",
[](Stack& stack) {
auto a = pop(stack).toDevice();
auto b = pop(stack).toDevice();
push(stack, a == b);
return 0;
}),
Operator(
"prim::device(Tensor a) -> Device",
[](Stack& stack) {
push(stack, pop(stack).toTensor().device());
return 0;
}),
Operator(
"prim::dtype(Tensor a) -> int",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, static_cast<int64_t>(a.scalar_type()));
return 0;
}),
Operator(
"prim::requires_grad(Tensor a) -> bool",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.requires_grad());
return 0;
}),
Operator(
"prim::shape(Tensor a) -> int[]",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.sizes());
return 0;
}),
Operator(
"prim::is_cuda(Tensor a) -> bool",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.is_cuda());
return 0;
}),
Operator(
"aten::cpu(Tensor(a) self) -> Tensor(a|b)",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.cpu());
return 0;
}),
Operator(
// TODO return generator object when torchscript supports RNG
// first-class
"aten::manual_seed(int seed) -> ()",
[](Stack& stack) {
at::manual_seed(pop(stack).toInt());
return 0;
}),
Operator(
"aten::cuda(Tensor(a) self) -> Tensor(a|b)",
[](Stack& stack) {
at::Tensor a;
pop(stack, a);
push(stack, a.cuda());
return 0;
}),
Operator(
"prim::AutogradZero() -> Tensor",
[](const Node* node) {
return [](Stack& stack) {
stack.emplace_back(at::Tensor());
return 0;
};
}),
Operator(
"aten::save(t item, str filename) -> ()",
[](Stack& stack) {
auto filename = pop(stack).toStringRef();
auto value = pop(stack);
// Pickle the tensor
Pickler p;
p.pushMetadata();
p.start();
p.addIValue(value);
p.finish();
// Write file
std::fstream output(filename, std::ios::out | std::ios::binary);
output.write(p.stack().data(), p.stack().size());
return 0;
}),
Operator(
prim::Print,
[](const Node* node) {
size_t num_inputs = node->inputs().size();
return [num_inputs](Stack& stack) {
std::stringstream ss;
bool first = true;
for (const IValue& i : last(stack, num_inputs)) {
if (!first)
ss << " ";
first = false;
ss << i;
}
drop(stack, num_inputs);
ss << std::endl;
auto* handler = getPrintHandler();
TORCH_INTERNAL_ASSERT(handler);
handler(ss.str());
return 0;
};
}),
Operator(
prim::BroadcastSizes,
[](const Node* node) -> Operation {
size_t num_inputs = node->inputs().size();
return [num_inputs](Stack& stack) {
std::vector<int64_t> size;
size.reserve(8);
for (size_t i = 0; i < num_inputs; ++i) {
size = at::infer_size(
size, peek(stack, i, num_inputs).toIntListRef());
}
drop(stack, num_inputs);
push(stack, std::move(size));
return 0;
};
}),
Operator(
prim::ChunkSizes,
[](const Node* node) -> Operation {
int64_t raw_dim = node->i(attr::dim);
int64_t chunks = node->i(attr::chunks);
return [raw_dim, chunks](Stack& stack) {
c10::ListPtr<int64_t> shape = pop(stack).toIntList();
c10::ListPtr<int64_t> regular_shape = shape.copy();
c10::ListPtr<int64_t> last_shape = shape.copy();
int64_t dim = at::maybe_wrap_dim(raw_dim, shape.size());
TORCH_CHECK(
dim < (int64_t)regular_shape.size(),
"Dimension out of range for chunk");
int64_t split_size = (regular_shape[dim] + chunks - 1) / chunks;
regular_shape[dim] =split_size;
if (shape[dim] % chunks == 0) {
last_shape[dim] = split_size;
} else {
int64_t num_splits = std::max<int64_t>(
(shape[dim] + split_size - 1) / split_size, 1);
last_shape[dim] =
split_size - (split_size * num_splits - shape[dim]);
AT_ASSERT(last_shape[dim] >= 0);
}
push(stack, std::move(regular_shape));
push(stack, std::move(last_shape));
return 0;
};
}),
Operator(
FunctionSchema(
"aten::warn",
"",
{Argument("message", StringType::get()),
Argument("stacklevel", IntType::get(), c10::nullopt, 2, true)},
{}),
[](const Node* node) -> std::function<int(Stack&)> {
auto range = node->sourceRange().source();
if (range->filename()) {
auto line = range->starting_line_no() +
range->lineno_for_offset(node->sourceRange().start());
return [=](Stack& stack) {
drop(stack, 1);
c10::SourceLocation location{
"", range->filename()->c_str(), uint32_t(line)};
c10::Warning::warn(location,
pop(stack).toStringRef());
return 0;
};
}
return [=](Stack& stack) {
drop(stack, 1);
AT_WARN(pop(stack).toStringRef());
return 0;
};
}),
Operator(
"prim::RaiseException(str msg) -> ()",
[](Stack& stack) {
throw JITException(pop(stack).toStringRef());
return 0;
}),
Operator(
"prim::IgnoredPythonOp(...) -> None",
[](Stack& stack) {
throw JITException(
"This Python function is annotated to be ignored"
" and cannot be and has not been included in the exported"
" binary, meaning that it cannot be executed now."
" Make sure that ignored operations are never executed after"
" import");
return 0;
}),
// Load x, y
// loads values from registers onto the stack, the actual callback does
// nothing since the stack manipulation is already encoded in inst.inputs
// and inst.outputs
Operator(prim::Load, noop),
// x, y = Store
// stores vales from stack into registers, the actual callback does
// nothing since the stack manipulation is already encoded in inst.inputs
// and inst.outputs
Operator(prim::Store, noop),
Operator(
prim::Drop,
[](const Node* node) {
auto N = node->inputs().size();
return [=](Stack& stack) {
drop(stack, N);
return 0;
};
}),
Operator(
c10::onnx::Reshape,
[](const Node* node) {
return [=](Stack& stack) {
at::Tensor input, shape;
pop(stack, input, shape);
shape = shape.contiguous();
AT_ASSERT(shape.ndimension() == 1);
at::IntArrayRef shape_list(shape.data<int64_t>(), shape.size(0));
push(stack, input.reshape(shape_list));
return 0;
};
}),
Operator(
c10::onnx::Shape,
[](const Node* node) {
return [=](Stack& stack) {
auto t = pop(stack).toTensor();
at::IntArrayRef sizes = t.sizes();
auto sizes_tensor = torch::empty(
{static_cast<int64_t>(sizes.size())}, at::dtype(at::kLong));
auto accessor = sizes_tensor.accessor<int64_t, 1>();
for (size_t i = 0; i < sizes.size(); ++i) {
accessor[i] = sizes[i];
}
stack.emplace_back(sizes_tensor);
return 0;
};
}),
Operator(
prim::AutogradAnyNonZero,
[](const Node* node) {
size_t num_inputs = node->inputs().size();
return [=](Stack& stack) {
bool result = false;
for (const IValue& t : last(stack, num_inputs)) {
if (t.toTensor().defined()) {
result = true;
break;
}
}
drop(stack, num_inputs);
stack.emplace_back(result);
return 0;
};
}),
Operator(
prim::AutogradAdd,
[](const Node* node) {
return [=](Stack& stack) {
at::Tensor a, b;
pop(stack, a, b);
if (!a.defined())
stack.emplace_back(b);
else if (!b.defined())
stack.emplace_back(a);
else
stack.emplace_back(a + b);
return 0;
};
}),
Operator(
"aten::_grad_sum_to_size(Tensor(a) self, int[]? size) -> Tensor(a)",
[](Stack& stack) {
IValue self, size;
pop(stack, self, size);
if (size.isNone()) {
push(stack, std::move(self));
} else {
push(
stack,
at::sum_to(self.toTensor(), size.toIntListRef()));
}
return 0;
}),
Operator(
"aten::_size_if_not_equal(int[] self_size, int[] other_size) -> int[]?",
[](Stack& stack) {
IValue self_size, other_size;
pop(stack, self_size, other_size);
auto s = self_size.toIntListRef();
if (s.equals(other_size.toIntListRef())) {
push(stack, IValue());
} else {
push(stack, s);
}
return 0;
}),
Operator(
prim::TupleUnpack,
[](const Node* node) {
size_t num_elems = node->outputs().size();
return [=](Stack& stack) {
auto tuple = pop(stack).toTuple();
if (tuple->elements().size() != num_elems) {
AT_ERROR(
"Expected a tuple of ",
num_elems,
" elements, but got ",
tuple->elements().size());
}
stack.insert(
stack.end(),
tuple->elements().begin(),
tuple->elements().end());
return 0;
};
}),
Operator(
prim::TupleSlice,
[](const Node* node) {
int64_t beg_ind = node->i(attr::beg);
int64_t end_ind = node->i(attr::end);
return [=](Stack& stack) {
auto tuple = pop(stack).toTuple();
std::vector<IValue> output_elems;
for (int64_t i = beg_ind; i < end_ind; ++i) {
output_elems.emplace_back(tuple->elements()[i]);
}
push(stack, c10::ivalue::Tuple::create(std::move(output_elems)));
return 0;
};
}),
Operator(
prim::TupleIndex,
[](const Node* node) {
return [](Stack& stack) {
int64_t index = pop(stack).toInt();
auto tuple = pop(stack).toTuple();
auto norm_index = normalizeIndex(index, tuple->elements().size());
if (norm_index < 0 ||
norm_index > static_cast<int64_t>(tuple->elements().size())) {
throw std::out_of_range("Tuple list index out of range");
}
stack.emplace_back(tuple->elements()[norm_index]);
return 0;
};
}),
Operator(
prim::TupleConstruct,
[](const Node* node) {
size_t num_inputs = node->inputs().size();
auto type = node->output()->type()->expect<TupleType>();
return [=](Stack& stack) {
std::vector<IValue> elems{
std::make_move_iterator(stack.end() - num_inputs),
std::make_move_iterator(stack.end())};
drop(stack, num_inputs);
push(stack, c10::ivalue::Tuple::create(std::move(elems), type));
return 0;
};
}),
Operator(
prim::ConstantChunk,
[](const Node* node) {
int64_t chunks = node->i(attr::chunks);
int64_t dim = node->i(attr::dim);
auto outputs_used = fmap(node->outputs(), [](const Value* v) {
return v->uses().size() > 0;
});
return [=](Stack& stack) {
RECORD_FUNCTION("chunk", last(stack, 1));
at::Tensor t;
pop(stack, t);
auto result = at::chunk(t, chunks, dim);
stack.insert(
stack.end(),
std::make_move_iterator(result.begin()),
std::make_move_iterator(result.end()));
// NB: Chunk can sometimes return a smaller number of outputs.
int64_t num_results = result.size();
if (num_results != chunks) {
if (num_results > chunks) {
TORCH_CHECK(
num_results == chunks,
"Expected chunk to return ",
chunks,
" outputs, but got ",
num_results);
}
for (int64_t i = num_results; i < chunks; ++i) {
TORCH_CHECK(
!outputs_used[i],
"Expected chunk to return at least ",
chunks,
" outputs, but got only ",
num_results);
// We know that the output is unused, so it's ok to push
// anything on the stack.
stack.emplace_back();
}
}
return 0;
};
}),
Operator(
prim::ListUnpack,
[](const Node* node) -> Operation {
const auto num_outputs = node->outputs().size();
ListTypePtr lt = node->input()->type()->expect<ListType>();
if (lt->getElementType() == IntType::get()) {
return [=](Stack& stack) {
auto list = pop(stack).toIntList();
TORCH_CHECK(
list.size() == num_outputs,
"Expected ",
num_outputs,
" elements in a list but found ",
list.size());
push_list_elements(stack, list);
return 0;
};
} else if (lt->getElementType() == FloatType::get()) {
return [=](Stack& stack) {
auto list = pop(stack).toDoubleList();
TORCH_CHECK(
list.size() == num_outputs,
"Expected ",
num_outputs,
" elements in a list but found ",
list.size());
push_list_elements(stack, list);
return 0;
};
} else if (lt->getElementType() == TensorType::get()) {
return [=](Stack& stack) {
auto list = pop(stack).toTensorList();
TORCH_CHECK(
list.size() == num_outputs,
"Expected ",
num_outputs,
" elements in a list but found ",
list.size());
push_list_elements(stack, list);
return 0;
};
} else {
return [=](Stack& stack) {
auto list = pop(stack).toGenericList();
TORCH_CHECK(
list.size() == num_outputs,
"Expected ",
num_outputs,
" elements in a list but found ",
list.size());
push_list_elements(stack, list);
return 0;
};
}
}),
Operator(
prim::ListConstruct,
[](const Node* node) -> Operation {
const auto num_inputs = node->inputs().size();
ListTypePtr lt = node->output()->type()->expect<ListType>();
if (IntType::get() == lt->getElementType()) {
return listConstruct<int64_t>(num_inputs);
} else if (FloatType::get() == lt->getElementType()) {
return listConstruct<double>(num_inputs);
} else if (lt->getElementType() == BoolType::get()) {
return listConstruct<bool>(num_inputs);
} else if (lt->getElementType()->isSubtypeOf(TensorType::get())) {
return [=](Stack& stack) {
const size_t stack_size = stack.size();
c10::ListPtr<at::Tensor> vals = c10::make_list<at::Tensor>();
vals.reserve(num_inputs);
for (size_t i = stack_size - num_inputs; i < stack_size; ++i) {
vals.emplace_back(std::move(stack[i]).toTensor());
}
drop(stack, num_inputs);
push(stack, std::move(vals));
return 0;
};
} else {
return [=](Stack& stack) {
const size_t stack_size = stack.size();
c10::ListPtr<IValue> vals = c10::make_list<IValue>();
vals.reserve(num_inputs);
for (size_t i = stack_size - num_inputs; i < stack_size; ++i) {
vals.emplace_back(std::move(stack[i]));
}
drop(stack, num_inputs);
push(stack, std::move(vals));
return 0;
};
}
}),
Operator(
prim::DictConstruct,
[](const Node* node) -> Operation {
const auto num_inputs = node->inputs().size();
if (num_inputs % 2 != 0) {
throw std::runtime_error(
"DictConstruct must have an even number of inputs");
}
return [=](Stack& stack) {
c10::impl::GenericDictPtr vals = c10::impl::make_generic_dict();
for (size_t i = 0; i < num_inputs; i += 2) {
auto val = pop(stack);
auto key = pop(stack);
vals.insert_or_assign(std::move(key), std::move(val));
}
push(stack, std::move(vals));
return 0;
};
}),
Operator(
"aten::_unwrap_optional(t(a)? optional) -> t(a)",
[](Stack& stack) {
auto val = pop(stack);
TORCH_CHECK(!val.isNone(), "Unwrapping null optional");
push(stack, std::move(val));
return 0;
}),
// This op can be removed in preprocessing before being run in the
// interpreter (but is currently not removed), even when it is removed it
// needs to remain a registered op so that constant prop can run.
Operator("prim::unchecked_unwrap_optional(t(a)? optional) -> t(a)", noop),
Operator(
prim::fork,
[](const Node* node) {
Code code(node->g(attr::Subgraph));
int n_inputs = node->inputs().size();
AT_ASSERT(node->blocks().size() == 0);
AT_ASSERT(node->hasAttribute(attr::Subgraph));
return [=](Stack& stack) {
// Move inputs to a separate stack
InterpreterState forked_interprester(code);
InterpreterContinuation continuation(
forked_interprester,
Stack(stack.end() - n_inputs, stack.end()),
autograd::GradMode::is_enabled());
drop(stack, n_inputs);
push(stack, forked_interprester.getFuture());
at::launch(std::move(continuation));
return 0;
};
}),
Operator(
"aten::wait(Future(t) self) -> t",
[](Stack& stack) {
TORCH_CHECK(
false, "wait is implemented directly in the interpreter");
return 0;
}),
Operator(
prim::Uninitialized,
[](const Node* node) {
return [](Stack& stack) {
push(stack, IValue::uninitialized());
return 0;
};
}),
Operator(
prim::CreateObject,
[](const Node* node) {
const auto type = node->output()->type()->expect<ClassType>();
const size_t numAttrs = type->numAttributes();
return [type, numAttrs](Stack& stack) {
auto userObj = c10::ivalue::Object::create(type, numAttrs);
push(stack, std::move(userObj));
return 0;
};
}),
Operator(
prim::GetAttr,
[](const Node* node) {
const auto type = node->input()->type()->expect<ClassType>();
const auto& field = node->s(attr::name);
const auto slot = type->getAttributeSlot(field);
return [slot](Stack& stack) {
auto userObj = pop(stack).toObject();
auto value = userObj->getSlot(slot);
push(stack, std::move(value));
return 0;
};
}),
Operator(prim::SetAttr, [](const Node* node) {
const auto type = node->inputs().at(0)->type()->expect<ClassType>();
const auto& field = node->s(attr::name);
const auto slot = type->getAttributeSlot(field);
return [slot](Stack& stack) {
auto v = pop(stack);
auto userObj = pop(stack).toObject();
userObj->setSlot(slot, std::move(v));
return 0;
};
})});
RegisterOperators logging_operators(
{Operator(
"prim::AddStatValue(str key, int val) -> ()",
[](Stack& stack) {
auto val = pop(stack).toInt();
auto key = pop(stack).toString();
auto schema =
parseSchema("prim::AddStatValue(str key, int val) -> ()");
// TODO: remove this custom tracing code once the custom op bugfix
// lands
if (jit::tracer::isTracing()) {
const auto& graph = tracer::getTracingState()->graph;
Node* node = graph->create(prim::AddStatValue, /*num_outputs=*/0);
tracer::recordSourceLocation(node);
node->addInput(insertConstant(*graph, key));
tracer::addInputs(node, "val", val);
graph->insertNode(node);
}
torch::jit::logging::getLogger()->addStatValue(*key, val);
return 0;
}),
Operator("prim::TimePoint() -> int", [](Stack& stack) {
auto schema = parseSchema("prim::TimePoint() -> int");
Node* node = nullptr;
// TODO: remove this custom tracing code once the custom op bugfix lands
if (jit::tracer::isTracing()) {
const auto& graph = tracer::getTracingState()->graph;
Node* node = graph->create(prim::TimePoint, /*num_outputs=*/0);
tracer::recordSourceLocation(node);
graph->insertNode(node);
}
auto output = autograd::profiler::getTime();
push(stack, output);
if (jit::tracer::isTracing()) {
jit::tracer::addOutput(node, output);
}
return 0;
})});
// define implementations for primitive number ops
#define DEFINE_GENERIC_OP(aten_op, int_op, float_op, int_result, float_result) \
Operator( \
#aten_op "(int a, int b) -> " #int_result, \
[](Stack& stack) { \
int64_t a, b; \
pop(stack, a, b); \
push(stack, int_op); \
return 0; \
}), \
Operator( \
#aten_op "(float a, float b) -> " #float_result, [](Stack& stack) { \
double a, b; \
pop(stack, a, b); \
push(stack, float_op); \
return 0; \
})
#define DEFINE_INT_FLOAT_OP(aten_op, op, result) \
Operator( \
#aten_op "(int a, float b) -> " #result, \
[](Stack& stack) { \
int64_t a; \
double b; \
pop(stack, a, b); \
push(stack, op); \
return 0; \
}), \
Operator(#aten_op "(float a, int b) -> " #result, [](Stack& stack) { \
double a; \
int64_t b; \
pop(stack, a, b); \
push(stack, op); \
return 0; \
})
#define DEFINE_INT_OP(aten_op, op) \
Operator(#aten_op "(int a, int b) -> int", [](Stack& stack) { \
int64_t a, b; \
pop(stack, a, b); \
push(stack, op); /* NOLINT(hicpp-signed-bitwise) */ \
return 0; \
})
#define DEFINE_STR_CMP_OP(aten_op, op) \
Operator(#aten_op "(str a, str b) -> bool", [](Stack& stack) { \
auto b = pop(stack).toStringRef(); \
auto a = pop(stack).toStringRef(); \
push(stack, op); \
return 0; \
})
#define DEFINE_BINARY_OP(aten_op, op) \
DEFINE_GENERIC_OP(aten_op, op, op, int, float), \
DEFINE_INT_FLOAT_OP(aten_op, op, float)
#define DEFINE_BINARY_FLOAT_OP(aten_op, op) \
DEFINE_GENERIC_OP(aten_op, op, op, float, float), \
DEFINE_INT_FLOAT_OP(aten_op, op, float)
#define DEFINE_COMPARISON_OP(aten_op, op) \
DEFINE_GENERIC_OP(aten_op, op, op, bool, bool), \
DEFINE_INT_FLOAT_OP(aten_op, op, bool), DEFINE_STR_CMP_OP(aten_op, op)
#define DEFINE_UNARY_INT_OP(aten_op, op, result) \
Operator(#aten_op "(int a) -> " #result, [](Stack& stack) { \
int64_t a; \
pop(stack, a); \
push(stack, op); \
return 0; \
})
#define DEFINE_UNARY_FLOAT_OP(aten_op, op, result) \
Operator(#aten_op "(float a) -> " #result, [](Stack& stack) { \
double a; \
pop(stack, a); \
push(stack, op); \
return 0; \
})
#define DEFINE_UNARY_OP(aten_op, op, int_result, float_result) \
DEFINE_UNARY_INT_OP(aten_op, op, int_result), \
DEFINE_UNARY_FLOAT_OP(aten_op, op, float_result)
#define DEFINE_BOOL_OP(aten_op, op) \
Operator(#aten_op "(bool a, bool b) -> bool", [](Stack& stack) { \
bool a, b; \
pop(stack, a, b); \
push(stack, op); \
return 0; \
})
// Equivalent to list.at(idx)
template <typename T>
T getItem(const c10::ListPtr<T>& list, int64_t idx) {
const int64_t list_size = list.size();
const int64_t normalized_idx = normalizeIndex(idx, list_size);
if (normalized_idx < 0 || normalized_idx >= list_size) {
throw std::out_of_range("list index out of range");
}
return list.get(normalized_idx);
}
template <typename T>
void setItem(const c10::ListPtr<T>& list, int64_t idx, T&& value) {
const int64_t list_size = list.size();
const int64_t normalized_idx = normalizeIndex(idx, list_size);
if (normalized_idx < 0 || normalized_idx >= list_size) {
throw std::out_of_range("list index out of range");
}
list.set(normalized_idx, std::move(value));
}
template <typename T>
int listAppend(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
T el;
pop(stack, list, el);
list.push_back(std::move(el));
push(stack, std::move(list));
return 0;
}
template <typename T>
int listReverse(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
pop(stack, list);
std::reverse(list.begin(), list.end());
return 0;
}
template <typename T>
int listPop(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
int64_t idx;
pop(stack, list, idx);
const int64_t list_size = list.size();
const int64_t normalized_idx = normalizeIndex(idx, list_size);
if (list_size == 0) {
AT_ERROR("pop from empty list");
}
push(stack, getItem(list, idx));
list.erase(list.begin() + normalized_idx);
return 0;
}
template <typename T>
int listClear(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
pop(stack, list);
list.clear();
return 0;
}
template <typename T>
int listInsert(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
int64_t idx;
T elem;
pop(stack, list, idx, elem);
const int64_t list_size = list.size();
const int64_t normalized_idx = normalizeIndex(idx, list_size);
if (normalized_idx < 0 || normalized_idx >= list_size) {
if (normalized_idx < 0) {
list.insert(list.begin(), elem);
} else {
list.push_back(elem);
}
} else {
list.insert(list.begin() + normalized_idx, elem);
}
return 0;
}
template <typename T>
int listRemove(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
T elem;
pop(stack, list, elem);
auto pos = std::find(list.begin(), list.end(), elem);
if (pos != list.end()) {
list.erase(pos);
} else {
AT_ERROR("list.remove(x): x not in list");
}
return 0;
}
template <>
int listRemove<at::Tensor>(Stack& stack) {
c10::ListPtr<at::Tensor> list = c10::make_list<at::Tensor>();
at::Tensor elem;
pop(stack, list, elem);
auto pos = std::find_if(
list.begin(), list.end(), [&](const at::Tensor& b) {
const auto cmp_result = elem.eq(b);
return cmp_result.is_nonzero();
});
if (pos != list.end()) {
list.erase(pos);
} else {
AT_ERROR("list.remove(x): x not in list");
}
return 0;
}
template <typename T>
int listIndex(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
T elem;
pop(stack, list, elem);
auto pos = std::find(list.begin(), list.end(), elem);
if (pos != list.end()) {
push(stack, static_cast<int64_t>(std::distance(list.begin(), pos)));
} else {
AT_ERROR("'", elem, "' is not in list");
}
return 0;
}
template <>
int listIndex<at::Tensor>(Stack& stack) {
c10::ListPtr<at::Tensor> list = c10::make_list<at::Tensor>();
at::Tensor elem;
pop(stack, list, elem);
auto pos = std::find_if(
list.begin(), list.end(), [elem](const at::Tensor& b) {
const auto cmp_result = elem.eq(b);
return cmp_result.is_nonzero();
});
if (pos != list.end()) {
push(stack, static_cast<int64_t>(std::distance(list.begin(), pos)));
} else {
AT_ERROR("'", elem, "' is not in list");
}
return 0;
}
template <typename T>
int listCount(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
T elem;
pop(stack, list, elem);
const int64_t count = std::count(list.begin(), list.end(), elem);
push(stack, count);
return 0;
}
template <>
int listCount<at::Tensor>(Stack& stack) {
c10::ListPtr<at::Tensor> list = c10::make_list<at::Tensor>();
at::Tensor elem;
pop(stack, list, elem);
const int64_t count = std::count_if(
list.begin(), list.end(), [&](const at::Tensor& b) {
const auto cmp_result = elem.eq(b);
return cmp_result.is_nonzero();
});
push(stack, count);
return 0;
}
template <typename T>
Operation listExtend(const Node* node) {
return [](Stack& stack) {
c10::ListPtr<T> a = c10::make_list<T>();
c10::ListPtr<T> b = c10::make_list<T>();
pop(stack, a, b);
a.reserve(a.size() + b.size());
for (size_t i = 0; i < b.size(); ++i) {
a.push_back(b.get(i));
}
return 0;
};
}
template <typename T>
Operation listCopy(const Node* node) {
return [](Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
pop(stack, list);
push(stack, list.copy());
return 0;
};
}
template <typename T>
int listSelect(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
int64_t idx;
pop(stack, list, idx);
auto element = getItem(list, idx);
push(stack, std::move(element));
return 0;
}
template <typename T>
int listLen(Stack& stack) {
c10::ListPtr<T> a = c10::make_list<T>();
pop(stack, a);
const int64_t size = a.size();
push(stack, size);
return 0;
}
template <typename T>
int listEq(Stack& stack) {
c10::ListPtr<T> a = c10::make_list<T>();
c10::ListPtr<T> b = c10::make_list<T>();
pop(stack, a, b);
push(stack, list_is_equal(a, b));
return 0;
}
template <typename T>
int listNe(Stack& stack) {
c10::ListPtr<T> a = c10::make_list<T>();
c10::ListPtr<T> b = c10::make_list<T>();
pop(stack, a, b);
push(stack, !list_is_equal(a, b));
return 0;
}
inline bool tensor_list_equal(const c10::ListPtr<at::Tensor>& a, const c10::ListPtr<at::Tensor>& b) {
if (a.size() != b.size()) {
return false;
}
for (size_t i = 0; i < a.size(); ++i) {
at::Tensor a_element = a[i];
at::Tensor b_element = b[i];
// This preserves Python's semantics, which uses eq() to compare two
// elements, then passes the result to bool().
// see: https://docs.python.org/3.4/reference/datamodel.html#object.__ge__
const auto cmp_result = a_element.eq(b_element);
if (!cmp_result.is_nonzero()) {
return false;
}
}
return true;
}
// Specialization for at::Tensor, since it doesn't define operator==
template <>
int listEq<at::Tensor>(Stack& stack) {
c10::ListPtr<at::Tensor> a = c10::make_list<at::Tensor>();
c10::ListPtr<at::Tensor> b = c10::make_list<at::Tensor>();
pop(stack, a, b);
push(stack, tensor_list_equal(a, b));
return 0;
}
// Specialization for at::Tensor, since it doesn't define operator==
template <>
int listNe<at::Tensor>(Stack& stack) {
c10::ListPtr<at::Tensor> a = c10::make_list<at::Tensor>();
c10::ListPtr<at::Tensor> b = c10::make_list<at::Tensor>();
pop(stack, a, b);
push(stack, !tensor_list_equal(a, b));
return 0;
}
Operation listList(const Node* node) {
return [=](Stack& stack) {
// Intentional no-op, needed to match Python semantics for list(iterable),
// but in JIT these will already be lists
return 0;
};
}
template <class T>
int listAdd(Stack& stack) {
c10::ListPtr<T> a = c10::make_list<T>();
c10::ListPtr<T> b = c10::make_list<T>();
pop(stack, a, b);
c10::ListPtr<T> ret = c10::make_list<T>();
const auto total_size = a.size() + b.size();
ret.reserve(total_size);
for (T a_element : a) {
ret.push_back(std::move(a_element));
}
for (T b_element : b) {
ret.push_back(std::move(b_element));
}
push(stack, std::move(ret));
return 0;
}
template <class T>
int listMulIntLeft(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
int64_t n;
pop(stack, list, n);
c10::ListPtr<T> ret = c10::make_list<T>();
const auto size = list.size() * n;
ret.reserve(size);
for (auto i = 0; i < n; i++) {
for (T e : list) {
ret.push_back(std::move(e));
}
}
push(stack, std::move(ret));
return 0;
}
template <class T>
int listMulIntRight(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
int64_t n;
pop(stack, n, list);
c10::ListPtr<T> ret = c10::make_list<T>();
const auto size = list.size() * n;
ret.reserve(size);
for (auto i = 0; i < n; i++) {
for (T e : list) {
ret.push_back(std::move(e));
}
}
push(stack, std::move(ret));
return 0;
}
template <typename T>
int listSlice(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
int64_t start;
int64_t end;
int64_t step;
pop(stack, list, start, end, step);
const int64_t list_size = list.size();
// clamp start and end to the bounds of the list
const auto normalized_start =
std::max((int64_t)0, normalizeIndex(start, list_size));
const auto normalized_end =
std::min(list_size, normalizeIndex(end, list_size));
c10::ListPtr<T> sliced_list = c10::make_list<T>();
if (normalized_end <= normalized_start) {
// early exit if the slice is trivially empty
push(stack, std::move(sliced_list));
return 0;
}
sliced_list.reserve(normalized_end - normalized_start);
for (auto i = normalized_start; i < normalized_end;) {
sliced_list.push_back(list.get(i));
i += step;
}
push(stack, std::move(sliced_list));
return 0;
}
template <typename T>
int listSort(Stack& stack) {
c10::ListPtr<T> list = pop(stack).to<c10::ListPtr<T>>();
std::sort(list.begin(), list.end(), [] (const T& a, const T& b) {
return a < b;
});
return 0;
}
// Specialization for at::Tensor
template <>
int listSort<at::Tensor>(Stack& stack) {
c10::ListPtr<at::Tensor> list = pop(stack).toTensorList();
std::sort(
list.begin(),
list.end(),
[](const at::Tensor& a, const at::Tensor& b) {
return a.lt(b).is_nonzero();
});
return 0;
}
template <typename T>
int listSetItem(Stack& stack) {
c10::ListPtr<T> list = c10::make_list<T>();
int64_t idx;
T value;
pop(stack, list, idx, value);
setItem(list, idx, std::move(value));
push(stack, std::move(list));
return 0;
}
int dictSetItem(Stack& stack) {
auto value = pop(stack);
auto idx = pop(stack);
auto dict = pop(stack).toGenericDict();
dict.insert_or_assign(std::move(idx), std::move(value));
return 0;
}
int dictLen(Stack& stack) {
auto dict = pop(stack).toGenericDict();
push(stack, int64_t(dict.size()));
return 0;
}
int dictKeys(Stack& stack) {
auto dict = pop(stack).toGenericDict();
c10::impl::GenericListPtr keys = c10::impl::make_generic_list();
keys.reserve(dict.size());
for (auto& item : dict) {
keys.push_back(item.key());
}
push(stack, IValue(keys));
return 0;
}
template <typename Elem>
c10::ListPtr<Elem> makeListForDictValues(
const std::vector<std::pair<IValue, IValue>>& order) {
c10::ListPtr<Elem> values = c10::make_list<Elem>();
values.reserve(order.size());
for (auto item : order) {
values.push_back(item.second.to<Elem>());
}
return values;
}
Operation dictValues(const Node* n) {
auto outputType = n->output()->type()->expect<ListType>();
return [=](Stack& stack) -> int {
const auto& order = iterationOrder(pop(stack).toGenericDict());
if (outputType->getElementType()->isSubtypeOf(TensorType::get())) {
push(stack, makeListForDictValues<at::Tensor>(order));
} else if (outputType->getElementType() == IntType::get()) {
push(stack, makeListForDictValues<int64_t>(order));
} else if (outputType->getElementType() == FloatType::get()) {
push(stack, makeListForDictValues<double>(order));
} else if (outputType->getElementType() == BoolType::get()) {
push(stack, makeListForDictValues<bool>(order));
} else {
push(stack, makeListForDictValues<IValue>(order));
}
return 0;
};
}
int dictIndex(Stack& stack) {
auto index = pop(stack);
auto dict = pop(stack).toGenericDict();
auto value = dict.find(index);
if (value == dict.end()) {
AT_ERROR("KeyError: '", index, "'");
}
push(stack, value->value());
return 0;
}
int dictGet(Stack& stack) {
auto index = pop(stack);
auto dict = pop(stack).toGenericDict();
auto value = dict.find(index);
if (value == dict.end()) {
push(stack, IValue());
} else {
push(stack, value->value());
}
return 0;
}
int dictGetDefault(Stack& stack) {
auto default_value = pop(stack);
auto index = pop(stack);
auto dict = pop(stack).toGenericDict();
auto value = dict.find(index);
if (value == dict.end()) {
push(stack, std::move(default_value));
} else {
push(stack, value->value());
}
return 0;
}
template <typename T>
int hashValue(Stack& stack) {
auto value = pop(stack);
auto hash = std::hash<T>()(value.to<T>());
push(stack, int64_t(hash));
return 0;
}
RegisterOperators reg2({
#define DEFINE_STRING_OP(op_name, string_op, result) \
Operator(#op_name "(str a, str b) ->" #result, [](Stack& stack) { \
auto b = pop(stack).toStringRef(); \
auto a = pop(stack).toStringRef(); \
push(stack, string_op); \
return 0; \
})
DEFINE_STRING_OP(aten::eq, a == b, bool),
DEFINE_STRING_OP(aten::ne, a != b, bool),
DEFINE_STRING_OP(aten::add, a + b, str),
#undef DEFINE_STRING_OP
Operator(
"aten::len(str s) -> int",
[](Stack& stack) {
auto string = pop(stack).toStringRef();
push(stack, static_cast<int64_t>(string.size()));
return 0;
}),
// tensor length op (size of 1st dimension)
Operator(
"aten::len(Tensor t) -> int",
[](Stack& stack) {
at::Tensor t = pop(stack).toTensor();
if (t.dim() == 0) {
AT_ERROR("len() of a 0-d tensor");
}
push(stack, t.sizes()[0]);
return 0;
}),
Operator(
"aten::list(str t) -> str[]",
[](Stack& stack) {
auto str = pop(stack).toStringRef();
c10::ListPtr<std::string> chars = c10::make_list<std::string>();
chars.reserve(str.size());
for (auto c : str) {
chars.push_back(std::string(1, c));
}
push(stack, std::move(chars));
return 0;
}),
// Mutable ops for lists containing mutable types.
#define CREATE_MUTABLE_LIST_OPS(decl_type, value_type) \
Operator( \
"aten::select(" decl_type "[](a) list, int idx) -> " decl_type "(*)", \
listSelect<value_type>), \
Operator( \
"aten::append( " decl_type "[](a!) self, " decl_type \
"(c -> *) el) -> " decl_type "[](a!)", \
listAppend<value_type>), \
Operator( \
"aten::reverse( " decl_type "[](a!) self) -> ()", \
listReverse<value_type>), \
Operator( \
"aten::extend(" decl_type "[](a!) self, " decl_type \
" [] other) -> ()", \
listExtend<value_type>), \
Operator( \
"aten::copy(" decl_type \
"[](a) self)" \
" -> " decl_type "[]", \
listCopy<value_type>), \
Operator( \
"aten::_set_item(" decl_type "[](a!) l, int idx, " decl_type \
"(b -> *) el) -> " decl_type "[](a!)", \
listSetItem<value_type>), \
Operator( \
"aten::clear( " decl_type "[](a!) self) -> ()", \
listClear<value_type>), \
Operator( \
"aten::insert( " decl_type \
"[](a!) self, int idx, \
" decl_type "(b -> *) el) -> ()", \
listInsert<value_type>), \
Operator( \
"aten::pop(" decl_type \
"[](a!) self, int idx=-1) \
-> " decl_type "(*)", \
listPop<value_type>)
CREATE_MUTABLE_LIST_OPS("Tensor", at::Tensor),
Operator(
"aten::remove(Tensor[](a!) self, Tensor el) -> ()",
listRemove<at::Tensor>),
Operator(
"aten::index(Tensor[] self, Tensor el) -> int",
listIndex<at::Tensor>),
Operator(
"aten::count(Tensor[] self, Tensor el) -> int",
listCount<at::Tensor>),
// Mutable ops for lists containing immutable types.
#define CREATE_IMMUTABLE_LIST_OPS(decl_type, value_type) \
Operator( \
"aten::select(" decl_type "[] a, int b) -> " decl_type, \
listSelect<value_type>), \
Operator( \
"aten::append(" decl_type "[](a!) self, " decl_type \
" el) -> " decl_type "[](a!)", \
listAppend<value_type>), \
Operator( \
"aten::reverse(" decl_type "[](a!) self) -> ()", \
listReverse<value_type>), \
Operator( \
"aten::extend(" decl_type "[](a!) self, " decl_type \
" [] other) -> ()", \
listExtend<value_type>), \
Operator( \
"aten::copy(" decl_type \
"[](a) self)" \
" -> " decl_type "[]", \
listCopy<value_type>), \
Operator( \
"aten::_set_item(" decl_type "[](a!) l, int idx, " decl_type \
" el) -> " decl_type "[](a!)", \
listSetItem<value_type>), \
Operator( \
"aten::clear( " decl_type "[](a!) self) -> ()", \
listClear<value_type>), \
Operator( \
"aten::insert( " decl_type \
"[](a!) self, int idx, \
" decl_type " el) -> ()", \
listInsert<value_type>), \
Operator( \
"aten::remove(" decl_type \
"[](a!) self, \
" decl_type " el) -> ()", \
listRemove<value_type>), \
Operator( \
"aten::index(" decl_type \
"[] self, \
" decl_type " el) -> int", \
listIndex<value_type>), \
Operator( \
"aten::count(" decl_type \
"[] self, \
" decl_type " el) -> int", \
listCount<value_type>), \
Operator( \
"aten::pop(" decl_type \
"[](a!) self, int idx=-1) \
-> " decl_type, \
listPop<value_type>)
CREATE_IMMUTABLE_LIST_OPS("int", int64_t),
CREATE_IMMUTABLE_LIST_OPS("float", double),
CREATE_IMMUTABLE_LIST_OPS("bool", bool),
// NOTE: this must be after the other list specializations so that operator
// resolution doesn't pick this up first
CREATE_MUTABLE_LIST_OPS("t", IValue),
#undef CREATE_IMMUTABLE_LIST_OPS
#undef CREATE_MUTABLE_LIST_OPS
#define CREATE_LIST_OPS(decl_type, c_type) \
Operator("aten::len(" decl_type "[] a) -> int", listLen<c_type::value_type>), \
Operator( \
"aten::add(" decl_type "[] a, " decl_type "[] b) -> " decl_type \
"[]", \
listAdd<c_type::value_type>), \
Operator( \
"aten::slice(" decl_type \
"[] l, int start, int end=9223372036854775807, int step=1) -> " decl_type \
"[]", \
listSlice<c_type::value_type>), \
Operator("aten::list(" decl_type "[] l) -> " decl_type "[]", listList), \
Operator( \
"aten::mul(" decl_type "[] l, int n) -> " decl_type "[]", \
listMulIntLeft<c_type::value_type>), \
Operator( \
"aten::mul(int n, " decl_type "[] l) -> " decl_type "[]", \
listMulIntRight<c_type::value_type>)
CREATE_LIST_OPS("int", c10::ListPtr<int64_t>),
CREATE_LIST_OPS("float", c10::ListPtr<double>),
CREATE_LIST_OPS("bool", c10::ListPtr<bool>),
CREATE_LIST_OPS("Tensor", c10::ListPtr<at::Tensor>),
CREATE_LIST_OPS("t", c10::ListPtr<IValue>),
#undef CREATE_LIST_OPS
Operator("aten::sort(int[](a!) self) -> ()", listSort<int64_t>),
Operator(
"aten::sort(float[](a!) self) -> ()",
listSort<double>),
Operator(
"aten::sort(Tensor[](a!) self) -> ()",
listSort<at::Tensor>),
Operator("aten::sort(bool[](a!) self) -> ()", listSort<bool>),
Operator("aten::eq(int[] a, int[] b) -> bool", listEq<int64_t>),
Operator(
"aten::eq(float[] a, float[] b) -> bool",
listEq<double>),
Operator(
"aten::eq(Tensor[] a, Tensor[] b) -> bool",
listEq<at::Tensor>),
Operator("aten::eq(bool[] a, bool[] b) -> bool", listEq<bool>),
Operator("aten::ne(int[] a, int[] b) -> bool", listNe<int64_t>),
Operator(
"aten::ne(float[] a, float[] b) -> bool",
listNe<double>),
Operator(
"aten::ne(Tensor[] a, Tensor[] b) -> bool",
listNe<at::Tensor>),
Operator("aten::ne(bool[] a, bool[] b) -> bool", listNe<bool>),
Operator(
"prim::StringIndex(str string, int index) -> str",
[](Stack& stack) {
auto index = pop(stack).toInt();
auto string = pop(stack).toStringRef();
char c = string.at(index);
push(stack, std::string(&c, 1));
return 0;
}),
Operator(
"prim::str(t elem) -> str",
[](Stack& stack) {
std::stringstream ss;
ss << pop(stack);
push(stack, ss.str());
return 0;
}),
Operator(
"aten::ord(str string) -> int",
[](Stack& stack) {
auto string = pop(stack).toStringRef();
TORCH_CHECK(
string.size() == 1,
"String for ord() must be 1 character, found",
string.size());
uint8_t ord = string.at(0);
push(stack, int64_t(ord));
return 0;
}),
#define CREATE_COPY_OP(other_type, c_type) \
Operator( \
"aten::copy_(Tensor(a!) self, " #other_type " other) -> Tensor(a!)", \
[](Stack& stack) { \
at::Tensor t; \
c_type other; \
pop(stack, t, other); \
std::move(t) = other; /* NOLINT(bugprone-use-after-move) */ \
push(stack, std::move(t)); /* NOLINT(bugprone-use-after-move) */ \
return 0; \
})
CREATE_COPY_OP(Tensor, at::Tensor),
CREATE_COPY_OP(int, int64_t),
CREATE_COPY_OP(float, double),
#undef CREATE_COPY_OP
DEFINE_BINARY_OP(aten::add, a + b),
DEFINE_BINARY_OP(aten::sub, a - b),
DEFINE_BINARY_OP(aten::mul, a* b),
DEFINE_BINARY_OP(aten::pow, pow(a, b)),
// min and max are in prim:: because there is a difference between
// the python builtin 'min' and 'torch.min'
DEFINE_BINARY_OP(prim::min, a < b ? a : b),
DEFINE_BINARY_OP(prim::max, a > b ? a : b),
// Pass in two ops for handling int and float separately as % in C++ only
// works for int The modulus calculation is different between C++ and Python
// (on negative), we preserve the python behavior as it's more common and
// match python syntax, hence the conversion.
DEFINE_GENERIC_OP(
aten::remainder,
(b + (a % b)) % b,
fmod((b + fmod(a, b)), b),
int,
float),
DEFINE_INT_FLOAT_OP(aten::remainder, fmod((b + fmod(a, b)), b), float),
DEFINE_GENERIC_OP(
aten::floordiv,
floordiv(a, b),
std::floor(a / b),
int,
float),
DEFINE_INT_FLOAT_OP(aten::floordiv, std::floor(a / b), float),
// NB: This is the python truediv operation
DEFINE_GENERIC_OP(
aten::div,
static_cast<double>(a) / static_cast<double>(b),
a / b,
float,
float),
// only used in loop unrolling, not exposed to end users
DEFINE_INT_OP(aten::__round_to_zero_floordiv, a / b),
// only used internally in range() translation
Operator(
"aten::__range_length(int lo, int hi, int step) -> int",
[](Stack& stack) {
int64_t lo, hi, step;
pop(stack, lo, hi, step);
if (step > 0 && lo < hi)
push(stack, 1 + (hi - 1 - lo) / step);
else if (step < 0 && lo > hi)
push(stack, 1 + (lo - 1 - hi) / (0 - step));
else
push(stack, 0);
return 0;
}),
Operator(
"aten::__derive_index(int index, int start, int step) -> int",
[](Stack& stack) {
int64_t index, start, step;
pop(stack, index, start, step);
push(stack, start + index * step);
return 0;
}),
DEFINE_INT_OP(aten::__and__, a& b),
DEFINE_INT_OP(aten::__or__, a | b),
DEFINE_INT_OP(aten::__xor__, a ^ b),
DEFINE_UNARY_OP(aten::floor, floor(a), int, int),
DEFINE_UNARY_OP(aten::ceil, ceil(a), int, int),
DEFINE_UNARY_OP(aten::log, std::log(a), float, float),
DEFINE_BINARY_FLOAT_OP(aten::log, std::log(a) / std::log(b)),
DEFINE_UNARY_OP(aten::log1p, std::log1p(a), float, float),
DEFINE_UNARY_OP(aten::log10, std::log10(a), float, float),
DEFINE_UNARY_OP(aten::exp, std::exp(a), float, float),
DEFINE_UNARY_OP(aten::sqrt, std::sqrt(a), float, float),
DEFINE_UNARY_OP(aten::acos, std::acos(a), float, float),
DEFINE_UNARY_OP(aten::asin, std::asin(a), float, float),
DEFINE_UNARY_OP(aten::atan, std::atan(a), float, float),
DEFINE_BINARY_FLOAT_OP(aten::atan2, std::atan2(a, b)),
DEFINE_UNARY_OP(aten::cos, std::cos(a), float, float),
DEFINE_UNARY_OP(aten::sin, std::sin(a), float, float),
DEFINE_UNARY_OP(aten::tan, std::tan(a), float, float),
DEFINE_UNARY_OP(aten::asinh, std::asinh(a), float, float),
DEFINE_UNARY_OP(aten::atanh, std::atanh(a), float, float),
DEFINE_UNARY_OP(aten::acosh, std::acosh(a), float, float),
DEFINE_UNARY_OP(aten::sinh, std::sinh(a), float, float),
DEFINE_UNARY_OP(aten::cosh, std::cosh(a), float, float),
DEFINE_UNARY_OP(aten::tanh, std::tanh(a), float, float),
DEFINE_UNARY_OP(aten::degrees, degrees(a), float, float),
DEFINE_UNARY_OP(aten::radians, radians(a), float, float),
DEFINE_BINARY_FLOAT_OP(aten::fmod, std::fmod(a, b)),
DEFINE_UNARY_INT_OP(aten::factorial, factorial(a), int),
DEFINE_UNARY_FLOAT_OP(aten::isnan, std::isnan(a), bool),
DEFINE_UNARY_FLOAT_OP(aten::isfinite, std::isfinite(a), bool),
DEFINE_UNARY_FLOAT_OP(aten::isinf, std::isinf(a), bool),
Operator(
"aten::modf(float a) -> (float, float)",
[](Stack& stack) {
double a;
pop(stack, a);
double b, c;
b = modf(a, &c);
push(stack, b, c);
return 0;
}),
Operator(
"aten::frexp(float a) -> (float, int)",
[](Stack& stack) {
double a;
pop(stack, a);
double m;
int e;
m = std::frexp(a, &e);
push(stack, m, e);
return 0;
}),
Operator(
"aten::ldexp(float x, int i) -> float",
[](Stack& stack) {
double a;
int64_t b;
pop(stack, a, b);
push(stack, std::ldexp(a, b));
return 0;
}),
DEFINE_BINARY_FLOAT_OP(aten::mathremainder, std::remainder(a, b)),
// TODO: move abs to aten namespace because it's schematized!
DEFINE_UNARY_OP(prim::abs, std::abs(a), int, float),
Operator(
"prim::abs(Tensor x) -> Tensor",
[](Stack& stack) {
at::Tensor x;
pop(stack, x);
push(stack, x.abs());
return 0;
}),
DEFINE_INT_OP(aten::gcd, gcd(a, b)),
DEFINE_GENERIC_OP(
aten::copysign,
std::copysign(a, b),
std::copysign(a, b),
float,
float),
DEFINE_INT_FLOAT_OP(aten::copysign, std::copysign(a, b), float),
DEFINE_UNARY_OP(aten::gamma, std::tgamma(a), float, float),
DEFINE_UNARY_OP(aten::erf, std::erf(a), float, float),
DEFINE_UNARY_OP(aten::erfc, std::erfc(a), float, float),
DEFINE_UNARY_OP(aten::expm1, std::expm1(a), float, float),
DEFINE_UNARY_OP(aten::fabs, std::fabs(a), float, float),
DEFINE_UNARY_OP(aten::lgamma, std::lgamma(a), float, float),
DEFINE_UNARY_OP(aten::asinh, std::asinh(a), float, float),
DEFINE_UNARY_OP(aten::atanh, std::atanh(a), float, float),
DEFINE_UNARY_OP(aten::cosh, std::cosh(a), float, float),
DEFINE_UNARY_OP(aten::sinh, std::sinh(a), float, float),
DEFINE_UNARY_OP(aten::tanh, std::tanh(a), float, float),
Operator(
"aten::isnan(float a) -> bool",
[](Stack& stack) {
double a;
pop(stack, a);
push(stack, std::isnan(a));
return 0;
}),
DEFINE_COMPARISON_OP(aten::ne, a != b),
DEFINE_COMPARISON_OP(aten::eq, a == b),
DEFINE_COMPARISON_OP(aten::lt, a < b),
DEFINE_COMPARISON_OP(aten::gt, a > b),
DEFINE_COMPARISON_OP(aten::le, a <= b),
DEFINE_COMPARISON_OP(aten::ge, a >= b),
DEFINE_BOOL_OP(aten::__and__, a&& b),
DEFINE_BOOL_OP(aten::__or__, a || b),
DEFINE_BOOL_OP(aten::__xor__, a != b),
DEFINE_UNARY_OP(aten::neg, -a, int, float),
Operator(
"aten::__not__(bool self) -> bool",
[](Stack& stack) {
push(stack, !pop(stack).toBool());
return 0;
}),
Operator(
"aten::__is__(t1 self, t2 obj) -> bool",
[](Stack& stack) {
IValue self, obj;
pop(stack, self, obj);
push(stack, self.isSameIdentity(obj));
return 0;
}),
Operator(
"aten::__isnot__(t1 self, t2 obj) -> bool",
[](Stack& stack) {
IValue self, obj;
pop(stack, self, obj);
push(stack, !self.isSameIdentity(obj));
return 0;
}),
Operator(
"aten::_tensor_to_list(Tensor self) -> int[]",
[](Stack& stack) {
at::Tensor t;
pop(stack, t);
c10::ListPtr<int64_t> elems = c10::make_list<int64_t>();
elems.reserve(t.size(0));
for (int i = 0; i < t.size(0); i++) {
elems.push_back(*t[i].data<int32_t>());
}
push(stack, std::move(elems));
return 0;
}),
Operator(
"aten::_list_to_tensor(int[] self) -> Tensor",
[](Stack& stack) {
c10::ListPtr<int64_t> l = pop(stack).toIntList();
auto t = torch::empty(
{static_cast<int64_t>(l.size())}, at::dtype(at::kInt));
for (size_t i = 0; i < l.size(); i++) {
t[i] = l.get(i);
}
push(stack, std::move(t));
return 0;
}),
#define CREATE_DICT_OPS(key_type) \
Operator("aten::len(Dict(" key_type ", t) self) -> int", dictLen), \
Operator( \
"aten::keys(Dict(" key_type ", t) self) -> " key_type "[](*)", \
dictKeys), \
Operator( \
"aten::values(Dict(" key_type ", t) self) -> t[](*)", dictValues), \
Operator( \
"prim::DictIndex(Dict(" key_type ", t) self, " key_type \
" key) -> t(*)", \
dictIndex), \
Operator( \
"aten::get(Dict(" key_type ", t) self, " key_type " key) -> t(*)?", \
dictGet), \
Operator( \
"aten::get(Dict(" key_type ", t) self, " key_type \
" key, t default_value) -> t(*)", \
dictGetDefault), \
Operator( \
"aten::_set_item(Dict(" key_type ", t)(a!) l, " key_type \
" idx, t(b -> *) v) -> ()", \
dictSetItem)
CREATE_DICT_OPS("str"),
CREATE_DICT_OPS("int"),
CREATE_DICT_OPS("float"),
#undef CREATE_DICT_OPS
Operator(
"aten::divmod(int x, int y) -> (int, int)",
[](Stack& stack) {
int64_t a, b;
lldiv_t divresult = {};
pop(stack, a, b);
if (b == 0) {
throw std::runtime_error("ZeroDivisionError: integer division or modulo by zero");
}
divresult = lldiv(a, b);
if (divresult.rem && (a < 0) != (b < 0)) {
divresult.quot -= 1;
divresult.rem += b;
}
push(stack, static_cast<int64_t>(divresult.quot), \
static_cast<int64_t>(divresult.rem));
return 0;
}),
Operator(
"aten::divmod(float x, float y) -> (float, float)",
[](Stack& stack) {
double a, b;
pop(stack, a, b);
if (b == 0) {
throw std::runtime_error("ZeroDivisionError: float divmod()");
}
double rem = fmod(a, b);
if (rem && (a < 0) != (b < 0)) {
rem += b;
}
push(stack, (a - rem)/b, rem);
return 0;
}),
#define DEFINE_DIVMOD_MIXED_OP(type_a, type_b) \
Operator( \
"aten::divmod(" #type_a " x," #type_b " y) -> (float, float)", \
[](Stack& stack) { \
type_a a; \
type_b b; \
pop(stack, a, b); \
if (b == 0) { \
throw std::runtime_error("ZeroDivisionError: float divmod()"); \
} \
double quot = floor(a / b); \
double rem = a - (quot * b); \
push(stack, quot, rem); \
return 0; \
})
DEFINE_DIVMOD_MIXED_OP(int, float),
DEFINE_DIVMOD_MIXED_OP(float, int),
#undef DEFINE_DIVMOD_MIXED_OP
Operator("aten::hash(str t) -> int", hashValue<std::string>),
Operator("aten::hash(int t) -> int", hashValue<int>),
Operator("aten::hash(float t) -> int", hashValue<double>),
});
bool simpleClassTypeArg(const Argument& arg, const ClassTypePtr& type) {
return arg.type() == type && !arg.kwarg_only() && !arg.default_value();
}
void checkSortSchema(const Node* node, const c10::TypePtr& list_element_type) {
std::stringstream error_str;
if (auto class_type = list_element_type->cast<ClassType>()) {
if (auto method = class_type->getMethod("__lt__")) {
const auto& lt_schema = method->getSchema();
const auto& schema_args = lt_schema.arguments();
bool error =
(schema_args.size() != 2 ||
!simpleClassTypeArg(schema_args[0], class_type) ||
!simpleClassTypeArg(schema_args[1], class_type) ||
lt_schema.returns().size() != 1 ||
lt_schema.returns()[0].type() != BoolType::get());
if (!error) {
return;
}
}
error_str << "To sort a list of " << class_type->python_str()
<< " it must define a "
<< "__lt__ method with two inputs of type "
<< class_type->python_str() << " that "
<< "returns a bool";
} else {
error_str
<< "Input to list sort must be of Tensors, ints, floats, bools or "
<< "a User Defined Class that defines the __lt__ compare method"
<< ", got list of " << list_element_type->python_str() << "\n";
}
auto error_msg = script::ErrorReport(node->sourceRange());
error_msg << error_str.str();
throw error_msg;
}
// NB: this must be registered after the other aten::sort operators
RegisterOperators regSort({
Operator(
"aten::sort(t[](a!) self, bool reverse=False) -> ()",
[](const Node* node) {
const auto list_type =
node->inputs().at(0)->type()->expect<ListType>();
checkSortSchema(node, list_type->getElementType());
const auto elem = list_type->getElementType()->expect<ClassType>();
auto func = elem->getMethod("__lt__");
return [func](Stack& stack) {
bool reverse = pop(stack).toBool();
auto g_list = pop(stack).toGenericList();
Stack sort_stack;
std::sort(
g_list.begin(),
g_list.end(),
[func, reverse, &sort_stack](
IValue a, IValue b) -> bool {
// FBCode errors without this check - "strict weak ordering"
// TODO: remove when possible, since it just slows down
// sorting and doesn't do anything useful
if (a.isSameIdentity(b)) {
return false;
}
sort_stack.push_back(a);
sort_stack.push_back(b);
func->run(sort_stack);
return pop(sort_stack).toBool() ^ reverse;
});
return 0;
};
}),
});
// reference: _output_size in torch/nn/functional.py
// size can be none, int or intlist
// scale_factors can be none, float, or floatlist
std::vector<int64_t> _output_size(
const at::Tensor& input,
size_t dim,
const IValue& size,
const IValue& scale_factors) {
if (!size.isNone()) {
if (size.isInt()) {
std::vector<int64_t> repeated(dim, size.toInt());
return repeated;
} else {
return size.toIntListRef().vec();
}
}
std::vector<double> scale_repeated;
if (scale_factors.isDouble()) {
scale_repeated = std::vector<double>(dim, scale_factors.toDouble());
} else {
scale_repeated = scale_factors.toDoubleListRef().vec();
}
std::vector<int64_t> ret;
for (size_t i = 0; i < dim; ++i) {
ret.push_back(std::floor(input.size(i + 2) * scale_repeated[i]));
}
return ret;
}
// reference: interpolate in torch/nn/functional.py
// size can be none, int or intlist
// scale_factors can be none, float, or floatlist
at::Tensor interpolate(
const at::Tensor& input,
const IValue& size,
const IValue& scale_factors,
const std::string& mode,
c10::optional<bool> align_corners) {
if ((mode == "nearest" || mode == "area")) {
if (align_corners != c10::nullopt) {
throw std::runtime_error(
"align_corners option can only be set with the "
"interpolating modes: linear | bilinear | bicubic | trilinear");
}
} else {
if (align_corners == c10::nullopt) {
AT_WARN(
"Default upsampling behavior when mode=",
mode,
" is changed "
"to align_corners=False since 0.4.0. Please specify align_corners=True "
"if the old behavior is desired. See the documentation of nn.Upsample for details");
align_corners = false;
}
}
auto input_dim = input.dim();
if (input_dim == 3 && mode == "nearest")
return at::upsample_nearest1d(
input, _output_size(input, 1, size, scale_factors));
if (input_dim == 4 && mode == "nearest")
return at::upsample_nearest2d(
input, _output_size(input, 2, size, scale_factors));
if (input_dim == 5 && mode == "nearest")
return at::upsample_nearest3d(
input, _output_size(input, 3, size, scale_factors));
if (input_dim == 3 && mode == "area")
return at::adaptive_avg_pool1d(
input, _output_size(input, 1, size, scale_factors));
if (input_dim == 4 && mode == "area")
return at::adaptive_avg_pool2d(
input, _output_size(input, 2, size, scale_factors));
if (input_dim == 5 && mode == "area")
return at::adaptive_avg_pool3d(
input, _output_size(input, 3, size, scale_factors));
if (input_dim == 3 && mode == "linear")
return at::upsample_linear1d(
input, _output_size(input, 1, size, scale_factors), *align_corners);
if (input_dim == 3 && mode == "bilinear")
throw std::runtime_error("Got 3D input, but bilinear mode needs 4D input");
if (input_dim == 3 && mode == "bicubic")
throw std::runtime_error("Got 3D input, but bicubic mode needs 4D input");
if (input_dim == 3 && mode == "trilinear")
throw std::runtime_error("Got 3D input, but trilinear mode needs 5D input");
if (input_dim == 4 && mode == "linear")
throw std::runtime_error("Got 4D input, but linear mode needs 3D input");
if (input_dim == 4 && mode == "bilinear")
return at::upsample_bilinear2d(
input, _output_size(input, 2, size, scale_factors), *align_corners);
if (input_dim == 4 && mode == "bicubic")
return at::upsample_bicubic2d(
input, _output_size(input, 2, size, scale_factors), *align_corners);
if (input_dim == 4 && mode == "trilinear")
throw std::runtime_error("Got 4D input, but trilinear mode needs 5D input");
if (input_dim == 5 && mode == "linear")
throw std::runtime_error("Got 5D input, but linear mode needs 3D input");
if (input_dim == 5 && mode == "bilinear")
throw std::runtime_error("Got 5D input, but bilinear mode needs 4D input");
if (input_dim == 5 && mode == "bicubic")
throw std::runtime_error("Got 5D input, but bicubic mode needs 4D input");
if (input_dim == 5 && mode == "trilinear")
return at::upsample_trilinear3d(
input, _output_size(input, 3, size, scale_factors), *align_corners);
AT_ERROR(
"Input Error: Only 3D, 4D and 5D input Tensors supported",
" (got ",
input_dim,
"D) for the modes: nearest | linear | bilinear | trilinear",
" (got ",
mode,
") ");
}
Operation interpolate_op(const Node* n) {
return [](Stack& stack) {
at::Tensor input;
IValue size;
IValue scale_factors;
std::string mode;
IValue align_corners;
pop(stack, input, size, scale_factors, mode, align_corners);
at::Tensor res = interpolate(
input, size, scale_factors, mode, align_corners.toOptional<bool>());
push(stack, std::move(res));
return 0;
};
}
// interpolate takes in float & float[] for scale factor
// upsample takes in int & int[], so convert the ints to floats before
// passing on to the interpolate op
IValue convert_scale_factor_to_double(const IValue& int_ivalue) {
IValue scale_factor_double;
if (int_ivalue.isInt()) {
scale_factor_double = static_cast<double>(int_ivalue.toInt());
} else if (int_ivalue.isIntList()) {
auto int_list = int_ivalue.toIntListRef();
std::vector<double> double_vec(int_list.begin(), int_list.end());
scale_factor_double = c10::impl::toList(double_vec);
} else if (int_ivalue.isNone()) {
return IValue();
} else {
std::stringstream ss;
ss << "Expecting optional int or int list arg for scale factor, got"
<< int_ivalue;
throw std::runtime_error(ss.str());
}
return scale_factor_double;
}
Operation upsample_nearest_op(const Node* n) {
return [](Stack& stack) {
at::Tensor input;
IValue size;
IValue scale_factor_int;
pop(stack, input, size, scale_factor_int);
IValue scale_factor_double =
convert_scale_factor_to_double(scale_factor_int);
at::Tensor res =
interpolate(input, size, scale_factor_double, "nearest", c10::nullopt);
push(stack, std::move(res));
return 0;
};
}
Operation upsample_op(const Node* n) {
return [](Stack& stack) {
at::Tensor input;
IValue size;
IValue scale_factor_int;
std::string mode;
IValue align_corners;
pop(stack, input, size, scale_factor_int, mode, align_corners);
IValue scale_factor_double =
convert_scale_factor_to_double(scale_factor_int);
at::Tensor res = interpolate(
input,
size,
scale_factor_double,
mode,
align_corners.toOptional<bool>());
push(stack, std::move(res));
return 0;
};
}
Operation upsample_bilinear_op(const Node* n) {
return [](Stack& stack) {
at::Tensor input;
IValue size;
IValue scale_factor_int;
pop(stack, input, size, scale_factor_int);
IValue scale_factor_double =
convert_scale_factor_to_double(scale_factor_int);
at::Tensor res =
interpolate(input, size, scale_factor_double, "bilinear", true);
push(stack, std::move(res));
return 0;
};
}
RegisterOperators reg3({
Operator(
"aten::__interpolate(Tensor input, int? size = None, float[]? scale_factor = None, str mode = 'nearest', bool? align_corners = None) -> Tensor",
interpolate_op),
Operator(
"aten::__interpolate(Tensor input, int[]? size = None, float[]? scale_factor = None, str mode = 'nearest', bool? align_corners = None) -> Tensor",
interpolate_op),
Operator(
"aten::__interpolate(Tensor input, int? size = None, float? scale_factor = None, str mode = 'nearest', bool? align_corners = None) -> Tensor",
interpolate_op),
Operator(
"aten::__interpolate(Tensor input, int[]? size = None, float? scale_factor = None, str mode = 'nearest', bool? align_corners = None) -> Tensor",
interpolate_op),
Operator(
"aten::__upsample_nearest(Tensor input, int? size = None, int? scale_factor = None) -> Tensor",
upsample_nearest_op),
Operator(
"aten::__upsample_nearest(Tensor input, int[]? size = None, int? scale_factor = None) -> Tensor",
upsample_nearest_op),
Operator(
"aten::__upsample(Tensor input, int? size = None, int? scale_factor = None, str mode = 'nearest', bool? align_corners = None) -> Tensor",
upsample_op),
Operator(
"aten::__upsample(Tensor input, int[]? size = None, int? scale_factor = None, str mode = 'nearest', bool? align_corners = None) -> Tensor",
upsample_op),
Operator(
"aten::__upsample_bilinear(Tensor input, int? size = None, int? scale_factor = None) -> Tensor",
upsample_bilinear_op),
Operator(
"aten::__upsample_bilinear(Tensor input, int[]? size = None, int? scale_factor = None) -> Tensor",
upsample_bilinear_op),
Operator(
"aten::__upsample_bilinear(Tensor input, int? size = None, int[]? scale_factor = None) -> Tensor",
upsample_bilinear_op),
Operator(
"aten::__upsample_bilinear(Tensor input, int[]? size = None, int[]? scale_factor = None) -> Tensor",
upsample_bilinear_op),
});
at::Tensor leaky_relu(const at::Tensor& tensor, double scalar) {
return at::leaky_relu(tensor, scalar);
}
at::Tensor cat(const std::vector<at::Tensor>& tensors) {
return at::cat(tensors);
}
std::string get_first(const std::vector<std::vector<std::string>>& strings) {
return strings[0][0];
}
static auto reg4 =
torch::jit::RegisterOperators()
.op("_test::leaky_relu(Tensor self, float v=0.01) -> Tensor",
&leaky_relu)
.op("_test::cat(Tensor[] inputs) -> Tensor", &cat)
.op("_test::get_first", &get_first);
} // namespace
} // namespace jit
} // namespace torch
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
3c8827c54f6d8c34658b7afea5518402400106ad | 81cf910ae87bf3220f4dcc5773cf1b9cc4e2f3b7 | /addresstable.cpp | f6c2bbc24e4afba7a802832345caa7f418bd2250 | [] | no_license | ivanprosh/fastRetro | dbc0258d55912706741a4fe4f655001462a5773c | dcdd2c89d30588da083c3ebf89bc65872bb5ba1b | refs/heads/master | 2021-01-23T00:15:28.055037 | 2017-04-09T00:08:40 | 2017-04-09T00:08:40 | 85,710,458 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,910 | cpp | #include "addresstable.h"
#include "global.h"
#include <QDebug>
#include <QRegExp>
namespace {
const int MaxColumns = 2;
}
AddressTable::AddressTable(QObject *parent)
: QAbstractTableModel(parent)
{
initialize();
}
void AddressTable::initialize()
{
hash = new QHash<int,QByteArray>;
hash->insert(ipRole, "ipAddr");
hash->insert(statusRole, "status");
//setHorizontalHeaderLabels(QStringList() << tr("IP адрес") << tr("Статус"));
//добавим строки
items.push_back(QPair<QString,QString>("172.16.3.121:10000","Не активен"));
int row(1);
while(row < MAX_CONNECTIONS_COUNT){
items.push_back(QPair<QString,QString>("",""));
row++;
}
}
void AddressTable::clear()
{
//QStandardItemModel::clear();
initialize();
}
void AddressTable::ipChange(const int curRow, const int curColumn, const QVariant &value)
{
// qDebug() << "row " << curRow << "column " << curColumn << "role " << Qt::UserRole+curColumn;
// qDebug() << value.toString();
QRegExp correctIp("^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\:(\\d+)");
if(index(curRow,curColumn).isValid() && (correctIp.exactMatch(value.toString())))
if(correctIp.cap(1).toInt() < 255 || correctIp.cap(2).toInt() < 255 || correctIp.cap(3).toInt() < 255 || correctIp.cap(4).toInt() < 255)
setData(index(curRow,curColumn), value, Qt::UserRole+curColumn);
}
bool AddressTable::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (index.isValid() && (role == Qt::EditRole || role >= Qt::UserRole)) {
qDebug() << role << " " << value.toString();
Q_ASSERT(index.row()<=items.size());
if(items.empty()){
Q_ASSERT(role==statusRole);
items.push_back(QPair<QString,QString>(value.toString(),"Не активен"));
} else {
switch (role) {
case ipRole:
if(items.at(index.row()).first == value.toString())
return false;
items[index.row()].first = value.toString();
break;
case statusRole:
if(items.at(index.row()).second == value.toString())
return false;
items[index.row()].second = value.toString();
break;
default:
return false;
}
}
emit dataChanged(index, index);
return true;
}
return false;
}
int AddressTable::rowCount(const QModelIndex &index) const
{
return index.isValid() ? 0 : items.size();
}
int AddressTable::columnCount(const QModelIndex &index) const
{
return index.isValid() ? 0 : MaxColumns;
}
QVariant AddressTable::data(const QModelIndex &index, int role) const
{
if(!index.isValid()) return QVariant();
//qDebug() << index.row() << items.size();
Q_ASSERT(index.row()<=items.size());
switch (role) {
case ipRole:
return items.at(index.row()).first;
case statusRole:
return items.at(index.row()).second;
default:
Q_ASSERT(false);
}
}
QHash<int, QByteArray> AddressTable::roleNames() const
{
return *hash;
}
Qt::ItemFlags AddressTable::flags(const QModelIndex &index) const
{
Qt::ItemFlags theFlags = QAbstractTableModel::flags(index);
if (index.isValid())
theFlags |= Qt::ItemIsSelectable|Qt::ItemIsEditable|
Qt::ItemIsEnabled;
return theFlags;
}
QVariant AddressTable::headerData(int section,
Qt::Orientation orientation, int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
if (orientation == Qt::Horizontal) {
switch (section) {
case ipColumn: return tr("IP адрес");
case statusColumn: return tr("Статус");
default: Q_ASSERT(false);
}
}
return section + 1;
}
| [
"ivanprosh@gmail.com"
] | ivanprosh@gmail.com |
d048bdd5b356dd528deaafbc436eff2134fe60a8 | bdaa8dbc397dedbff35c8cb55a756dd11c068b30 | /test/buffer/push_pop.cc | 8d48c75d5f61c2e0745bd18d68b828ba695cf06d | [
"MIT"
] | permissive | humu1us/cmicro | e8f2f21fa2462fb72ad641148897deddd38494ef | fc34c9a1fba68451f64df8a34819f29b31ec7182 | refs/heads/master | 2020-04-11T11:23:17.398714 | 2019-06-15T02:25:38 | 2019-06-15T02:25:38 | 161,746,423 | 0 | 0 | MIT | 2019-07-22T00:06:40 | 2018-12-14T07:14:09 | C++ | UTF-8 | C++ | false | false | 1,756 | cc | #include <micro/core/buffer.h>
#include <micro/core/message.h>
#include <assert.h>
int main()
{
micro::Buffer buffer(2);
assert(buffer.is_empty());
assert(!buffer.is_full());
assert(buffer.size() == 0);
auto msg_1 = std::make_unique<micro::Message>(micro::Message(1, "", "", ""));
assert(msg_1);
assert(msg_1->get_iface_id() == 1);
buffer.push(std::move(msg_1));
assert(!msg_1);
assert(!buffer.is_empty());
assert(!buffer.is_full());
assert(buffer.size() == 1);
auto msg_2 = std::make_unique<micro::Message>(micro::Message(2, "", "", ""));
assert(msg_2);
assert(msg_2->get_iface_id() == 2);
buffer.push(std::move(msg_2));
assert(!msg_2);
assert(!buffer.is_empty());
assert(buffer.is_full());
assert(buffer.size() == 2);
auto msg_3 = std::make_unique<micro::Message>(micro::Message(3, "", "", ""));
assert(msg_3);
assert(msg_3->get_iface_id() == 3);
std::string error = std::string();
try
{
buffer.push(std::move(msg_3));
} catch (std::out_of_range &e)
{
error = e.what();
}
assert(error == "buffer is full");
assert(!msg_3);
std::unique_ptr<micro::Message> msg_1_ = buffer.pop();
assert(msg_1_->get_iface_id() == 1);
assert(!buffer.is_empty());
assert(!buffer.is_full());
assert(buffer.size() == 1);
std::unique_ptr<micro::Message> msg_2_ = buffer.pop();
assert(msg_2_->get_iface_id() == 2);
assert(buffer.is_empty());
assert(!buffer.is_full());
assert(buffer.size() == 0);
std::unique_ptr<micro::Message> msg_3_ = buffer.pop();
assert(!msg_3_);
assert(buffer.is_empty());
assert(!buffer.is_full());
assert(buffer.size() == 0);
return 0;
}
| [
"pablo.ahumadadiaz@gmail.com"
] | pablo.ahumadadiaz@gmail.com |
863e87a2c042c4a20f0007f886c8ce06a46ec645 | 12ef8f1dc18801baa852b2d9fad780d4ace81b37 | /gl-craft/Source/Texture/TexturePaths.hpp | 97ced6de1f34339842b42f844dc2f581672b52dc | [] | no_license | dwarzecha/gl-craft | a65cb3b46a635351bb5326ce4fd2408ac225d461 | efac9026f402e10286f568f78556ae596542b75a | refs/heads/master | 2023-01-01T19:46:34.258115 | 2020-10-16T20:17:34 | 2020-10-16T20:17:34 | 285,246,638 | 2 | 1 | null | 2020-09-24T13:34:34 | 2020-08-05T09:48:47 | C++ | UTF-8 | C++ | false | false | 290 | hpp | #ifndef TEXTUREPATHS_HPP_INCLUDED
#define TEXTUREPATHS_HPP_INCLUDED
#include <vector>
#include <map>
#include <string>
namespace TexturePaths
{
typedef std::map<int, std::string> PathMap;
extern PathMap grass;
extern std::vector<PathMap> paths;
}
#endif // TEXTUREPATHS_HPP_INCLUDED
| [
"dawiozol@gmail.com"
] | dawiozol@gmail.com |
a864dd20e910efbae7b72e59b56bda17d283f442 | f9d77c29938b652a102f29a5d442b9a8021ecafa | /B5/task1.hpp | c16100aa9ce1fa68c14d21bf11958f9d2ed05d07 | [] | no_license | TheTedLab/OOP-2020-Labs | aa33fe27bb73dcd3a73399e8ddac9f4e4e771ba9 | cccc14c50c1bbc47126c274664443c4e5d393235 | refs/heads/main | 2023-05-26T17:19:28.979255 | 2021-06-07T15:57:48 | 2021-06-07T15:57:48 | 374,709,732 | 1 | 0 | null | 2021-06-07T15:57:49 | 2021-06-07T15:12:56 | C++ | UTF-8 | C++ | false | false | 532 | hpp | #ifndef TASK_ONE_HPP
#define TASK_ONE_HPP
#include <iostream>
#include <iterator>
#include <string>
#include <unordered_set>
using in_iter = std::istream_iterator<std::string>;
using out_iter = std::ostream_iterator<std::string>;
void task1(std::istream& sin, std::ostream& os)
{
std::unordered_set<std::string> list{in_iter(sin), in_iter()};
if (!sin.eof() && sin.fail())
{
throw std::invalid_argument("Error while reading data in task1!\n");
}
std::copy(list.begin(), list.end(), out_iter(os, "\n"));
}
#endif
| [
"reserv.muhin2001@yandex.ru"
] | reserv.muhin2001@yandex.ru |
44a07fe04272a72376905f9868707d050ec03149 | ee32d46014c1f2fc5ec7bb833233c24237270933 | /1355B/main.cpp | bd9e26016b324e634694699b99ba0d3884dc60a6 | [] | no_license | boxnos/codeforces | 42b48367d222cc58c2bc0f408469fc6a2732cec7 | fbc358fe7ddf48d48bda29e75ef3264f9ed19852 | refs/heads/master | 2023-08-27T21:18:44.163264 | 2023-08-26T18:06:59 | 2023-08-26T18:06:59 | 192,764,064 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,562 | cpp | #include <cstdio>
#include <utility>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;
#ifdef __linux
#define _U(s) s##_unlocked
#else
#define _U(s) _##s##_nolock
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
#define gcu _U(getchar)
#define pcu _U(putchar)
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _I inline
#define _OP(t) _I operator t()
struct _in {
#ifdef _GLIBCXX_STRING
_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
//_OP(string){string s;char c;while(isspace(c = gcu()));do{s+=c;}while(c=gcu(),c!=' '&&c!='\n'&&c!=EOF);return s;}
#define _S
#endif
_OP(char){char c=gcu();gcu();return c;}
_OP(double){double d; scanf("%lf",&d); gcu();return d;}
_T _OP(T){T n{},m{1},c;while(isspace(c=gcu()));if(c=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
_HT _OUT(H &&h, T... t){out(h);out(t...);}
template <typename... T> _OUTL(T... t){out(t...);outl();}
struct range{
int e,b=0,s=1;range(int b,int e,int s):e(e),b(b),s(s){} range(int b,int e): e(e), b(b){} range(int e):e(e){}
struct it{int v,s; it(int v,int s):v(v),s(s){} operator int()const{return v;} _I operator int&(){return v;}int operator*()const{return v;}
_I it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define tee(s,v) ({dbg(s,v);v;})
int main() {
times (T, in) {
int N {in}, r {}, a {};
vector<int> e(N);
for (int &i: e)
i = in;
sort(begin(e), end(e));
for (int i: e)
if (++a == i)
r++, a = 0;
outl(r);
}
}
/* vim: set ts=4 noet: */
| [
"boxnos@yahoo.com"
] | boxnos@yahoo.com |
56db928495dbda1e842762fcf416c5f8aca23106 | b499415ddf8baed8eadd898a16060237e24dd03c | /Exercises/GPP_Exercise_04_Objects_and_Components/gameapp_gpp/src/gpp/gamecomponents/rendercomponent.cpp | 8d98c160e55815c98c378766adf219be8714a79a | [] | no_license | imbabaer/gpp | 22890ea824f251178342c5fe210b8be7aa31e7bd | 656947b5a0fde48fd220c1029685cc37452278c2 | refs/heads/master | 2020-05-22T14:49:25.952782 | 2014-05-21T06:52:26 | 2014-05-21T06:52:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,336 | cpp | #include "stdafx.h"
#include "gpp/gameComponents/renderComponent.h"
#include "gep/globalManager.h"
#include "gep/interfaces/renderer.h"
#include "gep/interfaces/logging.h"
#include "gep/interfaces/scripting.h"
gpp::RenderComponent::RenderComponent():
Component(),
m_path(),
m_pModel(nullptr),
m_extractionCallbackId(0)
{
}
gpp::RenderComponent::~RenderComponent()
{
m_pModel = nullptr;
}
void gpp::RenderComponent::initalize()
{
if(m_path.empty())
{
g_globalManager.getLogging()->logError("Render Component's path on GameObject %s hasn't been set!", m_pParentGameObject->getName().c_str());
GEP_ASSERT(false);
}
else
{
m_pModel = g_globalManager.getRenderer()->loadModel(m_path.c_str());
m_extractionCallbackId = g_globalManager.getRendererExtractor()->registerExtractionCallback(std::bind(&RenderComponent::extract,this,std::placeholders::_1));
}
}
void gpp::RenderComponent::update(float elapsedMS)
{
}
void gpp::RenderComponent::destroy()
{
g_globalManager.getRendererExtractor()->deregisterExtractionCallback(m_extractionCallbackId);
}
void gpp::RenderComponent::extract(gep::IRendererExtractor& extractor)
{
m_pModel->extract(extractor, m_pParentGameObject->getTransformationMatrix());
}
| [
"rubenmueller90@gmail.com"
] | rubenmueller90@gmail.com |
a3b656d070e6fff4b72d5ffd8c32e51656dc8606 | c5ac7777ef6f11cb6876dad578e7e5ea5de4c01b | /codeforces/814C.cpp | 467c57984dee7683e7ba1e6cd688b295fcf35bcd | [] | no_license | taufiqhusada/competitive-programming | 681d68650289d3cf90914f70e1430157ff273f44 | 4469fa21de0325b07b47109dd9b144cd76173754 | refs/heads/master | 2021-06-26T04:52:03.280287 | 2020-12-16T04:06:02 | 2020-12-16T04:06:02 | 161,109,687 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 627 | cpp | #include<bits/stdc++.h>
using namespace std;
int n,q,m,re,x;
char c,t;
string s;
int dp[30][2000];
int main(){
cin>>n;
cin>>s;
int len = s.length();
for (int i = 0; i<26; ++i){
for (int j = 0; j<len; ++j){
re = 0;
for (int k = j; k<len; ++k){
if (s[k]!=(char)(i+(int)'a'))re++;
dp[i][re] = max(dp[i][re],k-j+1);
}
}
for (int re = 1; re<=n; ++re){
dp[i][re] = max(dp[i][re],dp[i][re-1]);
}
}
cin>>q;
while(q--){
cin>>x>>t;
cout<<dp[(int)((int)t-'a')][x]<<endl;
}
}
| [
"taufiqhusdr@gmail.com"
] | taufiqhusdr@gmail.com |
a4ca208411442389db072e087c793674616b2385 | 298c5db462af93b99f6c457b5245619a009e537e | /DiscountCoupon.h | bd62875f25034e74fe241ba17b6f8fc0438ef0dc | [] | no_license | ohaluminum/COSC1430_Lab22 | f07251438df911df9c2634f1d0c1dc2e9109eb88 | 543ab2740b0453df02fc8f3951ff45b9eda27803 | refs/heads/master | 2021-05-25T18:14:41.062811 | 2020-04-07T18:25:49 | 2020-04-07T18:25:49 | 253,864,367 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 980 | h | #pragma once
#include "Coupon.h"
#ifndef DISCOUNTCOUPON_H
#define DISCOUNTCOUPON_H
class DiscountCoupon : public Coupon {
public:
/*
*A constructor with one parameter (with default value).
*This parameter will be used to initialize the private member inherited from the Coupon class
*/
DiscountCoupon(float off = 0)
: Coupon(off)
{
if (off > 1 || off < 0)
setCoupon(0.0);
}
//A destructor that prints out the message Discount coupon is used!
~DiscountCoupon()
{
cout << "Discount coupon is used!" << endl;
}
/*
*The overriding function float applyCoupon(float orgPrice) that re-implements the strategy of applying coupon.
*In particular, the new price after applying coupon will be (1 - amount) * orgPrice.
*/
float applyCoupon(float orgPrice)
{
orgPrice = orgPrice * (1 - getCoupon());
return orgPrice;
}
};
#endif //DISCOUNTCOUPON_H
| [
"ohaluminum@users.noreply.github.com"
] | ohaluminum@users.noreply.github.com |
e57bd74b4f27b360e5e8250ee480eb5db1afe449 | 7f0fecfcdadd67036443a90034d34a0b0318a857 | /sparta/sparta/collection/PipelineCollector.hpp | fb14ec46a3c7a669d6ea97af792bdf5702481ca6 | [
"MIT"
] | permissive | timsnyder/map | e01b855288fc204d12e32198b2c8bd0f13c4cdf7 | aa4b0d7a1260a8051228707fd047431e1e52e01e | refs/heads/master | 2020-12-21T19:34:48.716857 | 2020-02-17T17:29:29 | 2020-02-17T17:29:29 | 236,536,756 | 0 | 0 | MIT | 2020-01-27T16:31:24 | 2020-01-27T16:31:23 | null | UTF-8 | C++ | false | false | 28,780 | hpp | // <PipelineCollector.hpp> -*- C++ -*-
/**
* \file PipelineCollector.hpp
*
* \brief Class to facilitate pipeline collection operations.
*/
#ifndef __PIPELINE_COLLECTOR_H__
#define __PIPELINE_COLLECTOR_H__
#include <set>
#include <map>
#include "sparta/simulation/TreeNode.hpp"
#include "sparta/simulation/Clock.hpp"
#include "sparta/utils/SpartaAssert.hpp"
#include "sparta/collection/CollectableTreeNode.hpp"
#include "sparta/collection/Collector.hpp"
#include "sparta/events/EventSet.hpp"
#include "sparta/events/UniqueEvent.hpp"
#include "sparta/kernel/Scheduler.hpp"
#include "sparta/argos/Outputter.hpp"
#include "sparta/argos/ClockFileWriter.hpp"
#include "sparta/argos/LocationFileWriter.hpp"
#include "sparta/simulation/TreeNodePrivateAttorney.hpp"
namespace sparta{
namespace collection
{
/**
* \class PipelineCollector
*
* \brief A class that facilitates all universal pipeline
* collection operations such as outputting finalized
* records, generating unique transaction Id's, maintaining
* heartbeat functionality, writing the location file,
* writing the clock file.
*
* The class must be initialized with
* PipelineCollector::getPipelineCollector()->init(...) before
* collection is to occure. This method is required to have
* important parameters required during pipeline collection.
*
* This class operates on a specific scheduler specified at construction.
* It's implementation should not access the sparta Scheduler singleton
* directly.
*
* destroy() should also be called at the end of the programs life
* to perform post collection maintenance. Any transactions alive
* at this point will have their current data written to disk with
* the end time as the end time of simulation. If the singleton
* was never initialized, destroy will have no effect.
*
* Once the singleton is created and initialized with init
* pipeline collection still needs to be switched on. This can be
* done via the startCollection() at the treenode level. This
* method recursively turns on collection at and below the
* treenode pointer passed in.
*
* Likewise collection can be turned off via stopCollection at any
* time.
*/
class PipelineCollector : public Collector
{
class CollectablesByClock
{
public:
CollectablesByClock(const Clock * clk,
SchedulingPhase collection_phase) :
ev_set_(nullptr)
{
switch(collection_phase)
{
case SchedulingPhase::Trigger:
ev_collect_.reset(new sparta::UniqueEvent<SchedulingPhase::Trigger>
(&ev_set_, sparta::notNull(clk)->getName() + "_auto_collection_event_trigger",
CREATE_SPARTA_HANDLER(CollectablesByClock, performCollection), 1));
break;
case SchedulingPhase::Update:
ev_collect_.reset(new sparta::UniqueEvent<SchedulingPhase::Update>
(&ev_set_, sparta::notNull(clk)->getName() + "_auto_collection_event_update",
CREATE_SPARTA_HANDLER(CollectablesByClock, performCollection), 1));
break;
case SchedulingPhase::PortUpdate:
ev_collect_.reset(new sparta::UniqueEvent<SchedulingPhase::PortUpdate>
(&ev_set_, sparta::notNull(clk)->getName() + "_auto_collection_event_portupdate",
CREATE_SPARTA_HANDLER(CollectablesByClock, performCollection), 1));
break;
case SchedulingPhase::Flush:
ev_collect_.reset(new sparta::UniqueEvent<SchedulingPhase::Flush>
(&ev_set_, sparta::notNull(clk)->getName() + "_auto_collection_event_flush",
CREATE_SPARTA_HANDLER(CollectablesByClock, performCollection), 1));
break;
case SchedulingPhase::Collection:
ev_collect_.reset(new sparta::UniqueEvent<SchedulingPhase::Collection>
(&ev_set_, sparta::notNull(clk)->getName() + "_auto_collection_event_collection",
CREATE_SPARTA_HANDLER(CollectablesByClock, performCollection), 1));
break;
case SchedulingPhase::Tick:
ev_collect_.reset(new sparta::UniqueEvent<SchedulingPhase::Tick>
(&ev_set_, sparta::notNull(clk)->getName() + "_auto_collection_event_tick",
CREATE_SPARTA_HANDLER(CollectablesByClock, performCollection), 1));
break;
case SchedulingPhase::PostTick:
ev_collect_.reset(new sparta::UniqueEvent<SchedulingPhase::PostTick>
(&ev_set_, sparta::notNull(clk)->getName() + "_auto_collection_event_posttick",
CREATE_SPARTA_HANDLER(CollectablesByClock, performCollection), 1));
break;
case SchedulingPhase::__last_scheduling_phase:
sparta_assert(!"Should not have gotten here");
break;
// NO DEFAULT! Allows for compiler errors if the enum
// class is updated.
}
ev_collect_->setScheduleableClock(clk);
ev_collect_->setScheduler(clk->getScheduler());
ev_collect_->setContinuing(false);
}
void enable(CollectableTreeNode * ctn) {
enabled_ctns_.insert(ctn);
ev_collect_->schedule(sparta::Clock::Cycle(0));
}
void disable(CollectableTreeNode * ctn) {
enabled_ctns_.erase(ctn);
}
bool anyCollected() const {
return !enabled_ctns_.empty();
}
void performCollection() {
// std::for_each(enabled_ctns_.begin(),
// enabled_ctns_.end(), [&](CollectableTreeNode * it) {
// std::cout << it->getName() << " " << ev_collect_.getClock()->currentCycle() << std::endl;
// });
for(auto & ctn : enabled_ctns_) {
if(ctn->isCollected()) {
ctn->collect();
}
}
if(!enabled_ctns_.empty()) {
ev_collect_->schedule();
}
}
void print() {
for(auto ctn : enabled_ctns_) {
std::cout << '\t' << ctn->getName() << std::endl;
}
}
private:
EventSet ev_set_;
std::unique_ptr<sparta::Scheduleable> ev_collect_;
std::set<CollectableTreeNode*> enabled_ctns_;
};
// A map of the clock pointer and the structures that
// represent collectables on that clock.
std::map<const sparta::Clock *,
std::array<std::unique_ptr<CollectablesByClock>,
sparta::NUM_SCHEDULING_PHASES>> clock_ctn_map_;
// Registered collectables
std::set<CollectableTreeNode*> registered_collectables_;
public:
/**
* \brief Instantiate the collector with required parameters before
* pipeline collection can occur.
* \param filepath The relative path to the output directory or file prefix.
* \param heartbeat_interval The interval offset at which to write an
* index file (in Ticks). If 0, the heartbeat will be derived from the
* known clocks in the simulation.
* \param root_clk A pointer to the clock that maintains the hyper
* cycle time.
* \param root A pointer to the root sparta::TreeNode during
* simulation which will be walked when producing
* a location map file that maps location id
* numbers with the sparta tree location for
* collected objects.
* \param scheduler Scheduler on which this collector operates. If null,
* uses the Scheduler belonging to root_clk. This allows us to
* run different pipeline collectors on different schedulers
* which is useful for standalone analyzers which run multiple
* instances of some model in parallel over the same trace data
*
* \warning If filepath is a directory, the directory must
* already exist.
* \pre The sparta tree must be finalized.
* \note This method does NOT start collection. To start
* collection, call startCollection
*
*/
PipelineCollector(const std::string& filepath, Scheduler::Tick heartbeat_interval,
const sparta::Clock* root_clk, const sparta::TreeNode* root,
Scheduler* scheduler=nullptr) :
Collector("PipelineCollector"),
scheduler_(scheduler != nullptr ? scheduler : root_clk->getScheduler()),
collector_events_(nullptr),
ev_heartbeat_(&collector_events_, Collector::getName() + "_heartbeat_event",
CREATE_SPARTA_HANDLER(PipelineCollector, performHeartBeat_), 0)
{
// Sanity check - pipeline collection cannot occur without a scheduler
sparta_assert(scheduler_);
ev_heartbeat_.setScheduleableClock(root_clk);
ev_heartbeat_.setScheduler(scheduler_);
sparta_assert(root != nullptr, "Pipeline Collection will not be able to create location file because it was passed a nullptr root treenode.");
sparta_assert(root->isFinalized(), "Pipeline collection cannot be constructed until the sparta tree has been finalized.");
// Assert that we got valid pointers necessary for pipeline collection.
sparta_assert(root_clk != nullptr, "Cannot construct PipelineCollector because root clock is a nullptr");
sparta_assert(scheduler_->isFinalized() == false, "Pipeline Collection cannot be instantiated after scheduler finalization -- it creates events");
// Initialize the clock/collectable map and find the fastest clock
const sparta::Clock* fastest_clk = nullptr;
std::function<void (const sparta::Clock*)> addClks;
addClks = [&addClks, this, &fastest_clk] (const sparta::Clock* clk)
{
if(clk != nullptr){
auto & u_p = clock_ctn_map_[clk];
for(uint32_t i = 0; i < NUM_SCHEDULING_PHASES; ++i) {
u_p[i].reset(new CollectablesByClock(clk, static_cast<SchedulingPhase>(i)));
}
for(const sparta::TreeNode* child : sparta::TreeNodePrivateAttorney::getAllChildren(clk)) {
const sparta::Clock* child_clk = dynamic_cast<const sparta::Clock*>(child);
if(child_clk){
auto clk_period = child_clk->getPeriod();
// If this clock has a non-1 period (i.e. not the root clock)
// AND there is either
// (A) no fastest clock yet
// or
// (B) this clock is a higher frequency than the fastest clock.
// then choose this as the fastest
if(clk_period != 1 && (!fastest_clk || (clk_period < fastest_clk->getPeriod()))) {
fastest_clk = child_clk;
}
addClks(child_clk);
}
}
}
};
addClks(root_clk);
if(fastest_clk == nullptr){
fastest_clk = root_clk;
}
// A multiple to multiply against the fastest clock when no heartbeat was set.
//! \todo The multiplier should also be scaled slightly by the number of locations
//! registered in order to better estimate the ideal heartbeat size.
static const uint32_t heartbeat_multiplier = 200;
// round heartbeat using a multiple of the fastest clock if one was not set.
if (heartbeat_interval == 0)
{
sparta_assert(fastest_clk->getPeriod() != 0);
heartbeat_interval = fastest_clk->getPeriod() * heartbeat_multiplier; //round up to the nearest multiple of 100
heartbeat_interval = heartbeat_interval + (100 - (heartbeat_interval % 100));
// Argos requires that intervals be a multiple of 100.
sparta_assert(heartbeat_interval % 100 == 0)
}
// We are gonna subtract one from the heartbeat_interval
// later.. Better be greater than one.
sparta_assert(heartbeat_interval > 1);
// Initialize some values.
filepath_ = filepath;
heartbeat_interval_ = heartbeat_interval;
closing_time_ = heartbeat_interval;
root_clk_ = root_clk;
ev_heartbeat_.setContinuing(false); // This event does not keep simulation going
}
~PipelineCollector() {
// XXX This is a little goofy looking. Should we make sparta_abort that takes conditional
// be sparta_abort_unless()?
sparta_abort(collection_active_ != true,
"The PipelineCollector was not torn down properly. Before "
"tearing down the simulation tree, you must call "
"destroy() on the collector");
}
/*!
* \brief Teardown the pipeline collector
*
* Tear down the PipelineCollector. Should be called before
* Tree teardown to close all open transactions.
*/
void destroy()
{
sparta_assert(writer_ != nullptr, "You cannot call PipelineCollector->destroy() more than once");
if(collection_active_) {
for(auto & ctn : registered_collectables_) {
if(ctn->isCollected()) {
ctn->closeRecord(true); // set true for simulation termination
}
}
}
registered_collectables_.clear();
writer_.reset();
collection_active_ = false;
}
/**
* \brief Turn on collection for everything below a TreeNode.
* Recursively transverse the tree and turn on child
* nodes for pipeline collection.
*
* \param starting_node TreeNode to start collection on. This
* TreeNode will try to start collection
* as well as any node below it.
*
* \note The Scheduler MUST be finalized before this method is
* called
*/
void startCollection(sparta::TreeNode* starting_node)
{
if(collection_active_ == false)
{
// Create the outputter used for writing transactions to disk.
writer_.reset(new argos::Outputter(filepath_, heartbeat_interval_));
// We need to write an index on the start BEFORE any transactions have been written.
writer_->writeIndex();
// Write the clock information out
writeClockFile_();
// Open the locations file
location_writer_.reset(new argos::LocationFileWriter(filepath_));
// The reader needs heartbeat indexes up to the current
// collection point. This can happen on delayed pipeline
// collection. Start the heartbeats at the first interval
// as the Outputter class handles hb 0
last_heartbeat_ = 0;
const uint64_t num_hb = scheduler_->getCurrentTick()/heartbeat_interval_;
uint64_t cnt = 0;
while(cnt != num_hb) {
// write an index
writer_->writeIndex();
last_heartbeat_ += heartbeat_interval_;
++cnt;
}
// Schedule a heartbeat at the next interval, offset from
// the current tick. For example, if the scheduler is at
// 6,600,456, then we want to schedule at 7,000,000 if the
// interval is 1M and the num_hb is 6
ev_heartbeat_.scheduleRelativeTick(((num_hb + 1) * heartbeat_interval_) -
scheduler_->getCurrentTick(), scheduler_);
collection_active_ = true;
}
*(location_writer_.get()) << (*starting_node);
// Recursively collect the start node and children
std::function<void (sparta::TreeNode* starting_node)> recursiveCollect;
recursiveCollect = [&recursiveCollect, this] (sparta::TreeNode* starting_node)
{
// First turn on this node if it's actually a CollectableTreeNode
CollectableTreeNode* c_node = dynamic_cast<CollectableTreeNode*>(starting_node);
if(c_node != nullptr) {
c_node->startCollecting(this);
registered_collectables_.insert(c_node);
}
// Recursive step. Go through the children and turn them on as well.
for(sparta::TreeNode* node : sparta::TreeNodePrivateAttorney::getAllChildren(starting_node))
{
recursiveCollect(node);
}
};
recursiveCollect(starting_node);
}
/**
* \brief Stop pipeline collection on only those
* CollectableTreeNodes given
* \param starting_node The node to shut collection down on
*
*/
void stopCollection(sparta::TreeNode* starting_node)
{
std::function<void (sparta::TreeNode* starting_node)> recursiveStopCollect;
recursiveStopCollect = [&recursiveStopCollect, this] (sparta::TreeNode* starting_node) {
// First turn off this node if it's actually a CollectableTreeNode
CollectableTreeNode* c_node = dynamic_cast<CollectableTreeNode*>(starting_node);
if(c_node != nullptr)
{
c_node->stopCollecting(this);
registered_collectables_.erase(c_node);
}
// Recursive step. Go through the children and turn them on as well.
for(sparta::TreeNode* node : sparta::TreeNodePrivateAttorney::getAllChildren(starting_node))
{
recursiveStopCollect(node);
}
};
recursiveStopCollect(starting_node);
bool still_active = !registered_collectables_.empty();
// for(auto & cp : clock_ctn_map_) {
// if(cp.second->anyCollected()) {
// still_active = true;
// break;
// }
// }
collection_active_ = still_active;
}
/**
* \brief Stop pipeline collection on only those
* CollectableTreeNodes that this PipelineCollector
* was started with
*/
void stopCollection() {
for(auto & col : registered_collectables_) {
col->stopCollecting(this);
}
registered_collectables_.clear();
}
/**
* \brief Add the CollectableTreeNode to auto collection
* \param ctn The CollectableTreeNode that is to be collected
* \param collection_phase The phase to collect the object in
*
* Enable collection on the given CollectableTreeNode. This
* is a runtime call. There are some rules here:
*
* #. The Scheduler must be finialized and simulation started
* #. The clock that the CollectableTreeNode belongs to must
* have been registered with the PipelineCollector at init time.
*/
void addToAutoCollection(CollectableTreeNode * ctn,
SchedulingPhase collection_phase = SchedulingPhase::Tick)
{
auto ccm_pair = clock_ctn_map_.find(ctn->getClock());
sparta_assert(ccm_pair != clock_ctn_map_.end());
ccm_pair->second[static_cast<uint32_t>(collection_phase)]->enable(ctn);
}
/**
* \brief Remove the given CollectableTreeNode from collection
* \param ctn The CollectableTreeNode that is to be removed from collection
*
* Disable collection on the given CollectableTreeNode. This
* is a runtime call. There are some rules here:
*
* #. The Scheduler must be finialized and simulation started
* #. The clock that the CollectableTreeNode belongs to must
* have been registered with the PipelineCollector at init time.
*/
void removeFromAutoCollection(CollectableTreeNode * ctn)
{
auto ccm_pair = clock_ctn_map_.find(ctn->getClock());
sparta_assert(ccm_pair != clock_ctn_map_.end());
for(auto & u_p : ccm_pair->second) {
u_p->disable(ctn);
}
}
/**
* \brief Return a unique transaction id using a dummy counter
*/
uint64_t getUniqueTransactionId()
{
// make sure we are not going to overflow our int,
// if we did overflow our id's are no longer unique!
sparta_assert(last_transaction_id_ < (~(uint64_t)0));
return ++last_transaction_id_;
}
/**
* \brief Output a finized transaction to our Outputter class.
* \param dat The transaction to be outputted.
* \param R_Type the type of transaction struct
*/
template<class R_Type>
void writeRecord(const R_Type& dat)
{
sparta_assert(collection_active_, "The pipeline head must be running in order to write a transaction");
// Make sure it's within the heartbeat window
sparta_assert(dat.time_End <= (last_heartbeat_ + heartbeat_interval_));
sparta_assert(dat.time_Start >= last_heartbeat_);
// Make sure transactions are exclusive.
// transaction [4999-5000] should be written BEFORE the index is written for transactions
// starting at 5000
sparta_assert(closing_time_ < heartbeat_interval_ // Ignore first heartbeat
|| dat.time_Start >= closing_time_ - heartbeat_interval_,
"Attempted to write a pipeout record with exclusive start =("
<< dat.time_Start << "), less than closing of previous interval"
<< closing_time_ - heartbeat_interval_ );
// std::cout << "writing annt. " << "loc: " << dat.location_ID << " start: "
// << dat.time_Start << " end: " << dat.time_End
// << " parent: " << dat.parent_ID << std::endl;
writer_->writeTransaction<R_Type>(dat);
++transactions_written_;
}
/**
* \brief Return the number of transactions that this singleton
* has passed to it's output. This is useful for testing purposes.
*/
uint64_t numTransactionsWritten() const
{
return transactions_written_;
}
/**
* \brief Return true if the collector is actively collecting
*
* Will be true if there are any registered collectables that
* are being collected on any clock.
*
* \note This method should not be used to determine whether
* pipeline collection is running at a specific tree
* node location.
*/
bool isCollectionActive() const {
return collection_active_;
}
void printMap() {
//std::cout << "Printing Map Not Supported" << std::endl;
// for(auto & p : clock_ctn_map_) {
// std::cout << "\nClock : " << p.first->getName()
// << "\nAuto collectables: " << std::endl;
// p.second->print();
// }
}
//! \return the pipeout file path
const std::string & getFilePath() const {
return filepath_;
}
//! \return the scheduler for this collector
Scheduler* getScheduler() const {
return scheduler_;
}
private:
/**
* \brief Write the clock file based off of a pointer to the root clock,
* that was established in the parameters of startCollection
*/
void writeClockFile_()
{
// We only need the ClockFileWriter to exist during the writing of the clock file.
// there for it was created on the stack.
//std::cout << "Writing Pipeline Collection clock file. " << std::endl;
argos::ClockFileWriter clock_writer(filepath_);
clock_writer << (*root_clk_);
}
//! Perform a heartbeat on the collector. This is required to
//! enable the writing of an index file used by the pipeout
//! reader for fast access
void performHeartBeat_()
{
if(collection_active_) {
// Close all transactions
for(auto & ctn : registered_collectables_) {
if(ctn->isCollected()) {
ctn->restartRecord();
}
}
// write an index
writer_->writeIndex();
// Remember the last time we recorded a heartbeat
last_heartbeat_ = scheduler_->getCurrentTick();
// Schedule another heartbeat
ev_heartbeat_.schedule(heartbeat_interval_);
}
}
//! A pointer to the outputter class used for writing
//! transactions to physical disk.
std::unique_ptr<argos::Outputter> writer_;
//! A pointer to the root sparta TreeNode of the
//! simulation. Important for writing the location map file.
std::unique_ptr<argos::LocationFileWriter> location_writer_;
//sparta::TreeNode* collected_treenode_ = nullptr;
//! Pointer to the root clock. This clock is considered the
//! hyper-clock or the clock with the hypercycle
const sparta::Clock * root_clk_ = nullptr;
//! The filepath/prefix for writing pipeline collection files too
std::string filepath_;
//! Keep track of the last transaction id given to ensure that
//! each transaction is written with a unique id
uint64_t last_transaction_id_ = 0;
//! The number of transactions written to disk so far
uint64_t transactions_written_ = 0;
//! The number of ticks between heart beats. Also the offset
//! between index pointer writes in the Outputter
uint64_t heartbeat_interval_ = 0;
//! The last heartbeat we recorded
Scheduler::Tick last_heartbeat_ = 0;
//! Scheduler on which this collector operates
Scheduler * scheduler_;
//! Event and EventSet for performing heartbeats
EventSet collector_events_;
UniqueEvent<SchedulingPhase::Collection> ev_heartbeat_;
//! The time that the next heartbeat will occur
uint64_t closing_time_ = 0;
//! Is collection enabled on at least one node?
bool collection_active_ = false;
};
}// namespace collection
}// namespace sparta
//__PIPELINE_COLLECTOR_H__
#endif
| [
"klingaard@gmail.com"
] | klingaard@gmail.com |
f473ad9590c5a1f9157b104d29763148eead1944 | 3290af0c6ff6325b80b872b0849a5b5191cb4865 | /pj2/src/include/advection.h | 42af5ec24647600f2802f2df986837db4b540969 | [] | no_license | awesomejiang/HPC | 9191dd6ee3092cd41ecf8ca8c9e189467d5a766f | fc7862157da00ed8c60ca18d13e90e33bd5448c9 | refs/heads/master | 2020-03-09T14:41:03.348100 | 2018-06-07T07:53:55 | 2018-06-07T07:53:55 | 128,840,604 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,479 | h | #ifndef ADVECTION
#define ADVECTION
#include <vector>
#include <string>
template<typename T>
using line = std::vector<T>;
template<typename T>
using matrix = std::vector<line<T>>;
namespace advection{
class Advection_common{
public:
Advection_common(int N, int NT, double L, double T, double u, double v);
int N, NT;
double L, T, u, v, delta_x, delta_t;
matrix<double> curr_mx, next_mx;
//x0, y0 is left-up corner of matrix
virtual void init_gaussian(double sig_x, double sig_y, double x0, double y0) = 0;
virtual void run() = 0;
virtual void run(std::string file) = 0;
double update_value(int i, int j);
};
class Advection_serial: public Advection_common {
public:
Advection_serial(int N, int NT, double L, double T, double u, double v);
void init_gaussian(double sig_x, double sig_y, double x0, double y0) override;
void run() override;
void run(std::string file) override;
};
class Advection_threads: public Advection_common {
public:
Advection_threads(int N, int NT, double L, double T, double u, double v);
void init_gaussian(double sig_x, double sig_y, double x0, double y0) override;
void run() override;
void run(std::string file) override;
};
class Advection_mpi_blocking: public Advection_common {
public:
Advection_mpi_blocking(int N, int NT, double L, double T, double u, double v, int mype, int k);
void init_gaussian(double sig_x, double sig_y, double x0, double y0) override;
void run() override;
void run(std::string file) override;
int mype, k;
std::vector<std::vector<double>> ghost_cells; //0,1,2,3->up, right, down, left
double update_value(int i, int j);
void sync();
private:
void sync_up();
void sync_down();
void sync_left();
void sync_right();
};
class Advection_mpi_non_blocking: public Advection_mpi_blocking {
public:
Advection_mpi_non_blocking(int N, int NT, double L, double T, double u, double v, int mype, int k);
void sync();
};
class Advection_hybrid: public Advection_mpi_blocking {
public:
Advection_hybrid(int N, int NT, double L, double T, double u, double v, int mype, int k);
void init_gaussian(double sig_x, double sig_y, double x0, double y0) override;
void run() override;
void run(std::string file) override;
};
class Driver{
public:
Driver(int argc, char**argv);
void run();
private:
char **argv;
int argc, N, NT, thread;
double L, T, u, v;
std::string mode;
void serial();
void threads();
void mpi_blocking();
void mpi_non_blocking();
void hybrid();
};
}
#endif | [
"awesomejiang1995@gmail.com"
] | awesomejiang1995@gmail.com |
e70be52f20fc77805e44d330b6688c980e639c18 | 5a1d5388c134685bab23cc63652709254d3a9d4c | /FramePartition.cpp | 0e4562cdefd72e52763d894aee13c4c08428e7a5 | [] | no_license | kachan0627/SHORINJIKEMPO_Motion_Analysis_System | 1e6b201bc3e9bf8237ec131597663e908b689793 | 17ddb7f3741715f067c2de09538a2a1e8737b39b | refs/heads/main | 2023-08-30T10:24:51.897970 | 2021-11-17T13:48:28 | 2021-11-17T13:48:28 | 429,061,786 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 118 | cpp | #include "FramePartition.h"
FramePartition::FramePartition()
{
}
FramePartition::~FramePartition()
{
}
| [
"kachan.0627.619@gmail.com"
] | kachan.0627.619@gmail.com |
db740ae5d5b9558c73d4a292f5261e93c48d8cd1 | 948f4e13af6b3014582909cc6d762606f2a43365 | /testcases/juliet_test_suite/testcases/CWE680_Integer_Overflow_to_Buffer_Overflow/CWE680_Integer_Overflow_to_Buffer_Overflow__new_listen_socket_09.cpp | b169dc1266e8823ac70b9389361ec743a442bb9d | [] | 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 | 7,098 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE680_Integer_Overflow_to_Buffer_Overflow__new_listen_socket_09.cpp
Label Definition File: CWE680_Integer_Overflow_to_Buffer_Overflow__new.label.xml
Template File: sources-sink-09.tmpl.cpp
*/
/*
* @description
* CWE: 680 Integer Overflow to Buffer Overflow
* BadSource: listen_socket Read data using a listen socket (server side)
* GoodSource: Small number greater than zero that will not cause an integer overflow in the sink
* Sink:
* BadSink : Attempt to allocate array using length value from source
* Flow Variant: 09 Control flow: if(GLOBAL_CONST_TRUE) and if(GLOBAL_CONST_FALSE)
*
* */
#include "std_testcase.h"
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define LISTEN_BACKLOG 5
#define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2)
namespace CWE680_Integer_Overflow_to_Buffer_Overflow__new_listen_socket_09
{
#ifndef OMITBAD
void bad()
{
int data;
/* Initialize data */
data = -1;
if(GLOBAL_CONST_TRUE)
{
{
#ifdef _WIN32
WSADATA wsaData;
int wsaDataInit = 0;
#endif
int recvResult;
struct sockaddr_in service;
SOCKET listenSocket = INVALID_SOCKET;
SOCKET acceptSocket = INVALID_SOCKET;
char inputBuffer[CHAR_ARRAY_SIZE];
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
{
break;
}
wsaDataInit = 1;
#endif
/* POTENTIAL FLAW: Read data using a listen socket */
listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listenSocket == INVALID_SOCKET)
{
break;
}
memset(&service, 0, sizeof(service));
service.sin_family = AF_INET;
service.sin_addr.s_addr = INADDR_ANY;
service.sin_port = htons(TCP_PORT);
if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
{
break;
}
if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR)
{
break;
}
acceptSocket = accept(listenSocket, NULL, NULL);
if (acceptSocket == SOCKET_ERROR)
{
break;
}
/* Abort on error or the connection was closed */
recvResult = recv(acceptSocket, inputBuffer, CHAR_ARRAY_SIZE - 1, 0);
if (recvResult == SOCKET_ERROR || recvResult == 0)
{
break;
}
/* NUL-terminate the string */
inputBuffer[recvResult] = '\0';
/* Convert to int */
data = atoi(inputBuffer);
}
while (0);
if (listenSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(listenSocket);
}
if (acceptSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(acceptSocket);
}
#ifdef _WIN32
if (wsaDataInit)
{
WSACleanup();
}
#endif
}
}
{
size_t dataBytes,i;
int *intPointer;
/* POTENTIAL FLAW: dataBytes may overflow to a small value */
dataBytes = data * sizeof(int); /* sizeof array in bytes */
intPointer = (int*)new char[dataBytes];
for (i = 0; i < (size_t)data; i++)
{
intPointer[i] = 0; /* may write beyond limit of intPointer if integer overflow occured above */
}
printIntLine(intPointer[0]);
delete [] intPointer;
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the GLOBAL_CONST_TRUE to GLOBAL_CONST_FALSE */
static void goodG2B1()
{
int data;
/* Initialize data */
data = -1;
if(GLOBAL_CONST_FALSE)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Set data to a relatively small number greater than zero */
data = 20;
}
{
size_t dataBytes,i;
int *intPointer;
/* POTENTIAL FLAW: dataBytes may overflow to a small value */
dataBytes = data * sizeof(int); /* sizeof array in bytes */
intPointer = (int*)new char[dataBytes];
for (i = 0; i < (size_t)data; i++)
{
intPointer[i] = 0; /* may write beyond limit of intPointer if integer overflow occured above */
}
printIntLine(intPointer[0]);
delete [] intPointer;
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
int data;
/* Initialize data */
data = -1;
if(GLOBAL_CONST_TRUE)
{
/* FIX: Set data to a relatively small number greater than zero */
data = 20;
}
{
size_t dataBytes,i;
int *intPointer;
/* POTENTIAL FLAW: dataBytes may overflow to a small value */
dataBytes = data * sizeof(int); /* sizeof array in bytes */
intPointer = (int*)new char[dataBytes];
for (i = 0; i < (size_t)data; i++)
{
intPointer[i] = 0; /* may write beyond limit of intPointer if integer overflow occured above */
}
printIntLine(intPointer[0]);
delete [] intPointer;
}
}
void good()
{
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 CWE680_Integer_Overflow_to_Buffer_Overflow__new_listen_socket_09; /* 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 |
21c749e6d69d67430622cb8cc4c4c7b512925cb6 | 66b680ade6dce8bd79925d6b69064ea52202f7a9 | /uss/src/daemon/uss_scheduler.h | 8ddc75b868dea5c958d3f780ad405929b7737d7a | [] | no_license | tobib/hetsched | 8c177341ddc26afc10ffe3b501f26a1f69bba766 | b3d17cab5b31279285a429b312771df9ae0989d0 | refs/heads/master | 2020-04-15T17:05:47.005652 | 2011-11-28T16:11:34 | 2011-11-28T16:11:34 | 2,868,169 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,350 | h | #ifndef SCHEDULER_H_INCLUDED
#define SCHEDULER_H_INCLUDED
#include "./uss_daemon.h"
#include "./uss_comm_controller.h"
#include "./uss_registration_controller.h"
#include "../library/uss.h"
/***************************************\
* se *
\***************************************/
/*
* this scheduling entity (se) holds all relevant infos for a handle
*/
class uss_se
{
public:
uss_se(int handle, struct meta_sched_addr_info masi);
~uss_se();
//basic
int handle;
int execution_mode; //=accelerator_type
int next_execution_mode; //set when sending an RUN_ON mess to this (can be updated when cleanup mess arrives)
int already_send_free_cpu; //each handle can be in CPU-mode independant of run queues (=>save in SE)
//which rq is this handle loaded into (can be -1 if it is nowhere)
int enqueued_in_mq; //=accelerator_type
int enqueued_in_rq; //=accelerator_index
class uss_nanotime rruntime; //=real runtime that is independent of priorities
class uss_nanotime vruntime; //=virtual runtime considering priorities
class uss_nanotime min_granularity;
int is_finished;
struct meta_sched_addr_info msai;
//additional
pid_t corresponding_process;
int progress_counter;
};
/*
* this holds all scheduling entities (se)
*
* int: the unique handle
* struct uss_se: entry
*/
typedef map<int, struct uss_se, less<int> > uss_se_table;
typedef uss_se_table::iterator uss_se_table_iterator;
/***************************************\
* rq *
\***************************************/
struct uss_rq_tree_entry
{
uss_nanotime vruntime;
int handle;
uss_rq_tree_entry(uss_nanotime t, int h)
{
vruntime = t;
handle = h;
}
bool operator==(const uss_rq_tree_entry& other) const
{
return (this->vruntime == other.vruntime && this->handle == other.handle);
}
bool operator< (const struct uss_rq_tree_entry& other) const
{
return (this->vruntime < other.vruntime || (this->vruntime == other.vruntime && this->handle < other.handle));
}
};
/*
* this holds vruntime as index and the corresponding
* handle as index
*/
typedef set<uss_rq_tree_entry, less<uss_rq_tree_entry> > uss_rq_tree;
typedef uss_rq_tree::iterator uss_rq_tree_iterator;
/*
* this is data struct for remembering the handle that is really running
* and stores everything related to message passing
*/
class uss_curr_state
{
public:
//basic
int handle;
//time
/*
*this is the time when handle became current or the last
*point in time and update_curr has been performed
*/
class uss_nanotime exec_start;
//advanced
int marked_runon_idle;
int already_send_message;
uss_curr_state();
~uss_curr_state();
};
/*
* this is the main data structure in scheduler
*/
class uss_rq
{
public:
pthread_mutex_t tree_mutex;
uss_rq(int, int);
~uss_rq();
//rq identification
int accelerator_type;
int accelerator_index;
//curr information
uss_curr_state curr;
uss_nanotime min_vruntime;
//list
uss_rq_tree tree;
int length;
};
/*
* for each supported accelerator type there may be a runqueue in map
*
* COMMENT:
* it is not recommended to use this for IDLE and CPU, since they don't
* have to be sorted or must maintain a "current element"
*/
typedef map<int, uss_rq, less<int> > uss_rq_list;
typedef uss_rq_list::iterator uss_rq_list_iterator;
struct uss_affinity_list_entry
{
int affinity;
int handle;
uss_affinity_list_entry(int a, int h)
{
affinity = a;
handle = h;
}
bool operator==(const uss_affinity_list_entry& other) const
{
return (this->affinity == other.affinity && this->handle == other.handle);
}
bool operator< (const struct uss_affinity_list_entry& other) const
{
return (this->affinity < other.affinity || (this->affinity == other.affinity && this->handle < other.handle));
}
bool operator> (const struct uss_affinity_list_entry& other) const
{
return (this->affinity > other.affinity || (this->affinity == other.affinity && this->handle > other.handle));
}
};
typedef set<uss_affinity_list_entry, less<uss_affinity_list_entry> > uss_affinity_list_asc;
typedef uss_affinity_list_asc::iterator uss_affinity_list_asc_iterator;
typedef set<uss_affinity_list_entry, greater<uss_affinity_list_entry> > uss_affinity_list_des;
typedef uss_affinity_list_des::iterator uss_affinity_list_des_iterator;
class uss_mq
{
public:
uss_mq(int);
~uss_mq();
//mq info
int accelerator_type;
int nof_rq;
int nof_all_handles;
double centerpoint;
//data structures to speed up load balancing
uss_affinity_list_asc best_to_push; //[affinity,handle]
uss_affinity_list_des best_to_pull; //[affinity,handle]
//the runqueues
uss_rq_list list;
};
typedef map<int, uss_mq, less<int> > uss_rq_matrix;
typedef uss_rq_matrix::iterator uss_rq_matrix_iterator;
/*
* the CPU is special -> it has a unique rq with methods that do signaling
*/
class uss_urq
{
public:
int accelerator_type;
int accelerator_index;
uss_urq();
uss_urq(int, int);
~uss_urq();
//list
set<int> tree;
};
struct uss_push_curve
{
int min_push_affinity[USS_MAX_PUSH_CURVE_LEN];
};
/***************************************\
* scheduler *
\***************************************/
class uss_scheduler
{
private:
pthread_t quick_dispatcher_thread;
int bluemode, status;
#if(USS_SYSLOAD_FROM_PROC == 1)
int sysload_proc_fd;
#endif
double sysload_current;
public:
//tables
uss_se_table se_table;
uss_urq rq_idle;
uss_urq rq_cpu;
uss_rq_matrix rq_matrix;
//removal helper
set<int> tokill_list;
pthread_mutex_t kill_mutex;
pthread_mutex_t se_mutex;
//clock
uss_nanotime clock;
//config paramters
long min_granularity[USS_NOF_SUPPORTED_ACCEL]; //value in micro seconds
uss_push_curve *push_curve[USS_NOF_SUPPORTED_ACCEL];
//controller
uss_comm_controller *cc;
uss_registration_controller *rc;
uss_scheduler(uss_comm_controller*, uss_registration_controller*);
~uss_scheduler();
//helper
int is_accelerator_type_active(int accel_type);
uss_rq* get_rq_of_handle(int handle);
uss_mq* get_mq_of_handle(int handle);
uss_se* get_se_of_handle(int handle);
int get_affinity_of_handle(int handle, int target_accelerator);
//print functions
void print_rq(int type, int index);
void print_rq(uss_rq *rq);
void print_mq(int type);
void print_mq(uss_mq *mq);
void print_queues();
//rq management
int create_rq(int type, int index);
int delete_rq(int type, int index);
//insert and remove from rq
int insert_to_rq(struct uss_rq *rq, int handle);
int remove_from_rq(struct uss_rq *rq, int handle);
int check_handle_notsingle_notrunning(uss_rq *source_rq, int handle);
int move_to_rq(int source_handle,
class uss_mq *target_mq, class uss_rq *target_rq,
class uss_mq *source_mq, class uss_rq *source_rq);
//insert and remove from mq
int get_best_rq_of_mq(class uss_mq *mq);
int insert_to_mq(struct uss_mq *mq, int handle);
int insert_to_mq(struct uss_mq *mq, int handle, int index);
int remove_from_mq(struct uss_mq *mq, int handle);
//insert and remove from special queues
int insert_to_rq_idle(int handle);
int remove_from_rq_idle(int handle);
int insert_to_rq_cpu(int handle);
int remove_from_rq_cpu(int handle);
//time keeping
void update_time();
void update_sysload();
//LONG TERM
//add and remove a complete job from entire sched
int add_job(int handle, struct meta_sched_addr_info msai);
int remove_job(int handle);
//remover called by daemon thread
void remove_finished_jobs();
//MID TERM
//mid term functions
void update_runtime(uss_rq *rq, uss_se *current_se);
void update_curr(uss_rq *rq);
void periodic_tick();
int get_value_from_push_curve(struct uss_push_curve *pc, int x);
void load_balancing();
//SHORT TERM
//quick response functions
void handle_cleanup(int handle, int is_finished);
void pick_next(struct uss_message m);
int handle_message(struct uss_address a, struct uss_message m);
};
//SHORT TERM
//quick scheduling thread
void* quick_dispatcher(void* ptr);
#endif
| [
"tbeisel@uni-paderborn.de"
] | tbeisel@uni-paderborn.de |
b1f0d8548ec503f4d10e51bb133aab1abc2d557b | d3667abebe6446853814f8a993b81fdb494f18a7 | /model/object.cpp | a12e9ccca7a102f91481087618ef6001b04086e4 | [] | no_license | Pitora/ProgrammaP2 | a6b67bb7cbcf7999b7e16bdb8456d48263f10ab9 | 03da4f2289c54789efc472f4d789e02e1e3d64b9 | refs/heads/main | 2023-08-14T10:29:20.900546 | 2021-09-23T09:22:13 | 2021-09-23T09:22:13 | 370,415,734 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,145 | cpp | #include "object.h"
Obj::Obj(){}
Obj::Obj(int i, std::string n) : id(i), name(n) {}
Obj::Obj(std::string imported){
if (sm::checkKW(imported, "<Obj>", "</Obj>"))
{
id = stoi(sm::substring(imported, "<Id>", "</Id>"));
name = sm::substring(imported, "<Name>", "</Name>");
}
else throw err_import();
}
Obj::~Obj() {
//std::cout<<"Distruttore virtuale puro chiamato"<<std::endl;
}
bool Obj::operator== (const Obj& x) const {return id == x.id;}
std::ostream& operator<<(std::ostream& s, const Obj& o) {
o.print(s);
return s;
}
std::string Obj::exp() const{ //Esempio di export?
std::string s = "<Obj>";
s += "<Id>" + std::to_string(id) + "</Id>";
s += "<Name>" + name + "</Name>";
s += "</Obj>";
return s;
}
void Obj::print(std::ostream& os) const {os<<"Id : "<<(*this).id<<" Nome : "<<(*this).name<<std::endl;}
std::string Obj::getInfo() const{
return "Id : " + std::to_string(id) + "\n" + "Nome : " + name + "\n";
}
int Obj::getId() const {return id;}
std::string Obj::getName() const {return name;}
| [
"pietro.villatora@gmail.com"
] | pietro.villatora@gmail.com |
e1b35823d6f2844266fc8605e6cd9cec9c9d68b4 | 654214efc22abf0f068ae4850a92202527f5d654 | /FlashEmitter.h | 2ea85b3a5fd9e92fa2a09c5d4c8f5a9e9d57420c | [] | no_license | noodlehair/ParticleSystem | 0d53c2a0f525c606250769512396f3cc5cd5bf3d | ab1f9b04e7f2a577f44ed5431ed30c5ce9772151 | refs/heads/master | 2021-01-22T13:42:09.716927 | 2013-12-14T00:09:39 | 2013-12-14T00:09:39 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 501 | h | #include "LocalGraphicsLib.h"
#include "ImageIO.h"
#include <glut.h>
#define MAX_FLASH_PARTICLES 2
using namespace std;
class FlashEmitter{
public:
FlashEmitter(const char* file_name);
~FlashEmitter(void);
void flashEmitterInit();
void flashEmitterDisplay();
ImageIO* image;
float slowdown;
float zoom;
GLuint loop;
GLuint col;
GLuint delay;
GLuint texture[1];
float dx;
float dy;
float const_adder;
bool initFlag;
particles *flash_particle[MAX_FLASH_PARTICLES]; // Particle Array
}; | [
"lanceton_dsouza@yahoo.co.in"
] | lanceton_dsouza@yahoo.co.in |
93e56315beadda350422534a83df0b423aab1dd5 | 435849051862b284b71c4517bf0695d41c217cd1 | /1.cpp | e41407dda47c2e488f0a86bb68cb663325e4549c | [] | no_license | iambramhaa/Aryalashok | 7afc49fe21dc65c3f7c3b88ab365796ff851a3f3 | 802a645acb42de05da4d1d088c1860c6fb9dffb9 | refs/heads/main | 2023-06-26T04:34:59.144585 | 2023-06-09T05:59:24 | 2023-06-09T05:59:24 | 379,574,076 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 573 | cpp | #include <iostream>
using namespace std;
class Multiply
{
double Number1, Number2;
public:
void getData(void);
void dataProduct(void);
};
inline void Multiply ::getData(void)
{
cout << "Enter The First Number: ";
cin >> Number1;
cout << "Enter The Second Number: ";
cin >> Number2;
}
inline void Multiply ::dataProduct(void)
{
double mul;
mul = Number1 * Number2;
cout << "The Product or Multiple of two Number is: " << mul;
}
int main()
{
Multiply integer;
integer.getData();
integer.dataProduct();
return 0;
} | [
"iamashokaryal@gmail.com"
] | iamashokaryal@gmail.com |
1c4cff656a798fb884f26f52b216da08abd312d7 | 785df77400157c058a934069298568e47950e40b | /Common/Foam/include/base/uint32.hxx | 1372bea321b657cbd9f0c6f8310929498bedc94b | [] | no_license | amir5200fx/Tonb | cb108de09bf59c5c7e139435e0be008a888d99d5 | ed679923dc4b2e69b12ffe621fc5a6c8e3652465 | refs/heads/master | 2023-08-31T08:59:00.366903 | 2023-08-31T07:42:24 | 2023-08-31T07:42:24 | 230,028,961 | 9 | 3 | null | 2023-07-20T16:53:31 | 2019-12-25T02:29:32 | C++ | UTF-8 | C++ | false | false | 3,498 | hxx | #pragma once
#ifndef _uint32_Header
#define _uint32_Header
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2014-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Primitive
uint32
Description
32bit uinteger
SourceFiles
uint32.C
uint32IO.C
\*---------------------------------------------------------------------------*/
#include <cstdint>
#include <climits>
#include <cstdlib>
#include <word.hxx>
#include <pTraits.hxx>
#include <direction.hxx>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace tnbLib
{
class Istream;
class Ostream;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Return a word representation of an uint32
FoamBase_EXPORT word name(const uint32_t);
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
FoamBase_EXPORT uint32_t readUint32(Istream&);
FoamBase_EXPORT bool read(const char*, uint32_t&);
FoamBase_EXPORT Istream& operator>>(Istream&, uint32_t&);
FoamBase_EXPORT Ostream& operator<<(Ostream&, const uint32_t);
//- Template specialization for pTraits<uint32_t>
template<>
class pTraits<uint32_t>
{
uint32_t p_;
public:
//- Component type
typedef uint32_t cmptType;
// Member constants
//- Dimensionality of space
static FoamBase_EXPORT const direction dim = 3;
//- Rank of uint32_t is 0
static FoamBase_EXPORT const direction rank = 0;
//- Number of components in uint32_t is 1
static FoamBase_EXPORT const direction nComponents = 1;
// Static Data Members
static FoamBase_EXPORT const char* const typeName;
static FoamBase_EXPORT const char* const componentNames[];
static FoamBase_EXPORT const uint32_t zero;
static FoamBase_EXPORT const uint32_t one;
static FoamBase_EXPORT const uint32_t min;
static FoamBase_EXPORT const uint32_t max;
static FoamBase_EXPORT const uint32_t rootMax;
static FoamBase_EXPORT const uint32_t rootMin;
// Constructors
//- Construct from primitive
FoamBase_EXPORT explicit pTraits(const uint32_t&);
//- Construct from Istream
FoamBase_EXPORT pTraits(Istream&);
// Member Functions
//- Access to the uint32_t value
operator uint32_t() const
{
return p_;
}
//- Access to the uint32_t value
operator uint32_t&()
{
return p_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace tnbLib
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif // !_uint32_Header
| [
"aasoleimani86@gmail.com"
] | aasoleimani86@gmail.com |
c44f3b073c96d4a1db0f3ceed9ea46927cb5b849 | d1b5f98de3d6587c6f15e30d231dd524c05f6427 | /lab5(main)/lab5(main)/EmployeeLaboratory.h | d45ca0cb1cc1e0e5878a2feeb81fe087bc6948a2 | [] | no_license | andrei7a/lab5 | 6967fb0a9e662872d394b4d57527f3318d9bd43c | 87fbd246d1c87993e081dbb6c27c207303472279 | refs/heads/master | 2021-01-10T14:30:23.660545 | 2015-10-22T22:30:45 | 2015-10-22T22:30:45 | 44,750,521 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 351 | h | #pragma once
#include "Laboratory.h"
#include "PrintConsole.h"
class EmployeeLaboratory:public Laboratory
{
public:
EmployeeLaboratory(char*, int, bool);
EmployeeLaboratory(char*, bool);
char* getDiscipline(void);
void setDiscipline(char*);
bool getProtection(void);
void setPoint(int);
int getPoint(void);
void add();
static void show();
};
| [
"andrei7a@mail.ru"
] | andrei7a@mail.ru |
54af81dd86e7643f60878411f230740a4f233568 | f36a3030e822b3f1881d6e43197f2b4d504e8b36 | /master_include.hpp | a5ea6c2bb600cac66ccc50252a9039624830e348 | [] | no_license | cvgeorge/Quack-Compiler | 1c042adf3ad98792bb53f79399d829f955082904 | 06d60777f11460e7a83adadba540bbad51b12953 | refs/heads/master | 2021-01-19T06:29:20.180203 | 2017-04-06T19:14:38 | 2017-04-06T19:14:38 | 87,465,362 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 362 | hpp | #ifndef __MASTER_INCLUDE_H__
#define __MASTER_INCLUDE_H__
#include <algorithm>
#include <curses.h>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <map>
#include <pthread.h>
#include <typeinfo>
#include <unistd.h>
#include <vector>
#include <string>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#endif
| [
"cgeorge@cs.uoregon.edu"
] | cgeorge@cs.uoregon.edu |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.