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 986
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145
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 122
values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f95c3d775d9975781ea671d0d0bc8b7a6a5aa7d9 | 6d7f43d0c778715a07ef9b96820ee58525364f77 | /Client/KuberaClient/FBX/GFBXMesh.h | 9b0a75f3ba5449db849f286a01ab69e1cab1cbd0 | [] | no_license | shootan/kubera | 682fc3a606e500a81971a57859e11228771bce0a | 49d8d7e54d70181530bf4a88c493ece08a2d0ed1 | refs/heads/master | 2021-01-18T15:08:54.382606 | 2015-10-05T04:32:23 | 2015-10-05T04:32:23 | 29,336,906 | 2 | 1 | null | 2015-01-16T07:41:25 | 2015-01-16T07:03:05 | C++ | UTF-8 | C++ | false | false | 2,098 | h | #pragma once
#include "GFBXSkeleton.h"
#include <vector>
#include "../Mesh.h"
#define MAX_BONE_MATRICES 70
namespace GFBX {
struct Vertex
{
Vertex() {
indices[0] = indices[1] = indices[2] = indices[3] = 0;
weights = D3DXVECTOR4(1,0,0,0);
}
D3DXVECTOR3 pos;
D3DXVECTOR3 norm;
D3DXVECTOR2 uv;
D3DXVECTOR3 tan;
D3DXVECTOR3 binorm;
BYTE indices[4];
D3DXVECTOR4 weights;
};
typedef std::vector<Vertex> VERTS;
typedef std::vector<DWORD> INDICES;
struct CBConstBoneWorld
{
D3DXMATRIX g_mConstBoneWorld[MAX_BONE_MATRICES];
};
class MeshSubset : public CMesh
{
public:
MeshSubset(ID3D11Device *pd3dDevice);
virtual ~MeshSubset();
HRESULT OnCreateDevice(ID3D11Device* pd3dDevice);
HRESULT CreateBuffers(ID3D11Device* pd3dDevice);
virtual void Render(ID3D11DeviceContext *pd3dDeviceContext);
virtual void CreateRasterizerState(ID3D11Device *pd3dDevice);
void ResetCULLNONECreateRasterizerState(ID3D11Device *pd3dDevice);
virtual void RenderInstanced(ID3D11DeviceContext *pd3dDeviceContext, int nInstances=0, int nStartInstance=0);
virtual bool LoadTexture(ID3D11Device* pd3dDevice, WCHAR* filename);
virtual void ReleaseTexture();
void SetUVTilling(int _tilenum);
CTextureclass* m_pTexture;
VERTS m_verts;
INDICES m_indices;
std::string m_texDiffuseName;
std::string m_texNormalName;
};
class Mesh
{
public:
Mesh();
virtual ~Mesh();
public:
HRESULT OnCreateDevice(ID3D11Device* pd3dDevice);
HRESULT Render(ID3D11DeviceContext* pd3dImmediateContext);
HRESULT Render(ID3D11DeviceContext* pd3dImmediateContext, float t);
void RenderInstanced(ID3D11DeviceContext *pd3dDeviceContext, int nInstances=0, int nStartInstance=0);
MeshSubset* CreateSubset(ID3D11Device* pd3dDevice);
int GetSubsetCount() { return m_Subsets.size(); }
MeshSubset* GetSubset(int nIdx) { return m_Subsets[nIdx]; }
std::vector<MeshSubset*> m_Subsets;
Skeleton m_Initialskeleton;
Skeleton m_Animationkeleton;
D3DXVECTOR3 m_vBoundingCenter;
float m_fBoundingRadius;
CBConstBoneWorld g_CBConstBoneWorld;
ID3D11Buffer* g_pCBConstBoneWorld;
};
};
| [
"fhemfltmxm@naver.com"
] | fhemfltmxm@naver.com |
6b091abc0198aeef93525ea77a021e932acb8e29 | 57ad4cc874b18ec29e2ecd1917c88f2a551b9a88 | /CAN_com/arduino/libraries/arduino-library-nine-axes-motion-master/examples/BareMinimum/BareMinimum.ino | b2665b7d46e8f11ef76d98d5b32eda1a507eb268 | [] | no_license | jeffykim/NJITSolarCarUI | fe12fe3ad70983a5842bf850e7b1e72b886e1fa4 | 5e81bae500f4948e9de29d6bbdbd30c558388bdf | refs/heads/master | 2018-12-26T23:43:43.573244 | 2018-10-22T21:23:28 | 2018-10-22T21:23:28 | 107,796,200 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 2,957 | ino | /****************************************************************************
* Copyright (C) 2011 - 2014 Bosch Sensortec GmbH
*
* BareMinimum.ino
* Date: 2014/08/25
* Revision: 2.1 $
*
* Usage: Example code to describe the Bare Minimum
*
****************************************************************************
/***************************************************************************
* License:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the copyright holder nor the names of the
* 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 COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
*
* The information provided is believed to be accurate and reliable.
* The copyright holder assumes no responsibility for the consequences of use
* of such information nor for any infringement of patents or
* other rights of third parties which may result from its use.
* No license is granted by implication or otherwise under any patent or
* patent rights of the copyright holder.
*/
#include "NineAxesMotion.h" //Contains the bridge code between the API and the Arduino Environment
#include <Wire.h>
NineAxesMotion mySensor; //Object that for the sensor
void setup() //This code is executed once
{
//Peripheral Initialization
I2C.begin(); //Initialize I2C communication to the let the library communicate with the sensor.
//Sensor Initialization
mySensor.initSensor(); //The I2C Address can be changed here inside this function in the library
mySensor.setOperationMode(OPERATION_MODE_NDOF); //Can be configured to other operation modes as desired
}
void loop() //This code is looped forever
{
//Blank
}
| [
"bduemmer1@gmail.com"
] | bduemmer1@gmail.com |
c14b6ff00d0cd42385835ef29425cdd8f12f3ca9 | 6c2a0b2b307779ce9cf62801c398453e83550015 | /Protocol/HTTP/HTTP.h | 5e3f5618159f02bb890d4b0445b77a5e860d2484 | [] | no_license | pbabics/Project-Ikaros | f11b8aa2600d090a2d0eced8dcac74c35837dcf6 | 1558fcd6662aec209d7e97c4ff6ef96af9832677 | refs/heads/master | 2021-05-27T21:36:07.095534 | 2012-05-12T16:28:01 | 2012-05-12T16:28:01 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,686 | h | #include "Includes.cpp"
#include "Adds.h"
#include "defines.h"
#include "ConfigMgr.cpp"
#ifdef __cplusplus
extern "C"
{
#endif
void processRecieve(in_addr /* address */, int fd, char* data);
void Init();
void InitStrings();
void InitErrorPages();
void LoadConfig();
class HTTPResponse
{
public:
static void SendErrorPage(Socket* socket, uint32 ErrorId);
static void SendDirectPage(Socket* socket, string file);
static void SendHeadPage(Socket* socket, string file);
static void KillSpartans(Socket* socket);
};
#ifdef __cplusplus
}
#endif
struct SeparateThreadedSendingData
{
SeparateThreadedSendingData(Socket* s, const char* d, size_t l): sock(s), data(d), length(l), dat(NULL), stream(NULL) { }
SeparateThreadedSendingData(Socket* s, BinnaryData* d): sock(s), data(NULL), length(0), dat(d), stream(NULL) { }
SeparateThreadedSendingData(Socket* s, stringstream* d): sock(s), data(NULL), length(0), dat(NULL), stream(d) { }
Socket* sock;
const char* data;
size_t length;
BinnaryData* dat;
stringstream* stream;
};
std::map<int, const char*> errorStrings;
std::map<int, const char*> errorPages;
ConfigMgr* configMgr;
SimpleLog* protoLog;
enum BoolConfigs
{
CONFIG_BOOL_ALLOW_DEFAULT_INDEX,
CONFIG_BOOL_DEBUG,
CONFIG_BOOL_CONTROL,
MAX_BOOL_CONFIGS
};
enum StringConfigs
{
CONFIG_STRING_DEFAULT_INDEX_FILE,
CONFIG_STRING_HOSTNAME,
CONFIG_STRING_ROOT_DIR,
MAX_STRING_CONFIGS
};
enum IntConfigs
{
CONFIG_INT_MAX_MAIN_THREAD_FILE_SIZE,
MAX_INT_CONFIGS
};
bool boolConfigs[MAX_BOOL_CONFIGS];
string stringConfigs[MAX_STRING_CONFIGS];
int intConfigs[MAX_STRING_CONFIGS];
| [
"NTX@zoznam.sk"
] | NTX@zoznam.sk |
c1f34982413ce3d02fe16a0a485c7ad601e19492 | 217b0029ff0df2a71e1de0197b34c72b5a6a7801 | /wiibalance_min/wiibalance_min.ino | 5f676e0768ca1ecff66d2e2986b560b6b7834e81 | [] | no_license | soiyadakara/ArduinoProjects | dc84b7516dd2049ba3f64c25a6de0b69cf0917dd | 898f01622a210dea653e6c0c9df1e5c687ad7b2e | refs/heads/master | 2021-07-13T13:14:56.383653 | 2020-09-10T15:32:20 | 2020-09-10T15:32:20 | 204,957,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,643 | ino | /*
wiibalance
created 2017/02
by JR2GEV
*/
#include "WiiBalanceBoard.h"
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
WiiBalanceBoard wbb;
#define LED_MAIN 16 //LOWで点灯
#define PWR_ON 14 //LOWでON
#define SW_SYNC 13
#define SW_MAIN 12
// wifi設定
String ssid = "ssid";
String pass = "pass";
String host = "script.google.com";
String url = "macros/nanyarakanyara/exec";
void setup() {
// 電源のFETをON
pinMode(PWR_ON, OUTPUT);
digitalWrite(PWR_ON, LOW);
pinMode(SW_SYNC, INPUT);
pinMode(SW_MAIN, INPUT);
pinMode(LED_MAIN, OUTPUT);
//Serialのinitialization
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
wbb.init();
digitalWrite(LED_MAIN, LOW);
delay(1000);
// wifiの挙動が怪しい場合があるので、切断しておく
WiFi.disconnect();
WiFi.mode(WIFI_STA);
}
void loop() {
float total;
float weights_buf[4];
wbb.getWeights(weights_buf);
total = (weights_buf[0] + weights_buf[1] + weights_buf[2] + weights_buf[3]) / 4;
Serial.println(String(total, 2));
for (byte i = 0; i < 4; i++) {
digitalWrite(LED_MAIN, HIGH);
delay(200);
digitalWrite(LED_MAIN, LOW);
delay(200);
}
// 測定値をPOST
postWeight(total);
// 終了
digitalWrite(PWR_ON, HIGH);
pinMode(PWR_ON, INPUT);
}
byte postWeight(float weight) {
Serial.println("SSID: " + ssid);
Serial.println("PASS: " + pass);
Serial.println(host + url);
WiFi.begin(ssid.c_str(), pass.c_str());
while (1) {
if (WiFi.status() == WL_CONNECTED) {
break;
}
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
WiFiClientSecure sslclient;
String params;
params = "key=rinpoyo&weight=" + String(weight, 2);
if (sslclient.connect(host.c_str(), 443) > 0) {
Serial.println("[HTTPS] POST... \n");
sslclient.println("POST " + url + " HTTP/1.1");
sslclient.println("Host: " + host);
sslclient.println("User-Agent: ESP8266/1.0");
sslclient.println("Connection: close");
sslclient.println("Content-Type: application/x-www-form-urlencoded;");
sslclient.print("Content-Length: ");
sslclient.println(params.length());
sslclient.println();
sslclient.println(params);
delay(10);
String response = sslclient.readString();
int bodypos = response.indexOf("\r\n");
Serial.println( response.substring(0, bodypos));
} else {
// HTTP client errors
Serial.println("[HTTPS] no connection or no HTTP server.");
}
}
| [
"soiyadakara@gmail.com"
] | soiyadakara@gmail.com |
fcbbebb87d94c4c85a18ea12cc14967a0b5881db | faacd0003e0c749daea18398b064e16363ea8340 | /3rdparty/phonon/globalconfig.cpp | 52339f06f35301b63da205b122b0d05cbbc0d30c | [] | no_license | yjfcool/lyxcar | 355f7a4df7e4f19fea733d2cd4fee968ffdf65af | 750be6c984de694d7c60b5a515c4eb02c3e8c723 | refs/heads/master | 2016-09-10T10:18:56.638922 | 2009-09-29T06:03:19 | 2009-09-29T06:03:19 | 42,575,701 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,781 | cpp | /* This file is part of the KDE project
Copyright (C) 2006-2008 Matthias Kretz <kretz@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), Trolltech ASA
(or its successors, if any) and the KDE Free Qt Foundation, which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library 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.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "globalconfig_p.h"
#include "factory_p.h"
#include "objectdescription.h"
#include "phonondefs_p.h"
#include "platformplugin.h"
#include "backendinterface.h"
#include "qsettingsgroup_p.h"
#include "phononnamespace_p.h"
#include <QtCore/QList>
#include <QtCore/QVariant>
QT_BEGIN_NAMESPACE
namespace Phonon
{
GlobalConfig::GlobalConfig() : m_config(QLatin1String("kde.org"), QLatin1String("libphonon"))
{
}
GlobalConfig::~GlobalConfig()
{
}
enum WhatToFilter {
FilterAdvancedDevices = 1,
FilterHardwareDevices = 2,
FilterUnavailableDevices = 4
};
static void filter(ObjectDescriptionType type, BackendInterface *backendIface, QList<int> *list, int whatToFilter)
{
QMutableListIterator<int> it(*list);
while (it.hasNext()) {
const QHash<QByteArray, QVariant> properties = backendIface->objectDescriptionProperties(type, it.next());
QVariant var;
if (whatToFilter & FilterAdvancedDevices) {
var = properties.value("isAdvanced");
if (var.isValid() && var.toBool()) {
it.remove();
continue;
}
}
if (whatToFilter & FilterHardwareDevices) {
var = properties.value("isHardwareDevice");
if (var.isValid() && var.toBool()) {
it.remove();
continue;
}
}
if (whatToFilter & FilterUnavailableDevices) {
var = properties.value("available");
if (var.isValid() && !var.toBool()) {
it.remove();
continue;
}
}
}
}
static QList<int> listSortedByConfig(const QSettingsGroup &backendConfig, Phonon::Category category, QList<int> &defaultList)
{
if (defaultList.size() <= 1) {
// nothing to sort
return defaultList;
} else {
// make entries unique
QSet<int> seen;
QMutableListIterator<int> it(defaultList);
while (it.hasNext()) {
if (seen.contains(it.next())) {
it.remove();
} else {
seen.insert(it.value());
}
}
}
QString categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(category));
if (!backendConfig.hasKey(categoryKey)) {
// no list in config for the given category
categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(Phonon::NoCategory));
if (!backendConfig.hasKey(categoryKey)) {
// no list in config for NoCategory
return defaultList;
}
}
//Now the list from m_config
QList<int> deviceList = backendConfig.value(categoryKey, QList<int>());
//if there are devices in m_config that the backend doesn't report, remove them from the list
QMutableListIterator<int> i(deviceList);
while (i.hasNext()) {
if (0 == defaultList.removeAll(i.next())) {
i.remove();
}
}
//if the backend reports more devices that are not in m_config append them to the list
deviceList += defaultList;
return deviceList;
}
QList<int> GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int override) const
{
//The devices need to be stored independently for every backend
const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioOutputDevice")); // + Factory::identifier());
const QSettingsGroup generalGroup(&m_config, QLatin1String("General"));
const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings)
? generalGroup.value(QLatin1String("HideAdvancedDevices"), true)
: static_cast<bool>(override & HideAdvancedDevices));
QList<int> defaultList;
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
// the platform plugin lists the audio devices for the platform
// this list already is in default order (as defined by the platform plugin)
defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
if (hideAdvancedDevices) {
QMutableListIterator<int> it(defaultList);
while (it.hasNext()) {
AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next());
const QVariant var = objDesc.property("isAdvanced");
if (var.isValid() && var.toBool()) {
it.remove();
}
}
}
}
#endif //QT_NO_PHONON_PLATFORMPLUGIN
// lookup the available devices directly from the backend (mostly for virtual devices)
if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend())) {
// this list already is in default order (as defined by the backend)
QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
filter(AudioOutputDeviceType, backendIface, &list,
(hideAdvancedDevices ? FilterAdvancedDevices : 0)
// the platform plugin already provided the hardware devices
| (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
| ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
);
}
defaultList += list;
}
return listSortedByConfig(backendConfig, category, defaultList);
}
int GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override) const
{
QList<int> ret = audioOutputDeviceListFor(category, override);
if (ret.isEmpty())
return -1;
return ret.first();
}
#ifndef QT_NO_PHONON_AUDIOCAPTURE
QList<int> GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, int override) const
{
//The devices need to be stored independently for every backend
const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier());
const QSettingsGroup generalGroup(&m_config, QLatin1String("General"));
const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings)
? generalGroup.value(QLatin1String("HideAdvancedDevices"), true)
: static_cast<bool>(override & HideAdvancedDevices));
QList<int> defaultList;
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
// the platform plugin lists the audio devices for the platform
// this list already is in default order (as defined by the platform plugin)
defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
if (hideAdvancedDevices) {
QMutableListIterator<int> it(defaultList);
while (it.hasNext()) {
AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next());
const QVariant var = objDesc.property("isAdvanced");
if (var.isValid() && var.toBool()) {
it.remove();
}
}
}
}
#endif //QT_NO_PHONON_PLATFORMPLUGIN
// lookup the available devices directly from the backend (mostly for virtual devices)
if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend())) {
// this list already is in default order (as defined by the backend)
QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
filter(AudioCaptureDeviceType, backendIface, &list,
(hideAdvancedDevices ? FilterAdvancedDevices : 0)
// the platform plugin already provided the hardware devices
| (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
| ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
);
}
defaultList += list;
}
return listSortedByConfig(backendConfig, category, defaultList);
}
int GlobalConfig::audioCaptureDeviceFor(Phonon::Category category, int override) const
{
QList<int> ret = audioCaptureDeviceListFor(category, override);
if (ret.isEmpty())
return -1;
return ret.first();
}
#endif //QT_NO_PHONON_AUDIOCAPTURE
} // namespace Phonon
QT_END_NAMESPACE
| [
"futurelink.vl@9e60f810-e830-11dd-9b7c-bbba4c9295f9"
] | futurelink.vl@9e60f810-e830-11dd-9b7c-bbba4c9295f9 |
90822340538cb193610dcff922819b898bb1970d | 51985c9b23723019995d1fc595cbc9b8f6d669e4 | /Project2/Project2/GameL/Draw2DTex_Source.cpp | 63c104b6e3391bcfe1e2d417a7fd62cf1a029b6e | [] | no_license | mamesensya/mamesennsya | d924a6c6f33accbe86320cd5311498541dbbb56a | 5060b5a8ba227478abc633c7dbbdbd53e8bee471 | refs/heads/main | 2023-03-08T15:00:28.302699 | 2020-12-10T07:59:39 | 2020-12-10T07:59:39 | 305,953,704 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,006 | cpp | const char* g_hlsl_str =
{
"struct vertexIn "
"{ "
" float4 pos : POSITION; "
" unsigned int2 uv : TEXCOORD; "
"}; "
" "
"struct vertexOut "
"{ "
" float4 pos : SV_POSITION; "
" float2 uv : TEXCOORD0; "
"}; "
" "
" "
"Texture2D txDiffuse : register(t0); "
"SamplerState samLinear : register(s0); "
" "
" "
"cbuffer global "
"{ "
" float4 size; "
" float4 color; "
" float4 rect_in; "
" float4 rect_out; "
" float4 rotation; "
"}; "
" "
"vertexOut vs(vertexIn IN) "
"{ "
" vertexOut OUT; "
" float x = size.z; "
" float y = size.w; "
" float r = 3.14f / 180.0f*rotation.x; "
" float t = ((rect_out.z - rect_out.x) / size.z)*2.0f; "
" float d = (-(rect_out.w - rect_out.y) / size.w)*2.0f; "
" "
" float2 pos; "
" pos.x = IN.pos.x - 0.5f; "
" pos.y = IN.pos.y - 0.5f; "
" pos.x *= -(rect_out.x - rect_out.z)*2.0f / size.z; "
" pos.y *= -(rect_out.y - rect_out.w)*2.0f / size.w; "
" "
" "
" float2 r_pos; "
" r_pos.x = pos.x*cos(-r) - pos.y*sin(-r)* (y / x); "
" r_pos.y = pos.y*cos(-r) + pos.x*sin(-r)* (x / y); "
" "
" "
" float2 s_pos; "
" s_pos.x = r_pos.x - 0.5f * (rect_out.x - rect_out.z)*2.0f / size.z; "
" s_pos.y = r_pos.y - 0.5f * (rect_out.y - rect_out.w)*2.0f / size.w; "
" "
" "
" float2 t_pos; "
" t_pos.x = s_pos.x - 1.0f + (rect_out.x*2.0f / x); "
" t_pos.y = -s_pos.y + 1.0f + (-rect_out.y*2.0f / y); "
" "
" "
" float f[4] = { rect_in.x / size.x , rect_in.z / size.x , rect_in.y / size.y , rect_in.w / size.y }; "
" float2 uv = (float2)0.0f; "
" uv.x = f[IN.uv.x]; "
" uv.y = f[IN.uv.y]; "
" "
" OUT.pos = IN.pos; "
" OUT.pos.xy = t_pos.xy; "
" OUT.uv = uv; "
" return OUT; "
"} "
" "
"float4 ps(vertexOut IN) : SV_Target "
"{ "
" float4 col = (float4)0.0f; "
" float4 tex = (float4)0.0f; "
" "
" if(size.x == 0.0f) "
" { "
" col = color; "
" } "
" else "
" { "
" tex = txDiffuse.Sample(samLinear, IN.uv); "
" col = tex*color; "
" } "
" return col; "
"} "
};
| [
"noreply@github.com"
] | mamesensya.noreply@github.com |
e0cecbc95580b6156143d1fd0dfa7d99fd9c19b3 | 2cc7dd012ec7bf03384c5ad0935424f96a21ca86 | /android-auto-9-notes/hwbinder/android.hardware.keymaster@3.0-service/service_note.cpp | e48cf642c6cc029563bc2051de2c1aa8f06c2062 | [] | no_license | clear39/notes | 058b4dfb40268747d9cf3456ea71fe88606b8bfb | 013211969abfc1be8de85f4766a0826d9a66b344 | refs/heads/master | 2021-06-06T22:00:06.503892 | 2021-06-06T15:53:10 | 2021-06-06T15:53:10 | 149,075,176 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,074 | cpp |
// @/work/workcodes/aosp-p9.x-auto-alpha/hardware/interfaces/keymaster/3.0/default/android.hardware.keymaster@3.0-service.rc
service vendor.keymaster-3-0 /vendor/bin/hw/android.hardware.keymaster@3.0-service
class early_hal
user system
group system drmrpc
// @/work/workcodes/aosp-p9.x-auto-alpha/hardware/interfaces/keymaster/3.0/default/service.cpp
int main() {
return defaultPassthroughServiceImplementation<IKeymasterDevice>();
}
// @/work/workcodes/aosp-p9.x-auto-alpha/hardware/interfaces/keymaster/3.0/default/KeymasterDevice.cpp
IKeymasterDevice* HIDL_FETCH_IKeymasterDevice(const char* name) {
ALOGI("Fetching keymaster device name %s", name);
if (name && strcmp(name, "softwareonly") == 0) {
return ::keymaster::ng::CreateKeymasterDevice();
} else if (name && strcmp(name, "default") == 0) {//默认 name = "default"
return createKeymaster3Device();
}
return nullptr;
}
static IKeymasterDevice* createKeymaster3Device() {
const hw_module_t* mod = nullptr;
int rc = hw_get_module_by_class(KEYSTORE_HARDWARE_MODULE_ID, NULL, &mod);
if (rc) {
ALOGI("Could not find any keystore module, using software-only implementation.");
// SoftKeymasterDevice will be deleted by keymaster_device_release()
return ::keymaster::ng::CreateKeymasterDevice();
}
// @hardware/libhardware/include/hardware/keymaster_common.h:54:#define KEYMASTER_MODULE_API_VERSION_1_0 HARDWARE_MODULE_API_VERSION(1, 0)
if (mod->module_api_version < KEYMASTER_MODULE_API_VERSION_1_0) {
keymaster0_device_t* dev = nullptr;
if (get_keymaster0_dev(&dev, mod)) {
return nullptr;
}
return ::keymaster::ng::CreateKeymasterDevice(dev);
} else if (mod->module_api_version == KEYMASTER_MODULE_API_VERSION_1_0) { //执行这里
keymaster1_device_t* dev = nullptr;
if (get_keymaster1_dev(&dev, mod)) {
return nullptr;
}
return ::keymaster::ng::CreateKeymasterDevice(dev);
} else {
keymaster2_device_t* dev = nullptr;
if (get_keymaster2_dev(&dev, mod)) {
return nullptr;
}
return ::keymaster::ng::CreateKeymasterDevice(dev);
}
}
static int get_keymaster1_dev(keymaster1_device_t** dev, const hw_module_t* mod) {
// @/work/workcodes/aosp-p9.x-auto-alpha/hardware/libhardware/include/hardware/keymaster1.h
int rc = keymaster1_open(mod, dev);
if (rc) {
ALOGE("Error %d opening keystore keymaster1 device", rc);
if (*dev) {
(*dev)->common.close(&(*dev)->common);
*dev = nullptr;
}
}
return rc;
}
// @/work/workcodes/aosp-p9.x-auto-alpha/hardware/libhardware/include/hardware/keymaster1.h
static inline int keymaster1_open(const struct hw_module_t* module, keymaster1_device_t** device) {
return module->methods->open(module, KEYSTORE_KEYMASTER, TO_HW_DEVICE_T_OPEN(device));
}
| [
"lixuqing@auto-link.com.cn"
] | lixuqing@auto-link.com.cn |
9fd90c8862f85dd6cda5905a1028fae4fd9d6ad4 | 2b93d3bc50cb40a0f6c44819a8470e091fcc30c4 | /com/include/QKinect.h | c771ca2c300601306347347f36e51ce1d9a4ca75 | [] | no_license | NCCA/KinectMDI | 184bea96ad1617e035d313c832a3f8c82c7499e3 | e1a242d8a465bc643dcae103335847015a44ea97 | refs/heads/master | 2021-01-19T07:57:18.266493 | 2017-09-25T21:00:15 | 2017-09-25T21:00:15 | 24,463,144 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 26,859 | h | #ifndef QKINECT_H__
#define QKINECT_H__
/*
* This file is part of the OpenKinect Project. http://www.openkinect.org
*
* Copyright (c) 2010 individual OpenKinect contributors. See the CONTRIB file
* for details.
*
* This code is licensed to you under the terms of the Apache License, version
* 2.0, or, at your option, the terms of the GNU General Public License,
* version 2.0. See the APACHE20 and GPL2 files for the text of the licenses,
* or the following URLs:
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.gnu.org/licenses/gpl-2.0.txt
*
* If you redistribute this file in source form, modified or unmodified, you
* may:
* 1) Leave this header intact and distribute it under the same terms,
* accompanying it with the APACHE20 and GPL20 files, or
* 2) Delete the Apache 2.0 clause and accompany it with the GPL2 file, or
* 3) Delete the GPL v2 clause and accompany it with the APACHE20 file
* In all cases you must keep the copyright notice intact and include a copy
* of the CONTRIB file.
*
* Binary distributions must follow the binary distribution requirements of
* either License.
*/
//----------------------------------------------------------------------------------------------------------------------
/// @file QKinect.h
/// @brief a Qt wrapper for the OpenKinect project a lot of the code has been modified from
/// this project source here https://github.com/OpenKinect/libfreenect
//----------------------------------------------------------------------------------------------------------------------
#include <QObject>
#include <QThread>
#include <stdexcept>
#include <QMutex>
#include <QMutexLocker>
#include <vector>
#include <libfreenect.h>
//----------------------------------------------------------------------------------------------------------------------
/// @class QKinectProcessEvents "QKinect.h"
/// @author Jonathan Macey
/// @version 1.0
/// @date 20/12/10 Inital commit
/// @brief this is the process event thread class
/// it needs to be a class so we can use the Qt thread system
//----------------------------------------------------------------------------------------------------------------------
class QKinectProcessEvents : public QThread
{
public :
//----------------------------------------------------------------------------------------------------------------------
/// @brief ctor where we pass in the context of the kinect
/// @param [in] _ctx the context of the current kinect device
//----------------------------------------------------------------------------------------------------------------------
inline QKinectProcessEvents(freenect_context *_ctx )
{m_ctx=_ctx;}
//----------------------------------------------------------------------------------------------------------------------
/// @brief sets the thread active this will loop the run thread
/// with a while(m_active) setting this will end the thread loop
//----------------------------------------------------------------------------------------------------------------------
inline void setActive(){m_active=true;}
//----------------------------------------------------------------------------------------------------------------------
/// @brief sets the thread active must call QThread::start again to make this
/// work if the thread has been de-activated
//----------------------------------------------------------------------------------------------------------------------
inline void setInActive(){m_active=false;}
protected :
//----------------------------------------------------------------------------------------------------------------------
/// @brief the actual thread main loop, this is not callable and the
/// QThread::start method of QThread must be called to activate the loop
//----------------------------------------------------------------------------------------------------------------------
void run();
private :
//----------------------------------------------------------------------------------------------------------------------
/// @brief a flag to indicate if the loop is to be active
/// set true in the ctor
//----------------------------------------------------------------------------------------------------------------------
bool m_active;
//----------------------------------------------------------------------------------------------------------------------
/// @brief the context of the kinect device, this must
/// be set before the thread is run with QThread::start
//----------------------------------------------------------------------------------------------------------------------
freenect_context *m_ctx;
};
//----------------------------------------------------------------------------------------------------------------------
/// @class QKinect "QKinect.h"
/// @author Jonathan Macey
/// @version 1.0
/// @date 20/12/10 Inital commit
/// @brief this class wraps the libfreenect library as a QObject
/// this allows us to use singals and slots to communicate with the class
/// from other Qt GUI elements. This class uses the Singleton pattern so must
/// be accessed via the instance method
//----------------------------------------------------------------------------------------------------------------------
class QKinect : public QObject
{
// must include this macro so we inherit all the core QT features such as singnals and slots
Q_OBJECT
public :
//----------------------------------------------------------------------------------------------------------------------
/// @brief get the instance of the QKinect object this will call the
/// init method of the class if the instance doesn't exist. This is because
/// this class will construct some threads so we need to create an instance
/// first then pass that to the other classes in the thread
/// @returns an instance of the QKinect object
//----------------------------------------------------------------------------------------------------------------------
static QKinect *instance();
//----------------------------------------------------------------------------------------------------------------------
/// @brief we can set the user device number here by default it will be 1
/// @param[in] _m the number we wish to set
//----------------------------------------------------------------------------------------------------------------------
inline void setUserDeviceNumber(int _m)
{m_userDeviceNumber=_m;}
//----------------------------------------------------------------------------------------------------------------------
/// @brief method to shutdown our device and close
//----------------------------------------------------------------------------------------------------------------------
void shutDownKinect();
//----------------------------------------------------------------------------------------------------------------------
/// @brief get if device is active
//----------------------------------------------------------------------------------------------------------------------
inline bool haveKinect()const {return m_deviceActive;}
inline unsigned int getResolutionDepthBytes()const {return m_resolutionDepthBytes;}
public slots :
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to change the angle of the Kinect
/// @param[in] _angle the angle to set will be constrained to -/+ 30.0
//----------------------------------------------------------------------------------------------------------------------
void setAngle(double _angle);
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to turn off the led
//----------------------------------------------------------------------------------------------------------------------
void setLedOff();
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to enable the red LED
//----------------------------------------------------------------------------------------------------------------------
void setRedLed();
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to enable the green LED
//----------------------------------------------------------------------------------------------------------------------
void setGreenLed();
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to enable the yellow LED
//----------------------------------------------------------------------------------------------------------------------
void setYellowLed();
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to flash the red led
//----------------------------------------------------------------------------------------------------------------------
void setRedLedFlash();
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to flash the green led
//----------------------------------------------------------------------------------------------------------------------
void setGreenLedFlash();
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to flash the yellow led
//----------------------------------------------------------------------------------------------------------------------
void setYellowLedFlash();
//----------------------------------------------------------------------------------------------------------------------
/// @brief slot to set the video mode
/// @brief param _mode the video mode as an int index
/// FREENECT_VIDEO_RGB = 0,
/// FREENECT_VIDEO_YUV_RGB = 1,
/// FREENECT_VIDEO_IR_8BIT = 2,
//----------------------------------------------------------------------------------------------------------------------
void setVideoMode(int _mode );
//----------------------------------------------------------------------------------------------------------------------
/// @brief reset the tilt angle
//----------------------------------------------------------------------------------------------------------------------
void resetAngle();
//----------------------------------------------------------------------------------------------------------------------
/// @brief getDepth buffer and convert it to an RGB colour representation
/// this code is based on the sample implementation glview.c / cppview.cpp
/// @param[out] o_buffer the buffer to fill
//----------------------------------------------------------------------------------------------------------------------
bool getDepth(std::vector<uint8_t> &o_buffer);
//----------------------------------------------------------------------------------------------------------------------
/// @brief getDepth buffer as the raw values converted to uint8_t not sure if this will
/// be much use but have used it in some tracking examples
/// @param[out] o_buffer the buffer to fill
//----------------------------------------------------------------------------------------------------------------------
bool getDepthRaw(std::vector<uint8_t> &o_buffer);
//----------------------------------------------------------------------------------------------------------------------
/// @brief getDepth buffer as the raw 16 Bit values
/// this is useful for generating point cloud renders as we have the full depth range
/// @param[out] o_buffer the buffer to fill
//----------------------------------------------------------------------------------------------------------------------
bool getDepth16Bit( std::vector<uint16_t> &o_buffer );
//----------------------------------------------------------------------------------------------------------------------
/// @brief get the RGB buffer
/// @param [out] o_buffer the rgb values
//----------------------------------------------------------------------------------------------------------------------
bool getRGB(std::vector<uint8_t> &o_buffer );
//----------------------------------------------------------------------------------------------------------------------
/// @brief start the Depth buffer grabbing subsystem
//----------------------------------------------------------------------------------------------------------------------
void startDepth();
//----------------------------------------------------------------------------------------------------------------------
/// @brief stop the Depth buffer grabbing subsystem
//----------------------------------------------------------------------------------------------------------------------
void stopDepth();
//----------------------------------------------------------------------------------------------------------------------
/// @brief start the Video buffer grabbing subsystem
//----------------------------------------------------------------------------------------------------------------------
void startVideo();
//----------------------------------------------------------------------------------------------------------------------
/// @brief stop the Depth buffer grabbing subsystem
//----------------------------------------------------------------------------------------------------------------------
void stopVideo();
//----------------------------------------------------------------------------------------------------------------------
/// @brief convenience method to toggle the video mode with a bool to indicate
/// mode, useful for connecting to buttons
//----------------------------------------------------------------------------------------------------------------------
void toggleVideoState(bool _mode );
//----------------------------------------------------------------------------------------------------------------------
/// @brief convenience method to toggle the depth mode with a bool to indicate
/// mode, useful for connecting to buttons
//----------------------------------------------------------------------------------------------------------------------
void toggleDepthState(bool _mode);
//----------------------------------------------------------------------------------------------------------------------
/// @brief return a pointer to the active device context
/// @returns the current active contects
//----------------------------------------------------------------------------------------------------------------------
inline freenect_context *getContext(){return m_ctx;}
private :
//----------------------------------------------------------------------------------------------------------------------
/// @brief private ctor as we are a singleton class
//----------------------------------------------------------------------------------------------------------------------
QKinect();
//----------------------------------------------------------------------------------------------------------------------
/// @brief private dtor as we are a singleton class
//----------------------------------------------------------------------------------------------------------------------
~QKinect();
//----------------------------------------------------------------------------------------------------------------------
/// @brief private copy ctor as we are a singleton class
//----------------------------------------------------------------------------------------------------------------------
Q_DISABLE_COPY(QKinect)
//----------------------------------------------------------------------------------------------------------------------
/// @brief private init method, this makes the instance method thread safe
/// as all the initialisations will be done here
//----------------------------------------------------------------------------------------------------------------------
void init();
//----------------------------------------------------------------------------------------------------------------------
/// @brief our instance of the Kinect device
//----------------------------------------------------------------------------------------------------------------------
static QKinect *s_instance;
//----------------------------------------------------------------------------------------------------------------------
/// @brief the contex for the device
//----------------------------------------------------------------------------------------------------------------------
freenect_context *m_ctx;
//----------------------------------------------------------------------------------------------------------------------
/// @brief our device pointer
//----------------------------------------------------------------------------------------------------------------------
freenect_device *m_dev;
//----------------------------------------------------------------------------------------------------------------------
/// @brief user device number
//----------------------------------------------------------------------------------------------------------------------
int m_userDeviceNumber;
//----------------------------------------------------------------------------------------------------------------------
/// @brief function for depth callback this hooks into the libfreenect callback system
/// @param[in] _dev the device we are querying
/// @param[out] the actual depth data returned from the device
/// @param _timestamp the time stamp for the grab (not used at present)
//----------------------------------------------------------------------------------------------------------------------
void depthFunc(freenect_device *_dev, void *o_depth,uint32_t _timestamp );
//----------------------------------------------------------------------------------------------------------------------
/// @brief function for Video callback this hooks into the libfreenect callback system
/// @param[in] _dev the device we are querying
/// @param[out] o_rgb the actual video data returned from the device
/// @param _timestamp the time stamp for the grab (not used at present)
//----------------------------------------------------------------------------------------------------------------------
void rgbFunc(freenect_device *_dev, void *o_rgb,uint32_t _timestamp);
//----------------------------------------------------------------------------------------------------------------------
/// @brief our depth buffer for the current depth frames will be filled
/// from the depth callback, this data is converted into an RGB representation
/// with Red being closest and blue far away, this is done via a gamma table
/// and converting the depth from 16 bit to 8 bit RGB useful for OpenCV like
/// motion tracking
//----------------------------------------------------------------------------------------------------------------------
std::vector<uint8_t> m_bufferDepth;
//----------------------------------------------------------------------------------------------------------------------
/// @brief our video buffer for the current rgb video frames will be filled
/// from the rgb callback
//----------------------------------------------------------------------------------------------------------------------
std::vector<uint8_t> m_bufferVideo;
//----------------------------------------------------------------------------------------------------------------------
/// @brief our depth buffer for the current depth frames will be filled
/// from the depth callback this is the unaltered data converted to 8 bit
/// not really useful so may get rid of at a later date just legacy from
/// testing the other examples
//----------------------------------------------------------------------------------------------------------------------
std::vector<uint8_t> m_bufferDepthRaw;
//----------------------------------------------------------------------------------------------------------------------
/// @brief the 16Bit raw depth values, this is good for voxel rendering of the
/// data
//----------------------------------------------------------------------------------------------------------------------
std::vector<uint16_t> m_bufferDepthRaw16;
//----------------------------------------------------------------------------------------------------------------------
/// @brief our gamma table this is filled in the ctor and used in the depth
/// callbacks, this is taken from the sample code glview.c cppview.cpp
//----------------------------------------------------------------------------------------------------------------------
std::vector<uint16_t> m_gamma;
//----------------------------------------------------------------------------------------------------------------------
/// @brief flag to indicate if there is a new rgb frame
//----------------------------------------------------------------------------------------------------------------------
bool m_newRgbFrame;
//----------------------------------------------------------------------------------------------------------------------
/// @brief flag to indicate if there is a new depth frame
//----------------------------------------------------------------------------------------------------------------------
bool m_newDepthFrame;
//----------------------------------------------------------------------------------------------------------------------
/// @brief flag to indicate if we need to stop the device
//----------------------------------------------------------------------------------------------------------------------
bool m_stopDevice;
//----------------------------------------------------------------------------------------------------------------------
/// @brief flag to indicate if the device is active
//----------------------------------------------------------------------------------------------------------------------
bool m_deviceActive;
//----------------------------------------------------------------------------------------------------------------------
/// @brief size of the RGB buffer for the current mode
//----------------------------------------------------------------------------------------------------------------------
unsigned int m_resolutionRGBBytes;
//----------------------------------------------------------------------------------------------------------------------
/// @brief size of the depth buffer for the current mode
//----------------------------------------------------------------------------------------------------------------------
unsigned int m_resolutionDepthBytes;
//----------------------------------------------------------------------------------------------------------------------
/// @brief pointer to our thread process used to process the events
//----------------------------------------------------------------------------------------------------------------------
QKinectProcessEvents *m_process;
//----------------------------------------------------------------------------------------------------------------------
/// @brief our mutex used for the threaded processes, for ease we use a
/// QMutexLocker to automagically control our mutex state
//----------------------------------------------------------------------------------------------------------------------
QMutex m_mutex;
//----------------------------------------------------------------------------------------------------------------------
/// @brief set to indicate if we have a kinect attached and running
//----------------------------------------------------------------------------------------------------------------------
bool m_deviceConnected;
//----------------------------------------------------------------------------------------------------------------------
/// @brief method to grab the depth passed to the depthCallback function
/// as we are hooking into a C lib we need to do it this way as the callback
/// functions must be static (see below)
/// @param[out] _depth the depth data
/// @param[in] _timestamp the timestamp of the operation (not used)
//----------------------------------------------------------------------------------------------------------------------
void grabDepth(void *_depth,uint32_t timestamp);
//----------------------------------------------------------------------------------------------------------------------
/// @brief method to grab the Video passed to the depthCallback function
/// as we are hooking into a C lib we need to do it this way as the callback
/// functions must be static (see below)
/// @param[out] _video the depth data
/// @param[in] _timestamp the timestamp of the operation (not used)
//----------------------------------------------------------------------------------------------------------------------
void grabVideo(void *_video, uint32_t timestamp );
//----------------------------------------------------------------------------------------------------------------------
/// @brief this hooks into the feenet callback system an is the main way of
/// getting the data from the kinect this is not called directly
/// @param[in] _dev this is not used as we use the class m_dev
/// @param[out] _video the depth data
/// @param[in] _timestamp the timestamp of the operation (not used)
//----------------------------------------------------------------------------------------------------------------------
static inline void depthCallback( freenect_device *_dev, void *_depth,uint32_t _timestamp=0)
{
/// get an instance of our device
QKinect *kinect=QKinect::instance();
/// then call the grab method to fill the depth buffer and return it
kinect->grabDepth(_depth,_timestamp);
}
//----------------------------------------------------------------------------------------------------------------------
/// @brief this hooks into the feenet callback system an is the main way of
/// getting the data from the kinect this is not called directly
/// @param[in] _dev this is not used as we use the class m_dev
/// @param[out] _video the depth data
/// @param[in] _timestamp the timestamp of the operation (not used)
//----------------------------------------------------------------------------------------------------------------------
static inline void videoCallback(freenect_device *_dev, void *_video, uint32_t _timestamp=0)
{
/// get an instance of our device
QKinect *kinect=QKinect::instance();
/// then fill the video buffer
kinect->grabVideo(_video, _timestamp);
}
};
#endif
| [
"jmacey@bournemouth.ac.uk"
] | jmacey@bournemouth.ac.uk |
97c8761a93c42cfa6dfce65bf6f121318a5fd187 | 0ebb297fe3a7354d988661be5b1de8ab2019c60a | /code/neuroevo/common/systems/physics2d/phys2d_system_defn.h | dbf1da981940270740fddc52b5bc350974ad8ce9 | [] | no_license | kamrann/workbase | a56e8ca3874ae5e71e4c77331ed10f59acff5914 | ce2cade80365f885839bf96bfc5db5e57059ba39 | refs/heads/master | 2021-01-19T03:22:32.745349 | 2015-01-02T23:05:04 | 2015-01-02T23:05:04 | 15,985,205 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,228 | h | // phys2d_system_defn.h
#ifndef __WB_NE_PHYSICS_2D_SYSTEM_DEFN_H
#define __WB_NE_PHYSICS_2D_SYSTEM_DEFN_H
#include "scenario_defn.h"
#include "system_sim/basic_system_defn.h"
#include "util/bimap.h"
namespace sys {
struct update_info;
namespace phys2d {
class phys2d_system_defn:
public basic_system_defn
{
public:
static std::unique_ptr< phys2d_system_defn > create_default();
public:
virtual std::string get_name() const override;
virtual bool is_instantaneous() const override;
virtual update_info get_update_info() const override;
void add_scenario_defn(scenario_defn_ptr defn);
virtual //state_value_id_list
ddl::dep_function< state_value_id_list >
get_system_core_state_values_fn() const override;
virtual system_ptr create_system_core(ddl::navigator nav) const override;
private:
virtual ddl::defn_node get_system_core_defn(ddl::specifier& spc) override;
private:
enum class StateValue: unsigned long;
static const bimap< StateValue, std::string > s_state_values;
std::map< std::string, scenario_defn_ptr > m_scenario_defns;
ddl::dep_function< state_value_id_list > core_state_values_fn_;
friend class phys2d_system;
};
}
}
#endif
| [
"cjangus@gmail.com"
] | cjangus@gmail.com |
f708338aa68bf7e26c4a81f230aa0c3e9273c61d | 49e6354d92450ac3a7421706cec8c074e4ea2e03 | /include/ME/light/LightClass.h | 00238f02cae51e651c14244541a916b5528428c3 | [] | no_license | Milhau5/A10---Separation-Axis-Test | 21ae6be3b9f761a59d2c263f8e645fa9fddb040d | 91764e6391655d9e78327f84777be75b94aa8b23 | refs/heads/master | 2021-03-12T19:54:48.913567 | 2015-04-16T00:08:30 | 2015-04-16T00:08:30 | 33,953,258 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,789 | h | /*
Programmer: Alberto Bobadilla (labigm@gmail.com)
Date: 2014/05
*/
#ifndef __LIGHTCLASS_H_
#define __LIGHTCLASS_H_
#include "ME\system\SystemSingleton.h"
namespace MyEngine
{
class MyEngineDLL LightClass
{
//Private Fields
float m_fIntensity;
vector3 m_vPosition;
vector3 m_vColor;
public:
//The Big 3
/* Constructor */
LightClass(void);
/* Constructor */
LightClass( vector3 a_vPosition, vector3 a_vColor, float a_vIntensity);
/* Copy Constructor */
LightClass(const LightClass& other);
/* Copy Assignment operator */
LightClass& operator=(const LightClass& other);
/* Destructor */
~LightClass(void);
//Helper Methods
/* Swapts the information of two objects*/
void Swap(LightClass& other);
//Accessors
/* Sets the position of the light */
void SetPosition(vector3 a_vPosition);
/* Gets the position of the light */
vector3 GetPosition(void);
/* Property SetPosition/GetPosition */
__declspec(property(put = SetPosition, get = GetPosition)) vector3 Position;
/* Sets the color of the light */
void SetColor(vector3 a_vColor);
/* Gets the color of the light*/
vector3 GetColor(void);
/* Property SetColor/GetColor */
__declspec(property(put = SetColor, get = GetColor)) vector3 Color;
/* Set Intensity of the light */
void SetIntensity(float a_fIntensity);
/* Gets the intensity of the light*/
float GetIntensity(void);
/* Property SetIntensity/GetIntensity */
__declspec(property(put = SetIntensity, get = GetIntensity)) float Intensity;
protected:
//Protected methods
/* Initializates the object values*/
void Init(void);
/* Releases the object*/
void Release(void);
};
EXPIMP_TEMPLATE template class MyEngineDLL std::vector<LightClass>;
EXPIMP_TEMPLATE template class MyEngineDLL std::vector<LightClass*>;
}
#endif //__LIGHT_H__ | [
"nai7804@GDD-55.main.ad.rit.edu"
] | nai7804@GDD-55.main.ad.rit.edu |
1c69969a1dc3868b5ca6ebfc4eaf64f294adce3c | 45f8762035df391bdb4e345e340ee09bf9655a22 | /VideoTracking/PositionStream.h | dc5965c4eb48989273f9f541182515230f6ec196 | [] | no_license | rafaelkuffner/OpticalFlowCloud | 4f44146667e80c4226e34cd664060a29e6479191 | 854842aa4032725e5f608f69fb7eb4b751025f6a | refs/heads/master | 2020-03-28T01:23:44.575077 | 2018-09-05T10:50:24 | 2018-09-05T10:50:24 | 147,501,330 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 399 | h | #pragma once
#include <vector>
#include "opencv2/core/core.hpp"
using namespace std;
using namespace cv;
class PositionStream
{
public:
bool _active;
bool _fresh;
int _id;
int _firstFrame;
vector<Vec2i> _positions;
vector<float> _topValue;
vector<float> _midValue;
vector<float> _bottomValue;
PositionStream(int id, int firstFrame);
~PositionStream();
void drawPath(Mat &img);
};
| [
"rafaelkuffner@gmail.com"
] | rafaelkuffner@gmail.com |
fa3ada897e1364f41b5f15a806bca32fbb8af259 | 9f93116a1a67b9e2e56c9684eb968175fcdb37a4 | /LUCKG.cpp | b003739c29eaebaa37cf907cd5ec63875719b337 | [] | no_license | Anmol2307/SpojProblems | 72d7fa2b1b56f0228dcdd4c803a40ac97abb592e | 9784e8149df8ff19f441d77fd30f829e4f1d551d | refs/heads/master | 2016-08-03T07:43:26.350944 | 2014-11-20T10:06:12 | 2014-11-20T10:06:12 | 17,081,832 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,758 | cpp | #include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <cctype>
#include <list>
#include <stack>
#include <fstream>
#include <utility>
#include <iomanip>
using namespace std;
#define pb push_back
#define all(s) s.begin(),s.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define F(i,a,b) for(int i=a;i>=b;i--)
#define PI 3.1415926535897932384626433832795
#define BIG_INF 7000000000000000000LL
#define mp make_pair
#define eps 1e-9
#define si(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define mod 1000000007
#define mm 10000000
#define INF (1<<29)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define FILL(a,v) memset(a,v,sizeof(a))
#define EPS 1e-9
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
typedef long long LL;
string inttostring(int n)
{
stringstream a;
a<<n;
string A;
a>>A;
return A;
}
int stringtoint(string A)
{
stringstream a;
a<<A;
int p;
a>>p;
return p;
}
inline void inp(int &n ) {//fast input function
n=0;
int ch=getchar(),sign=1;
while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}
while( ch >= '0' && ch <= '9' )
n=(n<<3)+(n<<1)+ ch-'0', ch=getchar();
n=n*sign;
}
int main () {
int t,n,m;
inp(t);
while (t--) {
inp(n);inp(m);
int p[n][m];
for (int i=0;i<n;i++) {
int x=i;
int count=m;
int j = 0;
int val;
inp(val);
while (count--) {
if (x<0) x=n-1;
p[x][j]=val;
x--;j++;
}
}
// for (int i = 0; i < n; i++) {
// for (int j = 0; j< m; j++) {
// printf("%d ",p[i][j]);
// }
// printf("\n");
// }
// cout << p[0][0] << endl;
// exit(0);
int ans[n][m];
int pro = n*m;
int y = 1;
int a[pro];
memset(a,0,sizeof(a));
bool flag = false;
for (int i=0; i<m; i++) {
for (int j=0; j<n; j++) {
int value;
if (p[j][i] != 0) {
value = n*i+p[j][i];
}
else {
value = n*(i+1);
}
if (a[value-1] == 0 && value >= 1 && value <= pro && n > 1) ans[j][i] = value;
else {
flag = true;
break;
}
}
if (flag) break;
}
if (!flag) {
for (int i = 0; i < n; i++) {
for (int j = 0; j< m-1; j++) {
printf("%d ",ans[i][j]);
}
printf("%d\n",ans[i][m-1]);
}
}
else {
printf("%s\n","No Solution");
}
}
} | [
"garganmol1993@gmail.com"
] | garganmol1993@gmail.com |
c3df50cc5a855bba868b897d026f7cf42a870208 | 8056397c905fa86f4f3489c6f34176f0a167a351 | /contest/1324/f/73119520.cpp | 584ffd456c56959042acd32262cf8cfeaa851a9d | [] | no_license | priyankjairaj100/Codeforces-Solutions | e9ac35b339ebd71e17882873ae2150d0c17101f6 | 540f30d8741e5d84bc983cb7abcee0a0dc03bfbb | refs/heads/master | 2022-04-23T06:14:52.931737 | 2020-04-25T03:16:24 | 2020-04-25T03:16:24 | 258,675,413 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,688 | cpp | #include <bits/stdc++.h>
#include <string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pii pair<int, int>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define jai_shree_ram ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, a, b, d) for (int i = a; i <= b; i += d)
#define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
int MAX = 1e5 + 5;
int MOD = 1e9 + 7;
////////////////////////////////
vector <int> g[200005];
int n;
int a[200005], dp[200005], ans[200005];
void dfs(int x, int pp){
for(auto y : g[x]){
if(y == pp) continue;
dfs(y, x);
if(dp[y] > 0) dp[x] += dp[y];
}
}
void dfs1(int x, int pp){
ans[x] = dp[x];
for(auto y: g[x]){
if(y == pp) continue;
dp[x] -= max(0LL, dp[y]);
dp[y] += max(0LL, dp[x]);
dfs1(y, x);
dp[y] -= max(0LL, dp[x]);
dp[x] += max(0LL, dp[y]);
}
}
int32_t main(){
jai_shree_ram
cin >> n;
rep(i,1,n,1) {
cin >> a[i];
if(a[i]) dp[i] = 1;
else dp[i] = -1;
}
rep(i,1,n-1,1){
int u, v;
cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
dfs(1, -1);
dfs1(1, -1);
rep(i,1,n,1) cout << ans[i] << " ";
cout << endl;
return 0;
} | [
"f2016615@pilani.bits-pilani.ac.in"
] | f2016615@pilani.bits-pilani.ac.in |
892886011dcc589cdd2a53359608fcb3feb93a32 | 33f8a1164c44b4ade4a1ae9edca25a5d631b14dc | /Equipment.cpp | 38c5b5a1beaa5bc45eb715e8283c53a9ef9a66cd | [] | no_license | kuribohlv9/Skelly_Dungeon | fe2ef781c3e4169ef7300a3af1347ee7f18bf4a3 | 01d8d165a3d045b58b467a5e5c4594ba6c92a115 | refs/heads/master | 2020-04-30T09:03:41.956469 | 2015-02-07T15:29:12 | 2015-02-07T15:29:12 | 28,010,758 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 314 | cpp | // Equipment.cpp
#include "stdafx.h"
#include "Equipment.h"
#include "Item.h" // do I need this?
#include "Collider.h"
#include "Sprite.h"
Equipment::Equipment(){
}
Equipment::~Equipment(){
}
void Equipment::PickUp(Player* player)
{
// here will be the code to pick up equipment items
} | [
"gamedesignwithdee@gmail.com"
] | gamedesignwithdee@gmail.com |
eb4c987ae218b991e5ad275b3bd950424c71e970 | 723202e673511cf9f243177d964dfeba51cb06a3 | /10/oot/src/gui/GraphView/inc/Edge.h | c2fee04718c7ee4a200fc1ab43f063362d105792 | [] | no_license | aeremenok/a-team-777 | c2ffe04b408a266f62c523fb8d68c87689f2a2e9 | 0945efbe00c3695c9cc3dbcdb9177ff6f1e9f50b | refs/heads/master | 2020-12-24T16:50:12.178873 | 2009-06-16T14:55:41 | 2009-06-16T14:55:41 | 32,388,114 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 710 | h | #ifndef EDGE_H
#define EDGE_H
#include <QtGui/QGraphicsItem>
class Node;
class Edge : public QGraphicsItem
{
public:
Edge(Node *sourceNode, Node *destNode);
~Edge();
Node *sourceNode() const;
void setSourceNode(Node *node);
Node *destNode() const;
void setDestNode(Node *node);
void adjust();
enum { Type = UserType + 2 };
int type() const { return Type; }
void setActive(bool f);
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
Node *source, *dest;
QPointF sourcePoint;
QPointF destPoint;
qreal arrowSize;
bool m_active;
};
#endif
| [
"Pavel.Zubarev@9273621a-9230-0410-b1c6-9ffd80c20a0c"
] | Pavel.Zubarev@9273621a-9230-0410-b1c6-9ffd80c20a0c |
8e43d0711a6564387fead9439af945df873fc9ed | e95a7284e50993fc8082348861b09221b4967d74 | /src/gamefield.h | c64e3be3a42417e6590b74fb11d8065c00908673 | [] | no_license | almikhailov/CrazyTanks2 | eaf0ab130c2198058cf9a53ca5d630734bd1deeb | a3a38c103d4b0cb6e92ae0078f7940949b53dd99 | refs/heads/master | 2021-04-15T07:43:40.374183 | 2018-03-30T11:13:24 | 2018-03-30T11:13:24 | 126,135,129 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 724 | h | //#include "constants.h"
class GameField : Game {
public:
GameField();
int checkCoords(int,int);
Game* getRefCoords(int ,int);
void setCoords(int,int,int,Game*);
private:
int gameFieldArrOfType[LIMIT_RIGHT-LIMIT_LEFT+1][LIMIT_DOWN-LIMIT_UP+1];
Game* gameFieldArrOfRef[LIMIT_RIGHT-LIMIT_LEFT+1][LIMIT_DOWN-LIMIT_UP+1];
};
GameField::GameField() { };
int GameField::checkCoords(int x,int y) {
return(gameFieldArrOfType[x][y]);
}
Game* GameField::getRefCoords(int x,int y) {
return(gameFieldArrOfRef[x][y]);
}
void GameField::setCoords(int x,int y, int typeOfObject, Game* refOfObject) {
gameFieldArrOfType[x][y]=typeOfObject;
gameFieldArrOfRef[x][y]=refOfObject;
}
| [
"noreply@github.com"
] | almikhailov.noreply@github.com |
b54116a7e2015d8b0dbe6038645b135305b28d07 | 3efc5d6fe78e55f92c753e264e966c74a71a824b | /Alexandria/Dynamic_Mesh.cpp | ef55c79cf5d56d3f9b78dbb2d750346347cb8c4f | [] | no_license | TaehunKim0/Alexandria | 06e3978ec790a1f8dc175136c73700a1b76fcf9d | bfb2994506a46932914638da1ba170a09c1eafc1 | refs/heads/master | 2023-04-13T05:14:57.687856 | 2018-06-25T12:00:33 | 2018-06-25T12:00:33 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 3,887 | cpp | #include "stdafx.h"
#include "Dynamic_Mesh.h"
#include "CHierarchyLoader.h"
#include "CAnimationCtrl.h"
Dynamic_Mesh::Dynamic_Mesh(LPDIRECT3DDEVICE9 pGraphicDev)
: m_pGraphicDev(pGraphicDev)
{
m_pGraphicDev->AddRef();
}
Dynamic_Mesh::~Dynamic_Mesh()
{
}
HRESULT Dynamic_Mesh::Init_Dynamic_Mesh(const wchar_t * pFilePath, const wchar_t * pFileName)
{
wchar_t szFullPath[128] = L"";
lstrcpyW(szFullPath, pFilePath);
lstrcatW(szFullPath, pFileName);
m_pLoader = new CHierarchyLoader(m_pGraphicDev, pFilePath);
if (nullptr == m_pLoader)
return E_FAIL;
LPD3DXANIMATIONCONTROLLER pAniCtrl = nullptr;
if (FAILED(D3DXLoadMeshHierarchyFromXW(szFullPath, D3DXMESH_MANAGED, m_pGraphicDev, m_pLoader, nullptr, &m_pRootFrame, &pAniCtrl)))
return E_FAIL;
m_pAnimationCtrl = new CAnimationCtrl(m_pGraphicDev, pAniCtrl);
if (nullptr == m_pAnimationCtrl)
return E_FAIL;
pAniCtrl->Release();
m_pAnimationCtrl->Set_AnimationSet(55);
//걷기 54
D3DXMATRIX matPivot;
Update_CombiendTransformationMatrices((D3DXFRAME_DERIVED*)m_pRootFrame, *D3DXMatrixRotationY(&matPivot, D3DXToRadian(180.0f)));
SetUp_CombinedMatricesPointer((D3DXFRAME_DERIVED*)m_pRootFrame);
return S_OK;
}
void Dynamic_Mesh::Update_CombiendTransformationMatrices(D3DXFRAME_DERIVED * pFrame, D3DXMATRIX matParent)
{
pFrame->matCombinedTransformationMatrix = pFrame->TransformationMatrix * matParent;
if (nullptr != pFrame->pFrameSibling)
Update_CombiendTransformationMatrices(((D3DXFRAME_DERIVED*)pFrame->pFrameSibling), matParent);
if (nullptr != pFrame->pFrameFirstChild)
Update_CombiendTransformationMatrices(((D3DXFRAME_DERIVED*)pFrame->pFrameFirstChild), pFrame->matCombinedTransformationMatrix);
}
void Dynamic_Mesh::SetUp_CombinedMatricesPointer(D3DXFRAME_DERIVED * pFrame)
{
if (nullptr != pFrame->pMeshContainer)
{
D3DXMESHCONTAINER_DERIVED* pMeshContainer = (D3DXMESHCONTAINER_DERIVED*)pFrame->pMeshContainer;
m_MeshContainerList.push_back(pMeshContainer);
for (int i = 0; i < pMeshContainer->dwNumBones; ++i)
{
const char* pName = pMeshContainer->pSkinInfo->GetBoneName(i);
D3DXFRAME_DERIVED* pFrame_Find = (D3DXFRAME_DERIVED*)D3DXFrameFind(m_pRootFrame, pName);
pMeshContainer->ppCombinedTransformationMatrices[i] = &pFrame_Find->matCombinedTransformationMatrix;
}
}
if (nullptr != pFrame->pFrameSibling)
SetUp_CombinedMatricesPointer(((D3DXFRAME_DERIVED*)pFrame->pFrameSibling));
if (nullptr != pFrame->pFrameFirstChild)
SetUp_CombinedMatricesPointer(((D3DXFRAME_DERIVED*)pFrame->pFrameFirstChild));
}
void Dynamic_Mesh::Render_Mesh()
{
for (auto& pMeshContainer : m_MeshContainerList)
{
for (DWORD j = 0; j < pMeshContainer->dwNumBones; ++j)
{
pMeshContainer->pRenderingMatrices[j]
= pMeshContainer->pOffsetMatrices[j] * *pMeshContainer->ppCombinedTransformationMatrices[j];
}
void *pVerticesSrc = nullptr, *pVerticesDst = nullptr;
pMeshContainer->pOriginal_Mesh->LockVertexBuffer(0, &pVerticesSrc);
pMeshContainer->MeshData.pMesh->LockVertexBuffer(0, &pVerticesDst);
pMeshContainer->pSkinInfo->UpdateSkinnedMesh(pMeshContainer->pRenderingMatrices, nullptr, pVerticesSrc, pVerticesDst); //소프트웨어 스키닝 ( 느림 )
pMeshContainer->pOriginal_Mesh->UnlockVertexBuffer();
pMeshContainer->MeshData.pMesh->UnlockVertexBuffer();
for (DWORD i = 0; i < pMeshContainer->NumMaterials; ++i)
{
m_pGraphicDev->SetTexture(0, pMeshContainer->ppTextures[i]);
pMeshContainer->MeshData.pMesh->DrawSubset(i);
}
}
}
void Dynamic_Mesh::Set_AnimationSet(const unsigned int & iIndex)
{
m_pAnimationCtrl->Set_AnimationSet(iIndex);
}
void Dynamic_Mesh::Play_AnimationSet(const float & fTime)
{
m_pAnimationCtrl->Play_AnimationSet(fTime);
D3DXMATRIX matPivot;
Update_CombiendTransformationMatrices((D3DXFRAME_DERIVED*)m_pRootFrame, *D3DXMatrixRotationY(&matPivot, D3DXToRadian(180.0f)));
}
| [
"jack071000@naver.com"
] | jack071000@naver.com |
f4a7e56b15e3ce2eba97375a0dc0c1df64109d47 | f12a66636dccdd3f2aa9b565b726b0f298b8faaf | /A 1-7/A1-7_Training_Grounds.Altis/cScripts/CfgUnitInsignia.hpp | 80b917735eac8d82411f44f1553640f0b7a872d4 | [] | no_license | TicknorD/Training-Missions | 83e31acb8a61c16d96fa3aed9be371e07ff2b7a1 | e2fe103786450382546fa7279e0ce655d6a13598 | refs/heads/master | 2020-03-31T01:11:53.134918 | 2018-06-24T11:57:02 | 2018-06-24T11:57:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,654 | hpp | class CfgUnitInsignia {
#include "script_component.hpp"
// Alpha first platoon
//MACRO_UNITINSIGNIA(1A_17_Insignia,1-A-17.paa);
//MACRO_UNITINSIGNIA(A1A_17_Insignia,A-1-A-17.paa);
//MACRO_UNITINSIGNIA(B1A_17_Insignia,B-1-A-17.paa);
MACRO_UNITINSIGNIA(C1A_17_Insignia,C-1-A-17.paa);
//MACRO_UNITINSIGNIA(D1A_17_Insignia,D-1-A-17.paa);
// Alpha second platoon
MACRO_UNITINSIGNIA(2A_17_Insignia,2-A-17.paa);
MACRO_UNITINSIGNIA(A2A_17_Insignia,A-2-A-17.paa);
//MACRO_UNITINSIGNIA(B2A_17_Insignia,B-2-A-17.paa);
MACRO_UNITINSIGNIA(C2A_17_Insignia,C-2-A-17.paa);
//MACRO_UNITINSIGNIA(D2A_17_Insignia,D-2-A-17.paa);
// Bravo first platoon
// Bravo second platoon
// Charlie first platoon
MACRO_UNITINSIGNIA(11C_17_Insignia,1-1-C-17.paa);
MACRO_UNITINSIGNIA(21C_17_Insignia,2-1-C-17.paa);
MACRO_UNITINSIGNIA(31C_17_Insignia,3-1-C-17.paa);
//MACRO_UNITINSIGNIA(41C_17_Insignia,4-1-C-17.paa);
// Charlie second platoon
MACRO_UNITINSIGNIA(2C_17_Insignia,2-C-17.paa);
MACRO_UNITINSIGNIA(12C_17_Insignia,1-2-C-17.paa);
//MACRO_UNITINSIGNIA(22C_17_Insignia,1-2-C-17.paa);
//MACRO_UNITINSIGNIA(32C_17_Insignia,1-2-C-17.paa);
//MACRO_UNITINSIGNIA(42C_17_Insignia,1-2-C-17.paa);
// Other Insignias
MACRO_UNITINSIGNIA(7_Insignia,7.paa);
MACRO_UNITINSIGNIA(7_m81_Insignia,7_m81.paa);
MACRO_UNITINSIGNIA(7_ocp_Insignia,7_ocp.paa);
MACRO_UNITINSIGNIA(CLS_Insignia,CLS.paa);
// Specialized
MACRO_UNITINSIGNIA(RANGER,Ranger.paa);
MACRO_UNITINSIGNIA(CAG,Airborne_Insignia.paa);
MACRO_UNITINSIGNIA(Follow_Me,follow-me-patch.paa);
};
| [
"olafdemol@hotmail.com"
] | olafdemol@hotmail.com |
18f48b4c12b75699d3a0ef46ad6a792b1578159d | d988d257f6f42d871c1a110b24afabed845c38d8 | /codesrc/source/cl_dll/forsaken/vgui/forsaken_warsummary.h | 6b5d44ba96b07ea458e51e4c33efaff4a8b76f92 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | blockspacer/Forsaken | 3748f7d25b6425db00033d7650799d4f7107d276 | 966ba79dba9e418eb7513f5ab771556eb5935036 | refs/heads/master | 2021-09-22T20:15:52.609394 | 2018-09-15T10:12:34 | 2018-09-15T10:12:34 | 258,598,863 | 1 | 0 | null | 2020-04-24T18:59:02 | 2020-04-24T18:59:01 | null | UTF-8 | C++ | false | false | 1,240 | h | #ifndef __FORSAKEN_VGUI_WARSUMMARY_H_
#define __FORSAKEN_VGUI_WARSUMMARY_H_
namespace vgui
{
class RichText;
class HTML;
}
class CWarSummary : public vgui::Frame, public IViewPortPanel
{
public:
DECLARE_CLASS_SIMPLE(CWarSummary, vgui::Frame);
// Constructor & Deconstructor
CWarSummary(IViewPort *pViewport);
virtual ~CWarSummary();
// Public Accessor Functions
vgui::VPANEL GetVPanel() { return BaseClass::GetVPanel(); }
virtual bool HasInputElements() { return true; }
virtual bool IsVisible() { return BaseClass::IsVisible(); }
virtual const char *GetName() { return PANEL_WARSUMMARY; }
virtual void SetData(KeyValues *pData);
virtual void SetParent(vgui::VPANEL parent) { BaseClass::SetParent(parent); }
// Public Functions
virtual bool NeedsUpdate() { return true; }
virtual void Reset() { }
virtual void ShowPanel(bool bState);
virtual void Update();
// Public Variables
protected:
// Protected Functions
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
void OnCommand(const char *czCommand);
void SetImage(const char *czImagePanel, const char *czPath);
void SetLabelText(const char *czLabel, const char *czText);
// Protected Variables
int m_nTeamWinner;
IViewPort *m_pViewport;
};
#endif | [
"mail@jessevanover92.net"
] | mail@jessevanover92.net |
2ccf5169b1827e5c1634cf6fe148df473e42700f | 47673ac3b6d9918b43ba1238bbace51afd30be52 | /Source/MidiDeviceChooser.cpp | 839f6a73dfd4593c98dbe4248d4bbba4ccfbffb2 | [] | no_license | sabjorn/retrofoot | 3ef774e8fb3d5637119759a5114aef3cfc67ff07 | f2f19298f10cab5deb4e911d73ce6f6b2a6c3003 | refs/heads/master | 2020-05-30T04:08:57.622199 | 2016-01-11T23:51:59 | 2016-01-11T23:51:59 | 32,959,641 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,108 | cpp | #include "MidiDeviceChooser.h"
#include <iostream>
MidiDeviceChooser::MidiDeviceChooser(const String &componentName)
: ComboBox(componentName),
Thread("Midi Device Detect")
{
}
MidiDeviceChooser::~MidiDeviceChooser()
{
stopThread(1000);
}
void MidiDeviceChooser::run()
{
uint32_t selId;
while (!threadShouldExit())
{
wait (500);
const MessageManagerLock mml (Thread::getCurrentThread());
if (! mml.lockWasGained()) // if something is trying to kill this job, the lock
return; // will fail, in which case we'd better return..
StringArray tmpDevices = MidiOutput::getDevices();
selId = getSelectedId();
for (uint32_t i = 0; i < tmpDevices.size(); i++)
{
if (!devices.contains(tmpDevices[i]))
{
// Select any device that is "New"
// if multiple devices show up it will select whichever
// one shows up last. Oh well.
selId = tmpDevices[i].hash();
}
}
devices = tmpDevices;
clear();
for (uint32_t i = 0; i < devices.size(); i++)
{
addItem(devices[i], devices[i].hash());
}
setSelectedId(selId);
}
}
| [
"msteveharrison@gmail.com"
] | msteveharrison@gmail.com |
24750c8a4f3c9df3ed0de8a4125f42c699994589 | 8c7704a38e264da31382e4a58ac922f89837bd6c | /processingSerial/updated/serialArduUpd/serialArduUpd.ino | a9af7c145ff69d13a6f77762cf1f7dc52edfc8cc | [] | no_license | Golowa70/tutorials | 32c5e4e0cfc3a9ba9aaec65dd4b9764f3c4119ba | 08f7012e879e56fcba07139203d2d39498df6a05 | refs/heads/master | 2023-06-20T00:19:50.505808 | 2021-07-22T16:52:05 | 2021-07-22T16:52:05 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,680 | ino | #define POT 0
#define BTN 3
#define LED_R 9
#define LED_G 10
#define LED_B 11
#define SRV_PIN 2
#define PHOTO 2
#define THERM 1
#define JOYX 6
#define JOYY 7
#define MOS 4
#define RELAY 5
#include <Servo.h>
Servo servo;
#include <LiquidCrystal_I2C.h>
// 0x27 или 0x3f
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include "thermistorMinim.h";
thermistor therm(THERM, 10000, 3950);
#include "EncButton.h"
#include "Parser.h"
#include "AsyncStream.h" // асинхронное чтение сериал
AsyncStream<50> serial(&Serial, ';'); // указываем обработчик и стоп символ
EncButton<EB_TICK, BTN> btn;
bool flag = 0;
void setup() {
Serial.begin(115200);
lcd.init();
lcd.backlight();
servo.attach(SRV_PIN);
pinMode(13, 1);
pinMode(LED_R, 1);
pinMode(LED_G, 1);
pinMode(LED_B, 1);
pinMode(MOS, 1);
pinMode(RELAY, 1);
}
// с ардуино на пк, терминтаор \n
// 0,потенц,фоторез,термистор
// 1,кнопка
// 2,joyx,joyy
// с пк на ардуино, терминтаор ;
// 0,лед 13
// 1,r,g,b
// 2,angle
// 3,fan
// 4,relay
// 5,text
void loop() {
parsing();
btn.tick();
static uint32_t tmr = 0;
if (millis() - tmr > 100) {
tmr = millis();
Serial.print(0);
Serial.print(',');
Serial.print(analogRead(POT));
Serial.print(',');
Serial.print(analogRead(PHOTO));
Serial.print(',');
Serial.println(therm.getTempAverage(), 2);
}
static uint32_t tmr2 = 0;
if (millis() - tmr2 > 50) {
tmr2 = millis();
Serial.print(2);
Serial.print(',');
Serial.print(analogRead(JOYX));
Serial.print(',');
Serial.println(analogRead(JOYY));
}
if (btn.isClick()) {
flag = !flag;
Serial.print(1);
Serial.print(',');
Serial.println(flag);
}
}
// функция парсинга, опрашивать в лупе
void parsing() {
if (serial.available()) {
Parser data(serial.buf, ','); // отдаём парсеру
int ints[10]; // массив для численных данных
data.parseInts(ints); // парсим в него
switch (ints[0]) {
case 0: digitalWrite(13, ints[1]);
break;
case 1:
analogWrite(LED_R, ints[1]);
analogWrite(LED_G, ints[2]);
analogWrite(LED_B, ints[3]);
break;
case 2:
servo.write(ints[1]);
break;
case 3:
digitalWrite(MOS, ints[1]);
break;
case 4:
digitalWrite(RELAY, ints[1]);
break;
case 5:
data.split();
lcd.clear();
lcd.home();
lcd.print(data[1]);
break;
}
}
}
| [
"beragumbo@ya.ru"
] | beragumbo@ya.ru |
1c30186da9360e9fbd1be74804c15d541a234624 | 9d09facb2a90d01cb5230da9feb3a2dff92db674 | /5_OOP/1_Class/8_FriendsClass/Player.hpp | 421adb3e2fc5a1ec2f12a12888fd7b7898346b80 | [] | no_license | ashwani8958/Cpp | 7181ab84a1a2ce3ddd1b82e92deab6f59d50e971 | 66e87899d6048d8a96df5951bfaa4a1a28b21e4a | refs/heads/master | 2021-05-25T15:32:16.139311 | 2020-11-06T08:07:39 | 2020-11-06T08:07:39 | 253,809,856 | 0 | 1 | null | 2020-04-08T09:20:04 | 2020-04-07T13:59:45 | C++ | UTF-8 | C++ | false | false | 821 | hpp | //
// Player.hpp
// Class
//
// Created by Ashwani on 22/04/20.
// Copyright © 2020 Ashwani. All rights reserved.
//
#ifndef Player_hpp
#define Player_hpp
#include <string>
#include "Other_class.hpp"
class Friend_class;
class Player {
friend void Other_class::display_player(Player &p);
friend void display_player(Player &p);
friend class Friend_class;
private:
static int num_players;
std::string name;
int health;
int xp;
public:
std::string get_name() { return name; }
int get_health() { return health; }
int get_xp() {return xp; }
Player(std::string name_val ="None", int health_val = 0, int xp_val = 0);
// Copy constructor
Player(const Player &source);
// Destructor
~Player();
static int get_num_players();
};
#endif /* Player_hpp */
| [
"53987093+ashwani8958@users.noreply.github.com"
] | 53987093+ashwani8958@users.noreply.github.com |
5527c8003f4af3ab363e64b91d13498931d85f32 | d76f02dd74465c7c249c5e42607a6219014fc7d8 | /src/mainmenu.cpp | 227a4587953b8f30d6cca60205110f20291db905 | [] | no_license | Matheovi/Sokoban-Project-Sem-IV | 05c8d0988d6c5bb0f88fd64136c04b7e3d95695f | 4706282d9e8b7bad443927f6f94b2d5a2c8b5a6a | refs/heads/master | 2023-06-09T02:37:39.799914 | 2021-07-04T21:10:11 | 2021-07-04T21:10:11 | 382,709,985 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,047 | cpp | #include "mainmenu.h"
#define MOUSE_X ev.mouseButton.x
#define MOUSE_Y ev.mouseButton.y
MainMenu::MainMenu()
{
playtex.loadFromFile("textures/play.png");
exittex.loadFromFile("textures/exit.png");
maintex.loadFromFile("textures/menu.png");
playsprite.setTexture(playtex);
exitsprite.setTexture(exittex);
mainsprite.setTexture(maintex);
playsprite.setPosition(50, 100);
exitsprite.setPosition(50, 200);
}
void MainMenu::draw(sf::RenderTarget &target, sf::RenderStates states) const
{
target.clear(sf::Color(255, 255, 255));
target.draw(mainsprite);
target.draw(playsprite);
target.draw(exitsprite);
}
int MainMenu::CheckClick(sf::Event &ev)
{
if (ev.type == sf::Event::MouseButtonPressed)
{
if (MOUSE_X > 50 && MOUSE_X < 100)
{
if (MOUSE_Y > 100 && MOUSE_Y < 156)
{
return 1;
}
else if (MOUSE_Y > 200 && MOUSE_Y < 249)
{
return 2;
}
}
}
return 0;
}
| [
"wiatrok35@gmail.com"
] | wiatrok35@gmail.com |
173c9eeef1fc662ab4102406318491d866c5853a | 458eea1b41c9eae73146a1668af6bb6a3362a14c | /libraries/gui/source/utilities.cpp | 166c71a00200b6ddb4949c3417a1c3ae985a8aea | [
"BSL-1.0"
] | permissive | mCRL2org/mCRL2 | 91fb459f26087ac50036150cd77c7e8a16b5ec42 | 33d77f5ef994381e03a0d3b0693c1014e4e12d41 | refs/heads/master | 2023-09-01T13:54:28.982994 | 2023-09-01T12:54:35 | 2023-09-01T12:54:35 | 128,542,478 | 90 | 42 | BSL-1.0 | 2023-08-10T15:12:42 | 2018-04-07T15:35:53 | C++ | UTF-8 | C++ | false | false | 757 | cpp | // Author(s): Olav Bunte
// Copyright: see the accompanying file COPYING or copy at
// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include "mcrl2/gui/utilities.h"
bool mcrl2::gui::qt::hasLightBackground(QWidget* widget)
{
return widget->palette().window().color().lightness() >= 128;
}
void mcrl2::gui::qt::setTextEditTextColor(QTextEdit* textEdit, QColor light,
QColor dark)
{
textEdit->setTextColor(mcrl2::gui::qt::hasLightBackground(textEdit) ? light
: dark);
}
| [
"o.bunte@tue.nl"
] | o.bunte@tue.nl |
0bffde7836d8553986265b2934b9d84e17ad6f6e | cdefa027c687d8e55d4294754414f136fbd0f638 | /Source/Plake/PlayerStatsComponent.h | 633cc7522c44f20b10bc5fda6354fcf425e31fa4 | [] | no_license | atoddsPL/Plake | ca3332c54da88c15d63eee94582b1551625dbacb | 46025c813548bfc9181ac3381692787eeb963806 | refs/heads/master | 2023-03-14T12:38:34.365619 | 2021-03-07T20:15:57 | 2021-03-07T20:15:57 | 344,874,306 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,496 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PlayerStatsComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class PLAKE_API UPlayerStatsComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UPlayerStatsComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
// GETTERS AND SETTERS
UFUNCTION(BlueprintCallable)
float GetCurrentHealth() { return CurrentHealth; };
UFUNCTION(BlueprintCallable)
float GetCurrentHealthPercent() { return (CurrentHealth/MaxHealth); };
UFUNCTION(BlueprintCallable)
float GetCurrentMana() { return CurrentMana; };
UFUNCTION(BlueprintCallable)
float GetCurrentManaPercent() { return (CurrentMana / MaxMana); };
/* Changes Health and returns remaining amount. 0 = Dead*/
float ChangeHealth(float Delta);
private:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"), Category = "Health")
float MaxHealth = 100.f;
float CurrentHealth = 100.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"), Category = "Mana")
float MaxMana = 100.f;
float CurrentMana = 100.f;
};
| [
"tomasz.salata@gmail.com"
] | tomasz.salata@gmail.com |
2284c619df8e9f080cfacb7cd73f0ec43158b202 | b1320eb7edd285f493a0e4473dc433842aaa9178 | /Blik2D/addon/opencv-3.1.0_for_blik/samples/gpu/generalized_hough.cpp | fad32a6db6e2ea71496b895e274932a289e7b22f | [
"MIT",
"BSD-3-Clause"
] | permissive | BonexGoo/Blik2D-SDK | 2f69765145ef4281ed0cc2532570be42f7ccc2c6 | 8e0592787e5c8e8a28682d0e1826b8223eae5983 | refs/heads/master | 2021-07-09T01:39:48.653968 | 2017-10-06T17:37:49 | 2017-10-06T17:37:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,998 | cpp | #include <vector>
#include <iostream>
#include <string>
#include BLIK_OPENCV_U_opencv2__core_hpp //original-code:"opencv2/core.hpp"
#include BLIK_OPENCV_U_opencv2__core__utility_hpp //original-code:"opencv2/core/utility.hpp"
#include BLIK_OPENCV_U_opencv2__imgproc_hpp //original-code:"opencv2/imgproc.hpp"
#include "opencv2/cudaimgproc.hpp"
#include BLIK_OPENCV_U_opencv2__highgui_hpp //original-code:"opencv2/highgui.hpp"
#include "tick_meter.hpp"
using namespace std;
using namespace cv;
static Mat loadImage(const string& name)
{
Mat image = imread(name, IMREAD_GRAYSCALE);
if (image.empty())
{
cerr << "Can't load image - " << name << endl;
exit(-1);
}
return image;
}
int main(int argc, const char* argv[])
{
CommandLineParser cmd(argc, argv,
"{ image i | ../data/pic1.png | input image }"
"{ template t | templ.png | template image }"
"{ full | | estimate scale and rotation }"
"{ gpu | | use gpu version }"
"{ minDist | 100 | minimum distance between the centers of the detected objects }"
"{ levels | 360 | R-Table levels }"
"{ votesThreshold | 30 | the accumulator threshold for the template centers at the detection stage. The smaller it is, the more false positions may be detected }"
"{ angleThresh | 10000 | angle votes treshold }"
"{ scaleThresh | 1000 | scale votes treshold }"
"{ posThresh | 100 | position votes threshold }"
"{ dp | 2 | inverse ratio of the accumulator resolution to the image resolution }"
"{ minScale | 0.5 | minimal scale to detect }"
"{ maxScale | 2 | maximal scale to detect }"
"{ scaleStep | 0.05 | scale step }"
"{ minAngle | 0 | minimal rotation angle to detect in degrees }"
"{ maxAngle | 360 | maximal rotation angle to detect in degrees }"
"{ angleStep | 1 | angle step in degrees }"
"{ maxBufSize | 1000 | maximal size of inner buffers }"
"{ help h ? | | print help message }"
);
cmd.about("This program demonstrates arbitary object finding with the Generalized Hough transform.");
if (cmd.has("help"))
{
cmd.printMessage();
return 0;
}
const string templName = cmd.get<string>("template");
const string imageName = cmd.get<string>("image");
const bool full = cmd.has("full");
const bool useGpu = cmd.has("gpu");
const double minDist = cmd.get<double>("minDist");
const int levels = cmd.get<int>("levels");
const int votesThreshold = cmd.get<int>("votesThreshold");
const int angleThresh = cmd.get<int>("angleThresh");
const int scaleThresh = cmd.get<int>("scaleThresh");
const int posThresh = cmd.get<int>("posThresh");
const double dp = cmd.get<double>("dp");
const double minScale = cmd.get<double>("minScale");
const double maxScale = cmd.get<double>("maxScale");
const double scaleStep = cmd.get<double>("scaleStep");
const double minAngle = cmd.get<double>("minAngle");
const double maxAngle = cmd.get<double>("maxAngle");
const double angleStep = cmd.get<double>("angleStep");
const int maxBufSize = cmd.get<int>("maxBufSize");
if (!cmd.check())
{
cmd.printErrors();
return -1;
}
Mat templ = loadImage(templName);
Mat image = loadImage(imageName);
Ptr<GeneralizedHough> alg;
if (!full)
{
Ptr<GeneralizedHoughBallard> ballard = useGpu ? cuda::createGeneralizedHoughBallard() : createGeneralizedHoughBallard();
ballard->setMinDist(minDist);
ballard->setLevels(levels);
ballard->setDp(dp);
ballard->setMaxBufferSize(maxBufSize);
ballard->setVotesThreshold(votesThreshold);
alg = ballard;
}
else
{
Ptr<GeneralizedHoughGuil> guil = useGpu ? cuda::createGeneralizedHoughGuil() : createGeneralizedHoughGuil();
guil->setMinDist(minDist);
guil->setLevels(levels);
guil->setDp(dp);
guil->setMaxBufferSize(maxBufSize);
guil->setMinAngle(minAngle);
guil->setMaxAngle(maxAngle);
guil->setAngleStep(angleStep);
guil->setAngleThresh(angleThresh);
guil->setMinScale(minScale);
guil->setMaxScale(maxScale);
guil->setScaleStep(scaleStep);
guil->setScaleThresh(scaleThresh);
guil->setPosThresh(posThresh);
alg = guil;
}
vector<Vec4f> position;
TickMeter tm;
if (useGpu)
{
cuda::GpuMat d_templ(templ);
cuda::GpuMat d_image(image);
cuda::GpuMat d_position;
alg->setTemplate(d_templ);
tm.start();
alg->detect(d_image, d_position);
d_position.download(position);
tm.stop();
}
else
{
alg->setTemplate(templ);
tm.start();
alg->detect(image, position);
tm.stop();
}
cout << "Found : " << position.size() << " objects" << endl;
cout << "Detection time : " << tm.getTimeMilli() << " ms" << endl;
Mat out;
cv::cvtColor(image, out, COLOR_GRAY2BGR);
for (size_t i = 0; i < position.size(); ++i)
{
Point2f pos(position[i][0], position[i][1]);
float scale = position[i][2];
float angle = position[i][3];
RotatedRect rect;
rect.center = pos;
rect.size = Size2f(templ.cols * scale, templ.rows * scale);
rect.angle = angle;
Point2f pts[4];
rect.points(pts);
line(out, pts[0], pts[1], Scalar(0, 0, 255), 3);
line(out, pts[1], pts[2], Scalar(0, 0, 255), 3);
line(out, pts[2], pts[3], Scalar(0, 0, 255), 3);
line(out, pts[3], pts[0], Scalar(0, 0, 255), 3);
}
imshow("out", out);
waitKey();
return 0;
}
| [
"slacealic@gmail.com"
] | slacealic@gmail.com |
2f5ce45b57bd9ab95d8648f3c56ade71b5f9c3a4 | 119819aa5d4de077558e9bc6fa9b6fd49ce2811d | /Sat842/Pytorch-iOS-Device/libs-no-caffe-ios/include/torch/csrc/autograd/generated/VariableType.h | ea31ecc5f8dfd2390d1582f431e230266f10c6f0 | [
"MIT"
] | permissive | xta0/Sat842 | bec1f858acc73300ff47b733b977c2441b004045 | 635c1bb469ef8f71d0a66bc7b11f19ba4c6ac45c | refs/heads/master | 2020-06-18T09:12:46.904729 | 2019-08-18T03:53:48 | 2019-08-18T03:53:48 | 196,246,831 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 131,005 | h | #pragma once
// @generated from tools/autograd/templates/VariableType.h
#include <ATen/ATen.h>
#include <c10/util/intrusive_ptr.h>
#include <torch/csrc/WindowsTorchApiMacro.h>
#include <cstdint> // for size_t
#include <functional> // for function
#include <memory> // for unique_ptr
#include <string>
#include <vector>
namespace at {
struct Quantizer;
};
namespace torch { namespace autograd {
struct Variable;
using at::Context;
using at::Device;
#ifdef BUILD_NAMEDTENSOR
using at::Dimname;
using at::DimnameList;
#endif
using at::Generator;
using at::IntArrayRef;
using at::MemoryFormat;
using at::QScheme;
using at::Scalar;
using at::ScalarType;
using at::Storage;
using at::Tensor;
using at::TensorList;
using at::TensorOptions;
using at::Quantizer;
// This is temporary typedef to enable Quantizer in aten native function API
// we'll remove them when we are actually exposing Quantizer class
// to frontend
using ConstQuantizerPtr = const c10::intrusive_ptr<Quantizer>&;
using c10::optional;
struct TORCH_API VariableType final {
static std::vector<at::DeprecatedTypeProperties*> allCUDATypes();
static std::vector<at::DeprecatedTypeProperties*> allCPUTypes();
static Tensor __and__(const Tensor & self, Scalar other) ;
static Tensor __and__(const Tensor & self, const Tensor & other) ;
static Tensor & __iand__(Tensor & self, Scalar other) ;
static Tensor & __iand__(Tensor & self, const Tensor & other) ;
static Tensor & __ilshift__(Tensor & self, Scalar other) ;
static Tensor & __ilshift__(Tensor & self, const Tensor & other) ;
static Tensor & __ior__(Tensor & self, Scalar other) ;
static Tensor & __ior__(Tensor & self, const Tensor & other) ;
static Tensor & __irshift__(Tensor & self, Scalar other) ;
static Tensor & __irshift__(Tensor & self, const Tensor & other) ;
static Tensor & __ixor__(Tensor & self, Scalar other) ;
static Tensor & __ixor__(Tensor & self, const Tensor & other) ;
static Tensor __lshift__(const Tensor & self, Scalar other) ;
static Tensor __lshift__(const Tensor & self, const Tensor & other) ;
static Tensor __or__(const Tensor & self, Scalar other) ;
static Tensor __or__(const Tensor & self, const Tensor & other) ;
static Tensor __rshift__(const Tensor & self, Scalar other) ;
static Tensor __rshift__(const Tensor & self, const Tensor & other) ;
static Tensor __xor__(const Tensor & self, Scalar other) ;
static Tensor __xor__(const Tensor & self, const Tensor & other) ;
static Tensor _adaptive_avg_pool2d(const Tensor & self, IntArrayRef output_size) ;
static Tensor _adaptive_avg_pool2d_backward(const Tensor & grad_output, const Tensor & self) ;
static Tensor _addmm(const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor & _addmm_(Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor & _addmm_out(Tensor & out, const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor _addr(const Tensor & self, const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) ;
static Tensor & _addr_(Tensor & self, const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) ;
static Tensor & _addr_out(Tensor & out, const Tensor & self, const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) ;
static Tensor & _baddbmm_mkl_(Tensor & self, const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) ;
static std::tuple<Tensor,Tensor,Tensor,int64_t> _batch_norm_impl_index(const Tensor & input, const Tensor & weight, const Tensor & bias, const Tensor & running_mean, const Tensor & running_var, bool training, double momentum, double eps, bool cudnn_enabled) ;
static std::tuple<Tensor,Tensor,Tensor> _batch_norm_impl_index_backward(int64_t impl_index, const Tensor & input, const Tensor & grad_output, const Tensor & weight, const Tensor & running_mean, const Tensor & running_var, const Tensor & save_mean, const Tensor & save_var_transform, bool train, double eps, std::array<bool,3> output_mask) ;
static Tensor _cast_Byte(const Tensor & self, bool non_blocking) ;
static Tensor _cast_Char(const Tensor & self, bool non_blocking) ;
static Tensor _cast_Double(const Tensor & self, bool non_blocking) ;
static Tensor _cast_Float(const Tensor & self, bool non_blocking) ;
static Tensor _cast_Half(const Tensor & self, bool non_blocking) ;
static Tensor _cast_Int(const Tensor & self, bool non_blocking) ;
static Tensor _cast_Long(const Tensor & self, bool non_blocking) ;
static Tensor _cast_Short(const Tensor & self, bool non_blocking) ;
static Tensor _cat(TensorList tensors, int64_t dim) ;
static Tensor & _cat_out(Tensor & out, TensorList tensors, int64_t dim) ;
static Tensor _cdist_backward(const Tensor & grad, const Tensor & x1, const Tensor & x2, double p, const Tensor & cdist) ;
static Tensor _cholesky_helper(const Tensor & self, bool upper) ;
static Tensor _cholesky_solve_helper(const Tensor & self, const Tensor & A, bool upper) ;
static Tensor & _coalesced_(Tensor & self, bool coalesced) ;
static Tensor _convolution(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool transposed, IntArrayRef output_padding, int64_t groups, bool benchmark, bool deterministic, bool cudnn_enabled) ;
static std::tuple<Tensor,Tensor,Tensor> _convolution_double_backward(const Tensor & ggI, const Tensor & ggW, const Tensor & ggb, const Tensor & gO, const Tensor & weight, const Tensor & self, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool transposed, IntArrayRef output_padding, int64_t groups, bool benchmark, bool deterministic, bool cudnn_enabled, std::array<bool,3> output_mask) ;
static Tensor _convolution_nogroup(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool transposed, IntArrayRef output_padding) ;
static Tensor _copy_from(const Tensor & self, const Tensor & dst, bool non_blocking) ;
static std::tuple<Tensor,Tensor> _ctc_loss(const Tensor & log_probs, const Tensor & targets, IntArrayRef input_lengths, IntArrayRef target_lengths, int64_t blank, bool zero_infinity) ;
static Tensor _ctc_loss_backward(const Tensor & grad, const Tensor & log_probs, const Tensor & targets, IntArrayRef input_lengths, IntArrayRef target_lengths, const Tensor & neg_log_likelihood, const Tensor & log_alpha, int64_t blank, bool zero_infinity) ;
static std::tuple<Tensor,Tensor> _cudnn_ctc_loss(const Tensor & log_probs, const Tensor & targets, IntArrayRef input_lengths, IntArrayRef target_lengths, int64_t blank, bool deterministic, bool zero_infinity) ;
static Tensor _cudnn_init_dropout_state(double dropout, bool train, int64_t dropout_seed, const TensorOptions & options) ;
static std::tuple<Tensor,Tensor,Tensor,Tensor,Tensor> _cudnn_rnn(const Tensor & input, TensorList weight, int64_t weight_stride0, const Tensor & weight_buf, const Tensor & hx, const Tensor & cx, int64_t mode, int64_t hidden_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, IntArrayRef batch_sizes, const Tensor & dropout_state) ;
static std::tuple<Tensor,Tensor,Tensor,std::vector<Tensor>> _cudnn_rnn_backward(const Tensor & input, TensorList weight, int64_t weight_stride0, const Tensor & weight_buf, const Tensor & hx, const Tensor & cx, const Tensor & output, const Tensor & grad_output, const Tensor & grad_hy, const Tensor & grad_cy, int64_t mode, int64_t hidden_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, IntArrayRef batch_sizes, const Tensor & dropout_state, const Tensor & reserve, std::array<bool,4> output_mask) ;
static Tensor _cudnn_rnn_flatten_weight(TensorList weight_arr, int64_t weight_stride0, int64_t input_size, int64_t mode, int64_t hidden_size, int64_t num_layers, bool batch_first, bool bidirectional) ;
static void _cufft_clear_plan_cache(int64_t device_index) ;
static int64_t _cufft_get_plan_cache_max_size(int64_t device_index) ;
static int64_t _cufft_get_plan_cache_size(int64_t device_index) ;
static void _cufft_set_plan_cache_max_size(int64_t device_index, int64_t max_size) ;
static Tensor _cumprod(const Tensor & self, int64_t dim) ;
static Tensor & _cumprod_out(Tensor & out, const Tensor & self, int64_t dim) ;
static Tensor _cumsum(const Tensor & self, int64_t dim) ;
static Tensor & _cumsum_out(Tensor & out, const Tensor & self, int64_t dim) ;
static int64_t _debug_has_internal_overlap(const Tensor & self) ;
static Tensor _dequantize_linear(const Tensor & self, double scale, int64_t zero_point, ScalarType dtype) ;
static int64_t _dimI(const Tensor & self) ;
static int64_t _dimV(const Tensor & self) ;
static Tensor _dim_arange(const Tensor & like, int64_t dim) ;
static Tensor _dirichlet_grad(const Tensor & x, const Tensor & alpha, const Tensor & total) ;
static std::tuple<Tensor,Tensor,Tensor,Tensor> _embedding_bag(const Tensor & weight, const Tensor & indices, const Tensor & offsets, bool scale_grad_by_freq, int64_t mode, bool sparse, const Tensor & per_sample_weights) ;
static Tensor _embedding_bag_backward(const Tensor & grad, const Tensor & indices, const Tensor & offsets, const Tensor & offset2bag, const Tensor & bag_size, const Tensor & maximum_indices, int64_t num_weights, bool scale_grad_by_freq, int64_t mode, bool sparse, const Tensor & per_sample_weights) ;
static Tensor _embedding_bag_dense_backward(const Tensor & grad, const Tensor & indices, const Tensor & offsets, const Tensor & offset2bag, const Tensor & bag_size, const Tensor & maximum_indices, int64_t num_weights, bool scale_grad_by_freq, int64_t mode, const Tensor & per_sample_weights) ;
static Tensor _embedding_bag_per_sample_weights_backward(const Tensor & grad, const Tensor & weight, const Tensor & indices, const Tensor & offsets, const Tensor & offset2bag, int64_t mode) ;
static Tensor _embedding_bag_sparse_backward(const Tensor & grad, const Tensor & indices, const Tensor & offsets, const Tensor & offset2bag, const Tensor & bag_size, int64_t num_weights, bool scale_grad_by_freq, int64_t mode, const Tensor & per_sample_weights) ;
static Tensor _empty_affine_quantized(IntArrayRef size, const TensorOptions & options, double scale, int64_t zero_point, c10::optional<MemoryFormat> memory_format) ;
static Tensor _fft_with_size(const Tensor & self, int64_t signal_ndim, bool complex_input, bool complex_output, bool inverse, IntArrayRef checked_signal_sizes, bool normalized, bool onesided, IntArrayRef output_sizes) ;
static std::tuple<Tensor,Tensor> _fused_dropout(const Tensor & self, double p, Generator * generator) ;
static Tensor _gather_sparse_backward(const Tensor & self, int64_t dim, const Tensor & index, const Tensor & grad) ;
static bool _has_compatible_shallow_copy_type(const Tensor & self, const Tensor & from) ;
static Tensor & _index_copy_(Tensor & self, int64_t dim, const Tensor & index, const Tensor & source) ;
static Tensor & _index_put_impl_(Tensor & self, TensorList indices, const Tensor & values, bool accumulate, bool unsafe) ;
static Tensor _indices(const Tensor & self) ;
static Tensor _inverse_helper(const Tensor & self) ;
static Scalar _local_scalar_dense(const Tensor & self) ;
static Tensor _log_softmax(const Tensor & self, int64_t dim, bool half_to_float) ;
static Tensor _log_softmax_backward_data(const Tensor & grad_output, const Tensor & output, int64_t dim, const Tensor & self) ;
static Tensor _lu_solve_helper(const Tensor & self, const Tensor & LU_data, const Tensor & LU_pivots) ;
static std::tuple<Tensor,Tensor,Tensor> _lu_with_info(const Tensor & self, bool pivot, bool check_errors) ;
static Tensor _masked_scale(const Tensor & self, const Tensor & mask, double scale) ;
static std::tuple<Tensor,Tensor> _max(const Tensor & self, int64_t dim, bool keepdim) ;
static std::tuple<Tensor &,Tensor &> _max_out(Tensor & max, Tensor & max_indices, const Tensor & self, int64_t dim, bool keepdim) ;
static std::tuple<Tensor,Tensor> _min(const Tensor & self, int64_t dim, bool keepdim) ;
static std::tuple<Tensor &,Tensor &> _min_out(Tensor & min, Tensor & min_indices, const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor _mkldnn_reshape(const Tensor & self, IntArrayRef shape) ;
static Tensor _mkldnn_transpose(const Tensor & self, int64_t dim0, int64_t dim1) ;
static Tensor & _mkldnn_transpose_(Tensor & self, int64_t dim0, int64_t dim1) ;
static std::tuple<Tensor,Tensor> _mode(const Tensor & self, int64_t dim, bool keepdim) ;
static std::tuple<Tensor &,Tensor &> _mode_out(Tensor & values, Tensor & indices, const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor _multinomial_alias_draw(const Tensor & J, const Tensor & q, int64_t num_samples, Generator * generator) ;
static std::tuple<Tensor,Tensor> _multinomial_alias_setup(const Tensor & probs) ;
static bool _nnpack_available() ;
static Tensor _nnpack_spatial_convolution(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef padding) ;
static std::tuple<Tensor,Tensor,Tensor> _nnpack_spatial_convolution_backward(const Tensor & input, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, std::array<bool,3> output_mask) ;
static Tensor _nnpack_spatial_convolution_backward_input(const Tensor & input, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding) ;
static Tensor _nnpack_spatial_convolution_backward_weight(const Tensor & input, IntArrayRef weightsize, const Tensor & grad_output, IntArrayRef padding) ;
static int64_t _nnz(const Tensor & self) ;
static std::tuple<Tensor,Tensor> _pack_padded_sequence(const Tensor & input, const Tensor & lengths, bool batch_first) ;
static Tensor _pack_padded_sequence_backward(const Tensor & grad, IntArrayRef input_size, const Tensor & batch_sizes, bool batch_first) ;
static std::tuple<Tensor,Tensor> _pad_packed_sequence(const Tensor & data, const Tensor & batch_sizes, bool batch_first, Scalar padding_value, int64_t total_length) ;
static Tensor _pdist_backward(const Tensor & grad, const Tensor & self, double p, const Tensor & pdist) ;
static Tensor _pdist_forward(const Tensor & self, double p) ;
static Tensor _per_tensor_affine_qtensor(const Tensor & self, double scale, int64_t zero_point) ;
static std::tuple<Tensor,Tensor> _qr_helper(const Tensor & self, bool some) ;
static Tensor _reshape_from_tensor(const Tensor & self, const Tensor & shape) ;
static Tensor _s_where(const Tensor & condition, const Tensor & self, const Tensor & other) ;
static Tensor _sample_dirichlet(const Tensor & self, Generator * generator) ;
static Tensor _shape_as_tensor(const Tensor & self) ;
static std::tuple<Tensor,Tensor> _sobol_engine_draw(const Tensor & quasi, int64_t n, const Tensor & sobolstate, int64_t dimension, int64_t num_generated, c10::optional<ScalarType> dtype) ;
static Tensor & _sobol_engine_ff_(Tensor & self, int64_t n, const Tensor & sobolstate, int64_t dimension, int64_t num_generated) ;
static Tensor & _sobol_engine_initialize_state_(Tensor & self, int64_t dimension) ;
static Tensor & _sobol_engine_scramble_(Tensor & self, const Tensor & ltm, int64_t dimension) ;
static Tensor _softmax(const Tensor & self, int64_t dim, bool half_to_float) ;
static Tensor _softmax_backward_data(const Tensor & grad_output, const Tensor & output, int64_t dim, const Tensor & self) ;
static std::tuple<Tensor,Tensor> _solve_helper(const Tensor & self, const Tensor & A) ;
static Tensor & _sparse_add_out(Tensor & out, const Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor _sparse_addmm(const Tensor & self, const Tensor & sparse, const Tensor & dense, Scalar beta, Scalar alpha) ;
static Tensor _sparse_coo_tensor_unsafe(const Tensor & indices, const Tensor & values, IntArrayRef size, const TensorOptions & options) ;
static Tensor _sparse_coo_tensor_with_dims(int64_t sparse_dim, int64_t dense_dim, IntArrayRef size, const TensorOptions & options) ;
static Tensor _sparse_coo_tensor_with_dims_and_tensors(int64_t sparse_dim, int64_t dense_dim, IntArrayRef size, const Tensor & indices, const Tensor & values, const TensorOptions & options) ;
static Tensor & _sparse_dense_add_out(Tensor & out, const Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor & _sparse_div_scalar_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & _sparse_div_zerodim_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor _sparse_mm(const Tensor & sparse, const Tensor & dense) ;
static Tensor & _sparse_mul_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor & _sparse_mul_scalar_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & _sparse_mul_zerodim_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor _sparse_sum(const Tensor & self) ;
static Tensor _sparse_sum(const Tensor & self, ScalarType dtype) ;
static Tensor _sparse_sum(const Tensor & self, IntArrayRef dim) ;
static Tensor _sparse_sum(const Tensor & self, IntArrayRef dim, ScalarType dtype) ;
static Tensor _sparse_sum_backward(const Tensor & grad, const Tensor & self, IntArrayRef dim) ;
static Tensor _standard_gamma(const Tensor & self, Generator * generator) ;
static Tensor _standard_gamma_grad(const Tensor & self, const Tensor & output) ;
static Tensor _std(const Tensor & self, bool unbiased) ;
static std::tuple<Tensor,Tensor,Tensor> _svd_helper(const Tensor & self, bool some, bool compute_uv) ;
static std::tuple<Tensor,Tensor> _symeig_helper(const Tensor & self, bool eigenvectors, bool upper) ;
static std::tuple<Tensor,Tensor> _thnn_fused_gru_cell(const Tensor & input_gates, const Tensor & hidden_gates, const Tensor & hx, const Tensor & input_bias, const Tensor & hidden_bias) ;
static std::tuple<Tensor,Tensor,Tensor,Tensor,Tensor> _thnn_fused_gru_cell_backward(const Tensor & grad_hy, const Tensor & workspace, bool has_bias) ;
static std::tuple<Tensor,Tensor,Tensor> _thnn_fused_lstm_cell(const Tensor & input_gates, const Tensor & hidden_gates, const Tensor & cx, const Tensor & input_bias, const Tensor & hidden_bias) ;
static std::tuple<Tensor,Tensor,Tensor,Tensor,Tensor> _thnn_fused_lstm_cell_backward(const Tensor & grad_hy, const Tensor & grad_cy, const Tensor & cx, const Tensor & cy, const Tensor & workspace, bool has_bias) ;
static std::tuple<Tensor,Tensor> _triangular_solve_helper(const Tensor & self, const Tensor & A, bool upper, bool transpose, bool unitriangular) ;
static Tensor _trilinear(const Tensor & i1, const Tensor & i2, const Tensor & i3, IntArrayRef expand1, IntArrayRef expand2, IntArrayRef expand3, IntArrayRef sumdim, int64_t unroll_dim) ;
static std::tuple<Tensor,Tensor> _unique(const Tensor & self, bool sorted, bool return_inverse) ;
static std::tuple<Tensor,Tensor,Tensor> _unique2(const Tensor & self, bool sorted, bool return_inverse, bool return_counts) ;
static Tensor _unsafe_view(const Tensor & self, IntArrayRef size) ;
static Tensor _values(const Tensor & self) ;
static Tensor _var(const Tensor & self, bool unbiased) ;
static Tensor _weight_norm(const Tensor & v, const Tensor & g, int64_t dim) ;
static std::tuple<Tensor,Tensor> _weight_norm_cuda_interface(const Tensor & v, const Tensor & g, int64_t dim) ;
static std::tuple<Tensor,Tensor> _weight_norm_cuda_interface_backward(const Tensor & grad_w, const Tensor & saved_v, const Tensor & saved_g, const Tensor & saved_norms, int64_t dim) ;
static std::tuple<Tensor,Tensor> _weight_norm_differentiable_backward(const Tensor & grad_w, const Tensor & saved_v, const Tensor & saved_g, const Tensor & saved_norms, int64_t dim) ;
static Tensor abs(const Tensor & self) ;
static Tensor & abs_(Tensor & self) ;
static Tensor & abs_out(Tensor & out, const Tensor & self) ;
static Tensor acos(const Tensor & self) ;
static Tensor & acos_(Tensor & self) ;
static Tensor & acos_out(Tensor & out, const Tensor & self) ;
static Tensor adaptive_avg_pool1d(const Tensor & self, IntArrayRef output_size) ;
static Tensor adaptive_avg_pool2d(const Tensor & self, IntArrayRef output_size) ;
static Tensor & adaptive_avg_pool2d_out(Tensor & out, const Tensor & self, IntArrayRef output_size) ;
static Tensor adaptive_avg_pool3d(const Tensor & self, IntArrayRef output_size) ;
static Tensor adaptive_avg_pool3d_backward(const Tensor & grad_output, const Tensor & self) ;
static Tensor & adaptive_avg_pool3d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self) ;
static Tensor & adaptive_avg_pool3d_out(Tensor & out, const Tensor & self, IntArrayRef output_size) ;
static std::tuple<Tensor,Tensor> adaptive_max_pool1d(const Tensor & self, IntArrayRef output_size) ;
static std::tuple<Tensor,Tensor> adaptive_max_pool2d(const Tensor & self, IntArrayRef output_size) ;
static Tensor adaptive_max_pool2d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & indices) ;
static Tensor & adaptive_max_pool2d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & indices) ;
static std::tuple<Tensor &,Tensor &> adaptive_max_pool2d_out(Tensor & out, Tensor & indices, const Tensor & self, IntArrayRef output_size) ;
static std::tuple<Tensor,Tensor> adaptive_max_pool3d(const Tensor & self, IntArrayRef output_size) ;
static Tensor adaptive_max_pool3d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & indices) ;
static Tensor & adaptive_max_pool3d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & indices) ;
static std::tuple<Tensor &,Tensor &> adaptive_max_pool3d_out(Tensor & out, Tensor & indices, const Tensor & self, IntArrayRef output_size) ;
static Tensor add(const Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor add(const Tensor & self, Scalar other, Scalar alpha) ;
static Tensor & add_(Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor & add_(Tensor & self, Scalar other, Scalar alpha) ;
static Tensor & add_out(Tensor & out, const Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor addbmm(const Tensor & self, const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) ;
static Tensor & addbmm_(Tensor & self, const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) ;
static Tensor & addbmm_out(Tensor & out, const Tensor & self, const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) ;
static Tensor addcdiv(const Tensor & self, const Tensor & tensor1, const Tensor & tensor2, Scalar value) ;
static Tensor & addcdiv_(Tensor & self, const Tensor & tensor1, const Tensor & tensor2, Scalar value) ;
static Tensor & addcdiv_out(Tensor & out, const Tensor & self, const Tensor & tensor1, const Tensor & tensor2, Scalar value) ;
static Tensor addcmul(const Tensor & self, const Tensor & tensor1, const Tensor & tensor2, Scalar value) ;
static Tensor & addcmul_(Tensor & self, const Tensor & tensor1, const Tensor & tensor2, Scalar value) ;
static Tensor & addcmul_out(Tensor & out, const Tensor & self, const Tensor & tensor1, const Tensor & tensor2, Scalar value) ;
static Tensor addmm(const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor & addmm_(Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor & addmm_out(Tensor & out, const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor addmv(const Tensor & self, const Tensor & mat, const Tensor & vec, Scalar beta, Scalar alpha) ;
static Tensor & addmv_(Tensor & self, const Tensor & mat, const Tensor & vec, Scalar beta, Scalar alpha) ;
static Tensor & addmv_out(Tensor & out, const Tensor & self, const Tensor & mat, const Tensor & vec, Scalar beta, Scalar alpha) ;
static Tensor addr(const Tensor & self, const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) ;
static Tensor & addr_(Tensor & self, const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) ;
static Tensor & addr_out(Tensor & out, const Tensor & self, const Tensor & vec1, const Tensor & vec2, Scalar beta, Scalar alpha) ;
static Tensor affine_grid_generator(const Tensor & theta, IntArrayRef size) ;
static Tensor affine_grid_generator_backward(const Tensor & grad, IntArrayRef size) ;
static Tensor alias(const Tensor & self) ;
static Tensor all(const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor all(const Tensor & self) ;
static Tensor & all_out(Tensor & out, const Tensor & self, int64_t dim, bool keepdim) ;
static bool allclose(const Tensor & self, const Tensor & other, double rtol, double atol, bool equal_nan) ;
static Tensor alpha_dropout(const Tensor & input, double p, bool train) ;
static Tensor & alpha_dropout_(Tensor & self, double p, bool train) ;
static Tensor any(const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor any(const Tensor & self) ;
static Tensor & any_out(Tensor & out, const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor arange(Scalar end, const TensorOptions & options) ;
static Tensor arange(Scalar start, Scalar end, const TensorOptions & options) ;
static Tensor arange(Scalar start, Scalar end, Scalar step, const TensorOptions & options) ;
static Tensor & arange_out(Tensor & out, Scalar end) ;
static Tensor & arange_out(Tensor & out, Scalar start, Scalar end, Scalar step) ;
static Tensor argmax(const Tensor & self, c10::optional<int64_t> dim, bool keepdim) ;
static Tensor argmin(const Tensor & self, c10::optional<int64_t> dim, bool keepdim) ;
static Tensor argsort(const Tensor & self, int64_t dim, bool descending) ;
static Tensor as_strided(const Tensor & self, IntArrayRef size, IntArrayRef stride, c10::optional<int64_t> storage_offset) ;
static Tensor & as_strided_(Tensor & self, IntArrayRef size, IntArrayRef stride, c10::optional<int64_t> storage_offset) ;
static Tensor asin(const Tensor & self) ;
static Tensor & asin_(Tensor & self) ;
static Tensor & asin_out(Tensor & out, const Tensor & self) ;
static Tensor atan(const Tensor & self) ;
static Tensor atan2(const Tensor & self, const Tensor & other) ;
static Tensor & atan2_(Tensor & self, const Tensor & other) ;
static Tensor & atan2_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor & atan_(Tensor & self) ;
static Tensor & atan_out(Tensor & out, const Tensor & self) ;
static Tensor avg_pool1d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad) ;
static Tensor avg_pool2d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static Tensor avg_pool2d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static Tensor & avg_pool2d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static Tensor & avg_pool2d_out(Tensor & out, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static Tensor avg_pool3d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static Tensor avg_pool3d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static Tensor & avg_pool3d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static Tensor & avg_pool3d_out(Tensor & out, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, bool ceil_mode, bool count_include_pad, c10::optional<int64_t> divisor_override) ;
static void backward(const Tensor & self, const Tensor & gradient, bool keep_graph, bool create_graph) ;
static Tensor baddbmm(const Tensor & self, const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) ;
static Tensor & baddbmm_(Tensor & self, const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) ;
static Tensor & baddbmm_out(Tensor & out, const Tensor & self, const Tensor & batch1, const Tensor & batch2, Scalar beta, Scalar alpha) ;
static Tensor bartlett_window(int64_t window_length, const TensorOptions & options) ;
static Tensor bartlett_window(int64_t window_length, bool periodic, const TensorOptions & options) ;
static Tensor batch_norm(const Tensor & input, const Tensor & weight, const Tensor & bias, const Tensor & running_mean, const Tensor & running_var, bool training, double momentum, double eps, bool cudnn_enabled) ;
static Tensor batch_norm_backward_elemt(const Tensor & grad_out, const Tensor & input, const Tensor & mean, const Tensor & invstd, const Tensor & weight, const Tensor & mean_dy, const Tensor & mean_dy_xmu) ;
static std::tuple<Tensor,Tensor,Tensor,Tensor> batch_norm_backward_reduce(const Tensor & grad_out, const Tensor & input, const Tensor & mean, const Tensor & invstd, bool input_g, bool weight_g, bool bias_g) ;
static Tensor batch_norm_elemt(const Tensor & input, const Tensor & weight, const Tensor & bias, const Tensor & mean, const Tensor & invstd, double eps) ;
static std::tuple<Tensor,Tensor> batch_norm_gather_stats(const Tensor & input, const Tensor & mean, const Tensor & invstd, const Tensor & running_mean, const Tensor & running_var, double momentum, double eps, int64_t count) ;
static std::tuple<Tensor,Tensor> batch_norm_gather_stats_with_counts(const Tensor & input, const Tensor & mean, const Tensor & invstd, const Tensor & running_mean, const Tensor & running_var, double momentum, double eps, IntArrayRef counts) ;
static std::tuple<Tensor,Tensor> batch_norm_stats(const Tensor & input, double eps) ;
static std::tuple<Tensor,Tensor> batch_norm_update_stats(const Tensor & input, const Tensor & running_mean, const Tensor & running_var, double momentum) ;
static Tensor bernoulli(const Tensor & self, Generator * generator) ;
static Tensor bernoulli(const Tensor & self, double p, Generator * generator) ;
static Tensor & bernoulli_(Tensor & self, const Tensor & p, Generator * generator) ;
static Tensor & bernoulli_(Tensor & self, double p, Generator * generator) ;
static Tensor & bernoulli_out(Tensor & out, const Tensor & self, Generator * generator) ;
static Tensor bilinear(const Tensor & input1, const Tensor & input2, const Tensor & weight, const Tensor & bias) ;
static Tensor binary_cross_entropy(const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction) ;
static Tensor binary_cross_entropy_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction) ;
static Tensor & binary_cross_entropy_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction) ;
static Tensor & binary_cross_entropy_out(Tensor & out, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction) ;
static Tensor binary_cross_entropy_with_logits(const Tensor & self, const Tensor & target, const Tensor & weight, const Tensor & pos_weight, int64_t reduction) ;
static Tensor binary_cross_entropy_with_logits_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, const Tensor & weight, const Tensor & pos_weight, int64_t reduction) ;
static Tensor bincount(const Tensor & self, const Tensor & weights, int64_t minlength) ;
static Tensor bitwise_not(const Tensor & self) ;
static Tensor & bitwise_not_(Tensor & self) ;
static Tensor & bitwise_not_out(Tensor & out, const Tensor & self) ;
static Tensor blackman_window(int64_t window_length, const TensorOptions & options) ;
static Tensor blackman_window(int64_t window_length, bool periodic, const TensorOptions & options) ;
static Tensor bmm(const Tensor & self, const Tensor & mat2) ;
static Tensor & bmm_out(Tensor & out, const Tensor & self, const Tensor & mat2) ;
static std::vector<Tensor> broadcast_tensors(TensorList tensors) ;
static Tensor cartesian_prod(TensorList tensors) ;
static Tensor cat(TensorList tensors, int64_t dim) ;
static Tensor & cat_out(Tensor & out, TensorList tensors, int64_t dim) ;
static Tensor & cauchy_(Tensor & self, double median, double sigma, Generator * generator) ;
static Tensor cdist(const Tensor & x1, const Tensor & x2, double p) ;
static Tensor ceil(const Tensor & self) ;
static Tensor & ceil_(Tensor & self) ;
static Tensor & ceil_out(Tensor & out, const Tensor & self) ;
static Tensor celu(const Tensor & self, Scalar alpha) ;
static Tensor & celu_(Tensor & self, Scalar alpha) ;
static Tensor chain_matmul(TensorList matrices) ;
static Tensor cholesky(const Tensor & self, bool upper) ;
static Tensor cholesky_inverse(const Tensor & self, bool upper) ;
static Tensor & cholesky_inverse_out(Tensor & out, const Tensor & self, bool upper) ;
static Tensor & cholesky_out(Tensor & out, const Tensor & self, bool upper) ;
static Tensor cholesky_solve(const Tensor & self, const Tensor & input2, bool upper) ;
static Tensor & cholesky_solve_out(Tensor & out, const Tensor & self, const Tensor & input2, bool upper) ;
static std::vector<Tensor> chunk(const Tensor & self, int64_t chunks, int64_t dim) ;
static Tensor clamp(const Tensor & self, c10::optional<Scalar> min, c10::optional<Scalar> max) ;
static Tensor & clamp_(Tensor & self, c10::optional<Scalar> min, c10::optional<Scalar> max) ;
static Tensor clamp_max(const Tensor & self, Scalar max) ;
static Tensor & clamp_max_(Tensor & self, Scalar max) ;
static Tensor & clamp_max_out(Tensor & out, const Tensor & self, Scalar max) ;
static Tensor clamp_min(const Tensor & self, Scalar min) ;
static Tensor & clamp_min_(Tensor & self, Scalar min) ;
static Tensor & clamp_min_out(Tensor & out, const Tensor & self, Scalar min) ;
static Tensor & clamp_out(Tensor & out, const Tensor & self, c10::optional<Scalar> min, c10::optional<Scalar> max) ;
static Tensor clone(const Tensor & self) ;
static Tensor coalesce(const Tensor & self) ;
static Tensor col2im(const Tensor & self, IntArrayRef output_size, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor col2im_backward(const Tensor & grad_output, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor & col2im_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor & col2im_out(Tensor & out, const Tensor & self, IntArrayRef output_size, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor combinations(const Tensor & self, int64_t r, bool with_replacement) ;
static Tensor constant_pad_nd(const Tensor & self, IntArrayRef pad, Scalar value) ;
static Tensor contiguous(const Tensor & self, MemoryFormat memory_format) ;
static Tensor conv1d(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, int64_t groups) ;
static Tensor conv2d(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, int64_t groups) ;
static Tensor conv3d(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, int64_t groups) ;
static Tensor conv_tbc(const Tensor & self, const Tensor & weight, const Tensor & bias, int64_t pad) ;
static std::tuple<Tensor,Tensor,Tensor> conv_tbc_backward(const Tensor & self, const Tensor & input, const Tensor & weight, const Tensor & bias, int64_t pad) ;
static Tensor conv_transpose1d(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, int64_t groups, IntArrayRef dilation) ;
static Tensor conv_transpose2d(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, int64_t groups, IntArrayRef dilation) ;
static Tensor conv_transpose3d(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, int64_t groups, IntArrayRef dilation) ;
static Tensor convolution(const Tensor & input, const Tensor & weight, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool transposed, IntArrayRef output_padding, int64_t groups) ;
static Tensor & copy_(Tensor & self, const Tensor & src, bool non_blocking) ;
static Tensor & copy_sparse_to_sparse_(Tensor & self, const Tensor & src, bool non_blocking) ;
static Tensor cos(const Tensor & self) ;
static Tensor & cos_(Tensor & self) ;
static Tensor & cos_out(Tensor & out, const Tensor & self) ;
static Tensor cosh(const Tensor & self) ;
static Tensor & cosh_(Tensor & self) ;
static Tensor & cosh_out(Tensor & out, const Tensor & self) ;
static Tensor cosine_embedding_loss(const Tensor & input1, const Tensor & input2, const Tensor & target, double margin, int64_t reduction) ;
static Tensor cosine_similarity(const Tensor & x1, const Tensor & x2, int64_t dim, double eps) ;
static Tensor cross(const Tensor & self, const Tensor & other, c10::optional<int64_t> dim) ;
static Tensor & cross_out(Tensor & out, const Tensor & self, const Tensor & other, c10::optional<int64_t> dim) ;
static Tensor ctc_loss(const Tensor & log_probs, const Tensor & targets, IntArrayRef input_lengths, IntArrayRef target_lengths, int64_t blank, int64_t reduction, bool zero_infinity) ;
static Tensor ctc_loss(const Tensor & log_probs, const Tensor & targets, const Tensor & input_lengths, const Tensor & target_lengths, int64_t blank, int64_t reduction, bool zero_infinity) ;
static Tensor cudnn_affine_grid_generator(const Tensor & theta, int64_t N, int64_t C, int64_t H, int64_t W) ;
static Tensor cudnn_affine_grid_generator_backward(const Tensor & grad, int64_t N, int64_t C, int64_t H, int64_t W) ;
static std::tuple<Tensor,Tensor,Tensor> cudnn_batch_norm(const Tensor & input, const Tensor & weight, const Tensor & bias, const Tensor & running_mean, const Tensor & running_var, bool training, double exponential_average_factor, double epsilon) ;
static std::tuple<Tensor,Tensor,Tensor> cudnn_batch_norm_backward(const Tensor & input, const Tensor & grad_output, const Tensor & weight, const Tensor & running_mean, const Tensor & running_var, const Tensor & save_mean, const Tensor & save_var, double epsilon) ;
static Tensor cudnn_convolution(const Tensor & self, const Tensor & weight, const Tensor & bias, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static std::tuple<Tensor,Tensor,Tensor> cudnn_convolution_backward(const Tensor & self, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic, std::array<bool,3> output_mask) ;
static Tensor cudnn_convolution_backward_bias(const Tensor & grad_output) ;
static Tensor cudnn_convolution_backward_input(IntArrayRef self_size, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor cudnn_convolution_backward_weight(IntArrayRef weight_size, const Tensor & grad_output, const Tensor & self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor cudnn_convolution_transpose(const Tensor & self, const Tensor & weight, const Tensor & bias, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static std::tuple<Tensor,Tensor,Tensor> cudnn_convolution_transpose_backward(const Tensor & self, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic, std::array<bool,3> output_mask) ;
static Tensor cudnn_convolution_transpose_backward_bias(const Tensor & grad_output) ;
static Tensor cudnn_convolution_transpose_backward_input(const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor cudnn_convolution_transpose_backward_weight(IntArrayRef weight_size, const Tensor & grad_output, const Tensor & self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor cudnn_grid_sampler(const Tensor & self, const Tensor & grid) ;
static std::tuple<Tensor,Tensor> cudnn_grid_sampler_backward(const Tensor & self, const Tensor & grid, const Tensor & grad_output) ;
static bool cudnn_is_acceptable(const Tensor & self) ;
static Tensor cumprod(const Tensor & self, int64_t dim, c10::optional<ScalarType> dtype) ;
static Tensor & cumprod_out(Tensor & out, const Tensor & self, int64_t dim, c10::optional<ScalarType> dtype) ;
static Tensor cumsum(const Tensor & self, int64_t dim, c10::optional<ScalarType> dtype) ;
static Tensor & cumsum_out(Tensor & out, const Tensor & self, int64_t dim, c10::optional<ScalarType> dtype) ;
static int64_t dense_dim(const Tensor & self) ;
static Tensor dequantize(const Tensor & self) ;
static Tensor det(const Tensor & self) ;
static Tensor detach(const Tensor & self) ;
static Tensor & detach_(Tensor & self) ;
static Tensor diag(const Tensor & self, int64_t diagonal) ;
static Tensor diag_embed(const Tensor & self, int64_t offset, int64_t dim1, int64_t dim2) ;
static Tensor & diag_out(Tensor & out, const Tensor & self, int64_t diagonal) ;
static Tensor diagflat(const Tensor & self, int64_t offset) ;
static Tensor diagonal(const Tensor & self, int64_t offset, int64_t dim1, int64_t dim2) ;
static Tensor digamma(const Tensor & self) ;
static Tensor & digamma_(Tensor & self) ;
static Tensor & digamma_out(Tensor & out, const Tensor & self) ;
static Tensor dist(const Tensor & self, const Tensor & other, Scalar p) ;
static Tensor div(const Tensor & self, const Tensor & other) ;
static Tensor div(const Tensor & self, Scalar other) ;
static Tensor & div_(Tensor & self, const Tensor & other) ;
static Tensor & div_(Tensor & self, Scalar other) ;
static Tensor & div_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor dot(const Tensor & self, const Tensor & tensor) ;
static Tensor & dot_out(Tensor & out, const Tensor & self, const Tensor & tensor) ;
static Tensor dropout(const Tensor & input, double p, bool train) ;
static Tensor & dropout_(Tensor & self, double p, bool train) ;
static std::tuple<Tensor,Tensor> eig(const Tensor & self, bool eigenvectors) ;
static std::tuple<Tensor &,Tensor &> eig_out(Tensor & e, Tensor & v, const Tensor & self, bool eigenvectors) ;
static Tensor einsum(std::string equation, TensorList tensors) ;
static Tensor elu(const Tensor & self, Scalar alpha, Scalar scale, Scalar input_scale) ;
static Tensor & elu_(Tensor & self, Scalar alpha, Scalar scale, Scalar input_scale) ;
static Tensor elu_backward(const Tensor & grad_output, Scalar alpha, Scalar scale, Scalar input_scale, const Tensor & output) ;
static Tensor & elu_backward_out(Tensor & grad_input, const Tensor & grad_output, Scalar alpha, Scalar scale, Scalar input_scale, const Tensor & output) ;
static Tensor & elu_out(Tensor & out, const Tensor & self, Scalar alpha, Scalar scale, Scalar input_scale) ;
static Tensor embedding(const Tensor & weight, const Tensor & indices, int64_t padding_idx, bool scale_grad_by_freq, bool sparse) ;
static Tensor embedding_backward(const Tensor & grad, const Tensor & indices, int64_t num_weights, int64_t padding_idx, bool scale_grad_by_freq, bool sparse) ;
static std::tuple<Tensor,Tensor,Tensor,Tensor> embedding_bag(const Tensor & weight, const Tensor & indices, const Tensor & offsets, bool scale_grad_by_freq, int64_t mode, bool sparse, const Tensor & per_sample_weights) ;
static Tensor embedding_dense_backward(const Tensor & grad_output, const Tensor & indices, int64_t num_weights, int64_t padding_idx, bool scale_grad_by_freq) ;
static Tensor & embedding_renorm_(Tensor & self, const Tensor & indices, double max_norm, double norm_type) ;
static Tensor embedding_sparse_backward(const Tensor & grad, const Tensor & indices, int64_t num_weights, int64_t padding_idx, bool scale_grad_by_freq) ;
static Tensor empty(IntArrayRef size, const TensorOptions & options, c10::optional<MemoryFormat> memory_format) ;
static Tensor empty_like(const Tensor & self) ;
static Tensor empty_like(const Tensor & self, const TensorOptions & options, c10::optional<MemoryFormat> memory_format) ;
static Tensor & empty_out(Tensor & out, IntArrayRef size, c10::optional<MemoryFormat> memory_format) ;
static Tensor empty_strided(IntArrayRef size, IntArrayRef stride, const TensorOptions & options) ;
static Tensor eq(const Tensor & self, Scalar other) ;
static Tensor eq(const Tensor & self, const Tensor & other) ;
static Tensor & eq_(Tensor & self, Scalar other) ;
static Tensor & eq_(Tensor & self, const Tensor & other) ;
static Tensor & eq_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & eq_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static bool equal(const Tensor & self, const Tensor & other) ;
static Tensor erf(const Tensor & self) ;
static Tensor & erf_(Tensor & self) ;
static Tensor & erf_out(Tensor & out, const Tensor & self) ;
static Tensor erfc(const Tensor & self) ;
static Tensor & erfc_(Tensor & self) ;
static Tensor & erfc_out(Tensor & out, const Tensor & self) ;
static Tensor erfinv(const Tensor & self) ;
static Tensor & erfinv_(Tensor & self) ;
static Tensor & erfinv_out(Tensor & out, const Tensor & self) ;
static Tensor exp(const Tensor & self) ;
static Tensor & exp_(Tensor & self) ;
static Tensor & exp_out(Tensor & out, const Tensor & self) ;
static Tensor expand(const Tensor & self, IntArrayRef size, bool implicit) ;
static Tensor expand_as(const Tensor & self, const Tensor & other) ;
static Tensor expm1(const Tensor & self) ;
static Tensor & expm1_(Tensor & self) ;
static Tensor & expm1_out(Tensor & out, const Tensor & self) ;
static Tensor & exponential_(Tensor & self, double lambd, Generator * generator) ;
static Tensor eye(int64_t n, const TensorOptions & options) ;
static Tensor eye(int64_t n, int64_t m, const TensorOptions & options) ;
static Tensor & eye_out(Tensor & out, int64_t n) ;
static Tensor & eye_out(Tensor & out, int64_t n, int64_t m) ;
static Tensor fake_quantize_per_tensor_affine(const Tensor & self, double scale, int64_t zero_point, int64_t quant_min, int64_t quant_max) ;
static Tensor fake_quantize_per_tensor_affine_backward(const Tensor & grad, const Tensor & self, double scale, int64_t zero_point, int64_t quant_min, int64_t quant_max) ;
static bool fbgemm_is_cpu_supported() ;
static Tensor fbgemm_linear_fp16_weight(const Tensor & input, const Tensor & packed_weight, const Tensor & bias) ;
static Tensor fbgemm_linear_fp16_weight_fp32_activation(const Tensor & input, const Tensor & packed_weight, const Tensor & bias) ;
static Tensor fbgemm_linear_int8_weight(const Tensor & input, const Tensor & weight, const Tensor & packed, const Tensor & col_offsets, Scalar weight_scale, Scalar weight_zero_point, const Tensor & bias) ;
static Tensor fbgemm_linear_int8_weight_fp32_activation(const Tensor & input, const Tensor & weight, const Tensor & packed, const Tensor & col_offsets, Scalar weight_scale, Scalar weight_zero_point, const Tensor & bias) ;
static std::tuple<Tensor,Tensor,double,int64_t> fbgemm_linear_quantize_weight(const Tensor & input) ;
static Tensor fbgemm_pack_gemm_matrix_fp16(const Tensor & input) ;
static Tensor fbgemm_pack_quantized_matrix(const Tensor & input) ;
static Tensor fbgemm_pack_quantized_matrix(const Tensor & input, int64_t K, int64_t N) ;
static Tensor feature_alpha_dropout(const Tensor & input, double p, bool train) ;
static Tensor & feature_alpha_dropout_(Tensor & self, double p, bool train) ;
static Tensor feature_dropout(const Tensor & input, double p, bool train) ;
static Tensor & feature_dropout_(Tensor & self, double p, bool train) ;
static Tensor fft(const Tensor & self, int64_t signal_ndim, bool normalized) ;
static Tensor & fill_(Tensor & self, Scalar value) ;
static Tensor & fill_(Tensor & self, const Tensor & value) ;
static Tensor & fill_diagonal_(Tensor & self, Scalar fill_value, bool wrap) ;
static Tensor flatten(const Tensor & self, int64_t start_dim, int64_t end_dim) ;
static Tensor flip(const Tensor & self, IntArrayRef dims) ;
static Tensor floor(const Tensor & self) ;
static Tensor & floor_(Tensor & self) ;
static Tensor & floor_out(Tensor & out, const Tensor & self) ;
static Tensor fmod(const Tensor & self, Scalar other) ;
static Tensor fmod(const Tensor & self, const Tensor & other) ;
static Tensor & fmod_(Tensor & self, Scalar other) ;
static Tensor & fmod_(Tensor & self, const Tensor & other) ;
static Tensor & fmod_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & fmod_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor frac(const Tensor & self) ;
static Tensor & frac_(Tensor & self) ;
static Tensor & frac_out(Tensor & out, const Tensor & self) ;
static std::tuple<Tensor,Tensor> fractional_max_pool2d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & random_samples) ;
static Tensor fractional_max_pool2d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & indices) ;
static Tensor & fractional_max_pool2d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & indices) ;
static std::tuple<Tensor &,Tensor &> fractional_max_pool2d_out(Tensor & output, Tensor & indices, const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & random_samples) ;
static std::tuple<Tensor,Tensor> fractional_max_pool3d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & random_samples) ;
static Tensor fractional_max_pool3d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & indices) ;
static Tensor & fractional_max_pool3d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & indices) ;
static std::tuple<Tensor &,Tensor &> fractional_max_pool3d_out(Tensor & output, Tensor & indices, const Tensor & self, IntArrayRef kernel_size, IntArrayRef output_size, const Tensor & random_samples) ;
static Tensor frobenius_norm(const Tensor & self) ;
static Tensor frobenius_norm(const Tensor & self, IntArrayRef dim, bool keepdim) ;
static Tensor & frobenius_norm_out(Tensor & out, const Tensor & self, IntArrayRef dim, bool keepdim) ;
static Tensor from_file(std::string filename, c10::optional<bool> shared, c10::optional<int64_t> size, const TensorOptions & options) ;
static Tensor full(IntArrayRef size, Scalar fill_value, const TensorOptions & options) ;
static Tensor full_like(const Tensor & self, Scalar fill_value) ;
static Tensor full_like(const Tensor & self, Scalar fill_value, const TensorOptions & options) ;
static Tensor & full_out(Tensor & out, IntArrayRef size, Scalar fill_value) ;
static Tensor gather(const Tensor & self, int64_t dim, const Tensor & index, bool sparse_grad) ;
static Tensor & gather_out(Tensor & out, const Tensor & self, int64_t dim, const Tensor & index, bool sparse_grad) ;
static Tensor ge(const Tensor & self, Scalar other) ;
static Tensor ge(const Tensor & self, const Tensor & other) ;
static Tensor & ge_(Tensor & self, Scalar other) ;
static Tensor & ge_(Tensor & self, const Tensor & other) ;
static Tensor & ge_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & ge_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor gelu(const Tensor & self) ;
static Tensor gelu_backward(const Tensor & grad, const Tensor & self) ;
static Tensor & geometric_(Tensor & self, double p, Generator * generator) ;
static std::tuple<Tensor,Tensor> geqrf(const Tensor & self) ;
static std::tuple<Tensor &,Tensor &> geqrf_out(Tensor & a, Tensor & tau, const Tensor & self) ;
static Tensor ger(const Tensor & self, const Tensor & vec2) ;
static Tensor & ger_out(Tensor & out, const Tensor & self, const Tensor & vec2) ;
static Tensor glu(const Tensor & self, int64_t dim) ;
static Tensor glu_backward(const Tensor & grad_output, const Tensor & self, int64_t dim) ;
static Tensor & glu_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, int64_t dim) ;
static Tensor & glu_out(Tensor & out, const Tensor & self, int64_t dim) ;
static Tensor grid_sampler(const Tensor & input, const Tensor & grid, int64_t interpolation_mode, int64_t padding_mode) ;
static Tensor grid_sampler_2d(const Tensor & input, const Tensor & grid, int64_t interpolation_mode, int64_t padding_mode) ;
static std::tuple<Tensor,Tensor> grid_sampler_2d_backward(const Tensor & grad_output, const Tensor & input, const Tensor & grid, int64_t interpolation_mode, int64_t padding_mode) ;
static Tensor grid_sampler_3d(const Tensor & input, const Tensor & grid, int64_t interpolation_mode, int64_t padding_mode) ;
static std::tuple<Tensor,Tensor> grid_sampler_3d_backward(const Tensor & grad_output, const Tensor & input, const Tensor & grid, int64_t interpolation_mode, int64_t padding_mode) ;
static Tensor group_norm(const Tensor & input, int64_t num_groups, const Tensor & weight, const Tensor & bias, double eps, bool cudnn_enabled) ;
static std::tuple<Tensor,Tensor> gru(const Tensor & input, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional, bool batch_first) ;
static std::tuple<Tensor,Tensor> gru(const Tensor & data, const Tensor & batch_sizes, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional) ;
static Tensor gru_cell(const Tensor & input, const Tensor & hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh) ;
static Tensor gt(const Tensor & self, Scalar other) ;
static Tensor gt(const Tensor & self, const Tensor & other) ;
static Tensor & gt_(Tensor & self, Scalar other) ;
static Tensor & gt_(Tensor & self, const Tensor & other) ;
static Tensor & gt_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & gt_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor hamming_window(int64_t window_length, const TensorOptions & options) ;
static Tensor hamming_window(int64_t window_length, bool periodic, const TensorOptions & options) ;
static Tensor hamming_window(int64_t window_length, bool periodic, double alpha, const TensorOptions & options) ;
static Tensor hamming_window(int64_t window_length, bool periodic, double alpha, double beta, const TensorOptions & options) ;
static Tensor hann_window(int64_t window_length, const TensorOptions & options) ;
static Tensor hann_window(int64_t window_length, bool periodic, const TensorOptions & options) ;
static Tensor hardshrink(const Tensor & self, Scalar lambd) ;
static Tensor hardshrink_backward(const Tensor & grad_out, const Tensor & self, Scalar lambd) ;
static Tensor hardtanh(const Tensor & self, Scalar min_val, Scalar max_val) ;
static Tensor & hardtanh_(Tensor & self, Scalar min_val, Scalar max_val) ;
static Tensor hardtanh_backward(const Tensor & grad_output, const Tensor & self, Scalar min_val, Scalar max_val) ;
static Tensor & hardtanh_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, Scalar min_val, Scalar max_val) ;
static Tensor & hardtanh_out(Tensor & out, const Tensor & self, Scalar min_val, Scalar max_val) ;
static Tensor hinge_embedding_loss(const Tensor & self, const Tensor & target, double margin, int64_t reduction) ;
static Tensor histc(const Tensor & self, int64_t bins, Scalar min, Scalar max) ;
static Tensor & histc_out(Tensor & out, const Tensor & self, int64_t bins, Scalar min, Scalar max) ;
static Tensor hspmm(const Tensor & mat1, const Tensor & mat2) ;
static Tensor & hspmm_out(Tensor & out, const Tensor & mat1, const Tensor & mat2) ;
static Tensor ifft(const Tensor & self, int64_t signal_ndim, bool normalized) ;
static Tensor im2col(const Tensor & self, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor im2col_backward(const Tensor & grad_output, IntArrayRef input_size, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor & im2col_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef input_size, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor & im2col_out(Tensor & out, const Tensor & self, IntArrayRef kernel_size, IntArrayRef dilation, IntArrayRef padding, IntArrayRef stride) ;
static Tensor index(const Tensor & self, TensorList indices) ;
static Tensor index_add(const Tensor & self, int64_t dim, const Tensor & index, const Tensor & source) ;
static Tensor & index_add_(Tensor & self, int64_t dim, const Tensor & index, const Tensor & source) ;
static Tensor index_copy(const Tensor & self, int64_t dim, const Tensor & index, const Tensor & source) ;
static Tensor & index_copy_(Tensor & self, int64_t dim, const Tensor & index, const Tensor & source) ;
static Tensor index_fill(const Tensor & self, int64_t dim, const Tensor & index, Scalar value) ;
static Tensor index_fill(const Tensor & self, int64_t dim, const Tensor & index, const Tensor & value) ;
static Tensor & index_fill_(Tensor & self, int64_t dim, const Tensor & index, Scalar value) ;
static Tensor & index_fill_(Tensor & self, int64_t dim, const Tensor & index, const Tensor & value) ;
static Tensor index_put(const Tensor & self, TensorList indices, const Tensor & values, bool accumulate) ;
static Tensor & index_put_(Tensor & self, TensorList indices, const Tensor & values, bool accumulate) ;
static Tensor index_select(const Tensor & self, int64_t dim, const Tensor & index) ;
static Tensor & index_select_out(Tensor & out, const Tensor & self, int64_t dim, const Tensor & index) ;
static Tensor indices(const Tensor & self) ;
static Tensor instance_norm(const Tensor & input, const Tensor & weight, const Tensor & bias, const Tensor & running_mean, const Tensor & running_var, bool use_input_stats, double momentum, double eps, bool cudnn_enabled) ;
static Tensor int_repr(const Tensor & self) ;
static Tensor inverse(const Tensor & self) ;
static Tensor & inverse_out(Tensor & out, const Tensor & self) ;
static Tensor irfft(const Tensor & self, int64_t signal_ndim, bool normalized, bool onesided, IntArrayRef signal_sizes) ;
static bool is_coalesced(const Tensor & self) ;
static bool is_complex(const Tensor & self) ;
static bool is_distributed(const Tensor & self) ;
static bool is_floating_point(const Tensor & self) ;
static bool is_nonzero(const Tensor & self) ;
static bool is_pinned(const Tensor & self) ;
static bool is_same_size(const Tensor & self, const Tensor & other) ;
static bool is_set_to(const Tensor & self, const Tensor & tensor) ;
static bool is_signed(const Tensor & self) ;
static Tensor isclose(const Tensor & self, const Tensor & other, double rtol, double atol, bool equal_nan) ;
static Tensor isnan(const Tensor & self) ;
static Scalar item(const Tensor & self) ;
static Tensor kl_div(const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor kl_div_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static std::tuple<Tensor,Tensor> kthvalue(const Tensor & self, int64_t k, int64_t dim, bool keepdim) ;
static std::tuple<Tensor &,Tensor &> kthvalue_out(Tensor & values, Tensor & indices, const Tensor & self, int64_t k, int64_t dim, bool keepdim) ;
static Tensor l1_loss(const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor l1_loss_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & l1_loss_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & l1_loss_out(Tensor & out, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor layer_norm(const Tensor & input, IntArrayRef normalized_shape, const Tensor & weight, const Tensor & bias, double eps, bool cudnn_enable) ;
static Tensor le(const Tensor & self, Scalar other) ;
static Tensor le(const Tensor & self, const Tensor & other) ;
static Tensor & le_(Tensor & self, Scalar other) ;
static Tensor & le_(Tensor & self, const Tensor & other) ;
static Tensor & le_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & le_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor leaky_relu(const Tensor & self, Scalar negative_slope) ;
static Tensor & leaky_relu_(Tensor & self, Scalar negative_slope) ;
static Tensor leaky_relu_backward(const Tensor & grad_output, const Tensor & self, Scalar negative_slope) ;
static Tensor & leaky_relu_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, Scalar negative_slope) ;
static Tensor & leaky_relu_out(Tensor & out, const Tensor & self, Scalar negative_slope) ;
static Tensor lerp(const Tensor & self, const Tensor & end, Scalar weight) ;
static Tensor lerp(const Tensor & self, const Tensor & end, const Tensor & weight) ;
static Tensor & lerp_(Tensor & self, const Tensor & end, Scalar weight) ;
static Tensor & lerp_(Tensor & self, const Tensor & end, const Tensor & weight) ;
static Tensor & lerp_out(Tensor & out, const Tensor & self, const Tensor & end, Scalar weight) ;
static Tensor & lerp_out(Tensor & out, const Tensor & self, const Tensor & end, const Tensor & weight) ;
static Tensor lgamma(const Tensor & self) ;
static Tensor & lgamma_(Tensor & self) ;
static Tensor & lgamma_out(Tensor & out, const Tensor & self) ;
static Tensor linear(const Tensor & input, const Tensor & weight, const Tensor & bias) ;
static Tensor linspace(Scalar start, Scalar end, int64_t steps, const TensorOptions & options) ;
static Tensor & linspace_out(Tensor & out, Scalar start, Scalar end, int64_t steps) ;
static Tensor log(const Tensor & self) ;
static Tensor log10(const Tensor & self) ;
static Tensor & log10_(Tensor & self) ;
static Tensor & log10_out(Tensor & out, const Tensor & self) ;
static Tensor log1p(const Tensor & self) ;
static Tensor & log1p_(Tensor & self) ;
static Tensor & log1p_out(Tensor & out, const Tensor & self) ;
static Tensor log2(const Tensor & self) ;
static Tensor & log2_(Tensor & self) ;
static Tensor & log2_out(Tensor & out, const Tensor & self) ;
static Tensor & log_(Tensor & self) ;
static Tensor & log_normal_(Tensor & self, double mean, double std, Generator * generator) ;
static Tensor & log_out(Tensor & out, const Tensor & self) ;
static Tensor log_sigmoid(const Tensor & self) ;
static Tensor log_sigmoid_backward(const Tensor & grad_output, const Tensor & self, const Tensor & buffer) ;
static Tensor & log_sigmoid_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & buffer) ;
static std::tuple<Tensor,Tensor> log_sigmoid_forward(const Tensor & self) ;
static std::tuple<Tensor &,Tensor &> log_sigmoid_forward_out(Tensor & output, Tensor & buffer, const Tensor & self) ;
static Tensor & log_sigmoid_out(Tensor & out, const Tensor & self) ;
static Tensor log_softmax(const Tensor & self, int64_t dim, c10::optional<ScalarType> dtype) ;
static Tensor logdet(const Tensor & self) ;
static Tensor logspace(Scalar start, Scalar end, int64_t steps, double base, const TensorOptions & options) ;
static Tensor & logspace_out(Tensor & out, Scalar start, Scalar end, int64_t steps, double base) ;
static Tensor logsumexp(const Tensor & self, IntArrayRef dim, bool keepdim) ;
static Tensor & logsumexp_out(Tensor & out, const Tensor & self, IntArrayRef dim, bool keepdim) ;
static std::tuple<Tensor,Tensor,Tensor> lstm(const Tensor & input, TensorList hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional, bool batch_first) ;
static std::tuple<Tensor,Tensor,Tensor> lstm(const Tensor & data, const Tensor & batch_sizes, TensorList hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional) ;
static std::tuple<Tensor,Tensor> lstm_cell(const Tensor & input, TensorList hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh) ;
static std::tuple<Tensor,Tensor> lstsq(const Tensor & self, const Tensor & A) ;
static std::tuple<Tensor &,Tensor &> lstsq_out(Tensor & X, Tensor & qr, const Tensor & self, const Tensor & A) ;
static Tensor lt(const Tensor & self, Scalar other) ;
static Tensor lt(const Tensor & self, const Tensor & other) ;
static Tensor & lt_(Tensor & self, Scalar other) ;
static Tensor & lt_(Tensor & self, const Tensor & other) ;
static Tensor & lt_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & lt_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor lu_solve(const Tensor & self, const Tensor & LU_data, const Tensor & LU_pivots) ;
static Tensor & lu_solve_out(Tensor & out, const Tensor & self, const Tensor & LU_data, const Tensor & LU_pivots) ;
static Tensor margin_ranking_loss(const Tensor & input1, const Tensor & input2, const Tensor & target, double margin, int64_t reduction) ;
static Tensor masked_fill(const Tensor & self, const Tensor & mask, Scalar value) ;
static Tensor masked_fill(const Tensor & self, const Tensor & mask, const Tensor & value) ;
static Tensor & masked_fill_(Tensor & self, const Tensor & mask, Scalar value) ;
static Tensor & masked_fill_(Tensor & self, const Tensor & mask, const Tensor & value) ;
static Tensor masked_scatter(const Tensor & self, const Tensor & mask, const Tensor & source) ;
static Tensor & masked_scatter_(Tensor & self, const Tensor & mask, const Tensor & source) ;
static Tensor masked_select(const Tensor & self, const Tensor & mask) ;
static Tensor & masked_select_out(Tensor & out, const Tensor & self, const Tensor & mask) ;
static Tensor matmul(const Tensor & self, const Tensor & other) ;
static Tensor & matmul_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor matrix_power(const Tensor & self, int64_t n) ;
static Tensor matrix_rank(const Tensor & self, double tol, bool symmetric) ;
static Tensor matrix_rank(const Tensor & self, bool symmetric) ;
static std::tuple<Tensor,Tensor> max(const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor max(const Tensor & self, const Tensor & other) ;
static Tensor max(const Tensor & self) ;
static std::tuple<Tensor &,Tensor &> max_out(Tensor & max, Tensor & max_values, const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor & max_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor max_pool1d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static std::tuple<Tensor,Tensor> max_pool1d_with_indices(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static Tensor max_pool2d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static std::tuple<Tensor,Tensor> max_pool2d_with_indices(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static Tensor max_pool2d_with_indices_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, const Tensor & indices) ;
static Tensor & max_pool2d_with_indices_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, const Tensor & indices) ;
static std::tuple<Tensor &,Tensor &> max_pool2d_with_indices_out(Tensor & out, Tensor & indices, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static Tensor max_pool3d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static std::tuple<Tensor,Tensor> max_pool3d_with_indices(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static Tensor max_pool3d_with_indices_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, const Tensor & indices) ;
static Tensor & max_pool3d_with_indices_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode, const Tensor & indices) ;
static std::tuple<Tensor &,Tensor &> max_pool3d_with_indices_out(Tensor & out, Tensor & indices, const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static Tensor max_unpool2d(const Tensor & self, const Tensor & indices, IntArrayRef output_size) ;
static Tensor max_unpool2d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & indices, IntArrayRef output_size) ;
static Tensor & max_unpool2d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & indices, IntArrayRef output_size) ;
static Tensor & max_unpool2d_out(Tensor & out, const Tensor & self, const Tensor & indices, IntArrayRef output_size) ;
static Tensor max_unpool3d(const Tensor & self, const Tensor & indices, IntArrayRef output_size, IntArrayRef stride, IntArrayRef padding) ;
static Tensor max_unpool3d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & indices, IntArrayRef output_size, IntArrayRef stride, IntArrayRef padding) ;
static Tensor & max_unpool3d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & indices, IntArrayRef output_size, IntArrayRef stride, IntArrayRef padding) ;
static Tensor & max_unpool3d_out(Tensor & out, const Tensor & self, const Tensor & indices, IntArrayRef output_size, IntArrayRef stride, IntArrayRef padding) ;
static Tensor max_values(const Tensor & self, IntArrayRef dim, bool keepdim) ;
static Tensor mean(const Tensor & self, c10::optional<ScalarType> dtype) ;
static Tensor mean(const Tensor & self, IntArrayRef dim, bool keepdim, c10::optional<ScalarType> dtype) ;
static Tensor & mean_out(Tensor & out, const Tensor & self, IntArrayRef dim, bool keepdim, c10::optional<ScalarType> dtype) ;
static std::tuple<Tensor,Tensor> median(const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor median(const Tensor & self) ;
static std::tuple<Tensor &,Tensor &> median_out(Tensor & values, Tensor & indices, const Tensor & self, int64_t dim, bool keepdim) ;
static std::vector<Tensor> meshgrid(TensorList tensors) ;
static std::tuple<Tensor,Tensor> min(const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor min(const Tensor & self, const Tensor & other) ;
static Tensor min(const Tensor & self) ;
static std::tuple<Tensor &,Tensor &> min_out(Tensor & min, Tensor & min_indices, const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor & min_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor min_values(const Tensor & self, IntArrayRef dim, bool keepdim) ;
static std::tuple<Tensor,Tensor,Tensor> miopen_batch_norm(const Tensor & input, const Tensor & weight, const Tensor & bias, const Tensor & running_mean, const Tensor & running_var, bool training, double exponential_average_factor, double epsilon) ;
static std::tuple<Tensor,Tensor,Tensor> miopen_batch_norm_backward(const Tensor & input, const Tensor & grad_output, const Tensor & weight, const Tensor & running_mean, const Tensor & running_var, const Tensor & save_mean, const Tensor & save_var, double epsilon) ;
static Tensor miopen_convolution(const Tensor & self, const Tensor & weight, const Tensor & bias, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static std::tuple<Tensor,Tensor,Tensor> miopen_convolution_backward(const Tensor & self, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic, std::array<bool,3> output_mask) ;
static Tensor miopen_convolution_backward_bias(const Tensor & grad_output) ;
static Tensor miopen_convolution_backward_input(IntArrayRef self_size, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor miopen_convolution_backward_weight(IntArrayRef weight_size, const Tensor & grad_output, const Tensor & self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor miopen_convolution_transpose(const Tensor & self, const Tensor & weight, const Tensor & bias, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static std::tuple<Tensor,Tensor,Tensor> miopen_convolution_transpose_backward(const Tensor & self, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic, std::array<bool,3> output_mask) ;
static Tensor miopen_convolution_transpose_backward_input(const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor miopen_convolution_transpose_backward_weight(IntArrayRef weight_size, const Tensor & grad_output, const Tensor & self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor miopen_depthwise_convolution(const Tensor & self, const Tensor & weight, const Tensor & bias, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static std::tuple<Tensor,Tensor,Tensor> miopen_depthwise_convolution_backward(const Tensor & self, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic, std::array<bool,3> output_mask) ;
static Tensor miopen_depthwise_convolution_backward_input(IntArrayRef self_size, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static Tensor miopen_depthwise_convolution_backward_weight(IntArrayRef weight_size, const Tensor & grad_output, const Tensor & self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool benchmark, bool deterministic) ;
static std::tuple<Tensor,Tensor,Tensor,Tensor,Tensor> miopen_rnn(const Tensor & input, TensorList weight, int64_t weight_stride0, const Tensor & hx, const Tensor & cx, int64_t mode, int64_t hidden_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, IntArrayRef batch_sizes, const Tensor & dropout_state) ;
static std::tuple<Tensor,Tensor,Tensor,std::vector<Tensor>> miopen_rnn_backward(const Tensor & input, TensorList weight, int64_t weight_stride0, const Tensor & weight_buf, const Tensor & hx, const Tensor & cx, const Tensor & output, const Tensor & grad_output, const Tensor & grad_hy, const Tensor & grad_cy, int64_t mode, int64_t hidden_size, int64_t num_layers, bool batch_first, double dropout, bool train, bool bidirectional, IntArrayRef batch_sizes, const Tensor & dropout_state, const Tensor & reserve, std::array<bool,4> output_mask) ;
static Tensor mkldnn_adaptive_avg_pool2d(const Tensor & self, IntArrayRef output_size) ;
static Tensor mkldnn_convolution(const Tensor & self, const Tensor & weight, const Tensor & bias, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups) ;
static std::tuple<Tensor,Tensor,Tensor> mkldnn_convolution_backward(const Tensor & self, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, std::array<bool,3> output_mask) ;
static Tensor mkldnn_convolution_backward_input(IntArrayRef self_size, const Tensor & grad_output, const Tensor & weight, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool bias_defined) ;
static std::tuple<Tensor,Tensor> mkldnn_convolution_backward_weights(IntArrayRef weight_size, const Tensor & grad_output, const Tensor & self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups, bool bias_defined) ;
static Tensor mkldnn_linear(const Tensor & input, const Tensor & weight, const Tensor & bias) ;
static Tensor mkldnn_max_pool2d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, bool ceil_mode) ;
static Tensor mkldnn_reorder_conv2d_weight(const Tensor & self, IntArrayRef padding, IntArrayRef stride, IntArrayRef dilation, int64_t groups) ;
static Tensor mm(const Tensor & self, const Tensor & mat2) ;
static Tensor & mm_out(Tensor & out, const Tensor & self, const Tensor & mat2) ;
static std::tuple<Tensor,Tensor> mode(const Tensor & self, int64_t dim, bool keepdim) ;
static std::tuple<Tensor &,Tensor &> mode_out(Tensor & values, Tensor & indices, const Tensor & self, int64_t dim, bool keepdim) ;
static Tensor mse_loss(const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor mse_loss_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & mse_loss_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & mse_loss_out(Tensor & out, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor mul(const Tensor & self, const Tensor & other) ;
static Tensor mul(const Tensor & self, Scalar other) ;
static Tensor & mul_(Tensor & self, const Tensor & other) ;
static Tensor & mul_(Tensor & self, Scalar other) ;
static Tensor & mul_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor multi_margin_loss(const Tensor & self, const Tensor & target, Scalar p, Scalar margin, const Tensor & weight, int64_t reduction) ;
static Tensor multi_margin_loss_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, Scalar p, Scalar margin, const Tensor & weight, int64_t reduction) ;
static Tensor & multi_margin_loss_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, Scalar p, Scalar margin, const Tensor & weight, int64_t reduction) ;
static Tensor & multi_margin_loss_out(Tensor & out, const Tensor & self, const Tensor & target, Scalar p, Scalar margin, const Tensor & weight, int64_t reduction) ;
static Tensor multilabel_margin_loss(const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor multilabel_margin_loss_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction, const Tensor & is_target) ;
static Tensor & multilabel_margin_loss_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction, const Tensor & is_target) ;
static std::tuple<Tensor,Tensor> multilabel_margin_loss_forward(const Tensor & self, const Tensor & target, int64_t reduction) ;
static std::tuple<Tensor &,Tensor &> multilabel_margin_loss_forward_out(Tensor & output, Tensor & is_target, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & multilabel_margin_loss_out(Tensor & out, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor multinomial(const Tensor & self, int64_t num_samples, bool replacement, Generator * generator) ;
static Tensor & multinomial_out(Tensor & out, const Tensor & self, int64_t num_samples, bool replacement, Generator * generator) ;
static Tensor mv(const Tensor & self, const Tensor & vec) ;
static Tensor & mv_out(Tensor & out, const Tensor & self, const Tensor & vec) ;
static Tensor mvlgamma(const Tensor & self, int64_t p) ;
static Tensor & mvlgamma_(Tensor & self, int64_t p) ;
static Tensor narrow(const Tensor & self, int64_t dim, int64_t start, int64_t length) ;
static Tensor narrow_copy(const Tensor & self, int64_t dim, int64_t start, int64_t length) ;
static std::tuple<Tensor,Tensor,Tensor> native_batch_norm(const Tensor & input, const Tensor & weight, const Tensor & bias, const Tensor & running_mean, const Tensor & running_var, bool training, double momentum, double eps) ;
static std::tuple<Tensor,Tensor,Tensor> native_batch_norm_backward(const Tensor & grad_out, const Tensor & input, const Tensor & weight, const Tensor & running_mean, const Tensor & running_var, const Tensor & save_mean, const Tensor & save_invstd, bool train, double eps, std::array<bool,3> output_mask) ;
static std::tuple<Tensor,Tensor,Tensor> native_layer_norm(const Tensor & input, const Tensor & weight, const Tensor & bias, int64_t M, int64_t N, double eps) ;
static std::tuple<Tensor,Tensor,Tensor> native_layer_norm_backward(const Tensor & grad_out, const Tensor & input, const Tensor & mean, const Tensor & rstd, const Tensor & weight, int64_t M, int64_t N, std::array<bool,3> output_mask) ;
static std::tuple<Tensor,Tensor,Tensor> native_layer_norm_double_backward(const Tensor & ggI, const Tensor & ggW, const Tensor & ggb, const Tensor & gO, const Tensor & input, const Tensor & mean, const Tensor & rstd, const Tensor & weight, int64_t M, int64_t N, std::array<bool,3> output_mask) ;
static Tensor native_norm(const Tensor & self, Scalar p) ;
static Tensor ne(const Tensor & self, Scalar other) ;
static Tensor ne(const Tensor & self, const Tensor & other) ;
static Tensor & ne_(Tensor & self, Scalar other) ;
static Tensor & ne_(Tensor & self, const Tensor & other) ;
static Tensor & ne_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & ne_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor neg(const Tensor & self) ;
static Tensor & neg_(Tensor & self) ;
static Tensor & neg_out(Tensor & out, const Tensor & self) ;
static Tensor nll_loss(const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static Tensor nll_loss2d(const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static Tensor nll_loss2d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index, const Tensor & total_weight) ;
static Tensor & nll_loss2d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index, const Tensor & total_weight) ;
static std::tuple<Tensor,Tensor> nll_loss2d_forward(const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static std::tuple<Tensor &,Tensor &> nll_loss2d_forward_out(Tensor & output, Tensor & total_weight, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static Tensor & nll_loss2d_out(Tensor & out, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static Tensor nll_loss_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index, const Tensor & total_weight) ;
static Tensor & nll_loss_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index, const Tensor & total_weight) ;
static std::tuple<Tensor,Tensor> nll_loss_forward(const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static std::tuple<Tensor &,Tensor &> nll_loss_forward_out(Tensor & output, Tensor & total_weight, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static Tensor & nll_loss_out(Tensor & out, const Tensor & self, const Tensor & target, const Tensor & weight, int64_t reduction, int64_t ignore_index) ;
static Tensor nonzero(const Tensor & self) ;
static std::vector<Tensor> nonzero_numpy(const Tensor & self) ;
static Tensor & nonzero_out(Tensor & out, const Tensor & self) ;
static Tensor norm(const Tensor & self, c10::optional<Scalar> p, ScalarType dtype) ;
static Tensor norm(const Tensor & self, Scalar p) ;
static Tensor norm(const Tensor & self, c10::optional<Scalar> p, IntArrayRef dim, bool keepdim, ScalarType dtype) ;
static Tensor norm(const Tensor & self, c10::optional<Scalar> p, IntArrayRef dim, bool keepdim) ;
static Tensor norm_except_dim(const Tensor & v, int64_t pow, int64_t dim) ;
static Tensor & norm_out(Tensor & out, const Tensor & self, c10::optional<Scalar> p, IntArrayRef dim, bool keepdim, ScalarType dtype) ;
static Tensor & norm_out(Tensor & out, const Tensor & self, c10::optional<Scalar> p, IntArrayRef dim, bool keepdim) ;
static Tensor normal(const Tensor & mean, double std, Generator * generator) ;
static Tensor normal(double mean, const Tensor & std, Generator * generator) ;
static Tensor normal(const Tensor & mean, const Tensor & std, Generator * generator) ;
static Tensor normal(double mean, double std, IntArrayRef size, Generator * generator, const TensorOptions & options) ;
static Tensor & normal_(Tensor & self, double mean, double std, Generator * generator) ;
static Tensor & normal_out(Tensor & out, const Tensor & mean, double std, Generator * generator) ;
static Tensor & normal_out(Tensor & out, double mean, const Tensor & std, Generator * generator) ;
static Tensor & normal_out(Tensor & out, const Tensor & mean, const Tensor & std, Generator * generator) ;
static Tensor & normal_out(Tensor & out, double mean, double std, IntArrayRef size, Generator * generator) ;
static Tensor nuclear_norm(const Tensor & self, bool keepdim) ;
static Tensor nuclear_norm(const Tensor & self, IntArrayRef dim, bool keepdim) ;
static Tensor & nuclear_norm_out(Tensor & out, const Tensor & self, bool keepdim) ;
static Tensor & nuclear_norm_out(Tensor & out, const Tensor & self, IntArrayRef dim, bool keepdim) ;
static int64_t numel(const Tensor & self) ;
static Tensor numpy_T(const Tensor & self) ;
static Tensor one_hot(const Tensor & self, int64_t num_classes) ;
static Tensor ones(IntArrayRef size, const TensorOptions & options) ;
static Tensor ones_like(const Tensor & self) ;
static Tensor ones_like(const Tensor & self, const TensorOptions & options) ;
static Tensor & ones_out(Tensor & out, IntArrayRef size) ;
static Tensor orgqr(const Tensor & self, const Tensor & input2) ;
static Tensor & orgqr_out(Tensor & out, const Tensor & self, const Tensor & input2) ;
static Tensor ormqr(const Tensor & self, const Tensor & input2, const Tensor & input3, bool left, bool transpose) ;
static Tensor & ormqr_out(Tensor & out, const Tensor & self, const Tensor & input2, const Tensor & input3, bool left, bool transpose) ;
static Tensor pairwise_distance(const Tensor & x1, const Tensor & x2, double p, double eps, bool keepdim) ;
static Tensor pdist(const Tensor & self, double p) ;
static Tensor permute(const Tensor & self, IntArrayRef dims) ;
static Tensor pin_memory(const Tensor & self) ;
static Tensor pinverse(const Tensor & self, double rcond) ;
static Tensor pixel_shuffle(const Tensor & self, int64_t upscale_factor) ;
static Tensor poisson(const Tensor & self, Generator * generator) ;
static Tensor poisson_nll_loss(const Tensor & input, const Tensor & target, bool log_input, bool full, double eps, int64_t reduction) ;
static Tensor polygamma(int64_t n, const Tensor & self) ;
static Tensor & polygamma_(Tensor & self, int64_t n) ;
static Tensor & polygamma_out(Tensor & out, int64_t n, const Tensor & self) ;
static Tensor pow(const Tensor & self, Scalar exponent) ;
static Tensor pow(const Tensor & self, const Tensor & exponent) ;
static Tensor pow(Scalar self, const Tensor & exponent) ;
static Tensor & pow_(Tensor & self, Scalar exponent) ;
static Tensor & pow_(Tensor & self, const Tensor & exponent) ;
static Tensor & pow_out(Tensor & out, const Tensor & self, Scalar exponent) ;
static Tensor & pow_out(Tensor & out, const Tensor & self, const Tensor & exponent) ;
static Tensor & pow_out(Tensor & out, Scalar self, const Tensor & exponent) ;
static Tensor prelu(const Tensor & self, const Tensor & weight) ;
static std::tuple<Tensor,Tensor> prelu_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight) ;
static Tensor prod(const Tensor & self, c10::optional<ScalarType> dtype) ;
static Tensor prod(const Tensor & self, int64_t dim, bool keepdim, c10::optional<ScalarType> dtype) ;
static Tensor & prod_out(Tensor & out, const Tensor & self, int64_t dim, bool keepdim, c10::optional<ScalarType> dtype) ;
static Tensor & put_(Tensor & self, const Tensor & index, const Tensor & source, bool accumulate) ;
static double q_scale(const Tensor & self) ;
static int64_t q_zero_point(const Tensor & self) ;
static std::tuple<Tensor,Tensor> qr(const Tensor & self, bool some) ;
static std::tuple<Tensor &,Tensor &> qr_out(Tensor & Q, Tensor & R, const Tensor & self, bool some) ;
static QScheme qscheme(const Tensor & self) ;
static Tensor quantize_linear(const Tensor & self, double scale, int64_t zero_point, ScalarType dtype) ;
static Tensor quantize_linear_per_channel(const Tensor & self, const Tensor & scales, const Tensor & zero_points, IntArrayRef axis, ScalarType dtype) ;
static std::tuple<Tensor,Tensor> quantized_gru(const Tensor & input, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional, bool batch_first) ;
static std::tuple<Tensor,Tensor> quantized_gru(const Tensor & data, const Tensor & batch_sizes, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional) ;
static Tensor quantized_gru_cell(const Tensor & input, const Tensor & hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh, const Tensor & packed_ih, const Tensor & packed_hh, const Tensor & col_offsets_ih, const Tensor & col_offsets_hh, Scalar scale_ih, Scalar scale_hh, Scalar zero_point_ih, Scalar zero_point_hh) ;
static std::tuple<Tensor,Tensor,Tensor> quantized_lstm(const Tensor & input, TensorList hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional, bool batch_first, c10::optional<ScalarType> dtype) ;
static std::tuple<Tensor,Tensor> quantized_lstm_cell(const Tensor & input, TensorList hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh, const Tensor & packed_ih, const Tensor & packed_hh, const Tensor & col_offsets_ih, const Tensor & col_offsets_hh, Scalar scale_ih, Scalar scale_hh, Scalar zero_point_ih, Scalar zero_point_hh) ;
static Tensor quantized_max_pool2d(const Tensor & self, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static Tensor quantized_rnn_relu_cell(const Tensor & input, const Tensor & hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh, const Tensor & packed_ih, const Tensor & packed_hh, const Tensor & col_offsets_ih, const Tensor & col_offsets_hh, Scalar scale_ih, Scalar scale_hh, Scalar zero_point_ih, Scalar zero_point_hh) ;
static Tensor quantized_rnn_tanh_cell(const Tensor & input, const Tensor & hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh, const Tensor & packed_ih, const Tensor & packed_hh, const Tensor & col_offsets_ih, const Tensor & col_offsets_hh, Scalar scale_ih, Scalar scale_hh, Scalar zero_point_ih, Scalar zero_point_hh) ;
static Tensor rand(IntArrayRef size, const TensorOptions & options) ;
static Tensor rand(IntArrayRef size, Generator * generator, const TensorOptions & options) ;
static Tensor rand_like(const Tensor & self) ;
static Tensor rand_like(const Tensor & self, const TensorOptions & options) ;
static Tensor & rand_out(Tensor & out, IntArrayRef size) ;
static Tensor & rand_out(Tensor & out, IntArrayRef size, Generator * generator) ;
static Tensor randint(int64_t high, IntArrayRef size, const TensorOptions & options) ;
static Tensor randint(int64_t high, IntArrayRef size, Generator * generator, const TensorOptions & options) ;
static Tensor randint(int64_t low, int64_t high, IntArrayRef size, const TensorOptions & options) ;
static Tensor randint(int64_t low, int64_t high, IntArrayRef size, Generator * generator, const TensorOptions & options) ;
static Tensor randint_like(const Tensor & self, int64_t high) ;
static Tensor randint_like(const Tensor & self, int64_t low, int64_t high) ;
static Tensor randint_like(const Tensor & self, int64_t high, const TensorOptions & options) ;
static Tensor randint_like(const Tensor & self, int64_t low, int64_t high, const TensorOptions & options) ;
static Tensor & randint_out(Tensor & out, int64_t high, IntArrayRef size) ;
static Tensor & randint_out(Tensor & out, int64_t high, IntArrayRef size, Generator * generator) ;
static Tensor & randint_out(Tensor & out, int64_t low, int64_t high, IntArrayRef size) ;
static Tensor & randint_out(Tensor & out, int64_t low, int64_t high, IntArrayRef size, Generator * generator) ;
static Tensor randn(IntArrayRef size, const TensorOptions & options) ;
static Tensor randn(IntArrayRef size, Generator * generator, const TensorOptions & options) ;
static Tensor randn_like(const Tensor & self) ;
static Tensor randn_like(const Tensor & self, const TensorOptions & options) ;
static Tensor & randn_out(Tensor & out, IntArrayRef size) ;
static Tensor & randn_out(Tensor & out, IntArrayRef size, Generator * generator) ;
static Tensor & random_(Tensor & self, int64_t from, int64_t to, Generator * generator) ;
static Tensor & random_(Tensor & self, int64_t to, Generator * generator) ;
static Tensor & random_(Tensor & self, Generator * generator) ;
static Tensor randperm(int64_t n, const TensorOptions & options) ;
static Tensor randperm(int64_t n, Generator * generator, const TensorOptions & options) ;
static Tensor & randperm_out(Tensor & out, int64_t n) ;
static Tensor & randperm_out(Tensor & out, int64_t n, Generator * generator) ;
static Tensor range(Scalar start, Scalar end, Scalar step, const TensorOptions & options) ;
static Tensor range(Scalar start, Scalar end, const TensorOptions & options) ;
static Tensor & range_out(Tensor & out, Scalar start, Scalar end, Scalar step) ;
static Tensor reciprocal(const Tensor & self) ;
static Tensor & reciprocal_(Tensor & self) ;
static Tensor & reciprocal_out(Tensor & out, const Tensor & self) ;
static Tensor reflection_pad1d(const Tensor & self, IntArrayRef padding) ;
static Tensor reflection_pad1d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & reflection_pad1d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & reflection_pad1d_out(Tensor & out, const Tensor & self, IntArrayRef padding) ;
static Tensor reflection_pad2d(const Tensor & self, IntArrayRef padding) ;
static Tensor reflection_pad2d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & reflection_pad2d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & reflection_pad2d_out(Tensor & out, const Tensor & self, IntArrayRef padding) ;
static Tensor relu(const Tensor & self) ;
static Tensor & relu_(Tensor & self) ;
static Tensor remainder(const Tensor & self, Scalar other) ;
static Tensor remainder(const Tensor & self, const Tensor & other) ;
static Tensor & remainder_(Tensor & self, Scalar other) ;
static Tensor & remainder_(Tensor & self, const Tensor & other) ;
static Tensor & remainder_out(Tensor & out, const Tensor & self, Scalar other) ;
static Tensor & remainder_out(Tensor & out, const Tensor & self, const Tensor & other) ;
static Tensor renorm(const Tensor & self, Scalar p, int64_t dim, Scalar maxnorm) ;
static Tensor & renorm_(Tensor & self, Scalar p, int64_t dim, Scalar maxnorm) ;
static Tensor & renorm_out(Tensor & out, const Tensor & self, Scalar p, int64_t dim, Scalar maxnorm) ;
static Tensor repeat(const Tensor & self, IntArrayRef repeats) ;
static Tensor repeat_interleave(const Tensor & repeats) ;
static Tensor repeat_interleave(const Tensor & self, const Tensor & repeats, c10::optional<int64_t> dim) ;
static Tensor repeat_interleave(const Tensor & self, int64_t repeats, c10::optional<int64_t> dim) ;
static Tensor replication_pad1d(const Tensor & self, IntArrayRef padding) ;
static Tensor replication_pad1d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & replication_pad1d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & replication_pad1d_out(Tensor & out, const Tensor & self, IntArrayRef padding) ;
static Tensor replication_pad2d(const Tensor & self, IntArrayRef padding) ;
static Tensor replication_pad2d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & replication_pad2d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & replication_pad2d_out(Tensor & out, const Tensor & self, IntArrayRef padding) ;
static Tensor replication_pad3d(const Tensor & self, IntArrayRef padding) ;
static Tensor replication_pad3d_backward(const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & replication_pad3d_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, IntArrayRef padding) ;
static Tensor & replication_pad3d_out(Tensor & out, const Tensor & self, IntArrayRef padding) ;
static Tensor reshape(const Tensor & self, IntArrayRef shape) ;
static Tensor reshape_as(const Tensor & self, const Tensor & other) ;
static Tensor & resize_(Tensor & self, IntArrayRef size) ;
static Tensor & resize_as_(Tensor & self, const Tensor & the_template) ;
static Tensor rfft(const Tensor & self, int64_t signal_ndim, bool normalized, bool onesided) ;
static std::tuple<Tensor,Tensor> rnn_relu(const Tensor & input, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional, bool batch_first) ;
static std::tuple<Tensor,Tensor> rnn_relu(const Tensor & data, const Tensor & batch_sizes, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional) ;
static Tensor rnn_relu_cell(const Tensor & input, const Tensor & hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh) ;
static std::tuple<Tensor,Tensor> rnn_tanh(const Tensor & input, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional, bool batch_first) ;
static std::tuple<Tensor,Tensor> rnn_tanh(const Tensor & data, const Tensor & batch_sizes, const Tensor & hx, TensorList params, bool has_biases, int64_t num_layers, double dropout, bool train, bool bidirectional) ;
static Tensor rnn_tanh_cell(const Tensor & input, const Tensor & hx, const Tensor & w_ih, const Tensor & w_hh, const Tensor & b_ih, const Tensor & b_hh) ;
static Tensor roll(const Tensor & self, IntArrayRef shifts, IntArrayRef dims) ;
static Tensor rot90(const Tensor & self, int64_t k, IntArrayRef dims) ;
static Tensor round(const Tensor & self) ;
static Tensor & round_(Tensor & self) ;
static Tensor & round_out(Tensor & out, const Tensor & self) ;
static Tensor rrelu(const Tensor & self, Scalar lower, Scalar upper, bool training, Generator * generator) ;
static Tensor & rrelu_(Tensor & self, Scalar lower, Scalar upper, bool training, Generator * generator) ;
static Tensor rrelu_with_noise(const Tensor & self, const Tensor & noise, Scalar lower, Scalar upper, bool training, Generator * generator) ;
static Tensor & rrelu_with_noise_(Tensor & self, const Tensor & noise, Scalar lower, Scalar upper, bool training, Generator * generator) ;
static Tensor rrelu_with_noise_backward(const Tensor & grad_output, const Tensor & self, const Tensor & noise, Scalar lower, Scalar upper, bool training) ;
static Tensor & rrelu_with_noise_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & noise, Scalar lower, Scalar upper, bool training) ;
static Tensor & rrelu_with_noise_out(Tensor & out, const Tensor & self, const Tensor & noise, Scalar lower, Scalar upper, bool training, Generator * generator) ;
static Tensor rsqrt(const Tensor & self) ;
static Tensor & rsqrt_(Tensor & self) ;
static Tensor & rsqrt_out(Tensor & out, const Tensor & self) ;
static Tensor rsub(const Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor rsub(const Tensor & self, Scalar other, Scalar alpha) ;
static Tensor s_native_addmm(const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor & s_native_addmm_(Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor & s_native_addmm_out(Tensor & out, const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor scalar_tensor(Scalar s, const TensorOptions & options) ;
static Tensor scatter(const Tensor & self, int64_t dim, const Tensor & index, const Tensor & src) ;
static Tensor scatter(const Tensor & self, int64_t dim, const Tensor & index, Scalar value) ;
static Tensor & scatter_(Tensor & self, int64_t dim, const Tensor & index, const Tensor & src) ;
static Tensor & scatter_(Tensor & self, int64_t dim, const Tensor & index, Scalar value) ;
static Tensor scatter_add(const Tensor & self, int64_t dim, const Tensor & index, const Tensor & src) ;
static Tensor & scatter_add_(Tensor & self, int64_t dim, const Tensor & index, const Tensor & src) ;
static Tensor select(const Tensor & self, int64_t dim, int64_t index) ;
static Tensor selu(const Tensor & self) ;
static Tensor & selu_(Tensor & self) ;
static Tensor & set_(Tensor & self, Storage source) ;
static Tensor & set_(Tensor & self, Storage source, int64_t storage_offset, IntArrayRef size, IntArrayRef stride) ;
static Tensor & set_(Tensor & self, const Tensor & source) ;
static Tensor & set_(Tensor & self) ;
static void set_data(const Tensor & self, const Tensor & new_data) ;
static Tensor & set_quantizer_(Tensor & self, ConstQuantizerPtr quantizer) ;
static Tensor sigmoid(const Tensor & self) ;
static Tensor & sigmoid_(Tensor & self) ;
static Tensor sigmoid_backward(const Tensor & grad_output, const Tensor & output) ;
static Tensor & sigmoid_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & output) ;
static Tensor & sigmoid_out(Tensor & out, const Tensor & self) ;
static Tensor sign(const Tensor & self) ;
static Tensor & sign_(Tensor & self) ;
static Tensor & sign_out(Tensor & out, const Tensor & self) ;
static Tensor sin(const Tensor & self) ;
static Tensor & sin_(Tensor & self) ;
static Tensor & sin_out(Tensor & out, const Tensor & self) ;
static Tensor sinh(const Tensor & self) ;
static Tensor & sinh_(Tensor & self) ;
static Tensor & sinh_out(Tensor & out, const Tensor & self) ;
static int64_t size(const Tensor & self, int64_t dim) ;
static Tensor slice(const Tensor & self, int64_t dim, int64_t start, int64_t end, int64_t step) ;
static std::tuple<Tensor,Tensor> slogdet(const Tensor & self) ;
static Tensor slow_conv_dilated2d(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static std::tuple<Tensor,Tensor,Tensor> slow_conv_dilated2d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, std::array<bool,3> output_mask) ;
static Tensor slow_conv_dilated3d(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static std::tuple<Tensor,Tensor,Tensor> slow_conv_dilated3d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, std::array<bool,3> output_mask) ;
static Tensor slow_conv_transpose2d(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation) ;
static std::tuple<Tensor,Tensor,Tensor> slow_conv_transpose2d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation, const Tensor & columns, const Tensor & ones, std::array<bool,3> output_mask) ;
static std::tuple<Tensor &,Tensor &,Tensor &> slow_conv_transpose2d_backward_out(Tensor & grad_input, Tensor & grad_weight, Tensor & grad_bias, const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation, const Tensor & columns, const Tensor & ones) ;
static Tensor & slow_conv_transpose2d_out(Tensor & out, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation) ;
static Tensor slow_conv_transpose3d(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation) ;
static std::tuple<Tensor,Tensor,Tensor> slow_conv_transpose3d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation, const Tensor & finput, const Tensor & fgrad_input, std::array<bool,3> output_mask) ;
static std::tuple<Tensor &,Tensor &,Tensor &> slow_conv_transpose3d_backward_out(Tensor & grad_input, Tensor & grad_weight, Tensor & grad_bias, const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation, const Tensor & finput, const Tensor & fgrad_input) ;
static Tensor & slow_conv_transpose3d_out(Tensor & out, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef output_padding, IntArrayRef dilation) ;
static Tensor smm(const Tensor & self, const Tensor & mat2) ;
static Tensor smooth_l1_loss(const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor smooth_l1_loss_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & smooth_l1_loss_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & smooth_l1_loss_out(Tensor & out, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor soft_margin_loss(const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor soft_margin_loss_backward(const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & soft_margin_loss_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor & soft_margin_loss_out(Tensor & out, const Tensor & self, const Tensor & target, int64_t reduction) ;
static Tensor softmax(const Tensor & self, int64_t dim, c10::optional<ScalarType> dtype) ;
static Tensor softplus(const Tensor & self, Scalar beta, Scalar threshold) ;
static Tensor softplus_backward(const Tensor & grad_output, const Tensor & self, Scalar beta, Scalar threshold, const Tensor & output) ;
static Tensor & softplus_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, Scalar beta, Scalar threshold, const Tensor & output) ;
static Tensor & softplus_out(Tensor & out, const Tensor & self, Scalar beta, Scalar threshold) ;
static Tensor softshrink(const Tensor & self, Scalar lambd) ;
static Tensor softshrink_backward(const Tensor & grad_output, const Tensor & self, Scalar lambd) ;
static Tensor & softshrink_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & self, Scalar lambd) ;
static Tensor & softshrink_out(Tensor & out, const Tensor & self, Scalar lambd) ;
static std::tuple<Tensor,Tensor> solve(const Tensor & self, const Tensor & A) ;
static std::tuple<Tensor &,Tensor &> solve_out(Tensor & solution, Tensor & lu, const Tensor & self, const Tensor & A) ;
static std::tuple<Tensor,Tensor> sort(const Tensor & self, int64_t dim, bool descending) ;
static std::tuple<Tensor &,Tensor &> sort_out(Tensor & values, Tensor & indices, const Tensor & self, int64_t dim, bool descending) ;
static Tensor sparse_coo_tensor(IntArrayRef size, const TensorOptions & options) ;
static Tensor sparse_coo_tensor(const Tensor & indices, const Tensor & values, const TensorOptions & options) ;
static Tensor sparse_coo_tensor(const Tensor & indices, const Tensor & values, IntArrayRef size, const TensorOptions & options) ;
static int64_t sparse_dim(const Tensor & self) ;
static Tensor sparse_mask(const Tensor & self, const Tensor & mask) ;
static Tensor & sparse_resize_(Tensor & self, IntArrayRef size, int64_t sparse_dim, int64_t dense_dim) ;
static Tensor & sparse_resize_and_clear_(Tensor & self, IntArrayRef size, int64_t sparse_dim, int64_t dense_dim) ;
static std::vector<Tensor> split(const Tensor & self, int64_t split_size, int64_t dim) ;
static std::vector<Tensor> split_with_sizes(const Tensor & self, IntArrayRef split_sizes, int64_t dim) ;
static Tensor sqrt(const Tensor & self) ;
static Tensor & sqrt_(Tensor & self) ;
static Tensor & sqrt_out(Tensor & out, const Tensor & self) ;
static Tensor squeeze(const Tensor & self) ;
static Tensor squeeze(const Tensor & self, int64_t dim) ;
static Tensor & squeeze_(Tensor & self) ;
static Tensor & squeeze_(Tensor & self, int64_t dim) ;
static Tensor sspaddmm(const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor & sspaddmm_out(Tensor & out, const Tensor & self, const Tensor & mat1, const Tensor & mat2, Scalar beta, Scalar alpha) ;
static Tensor stack(TensorList tensors, int64_t dim) ;
static Tensor & stack_out(Tensor & out, TensorList tensors, int64_t dim) ;
static Tensor std(const Tensor & self, bool unbiased) ;
static Tensor std(const Tensor & self, IntArrayRef dim, bool unbiased, bool keepdim) ;
static std::tuple<Tensor,Tensor> std_mean(const Tensor & self, bool unbiased) ;
static std::tuple<Tensor,Tensor> std_mean(const Tensor & self, IntArrayRef dim, bool unbiased, bool keepdim) ;
static Tensor & std_out(Tensor & out, const Tensor & self, IntArrayRef dim, bool unbiased, bool keepdim) ;
static Tensor stft(const Tensor & self, int64_t n_fft, c10::optional<int64_t> hop_length, c10::optional<int64_t> win_length, const Tensor & window, bool normalized, bool onesided) ;
static int64_t stride(const Tensor & self, int64_t dim) ;
static Tensor sub(const Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor sub(const Tensor & self, Scalar other, Scalar alpha) ;
static Tensor & sub_(Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor & sub_(Tensor & self, Scalar other, Scalar alpha) ;
static Tensor & sub_out(Tensor & out, const Tensor & self, const Tensor & other, Scalar alpha) ;
static Tensor sum(const Tensor & self, c10::optional<ScalarType> dtype) ;
static Tensor sum(const Tensor & self, IntArrayRef dim, bool keepdim, c10::optional<ScalarType> dtype) ;
static Tensor & sum_out(Tensor & out, const Tensor & self, IntArrayRef dim, bool keepdim, c10::optional<ScalarType> dtype) ;
static Tensor sum_to_size(const Tensor & self, IntArrayRef size) ;
static std::tuple<Tensor,Tensor,Tensor> svd(const Tensor & self, bool some, bool compute_uv) ;
static std::tuple<Tensor &,Tensor &,Tensor &> svd_out(Tensor & U, Tensor & S, Tensor & V, const Tensor & self, bool some, bool compute_uv) ;
static std::tuple<Tensor,Tensor> symeig(const Tensor & self, bool eigenvectors, bool upper) ;
static std::tuple<Tensor &,Tensor &> symeig_out(Tensor & e, Tensor & V, const Tensor & self, bool eigenvectors, bool upper) ;
static Tensor t(const Tensor & self) ;
static Tensor & t_(Tensor & self) ;
static Tensor take(const Tensor & self, const Tensor & index) ;
static Tensor & take_out(Tensor & out, const Tensor & self, const Tensor & index) ;
static Tensor tan(const Tensor & self) ;
static Tensor & tan_(Tensor & self) ;
static Tensor & tan_out(Tensor & out, const Tensor & self) ;
static Tensor tanh(const Tensor & self) ;
static Tensor & tanh_(Tensor & self) ;
static Tensor tanh_backward(const Tensor & grad_output, const Tensor & output) ;
static Tensor & tanh_backward_out(Tensor & grad_input, const Tensor & grad_output, const Tensor & output) ;
static Tensor & tanh_out(Tensor & out, const Tensor & self) ;
static Tensor tensordot(const Tensor & self, const Tensor & other, IntArrayRef dims_self, IntArrayRef dims_other) ;
static Tensor thnn_conv2d(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static std::tuple<Tensor,Tensor,Tensor> thnn_conv2d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, const Tensor & finput, const Tensor & fgrad_input, std::array<bool,3> output_mask) ;
static std::tuple<Tensor &,Tensor &,Tensor &> thnn_conv2d_backward_out(Tensor & grad_input, Tensor & grad_weight, Tensor & grad_bias, const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, const Tensor & finput, const Tensor & fgrad_input) ;
static std::tuple<Tensor,Tensor,Tensor> thnn_conv2d_forward(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static std::tuple<Tensor &,Tensor &,Tensor &> thnn_conv2d_forward_out(Tensor & output, Tensor & finput, Tensor & fgrad_input, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static Tensor & thnn_conv2d_out(Tensor & out, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static Tensor thnn_conv3d(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static std::tuple<Tensor,Tensor,Tensor> thnn_conv3d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, const Tensor & finput, const Tensor & fgrad_input, std::array<bool,3> output_mask) ;
static std::tuple<Tensor &,Tensor &,Tensor &> thnn_conv3d_backward_out(Tensor & grad_input, Tensor & grad_weight, Tensor & grad_bias, const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, const Tensor & finput, const Tensor & fgrad_input) ;
static std::tuple<Tensor,Tensor,Tensor> thnn_conv3d_forward(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static std::tuple<Tensor &,Tensor &,Tensor &> thnn_conv3d_forward_out(Tensor & output, Tensor & finput, Tensor & fgrad_input, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static Tensor & thnn_conv3d_out(Tensor & out, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding) ;
static Tensor thnn_conv_depthwise2d(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static std::tuple<Tensor,Tensor> thnn_conv_depthwise2d_backward(const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation, std::array<bool,2> output_mask) ;
static std::tuple<Tensor &,Tensor &> thnn_conv_depthwise2d_backward_out(Tensor & grad_input, Tensor & grad_weight, const Tensor & grad_output, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static Tensor thnn_conv_depthwise2d_forward(const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static Tensor & thnn_conv_depthwise2d_forward_out(Tensor & out, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static Tensor & thnn_conv_depthwise2d_out(Tensor & out, const Tensor & self, const Tensor & weight, IntArrayRef kernel_size, const Tensor & bias, IntArrayRef stride, IntArrayRef padding, IntArrayRef dilation) ;
static Tensor threshold(const Tensor & self, Scalar threshold, Scalar value) ;
static Tensor & threshold_(Tensor & self, Scalar threshold, Scalar value) ;
static Tensor threshold_backward(const Tensor & grad_output, const Tensor & self, Scalar threshold) ;
static Tensor & threshold_out(Tensor & out, const Tensor & self, Scalar threshold, Scalar value) ;
static Tensor to(const Tensor & self, const TensorOptions & options, bool non_blocking, bool copy) ;
static Tensor to(const Tensor & self, Device device, ScalarType dtype, bool non_blocking, bool copy) ;
static Tensor to(const Tensor & self, ScalarType dtype, bool non_blocking, bool copy) ;
static Tensor to(const Tensor & self, const Tensor & other, bool non_blocking, bool copy) ;
static Tensor to_dense(const Tensor & self) ;
static Tensor to_dense_backward(const Tensor & grad, const Tensor & input) ;
static Tensor to_mkldnn(const Tensor & self) ;
static Tensor to_mkldnn_backward(const Tensor & grad, const Tensor & input) ;
static Tensor to_sparse(const Tensor & self, int64_t sparse_dim) ;
static Tensor to_sparse(const Tensor & self) ;
static std::tuple<Tensor,Tensor> topk(const Tensor & self, int64_t k, int64_t dim, bool largest, bool sorted) ;
static std::tuple<Tensor &,Tensor &> topk_out(Tensor & values, Tensor & indices, const Tensor & self, int64_t k, int64_t dim, bool largest, bool sorted) ;
static Tensor trace(const Tensor & self) ;
static Tensor transpose(const Tensor & self, int64_t dim0, int64_t dim1) ;
static Tensor & transpose_(Tensor & self, int64_t dim0, int64_t dim1) ;
static Tensor trapz(const Tensor & y, const Tensor & x, int64_t dim) ;
static Tensor trapz(const Tensor & y, double dx, int64_t dim) ;
static std::tuple<Tensor,Tensor> triangular_solve(const Tensor & self, const Tensor & A, bool upper, bool transpose, bool unitriangular) ;
static std::tuple<Tensor &,Tensor &> triangular_solve_out(Tensor & X, Tensor & M, const Tensor & self, const Tensor & A, bool upper, bool transpose, bool unitriangular) ;
static Tensor tril(const Tensor & self, int64_t diagonal) ;
static Tensor & tril_(Tensor & self, int64_t diagonal) ;
static Tensor tril_indices(int64_t row, int64_t col, int64_t offset, const TensorOptions & options) ;
static Tensor & tril_out(Tensor & out, const Tensor & self, int64_t diagonal) ;
static Tensor triplet_margin_loss(const Tensor & anchor, const Tensor & positive, const Tensor & negative, double margin, double p, double eps, bool swap, int64_t reduction) ;
static Tensor triu(const Tensor & self, int64_t diagonal) ;
static Tensor & triu_(Tensor & self, int64_t diagonal) ;
static Tensor triu_indices(int64_t row, int64_t col, int64_t offset, const TensorOptions & options) ;
static Tensor & triu_out(Tensor & out, const Tensor & self, int64_t diagonal) ;
static Tensor trunc(const Tensor & self) ;
static Tensor & trunc_(Tensor & self) ;
static Tensor & trunc_out(Tensor & out, const Tensor & self) ;
static Tensor type_as(const Tensor & self, const Tensor & other) ;
static std::vector<Tensor> unbind(const Tensor & self, int64_t dim) ;
static Tensor unfold(const Tensor & self, int64_t dimension, int64_t size, int64_t step) ;
static Tensor & uniform_(Tensor & self, double from, double to, Generator * generator) ;
static std::tuple<Tensor,Tensor,Tensor> unique_consecutive(const Tensor & self, bool return_inverse, bool return_counts, c10::optional<int64_t> dim) ;
static std::tuple<Tensor,Tensor,Tensor> unique_dim(const Tensor & self, int64_t dim, bool sorted, bool return_inverse, bool return_counts) ;
static std::tuple<Tensor,Tensor,Tensor> unique_dim_consecutive(const Tensor & self, int64_t dim, bool return_inverse, bool return_counts) ;
static Tensor unsqueeze(const Tensor & self, int64_t dim) ;
static Tensor & unsqueeze_(Tensor & self, int64_t dim) ;
static Tensor upsample_bicubic2d(const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor upsample_bicubic2d_backward(const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_bicubic2d_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_bicubic2d_out(Tensor & out, const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor upsample_bilinear2d(const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor upsample_bilinear2d_backward(const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_bilinear2d_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_bilinear2d_out(Tensor & out, const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor upsample_linear1d(const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor upsample_linear1d_backward(const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_linear1d_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_linear1d_out(Tensor & out, const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor upsample_nearest1d(const Tensor & self, IntArrayRef output_size) ;
static Tensor upsample_nearest1d_backward(const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size) ;
static Tensor & upsample_nearest1d_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size) ;
static Tensor & upsample_nearest1d_out(Tensor & out, const Tensor & self, IntArrayRef output_size) ;
static Tensor upsample_nearest2d(const Tensor & self, IntArrayRef output_size) ;
static Tensor upsample_nearest2d_backward(const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size) ;
static Tensor & upsample_nearest2d_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size) ;
static Tensor & upsample_nearest2d_out(Tensor & out, const Tensor & self, IntArrayRef output_size) ;
static Tensor upsample_nearest3d(const Tensor & self, IntArrayRef output_size) ;
static Tensor upsample_nearest3d_backward(const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size) ;
static Tensor & upsample_nearest3d_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size) ;
static Tensor & upsample_nearest3d_out(Tensor & out, const Tensor & self, IntArrayRef output_size) ;
static Tensor upsample_trilinear3d(const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor upsample_trilinear3d_backward(const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_trilinear3d_backward_out(Tensor & grad_input, const Tensor & grad_output, IntArrayRef output_size, IntArrayRef input_size, bool align_corners) ;
static Tensor & upsample_trilinear3d_out(Tensor & out, const Tensor & self, IntArrayRef output_size, bool align_corners) ;
static Tensor values(const Tensor & self) ;
static Tensor var(const Tensor & self, bool unbiased) ;
static Tensor var(const Tensor & self, IntArrayRef dim, bool unbiased, bool keepdim) ;
static std::tuple<Tensor,Tensor> var_mean(const Tensor & self, bool unbiased) ;
static std::tuple<Tensor,Tensor> var_mean(const Tensor & self, IntArrayRef dim, bool unbiased, bool keepdim) ;
static Tensor & var_out(Tensor & out, const Tensor & self, IntArrayRef dim, bool unbiased, bool keepdim) ;
static Tensor view(const Tensor & self, IntArrayRef size) ;
static Tensor view_as(const Tensor & self, const Tensor & other) ;
static Tensor where(const Tensor & condition, const Tensor & self, const Tensor & other) ;
static std::vector<Tensor> where(const Tensor & condition) ;
static Tensor & zero_(Tensor & self) ;
static Tensor zeros(IntArrayRef size, const TensorOptions & options) ;
static Tensor zeros_like(const Tensor & self) ;
static Tensor zeros_like(const Tensor & self, const TensorOptions & options) ;
static Tensor & zeros_out(Tensor & out, IntArrayRef size) ;
private:
// checks that t is actually a Variable
static const Variable & checked_cast_variable(const Tensor & t, const char * name, int pos);
static Variable & checked_cast_variable(Tensor & t, const char * name, int pos);
static at::Tensor & unpack(Tensor & t, const char * name, int pos);
static const at::Tensor & unpack(const Tensor & t, const char * name, int pos);
static at::Tensor unpack_opt(const Tensor & t, const char * name, int pos);
static std::vector<at::Tensor> unpack(at::TensorList tl, const char *name, int pos);
};
}} // namespace torch::autograd
| [
"taox@fb.com"
] | taox@fb.com |
d3a317340c23bd420c6e1f8b81ebd12810683ce5 | f36f69f28a27cbf278d54efae45222b7071b75f1 | /OOP_Lab/0402-Maximize Pulse/Source.cpp | 1b9856d90ea2c65de04299df4664db5ab5802c9c | [] | no_license | leeyk0501/NTUST-CSIE-OOP | 139bbf190be8543b06e9e4d7832170aba57cbc9d | 03e36a30895502b59cea03a768148ff76ed93e35 | refs/heads/master | 2020-03-18T16:05:02.901847 | 2018-07-01T10:36:29 | 2018-07-01T10:36:29 | null | 0 | 0 | null | null | null | null | BIG5 | C++ | false | false | 1,876 | cpp | // Name: 李聿鎧
// Date: March 22, 2018
// Last Update: March 22, 2018
// Problem statement: C++ Homework "0402 - Maximize Pulse"
#include<iostream>
#include<string>
#include<vector>
#include<map>
using namespace std;
int max;
struct strInfor
{
int index;
double probability;
};
// Intent: 計算該字串的maximizePulse
// Pre: pulseStr字串長度大於0
// Post: 回傳該字串的maximizePulse
int maximizePulse(string pulseStr)
{
int max = 0;
for (int i = pulseStr.size() - 1; i >= 0; i--)
{
if (pulseStr[i] == '0')
{
for (int j = i - 1; j >= 0; j--)
{
if (pulseStr[j] == '1')
{
max++;
}
}
}
}
return max;
}
// Intent: 計算該字串的出現1的比率
// Pre: str字串長度大於0
// Post: 回傳該字串的出現1的比率
double strProbability(string str)
{
double count = 0, size = str.size();
for (int i = 0; i < str.size(); i++)
{
if (str[i] == '1')
{
count++;
}
}
return (count / size);
}
int main()
{
int n;
string str;
vector<string> strData;
vector<strInfor> infor;
strInfor tempInfo;
while (cin >> n)
{
//初始化
max = -1;
strData.clear();
infor.clear();
//輸入每一筆資料,算出每筆資料"出現1的比率"
for (int i = 0; i < n; i++)
{
cin >> str;
strData.push_back(str);
tempInfo.index = i;
tempInfo.probability = strProbability(str);
infor.push_back(tempInfo);
}
//以比率(probability)做排序
int size = infor.size();
for (int i = 0; i < size - 1; i++)
{
for (int j = i + 1; j < size; j++)
{
if (infor[i].probability < infor[j].probability)
{
swap(infor[i], infor[j]);
}
}
}
//依比率由大到小組合出字串
str.clear();
for (int i = 0; i < size; i++)
{
str += strData[infor[i].index];
}
//輸出該字串的maximizePulse
cout << maximizePulse(str) << endl;
}
return 0;
} | [
"kevin991239@gmail.com"
] | kevin991239@gmail.com |
a7853a1c751366d9370d926c95433a71c708abb1 | b7a0ac5d1db9d54fa67a49147ef2350f07ccf857 | /ATK/Distortion/SD1OverdriveFilter.cpp | 5e00043829f125682814610d4b11eb60085a0cbb | [
"BSD-3-Clause"
] | permissive | xinsuinizhuan/AudioTK | a14e8812145d2e7da0fa02209805441e66255a14 | dba42eea68534501efe74692b74edf4792cca231 | refs/heads/main | 2023-04-16T04:36:09.831280 | 2021-02-18T19:53:58 | 2021-02-18T19:53:58 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,983 | cpp | /**
* \file SD1OverdriveFilter.cpp
*/
#include "SD1OverdriveFilter.h"
#include <ATK/Utility/fmath.h>
#include <ATK/Utility/ScalarNewtonRaphson.h>
#include <boost/math/special_functions/sign.hpp>
#include <stdexcept>
namespace ATK
{
template<typename DataType_>
class SD1OverdriveFilter<DataType_>::SD1OverdriveFunction
{
public:
using DataType = DataType_;
protected:
const DataType R;
const DataType R1;
const DataType C;
const DataType Q;
DataType drive = 0.5;
const DataType is;
const DataType vt;
DataType ieq{0};
DataType i{0};
DataType expdiode_y1_p{1};
DataType expdiode_y1_m{1};
public:
SD1OverdriveFunction(DataType dt, DataType R, DataType C, DataType R1, DataType Q, DataType is, DataType vt)
:R(R), R1(R1), C(2 * C / dt), Q(Q), is(is), vt(vt)
{
}
void set_drive(DataType drive)
{
this->drive = (R1 + drive * Q);
}
std::pair<DataType, DataType> operator()(const DataType* ATK_RESTRICT input, DataType* ATK_RESTRICT output, DataType y1)
{
auto x1 = input[0];
y1 -= x1;
expdiode_y1_p = fmath::exp(y1 / vt);
expdiode_y1_m = 1 / expdiode_y1_p;
DataType diode1 = is * (expdiode_y1_p - 2 * expdiode_y1_m + 1);
DataType diode1_derivative = is * (expdiode_y1_p + 2 * expdiode_y1_m) / vt;
i = (C * x1 - ieq) / (1 + R * C);
return std::make_pair(y1 / drive + diode1 - i, 1 / drive + diode1_derivative);
}
void update_state(const DataType* ATK_RESTRICT input, DataType* ATK_RESTRICT output)
{
auto x1 = input[0];
ieq = 2 * C * (x1 - i * R) - ieq;
}
DataType estimate(const DataType* ATK_RESTRICT input, DataType* ATK_RESTRICT output)
{
auto x0 = input[-1];
auto x1 = input[0];
auto y0 = output[-1];
return affine_estimate(x0, x1, y0);
}
DataType affine_estimate(DataType x0, DataType x1, DataType y0)
{
y0 -= x0;
auto sinh = is * (expdiode_y1_p - 2 * expdiode_y1_m + 1);
auto cosh = is * (expdiode_y1_p + 2 * expdiode_y1_m);
auto i = (C * x1 - ieq) / (1 + R * C);
return (i - (sinh - y0 / vt * cosh)) / (cosh / vt + (1 / drive)) + x1;
}
};
template <typename DataType>
SD1OverdriveFilter<DataType>::SD1OverdriveFilter()
:TypedBaseFilter<DataType>(1, 1)
{
input_delay = 1;
output_delay = 1;
}
template <typename DataType>
SD1OverdriveFilter<DataType>::~SD1OverdriveFilter()
{
}
template <typename DataType>
void SD1OverdriveFilter<DataType>::setup()
{
Parent::setup();
optimizer = std::make_unique<ScalarNewtonRaphson<SD1OverdriveFunction, num_iterations, true>>(SD1OverdriveFunction(static_cast<DataType>(1. / input_sampling_rate),
static_cast<DataType>(4.7e3), static_cast<DataType>(0.047e-6), static_cast<DataType>(33e3),
static_cast<DataType>(1e6), static_cast<DataType>(1e-12), static_cast<DataType>(26e-3)));
optimizer->get_function().set_drive(drive);
}
template <typename DataType_>
void SD1OverdriveFilter<DataType_>::set_drive(DataType_ drive)
{
if(drive < 0 || drive > 1)
{
throw std::out_of_range("Drive must be a value between 0 and 1");
}
this->drive = drive;
if(optimizer)
{
optimizer->get_function().set_drive(drive);
}
}
template <typename DataType_>
DataType_ SD1OverdriveFilter<DataType_>::get_drive() const
{
return drive;
}
template <typename DataType>
void SD1OverdriveFilter<DataType>::process_impl(gsl::index size) const
{
const DataType* ATK_RESTRICT input = converted_inputs[0];
DataType* ATK_RESTRICT output = outputs[0];
for(gsl::index i = 0; i < size; ++i)
{
optimizer->optimize(input + i, output + i);
optimizer->get_function().update_state(input + i, output + i);
}
}
#if ATK_ENABLE_INSTANTIATION
template class SD1OverdriveFilter<float>;
#endif
template class SD1OverdriveFilter<double>;
}
| [
"matthieu.brucher@gmail.com"
] | matthieu.brucher@gmail.com |
38bebe4029c514ba26e912ecb5f1802930375d61 | eee4e1d7e3bd56bd0c24da12f727017d509f919d | /Case/case6/1200/PMV | 6a219b3ca68adc1f96b72187688fadebbb9efe9c | [] | no_license | mamitsu2/aircond5_play5 | 35ea72345d23c5217564bf191921fbbe412b90f2 | f1974714161f5f6dad9ae6d9a77d74b6a19d5579 | refs/heads/master | 2021-10-30T08:59:18.692891 | 2019-04-26T01:48:44 | 2019-04-26T01:48:44 | 183,529,942 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,300 | /*--------------------------------*- C++ -*----------------------------------*========= |
\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\ / O peration | Website: https://openfoam.org
\ / A nd | Version: 6
\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "1200";
object PMV;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField nonuniform List<scalar>
458
(
2.989811227357476
2.7044844453981485
2.66776759611421
2.644885553299103
2.6305625749883923
2.6229828361764698
2.6185249600926745
2.6160077236712387
2.6148029082477593
2.6143698938051276
2.6148641205857692
2.6171619724945314
2.620819987824424
2.6283559314303813
2.630294078669487
2.2491445944725927
2.246275030085776
2.243405254430958
2.2381434543177168
2.2338378250542505
2.2333593930998044
2.2357514955563804
2.239578560318255
2.241013614196506
2.243405254430958
2.2477098387627303
2.2544049098036956
2.263967265374475
2.2582301408517407
2.2520139463874065
2.2491445944725927
2.2453184616158235
2.2391001974354876
2.8145357639822457
2.6851082658790104
2.616940986660778
2.5827628034420473
2.5644512328986906
2.555297971303244
2.5512557011567134
2.5505338259495143
2.5522733084911264
2.555936520621129
2.5621608982289934
2.5709858738110922
2.5821797605530272
2.5951723809579406
2.604726627516787
2.6064270723094585
2.622714478394104
2.6472851055441535
2.3432364025310135
2.333695721701075
2.331310111744447
2.322720479864208
2.3098318857548783
2.2926395546658003
2.2811733466410615
2.270659470321099
2.2720933577012397
2.275438878419028
2.279261957382287
2.284518035392652
2.289295623284346
2.2926395546658003
2.3017143433870424
2.3021918986477403
2.295505530547496
2.289295623284346
2.7109687795402233
2.5573800506162954
2.5061648097946145
2.4895176946190003
2.4870877765754167
2.488303911693681
2.4899437756614957
2.4931086663989377
2.499573596965098
2.509379456195032
2.521931276604041
2.536495736856781
2.5525913467578234
2.569075408357727
2.5849381535373723
2.598340653800245
2.6141057294393324
2.6258182376928727
2.425162079458623
2.4265889070441045
2.428489967662133
2.4327696857819228
2.4294410763452405
2.3818463448040292
2.3570653006637023
2.346098052342156
2.337035281392821
2.3289243276151126
2.320811370220182
2.3122190329567807
2.3064895998441988
2.346098052342156
2.40041844186164
2.3813699802748016
2.3699349284042626
2.366598880883047
2.6494684789544123
2.4402811317781987
2.4345803093485983
2.461964697124181
2.487692116716492
2.5010475991202816
2.5061880238935683
2.50789951086151
2.509288162814616
2.5130736993102394
2.5196536336033035
2.5294156754349957
2.5422167727151557
2.5576744416040516
2.574015426834706
2.589234872456085
2.602741133137204
2.6100365157567977
2.5724549424182834
2.474226490550406
2.4888141366739154
2.4940319113093596
2.5016192491511102
2.5079273100571413
2.5131302807634484
2.5158384831004375
2.5163122969554848
2.516786100322572
2.516786100322572
2.5172598931897245
2.517733675544998
2.5172598931897245
2.514890823974325
2.4992484823751804
2.4783750349425824
2.4532074396574464
2.428253393109194
2.5915744524849513
2.3409031947418573
2.4091292368912454
2.4968518036188434
2.54285787826319
2.5583896569638354
2.5611514234829587
2.5588066197602077
2.550898486653411
2.543847065267977
2.5396468174413096
2.5399653143562415
2.5451045743353387
2.5556431915525293
2.568940545385715
2.5836177190275884
2.5955918801089197
2.603027124157982
2.577639759484673
2.5332529866194236
2.512047596124548
2.5115736884136393
2.5144169787270805
2.516778164217463
2.518207447376311
2.51868120867167
2.51868120867167
2.51915495941899
2.51915495941899
2.519628699606248
2.5201024292212377
2.5201024292212377
2.51868120867167
2.514890823974325
2.5073080538050085
2.4930833141017636
2.4485804234342687
2.4387620180946614
2.4359621049736186
2.456539065403925
2.5294352202771937
2.2839808721539185
2.416451011232403
2.5572730081412964
2.570075110637829
2.5794699004650536
2.588404528567557
2.5924506257608946
2.588674623759188
2.5805463295935165
2.560783037650138
2.5516583515805444
2.551446077205594
2.557866727630318
2.5689420205086044
2.581530500201008
2.5925308581297988
2.5982560797445218
2.572085596787249
2.528528006790016
2.519628699606248
2.517733675544998
2.51915495941899
2.520576148251966
2.5210498566862443
2.5215235545119277
2.5215235545119277
2.5210498566862443
2.5215235545119277
2.5215235545119277
2.521997241716834
2.5224709182887324
2.5224709182887324
2.5215235545119277
2.5201024292212377
2.516786100322572
2.512047596124548
2.5073366634921075
2.4699687810069144
2.4446600233213824
2.4600555172652676
2.2708068326326125
2.4208644625316986
2.5664304671386606
2.5572806697184265
2.5588176113757646
2.5585138364663167
2.5588143183345853
2.5585397408692976
2.5566835527320193
2.5533464544682465
2.552280225348794
2.553989189714055
2.5607971734598873
2.5705387697108413
2.581818751100099
2.5905690244384183
2.591442858601122
2.561145369232735
2.5225734864221754
2.5238918840842937
2.5224709182887324
2.5238918840842937
2.524839141225227
2.525312753742002
2.525312753742002
2.5243655180019178
2.5238918840842937
2.523418239484733
2.523418239484733
2.520087425380499
2.5143501327528246
2.508322040582418
2.5024158981580724
2.4978626962592445
2.494547651245048
2.4928276108862453
2.497236257009444
2.5144169787270805
2.416477374229376
2.394114747560387
2.237670467293892
2.345003555642292
2.549329051209418
2.542188810908412
2.544492811045349
2.5436388517205457
2.5425714674335658
2.542209653224833
2.542910398331802
2.545076281479396
2.549374517843913
2.5554173385242414
2.563659788899777
2.5733813307747235
2.58256878409539
2.587979250466899
2.5826318923903333
2.55094815077223
2.522432564154675
2.5286277405350845
2.5281542033112707
2.5295747825524546
2.530995264314858
2.5314687365150563
2.5305217812459646
2.5286277405350845
2.527207096495812
2.5257863555397972
2.525312753742002
2.52383247963782
2.5129378202712673
2.5014362424130168
2.4900033952481495
2.478976767400134
2.4700374140126296
2.4631955236078915
2.458594322484793
2.4515939169530734
2.429136186839452
2.3366896791483995
2.113551681550915
2.0889602173031245
2.5284527622328046
2.536314973975197
2.5420766413392926
2.542215660414759
2.5414497533372673
2.541216492330892
2.542179449862329
2.5451951440731584
2.5504190160805176
2.5577487252053075
2.566038512368543
2.5748674448664244
2.581968076765301
2.5840311793907054
2.5746679079574717
2.5465247738152934
2.5306461379135463
2.536202857953009
2.5357294951371756
2.5380961990009134
2.5390428032150485
2.53856950664456
2.537149550545787
2.5347827365308087
2.531942197833968
2.529101266952979
2.527207096495812
2.5257863555397972
2.5257863555397972
2.526259946606268
2.527207096495812
2.5281542033112707
2.5272594420289964
2.528375148611407
2.5270795018253747
2.4980762796694327
2.447569760635987
1.5907378584255993
2.5211660041184283
2.541844764003466
2.5454985821940497
2.5455850294115825
2.5443726609417343
2.5443010051085833
2.5453278978677436
2.548066657154685
2.552630419566437
2.559039198833325
2.566158945030536
2.573880606786572
2.5799169176202015
2.580602858590747
2.5718419697825157
2.5524124318560424
2.549782282458277
2.5485063891166613
2.5475602330739022
2.5480333167637594
2.5480333167637594
2.5466140317371107
2.544248330934662
2.5409358785053717
2.537622880296994
2.5338359340435113
2.5305217812459646
2.5281542033112707
2.526259946606268
2.525312753742002
2.525312753742002
2.525312753742002
2.521782285091165
2.514543392830001
2.5024076305722773
2.4873628866367525
2.4730308777088785
2.3337196877929633
2.5482582918326373
2.5513204390807105
2.5477544326963013
2.5449054292791975
2.5437597870187685
2.5440258752863403
2.545564425493786
2.548057452933822
2.55211851365663
2.557478130582029
2.5649744379383352
2.572800511170882
2.5812905543521265
2.58854972985575
2.5917920307599407
2.5910347199168715
2.557575853575094
2.5341382642331043
2.5241810472996784
2.520256340967882
2.5199142336551517
2.5190912372818186
2.5177817696636535
2.5153903363161145
2.512559681220848
2.5095303120984735
2.5073035177568515
2.5063863177207257
2.505080312368955
2.502545132187208
2.497794389821625
2.4914325374234814
2.4841906687885964
2.478376269557536
2.47330118207343
2.460867846232023
2.4685288814744286
3.0
3.0
2.54391943227499
2.5660993091412454
2.5489133876581165
2.5412252653692833
2.53677008647823
2.534430021578623
2.53368308969144
2.534368026490756
2.536245161558661
2.5391701682453984
2.542647743461565
2.546701385225397
2.5510740143562067
2.5542077873468427
2.5531081784512653
2.5432119603096366
2.517579184694372
2.5021762434161525
2.491861047881387
2.483970887654197
2.478906847115786
2.4748702325722034
2.4706459875459976
2.466360436865886
2.461519407096206
2.4563008204622325
2.450898521624758
2.446833309359321
2.443144400271399
2.440629034625803
2.438442263385233
2.4362344133685045
2.433716351703415
2.4308175030955885
2.430277269803193
2.431233902390262
2.4258536444353416
2.3925511565046493
)
;
boundaryField
{
".*"
{
type zeroGradient;
}
}
// ************************************************************************* //
| [
"mitsuaki.makino@tryeting.jp"
] | mitsuaki.makino@tryeting.jp | |
bfc4ae7fca9de26cd5a5ef173b7b99af460c7d20 | 1dc2047d74b40dc9cb17ae38b21e0f8d2ad977fe | /integratedSketch/integratedSketch.ino | 557486f537b4fdce2c99b1efd7684d54d925aa73 | [] | no_license | caseyhofford/Arduino | 483842ec46ba81266129782869547662a7e563ea | e2a032fbffa1eed7e94ead575b95161db4ec8503 | refs/heads/master | 2021-01-22T20:54:16.819798 | 2017-04-12T19:40:34 | 2017-04-12T19:40:34 | 85,372,013 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,546 | ino | #include <SparkFunTSL2561.h>
#include <Wire.h>
#include <DHT.h>
#include <DHT_U.h>
#include <EEPROM.h>
#include <extEEPROM.h>
#include <avr/sleep.h>
#include "DHT.h"
#define disk1 0x50
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22
const int hygrometer = A0;
unsigned long msStart;
unsigned long msLast;
int duration = 24; //length to record in hours
uint16_t address = 0;
const uint32_t totalKBytes = 32; //for read and write test functions
extEEPROM eep(kbits_256, 1, 64); //device size, number of devices, page size
SFE_TSL2561 light;
boolean gain;
unsigned int ms;
struct Measurement {
float temp;
float humidity;
float lux;
float moisture;
unsigned long time;
};
struct Sums {
float temp;
int temp_count;
float humidity;
int humidity_count;
float lux;
int lux_count;
float moisture;
int moisture_count;
};
DHT dht(DHTPIN, DHTTYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Program Started");
//uint8_t *addressPtr = (uint8_t*)&address;
//eep.read(0,addressPtr,2);//write to the address variable the first two bytes of eeprom, this will ensure data collection continues if power is interrupted
dht.begin();
msStart = millis();
msLast = msStart;
uint8_t eepStatus = eep.begin(twiClock400kHz);
if (eepStatus) {
Serial.print(F("extEEPROM.begin() failed, status = "));
Serial.println(eepStatus);
while (1);
}
}
void loop() {
// put your main code here, to run repeatedly:
float temp;
float humidity;
double lux;//stores the lux value
float moisture;
/*Serial.print("Current time: ");
Serial.println(millis());
Serial.print("Start: ");
Serial.println(msStart);
Serial.print("Last: ");
Serial.println(msLast);
Serial.print("Diff: ");
Serial.println(millis()-msLast);*/
Sums sums{
0,0,0,0,0,0,0,0,
};
while(millis()-msLast < ((duration*60*60)/1.6)) {
if(Serial.available() > 0){
sendData();
}
float t = dht.readTemperature();
float h = dht.readHumidity();
Serial.println(t);
int data0;//these strore individual values from the light sensor that are used by the light library for lux calculation.
int data1;
light.getLux(gain,ms,data0,data1,lux);
moisture = readHygrometer();
if (isnan(t) || isnan(h) || isnan(lux) || isnan(moisture)) {
Serial.println("Error with a reading");
}
if(!isnan(t)) {
sums.temp += t;
sums.temp_count++;
}
if(!isnan(h)) {
sums.humidity += h;
sums.humidity_count++;
}
if(!isnan(lux)) {
sums.lux += lux;
sums.lux_count++;
}
if(!isnan(moisture)) {
sums.moisture += moisture;
sums.moisture_count++;
}
// Serial.print("Temperature: ");
// Serial.println(t);
// Serial.print("Humidity: ");
// Serial.println(h);
// Serial.print("Lux: ");
// Serial.println(lux);
// Serial.print("Soil moisture: ");
// Serial.println(moisture);
delay(5000);
}
msLast = millis();//records time at which the last reading was taken
//unsigned long mseconds = msStart-msLast; //records the time from the start that the reading was taken
Measurement reading = {
sums.temp/sums.temp_count, sums.humidity/sums.humidity_count, sums.lux/sums.lux_count, sums.moisture/sums.moisture_count, millis()
};
/*Serial.print("Reading size: ");
Serial.println(sizeof(reading));
Serial.println("*************Into Memory**************");
Serial.print(reading.temp);
Serial.print(":::");
Serial.print(reading.humidity);
Serial.print(":::");
Serial.print(reading.lux);
Serial.print(":::");
Serial.print(reading.moisture);
Serial.print(":::");
Serial.println(reading.time);*/
uint8_t *ptr = (uint8_t*)&reading;
eep.write(address, ptr, sizeof(reading));
/*Serial.println("********************From Memory*********************");
Serial.print(stored.temp);
Serial.print(":::");
Serial.print(stored.humidity);
Serial.print(":::");
Serial.print(stored.lux);
Serial.print(":::");
Serial.print(stored.moisture);
Serial.print(":::");
Serial.println(stored.time);*/
if(address <= 32747){
address += sizeof(reading);
//uint8_t *addressPtr = (uint8_t)&address;
//eep.write(0,addressPtr,2);//the first 2 bytes of eeprom store the next available address, this allows you to distinguish old and new data in case of a power loss.
}
else{
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode();
}
}
void sendData() {
int send_address = 0;
char request = Serial.read();
Serial.println(request);
if(request = 1) {
while (send_address<32760){
Measurement reading;
uint8_t *ptr = (uint8_t*)&reading;
uint8_t status = eep.read(send_address, ptr, 20);
if (status){
Serial.print("error reading EEPROM at ");
Serial.println(send_address);
}
Serial.print(reading.temp);
Serial.print(",");
Serial.print(reading.humidity);
Serial.print(",");
Serial.print(reading.lux);
Serial.print(",");
Serial.print(reading.moisture);
Serial.print(",");
Serial.print(reading.time);
Serial.print(",");
Serial.println(send_address);
send_address += sizeof(reading);
delay(10);
}
}
}
int readHygrometer() {
int value;
value = analogRead(hygrometer); //Read analog value
value = constrain(value,400,1023); //Keep the ranges!
value = map(value,400,1023,10000,0);
return value;
}
| [
"casey.hofford@gmail.com"
] | casey.hofford@gmail.com |
a007c72c442fa7c0a98bf05087655f6c2962b5ab | 5195ce1a3f3fe45dc572f84773dcbf57fb8f05eb | /2.cpp | b074c61bbb86e792cb9656b74ed1890eb46000c9 | [] | no_license | asddzxcc1856/-High-school-1st-practice- | b9f2f354665c5739d9d3bc65887fdf80271a8b2b | 148a054c5a64845769c47662e596405611b988dd | refs/heads/master | 2023-08-14T06:02:12.713873 | 2023-07-19T01:40:19 | 2023-07-19T01:40:19 | 231,220,200 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 724 | cpp | #include <iostream>
using namespace std;
int main ()
{
int a,b,c,d;
while (cin >> a >> b >> c >> d)
{
if (a==0 && b==0 && c==0 && d==0)
return 0;
else
{
int q1,q2,ans;
if (c>=a)
q1=c-a;
else
q1=a-c;
if (d>=b)
q2=d-b;
else
q2=b-d;
if (q1==q2 && q1 && q2)
ans=1;
else if (q1!=q2 && q1==0 && q2 )
ans=1;
else if (q1!=q2 && q1 && q2==0 )
ans=1;
else if (q1!=q2)
ans=2;
else if (q1==q2 && q1==0 && q2==0)
ans=0;
cout << ans <<endl;
}
}
}
| [
"noreply@github.com"
] | asddzxcc1856.noreply@github.com |
14699fb44858640db03c15f3b008f1e34c4f78f5 | 88ff0f4227d8f2004df52205cde54f568256597a | /task_1_6_5.cpp | ac71a221b9a17ae20fc5f7d44a40917d2bf6826d | [] | no_license | AlterFritz88/intro_to_prog_c_plus_plus | 6f5322ff6d2ce17ab5252db62cb774fcfb075598 | d83b15bbfad2252a041a560487b2dcc5c6b39c16 | refs/heads/master | 2020-06-13T04:39:24.602066 | 2019-07-16T10:18:53 | 2019-07-16T10:18:53 | 194,537,678 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 215 | cpp | #include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b, c, p, s;
cin >> a >> b >> c;
p = (a + b + c) / 2;
s = sqrt(p*(p-a)*(p-b)*(p-c));
cout << s;
return 0;
}
| [
"burdin009@gmail.com"
] | burdin009@gmail.com |
289093c38490530dba18ac407cd4e7651e740c15 | 3490f08b7fbf8668ce83e2f3323675837f7df4f0 | /global.h | 2d7aef35f02aa85d474437fb7df2e5afe2373067 | [] | no_license | ternz/httpclient | 0a58d7feacb144a12c1b9a9b72cceb5aeecb9e29 | 3591f1b4b08b96f965ddb42f16caa15c0c41eb89 | refs/heads/master | 2021-01-01T15:43:20.131644 | 2017-08-22T08:19:26 | 2017-08-22T08:19:26 | 97,683,805 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 529 | h | #ifndef __GLOBAL_H__
#define __GLOBAL_H__
#include <curl/curl.h>
#include "define.h"
namespace http {
#ifndef CURL_GLOBAL
#define CURL_GLOBAL CURL_GLOBAL_ALL
#endif
#define STR1(R) #R
#define STR2(R) STR1(R)
class GlobalObject {
public:
GlobalObject() {
//httpclient_debug("curl global init:%d\n", CURL_GLOBAL);
curl_global_init(CURL_GLOBAL);
}
~GlobalObject() {
//httpclient_debug("curl global cleanup\n");
curl_global_cleanup();
}
void Init() {
//void function
}
};
extern GlobalObject object;
}
#endif
| [
"862910030@qq.com"
] | 862910030@qq.com |
f85013c9415aad877b308f1acffe382dd52579d6 | a0ffa0eed06e3760ffcdce421dcbfaa1e30e1889 | /src/util.cpp | bd31649a3f1cadd927a8ff1d2ed1416d8aac7b1f | [
"MIT"
] | permissive | khushit-shah/thc-chess-library | 774f95d5486da661b39b7287164c10850088b0f4 | 20d470d15143c6e82835d6844f8eb36679e65b4c | refs/heads/master | 2020-09-25T21:23:51.237266 | 2019-08-07T03:29:53 | 2019-08-07T03:29:53 | 226,091,483 | 2 | 0 | MIT | 2019-12-05T11:56:23 | 2019-12-05T11:56:23 | null | UTF-8 | C++ | false | false | 5,298 | cpp | /*
Utility functions
Bill Forster, October 2018
*/
#include <iostream>
#include <string>
#include <stdarg.h> // For va_start, etc.
#include "util.h"
namespace util
{
void putline(std::ostream &out,const std::string &line)
{
out.write( line.c_str(), line.length() );
out.write( "\n", 1 );
}
std::string sprintf( const char *fmt, ... )
{
int size = strlen(fmt) * 3; // guess at size
std::string str;
va_list ap;
for(;;)
{
str.resize(size);
va_start(ap, fmt);
int n = vsnprintf((char *)str.data(), size, fmt, ap);
va_end(ap);
if( n>-1 && n<size ) // are we done yet?
{
str.resize(n);
return str;
}
if( n > size ) // Needed size returned
size = n + 1; // For null char
else
size *= 4; // Guess at a larger size
}
return str;
}
bool prefix( const std::string &s, const std::string prefix )
{
size_t offset = s.find(prefix);
return (offset == 0);
}
bool suffix( const std::string &s, const std::string suffix )
{
return( s.length() >= suffix.length() &&
suffix == s.substr(s.length()-suffix.length(), suffix.length())
);
}
bool prefix_remove( std::string &s, const std::string prefix )
{
size_t offset = s.find(prefix);
bool found = (offset == 0);
if( found )
s = s.substr(prefix.length());
return found;
}
void ltrim( std::string &s )
{
size_t first_char_offset = s.find_first_not_of(" \n\r\t");
if( first_char_offset == std::string::npos )
s.clear();
else
s = s.substr(first_char_offset);
}
void rtrim( std::string &s )
{
size_t final_char_offset = s.find_last_not_of(" \n\r\t");
if( final_char_offset == std::string::npos )
s.clear();
else
s.erase(final_char_offset+1);
}
// Try for a little efficiency, return true if changes made
bool trim( std::string &s )
{
bool changed=false;
size_t len = s.length();
if( len > 0 )
{
size_t first_char_offset = s.find_first_not_of(" \n\r\t");
if( first_char_offset == std::string::npos )
{
s.clear(); // string is all whitespace
return true;
}
else if( first_char_offset > 0 )
{
s = s.substr(first_char_offset); // effect left trim
changed = true;
}
size_t final_char_offset = s.find_last_not_of(" \n\r\t");
if( final_char_offset != std::string::npos && final_char_offset < len-1 )
{
s.erase(final_char_offset+1); // effect right trim
changed = true;
}
}
return changed;
}
static bool test_expect( std::string test_id, bool b, bool b_expected, const std::string s, const std::string s_expected )
{
bool ok=true;
if( b != b_expected )
{
printf( "test %s: failed, 1st parameter wrong\n", test_id.c_str() );
ok = false;
}
if( s != s_expected )
{
printf( "test %s: failed, 2nd parameter was %s\n", test_id.c_str(), s.c_str() );
ok = false;
}
return ok;
}
void tests()
{
std::string s;
s = " ";
bool changed = trim(s);
test_expect( "1.0", changed, true, s, "" );
s = " hello";
changed = trim(s);
test_expect( "1.1", changed, true, s, "hello" );
s = "hello ";
changed = trim(s);
test_expect( "1.2", changed, true, s, "hello" );
s = " hello ";
changed = trim(s);
test_expect( "1.3", changed, true, s, "hello" );
s = "hello";
changed = trim(s);
test_expect( "1.4", changed, false, s, "hello" );
}
void replace_all( std::string &s, const std::string from, const std::string to )
{
size_t next = 0;
for(;;)
{
size_t offset = s.find(from,next);
if( offset == std::string::npos )
break;
else
s.replace(offset,from.length(),to);
next = offset+to.length();
}
}
void replace_once( std::string &s, const std::string from, const std::string to )
{
size_t offset = s.find(from);
if( offset != std::string::npos )
s.replace(offset,from.length(),to);
}
void split( std::string &s, std::vector<std::string> &fields )
{
fields.clear();
size_t next = 0;
bool more = true;
while( more && s.length()>next)
{
size_t offset = s.find('\t',next);
std::string frag;
if( offset != std::string::npos )
frag = s.substr(next,offset-next);
else
{
frag = s.substr(next);
more = false;
}
fields.push_back(frag);
if( more )
next = offset+1;
}
}
std::string toupper( const std::string &s )
{
std::string r = s;
for( unsigned int i=0; i<r.length(); i++ )
{
char c = r[i];
if( 'a'<=c && c<='z' )
{
c -= 0x20;
r[i] = c;
}
}
return r;
}
std::string tolower( const std::string &s )
{
std::string r = s;
for( unsigned int i=0; i<r.length(); i++ )
{
char c = r[i];
if( 'A'<=c && c<='Z' )
{
c += 0x20;
r[i] = c;
}
}
return r;
}
} //namespace util
| [
"billforsternz@gmail.com"
] | billforsternz@gmail.com |
fcd7e2bef23478ca7012abefc40118856d4d1102 | d67a3bee00719170c94b04bcb229b564f490a1d2 | /Ass_Terrain/ModelEditor/UnitTest/MrtDemo.h | e0ae1de47a34cd931e5f041c08e8987b3719fca3 | [] | no_license | ilttac/Ass | 8520b2d7a246740149194f7bf9b6f8f33f5445e2 | a2ab4396a7c35419f47142459f5c3bc1110cc4b0 | refs/heads/master | 2022-12-22T18:04:50.051019 | 2020-09-08T15:13:48 | 2020-09-08T15:13:48 | 266,674,847 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,223 | h | #pragma once
#include "Systems/IExecute.h"
class MrtDemo : public IExecute
{
public:
virtual void Initialize() override;
virtual void Ready() override {};
virtual void Destroy() override;
virtual void Update() override;
virtual void PreRender() override;
virtual void Render() override;
virtual void PostRender() override {};
virtual void ResizeScreen() override {};
private:
void CreateViewer();
void Mesh();
void Airplane();
void Kachujin();
void AddPointLights();
void AddSpotLights();
void Pass(UINT mesh, UINT model, UINT anim);
private:
RenderTarget * renderTarget;
RenderTarget * mrt[2];
DepthStencil* depthStencil;
Viewport* viewport;
Render2D* renderTarget2D;
Render2D* left2D;
Render2D* right2D;
Shader * shader;
class SkyCube* sky;
Material* floor;
Material* stone;
Material* brick;
Material* wall;
MeshRender* sphere;
MeshRender* cylinder;
MeshRender* cube;
MeshRender* grid;
ModelRender* airPlane = NULL;
Model* weapon;
ModelAnimator* kachujin = NULL;
struct ColliderDesc
{
Transform* Init;
Transform* Transform;
Collider* Collider;
} collider[4];
vector<MeshRender*> meshes;
vector<ModelRender*> models;
vector<ModelAnimator*> animators;
};
| [
"whdals5607@naver.com"
] | whdals5607@naver.com |
0c46af189523884107db9ab9fe8e7c232d34e012 | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /components/pdf/renderer/pdf_view_web_plugin_client.cc | ab6af3cc20808df3df4698d717e9d321b7213c35 | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 9,229 | cc | // Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/pdf/renderer/pdf_view_web_plugin_client.h"
#include <memory>
#include <string>
#include <utility>
#include "base/check_op.h"
#include "base/values.h"
#include "components/pdf/renderer/pdf_accessibility_tree.h"
#include "content/public/renderer/render_thread.h"
#include "content/public/renderer/v8_value_converter.h"
#include "net/cookies/site_for_cookies.h"
#include "printing/buildflags/buildflags.h"
#include "third_party/blink/public/platform/web_security_origin.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/blink.h"
#include "third_party/blink/public/web/web_associated_url_loader.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_dom_message_event.h"
#include "third_party/blink/public/web/web_element.h"
#include "third_party/blink/public/web/web_frame_widget.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/public/web/web_local_frame_client.h"
#include "third_party/blink/public/web/web_plugin_container.h"
#include "third_party/blink/public/web/web_serialized_script_value.h"
#include "third_party/blink/public/web/web_view.h"
#include "third_party/blink/public/web/web_widget.h"
#include "ui/display/screen_info.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect.h"
#include "v8/include/v8-context.h"
#include "v8/include/v8-isolate.h"
#include "v8/include/v8-local-handle.h"
#include "v8/include/v8-value.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/printing/renderer/print_render_frame_helper.h"
#endif // BUILDFLAG(ENABLE_PRINTING)
namespace pdf {
PdfViewWebPluginClient::PdfViewWebPluginClient(
content::RenderFrame* render_frame)
: render_frame_(render_frame),
v8_value_converter_(content::V8ValueConverter::Create()),
isolate_(blink::MainThreadIsolate()) {
DCHECK(render_frame_);
}
PdfViewWebPluginClient::~PdfViewWebPluginClient() = default;
std::unique_ptr<base::Value> PdfViewWebPluginClient::FromV8Value(
v8::Local<v8::Value> value,
v8::Local<v8::Context> context) {
return v8_value_converter_->FromV8Value(value, context);
}
base::WeakPtr<chrome_pdf::PdfViewWebPlugin::Client>
PdfViewWebPluginClient::GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
void PdfViewWebPluginClient::SetPluginContainer(
blink::WebPluginContainer* container) {
plugin_container_ = container;
}
blink::WebPluginContainer* PdfViewWebPluginClient::PluginContainer() {
return plugin_container_;
}
net::SiteForCookies PdfViewWebPluginClient::SiteForCookies() const {
return plugin_container_->GetDocument().SiteForCookies();
}
blink::WebURL PdfViewWebPluginClient::CompleteURL(
const blink::WebString& partial_url) const {
return plugin_container_->GetDocument().CompleteURL(partial_url);
}
void PdfViewWebPluginClient::PostMessage(base::Value::Dict message) {
v8::Isolate::Scope isolate_scope(isolate_);
v8::HandleScope handle_scope(isolate_);
v8::Local<v8::Context> context = GetFrame()->MainWorldScriptContext();
DCHECK_EQ(isolate_, context->GetIsolate());
v8::Context::Scope context_scope(context);
v8::Local<v8::Value> converted_message =
v8_value_converter_->ToV8Value(message, context);
plugin_container_->EnqueueMessageEvent(
blink::WebSerializedScriptValue::Serialize(isolate_, converted_message));
}
void PdfViewWebPluginClient::Invalidate() {
plugin_container_->Invalidate();
}
void PdfViewWebPluginClient::RequestTouchEventType(
blink::WebPluginContainer::TouchEventRequestType request_type) {
plugin_container_->RequestTouchEventType(request_type);
}
void PdfViewWebPluginClient::ReportFindInPageMatchCount(int identifier,
int total,
bool final_update) {
plugin_container_->ReportFindInPageMatchCount(identifier, total,
final_update);
}
void PdfViewWebPluginClient::ReportFindInPageSelection(int identifier,
int index,
bool final_update) {
plugin_container_->ReportFindInPageSelection(identifier, index, final_update);
}
void PdfViewWebPluginClient::ReportFindInPageTickmarks(
const std::vector<gfx::Rect>& tickmarks) {
blink::WebLocalFrame* frame = GetFrame();
if (frame) {
frame->SetTickmarks(blink::WebElement(),
blink::WebVector<gfx::Rect>(tickmarks));
}
}
float PdfViewWebPluginClient::DeviceScaleFactor() {
// Do not rely on `blink::WebPluginContainer::DeviceScaleFactor()`, since it
// doesn't always reflect the real screen's device scale. Instead, get the
// device scale from the top-level frame's `display::ScreenInfo`.
blink::WebWidget* widget = GetFrame()->LocalRoot()->FrameWidget();
return widget->GetOriginalScreenInfo().device_scale_factor;
}
gfx::PointF PdfViewWebPluginClient::GetScrollPosition() {
// Note that `blink::WebLocalFrame::GetScrollOffset()` actually returns a
// scroll position (a point relative to the top-left corner).
return GetFrame()->GetScrollOffset();
}
void PdfViewWebPluginClient::UsePluginAsFindHandler() {
plugin_container_->UsePluginAsFindHandler();
}
void PdfViewWebPluginClient::SetReferrerForRequest(
blink::WebURLRequest& request,
const blink::WebURL& referrer_url) {
GetFrame()->SetReferrerForRequest(request, referrer_url);
}
void PdfViewWebPluginClient::Alert(const blink::WebString& message) {
blink::WebLocalFrame* frame = GetFrame();
if (frame)
frame->Alert(message);
}
bool PdfViewWebPluginClient::Confirm(const blink::WebString& message) {
blink::WebLocalFrame* frame = GetFrame();
return frame && frame->Confirm(message);
}
blink::WebString PdfViewWebPluginClient::Prompt(
const blink::WebString& message,
const blink::WebString& default_value) {
blink::WebLocalFrame* frame = GetFrame();
return frame ? frame->Prompt(message, default_value) : blink::WebString();
}
void PdfViewWebPluginClient::TextSelectionChanged(
const blink::WebString& selection_text,
uint32_t offset,
const gfx::Range& range) {
// Focus the plugin's containing frame before changing the text selection.
// TODO(crbug.com/1234559): Would it make more sense not to change the text
// selection at all in this case? Maybe we only have this problem because we
// support a "selectAll" message.
blink::WebLocalFrame* frame = GetFrame();
frame->View()->SetFocusedFrame(frame);
frame->TextSelectionChanged(selection_text, offset, range);
}
std::unique_ptr<blink::WebAssociatedURLLoader>
PdfViewWebPluginClient::CreateAssociatedURLLoader(
const blink::WebAssociatedURLLoaderOptions& options) {
return GetFrame()->CreateAssociatedURLLoader(options);
}
void PdfViewWebPluginClient::UpdateTextInputState() {
// `widget` is null in Print Preview.
auto* widget = GetFrame()->FrameWidget();
if (widget)
widget->UpdateTextInputState();
}
void PdfViewWebPluginClient::UpdateSelectionBounds() {
// `widget` is null in Print Preview.
auto* widget = GetFrame()->FrameWidget();
if (widget)
widget->UpdateSelectionBounds();
}
std::string PdfViewWebPluginClient::GetEmbedderOriginString() {
auto* frame = GetFrame();
if (!frame)
return {};
auto* parent_frame = frame->Parent();
if (!parent_frame)
return {};
return GURL(parent_frame->GetSecurityOrigin().ToString().Utf8()).spec();
}
bool PdfViewWebPluginClient::HasFrame() const {
return plugin_container_ && GetFrame();
}
blink::WebLocalFrame* PdfViewWebPluginClient::GetFrame() const {
return plugin_container_->GetDocument().GetFrame();
}
void PdfViewWebPluginClient::DidStartLoading() {
blink::WebLocalFrameClient* frame_client = GetFrame()->Client();
if (!frame_client)
return;
frame_client->DidStartLoading();
}
void PdfViewWebPluginClient::DidStopLoading() {
blink::WebLocalFrameClient* frame_client = GetFrame()->Client();
if (!frame_client)
return;
frame_client->DidStopLoading();
}
void PdfViewWebPluginClient::Print() {
blink::WebElement element = plugin_container_->GetElement();
DCHECK(!element.IsNull());
#if BUILDFLAG(ENABLE_PRINTING)
printing::PrintRenderFrameHelper::Get(render_frame_)->PrintNode(element);
#endif // BUILDFLAG(ENABLE_PRINTING)
}
void PdfViewWebPluginClient::RecordComputedAction(const std::string& action) {
content::RenderThread::Get()->RecordComputedAction(action);
}
std::unique_ptr<chrome_pdf::PdfAccessibilityDataHandler>
PdfViewWebPluginClient::CreateAccessibilityDataHandler(
chrome_pdf::PdfAccessibilityActionHandler* action_handler,
chrome_pdf::PdfAccessibilityImageFetcher* image_fetcher) {
return std::make_unique<PdfAccessibilityTree>(render_frame_, action_handler,
image_fetcher);
}
} // namespace pdf
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
92b4c7a750ab7721c8816dd2b00ea01569ee07ca | bf498a8e1e0ba2f70c4d8daa2dc1cd02cae56887 | /lab12/academiateacherhash/main.cpp | adf33c1fd30f42fb9b9cf8f78ed7f22f0d388437 | [] | no_license | SebastianSuchowiak/JIMP2 | 37d4f59a09a57e6798eaece4aa8ecfe346eeb934 | f0c558c025a0b5784820639845b216ba74f321a3 | refs/heads/master | 2021-01-24T11:46:18.666047 | 2018-06-05T01:17:07 | 2018-06-05T01:17:07 | 123,101,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 351 | cpp | //
// Created by sebastian on 02.06.18.
//
#include <iostream>
class A {
private:
int a;
public:
A() { a=0; }
friend class B; // Friend Class
};
class B {
private:
int b;
public:
void showA(A& x) {
// Since B is friend of A, it can access
// private members of A
std::cout << "A::a=" << x.a;
}
}; | [
"suchowiak.sebastian@gmail.com"
] | suchowiak.sebastian@gmail.com |
9f5d246692a1989e50ae4728a9ed1f720f60e737 | 08bd24caff7ebafe8946bb20a410a2adce23ccf9 | /DrawGraph/te.h | c5438c786855d0deddf9caa9896563ae4a96e038 | [] | no_license | UniqueOnly/DrawGraph | 78831485830e0d224f57353a9164b038bbaff555 | 1f605c894ca834f36da40bf2bcb2bf74e2a2cb96 | refs/heads/master | 2016-09-03T07:36:51.303001 | 2014-08-11T10:25:35 | 2014-08-11T10:25:35 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,318 | h | // te.h : main header file for the TE application
//
#if !defined(AFX_TE_H__4795B19E_8965_49E9_A4E4_CC60E9591F84__INCLUDED_)
#define AFX_TE_H__4795B19E_8965_49E9_A4E4_CC60E9591F84__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
#include "resource.h" // main symbols
/////////////////////////////////////////////////////////////////////////////
// CTeApp:
// See te.cpp for the implementation of this class
//
class CTeApp : public CWinApp
{
public:
CTeApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CTeApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CTeApp)
afx_msg void OnAppAbout();
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_TE_H__4795B19E_8965_49E9_A4E4_CC60E9591F84__INCLUDED_)
| [
"289211964@qq.com"
] | 289211964@qq.com |
70ba14d3b01abd816dde8ddaaab942ec4a206d38 | 2208bc66aba9b2473f054c6bbd40ddd7f103b598 | /src/graph/GridGraph.cpp | 87ad04938706730d455f277551ff8c14305dd2e9 | [
"MIT"
] | permissive | kunisura/algorithms2012 | 2a4f42e032ae7ce5f5d182f05548d8a8fc8c8673 | 49867c897fbca7d2b21f602428ea1a67a79f4a75 | refs/heads/master | 2016-09-16T13:58:45.967142 | 2015-04-02T05:12:41 | 2015-04-02T05:12:41 | 33,283,569 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,508 | cpp | /*
* Top-Down ZDD Builder
* Hiroaki Iwashita <iwashita@erato.ist.hokudai.ac.jp>
* Copyright (c) 2011 Japan Science and Technology Agency
* $Id: GridGraph.cpp 9 2011-11-16 06:38:04Z iwashita $
*/
#include "GridGraph.hpp"
void GridGraph::resize(int rows, int cols) {
reset();
rows_ = rows;
cols_ = cols;
for (int y = 0; y < rows; ++y) {
for (int x = 0; x < cols; ++x) {
VertexNumber v = getVertex(y, x);
if (x < cols - 1) addArc(v, v + 1);
if (y < rows - 1) addArc(v, v + cols);
}
}
arcs.resize((rows - 1) * (cols - 1));
for (int y = 0; y < rows - 1; ++y) {
for (int x = 0; x < cols - 1; ++x) {
auto& a = arcs[(cols - 1) * y + x];
a.resize(4);
a[0] = getArc(getVertex(y, x), getVertex(y, x + 1));
a[1] = getArc(getVertex(y, x), getVertex(y + 1, x));
a[2] = getArc(getVertex(y, x + 1), getVertex(y + 1, x + 1));
a[3] = getArc(getVertex(y + 1, x), getVertex(y + 1, x + 1));
}
}
setup();
}
void GridGraph::printAnswer(std::ostream& os,
std::set<ArcNumber> const& answer) const {
static char const* connector[] = { " ", "╴", "╶", "─", "╵", "┘", "└", "┴",
"╷", "┐", "┌", "┬", "│", "┤", "├", "┼" };
os << "┏";
for (int x = 0; x < cols(); ++x) {
os << "━";
}
os << "┓\n";
for (int y = 0; y < rows(); ++y) {
os << "┃";
for (int x = 0; x < cols(); ++x) {
int c = 0;
if (x - 1 >= 0) {
ArcNumber a = getArc(getVertex(y, x - 1), getVertex(y, x));
if (answer.count(a)) c |= 1;
}
if (x + 1 < cols()) {
ArcNumber a = getArc(getVertex(y, x), getVertex(y, x + 1));
if (answer.count(a)) c |= 2;
}
if (y - 1 >= 0) {
ArcNumber a = getArc(getVertex(y - 1, x), getVertex(y, x));
if (answer.count(a)) c |= 4;
}
if (y + 1 < rows()) {
ArcNumber a = getArc(getVertex(y, x), getVertex(y + 1, x));
if (answer.count(a)) c |= 8;
}
os << connector[c];
}
os << "┃\n";
}
os << "┗";
for (int x = 0; x < cols(); ++x) {
os << "━";
}
os << "┛\n";
}
void GridGraph::printQuiz(std::ostream& os) const {
printAnswer(os, std::set<ArcNumber>());
}
| [
"kunisura@users.noreply.github.com"
] | kunisura@users.noreply.github.com |
d7a2fca4915ed3173bc4e46dca3c6501112eb9c8 | fc9b2ff1011cdbccb4b29da2191bd59495c4376c | /C++/String.cpp | e76e3b305427e01f2c399aa7495d09083491c1c2 | [] | no_license | wobushimotou/Daily | 21993447fe07374f2704a67348ed31e6a77b66e8 | 3f55c4ae350b84c611d0e146ce18ef710869fe5d | refs/heads/master | 2021-06-10T04:34:37.627893 | 2021-05-24T13:43:15 | 2021-05-24T13:43:15 | 192,706,436 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,051 | cpp | #include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
class String{
private:
size_t length;
char *data;
public:
//引用类型
typedef char& reference;
//迭代器类型
class iterator;
size_t npos = -1;
//构造函数
String();
String(size_t length,char ch);
String(const char *str);
String(const char *str,size_t length);
String(String &str,size_t index,size_t length);
String(iterator begin,iterator end);
String(String const &str);
//运算符重载函数
char operator[](int num);
//运算符比较函数
bool operator==(String &s2);
bool operator!=(String &s2);
bool operator<(String &s2);
bool operator<=(String &s2);
bool operator>(String &s2);
bool operator>=(String &s2);
//合并函数
String operator+(String &s2);
String operator+(const char *str);
//赋值操作
String &operator=(const String &s2);
String &operator=(const char *str);
String operator+=(String &s2);
String operator+=(const char *str);
friend istream& operator>>(istream &is,String &str);
//特性函数
char *c_str() const; //返回指向的字符串
size_t size() const; //返回当前字符串长度
bool empty() const; //返回字符串是否为空
void resize(size_t len,char c); //把字符串当前大小置为len,多去少补,多出的字符c填充不足的部分
//查找函数
size_t find(const String &str,size_t index); //从index开始寻找,返回str在字符串中第一次出现的位置
size_t find( const char *str, size_t index );
size_t find(const String &str,size_t index,size_t length);
size_t find( const char *str, size_t index,size_t length);
size_t find( char ch, size_t index ); // 返回字符ch在字符串中第一次出现的位置
size_t rfind(String &str,size_t index,size_t length);//从index开始,返回str的前length个字符串在字符串中最后一次出现的位置
size_t rfind(String &str,size_t index);
size_t rfind( char ch, size_t index ); // 返回字符ch在字符串中第一次出现的位置
size_t rfind(const char *str,size_t index);
size_t find_first_of(String &str,size_t index);//从index开始,查找str中任意字符第一次出现的位置
size_t find_first_of(const char *str,size_t index);
size_t find_last_of(String &str,size_t index); //从index开始,查找第一个不在str中的字符出现的位置
//比较函数
int compare(const String &s2);
int compare(const String &s2,size_t pos1,size_t n1);
int compare(const String &s2,size_t pos1,size_t n1,size_t pos2,size_t n2);
//修改函数
String substr(size_t pos,size_t n) const; //返回pos开始的n个字符组成的字符串
String &insert(size_t p,const String &str); //在p的位置插入字符串str
String &erase(size_t p,size_t n); //删除从p开始的n个字符,返回修改后的字符串
String &assign(String &s2,size_t p,size_t n); //将s中的字符串替换为s2中从p开始的n个字符
String &replace(size_t p,size_t n,const char *s); //删除从p开始的n个字符,然后插入串s
void swap(String &s2); //减缓当前字符串与s2的值
String &append(const char *s); //把字符串s连接到当前字符串结尾
void push_back(char c); //将字符c加入当前字符串尾部
void pop_back(char c); //将字符C加入当前字符串头部
//清除函数
void clear(); //清楚字符串所有内容
//析构函数
~String();
//迭代器操作
iterator begin() const{
return iterator(this,0);
}
iterator end() const{
return iterator(this,length);
}
//引用操作
char &front() const{
return (this->data)[0];
}
char &back() const{
return (this->data)[length-1];
}
//迭代器类
class iterator{
public:
//迭代器构造函数
iterator() {
it = NULL;
}
iterator(const iterator &its) {
it = its.it;
index = its.index;
}
iterator(const String *str) {
it = str;
index = 0;
}
iterator(const String *str,size_t num) {
if(num < 0) {
it = NULL;
index = 0;
}
else {
it = str;
index = num;
}
}
char operator*() {
cout << "1" << endl;
return *(it->data+index);
}
//迭代器加法
iterator operator+(int num) {
if(!it)
return iterator();
return iterator(it,index+num);
}
//迭代器减法
iterator operator-(int num) {
if(!it)
return iterator();
return iterator(it,index-num);
}
//迭代器与迭代器减法
int operator-(iterator &end) {
//判断是否指向同一对象
if(this->it != end.it)
return -1;
else {
return this->index - end.index;
}
}
iterator &operator=(iterator &its) {
it = its.it;
index = its.index;
return *this;
}
//迭代器相等操作
bool operator==(iterator &its) {
return this->it == its.it && this->index == its.index;
}
bool operator!=(iterator &its) {
return !(*this == its);
}
//前置递增
iterator &operator++() {
if(index+1 > it->size()) {
cout << "无法递增,无效的迭代器" << endl;
exit(0);
}
else {
index += 1;
}
return *this;
}
//前置递减
iterator &operator--() {
if(index-1 < 0) {
cout << "无法递减,无效的迭代器" << endl;
exit(0);
}
else {
index -= 1;
}
return *this;
}
//后置递增
iterator operator++(int num) {
//保存当前迭代器状态
iterator its = *this;
++(*this);
return its;
}
//后置递减
iterator operator--(int num) {
//保存当前迭代器状态
iterator its = *this;
--(*this);
return its;
}
//小于大于
bool operator<(iterator &its) {
//判断是否指向同一String对象
if(this->it != its.it) {
cout << "指向不同对象的迭代器不能互相比较" << endl;
exit(0);
}
return this->index < its.index;
}
bool operator<=(iterator &its) {
//判断是否指向同一String对象
if(this->it != its.it) {
cout << "指向不同对象的迭代器不能互相比较" << endl;
exit(0);
}
return this->index <= its.index;
}
bool operator>(iterator &its) {
return !(*this < its);
}
bool operator>=(iterator &its) {
return !(*this <= its);
}
//累加累减
iterator &operator+=(int num) {
if(this->index+num > this->it->size()) {
cout << "无法增长,无效的迭代器" << endl;
exit(0);
}
this->index += num;
return *this;
}
iterator &operator-=(int num) {
if(this->index-num < 0) {
cout << "无法减少,无效的迭代器" << endl;
exit(0);
}
this->index -= num;
return *this;
}
//迭代器析构函数
~iterator() {
it = NULL;
}
private:
const String *it;
size_t index;
};
};
void String::clear()
{
this->length = 0;
delete(this->data);
}
String::~String()
{
clear();
}
String::String()
{
data = NULL;
length = 0;
}
String::String(size_t length,char ch)
{
if(length <= 0) {
data = NULL;
length = 0;
return;
}
this->length = length;
data = new char[length+1];
for(size_t i = 0;i < length;++i)
data[i] = ch;
data[length] = '\0';
}
String::String(const char *str)
{
if(!str) {
data = NULL;
length = 0;
return;
}
else {
this->length = strlen(str);
data = new char[this->length+1];
strcpy(data,str);
data[length] = '\0';
}
}
String::String(const char *str,size_t length)
{
if(!str) {
data = NULL;
this->length = 0;
return;
}
if(length > strlen(str)) {
this->length = strlen(str);
data = new char[this->length+1];
strcpy(data,str);
data[length] = '\0';
}
else{
this->length = length;
data = new char[length+1];
for(size_t i = 0;i < length;++i)
data[i] = str[i];
data[length] = '\0';
}
}
String::String(String const &str)
{
if(str.size() == 0) {
data = NULL;
this->length = 0;
return;
}
else {
this->length = str.size();
data = new char[str.size()+1];
strcpy(data,str.c_str());
data[str.size()] = '\0';
}
}
String::String(String &str,size_t index,size_t length)
{
if(str.size() == 0 || index < 0) {
data = NULL;
this->length = 0;
return;
}
if(length + index > str.size()) {
this->length = length;
data = new char[str.size()+1];
strcpy(data,str.c_str());
data[str.size()] = '\0';
}
else {
this->length = length;
data = new char[length+1];
for(size_t i = index,j = 0;j < length;++i,++j)
data[j] = str.c_str()[i];
data[length] = '\0';
}
}
String::String(iterator begin,iterator end)
{
//判断是否指向同一对象并且迭代器范围是否有误
if(end - begin < 0) {
cout << "length=" << end - begin << endl;
cout << "无效的迭代器" << endl;
exit(0);
}
else {
data = new char[end - begin+1];
size_t i = 0;
while(begin != end) {
data[i++] = *begin++;
}
data[i] = '\0';
}
}
char String::operator[](int num)
{
return c_str()[num];
}
bool String::operator==(String &s2)
{
if(this->length != s2.size())
return false;
for(size_t i = 0;i < this->length;++i) {
if(data[i] != s2.c_str()[i])
return false;
}
return true;
}
bool String::operator<(String &s2)
{
size_t n = 0;
while(n < this->length && n < s2.size()) {
if(this->c_str()[n] != s2.c_str()[n])
return this->c_str()[n] < s2.c_str()[n];
n++;
}
if(n == this->length && n == s2.size())
return false;
else if(n == s2.size())
return false;
else
return true;
}
bool String::operator<=(String &s2)
{
size_t n = 0;
while(n < this->length && n < s2.size()) {
if(this->c_str()[n] != s2.c_str()[n])
return this->c_str()[n] < s2.c_str()[n];
n++;
}
if(n == this->length && n == s2.size())
return true;
else if(n == s2.size())
return false;
else
return true;
}
bool String::operator>(String &s2)
{
return !(*this < s2);
}
bool String::operator>=(String &s2)
{
return !(*this <= s2);
}
bool String::operator!=(String &s2)
{
return !(*this == s2);
}
String String::operator+(String &s2)
{
long l = this->length + s2.size();
char ar[l];
strcpy(ar,this->c_str());
strcat(ar,s2.c_str());
String temp2(ar);
return temp2;
}
String String::operator+(const char *str)
{
String s2(str);
long l = this->length + s2.size();
char ar[l];
strcpy(ar,this->c_str());
strcat(ar,s2.c_str());
String temp2(ar);
return temp2;
}
String &String::operator=(const char *str)
{
//检查字符串是否有效
if(!str) {
String();
}
//检查当前String类是否有数据
if(this->length > 0) {
delete(this->data);
}
this->length = strlen(str);
data = new char[strlen(str)+1];
strcpy(data,str);;
data[this->length] = '\0';
return *this;
}
String &String::operator=(const String &s2)
{
return *this = s2.c_str();
}
char * String::c_str() const
{
return this->data;
}
size_t String::size() const
{
return this->length;
}
ostream& operator<<(ostream &os,const String &str)
{
if(str.size() == 0) {
}
else {
os << str.c_str();
}
return os;
}
istream& operator>>(istream &is,String &str)
{
if(str.size()) {
//删除原有内存空间
delete(str.data);
}
char buf[100];
cin >> buf;
str.data = new char[strlen(buf)+1];
strcpy(str.data,buf);
str.length = strlen(buf);
str.data[str.length] = strlen(buf);
return is;
}
bool String::empty() const
{
return this->length == 0;
}
void String::resize(size_t len,char c)
{
if(this->length < len) {
char buf[len];
strcpy(buf,this->data);
delete(this->data);
data = new char[len+1];
strcpy(this->data,buf);
for(size_t i = this->length;i < len;++i)
data[i] = c;
this->length = len;
this->data[len] = '\0';
}
else {
char buf[len];
for(size_t i = 0;i < len;++i)
buf[i] = this->data[i];
delete(this->data);
this->data = new char[len+1];
strcpy(this->data,buf);
this->data[len] = '\0';
}
}
size_t String::find( const char *str, size_t index,size_t length)
{
size_t l = length;
String cmp(str);
for(size_t i = index;i < this->length - l;++i) {
String temp(*this,i,l);
if(temp == cmp)
return i;
}
return npos;
}
size_t String::find(const String &str,size_t index,size_t length)
{
return find(str.c_str(),index,length);
}
size_t String::find( const char *str, size_t index)
{
return find(str,index,strlen(str));
}
size_t String::find(const String &str,size_t index)
{
return find(str.c_str(),index,str.size());
}
size_t String::find( char ch, size_t index )
{
for(size_t i = index;i < this->length;++i)
if(ch == (*this)[i])
return i;
return npos;
}
size_t String::find_first_of(String &str,size_t index)
{
for(size_t i = index;i < this->length;++i)
if(str.find((*this)[i],0) != npos)
return i;
return npos;
}
size_t String::find_first_of(const char *str,size_t index)
{
String s(str);
return find_first_of(s,index);
}
size_t String::rfind(String &str,size_t index,size_t length)
{
size_t temp = npos;
size_t num;
while(index < this->length) {
if((num = find(str,index,length)) != npos)
temp = num;
index++;
}
return temp;
}
size_t String::rfind(String &str,size_t index)
{
return rfind(str,index,str.size());
}
size_t String::rfind( char ch, size_t index )
{
size_t temp = npos;
size_t num;
while(index < this->length) {
if((num = find(ch,index)) != npos)
temp = num;
index++;
}
return temp;
}
size_t String::rfind(const char *str,size_t index)
{
String temp(str);
return rfind(temp,index);
}
size_t String::find_last_of(String &str,size_t index)
{
for(size_t i = index;i < this->length;++i)
if(str.find((*this)[i],0) == npos)
return i;
return npos;
}
int String::compare(const String &s2)
{
return strcmp(this->data,s2.c_str());
}
int String::compare(const String &s2,size_t pos1,size_t n1,size_t pos2,size_t n2)
{
String t1 = this->substr(pos1,n1);
String t2 = s2.substr(pos2,n2);
return strcmp(t1.c_str(),t2.c_str());
}
String String::substr(size_t pos,size_t n) const
{
if(pos + n > this->length) {
cout << "无效的长度" << endl;
exit(0);
}
char buf[n];
char *temp = this->data+pos;
strncpy(buf,temp,n);
return String(buf,n);
}
String &String::insert(size_t p,const String &str)
{
String s1 = str;
String s2 = this->substr(p,this->length-p);
String s3 = this->substr(0,p);
*this = s3 + s1 + s2;
return *this;
}
String &String::erase(size_t p,size_t n)
{
if(p + n > this->length) {
cout << "无效的范围" << endl;
exit(0);
}
String s1 = this->substr(0,p);
String s2 = this->substr(p,n);
String s3 = this->substr(p+n,this->length-p-n);
*this = s1 + s3;
return *this;
}
String &String::assign(String &s2,size_t p,size_t n)
{
String temp = s2.substr(p,n);
*this = temp;
return *this;
}
String &String::replace(size_t p,size_t n,const char *s)
{
this->erase(p,n);
this->insert(p,s);
return *this;
}
void String::swap(String &s2)
{
char *temp = this->c_str();
this->data = s2.c_str();
s2.data = temp;
}
String &String::append(const char *s)
{
return this->insert(this->length,s);
}
void String::push_back(char c)
{
char buf[this->length];
strcpy(buf,this->data);
delete(this->data);
this->length++;
this->data = new char[this->length+1];
strcpy(this->data,buf);
this->data[this->length-1] = c;
this->data[this->length] = '\0';
}
void String::pop_back(char c)
{
char buf[this->length];
strcpy(buf,this->data);
delete(this->data);
this->length++;
this->data = new char[this->length+1];
this->data[0] = c;
strcat(this->data,buf);
this->data[this->length] = '\0';
}
String To_string(int n)
{
char ar[5];
sprintf(ar,"%d",n);
return String(ar);
}
String To_string(double f)
{
char ar[20];
sprintf(ar,"%lf",f);
return String(ar);
}
int main()
{
String s1 = "123456";
String s2 = "789";
String *p = &s1;
cout << *p << endl;
return 0;
}
| [
"1687734258@qq.com"
] | 1687734258@qq.com |
dcb661282ce341349eb97e0ea3acb08bc5e82978 | 91a882547e393d4c4946a6c2c99186b5f72122dd | /Source/XPSP1/NT/admin/services/sched/folderui/xicon.cxx | 19dfcefa550648a09ff4e5ada86d9190ebd95dfa | [] | no_license | IAmAnubhavSaini/cryptoAlgorithm-nt5src | 94f9b46f101b983954ac6e453d0cf8d02aa76fc7 | d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2 | refs/heads/master | 2023-09-02T10:14:14.795579 | 2021-11-20T13:47:06 | 2021-11-20T13:47:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,939 | cxx | //____________________________________________________________________________
//
// Microsoft Windows
// Copyright (C) Microsoft Corporation, 1995 - 1996.
//
// File: xicon.cxx
//
// Contents: implementation of CJobsEI & CJobsEIA classes.
//
// Classes:
//
// Functions:
//
// History: 1/4/1996 RaviR Created
//
//____________________________________________________________________________
#include "..\pch\headers.hxx"
#pragma hdrstop
#include "dbg.h"
#include "macros.h"
#include "..\inc\resource.h"
#include "dll.hxx"
#include "jobidl.hxx"
#include "util.hxx"
#include "jobicons.hxx"
//
// extern
//
extern HINSTANCE g_hInstance;
//#undef DEB_TRACE
//#define DEB_TRACE DEB_USER1
const TCHAR c_szTask[] = TEXT("task!");
extern const TCHAR TEMPLATE_STR[] = TEXT("wizard:");
//____________________________________________________________________________
//
// Class: CJobsEI
//
// Purpose: Provide IExtractIcon interface to Job Folder objects.
//
// History: 1/24/1996 RaviR Created
//____________________________________________________________________________
class CJobsEI : public IExtractIcon
{
public:
CJobsEI(LPCTSTR pszFolderPath, LPITEMIDLIST pidl)
: m_pszFolderPath(pszFolderPath), m_pidl(pidl),
m_JobIcon(), m_ulRefs(1) {}
~CJobsEI() { ILFree(m_pidl); }
// IUnknown methods
DECLARE_STANDARD_IUNKNOWN;
// IExtractIcon methods
STDMETHOD(GetIconLocation)(UINT uFlags, LPTSTR szIconFile, UINT cchMax,
int *piIndex, UINT *pwFlags);
STDMETHOD(Extract)(LPCTSTR pszFile, UINT nIconIndex, HICON *phiconLarge,
HICON *phiconSmall, UINT nIconSize);
private:
CDllRef m_DllRef;
LPCTSTR m_pszFolderPath;
LPITEMIDLIST m_pidl;
CJobIcon m_JobIcon;
};
//____________________________________________________________________________
//
// Member: IUnknown methods
//____________________________________________________________________________
IMPLEMENT_STANDARD_IUNKNOWN(CJobsEI);
STDMETHODIMP
CJobsEI::QueryInterface(REFIID riid, LPVOID* ppvObj)
{
if (IsEqualIID(IID_IUnknown, riid) ||
IsEqualIID(IID_IExtractIcon, riid))
{
*ppvObj = (IUnknown*)(IExtractIcon*) this;
this->AddRef();
return S_OK;
}
*ppvObj = NULL;
return E_NOINTERFACE;
}
//____________________________________________________________________________
//
// Member: CJobsEI::IExtractIcon::GetIconLocation
//
// Arguments: [uFlags] -- IN
// [szIconFile] -- IN
// [cchMax] -- IN
// [piIndex] -- IN
// [pwFlags] -- IN
//
// Returns: HTRESULT
//
// History: 1/5/1996 RaviR Created
//
//____________________________________________________________________________
STDMETHODIMP
CJobsEI::GetIconLocation(
UINT uFlags,
LPTSTR szIconFile,
UINT cchMax,
int * piIndex,
UINT * pwFlags)
{
TRACE(CJobsEI, GetIconLocation);
szIconFile[0] = '\0'; // init
if (uFlags & GIL_OPENICON)
{
return S_FALSE;
}
*pwFlags = GIL_NOTFILENAME | GIL_PERINSTANCE;
PJOBID pjid = (PJOBID)m_pidl;
if (cchMax <= (UINT)(lstrlen(c_szTask) + lstrlen(pjid->GetAppName())))
{
DEBUG_OUT((DEB_ERROR,
"CJobsEI::GetIconLocation: insufficient buffer\n"));
return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER);
}
lstrcpy(szIconFile, c_szTask);
if (pjid->IsTemplate())
{
lstrcat(szIconFile, TEMPLATE_STR);
*piIndex = 0;
}
else
{
lstrcat(szIconFile, pjid->GetAppName());
*piIndex = ! pjid->IsJobFlagOn(TASK_FLAG_DISABLED);
}
return S_OK;
}
//____________________________________________________________________________
//
// Member: CJobsEI::Extract
//
// Arguments: [pszFile] -- IN
// [nIconIndex] -- IN
// [phiconLarge] -- IN
// [phiconSmall] -- IN
// [nIconSize] -- IN
//
// Returns: STDMETHODIMP
//
// History: 1/5/1996 RaviR Created
//____________________________________________________________________________
STDMETHODIMP
CJobsEI::Extract(
LPCTSTR pszFile,
UINT nIconIndex,
HICON * phiconLarge,
HICON * phiconSmall,
UINT nIconSize)
{
TRACE(CJobsEI, Extract);
if (((PJOBID)m_pidl)->IsTemplate())
{
m_JobIcon.GetTemplateIcons(phiconLarge, phiconSmall);
}
else
{
m_JobIcon.GetIcons(((PJOBID)m_pidl)->GetAppName(),
nIconIndex,
phiconLarge,
phiconSmall);
}
return S_OK;
}
//____________________________________________________________________________
//
// Function: JFGetExtractIcon
//
// Synopsis: Function to create IExtractIcon
//
// Arguments: [ppvObj] -- OUT
//
// Returns: HRESULT
//
// History: 1/31/1996 RaviR Created
//
//____________________________________________________________________________
HRESULT
JFGetExtractIcon(
LPVOID * ppvObj,
LPCTSTR pszFolderPath,
LPCITEMIDLIST pidl)
{
Win4Assert(pidl != NULL);
LPITEMIDLIST pidlClone = ILClone(pidl);
if (pidlClone == NULL)
{
CHECK_HRESULT(E_OUTOFMEMORY);
return E_OUTOFMEMORY;
}
CJobsEI* pObj = new CJobsEI(pszFolderPath, pidlClone);
if (NULL == pObj)
{
ILFree(pidlClone);
return E_OUTOFMEMORY;
}
HRESULT hr = pObj->QueryInterface(IID_IExtractIcon, ppvObj);
pObj->Release();
return hr;
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//////////////////// CJobsEIA //////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
#ifdef UNICODE
//____________________________________________________________________________
//
// Class: CJobsEIA
//
// Purpose: Provide IExtractIconA interface to Job Folder objects.
//
// History: 1/24/1996 RaviR Created
//____________________________________________________________________________
class CJobsEIA : public IExtractIconA
{
public:
CJobsEIA(LPCTSTR pszFolderPath, LPITEMIDLIST pidl)
: m_pszFolderPath(pszFolderPath), m_pidl(pidl),
m_JobIcon(), m_ulRefs(1) {}
~CJobsEIA() { ILFree(m_pidl); }
// IUnknown methods
DECLARE_STANDARD_IUNKNOWN;
// IExtractIcon methods
STDMETHOD(GetIconLocation)(UINT uFlags, LPSTR szIconFile, UINT cchMax,
int *piIndex, UINT *pwFlags);
STDMETHOD(Extract)(LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge,
HICON *phiconSmall, UINT nIconSize);
private:
CDllRef m_DllRef;
LPCTSTR m_pszFolderPath;
LPITEMIDLIST m_pidl;
CJobIcon m_JobIcon;
};
//____________________________________________________________________________
//
// Member: IUnknown methods
//____________________________________________________________________________
IMPLEMENT_STANDARD_IUNKNOWN(CJobsEIA);
STDMETHODIMP
CJobsEIA::QueryInterface(REFIID riid, LPVOID* ppvObj)
{
if (IsEqualIID(IID_IUnknown, riid) ||
IsEqualIID(IID_IExtractIconA, riid))
{
*ppvObj = (IUnknown*)(IExtractIconA*) this;
this->AddRef();
return S_OK;
}
*ppvObj = NULL;
return E_NOINTERFACE;
}
//____________________________________________________________________________
//
// Member: CJobsEIA::GetIconLocation
//
// Arguments: [uFlags] -- IN
// [szIconFile] -- IN
// [cchMax] -- IN
// [piIndex] -- IN
// [pwFlags] -- IN
//
// Returns: HTRESULT
//
// History: 1/5/1996 RaviR Created
//
//____________________________________________________________________________
STDMETHODIMP
CJobsEIA::GetIconLocation(
UINT uFlags,
LPSTR szIconFile,
UINT cchMax,
int * piIndex,
UINT * pwFlags)
{
TRACE(CJobsEIA, GetIconLocation);
HRESULT hr = S_OK;
szIconFile[0] = '\0'; // init
if (uFlags & GIL_OPENICON)
{
return S_FALSE;
}
*pwFlags = GIL_NOTFILENAME | GIL_PERINSTANCE;
WCHAR wcBuff[MAX_PATH];
PJOBID pjid = (PJOBID)m_pidl;
lstrcpy(wcBuff, c_szTask);
if (pjid->IsTemplate())
{
lstrcat(wcBuff, TEMPLATE_STR);
*piIndex = 0;
}
else
{
lstrcat(wcBuff, pjid->GetAppName());
*piIndex = ! pjid->IsJobFlagOn(TASK_FLAG_DISABLED);
}
hr = UnicodeToAnsi(szIconFile, wcBuff, cchMax);
return hr;
}
//____________________________________________________________________________
//
// Member: CJobsEIA::Extract
//
// Arguments: [pszFile] -- IN
// [nIconIndex] -- IN
// [phiconLarge] -- IN
// [phiconSmall] -- IN
// [nIconSize] -- IN
//
// Returns: HTRESULT
//
// History: 1/5/1996 RaviR Created
//
//____________________________________________________________________________
STDMETHODIMP
CJobsEIA::Extract(
LPCSTR pszFile,
UINT nIconIndex,
HICON* phiconLarge,
HICON* phiconSmall,
UINT nIconSize)
{
TRACE(CJobsEIA, Extract);
if (((PJOBID)m_pidl)->IsTemplate())
{
m_JobIcon.GetTemplateIcons(phiconLarge, phiconSmall);
}
else
{
m_JobIcon.GetIcons(((PJOBID)m_pidl)->GetAppName(),
nIconIndex,
phiconLarge,
phiconSmall);
}
return S_OK;
}
//____________________________________________________________________________
//
// Function: JFGetExtractIconA
//
// Synopsis: Function to create IExtractIconA
//
// Arguments: [ppvObj] -- OUT
//
// Returns: HRESULT
//
// History: 1/31/1996 RaviR Created
//
//____________________________________________________________________________
HRESULT
JFGetExtractIconA(
LPVOID * ppvObj,
LPCTSTR pszFolderPath,
LPCITEMIDLIST pidl)
{
Win4Assert(pidl != NULL);
LPITEMIDLIST pidlClone = ILClone(pidl);
if (pidlClone == NULL)
{
CHECK_HRESULT(E_OUTOFMEMORY);
return E_OUTOFMEMORY;
}
CJobsEIA* pObj = new CJobsEIA(pszFolderPath, pidlClone);
if (NULL == pObj)
{
ILFree(pidlClone);
return E_OUTOFMEMORY;
}
HRESULT hr = pObj->QueryInterface(IID_IExtractIcon, ppvObj);
pObj->Release();
return hr;
}
#endif // UNICODE
| [
"support@cryptoalgo.cf"
] | support@cryptoalgo.cf |
939fccd6b62dfe502a0383f7f830dbe90afd2c3f | 4302a6bcad6500017d9e5bbd91e8309b49fe2bc3 | /src/simplify_reshapes.cpp | 9996f27191c5d9f23e0c4194b220dd8e640d4251 | [
"MIT"
] | permissive | wrightkennethj/AMDMIGraphX | 3e54b20b8f9f3f9c6e2011265b2853bea1878bf5 | 0211d91c20a662f61f97b6b7feaab82e113db58c | refs/heads/master | 2020-05-20T04:19:59.998691 | 2019-03-26T23:14:52 | 2019-03-26T23:14:52 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,343 | cpp | #include <migraphx/simplify_reshapes.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/operators.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/ranges.hpp>
#include <unordered_set>
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
bool is_reshaper(instruction_ref ins)
{
// clang-format off
static const std::unordered_set<std::string> names = {
"reshape",
"contiguous"
};
// clang-format on
return contains(names, ins->name());
}
bool is_transpose_output(instruction_ref ins)
{
if(ins->outputs().size() != 1)
return false;
if(ins->outputs().front()->name() == "contiguous")
return is_transpose_output(ins->outputs().front());
return ins->outputs().front()->name() == "transpose";
}
instruction_ref find_transpose_input(instruction_ref ins)
{
if(ins->inputs().size() != 1)
return ins;
if(ins->inputs().front()->name() == "contiguous")
return find_transpose_input(ins->inputs().front());
if(ins->inputs().front()->name() == "transpose")
return ins->inputs().front();
return ins;
}
void simplify_reshapes::apply(program& p) const
{
auto end = std::prev(p.end());
for(auto ins : iterator_for(p))
{
if(ins->outputs().empty() and ins != end)
continue;
if(is_reshaper(ins))
{
if(std::any_of(ins->outputs().begin(), ins->outputs().end(), &is_reshaper))
continue;
// Gather reshapes
std::vector<instruction_ref> reshapes{ins};
while(is_reshaper(reshapes.back()))
{
assert(!reshapes.back()->inputs().empty());
assert(p.has_instruction(reshapes.back()->inputs().front()));
auto input = reshapes.back()->inputs().front();
reshapes.push_back(input);
}
std::pair<instruction_ref, instruction_ref> r{p.end(), p.end()};
for(auto start : iterator_for(reshapes))
{
auto last = std::find_if(reshapes.rbegin(), reshapes.rend(), [&](auto&& i) {
return i->get_shape() == (*start)->get_shape() and i != (*start);
});
if(last != reshapes.rend())
{
r = std::make_pair(*start, *last);
break;
}
}
if(r.first != r.second)
{
p.replace_instruction(r.first, r.second);
}
}
else if(ins->name() == "transpose")
{
if(is_transpose_output(ins))
continue;
auto x = ins;
auto t = ins;
do
{
x = t;
t = find_transpose_input(x);
} while(x != t and t->name() == "transpose");
if(t == ins or t->name() != "transpose")
continue;
p.replace_instruction(ins, t->inputs().front());
}
}
// Replace all reshapes with as_shape
for(auto ins : iterator_for(p))
{
if(ins->name() != "reshape")
continue;
p.replace_instruction(ins, op::as_shape{ins->get_shape()}, ins->inputs());
}
}
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
| [
"pfultz2@yahoo.com"
] | pfultz2@yahoo.com |
91fff28f10935d3fcd9c7da5a5bbeb970dcb1cf5 | 4ff6d9bf787892f6515162b46918eee17a53b3c0 | /Pr1_Uebungs_Bsp/week9/Geheim.cpp | d3ba6feab9abe38a419b09c1a1522183c43e66bd | [] | no_license | Aman12b/Uni-uebungs-bsp | 31bbb7a53c5611c4c1ac682b1bb98df117363e59 | 05af2e2a213669b0171251cde25f3b652ab8fe36 | refs/heads/main | 2023-04-18T08:41:44.499181 | 2021-04-27T13:07:44 | 2021-04-27T13:07:44 | 333,073,906 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,720 | cpp | #include<iostream>
#include"Geheim.h"
using namespace std;
Geheim::Geheim(const string& information):info{information},seal{false},lockable{false}{}; // offenes Objekt mit entsprechender Information
Geheim::Geheim(const string& information, const string& passwort):info{information},pass{passwort},seal{true}{}; // mit passwort geschütztes Objekt
bool Geheim::lock(const string& passwort){// sperrt ein Objekt mit passwort. Das darf nur funktionieren, wenn das Objekt vorher offen war. Sonst muß diese Funktion false liefern und das Objekt unverändert lassen.
if (seal==false&&lockable==true){
if (passwort==pass){seal=true;return true;}};
return false;
}
bool Geheim::unlock(const string& passwort) // entsperrt ein Objekt, falls dass Passwort korrekt ist. Ansonst wird false zurückgeliefert.
{
if (seal==true&&lockable==true){
if (passwort==pass){
seal=false;return true;
}
}
return false;
}
bool Geheim::checkseal(){
return seal;
}
string Geheim::getinfo(){
if (!seal)
{
return info;
}
return "";
}
Geheim Geheim::operator+(Geheim a) //funktioniert nur, wenn die beiden zu verknüpfenden Objekte offen sind. Dann werden die beiden Zeichenketten im Ergebnisobjekt einfach aneinandergehängt. Andernfalls wird eine Exception vom Typ runtime_error geworfen.
{
if ((this->seal==false)&&(a.seal==false))
{
Geheim erg(this->getinfo()+a.getinfo());
return erg;
}
throw runtime_error("verknuepfung nicht moeglich");
}
int Geheim::len() //Länge der Information. Liefert 0 für gesperrte Objekte
{ if (!seal)
{
return info.size();
}
return 0;
}
| [
"kumar.amanpreet01@gmail.com"
] | kumar.amanpreet01@gmail.com |
75f52f48c256c2d76eee913eede79481f0125a7c | 70615fa8f43c903f59b81337386e9e73c4a0c3cd | /tools/binary_size/libsupersize/caspian/model.h | f8523b0e81b13d25952f403a327c67bbdd7e1be4 | [
"BSD-3-Clause",
"Zlib",
"LGPL-2.0-or-later",
"MIT",
"LGPL-2.1-only",
"APSL-2.0",
"Apache-2.0",
"LGPL-2.0-only",
"LicenseRef-scancode-unknown",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | MinghuiGao/chromium | 28e05be8cafe828da6b2a4b74d46d2fbb357d25b | 7c79100d7f3124e2702a4d4586442912e161df7e | refs/heads/master | 2023-03-03T00:47:05.735666 | 2019-12-03T15:35:35 | 2019-12-03T15:35:35 | 225,664,287 | 1 | 0 | BSD-3-Clause | 2019-12-03T16:18:56 | 2019-12-03T16:18:55 | null | UTF-8 | C++ | false | false | 9,753 | h | // Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef TOOLS_BINARY_SIZE_LIBSUPERSIZE_CASPIAN_MODEL_H_
#define TOOLS_BINARY_SIZE_LIBSUPERSIZE_CASPIAN_MODEL_H_
#include <stdint.h>
#include <stdlib.h>
#include <array>
#include <deque>
#include <functional>
#include <map>
#include <ostream>
#include <string>
#include <string_view>
#include <vector>
#include "third_party/jsoncpp/source/include/json/json.h"
#include "tools/binary_size/libsupersize/caspian/grouped_path.h"
// Copied from representation in tools/binary_size/libsupersize/models.py
namespace caspian {
enum class ContainerType : char {
kSymbol = '\0',
kDirectory = 'D',
kComponent = 'C',
kFile = 'F',
kJavaClass = 'J',
};
enum class SectionId : char {
// kNone is unused except for default-initializing in containers
kNone = '\0',
kBss = 'b',
kData = 'd',
kDataRelRo = 'R',
kDex = 'x',
kDexMethod = 'm',
kOther = 'o',
kRoData = 'r',
kText = 't',
kPakNontranslated = 'P',
kPakTranslations = 'p',
};
enum class DiffStatus : uint8_t {
kUnchanged = 0,
kChanged = 1,
kAdded = 2,
kRemoved = 3,
};
class SymbolFlag {
public:
static const int32_t kAnonymous = 1;
static const int32_t kStartup = 2;
static const int32_t kUnlikely = 4;
static const int32_t kRel = 8;
static const int32_t kRelLocal = 16;
static const int32_t kGeneratedSource = 32;
static const int32_t kClone = 64;
static const int32_t kHot = 128;
static const int32_t kCovered = 256;
static const int32_t kUncompressed = 512;
};
class Symbol;
class BaseSymbol {
public:
virtual ~BaseSymbol();
virtual int32_t Address() const = 0;
virtual int32_t Size() const = 0;
virtual int32_t Flags() const = 0;
virtual int32_t Padding() const = 0;
virtual std::string_view FullName() const = 0;
// Derived from |full_name|. Generated lazily and cached.
virtual std::string_view TemplateName() const = 0;
virtual std::string_view Name() const = 0;
virtual const std::vector<Symbol*>* Aliases() const = 0;
virtual SectionId Section() const = 0;
virtual const char* ObjectPath() const = 0;
virtual const char* SourcePath() const = 0;
virtual const char* SectionName() const = 0;
virtual const char* Component() const = 0;
virtual float Pss() const = 0;
virtual float PssWithoutPadding() const = 0;
virtual float PaddingPss() const = 0;
virtual DiffStatus GetDiffStatus() const = 0;
int32_t SizeWithoutPadding() const { return Size() - Padding(); }
int32_t EndAddress() const { return Address() + SizeWithoutPadding(); }
int32_t NumAliases() const {
const std::vector<Symbol*>* aliases = Aliases();
return aliases ? aliases->size() : 1;
}
bool IsTemplate() const {
// Because of the way these are derived from |FullName|, they have the
// same contents if and only if they have the same length.
return Name().size() != TemplateName().size();
}
bool IsOverhead() const { return FullName().substr(0, 10) == "Overhead: "; }
bool IsBss() const { return Section() == SectionId::kBss; }
bool IsDex() const {
SectionId section_id = Section();
return section_id == SectionId::kDex || section_id == SectionId::kDexMethod;
}
bool IsOther() const { return Section() == SectionId::kOther; }
bool IsPak() const {
SectionId section_id = Section();
return section_id == SectionId::kPakNontranslated ||
section_id == SectionId::kPakTranslations;
}
bool IsNative() const {
SectionId section_id = Section();
return (section_id == SectionId::kBss || section_id == SectionId::kData ||
section_id == SectionId::kDataRelRo ||
section_id == SectionId::kText || section_id == SectionId::kRoData);
}
bool IsStringLiteral() const {
std::string_view full_name = FullName();
return !full_name.empty() && full_name[0] == '"';
}
bool IsGeneratedSource() const {
return Flags() & SymbolFlag::kGeneratedSource;
}
bool IsNameUnique() const {
return !(IsStringLiteral() || IsOverhead() ||
(!FullName().empty() && FullName()[0] == '*') ||
(IsNative() && FullName().find('.') != std::string_view::npos));
}
};
struct BaseSizeInfo;
class Symbol;
class Symbol : public BaseSymbol {
public:
Symbol();
~Symbol() override;
Symbol(const Symbol& other);
int32_t Address() const override;
int32_t Size() const override;
int32_t Flags() const override;
int32_t Padding() const override;
std::string_view FullName() const override;
// Derived from |full_name|. Generated lazily and cached.
std::string_view TemplateName() const override;
std::string_view Name() const override;
const std::vector<Symbol*>* Aliases() const override;
SectionId Section() const override;
const char* ObjectPath() const override;
const char* SourcePath() const override;
const char* SectionName() const override;
const char* Component() const override;
float Pss() const override;
float PssWithoutPadding() const override;
float PaddingPss() const override;
DiffStatus GetDiffStatus() const override;
int32_t address_ = 0;
int32_t size_ = 0;
int32_t flags_ = 0;
int32_t padding_ = 0;
SectionId section_id_ = SectionId::kNone;
std::string_view full_name_;
// Derived lazily
mutable std::string_view template_name_;
mutable std::string_view name_;
// Pointers into SizeInfo->raw_decompressed;
const char* section_name_ = nullptr;
const char* object_path_ = nullptr;
const char* source_path_ = nullptr;
const char* component_ = nullptr;
std::vector<Symbol*>* aliases_ = nullptr;
// The SizeInfo the symbol was constructed from. Primarily used for
// allocating commonly-reused strings in a context where they won't outlive
// the symbol.
BaseSizeInfo* size_info_ = nullptr;
private:
void DeriveNames() const;
};
class DeltaSymbol : public BaseSymbol {
public:
DeltaSymbol(const Symbol* before, const Symbol* after);
~DeltaSymbol() override;
int32_t Address() const override;
int32_t Size() const override;
int32_t Flags() const override;
int32_t Padding() const override;
std::string_view FullName() const override;
// Derived from |full_name|. Generated lazily and cached.
std::string_view TemplateName() const override;
std::string_view Name() const override;
const std::vector<Symbol*>* Aliases() const override;
SectionId Section() const override;
const char* ObjectPath() const override;
const char* SourcePath() const override;
const char* SectionName() const override;
const char* Component() const override;
float Pss() const override;
float PssWithoutPadding() const override;
float PaddingPss() const override;
DiffStatus GetDiffStatus() const override;
private:
const Symbol* before_ = nullptr;
const Symbol* after_ = nullptr;
};
std::ostream& operator<<(std::ostream& os, const Symbol& sym);
struct BaseSizeInfo {
BaseSizeInfo();
BaseSizeInfo(const BaseSizeInfo&);
virtual ~BaseSizeInfo();
Json::Value metadata;
std::deque<std::string> owned_strings;
SectionId ShortSectionName(const char* section_name);
};
struct SizeInfo : BaseSizeInfo {
SizeInfo();
~SizeInfo() override;
SizeInfo(const SizeInfo& other) = delete;
SizeInfo& operator=(const SizeInfo& other) = delete;
// Entries in |raw_symbols| hold pointers to this data.
std::vector<const char*> object_paths;
std::vector<const char*> source_paths;
std::vector<const char*> components;
std::vector<const char*> section_names;
std::vector<char> raw_decompressed;
std::vector<Symbol> raw_symbols;
// A container for each symbol group.
std::deque<std::vector<Symbol*>> alias_groups;
};
struct DeltaSizeInfo : BaseSizeInfo {
DeltaSizeInfo(const SizeInfo* before, const SizeInfo* after);
~DeltaSizeInfo() override;
DeltaSizeInfo(const DeltaSizeInfo&);
DeltaSizeInfo& operator=(const DeltaSizeInfo&);
using Results = std::array<int32_t, 4>;
Results CountsByDiffStatus() const {
Results ret{0};
for (const DeltaSymbol& sym : delta_symbols) {
ret[static_cast<uint8_t>(sym.GetDiffStatus())]++;
}
return ret;
}
const SizeInfo* before = nullptr;
const SizeInfo* after = nullptr;
std::vector<DeltaSymbol> delta_symbols;
// Symbols created during diffing, e.g. aggregated padding symbols.
std::deque<Symbol> owned_symbols;
};
struct Stat {
int32_t count = 0;
int32_t added = 0;
int32_t removed = 0;
int32_t changed = 0;
float size = 0.0f;
void operator+=(const Stat& other) {
count += other.count;
size += other.size;
added += other.added;
removed += other.removed;
changed += other.changed;
}
};
struct NodeStats {
NodeStats();
~NodeStats();
explicit NodeStats(const BaseSymbol& symbol);
void WriteIntoJson(Json::Value* out) const;
NodeStats& operator+=(const NodeStats& other);
SectionId ComputeBiggestSection() const;
int32_t SumCount() const;
std::map<SectionId, Stat> child_stats;
};
struct TreeNode {
TreeNode();
~TreeNode();
using CompareFunc =
std::function<bool(const TreeNode* const& l, const TreeNode* const& r)>;
void WriteIntoJson(int depth, CompareFunc compare_func, Json::Value* out);
GroupedPath id_path;
const char* src_path = nullptr;
const char* component = nullptr;
float size = 0.0f;
NodeStats node_stats;
int32_t flags = 0;
int32_t short_name_index = 0;
ContainerType container_type = ContainerType::kSymbol;
std::vector<TreeNode*> children;
TreeNode* parent = nullptr;
const BaseSymbol* symbol = nullptr;
};
} // namespace caspian
#endif // TOOLS_BINARY_SIZE_LIBSUPERSIZE_CASPIAN_MODEL_H_
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
53b19ced2b2bdcb27389b30d7945c679b7767cde | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /net/spdy/buffered_spdy_framer.cc | 9148fe430665ddfa53282552d24c33a15137611e | [
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 14,681 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/spdy/buffered_spdy_framer.h"
#include <utility>
#include "base/logging.h"
#include "base/strings/string_util.h"
namespace net {
namespace {
// GOAWAY frame debug data is only buffered up to this many bytes.
size_t kGoAwayDebugDataMaxSize = 1024;
// Initial and maximum sizes for header block buffer.
size_t kHeaderBufferInitialSize = 8 * 1024;
size_t kHeaderBufferMaxSize = 256 * 1024;
} // namespace
BufferedSpdyFramer::BufferedSpdyFramer()
: spdy_framer_(HTTP2),
visitor_(NULL),
header_buffer_valid_(false),
header_stream_id_(SpdyFramer::kInvalidStream),
frames_received_(0) {}
BufferedSpdyFramer::~BufferedSpdyFramer() {
}
void BufferedSpdyFramer::set_visitor(
BufferedSpdyFramerVisitorInterface* visitor) {
visitor_ = visitor;
spdy_framer_.set_visitor(this);
}
void BufferedSpdyFramer::set_debug_visitor(
SpdyFramerDebugVisitorInterface* debug_visitor) {
spdy_framer_.set_debug_visitor(debug_visitor);
}
void BufferedSpdyFramer::OnError(SpdyFramer* spdy_framer) {
DCHECK(spdy_framer);
visitor_->OnError(spdy_framer->error_code());
}
void BufferedSpdyFramer::OnSynStream(SpdyStreamId stream_id,
SpdyStreamId associated_stream_id,
SpdyPriority priority,
bool fin,
bool unidirectional) {
NOTREACHED();
}
void BufferedSpdyFramer::OnHeaders(SpdyStreamId stream_id,
bool has_priority,
int weight,
SpdyStreamId parent_stream_id,
bool exclusive,
bool fin,
bool end) {
frames_received_++;
DCHECK(!control_frame_fields_.get());
control_frame_fields_.reset(new ControlFrameFields());
control_frame_fields_->type = HEADERS;
control_frame_fields_->stream_id = stream_id;
control_frame_fields_->has_priority = has_priority;
if (control_frame_fields_->has_priority) {
control_frame_fields_->weight = weight;
control_frame_fields_->parent_stream_id = parent_stream_id;
control_frame_fields_->exclusive = exclusive;
}
control_frame_fields_->fin = fin;
InitHeaderStreaming(stream_id);
}
void BufferedSpdyFramer::OnSynReply(SpdyStreamId stream_id,
bool fin) {
NOTREACHED();
}
bool BufferedSpdyFramer::OnControlFrameHeaderData(SpdyStreamId stream_id,
const char* header_data,
size_t len) {
CHECK_EQ(header_stream_id_, stream_id);
if (len == 0) {
// Indicates end-of-header-block.
CHECK(header_buffer_valid_);
SpdyHeaderBlock headers;
if (!spdy_framer_.ParseHeaderBlockInBuffer(
header_buffer_.data(), header_buffer_.size(), &headers)) {
visitor_->OnStreamError(
stream_id, "Could not parse Spdy Control Frame Header.");
return false;
}
DCHECK(control_frame_fields_.get());
switch (control_frame_fields_->type) {
case SYN_STREAM:
NOTREACHED();
break;
case SYN_REPLY:
NOTREACHED();
break;
case HEADERS:
visitor_->OnHeaders(control_frame_fields_->stream_id,
control_frame_fields_->has_priority,
control_frame_fields_->weight,
control_frame_fields_->parent_stream_id,
control_frame_fields_->exclusive,
control_frame_fields_->fin, std::move(headers));
break;
case PUSH_PROMISE:
visitor_->OnPushPromise(control_frame_fields_->stream_id,
control_frame_fields_->promised_stream_id,
std::move(headers));
break;
default:
DCHECK(false) << "Unexpect control frame type: "
<< control_frame_fields_->type;
break;
}
control_frame_fields_.reset(NULL);
return true;
}
const size_t new_size = header_buffer_.size() + len;
if (new_size > kHeaderBufferMaxSize) {
header_buffer_valid_ = false;
visitor_->OnStreamError(stream_id, "Received too much header data.");
return false;
}
if (new_size > header_buffer_.capacity()) {
// Grow |header_buffer_| exponentially to reduce memory allocations and
// copies.
size_t new_capacity = std::max(new_size, kHeaderBufferInitialSize);
new_capacity = std::max(new_capacity, 2 * header_buffer_.capacity());
new_capacity = std::min(new_capacity, kHeaderBufferMaxSize);
header_buffer_.reserve(new_capacity);
}
header_buffer_.append(header_data, len);
return true;
}
void BufferedSpdyFramer::OnDataFrameHeader(SpdyStreamId stream_id,
size_t length,
bool fin) {
frames_received_++;
header_stream_id_ = stream_id;
visitor_->OnDataFrameHeader(stream_id, length, fin);
}
void BufferedSpdyFramer::OnStreamFrameData(SpdyStreamId stream_id,
const char* data,
size_t len) {
visitor_->OnStreamFrameData(stream_id, data, len);
}
void BufferedSpdyFramer::OnStreamEnd(SpdyStreamId stream_id) {
visitor_->OnStreamEnd(stream_id);
}
void BufferedSpdyFramer::OnStreamPadding(SpdyStreamId stream_id, size_t len) {
visitor_->OnStreamPadding(stream_id, len);
}
SpdyHeadersHandlerInterface* BufferedSpdyFramer::OnHeaderFrameStart(
SpdyStreamId stream_id) {
coalescer_.reset(new HeaderCoalescer());
return coalescer_.get();
}
void BufferedSpdyFramer::OnHeaderFrameEnd(SpdyStreamId stream_id,
bool end_headers) {
if (coalescer_->error_seen()) {
visitor_->OnStreamError(stream_id,
"Could not parse Spdy Control Frame Header.");
return;
}
DCHECK(control_frame_fields_.get());
switch (control_frame_fields_->type) {
case SYN_STREAM:
NOTREACHED();
break;
case SYN_REPLY:
NOTREACHED();
break;
case HEADERS:
visitor_->OnHeaders(
control_frame_fields_->stream_id, control_frame_fields_->has_priority,
control_frame_fields_->weight,
control_frame_fields_->parent_stream_id,
control_frame_fields_->exclusive, control_frame_fields_->fin,
coalescer_->release_headers());
break;
case PUSH_PROMISE:
visitor_->OnPushPromise(control_frame_fields_->stream_id,
control_frame_fields_->promised_stream_id,
coalescer_->release_headers());
break;
default:
DCHECK(false) << "Unexpect control frame type: "
<< control_frame_fields_->type;
break;
}
control_frame_fields_.reset(NULL);
}
void BufferedSpdyFramer::OnSettings(bool clear_persisted) {
visitor_->OnSettings(clear_persisted);
}
void BufferedSpdyFramer::OnSetting(SpdySettingsIds id,
uint8_t flags,
uint32_t value) {
visitor_->OnSetting(id, flags, value);
}
void BufferedSpdyFramer::OnSettingsAck() {
visitor_->OnSettingsAck();
}
void BufferedSpdyFramer::OnSettingsEnd() {
visitor_->OnSettingsEnd();
}
void BufferedSpdyFramer::OnPing(SpdyPingId unique_id, bool is_ack) {
visitor_->OnPing(unique_id, is_ack);
}
void BufferedSpdyFramer::OnRstStream(SpdyStreamId stream_id,
SpdyRstStreamStatus status) {
visitor_->OnRstStream(stream_id, status);
}
void BufferedSpdyFramer::OnGoAway(SpdyStreamId last_accepted_stream_id,
SpdyGoAwayStatus status) {
DCHECK(!goaway_fields_);
goaway_fields_.reset(new GoAwayFields());
goaway_fields_->last_accepted_stream_id = last_accepted_stream_id;
goaway_fields_->status = status;
}
bool BufferedSpdyFramer::OnGoAwayFrameData(const char* goaway_data,
size_t len) {
if (len > 0) {
if (goaway_fields_->debug_data.size() < kGoAwayDebugDataMaxSize) {
goaway_fields_->debug_data.append(
goaway_data, std::min(len, kGoAwayDebugDataMaxSize -
goaway_fields_->debug_data.size()));
}
return true;
}
visitor_->OnGoAway(goaway_fields_->last_accepted_stream_id,
goaway_fields_->status, goaway_fields_->debug_data);
goaway_fields_.reset();
return true;
}
void BufferedSpdyFramer::OnWindowUpdate(SpdyStreamId stream_id,
int delta_window_size) {
visitor_->OnWindowUpdate(stream_id, delta_window_size);
}
void BufferedSpdyFramer::OnPushPromise(SpdyStreamId stream_id,
SpdyStreamId promised_stream_id,
bool end) {
frames_received_++;
DCHECK(!control_frame_fields_.get());
control_frame_fields_.reset(new ControlFrameFields());
control_frame_fields_->type = PUSH_PROMISE;
control_frame_fields_->stream_id = stream_id;
control_frame_fields_->promised_stream_id = promised_stream_id;
InitHeaderStreaming(stream_id);
}
void BufferedSpdyFramer::OnAltSvc(
SpdyStreamId stream_id,
base::StringPiece origin,
const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) {
visitor_->OnAltSvc(stream_id, origin, altsvc_vector);
}
void BufferedSpdyFramer::OnContinuation(SpdyStreamId stream_id, bool end) {
}
bool BufferedSpdyFramer::OnUnknownFrame(SpdyStreamId stream_id,
int frame_type) {
return visitor_->OnUnknownFrame(stream_id, frame_type);
}
size_t BufferedSpdyFramer::ProcessInput(const char* data, size_t len) {
return spdy_framer_.ProcessInput(data, len);
}
void BufferedSpdyFramer::UpdateHeaderDecoderTableSize(uint32_t value) {
spdy_framer_.UpdateHeaderDecoderTableSize(value);
}
void BufferedSpdyFramer::Reset() {
spdy_framer_.Reset();
}
SpdyFramer::SpdyError BufferedSpdyFramer::error_code() const {
return spdy_framer_.error_code();
}
SpdyFramer::SpdyState BufferedSpdyFramer::state() const {
return spdy_framer_.state();
}
bool BufferedSpdyFramer::MessageFullyRead() {
return state() == SpdyFramer::SPDY_FRAME_COMPLETE;
}
bool BufferedSpdyFramer::HasError() {
return spdy_framer_.HasError();
}
// TODO(jgraettinger): Eliminate uses of this method (prefer
// SpdyRstStreamIR).
SpdySerializedFrame* BufferedSpdyFramer::CreateRstStream(
SpdyStreamId stream_id,
SpdyRstStreamStatus status) const {
SpdyRstStreamIR rst_ir(stream_id, status);
return new SpdySerializedFrame(spdy_framer_.SerializeRstStream(rst_ir));
}
// TODO(jgraettinger): Eliminate uses of this method (prefer
// SpdySettingsIR).
SpdySerializedFrame* BufferedSpdyFramer::CreateSettings(
const SettingsMap& values) const {
SpdySettingsIR settings_ir;
for (SettingsMap::const_iterator it = values.begin();
it != values.end();
++it) {
settings_ir.AddSetting(
it->first,
(it->second.first & SETTINGS_FLAG_PLEASE_PERSIST) != 0,
(it->second.first & SETTINGS_FLAG_PERSISTED) != 0,
it->second.second);
}
return new SpdySerializedFrame(spdy_framer_.SerializeSettings(settings_ir));
}
// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyPingIR).
SpdySerializedFrame* BufferedSpdyFramer::CreatePingFrame(SpdyPingId unique_id,
bool is_ack) const {
SpdyPingIR ping_ir(unique_id);
ping_ir.set_is_ack(is_ack);
return new SpdySerializedFrame(spdy_framer_.SerializePing(ping_ir));
}
// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyGoAwayIR).
SpdySerializedFrame* BufferedSpdyFramer::CreateGoAway(
SpdyStreamId last_accepted_stream_id,
SpdyGoAwayStatus status,
base::StringPiece debug_data) const {
SpdyGoAwayIR go_ir(last_accepted_stream_id, status, debug_data);
return new SpdySerializedFrame(spdy_framer_.SerializeGoAway(go_ir));
}
// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyHeadersIR).
SpdySerializedFrame* BufferedSpdyFramer::CreateHeaders(
SpdyStreamId stream_id,
SpdyControlFlags flags,
int weight,
SpdyHeaderBlock headers) {
SpdyHeadersIR headers_ir(stream_id, std::move(headers));
headers_ir.set_fin((flags & CONTROL_FLAG_FIN) != 0);
if (flags & HEADERS_FLAG_PRIORITY) {
headers_ir.set_has_priority(true);
headers_ir.set_weight(weight);
}
return new SpdySerializedFrame(spdy_framer_.SerializeHeaders(headers_ir));
}
// TODO(jgraettinger): Eliminate uses of this method (prefer
// SpdyWindowUpdateIR).
SpdySerializedFrame* BufferedSpdyFramer::CreateWindowUpdate(
SpdyStreamId stream_id,
uint32_t delta_window_size) const {
SpdyWindowUpdateIR update_ir(stream_id, delta_window_size);
return new SpdySerializedFrame(spdy_framer_.SerializeWindowUpdate(update_ir));
}
// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyDataIR).
SpdySerializedFrame* BufferedSpdyFramer::CreateDataFrame(SpdyStreamId stream_id,
const char* data,
uint32_t len,
SpdyDataFlags flags) {
SpdyDataIR data_ir(stream_id,
base::StringPiece(data, len));
data_ir.set_fin((flags & DATA_FLAG_FIN) != 0);
return new SpdySerializedFrame(spdy_framer_.SerializeData(data_ir));
}
// TODO(jgraettinger): Eliminate uses of this method (prefer SpdyPushPromiseIR).
SpdySerializedFrame* BufferedSpdyFramer::CreatePushPromise(
SpdyStreamId stream_id,
SpdyStreamId promised_stream_id,
SpdyHeaderBlock headers) {
SpdyPushPromiseIR push_promise_ir(stream_id, promised_stream_id,
std::move(headers));
return new SpdySerializedFrame(
spdy_framer_.SerializePushPromise(push_promise_ir));
}
SpdyPriority BufferedSpdyFramer::GetHighestPriority() const {
return spdy_framer_.GetHighestPriority();
}
void BufferedSpdyFramer::InitHeaderStreaming(SpdyStreamId stream_id) {
header_buffer_.clear();
header_buffer_valid_ = true;
header_stream_id_ = stream_id;
DCHECK_NE(header_stream_id_, SpdyFramer::kInvalidStream);
}
} // namespace net
| [
"enrico.weigelt@gr13.net"
] | enrico.weigelt@gr13.net |
ed1580124769724bc861fb8ad8dddb94a9c1fa1b | 7443c27bd58d96aee6a23aeb2db97a1e8e1e477c | /src/01_hello_world/main.cc | 06d5e18acd431a1363f7b6d2dd4e45bc6a102998 | [] | no_license | ryoherisson/cpp-book | 31114cca7326db87d6230667d92c0eb8afef28a2 | 1bdc63ed9e8855b04a5ba87bacd41c46285f6438 | refs/heads/main | 2023-03-03T22:15:24.369380 | 2021-02-18T14:51:51 | 2021-02-18T14:51:51 | 338,714,760 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 134 | cc | #include <iostream>
int main() {
std::cout << "hello world!" << std::endl;
std::cout << "baby!" << std::endl;
return 0;
} | [
"ryhizw@gmail.com"
] | ryhizw@gmail.com |
ee056c5d262ef32c618f896429ec9b408f84f628 | 6e6dca4ddcea7d32246571d4c02d9c92a3575ff4 | /art/runtime/mirror/class_ext.cc | 5dc3aca09474e2afeef429addea7f78458ac7c85 | [
"Apache-2.0",
"NCSA"
] | permissive | zaheeratgesl/Android-Projects | b8b58dea2ea3d4c970fd117b6ced46d8db343ed5 | bc9f02f66b2a0be64b110ebebc878ad639ad9b77 | refs/heads/master | 2021-01-19T05:00:45.613225 | 2017-04-07T08:56:13 | 2017-04-07T08:56:13 | 87,408,776 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,339 | cc | /*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "class_ext-inl.h"
#include "art_method-inl.h"
#include "base/casts.h"
#include "base/enums.h"
#include "class-inl.h"
#include "dex_file-inl.h"
#include "gc/accounting/card_table-inl.h"
#include "object-inl.h"
#include "object_array.h"
#include "stack_trace_element.h"
#include "utils.h"
#include "well_known_classes.h"
namespace art {
namespace mirror {
GcRoot<Class> ClassExt::dalvik_system_ClassExt_;
uint32_t ClassExt::ClassSize(PointerSize pointer_size) {
uint32_t vtable_entries = Object::kVTableLength;
return Class::ComputeClassSize(true, vtable_entries, 0, 0, 0, 0, 0, pointer_size);
}
void ClassExt::SetObsoleteArrays(ObjPtr<PointerArray> methods,
ObjPtr<ObjectArray<DexCache>> dex_caches) {
DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId())
<< "Obsolete arrays are set without synchronization!";
CHECK_EQ(methods.IsNull(), dex_caches.IsNull());
auto obsolete_dex_cache_off = OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_dex_caches_);
auto obsolete_methods_off = OFFSET_OF_OBJECT_MEMBER(ClassExt, obsolete_methods_);
DCHECK(!Runtime::Current()->IsActiveTransaction());
SetFieldObject<false>(obsolete_dex_cache_off, dex_caches.Ptr());
SetFieldObject<false>(obsolete_methods_off, methods.Ptr());
}
// We really need to be careful how we update this. If we ever in the future make it so that
// these arrays are written into without all threads being suspended we have a race condition! This
// race could cause obsolete methods to be missed.
bool ClassExt::ExtendObsoleteArrays(Thread* self, uint32_t increase) {
DCHECK_EQ(GetLockOwnerThreadId(), Thread::Current()->GetThreadId())
<< "Obsolete arrays are set without synchronization!";
StackHandleScope<5> hs(self);
Handle<ClassExt> h_this(hs.NewHandle(this));
Handle<PointerArray> old_methods(hs.NewHandle(h_this->GetObsoleteMethods()));
Handle<ObjectArray<DexCache>> old_dex_caches(hs.NewHandle(h_this->GetObsoleteDexCaches()));
ClassLinker* cl = Runtime::Current()->GetClassLinker();
size_t new_len;
if (old_methods == nullptr) {
CHECK(old_dex_caches == nullptr);
new_len = increase;
} else {
CHECK_EQ(old_methods->GetLength(), old_dex_caches->GetLength());
new_len = increase + old_methods->GetLength();
}
Handle<PointerArray> new_methods(hs.NewHandle<PointerArray>(
cl->AllocPointerArray(self, new_len)));
if (new_methods.IsNull()) {
// Fail.
self->AssertPendingOOMException();
return false;
}
Handle<ObjectArray<DexCache>> new_dex_caches(hs.NewHandle<ObjectArray<DexCache>>(
ObjectArray<DexCache>::Alloc(self,
cl->FindClass(self,
"[Ljava/lang/DexCache;",
ScopedNullHandle<ClassLoader>()),
new_len)));
if (new_dex_caches.IsNull()) {
// Fail.
self->AssertPendingOOMException();
return false;
}
if (!old_methods.IsNull()) {
// Copy the old contents.
new_methods->Memcpy(0,
old_methods.Get(),
0,
old_methods->GetLength(),
cl->GetImagePointerSize());
new_dex_caches->AsObjectArray<Object>()->AssignableCheckingMemcpy<false>(
0, old_dex_caches->AsObjectArray<Object>(), 0, old_dex_caches->GetLength(), false);
}
// Set the fields.
h_this->SetObsoleteArrays(new_methods.Get(), new_dex_caches.Get());
return true;
}
ClassExt* ClassExt::Alloc(Thread* self) {
DCHECK(dalvik_system_ClassExt_.Read() != nullptr);
return down_cast<ClassExt*>(dalvik_system_ClassExt_.Read()->AllocObject(self).Ptr());
}
void ClassExt::SetVerifyError(ObjPtr<Object> err) {
if (Runtime::Current()->IsActiveTransaction()) {
SetFieldObject<true>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_), err);
} else {
SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ClassExt, verify_error_), err);
}
}
void ClassExt::SetOriginalDexFileBytes(ObjPtr<ByteArray> bytes) {
DCHECK(!Runtime::Current()->IsActiveTransaction());
SetFieldObject<false>(OFFSET_OF_OBJECT_MEMBER(ClassExt, original_dex_file_bytes_), bytes);
}
void ClassExt::SetClass(ObjPtr<Class> dalvik_system_ClassExt) {
CHECK(dalvik_system_ClassExt != nullptr);
dalvik_system_ClassExt_ = GcRoot<Class>(dalvik_system_ClassExt);
}
void ClassExt::ResetClass() {
CHECK(!dalvik_system_ClassExt_.IsNull());
dalvik_system_ClassExt_ = GcRoot<Class>(nullptr);
}
void ClassExt::VisitRoots(RootVisitor* visitor) {
dalvik_system_ClassExt_.VisitRootIfNonNull(visitor, RootInfo(kRootStickyClass));
}
} // namespace mirror
} // namespace art
| [
"ks.siddalingesh@globaledgesoft.com"
] | ks.siddalingesh@globaledgesoft.com |
18a36e7c00fe2a5aeb84c6f27f39d14e5adee8f7 | 8a87f5b889a9ce7d81421515f06d9c9cbf6ce64a | /3rdParty/boost/1.78.0/boost/callable_traits/is_transaction_safe.hpp | 51c98c53e35b69dd9279246c9c4d0ab2cfda3d13 | [
"BSL-1.0",
"Apache-2.0",
"BSD-3-Clause",
"ICU",
"Zlib",
"GPL-1.0-or-later",
"OpenSSL",
"ISC",
"LicenseRef-scancode-gutenberg-2020",
"MIT",
"GPL-2.0-only",
"CC0-1.0",
"LicenseRef-scancode-autoconf-simple-exception",
"LicenseRef-scancode-pcre",
"Bison-exception-2.2",
"LicenseRef-scancode... | permissive | arangodb/arangodb | 0980625e76c56a2449d90dcb8d8f2c485e28a83b | 43c40535cee37fc7349a21793dc33b1833735af5 | refs/heads/devel | 2023-08-31T09:34:47.451950 | 2023-08-31T07:25:02 | 2023-08-31T07:25:02 | 2,649,214 | 13,385 | 982 | Apache-2.0 | 2023-09-14T17:02:16 | 2011-10-26T06:42:00 | C++ | UTF-8 | C++ | false | false | 2,983 | hpp | /*
@file is_transaction_safe
@Copyright Barrett Adair 2015-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#ifndef BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE_HPP
#define BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE_HPP
#include <boost/callable_traits/detail/core.hpp>
namespace boost { namespace callable_traits {
//[ is_transaction_safe_hpp
/*`[section:ref_is_transaction_safe is_transaction_safe]
[heading Header]
``#include <boost/callable_traits/is_transaction_safe.hpp>``
[heading Definition]
*/
// inherits from either std::true_type or std::false_type
template<typename T>
struct is_transaction_safe;
//<-
template<typename T>
struct is_transaction_safe : detail::traits<
detail::shallow_decay<T>>::is_transaction_safe {
using type = typename detail::traits<
detail::shallow_decay<T>>::is_transaction_safe;
};
#ifdef BOOST_CLBL_TRTS_DISABLE_VARIABLE_TEMPLATES
template<typename T>
struct is_transaction_safe_v {
static_assert(std::is_same<T, detail::dummy>::value,
"Variable templates not supported on this compiler.");
};
#else
//->
// only available when variable templates are supported
template<typename T>
//<-
BOOST_CLBL_TRAITS_INLINE_VAR
//->
constexpr bool is_transaction_safe_v = //see below
//<-
detail::traits<detail::shallow_decay<T>>::is_transaction_safe::value;
#endif
}} // namespace boost::callable_traits
//->
/*`
[heading Constraints]
* none
*
[heading Behavior]
* `is_transaction_safe<T>::value` is `true` when either:
* `T` is a function type, function pointer type, function reference type, or member function pointer type where the function has a `transaction_safe` specifier
* `T` is a function object with a non-overloaded `operator()`, where the `operator()` has a `transaction_safe` specifier
* On compilers that support variable templates, `is_transaction_safe_v<T>` is equivalent to `is_transaction_safe<T>::value`.
[heading Input/Output Examples]
[table
[[`T`] [`is_transaction_safe_v<T>`]]
[[`int() const transaction_safe`] [`true`]]
[[`int(*)() transaction_safe`] [`true`]]
[[`int(&)() transaction_safe`] [`true`]]
[[`int(foo::* const)() transaction_safe`] [`true`]]
[[`int() const`] [`false`]]
[[`int() volatile`] [`false`]]
[[`int(foo::*)() const`] [`false`]]
[[`int() const`] [`false`]]
[[`int() volatile`] [`false`]]
[[`int() &`] [`false`]]
[[`int(*)()`] [`false`]]
[[`int`] [`false`]]
[[`int foo::*`] [`false`]]
[[`const int foo::*`] [`false`]]
]
[heading Example Program]
[import ../example/is_transaction_safe.cpp]
[is_transaction_safe]
[endsect]
*/
//]
#endif // #ifndef BOOST_CLBL_TRTS_IS_TRANSACTION_SAFE_HPP
| [
"noreply@github.com"
] | arangodb.noreply@github.com |
a805495f4cd4a76d1ef0367c2f420468073f491b | aab14856adf22a9c2c2e0a0d20bc9590f3eda8c9 | /PaddleCode/lib/old methods.cpp | a419a09e2e5144c479f7899c745e7d78e8f96059 | [] | no_license | wrongwei/ActiveGrid | 1e37337568940c6ab9b6b18cc749516e1450709e | e7cb58b7b1e9192f28eb758d306dbaba1f285527 | refs/heads/master | 2021-01-21T01:50:52.031525 | 2018-04-15T17:55:39 | 2018-04-15T17:55:39 | 38,883,931 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,059 | cpp | //
// old methods.cpp
//
//
// Created by pilot_user on 9/17/12.
//
//
void algo::area(float actpos[], float actstep[]){
//calculates the projected area and corrects the position of each servo to keep the projected area constant
//float delta;
float area_ratio;
//create an array with servonumbers and shuffle it
int random[numberOfServos];
srand(time(0));
for (int i=0; i<numberOfServos; i++) {
random[i] = i;
}
for (int n=0; n < (numberOfServos - 1); n++) {
int r = n + (rand() % (numberOfServos - n));
int temp = random[n]; random[n] = random[r]; random[r] = temp;
}
projected_area = 0;
if(angle_constant_area!=0){
for(int j=0;j<numberOfServos;j++){
projected_area += 100 * fabs(sin(actpos[j] * M_PI / 180));
}
//cout << "old projected area :" << projected_area << endl;
//difference for each servo that needs to be corrected
//cout << "constant area: " << angle_constant_area << endl;
projected_area = (angle_constant_area - projected_area) / numberOfServos;
//cout << "area per servo that needs to be corrected: " << projected_area << endl;
for(int l=0; l<numberOfServos; l++){
area_ratio = (100 * fabs(sin(actpos[random[l]] * M_PI / 180)) + projected_area) / 100;
if (area_ratio <= 1) {
if (area_ratio > 0) {
epsilon = (asin(area_ratio) * 180 / M_PI) - fabs(actpos[random[l]]);
}
else {
epsilon = - fabs(actpos[random[l]]);
area_ratio = area_ratio * 100;
projected_area += area_ratio / (numberOfServos - l);
}
}
else {
epsilon = 90 - fabs(actpos[random[l]]);
area_ratio = (area_ratio * 100) - 100;
projected_area += area_ratio / (numberOfServos - l);
}
//cout << l << " before:" << "actpos: " << actpos[l] << "/t" << "actstep " << actstep[l] << endl;
//cout << "epsilon: " << epsilon << endl;
overwrite(actpos, actstep, random[l]);
//projected_area += delta / (numberOfServos - l);
}
projected_area = 0;
for(int j=0;j<numberOfServos;j++){
projected_area += 100 * fabs(sin(actpos[j] * M_PI / 180));
//cout << j << " " << "currently projected area: " << projected_area << endl;
if (actstep[j] > 42.8 || actstep[j] < 0) {
cout << j << " after:" << "actpos: " << actpos[j] << "/t" << "actstep " << actstep[j] << endl;
}
}
cout << "new projected area: " << projected_area << endl;
}
}
float algo::overwrite (float actpos[], float actstep[], int servonumber) {
//corrects the arrays positions, steps, actpos and actstep
//float check[positions[servonumber].size()];
//int count =0;
//float standard;
//standard = 100 * fabs(sin((actpos[servonumber] + epsilon) * M_PI / 180));
//cout << "standard alt: " << standard << endl;
//while (true) {
//for (int pos = actualpositioninvector[servonumber]; pos <= (int)(positions[servonumber].size() - 1); pos++) {
// check[pos] = positions[servonumber].at(pos);
//}
for (int vecpos = actualpositioninvector[servonumber] - 1; vecpos <= (int)(positions[servonumber].size() - 1); vecpos++) {
if (positions[servonumber].at(vecpos) == -100) {
break;
}
if (positions[servonumber].at(vecpos) < 0) {
//if because of an calculated epsilon an angle is bigger than 90 or -90 degrees, this overstepping will move the
//paddle in the other direction
if ((positions[servonumber].at(vecpos) - epsilon)<= -90 ) {
positions[servonumber].at(vecpos) = -180 + (epsilon - positions[servonumber].at(vecpos));
}
else positions[servonumber].at(vecpos) -= epsilon;
}
if (positions[servonumber].at(vecpos) >= 0) {
if ((positions[servonumber].at(vecpos) + epsilon)>= 90) {
positions[servonumber].at(vecpos) = 180 - (epsilon + positions[servonumber].at(vecpos));
}
else positions[servonumber].at(vecpos) += epsilon;
}
}
/*if (count == 1) {
for (int pos = 0; pos <= (int)(positions[servonumber].size() - 1); pos++) {
positions[servonumber].at(pos) = check[pos];
//formally here actpos[] = ...
}
standard = standard - (100 * fabs(sin(actpos[servonumber] * M_PI / 180)));
cout << "standard neu:" << standard << endl;
return standard;
break;
}*/
//correction of the next anglestep
if (actualpositioninvector[servonumber] - 1 == 0) {
steps[servonumber].at(actualpositioninvector[servonumber] - 1) += epsilon;
}
else {
if (positions[servonumber].at(actualpositioninvector[servonumber] - 1) > 0) {
if (positions[servonumber].at(actualpositioninvector[servonumber] - 1) - positions[servonumber].at(actualpositioninvector[servonumber] -2) - (steps[servonumber].at(actualpositioninvector[servonumber] - 1) + epsilon) < 0.01 || positions[servonumber].at(actualpositioninvector[servonumber] -2) < 0) {
//float difference = positions[servonumber].at(actualpositioninvector[servonumber] - 1) - positions[servonumber].at(actualpositioninvector[servonumber] -2) - (steps[servonumber].at(actualpositioninvector[servonumber] - 1) + epsilon);
//cout << "actual position :" << positions[servonumber].at(actualpositioninvector[servonumber] - 1) << endl;
//cout << "last position :" << positions[servonumber].at(actualpositioninvector[servonumber] - 2) << endl;
//cout << "actual step :" << steps[servonumber].at(actualpositioninvector[servonumber] - 1) << endl;
//cout << "epsilon :" << epsilon << endl;
//cout << "difference :" << difference << endl;
//steps[servonumber].at(actualpositioninvector[servonumber] -1) += epsilon;
}
else steps[servonumber].at(actualpositioninvector[servonumber] -1) -= epsilon;
}
if (positions[servonumber].at(actualpositioninvector[servonumber] - 1) < 0) {
if(fabs(positions[servonumber].at(actualpositioninvector[servonumber] - 1) - positions[servonumber].at(actualpositioninvector[servonumber] -2)) - (steps[servonumber].at(actualpositioninvector[servonumber] -1) + epsilon) < 0.01 || positions[servonumber].at(actualpositioninvector[servonumber] -2) > 0) {
steps[servonumber].at(actualpositioninvector[servonumber] -1) += epsilon;
}
else steps[servonumber].at(actualpositioninvector[servonumber] -1) -= epsilon;
}
}
/*if (steps[servonumber].at(actualpositioninvector[servonumber] - 1) > max_angleperstep) {
if (epsilon > 0) {
epsilon -= (steps[servonumber].at(actualpositioninvector[servonumber] - 1) - max_angleperstep);
}
if (epsilon < 0) {
epsilon += (steps[servonumber].at(actualpositioninvector[servonumber] - 1) - max_angleperstep);
}
steps[servonumber].at(actualpositioninvector[servonumber] - 1) = max_angleperstep;
}
if (steps[servonumber].at(actualpositioninvector[servonumber] - 1) < 0) {
if (epsilon > 0) {
epsilon -= fabs(steps[servonumber].at(actualpositioninvector[servonumber] - 1));
}
if (epsilon < 0) {
epsilon += fabs(steps[servonumber].at(actualpositioninvector[servonumber] - 1));
}
steps[servonumber].at(actualpositioninvector[servonumber] - 1) = 0;
}*/
actstep[servonumber] = steps[servonumber].at(actualpositioninvector[servonumber] - 1);
actpos[servonumber] = positions[servonumber].at(actualpositioninvector[servonumber] - 1);
//count++;
//}
} | [
"nathan@Florina.lfpn.ds.mpg.de"
] | nathan@Florina.lfpn.ds.mpg.de |
aa22644d8a36a5b46c2eaf076a0e8849a0ee32f3 | cef87962d74ab02898935b8cde3d4f4ed30fbea5 | /Test1/simple_bit_operation.cpp | 7946d6d876bdacfdc518fb90344f1713ac01741d | [] | no_license | chen-assert/algorithm-code-library | 3cba324c51fc4ca41c14a9e2a0e7825f7657ff53 | cb9ff66ad05b883be372366929d0e4200a8aabcc | refs/heads/master | 2021-07-06T16:43:39.748180 | 2019-04-01T02:07:49 | 2019-04-01T02:07:49 | 85,138,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,499 | cpp | #include<stdio.h>
#include <stdlib.h>
#include<algorithm>
#include<limits.h>
#include<time.h>
#include<iostream>
#include<functional>
#include <fstream>
#include<vector>
#include<queue>
#include<string.h>
#include<stack>
#include <set>
//#include"segment tree.h"
#include<regex>
//#include<windows.h>
using namespace std;
#define range(i, s, e) for (int i = (s); i < int(e); i++)
#define range0(i, e) for (int i = 0; i < int(e); i++)
#define input_int(n) int n;scanf("%d",&n);
#define input_int2(n,m) int n;int m;scanf("%d %d",&n,&m);
#define remax(max_record,refresh_number) max_record=std::max(max_record,refresh_number)
#define remin(min_record,refresh_number) min_record=std::min(min_record,refresh_number)
#define INF 0x3f3f3f3f
#define INF2 INT_MAX
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> llP;
inline void read(int &x) {//only read int
static char c;
for (c = getchar(); !('0' <= c && c <= '9'); c = getchar());
for (x = 0; '0' <= c && c <= '9'; x = x * 10 + c - 48, c = getchar());
}
int BigRand()
{
return RAND_MAX * rand() + rand();
}
int main() {
input_int2(n, s);
int *array = new int(n);
range0(i, n)scanf("%d", &array[i]);
for (int i = 1; i <= (1 << (n - 1)); i++) {
int sum = 0;
for (int o = 0; o < n; o++) {
if ((1<<o)&i)sum += array[o];
}
if (sum == s) {
for (int o = 0; o < n; o++) {
int flag = 0;
if ((1 << o)&i) {
printf(" %d ", array[o]);
}
}
printf("=%d\n", s);
}
}
} | [
"jingrui.chen@ucdconnect.ie"
] | jingrui.chen@ucdconnect.ie |
1635aeccdd78fed1632843e5f162043018cfdac8 | 7a9a8315971153ae84d114a0a32a11f5f6542d70 | /baekjoon/2741.cpp | 7433f4df4f562b353de2236716a6ba2425bc6c78 | [] | no_license | Minki000/Algorithm | 137c4ebb151d7d4613c44e31d20461326f832a02 | fd7cf2d75413147ef7ccb29c1adf6570f4479cf8 | refs/heads/master | 2022-12-06T20:30:12.795542 | 2020-09-05T05:10:43 | 2020-09-05T05:10:43 | 270,904,209 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 153 | cpp | #include <iostream>
using namespace std;
int main()
{
int input;
scanf("%d",&input);
for (int i = 1; i <= input; i++)
{
printf("%d\n",i);
}
}
| [
"noreply@github.com"
] | Minki000.noreply@github.com |
be83b58b7a776aecb25a24ec8c083ceb7992e7bc | e89d149a3d2af4708add76a66ecc917529e37884 | /Project/Thridlibrary/include/boost/boost/process/detail/posix/null_in.hpp | c1f6f4fb847db33764efd7a7590f758670cc9c2f | [] | no_license | q871980431/Algorithmtest | 4eebe2388481c1d6a6ec69a79de0e79202a7cf75 | 1c6295312ba9091b0cf9f7a14eb226ed9c23318a | refs/heads/master | 2021-07-21T12:13:17.538651 | 2020-06-11T03:23:09 | 2020-06-11T03:23:09 | 181,812,025 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,346 | hpp | // Copyright (c) 2006, 2007 Julio M. Merino Vidal
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
// Copyright (c) 2009 Boris Schaeling
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROCESS_DETAIL_POSIX_NULL_IN_HPP
#define BOOST_PROCESS_DETAIL_POSIX_NULL_IN_HPP
#include <boost/process/pipe.hpp>
#include <boost/process/detail/posix/handler.hpp>
#include <boost/process/detail/posix/file_descriptor.hpp>
#include <unistd.h>
#include <boost/process/detail/used_handles.hpp>
#include <array>
namespace boost { namespace process { namespace detail { namespace posix {
struct null_in : handler_base_ext, ::boost::process::detail::uses_handles
{
file_descriptor source{"/dev/null", file_descriptor::read};
std::array<int, 2> get_used_handles()
{
return {STDIN_FILENO, source.handle()};
}
public:
template <class Executor>
void on_exec_setup(Executor &e) const
{
if (::dup2(source.handle(), STDIN_FILENO) == -1)
e.set_error(::boost::process::detail::get_last_error(), "dup2() failed");
}
};
}}}}
#endif
| [
"xuping.phoenix@mokun.com"
] | xuping.phoenix@mokun.com |
bafe33cc2514ab20cd928b9559101061e7bbd35b | 9873e5b59c65b3b5d0fe135cc9e752e029853f82 | /Leet Code/C++/1302. Deepest Leaves Sum.cpp | 0755c2d66f18b55eb9996910b7155088bdfa924b | [] | no_license | one-diary/Solved-Programming-Questions | 323d5981fa1945623261d040d31798d29754a5e0 | fdbf78d73c851deb4b482dd2cd60c046af3ecaad | refs/heads/master | 2023-06-12T20:38:06.870457 | 2021-07-07T15:12:25 | 2021-07-07T15:12:25 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,107 | cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
* };
*/
class Solution
{
public:
int deepestLeavesSum(TreeNode *root)
{
int sum = 0, ans = 0;
queue<TreeNode *> q;
if (root == nullptr)
{
return ans;
}
q.push(root);
while (!q.empty())
{
int sz = q.size();
sum = 0;
while (sz--)
{
TreeNode *curr = q.front();
q.pop();
sum += curr->val;
if (curr->left)
{
q.push(curr->left);
}
if (curr->right)
{
q.push(curr->right);
}
}
ans = sum;
}
return ans;
}
}; | [
"harshitrock111@gmail.com"
] | harshitrock111@gmail.com |
0cf3dff7cb97aa2419c692257eff43985ba67090 | 7208837d6c1f0ac3ff623060fe0b64dfd4e541a1 | /components/offline_pages/core/prefetch/prefetch_item_unittest.cc | e5710ea21259c3dcb06f9de16c04a547a5f77c0d | [
"BSD-3-Clause"
] | permissive | isoundy000/chromium | b2ee07ebc5ce85e5d635292f6a37dbb7c2135a93 | 62580345c78c08c977ba504d789ed92c1ff18525 | refs/heads/master | 2023-03-17T17:29:40.945889 | 2017-06-29T22:29:10 | 2017-06-29T22:29:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,355 | cc | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/offline_pages/core/prefetch/prefetch_item.h"
#include "base/time/time.h"
#include "components/offline_pages/core/prefetch/prefetch_types.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace offline_pages {
TEST(PrefetchItemTest, OperatorEqualsAndCopyConstructor) {
PrefetchItem item1;
EXPECT_EQ(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1.guid = "A";
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.client_id = ClientId("B", "C");
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.state = PrefetchItemState::AWAITING_GCM;
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.url = GURL("http://test.com");
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.final_archived_url = GURL("http://test.com/final");
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.request_archive_attempt_count = 10;
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.operation_name = "D";
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.archive_body_name = "E";
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.archive_body_length = 20;
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.creation_time = base::Time::FromJavaTime(1000L);
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.freshness_time = base::Time::FromJavaTime(2000L);
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
item1 = PrefetchItem();
item1.error_code = PrefetchItemErrorCode::EXPIRED;
EXPECT_NE(item1, PrefetchItem());
EXPECT_EQ(item1, PrefetchItem(item1));
}
} // namespace offline_pages
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
fad275727d36c74bdb50eb99da6dfec31ba4115b | 5e8ac998f259247652805ffa664243676c928dc0 | /b1024.cpp | ce5d099ea35180371f4db0ca3c3880e1d956b2ae | [] | no_license | like777/PAT | 77992bd4b9009e95717909179834eeef9505876a | 479e90ca10fa1fea774f4a934eae73a31356a25a | refs/heads/master | 2020-03-18T15:54:38.043820 | 2018-08-22T06:51:39 | 2018-08-22T06:51:39 | 134,936,410 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,071 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
string s;
cin >> s;
bool isPostive;
if (s[0] == '+')
{
isPostive = true;
}else
{
isPostive = false;
}
string number;
int i = 1;
for (; s[i] != 'E'; i++)
{
if (s[i] != '.')
{
number.push_back(s[i]);
}
}
bool isPowPostive;
if (s[++i] == '+')
{
isPowPostive = true;
}else
{
isPowPostive = false;
}
int pow = 0;
for (++i; i < s.size(); i++)
{
pow = pow * 10 + (s[i] - '0');
}
if (!isPowPostive)
{
number.insert(number.begin(),'.');
number.insert(number.begin(),'0');
for (int j = 1; j < pow; j++)
{
number.insert(number.begin() + 2, '0');
}
}else
{
if (pow > number.size() - 1)
{
int length = pow + 1 - number.size();
for (int j = 0; j < length; j++)
{
number.insert(number.end(), '0');
}
}
else if (pow < number.size() - 1)
{
number.insert(number.begin() + pow + 1, '.');
}
}
if (!isPostive)
{
cout << "-";
}
cout << number;
system("pause");
return 0;
} | [
"likebrilliant@outlook.com"
] | likebrilliant@outlook.com |
ef7b255f5e06aee1289eb6eb51fa73b8168c6b49 | cbabd51ad600c63412dc41cd202ed4e9d8b32d40 | /RV_exemplesOpenGL/RV_exemple1/widgetopengl.cpp | 02ecf3b2b92ad15b941c8eac5e03fd1aff1415f1 | [] | no_license | yolanda93/virtual_reality | 3483adbfcb6f82568f65fba37db4c925bc68cd80 | 68ce230f1b402ca049508c7fbeec685d525e78ac | refs/heads/master | 2021-01-12T08:56:14.364462 | 2017-01-02T10:04:03 | 2017-01-02T10:04:03 | 76,728,325 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,876 | cpp | // Cours de Réalité Virtuelle
// leo.donati@unice.fr
//
// EPU 2016-17
#include "widgetopengl.h"
#include <QMessageBox>
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
WidgetOpenGL::WidgetOpenGL(QWidget* parent)
:QOpenGLWidget(parent),QOpenGLFunctions()
{ }
WidgetOpenGL::~WidgetOpenGL()
{
glDeleteProgram(m_programme);
glDeleteBuffers(1, &m_vbo);
}
void WidgetOpenGL::initializeGL()
{
initializeOpenGLFunctions();
glClearColor(0.8f,0.8f,0.8f,1.0f); //gris clair
glShadeModel(GL_SMOOTH);
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glFrontFace(GL_CCW);
initializeVBO();
initializeShader();
}
void WidgetOpenGL::initializeShader()
{
m_programme = glCreateProgram();
//Vertex Shader
GLint vs = glCreateShader(GL_VERTEX_SHADER);
const char* vs_source = "attribute vec3 pos;\n"
"attribute vec3 col;\n"
"uniform mat4 u_ModelViewProjectionMatrix;\n"
"varying vec4 color;\n"
"\n"
"void main(void)\n"
"{\n"
" gl_Position = u_ModelViewProjectionMatrix * vec4(pos, 1);\n"
" color = vec4(col, 1);\n"
"}\n";
glShaderSource(vs, 1, &vs_source, NULL);
glCompileShader(vs);
GLint res;
glGetShaderiv(vs, GL_COMPILE_STATUS, &res);
if (res != GL_TRUE)
{
QMessageBox msg;
msg.setText("Echec compilation vertex shader");
msg.exec();
}
glAttachShader(m_programme, vs);
//Fragment Shader
GLint fs = glCreateShader(GL_FRAGMENT_SHADER);
const char* fs_source = "varying vec4 color;\n"
"\n"
"void main(void)\n"
"{\n"
" gl_FragColor = color.rgba;\n"
"}\n";
glShaderSource(fs, 1, &fs_source, NULL);
glCompileShader(fs);
glGetShaderiv(fs, GL_COMPILE_STATUS, &res);
if (res != GL_TRUE)
{
QMessageBox msg;
msg.setText("Echec compilation fragment shader");
msg.exec();
}
glAttachShader(m_programme, fs);
glLinkProgram(m_programme);
glGetShaderiv(m_programme, GL_LINK_STATUS, &res);
if (res != GL_TRUE)
{
QMessageBox msg;
msg.setText("Echec link");
msg.exec();
}
glDetachShader(m_programme, vs);
glDetachShader(m_programme, fs);
glDeleteShader(vs);
glDeleteShader(fs);
}
void WidgetOpenGL::initializeVBO()
{
//Tableau des donnees : 3 sommets puis 3 couleurs
GLfloat vertex_data[] = {
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
-1.0f, 0.0f, 0.0f,
1.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 1.0f
};
//Generation d'un nom de VBO
glGenBuffers(1, &m_vbo);
//Liaison du VBO
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
//Ecriture des donnees dans le VBO
glBufferData(GL_ARRAY_BUFFER, sizeof(vertex_data), vertex_data, GL_STATIC_DRAW);
//Libération du VBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void WidgetOpenGL::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//Réglages du Shader Program
glUseProgram(m_programme);
//Récupération identifiant de la variable uniforme
GLuint matrice = glGetUniformLocation(m_programme, "u_ModelViewProjectionMatrix");
glm::mat4 proj = glm::perspective(glm::radians(45.0f), 1.33f, 0.1f, 100.0f);
glm::mat4 vue = glm::translate(glm::mat4(1.0f), glm::vec3(0, 0, -3));
glm::mat4 model = glm::mat4(1.0f);
m_matrix = proj * vue * model;
m_matrix = glm::transpose(m_matrix);
//Passage de la valeur de la variable uniforme
glUniformMatrix4fv(matrice, 1, GL_FALSE, glm::value_ptr(m_matrix));
//Récupération des identifinats des attributs du programma
GLuint idPos = glGetAttribLocation(m_programme, "pos");
GLuint idCol = glGetAttribLocation(m_programme, "col");
//Activation du VBO
glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
//Lien avec les attributs du programme
glVertexAttribPointer(idPos, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glVertexAttribPointer(idCol, 3, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(9*sizeof(GLfloat)));
//Activation des attributs
glEnableVertexAttribArray(idPos);
glEnableVertexAttribArray(idCol);
//Commande de rendu
glDrawArrays(GL_TRIANGLES, 0, 3);
//Désactivation des atributs
glDisableVertexAttribArray(idPos);
glDisableVertexAttribArray(idCol);
//Désactivation du VBO
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void WidgetOpenGL::resizeGL(int width, int height)
{
//transformation de viewport
glViewport(0, 0, width, height);
}
| [
"yolanda93h@gmail.com"
] | yolanda93h@gmail.com |
3d713bb8fc8bb3cba26e267c6c105681f7cd5b6f | 21fe8b7b8c0b87ff9d271f6a8dcfa1891fc17715 | /MSCvisus/include/mscRegularRawDataHandler.h | 094fd92f6a516f51c6cde22518ede2561cd41d5b | [] | no_license | sam-lev/UnSupUnetMSCSegmentation | f2541bc7237b00b727cd6c62b7607f87b21e1bcd | 8a9f996cf7bc7d1e7951deb14c9cb756ac79f48c | refs/heads/master | 2022-03-31T04:10:32.161467 | 2020-01-19T05:13:38 | 2020-01-19T05:13:38 | 197,672,736 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,690 | h | #ifndef MSC_REGULAR_RAW_DATA_HANDLER
#define MSC_REGULAR_RAW_DATA_HANDLER
#include "mscIndexTypes.h"
#include "mscBasicDataHandler.h"
#include "mscArrayFactory.h"
#include "mscConvergentGradientBuilder.h"
#include <vector>
#include <math.h>
using namespace std;
template<typename dtype>
class mscRegularRawDataHandler : public mscBasicDataHandler<dtype> {
protected:
mscBasicArray<dtype>* values;
public:
mscRegularRawDataHandler() {}
virtual ~mscRegularRawDataHandler() {
printf("delete: mscRegularRawDataHandler \n");
delete values;
}
bool load_data(char* filename, CELL_INDEX_TYPE num_elements, mscArrayFactory* array_factory) {
FILE* fin = fopen(filename, "rb");
if (fin == NULL) return false;
values = array_factory->create<dtype>(num_elements);
mscBasicArray<dtype>& values_r = *(values);
for (CELL_INDEX_TYPE i = 0; i < num_elements; i++) {
fread(&(values_r[i]), sizeof(dtype), 1, fin);
}
fclose(fin);
return true;
}
void logify() {
mscBasicArray<dtype>& values_r = *(values);
CELL_INDEX_TYPE num_elements = values->size();
for (CELL_INDEX_TYPE i = 0; i < num_elements; i++) {
values_r[i] = log(values_r[i]);
}
}
void hack_cut() {
mscBasicArray<dtype>& values_r = *(values);
CELL_INDEX_TYPE num_elements = values->size();
for (CELL_INDEX_TYPE i = 0; i < num_elements; i++) {
if (values_r[i] < .2) values_r[i] = .2;
}
}
void negate() {
mscBasicArray<dtype>& values_r = *(values);
CELL_INDEX_TYPE num_elements = values->size();
for (CELL_INDEX_TYPE i = 0; i < num_elements; i++) {
values_r[i] = -1.0* (values_r[i]);
}
}
inline dtype value(CELL_INDEX_TYPE index) {
mscBasicArray<dtype>& values_r = *values;
return values_r[index];
}
//void testfart() {
// for (int i =0; i < 5; i++)
// printf("%d = %.4f\n", i, value(i + i*100));
//}
void dump_vals(char* filename, int X, int Y, int Z, vector<idfpair>& v) {
int dX = 2*X-1;
int dY = 2*Y-1;
int dZ = 2*Z-1;
float* result = new float[X*Y*Z];
for (int i = 0; i < X*Y*Z; i++) result[i] = 1.0f;
for (int i =0; i < v.size(); i++) {
CELL_INDEX_TYPE id = v[i].id;
CELL_INDEX_TYPE x = id % dX;
CELL_INDEX_TYPE y = (id / dX) % dY;
CELL_INDEX_TYPE z = id / (dX*dY);
//if (x%2 + y%2 + z%2 == 0) {
result[(x/2)+(y/2)*X+(z/2)*Y*X] = min(result[(x/2)+(y/2)*X+(z/2)*Y*X], v[i].prob);
//}
}
char newname[1024];
sprintf(newname, "%s.prob", filename);
FILE* fout = fopen(newname, "wb");
fwrite(result, sizeof(float), X*Y*Z, fout);
fclose(fout);
}
};
#endif | [
"samlev@cs.utah.edu"
] | samlev@cs.utah.edu |
9d612533e32ed340281f04cba5ff78ccf149e696 | 7f2255fd0fce35a14556dda32ff06113c83b2e88 | /ACM训练/树形dp/hdu1054.cpp | cfa20e8c22adf6abdbc5a8de66bb7c23bb1ff363 | [] | no_license | cordercorder/ProgrammingCompetionCareer | c54e2c35c64a1a5fd45fc1e86ddfe5b72ab0cb01 | acc27440d3a9643d06bfbfc130958b1a38970f0a | refs/heads/master | 2023-08-16T18:21:27.520885 | 2023-08-13T15:13:44 | 2023-08-13T15:13:44 | 225,124,408 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,618 | cpp | #include<bits/stdc++.h>
using namespace std;
#define FC ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define FIN freopen("in.txt","r",stdin)
#define FOUT freopen("out.txt","w",stdout)
#define deb(x) cerr<<"DEBUG------"<<'\n';cerr<<#x<<"------>";err(x)
template<typename T>
void err(T a){
cerr<<a<<'\n';
cerr<<"END OF DEBUG"<<'\n'<<'\n';
}
const long double PI=acos(-1.0);
const long double eps=1e-6;
const long long maxw=(long long)1e17+(long long)10;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;
/*head------[@cordercorder]*/
const int maxn=1550;
int n;
vector<int> e[maxn];
char s[1000];
int dp[maxn][2];
void cal_index(int &u,int &k){
int len=strlen(s);
u=0;
k=0;
int i;
for(i=0;s[i]!=':';i++){
u=u*10+(int)(s[i]-'0');
}
i+=2;
for(;s[i]!=')';i++){
k=k*10+(int)(s[i]-'0');
}
}
void dfs(int u,int fa){
int v;
dp[u][0]=0;
dp[u][1]=1;
for(int i=0;i<(int)e[u].size();i++){
v=e[u][i];
if(v!=fa){
dfs(v,u);
dp[u][0]+=dp[v][1];
dp[u][1]+=min(dp[v][0],dp[v][1]);
}
}
}
int main(void){
while(scanf("%d",&n)!=EOF){
int u,v,k;
for(int i=0;i<n;i++){
scanf("%s",s);
cal_index(u,k);
for(int j=0;j<k;j++){
scanf("%d",&v);
e[u].push_back(v);
e[v].push_back(u);
}
}
dfs(0,-1);
printf("%d\n",min(dp[0][1],dp[0][0]));
for(int i=0;i<n;i++){
e[i].clear();
}
}
return 0;
}
| [
"2205722269@qq.com"
] | 2205722269@qq.com |
f63125530a4917ca19fbed0e0647d3f80a9a48e2 | c06ed530b5374e7b8a7e5fca7d2e750909477848 | /classes/Calculator.hpp | 955da525b609d74a5fbf2861418241ce875c77fb | [] | no_license | Lewanchik/abstractVM | 685c7faa2c2fea946a3cd37a489f462a68aece72 | a6d02f51af953a8b783c30481901882b2eff79dc | refs/heads/master | 2021-02-17T21:40:44.538617 | 2020-03-05T10:11:51 | 2020-03-05T10:11:51 | 245,129,312 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 431 | hpp |
#pragma once
#include "stack"
#include "string"
#include "Sign.hpp"
#include "Number.hpp"
#include <cmath>
class Calculator {
public:
Calculator() = default;
double calculatePolishString(std::string &string);
~Calculator() = default;
private:
Calculator(Calculator const &);
Calculator &operator=(Calculator const &);
std::vector<SignOrNumber *> createPolishString(std::string &input);
};
| [
"klop1280@gmail.com"
] | klop1280@gmail.com |
b574fe96af258838e5d931990693f70e594c5c81 | 8029141fedef57c5446ead984fc6e869b79c29a6 | /control.cpp | db5ce2cc895ccf763c32f42ff4f5fdc6a267ab07 | [] | no_license | oscarMATA/VehiculoEvasor | 41c2b64ee95d0b38a562b907b933a2025bd82a13 | b9ecdd5cbee851f331059d54f950534c3037f807 | refs/heads/master | 2021-01-10T05:58:48.167737 | 2015-12-12T03:38:24 | 2015-12-12T03:38:24 | 47,858,886 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,664 | cpp | #include "Arduino.h"
#include "control.h"
long evaluacionCercaRL (long distance)
{
long cerca;
//CERCA
if (distance <= cercaRL_1)
{
cerca = 100;
}
else if ((distance > cercaRL_1 ) && (distance < cercaRL_2) )
{
cerca = 100-((100/(cercaRL_2 - cercaRL_1))*(distance - cercaRL_1));
}
else
{
cerca = 0;
}
return cerca;
}
long evaluacionCercaF (long distance)
{
long cerca;
if (distance <= cercaF_1)
{
cerca = 100;
}
else if ((distance > cercaF_1 )&&(distance < cercaF_2) )
{
cerca = 100-((100/(cercaF_2 - cercaF_1))*(distance - cercaF_1));
}
else
{
cerca = 0;
}
return cerca;
}
long evaluacionLejosRL (long distance)
{
long lejos;
//LEJOS
if (distance <= lejosRL_1)
{
lejos = 0;
}
else if ((distance > lejosRL_1 )&(distance < lejosRL_2) )
{
lejos = (100/(lejosRL_2 - lejosRL_1))*(distance - lejosRL_1);
}
else
{
lejos = 100;
}
return lejos;
}
long evaluacionLejosF (long distance)
{
long lejos;
if (distance <= lejosF_1)
{
lejos = 0;
}
else if ((distance > lejosF_1 )&(distance < lejosF_2) )
{
lejos = (100/(lejosF_2 - lejosF_1))*(distance- lejosF_1);
}
else
{
lejos = 100;
}
return lejos;
}
long evaluacionReglasL (long cercaR, long cercaL, long cercaF, long lejosR, long lejosL, long lejosF)
{
long R1,R2,R3,R4,R5,R6,R7,R8;
long vL1,vL2,vL3,vL4,vL5,vL6,vL7,vL8;
long centroideL;
long num,den;
R1 = andFnct(lejosL,lejosR,lejosF);
R2 = andFnct(lejosL,lejosR,cercaF);
R3 = andFnct(lejosL,cercaR,lejosF);
R4 = andFnct(lejosL,cercaR,cercaF);
R5 = andFnct(cercaL,lejosR,lejosF);
R6 = andFnct(cercaL,lejosR,cercaF);
R7 = andFnct(cercaL,cercaR,lejosF);
R8 = andFnct(cercaL,cercaR,cercaF);
vL1 = R1*ADELANTE;
vL2 = R2*ATRAS;
vL3 = R3*ATRAS;
vL4 = R4*ATRAS;
vL5 = R5*ADELANTE;
vL6 = R6*ADELANTE;
vL7 = R7*ADELANTE;
vL8 = R8*ATRAS;
num = vL1 + vL2 + vL3 + vL4 + vL5 + vL6 + vL7 + vL8 ;
den = R1 + R2 + R3 + R4 + R5 + R6 + R7 + R8;
centroideL =num/den;
return centroideL;
}
long evaluacionReglasR (long cercaR, long cercaL, long cercaF, long lejosR, long lejosL, long lejosF)
{
long R1,R2,R3,R4,R5,R6,R7,R8;
long vR1,vR2,vR3,vR4,vR5,vR6,vR7,vR8;
long centroideR;
R1 = andFnct(lejosL,lejosR,lejosF);
R2 = andFnct(lejosL,lejosR,cercaF);
R3 = andFnct(lejosL,cercaR,lejosF);
R4 = andFnct(lejosL,cercaR,cercaF);
R5 = andFnct(cercaL,lejosR,lejosF);
R6 = andFnct(cercaL,lejosR,cercaF);
R7 = andFnct(cercaL,cercaR,lejosF);
R8 = andFnct(cercaL,cercaR,cercaF);
vR1 = R1*ADELANTE;
vR2 = R2*ADELANTE;
vR3 = R3*ADELANTE;
vR4 = R4*ADELANTE;
vR5 = R5*ATRAS;
vR6 = R6*ATRAS;
vR7 = R7*ADELANTE;
vR8 = R8*ATRAS;
centroideR = (vR1 + vR2 + vR3 + vR4 + vR5 + vR6 + vR7 + vR8)/(R1 + R2 + R3 + R4 + R5 + R6 + R7 + R8);
return centroideR;
}
void motorL (long centroideL)
{
long velocidad;
if(centroideL >= 75)
{
velocidad = 75 - (centroideL-75) - 4;
}
else
{
velocidad = (75 - centroideL ) + 75 +4;
}
Serial.print(" Motor Izq: ");
Serial.print(velocidad);
analogWrite(3,255*velocidad/100.0 );
}
void motorR (long centroideR)
{
long velocidad;
if(centroideR>= 75)
{
velocidad = centroideR;
}
else
{
velocidad = centroideR;
}
Serial.print(" motor derecha: ");
Serial.print(velocidad);
Serial.println(" ");
analogWrite(11, 255*velocidad/100.0 );
}
long andFnct(long a, long b, long c)
{
long R= 0;
if (a < b)
{ R = a; }
else
{ R = b; }
if (R < c)
{ R = R; }
else
{ R =c; }
return R;
}
| [
"oscardelarosa_93@hotmail.com"
] | oscardelarosa_93@hotmail.com |
68a431c68d70f87d17b217640797bfabb86f1b9d | 65a003b040520730f0db71d0df1d0d52a30c2c50 | /control/corba/client/trackingmonitor/trackingmonitor.cpp | 685a8a6f8f11ee43623624111d60d651ec9ff4af | [] | no_license | AndreasFMueller/AstroPhotography | dd4db3b90bd14eaf0f8cc225d19da1477a21418d | 23174595f1d0cb64bfcba46db75ade9925d245a4 | refs/heads/master | 2023-01-12T12:53:51.582049 | 2023-01-02T20:43:42 | 2023-01-02T20:43:42 | 7,716,135 | 8 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 6,544 | cpp | /*
* trackingmonitor.cpp -- demo program for the tracking monitor functionality
* of the astrod server
*
* (c) 2013 Prof Dr Andreas Mueller, Hochschule Rapperwil
*/
#include <stdexcept>
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <OrbSingleton.h>
#include <NameService.h>
#include <AstroDebug.h>
#include <includes.h>
#include <CorbaExceptionReporter.h>
#include <guider.hh>
#include <signal.h>
#include <iomanip>
#include <AstroUtils.h>
namespace astro {
Astro::Guider_var guider;
long monitorid = 0;
long imagemonitorid = 0;
CORBA::ORB_ptr orbptr;
//////////////////////////////////////////////////////////////////////
// TrackingMonitor service implementation
//////////////////////////////////////////////////////////////////////
std::ostream& operator<<(std::ostream& out, const Astro::Point& p) {
out << std::setw(7) << std::fixed << std::setprecision(3) << p.x;
out << ",";
out << std::setw(7) << std::fixed << std::setprecision(3) << p.y;
return out;
}
std::ostream& operator<<(std::ostream& out, const ::Astro::TrackingPoint& ti) {
out << std::fixed << std::setprecision(3) << Timer::gettime() - ti.timeago;
out << " ";
out << ti.trackingoffset;
out << " ";
out << ti.activation;
return out;
}
class TrackingMonitor_impl : public POA_Astro::TrackingMonitor {
public:
TrackingMonitor_impl() { }
virtual void update(const ::Astro::TrackingPoint& ti);
virtual void stop();
};
void TrackingMonitor_impl::update(const ::Astro::TrackingPoint& ti) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "update() received");
std::cout << ti << std::endl;
}
void TrackingMonitor_impl::stop() {
debug(LOG_DEBUG, DEBUG_LOG, 0, "stop received");
kill(getpid(), SIGINT);
}
//////////////////////////////////////////////////////////////////////
// TrackingImageMonitor service implementation
//////////////////////////////////////////////////////////////////////
class TrackingImageMonitor_impl : public POA_Astro::TrackingImageMonitor {
public:
TrackingImageMonitor_impl() { }
virtual void update(const ::Astro::TrackingImage& image);
virtual void stop() { }
};
void TrackingImageMonitor_impl::update(const ::Astro::TrackingImage& image) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "got an image of size %dx%d",
image.size.width, image.size.height);
double min = 65536;
double max = 0;
double mean = 0;
for (unsigned int i = 0; i < image.imagedata.length(); i++) {
unsigned short v = image.imagedata[i];
if (v > max) { max = v; }
if (v < min) { min = v; }
mean += v;
}
mean /= image.imagedata.length();
std::cout << image.size.width << "x" << image.size.height << " image, ";
std::cout << "min=";
std::cout << std::fixed << std::setprecision(0) << min;
std::cout << ", ";
std::cout << "mean=";
std::cout << std::fixed << std::setprecision(1) << mean;
std::cout << ", ";
std::cout << "max=";
std::cout << std::fixed << std::setprecision(0) << max;
std::cout << std::endl;
}
void signal_handler(int sig) {
debug(LOG_DEBUG, DEBUG_LOG, 0, "signal %d received", sig);
guider->unregisterMonitor(monitorid);
guider->unregisterImageMonitor(imagemonitorid);
orbptr->shutdown(false);
}
int trackingmonitor_main(int argc, char *argv[]) {
// initialize the ORB
Astro::OrbSingleton orb(argc, argv);
// guider parameters
std::string camera("camera:simulator/camera");
int ccdid = 0;
std::string guiderport("guiderport:simulator/guiderport");
// parse the commmand line for guider information
int c;
while (EOF != (c = getopt(argc, argv, "dC:c:g:")))
switch (c) {
case 'd':
debuglevel = LOG_DEBUG;
break;
case 'C':
camera = optarg;
break;
case 'c':
ccdid = atoi(optarg);
break;
case 'g':
guiderport = optarg;
break;
}
// access the naming service
Astro::Naming::NameService nameservice(orb);
// get a reference to the guider factory
Astro::GuiderFactory_var guiderfactory;
try {
guiderfactory = orb.getGuiderfactory();
} catch (const CORBA::Exception& x) {
std::string s = Astro::exception2string(x);
debug(LOG_ERR, DEBUG_LOG, 0, "getGuiderfactory() exception: %s",
s.c_str());
throw std::runtime_error(s);
}
// get a guider from the guider factory
Astro::GuiderDescriptor *descriptor = new Astro::GuiderDescriptor();
descriptor->cameraname = CORBA::string_dup(camera.c_str());
descriptor->ccdid = ccdid;
descriptor->guiderportname = CORBA::string_dup(guiderport.c_str());
guider = guiderfactory->get(*descriptor);
// create a POA for the local tracking monitor implementation
CORBA::Object_var obj
= orb.orbvar()->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
assert(!CORBA::is_nil(root_poa));
// create a TrackingMonintor implementation and hand it to the POA
TrackingMonitor_impl *trackingmonitor = new TrackingMonitor_impl();
PortableServer::ObjectId_var trackingmonitorsid
= root_poa->activate_object(trackingmonitor);
// now get a reference to object ourselves
CORBA::Object_var tmobj
= root_poa->id_to_reference(trackingmonitorsid);
Astro::TrackingMonitor_var tmvar
= Astro::TrackingMonitor::_narrow(tmobj);
// create the TrackingImageMonitor implementation and hand it to the POA
TrackingImageMonitor_impl *trackingimagemonitor
= new TrackingImageMonitor_impl();
PortableServer::ObjectId_var trackingimagemonitorsid
= root_poa->activate_object(trackingimagemonitor);
// now get a reference to the object
CORBA::Object_var timobj
= root_poa->id_to_reference(trackingimagemonitorsid);
Astro::TrackingImageMonitor_var timvar
= Astro::TrackingImageMonitor::_narrow(timobj);
// get the POA manager
PortableServer::POAManager_var pman = root_poa->the_POAManager();
pman->activate();
// register the tracking monitor with the guider
monitorid = guider->registerMonitor(tmvar);
imagemonitorid = guider->registerImageMonitor(timvar);
debug(LOG_DEBUG, DEBUG_LOG, 0, "monitor registered as %ld", monitorid);
// make the orb ptr available to the signal handler
orbptr = orb.orbvar();
// register signal handler
signal(SIGINT, signal_handler);
// wait for requests coming into the orb
orb.orbvar()->run();
orb.orbvar()->destroy();
// if we get to this point, then the orb was interrupted by the
// signal handler
return EXIT_SUCCESS;
}
} // namespace astro
int main(int argc, char *argv[]) {
try {
return astro::trackingmonitor_main(argc, argv);
} catch (std::exception& x) {
std::cout << argv[0] << " terminated by exception: ";
std::cout << x.what() << std::endl;
}
}
| [
"afm@othello.ch"
] | afm@othello.ch |
0ee42aeba9c83940fdec143ca6256ec1df3ef8e4 | 7ed7aa5e28bd3cdea44e809bbaf8a527a61259fb | /UVa/10389 - Subway.cpp | 833a7e1b6c772a7926b7209e9f3a880c046081ee | [] | no_license | NaiveRed/Problem-solving | bdbf3d355ee0cb2390cc560d8d35f5e86fc2f2c3 | acb47328736a845a60f0f1babcb42f9b78dfdd10 | refs/heads/master | 2022-06-16T03:50:18.823384 | 2022-06-12T10:02:23 | 2022-06-12T10:02:23 | 38,728,377 | 4 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 2,633 | cpp | #include <cstdio>
#include <sstream>
#include <utility>
#include <queue>
#include <map>
#include <vector>
#include <cmath>
using namespace std;
typedef pair<int, int> Stop;
struct Node
{
int id;
double cost; //minute
Node(int _id, double _cost) : id(_id), cost(_cost) {}
bool operator<(const Node &a) const { return cost > a.cost; }
};
inline double get_dist(Stop &a, Stop &b)
{
return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}
int main()
{
const double speed[2] = { 10000.0 / 60, 40000.0 / 60 };
map<Stop, int> stop_to_id;
Stop id_to_stop[205];
vector<int> adj_list[205];
int Case;
scanf("%d", &Case);
while (Case--)
{
Stop start, goal;
scanf("%d%d%d%d", &start.first, &start.second, &goal.first, &goal.second);
stop_to_id[start] = 1;
stop_to_id[goal] = 2;
id_to_stop[1] = start;
id_to_stop[2] = goal;
int id = 3;
char str[10000];
getchar();
// subway station
while (fgets(str, 10000, stdin) && str[0] != '\n')
{
istringstream ss(str);
int x, y, now, last = -1;
while (ss >> x >> y)
{
if (x < 0)
break;
Stop n(x, y);
if (stop_to_id.count(n))
now = stop_to_id[n];
else
{
now = stop_to_id[n] = id;
id++;
}
id_to_stop[now] = n;
if (last != -1)
{
adj_list[now].push_back(last);
adj_list[last].push_back(now);
}
last = now;
}
}
//dijkstra
bool visited[205] = {};
double d[205]; //best minute
for (int i = 0; i < id; i++)
d[i] = 1e9;
d[1] = 0;
priority_queue<Node> PQ;
PQ.push(Node(1, 0));
while (!PQ.empty())
{
int now_id = 0;
while (!PQ.empty() && visited[now_id = PQ.top().id])
PQ.pop();
if (!now_id || now_id == 2) // 2 is goal id
break;
visited[now_id] = true;
Stop now = id_to_stop[now_id];
//subway
for (int next_id : adj_list[now_id])
{
Stop next = id_to_stop[next_id];
if (!visited[next_id])
{
double cost = d[now_id] + get_dist(now, next) / speed[1];
if (cost < d[next_id])
{
d[next_id] = cost;
PQ.push(Node(next_id, d[next_id]));
}
}
}
//walk
for (int next_id = 2; next_id < id; next_id++)
{
Stop next = id_to_stop[next_id];
if (!visited[next_id])
{
double cost = d[now_id] + get_dist(now, next) / speed[0];
if (cost < d[next_id])
{
d[next_id] = cost;
PQ.push(Node(next_id, d[next_id]));
}
}
}
}
printf("%d\n", (int)(d[2]+0.5));
if (Case)
putchar('\n');
//init
stop_to_id.clear();
for (int i = 0; i < id; i++)
adj_list[i].clear();
}
return 0;
}
| [
"jason841201@gmail.com"
] | jason841201@gmail.com |
f4a8fe7f6178b359003467a9e645691f14507d72 | 7f5af127884a99a26dd9b9265ac30879eeb80ff0 | /ch05/fig05_09_11/fig05_11.cpp | 0c13a81738f931dca9022c888ec8de5cb676813f | [] | no_license | emiliaalbe/Code_Examples | 8b107230f227e39313dff6003ca12baa97ae5c4e | 81ed60e83aafeadfddda14a77226f5e2fdcda4ca | refs/heads/master | 2022-12-15T12:25:41.086903 | 2020-09-05T17:43:38 | 2020-09-05T17:43:38 | 293,095,429 | 0 | 0 | null | 2020-09-05T17:43:39 | 2020-09-05T14:47:37 | C++ | UTF-8 | C++ | false | false | 1,550 | cpp | // Fig. 5.11: fig05_11.cpp
// Creating a GradeBook object and calling its member functions.
#include "GradeBook.h" // include definition of class GradeBook
int main()
{
// create GradeBook object
GradeBook myGradeBook( "CS101 C++ Programming" );
myGradeBook.displayMessage(); // display welcome message
myGradeBook.inputGrades(); // read grades from user
myGradeBook.displayGradeReport(); // display report based on grades
} // end main
/**************************************************************************
* (C) Copyright 1992-2014 by Deitel & Associates, Inc. and *
* Pearson Education, Inc. All Rights Reserved. *
* *
* DISCLAIMER: The authors and publisher of this book have used their *
* best efforts in preparing the book. These efforts include the *
* development, research, and testing of the theories and programs *
* to determine their effectiveness. The authors and publisher make *
* no warranty of any kind, expressed or implied, with regard to these *
* programs or to the documentation contained in these books. The authors *
* and publisher shall not be liable in any event for incidental or *
* consequential damages in connection with, or arising out of, the *
* furnishing, performance, or use of these programs. *
**************************************************************************/
| [
"emiliabaezalbe@localhost.localdomain"
] | emiliabaezalbe@localhost.localdomain |
0049775c0157299485f9794fcd1c370ca39d927c | cb66fbeed2fb34ace91a7c326e9aeaf64ad36fd7 | /firmware/Старые версии/GyverControl_1.4.1/arrowControl.ino | b7c8f69fab4c5e6550c5a192eb67d317a217c3ee | [
"MIT"
] | permissive | ogneyar/GyverControl | 5c0a9042b7f43c94c73e6fe301bdfc0869d98868 | c8907b2b960dbdeed16853f74953126d3f19ba51 | refs/heads/master | 2023-07-19T05:51:09.374337 | 2021-09-09T16:10:36 | 2021-09-09T16:10:36 | 580,484,686 | 2 | 0 | MIT | 2022-12-20T17:16:37 | 2022-12-20T17:16:36 | null | UTF-8 | C++ | false | false | 6,083 | ino | void drawArrow() {
if (currentChannel >= 0) {
// ----------------- НАСТРОЙКИ КАНАЛОВ -----------------
space(0, 0);
space(14, 0);
if (navDepth == 0) {
space(0, 1);
space(0, 2);
space(0, 3);
if (currentChannel > 6 && currentChannel < 9 && !navDepth) {
space(10, 3);
space(15, 3);
}
if (arrowPos == 0)
arrow(0, 0);
else if (arrowPos == 1)
arrow(14, 0);
else if (arrowPos == 2)
arrow(0, 1);
else if (arrowPos == 3)
arrow(0, 2);
else if (arrowPos == 4) {
if (currentChannel > 6 && currentChannel < 9 && !navDepth) {
arrow(10, 3);
} else {
arrow(0, 3);
}
}
else if (arrowPos == 5) {
arrow(15, 3);
}
} else {
// ------------- НАСТРОЙКИ РЕЖИМОВ (navDepth == 1) -------------
byte thisMode = channels[currentChannel].mode;
space(0, 0);
space(14, 0);
if (arrowPos == 0) arrow(0, 0);
if (arrowPos == 1) arrow(14, 0);
switch (thisMode) {
case 0:
space(0, 1);
space(0, 2);
space(0, 3);
space(7, 1);
colon(11, 1);
colon(14, 1);
space(8, 2);
colon(11, 2);
colon(14, 2);
switch (arrowPos) {
case 2: arrow(7, 1); break;
case 3: arrow(11, 1); break;
case 4: arrow(14, 1); break;
case 5: arrow(8, 2); break;
case 6: arrow(11, 2); break;
case 7: arrow(14, 2); break;
}
break;
case 1:
space(0, 1);
space(0, 2);
space(0, 3);
switch (arrowPos) {
case 2: arrow(0, 1); break;
case 3: arrow(0, 2); break;
case 4: arrow(0, 3); break;
}
break;
case 2:
space(4, 1);
space(6, 1);
space(8, 1);
space(10, 1);
space(12, 1);
space(14, 1);
space(16, 1);
space(3, 2);
colon(6, 2);
colon(9, 2);
space(3, 3);
colon(6, 3);
colon(9, 3);
colon(17, 3);
switch (arrowPos) {
case 2: arrow(4, 1); break;
case 3: arrow(6, 1); break;
case 4: arrow(8, 1); break;
case 5: arrow(10, 1); break;
case 6: arrow(12, 1); break;
case 7: arrow(14, 1); break;
case 8: arrow(16, 1); break;
case 9: arrow(3, 2); break;
case 10: arrow(6, 2); break;
case 11: arrow(9, 2); break;
case 12: arrow(3, 3); break;
case 13: arrow(6, 3); break;
case 14: arrow(9, 3); break;
case 15: arrow(17, 3); break;
}
break;
case 3:
space(0, 1);
space(0, 2);
space(0, 3);
colon(15, 3);
colon(5, 3);
switch (arrowPos) {
case 2: arrow(0, 1); break;
case 3: arrow(0, 2); break;
case 4: arrow(5, 3); break;
case 5: arrow(15, 3); break;
}
break;
case 4:
colon(1, 1);
colon(8, 1);
colon(15, 1);
colon(4, 2);
colon(16, 2);
colon(1, 3);
colon(8, 3);
colon(16, 3);
switch (arrowPos) {
case 2: arrow(1, 1); break;
case 3: arrow(8, 1); break;
case 4: arrow(15, 1); break;
case 5: arrow(4, 2); break;
case 6: arrow(16, 2); break;
case 7: arrow(1, 3); break;
case 8: arrow(8, 3); break;
case 9: arrow(16, 3); break;
}
break;
case 5:
colon(5, 1);
colon(13, 1);
colon(4, 2);
colon(13, 2);
colon(3, 3);
colon(11, 3);
switch (arrowPos) {
case 2: arrow(5, 1); break;
case 3: arrow(13, 1); break;
case 4: arrow(4, 2); break;
case 5: arrow(13, 2); break;
case 6: arrow(3, 3); break;
case 7: arrow(11, 3); break;
}
break;
}
}
} else if (currentChannel == -1) {
arrow(0, 0);
} else if (currentChannel == -2) {
// ------------------ НАСТРОЙКИ -------------------
colon(16, 0); colon(8, 1); colon(16, 1); colon(5, 2);
colon(16, 2); colon(5, 3); colon(16, 3); space(0, 0);
switch (arrowPos) {
case 0: arrow(0, 0); break;
case 1: arrow(16, 0); break;
case 2: arrow(8, 1); break;
case 3: arrow(16, 1); break;
case 4: arrow(5, 2); break;
case 5: arrow(16, 2); break;
case 6: arrow(5, 3); break;
case 7: arrow(16, 3); break;
}
} else if (currentChannel == -3) {
// ------------------ SERVICE -------------------
space(0, 0); space(11, 0); colon(9, 3);
colon(14, 0); colon(17, 0); space(0, 2);
space(2, 2); space(4, 2); space(6, 2);
space(8, 2); space(10, 2); space(12, 2);
colon(16, 1); colon(16, 2); colon(1, 3);
colon(16, 3);
switch (arrowPos) {
case 0: arrow(0, 0); break;
case 1: arrow(11, 0); break;
case 2: arrow(14, 0); break;
case 3: arrow(17, 0); break;
case 4: arrow(0, 2); break;
case 5: arrow(2, 2); break;
case 6: arrow(4, 2); break;
case 7: arrow(6, 2); break;
case 8: arrow(8, 2); break;
case 9: arrow(10, 2); break;
case 10: arrow(12, 2); break;
case 11: arrow(16, 1); break;
case 12: arrow(16, 2); break;
case 13: arrow(1, 3); break;
case 14: arrow(9, 3); break;
case 15: arrow(16, 3); break;
}
}
}
void arrow(byte col, byte row) {
lcd.setCursor(col, row);
if (!controlState)
lcd.write(126);
else
lcd.write(62);
}
void space(byte col, byte row) {
lcd.setCursor(col, row);
lcd.print(F(" "));
}
void colon(byte col, byte row) {
lcd.setCursor(col, row);
lcd.print(F(":"));
}
| [
"beragumbo@ya.ru"
] | beragumbo@ya.ru |
c8c29f2a2360eb50d975588c8a3f193248e47e44 | 4d3b1403feb4c7124323b08dad340a017eff5b0a | /Client/cocos2dx-2.1beta3-x-2.1.1/catfight_1.01.02/Classes/LibIO/IO_OutputTextStream.cpp | f9c15584a4740774ce535344bb804ab3dee5339e | [
"MIT"
] | permissive | wanggan768q/GameWork | 9f69a3d64369f04a6693d24501cf90fdcb42ce7f | a249835eef66f64c862a5d80287475aa2b9b64e9 | refs/heads/master | 2021-06-25T18:33:15.314160 | 2017-05-14T11:47:58 | 2017-05-14T11:47:58 | 18,544,524 | 3 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 2,081 | cpp | #include "IO_OutputTextStream.h"
#include "IO_CharEncoder.h"
IO_OutputTextStream::IO_OutputTextStream()
{
stream = NULL;
encode = IO_ENCODE_DEFAULT;
}
IO_OutputTextStream::~IO_OutputTextStream()
{
}
bool IO_OutputTextStream::Open(IO_OutputDataStream* stream, int encode)
{
if(stream == NULL)
{
return false;
}
switch(encode)
{
case IO_ENCODE_ASCII:
break;
case IO_ENCODE_UNICODE:
if(stream->Write(0xff) == 0) return false;
if(stream->Write(0xfe) == 0) return false;
break;
case IO_ENCODE_UNICODE_BIG_ENDIAN:
if(stream->Write(0xfe) == 0) return false;
if(stream->Write(0xff) == 0) return false;
break;
case IO_ENCODE_UTF8:
if(stream->Write(0xef) == 0) return false;
if(stream->Write(0xbb) == 0) return false;
if(stream->Write(0xbf) == 0) return false;
break;
default:
return false;
}
this->stream = stream;
this->encode = encode;
return true;
}
void IO_OutputTextStream::Close()
{
stream = NULL;
encode = IO_ENCODE_DEFAULT;
}
int IO_OutputTextStream::GetEncode()
{
return encode;
}
int IO_OutputTextStream::Write(int ch)
{
if(stream != NULL)
{
return stream->Write(ch);
}
return -1;
}
int IO_OutputTextStream::Write(const void* buffer, int size)
{
if(stream != NULL)
{
return stream->Write(buffer, size);
}
return -1;
}
int IO_OutputTextStream::GetOutputSize()
{
if(stream == NULL)
{
return -1;
}
return stream->GetOutputSize();
}
void IO_OutputTextStream::WriteChar(wchar_t data)
{
if(!IO_CharEncoder::WriteChar(stream, encode, data))
{
IOMessageBox("IO_OutputTextStream @ WriteChar throw IO_ERROR_ENCODE");
}
}
void IO_OutputTextStream::WriteChars(const wchar_t* buffer, int size)
{
for(int i = 0; i < size; ++i)
{
if(!IO_CharEncoder::WriteChar(stream, encode, buffer[i]))
{
IOMessageBox("IO_OutputTextStream @ WriteChar throw IO_ERROR_ENCODE");
}
}
}
void IO_OutputTextStream::WriteLine(const wstring& text)
{
WriteChars(&text[0], text.length());
WriteChar('\n');
}
| [
"ambitiongxb@foxmail.com"
] | ambitiongxb@foxmail.com |
23daba7667d50521a8c070b40da46a6080e01e63 | 9eb1bd529426887a7f964386623b7f3183d7ba89 | /voxels/Chunks.cpp | 87416cdc4caafe5e10d3f21ea56f0bb15198e7f1 | [] | no_license | DenisLozhnikov/voxel-game-engine | 0f099cd0b7b7d0832d19e02c30f06a472a09ce7e | f687eca8777f58dc49ffedf52012e94f48b13afa | refs/heads/master | 2023-09-03T20:54:37.747786 | 2021-07-10T10:20:08 | 2021-07-10T10:20:08 | 384,669,566 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,285 | cpp | #include "Chunks.h"
#include <iostream>
Chunks::Chunks(int _w, int _h, int _d) : w(_w), h(_h), d(_d)
{
vol = w * h * d;
std::cout << std::endl << vol << " chunks proccesing\n";
chunks = new Chunk* [vol];
int index = 0;
for (int y = 0; y < h; y++) {
for (int z = 0; z < d; z++) {
for (int x = 0; x < w; x++, index++) {
std::cout << index << "/" << vol << std::endl;
Chunk* chunk = new Chunk(x, y, z);
chunks[index] = chunk;
}
}
}
}
Chunks::~Chunks()
{
for (int i = 0; i < vol; i++) {
delete chunks[i];
}
delete[] chunks;
}
voxel* Chunks::get(int x, int y, int z)
{
int cx = x / CHUNK_W;
int cy = y / CHUNK_H;
int cz = z / CHUNK_D;
if (x < 0) cx--;
if (y < 0) cy--;
if (z < 0) cz--;
if (cx < 0 || cy < 0 || cz < 0 || cx >= w || cy >= h || cz >= d)
return nullptr;
Chunk* chunk = chunks[(cy * d + cz) * w + cx];
int lx = x - cx * CHUNK_W;
int ly = y - cy * CHUNK_H;
int lz = z - cz * CHUNK_D;
return &chunk->voxels[(ly * CHUNK_D + lz) * CHUNK_W + lx];
}
Chunk* Chunks::getChunk(int x, int y, int z)
{
if (x < 0 || y < 0 || z < 0 || x >= w || y >= h || z >= d)
return nullptr;
return chunks[(y * d + z) * w + x];
}
void Chunks::set(int x, int y, int z, int id)
{
int cx = x / CHUNK_W;
int cy = y / CHUNK_H;
int cz = z / CHUNK_D;
if (x < 0) cx--;
if (y < 0) cy--;
if (z < 0) cz--;
if (cx < 0 || cy < 0 || cz < 0 || cx >= w || cy >= h || cz >= d)
return;
Chunk* chunk = chunks[(cy * d + cz) * w + cx];
int lx = x - cx * CHUNK_W;
int ly = y - cy * CHUNK_H;
int lz = z - cz * CHUNK_D;
chunk->voxels[(ly * CHUNK_D + lz) * CHUNK_W + lx].id = id;
chunk->modified = true;
if (lx == 0 && (chunk = getChunk(cx - 1, cy, cz))) chunk->modified = true;
if (ly == 0 && (chunk = getChunk(cx, cy - 1, cz))) chunk->modified = true;
if (lz == 0 && (chunk = getChunk(cx, cy, cz - 1))) chunk->modified = true;
if (lx == CHUNK_W - 1 && (chunk = getChunk(cx + 1, cy, cz))) chunk->modified = true;
if (ly == CHUNK_H - 1 && (chunk = getChunk(cx, cy + 1, cz))) chunk->modified = true;
if (lz == CHUNK_D - 1 && (chunk = getChunk(cx, cy, cz + 1))) chunk->modified = true;
}
voxel* Chunks::rayCast(glm::vec3 a, glm::vec3 dir, float maxDist, glm::vec3& end, glm::vec3& norm, glm::vec3& iend)
{
float px = a.x;
float py = a.y;
float pz = a.z;
float dx = dir.x;
float dy = dir.y;
float dz = dir.z;
t = 0.0f;
int ix = floor(px);
int iy = floor(py);
int iz = floor(pz);
float stepx = (dx > 0.0f) ? 1.0f : -1.0f;
float stepy = (dy > 0.0f) ? 1.0f : -1.0f;
float stepz = (dz > 0.0f) ? 1.0f : -1.0f;
constexpr float infinity = std::numeric_limits<float>::infinity();
float txDelta = (dx == 0.0f) ? infinity : abs(1.0f / dx);
float tyDelta = (dy == 0.0f) ? infinity : abs(1.0f / dy);
float tzDelta = (dz == 0.0f) ? infinity : abs(1.0f / dz);
float xdist = (stepx > 0) ? (ix + 1 - px) : (px - ix);
float ydist = (stepy > 0) ? (iy + 1 - py) : (py - iy);
float zdist = (stepz > 0) ? (iz + 1 - pz) : (pz - iz);
float txMax = (txDelta < infinity) ? txDelta * xdist : infinity;
float tyMax = (tyDelta < infinity) ? tyDelta * ydist : infinity;
float tzMax = (tzDelta < infinity) ? tzDelta * zdist : infinity;
int steppedIndex = -1;
while (t <= maxDist) {
voxel* voxel = get(ix, iy, iz);
if (voxel == nullptr || voxel->id) {
end.x = px + t * dx;
end.y = py + t * dy;
end.z = pz + t * dz;
iend.x = ix;
iend.y = iy;
iend.z = iz;
norm.x = norm.y = norm.z = 0.0f;
if (steppedIndex == 0) norm.x = -stepx;
if (steppedIndex == 1) norm.y = -stepy;
if (steppedIndex == 2) norm.z = -stepz;
return voxel;
}
if (txMax < tyMax) {
if (txMax < tzMax) {
ix += stepx;
t = txMax;
txMax += txDelta;
steppedIndex = 0;
}
else {
iz += stepz;
t = tzMax;
tzMax += tzDelta;
steppedIndex = 2;
}
}
else {
if (tyMax < tzMax) {
iy += stepy;
t = tyMax;
tyMax += tyDelta;
steppedIndex = 1;
}
else {
iz += stepz;
t = tzMax;
tzMax += tzDelta;
steppedIndex = 2;
}
}
}
iend.x = ix;
iend.y = iy;
iend.z = iz;
end.x = px + t * dx;
end.y = py + t * dy;
end.z = pz + t * dz;
norm.x = norm.y = norm.z = 0.0f;
return nullptr;
}
void Chunks::loadWorld(unsigned char* buff)
{
size_t index = 0;
for (size_t i = 0; i < vol; i++) {
Chunk* chunk = chunks[i];
for (size_t j = 0; j < CHUNK_VOL; j++, index++) {
chunk->voxels[j].id = buff[index];
}
chunk->modified = true;
}
}
void Chunks::saveWorld(unsigned char* buff)
{
size_t index = 0;
for (int i = 0; i < vol; i++) {
Chunk* chunk = chunks[i];
for (size_t j = 0; j < CHUNK_VOL; j++, index++) {
buff[index] = chunk->voxels[j].id;
}
}
}
| [
"deniswof@yandex.ru"
] | deniswof@yandex.ru |
26cdae65d363171857391458dde34ede7a61f2fd | cb0a12f23aa34e2983d89bb5e8d21b6687cdedda | /NeoPixel Trials/Gradient_Testing/Gradient_Testing.ino | 7b79c5b5ba4b02ab01f56d674fcda8f0e9576f18 | [] | no_license | harshita-gupta/Sing-Me-A-Dress | ad95880c102bafb241469157227032e4347e94b9 | d7870d491d607968886f0f75d0f16324316a531b | refs/heads/master | 2021-01-10T11:32:54.847104 | 2016-03-10T07:07:08 | 2016-03-10T07:07:08 | 52,170,546 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,105 | ino | #include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(150, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
rainbowCycle(20);
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j, k;
for(i=25; i< strip.numPixels(); i--) {
for (j=75, j<strip.numPixels(); j--) {
for (k=50, k<strip.numPixels(); k++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
}
}
strip.show();
delay(wait);
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(0, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(0, 255 - WheelPos * 3, 0);
}
| [
"xyla.foxlin@gmail.com"
] | xyla.foxlin@gmail.com |
92e23d7b83d0e051d97bc044d083cd3fe5ae8325 | 65f9576021285bc1f9e52cc21e2d49547ba77376 | /LINUX/android/vendor/qcom/proprietary/vam/vam_utils/JSON/json_parser/source/metadata_parser.cc | 27ca99404104c528a38cd1e31cbc7956c3c055c5 | [] | no_license | AVCHD/qcs605_root_qcom | 183d7a16e2f9fddc9df94df9532cbce661fbf6eb | 44af08aa9a60c6ca724c8d7abf04af54d4136ccb | refs/heads/main | 2023-03-18T21:54:11.234776 | 2021-02-26T11:03:59 | 2021-02-26T11:03:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 49,398 | cc | /*
* Copyright (c) 2016-2017, Qualcomm Technologies, Inc.
* All Rights Reserved.
* Confidential and Proprietary - Qualcomm Technologies, Inc.
*/
#include "metadata_parser.h"
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string.h>
extern "C"{
#include "json_metadata.h"
}
using namespace std;
MetadataParser::MetadataParser() :
filename_loaded(string("")),
file_pos_(0),
frames_loaded_(0),
time_stamp_(0),
fp_json_(0),
fp_idx_(0),
frame_cnt_(0),
cur_record_id_(0),
time_interval_(33)
{
AllocateMetadataContent(&metadata_content_);
metadata_content_.cnt_atomic_events = 0;
metadata_content_.cnt_events = 0;
metadata_content_.cnt_extensions = 0;
metadata_content_.cnt_heat_maps = 0;
metadata_content_.cnt_objects = 0;
metadata_content_.cnt_object_trees = 0;
metadata_frame_.camera_id.uuid = string(" ");
}
MetadataParser::~MetadataParser()
{
ReleaseMetadataContent(&metadata_content_);
if (metadata_frame_.heat_maps.size() > 0)
{
for (uint32_t i = 0; i < metadata_frame_.heat_maps.size(); i++)
if (metadata_frame_.heat_maps[i].data)
delete[]metadata_frame_.heat_maps[i].data;
}
if (fp_json_)
fclose(fp_json_);
if (fp_idx_)
fclose(fp_idx_);
}
JSONVAStatus MetadataParser::LoadFileToString(const char *filename,
std::string &contents)
{
frames_loaded_ = 0;
std::ifstream in(filename, std::ios::in | std::ios::binary);
if (in){
in.seekg(0, std::ios::end);
contents.resize(in.tellg());
in.seekg(0, std::ios::beg);
in.read(&contents[0], contents.size());
in.close();
return JSON_VA_OK;
}
else
return JSON_VA_INVALID;
}
JSONVAStatus MetadataParser::LoadIdxFile(const char *filename)
{
int ret;
fp_idx_ = fopen(filename, "r+t");
if (fp_idx_ == NULL)
return JSON_VA_END_OF_FILE;
// int idx_cnt = 0;
while (!feof(fp_idx_))
{
IdxFileRecord record;
ret = fscanf(fp_idx_, "%llu %d %d", &record.time_stamp, &record.frame_id, &record.frame_size);
if (ret != 3)
break;
idx_records.push_back(record);
}
fclose(fp_idx_);
fp_idx_ = 0;
cur_record_id_ = 0;
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::GetNextMetadataFrame(std::string & str)
{
if (cur_record_id_ == 0 || cur_record_id_ == idx_records.size()-1){
if (fp_json_)
fclose(fp_json_);
if (fp_idx_)
fclose(fp_idx_);
if (cur_record_id_ != 0)
start_time_stamp_ = time_stamp_+time_interval_;
cur_record_id_ = 0;
//time_stamp_ = frame_cnt_;
sprintf(filename_json_, "%s_%lld_%d.jsonx", file_prefix_, start_time_stamp_, frame_cnt_);
sprintf(filename_idx_, "%s_%lld_%d.idx", file_prefix_, start_time_stamp_, frame_cnt_);
fp_json_ = fopen(filename_json_, "r+t");
if (fp_json_ == NULL)
return JSON_VA_END_OF_FILE;
fp_idx_ = fopen(filename_idx_, "r+t");
if (fp_idx_ == NULL)
return JSON_VA_END_OF_FILE;
fclose(fp_idx_);
fp_idx_ = 0;
LoadIdxFile(filename_idx_);
}
if (idx_records.size() == 0 || idx_records.size() == cur_record_id_)
return JSON_VA_END_OF_FILE;
int size = idx_records[cur_record_id_].frame_size;
char * buf = new char[size+1];
int size2 = fread(buf, 1, size, fp_json_);
buf[size2] = 0;
str = string(buf);
//printf("%s\n", buf);
delete []buf;
cur_record_id_++;
frame_cnt_++;
if (size2 != size)
return JSON_VA_INVALID;
return JSON_VA_OK;
}
template<typename T>
bool MetadataParser::NotInValidRange(T value, T minValue, T maxValue)
{
if (value<minValue || value>maxValue)
return true;
else
return false;
}
JSONVAStatus MetadataParser::ParseScene(const Json::Value scene,
MetadataFrame & metadata)
{
if (scene.isMember("heat_map")){
Json::Value heat_map_node = scene["heat_map"];
VAHeatMap heat_map;
heat_map.cells_per_row = heat_map_node["cells_per_row"].asInt();
heat_map.rows_per_column = heat_map_node["rows_per_column"].asInt();
heat_map.start_time = heat_map_node["start_time"].asUInt64();
heat_map.end_time = heat_map_node["end_time"].asUInt64();
if (NotInValidRange<uint32_t>(heat_map.cells_per_row, 0, 100) ||
NotInValidRange<uint32_t>(heat_map.rows_per_column, (uint32_t)0,
(uint32_t)100))
return JSON_VA_INVALID;
Json::Value heat_map_data = heat_map_node["data"];
heat_map.data =
new uint16_t[heat_map.cells_per_row*heat_map.rows_per_column];
Json::Value::iterator it;
int i;
for (it= heat_map_data.begin(), i = 0; it != heat_map_data.end();
++it, i++){
heat_map.data[i] = (*it).asInt();
}
#ifdef DEBUG_
for (i = 0; i<heat_map.cells_per_row*heat_map.rows_per_column; i++){
cout<<heat_map.data[i] <<", ";
}
#endif
metadata.heat_maps.push_back(heat_map);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ClearMetadata(MetadataFrame & metadata)
{
metadata.camera_id.uuid = string(" ");
metadata.atomic_events.clear();
metadata.events.clear();
metadata.extensions.clear();
for (unsigned int i = 0; i < metadata.heat_maps.size(); i++){
if (metadata.heat_maps[i].data){
delete[]metadata.heat_maps[i].data;
metadata.heat_maps[i].data = NULL;
}
}
metadata.heat_maps.clear();
metadata.objects.clear();
metadata.object_trees.clear();
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseObjects(const Json::Value objects,
MetadataFrame & metadata)
{
Json::Value::iterator it;
for (it = objects.begin(); it != objects.end(); ++it){
VAObject object;
object.engine_type = (*it)["engine_type"].asString();
object.object_id = (*it)["object_id"].asInt();
if ((*it).isMember("appearance"))
{
Json::Value appearance = (*it)["appearance"];
object.appearance_descriptor.object_type =
(MetadataCategory)appearance["object_type"].asInt();
object.appearance_descriptor.object_type_confidence =
appearance["object_type_confidence"].asInt();
if (appearance.isMember("location"))
{
Json::Value location = appearance["location"];
object.appearance_descriptor.location.x = location["x"].asInt();
object.appearance_descriptor.location.y = location["y"].asInt();
object.appearance_descriptor.location.width =
location["width"].asInt();
object.appearance_descriptor.location.height =
location["height"].asInt();
}
if (object.engine_type == "object_tracker")
{
object.appearance_descriptor.object_tracker_appearance.
physical_width = appearance["physical_width"].asInt();
object.appearance_descriptor.object_tracker_appearance.
physical_height = appearance["physical_height"].asInt();
object.appearance_descriptor.object_tracker_appearance.
moving_dir = (MetadataDir)appearance["moving_dir"].asInt();
object.appearance_descriptor.object_tracker_appearance.
moving_speed = appearance["moving_speed"].asFloat();
}
}
else
return JSON_VA_INVALID;
if ((*it).isMember("on_event"))
{
Json::Value on_event = (*it)["on_event"];
object.on_event.status = on_event["status"].asInt();
Json::Value::iterator it_events;
for (it_events = on_event["events"].begin(); it_events !=
on_event["events"].end(); it_events++)
{
struct metadata_uuid_t event_id;
strcpy(event_id.uuid, (*it_events)["event"].asString().c_str());
object.on_event.event_ids.push_back(event_id);
}
}
else
object.on_event.status = 0;
for (int k = 0; k < 5; k++){
object.reserve[k] = 0;
object.reserve_str[k][0] = 0;
}
if ((*it).isMember("reserve"))
{
Json::Value::iterator it_reserve;
Json::Value reserve = (*it)["reserve"];
int k = 0;
for (it_reserve = (*it)["reserve"].begin(); it_reserve !=
(*it)["reserve"].end(); it_reserve++)
{
if (k >= 5)
break;
object.reserve[k] = (*it_reserve).asInt64();
k++;
}
}
if ((*it).isMember("reserve_str"))
{
Json::Value::iterator it_reserveStr;
Json::Value reserve_str = (*it)["reserve_str"];
int k = 0;
for (it_reserveStr = (*it)["reserve_str"].begin(); it_reserveStr !=
(*it)["reserve_str"].end(); it_reserveStr++)
{
if (k >= 5)
break;
strcpy(object.reserve_str[k], (*it_reserveStr).asString().c_str());
k++;
}
}
metadata.objects.push_back(object);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseObjectTrees(const Json::Value object_trees,
MetadataFrame & metadata)
{
Json::Value::iterator it;
for (it = object_trees.begin(); it != object_trees.end(); ++it)
{
VAObjectTree object_tree;
if( (*it).isMember("merged"))
{
Json::Value merged = (*it)["merged"];
object_tree.action = METADATA_OBJECT_TREE_MERGED;
object_tree.to.push_back(merged["to"].asInt());
Json::Value::iterator it_from;
for (it_from = merged["from"].begin(); it_from !=
merged["from"].end(); it_from++)
{
object_tree.from.push_back((*it_from).asInt());
}
}
else if ((*it).isMember("split"))
{
Json::Value split = (*it)["split"];
object_tree.action = METADATA_OBJECT_TREE_SPLIT;
object_tree.from.push_back(split["from"].asInt());
Json::Value::iterator it_to;
for (it_to = split["to"].begin(); it_to != split["to"].end();
it_to++)
{
object_tree.to.push_back((*it_to).asInt());
}
}
else if ((*it).isMember("created"))
{
Json::Value created = (*it)["created"];
object_tree.action = METADATA_OBJECT_TREE_CREATED;
object_tree.to.push_back(created["to"].asInt());
}
else if ((*it).isMember("deleted"))
{
Json::Value deleted = (*it)["deleted"];
object_tree.action = METADATA_OBJECT_TREE_DELETED;
object_tree.from.push_back(deleted["from"].asInt());
}
else if ((*it).isMember("renamed"))
{
Json::Value renamed = (*it)["renamed"];
object_tree.action = METADATA_OBJECT_TREE_RENAMED;
object_tree.to.push_back(renamed["to"].asInt());
object_tree.from.push_back(renamed["from"].asInt());
}
else
return JSON_VA_INVALID;
metadata.object_trees.push_back(object_tree);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseAtomicEvents(const Json::Value atomic_events,
MetadataFrame & metadata)
{
Json::Value::iterator it;
for (it = atomic_events.begin(); it != atomic_events.end(); ++it){
VAAtomicEvent atomic_event;
atomic_event.event_id.uuid = (*it)["event_id"].asString();
atomic_event.rule_id.uuid = (*it)["rule_id"].asString();
atomic_event.event_type = (MetadataEventType)(*it)["event_type"].asInt();
atomic_event.rule_name = (*it)["rule_name"].asString();
if ((*it).isMember("start_time"))
atomic_event.start_time = (*it)["start_time"].asUInt64();
else
atomic_event.start_time = metadata.time_stamp;
if ((*it).isMember("event_details")){
Json::Value event_details = (*it)["event_details"];
switch (atomic_event.event_type){
case METADATA_EVENT_CAMERA_TAMPER_DETECTED:
atomic_event.event_details.details_camera_tamper_detected.
tamper_type =
(CameraTamperType)event_details["tamper_type"].asInt();
break;
case METADATA_EVENT_MOTION_DETECTED:
atomic_event.event_details.details_motion_detected.
motion_activity =
(CameraTamperType)event_details["motion_activity"].asInt();
atomic_event.event_details.details_motion_detected.object_id =
(CameraTamperType)event_details["object_id"].asInt();
break;
case METADATA_EVENT_INTRUSION_DETECTED:
case METADATA_EVENT_LINECROSSED:
case METADATA_EVENT_LOITERING_DETECTED:
case METADATA_EVENT_OBJECT_DETECTED:
atomic_event.event_details.details_object_trackor.object_id =
event_details["object_id"].asInt();
break;
case METADATA_EVENT_OBJECT_COUNTED:
atomic_event.event_details.details_object_counted.count =
event_details["count"].asInt();
break;
case METADATA_EVENT_FACE_DETECTED:
atomic_event.event_details.details_face_detected.object_id =
event_details["object_id"].asInt();
break;
case METADATA_EVENT_FACE_RECOGNIZED:
atomic_event.event_details.details_face_recognized.group_name =
event_details["group_name"].asString();
atomic_event.event_details.details_face_recognized.display_name =
event_details["display_name"].asString();
atomic_event.event_details.details_face_recognized.object_id =
event_details["object_id"].asInt();
atomic_event.event_details.details_face_recognized.person_id.uuid =
event_details["person_id"].asString();
atomic_event.event_details.details_face_recognized.group_id.uuid =
event_details["group_id"].asString();
break;
case METADATA_EVENT_OBJECT_CLASSIFIED:
atomic_event.event_details.details_object_trackor.object_id =
event_details["object_id"].asInt();
break;
default:
break;
}
}
for (int k = 0; k < 5; k++){
atomic_event.reserve[k] = 0;
atomic_event.reserve_str[k][0] = 0;
}
if ((*it).isMember("reserve"))
{
Json::Value::iterator it_reserve;
Json::Value reserve = (*it)["reserve"];
int k = 0;
for (it_reserve = (*it)["reserve"].begin(); it_reserve !=
(*it)["reserve"].end(); it_reserve++)
{
if (k >= 5)
break;
atomic_event.reserve[k] = (*it_reserve).asInt64();
k++;
}
}
if ((*it).isMember("reserve_str"))
{
Json::Value::iterator it_reserveStr;
Json::Value reserve_str = (*it)["reserve_str"];
int k = 0;
for (it_reserveStr = (*it)["reserve_str"].begin(); it_reserveStr !=
(*it)["reserve_str"].end(); it_reserveStr++)
{
if (k >= 5)
break;
strcpy(atomic_event.reserve_str[k], (*it_reserveStr).asString().c_str());
k++;
}
}
metadata.atomic_events.push_back(atomic_event);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseEvents(const Json::Value events,
MetadataFrame & metadata)
{
Json::Value::iterator it;
for (it = events.begin(); it != events.end(); ++it){
VAEvent event;
event.event_id.uuid = (*it)["event_id"].asString();
event.rule_id.uuid = (*it)["rule_id"].asString();
event.rule_name = (*it)["rule_name"].asString();
if ((*it).isMember("start_time"))
event.start_time = (*it)["start_time"].asUInt64();
else
event.start_time = metadata.time_stamp;
Json::Value composite_event = (*it)["composite_event"];
event.composite_event.sub_event_id1.uuid =
composite_event["sub_event_id1"].asString();
event.composite_event.num_sub_events = 1;
if (composite_event.isMember("sub_event_id2")){
event.composite_event.sub_event_id2.uuid =
composite_event["sub_event_id2"].asString();
event.composite_event.num_sub_events++;
}
for (int k = 0; k < 5; k++){
event.reserve[k] = 0;
event.reserve_str[k][0] = 0;
}
if ((*it).isMember("reserve"))
{
Json::Value::iterator it_reserve;
Json::Value reserve = (*it)["reserve"];
int k = 0;
for (it_reserve = (*it)["reserve"].begin(); it_reserve !=
(*it)["reserve"].end(); it_reserve++)
{
if (k >= 5)
break;
event.reserve[k] = (*it_reserve).asInt64();
k++;
}
}
if ((*it).isMember("reserve_str"))
{
Json::Value::iterator it_reserveStr;
Json::Value reserve_str = (*it)["reserve_str"];
int k = 0;
for (it_reserveStr = (*it)["reserve_str"].begin(); it_reserveStr !=
(*it)["reserve_str"].end(); it_reserveStr++)
{
if (k >= 5)
break;
strcpy(event.reserve_str[k], (*it_reserveStr).asString().c_str());
k++;
}
}
metadata.events.push_back(event);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseExtension(const Json::Value extensions,
MetadataFrame & metadata)
{
Json::Value::iterator it;
for (it = extensions.begin(); it != extensions.end(); ++it){
VAExtension extension;
extension.engine_id = (*it)["engine_id"].asString();
extension.data = (*it)["data"].asString();
metadata.extensions.push_back(extension);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseDoc(const char* doc, MetadataFrame & metadata)
{
JSONVAStatus res;
Json::Value root; // will contains the root value after parsing.
Json::Reader reader;
ClearMetadata(metadata);
bool parsingSuccessful = reader.parse(doc, root);
if (!parsingSuccessful){
// report to the user the failure and their locations in the document.
std::cout << "Failed to parse metadata\n"
<< reader.getFormattedErrorMessages();
return JSON_VA_INVALID;
}
if (root.isMember("camera_id")){
//printf("camera_id: %p\n", root["camera_id"].asString().c_str());
metadata.camera_id.uuid = root["camera_id"].asString();
}
else
metadata.camera_id.uuid = " ";
if (root.isMember("time_stamp"))
metadata.time_stamp = root["time_stamp"].asUInt64();
else
return JSON_VA_INVALID;
if (root.isMember("scene")){
const Json::Value scene = root["scene"];
ParseScene(scene, metadata);
}
if (root.isMember("objects")){
const Json::Value objects = root["objects"];
res = ParseObjects(objects, metadata);
if (res != JSON_VA_OK){
printf("failed to parse objects in metadata parser\n");
return res;
}
}
if (root.isMember("object_tree")){
const Json::Value object_trees = root["object_tree"];
res = ParseObjectTrees(object_trees, metadata);
if (res != JSON_VA_OK){
printf("failed to parse object_tree in metadata parser\n");
return res;
}
}
if (root.isMember("atomic_events")){
const Json::Value atomic_events = root["atomic_events"];
res = ParseAtomicEvents(atomic_events, metadata);
if (res != JSON_VA_OK){
printf("failed to parse atomic_events in metadata parser\n");
return res;
}
}
if (root.isMember("events")){
const Json::Value events = root["events"];
res = ParseEvents(events, metadata);
if (res != JSON_VA_OK){
printf("failed to parse events in metadata parser\n");
return res;
}
}
if (root.isMember("extension")){
const Json::Value extension = root["extension"];
ParseExtension(extension, metadata);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseDoc(const char* doc, vector<MetadataFrame> & metadata)
{
Json::Value root; // will contains the root value after parsing.
Json::Value metadata_content; // will contains the root value after parsing.
Json::Reader reader;
bool parsingSuccessful = reader.parse(doc, root);
if (!parsingSuccessful){
// report to the user the failure and their locations in the document.
std::cout << "Failed to parse metadata\n"
<< reader.getFormattedErrorMessages();
return JSON_VA_INVALID;
}
Json::Value::iterator it;
metadata_content = root["metadata_content"];
for (it = metadata_content.begin(); it != metadata_content.end(); ++it){
MetadataFrame metadata_frame;
ClearMetadata(metadata_frame);
if ((*it).isMember("camera_id"))
metadata_frame.camera_id.uuid = (string)(*it)["camera_id"].asString();
else
return JSON_VA_INVALID;
if ((*it).isMember("time_stamp"))
metadata_frame.time_stamp = (*it)["time_stamp"].asUInt64();
else
return JSON_VA_INVALID;
if ((*it).isMember("scene")){
const Json::Value scene = (*it)["scene"];
ParseScene(scene, metadata_frame);
}
if ((*it).isMember("objects")){
const Json::Value objects = (*it)["objects"];
ParseObjects(objects, metadata_frame);
}
if ((*it).isMember("object_tree")){
const Json::Value object_trees = (*it)["object_tree"];
ParseObjectTrees(object_trees, metadata_frame);
}
if ((*it).isMember("atomic_events")){
const Json::Value atomic_events = (*it)["atomic_events"];
ParseAtomicEvents(atomic_events, metadata_frame);
}
if ((*it).isMember("events")){
const Json::Value events = (*it)["events"];
ParseEvents(events, metadata_frame);
}
if ((*it).isMember("extension")){
const Json::Value extension = (*it)["extension"];
ParseExtension(extension, metadata_frame);
}
metadata.push_back(metadata_frame);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ParseMetadataFrame(const char* metadata_str, MetadataFrame & metadata_frame)
{
Json::Value root; // will contains the root value after parsing.
Json::Value metadata_content; // will contains the root value after parsing.
Json::Reader reader;
bool parsingSuccessful = reader.parse(metadata_str, root);
if (!parsingSuccessful){
// report to the user the failure and their locations in the document.
std::cout << "Failed to parse metadata\n"
<< reader.getFormattedErrorMessages();
return JSON_VA_INVALID;
}
ClearMetadata(metadata_frame);
if (root.isMember("camera_id"))
metadata_frame.camera_id.uuid = (string)root["camera_id"].asString();
else
return JSON_VA_INVALID;
if (root.isMember("time_stamp"))
metadata_frame.time_stamp = root["time_stamp"].asUInt64();
else
return JSON_VA_INVALID;
if (root.isMember("scene")){
const Json::Value scene = root["scene"];
ParseScene(scene, metadata_frame);
}
if (root.isMember("objects")){
const Json::Value objects = root["objects"];
ParseObjects(objects, metadata_frame);
}
if (root.isMember("object_tree")){
const Json::Value object_trees = root["object_tree"];
ParseObjectTrees(object_trees, metadata_frame);
}
if (root.isMember("atomic_events")){
const Json::Value atomic_events = root["atomic_events"];
ParseAtomicEvents(atomic_events, metadata_frame);
}
if (root.isMember("events")){
const Json::Value events = root["events"];
ParseEvents(events, metadata_frame);
}
if (root.isMember("extension")){
const Json::Value extension = root["extension"];
ParseExtension(extension, metadata_frame);
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ConvertMetadataFrameToMetadataContent(
const MetadataFrame metadata,
struct metadata_content_t **metadata_content)
{
struct metadata_content_t *metadata_content_new;
metadata_content_new = &metadata_content_;
*metadata_content = metadata_content_new;
if (metadata_content_new->objects == 0)
{
// int flag = 1;
}
for (int i = 0; i < MD_EXTENSION_MAX; i++)
{
if (metadata_content_new->extensions[i].data){
free(metadata_content_new->extensions[i].data);
metadata_content_new->extensions[i].data = 0;
}
}
for (int i = 0; i < MD_HEAT_MAP_MAX; i++)
{
if (metadata_content_new->heat_maps[i].data){
free(metadata_content_new->heat_maps[i].data);
metadata_content_new->heat_maps[i].data = 0;
}
}
metadata_content_new->cnt_atomic_events = metadata.atomic_events.size();
metadata_content_new->cnt_events = metadata.events.size();
metadata_content_new->cnt_extensions = metadata.extensions.size();
metadata_content_new->cnt_heat_maps = metadata.heat_maps.size();
metadata_content_new->cnt_objects = metadata.objects.size();
metadata_content_new->cnt_object_trees = metadata.object_trees.size();
strcpy(metadata_content_new->camera_id.uuid, metadata.camera_id.uuid.c_str());
metadata_content_new->time_stamp = metadata.time_stamp;
for (int k = 0; k < 5; k++){
metadata_content_new->reserve[k] = metadata.reserve[k];
strcpy(metadata_content_new->reserve_str[k], metadata.reserve_str[k]);
}
if (metadata.atomic_events.size() > 0){
for (uint32_t i = 0; i < metadata.atomic_events.size(); i++){
metadata_content_new->atomic_events[i].start_time =
metadata.atomic_events[i].start_time;
strcpy(metadata_content_new->atomic_events[i].rule_id.uuid,
metadata.atomic_events[i].rule_id.uuid.c_str());
strcpy(metadata_content_new->atomic_events[i].event_id.uuid,
metadata.atomic_events[i].event_id.uuid.c_str());
metadata_content_new->atomic_events[i].event_type =
(MetadataEventType)metadata.atomic_events[i].event_type;
strcpy(metadata_content_new->atomic_events[i].rule_name,
metadata.atomic_events[i].rule_name.c_str());
for (int k = 0; k < 5; k++){
metadata_content_new->atomic_events[i].reserve[k] = metadata.atomic_events[i].reserve[k];
strcpy(metadata_content_new->atomic_events[i].reserve_str[k], metadata.atomic_events[i].reserve_str[k]);
}
switch (metadata.atomic_events[i].event_type){
case METADATA_EVENT_CAMERA_TAMPER_DETECTED:
metadata_content_new->atomic_events[i].event_details.
details_camera_tamper_detected.tamper_type =
(enum MetadataCameraTamperType)metadata.atomic_events[i].
event_details.details_camera_tamper_detected.tamper_type;
break;
case METADATA_EVENT_MOTION_DETECTED:
metadata_content_new->atomic_events[i].event_details.
details_motion_detected.motion_activity =
metadata.atomic_events[i].event_details.
details_motion_detected.motion_activity;
metadata_content_new->atomic_events[i].event_details.
details_motion_detected.object_id =
metadata.atomic_events[i].event_details.
details_motion_detected.object_id;
break;
case METADATA_EVENT_INTRUSION_DETECTED:
case METADATA_EVENT_LINECROSSED:
case METADATA_EVENT_LOITERING_DETECTED:
case METADATA_EVENT_OBJECT_DETECTED:
metadata_content_new->atomic_events[i].event_details.
details_object_trackor.object_id =
metadata.atomic_events[i].event_details.
details_object_trackor.object_id;
break;
case METADATA_EVENT_OBJECT_COUNTED:
metadata_content_new->atomic_events[i].event_details.
details_object_counted.count =
metadata.atomic_events[i].event_details.
details_object_counted.count;
break;
case METADATA_EVENT_FACE_DETECTED:
metadata_content_new->atomic_events[i].event_details.
details_face_detected.object_id =
metadata.atomic_events[i].event_details.
details_face_detected.object_id;
break;
case METADATA_EVENT_FACE_RECOGNIZED:
strcpy(metadata_content_new->atomic_events[i].event_details.
details_face_recognized.group_name, metadata.
atomic_events[i].event_details.details_face_recognized.
group_name.c_str());
strcpy(metadata_content_new->atomic_events[i].event_details.
details_face_recognized.display_name, metadata.
atomic_events[i].event_details.details_face_recognized.
display_name.c_str());
metadata_content_new->atomic_events[i].event_details.
details_face_recognized.object_id =
metadata.atomic_events[i].event_details.
details_face_recognized.object_id;
strcpy(metadata_content_new->atomic_events[i].event_details.
details_face_recognized.person_id.uuid,
metadata.atomic_events[i].event_details.
details_face_recognized.person_id.uuid.c_str());
strcpy(metadata_content_new->atomic_events[i].event_details.
details_face_recognized.group_id.uuid, metadata.
atomic_events[i].event_details. details_face_recognized.
group_id.uuid.c_str());
break;
case METADATA_EVENT_OBJECT_CLASSIFIED:
metadata_content_new->atomic_events[i].event_details.
details_object_trackor.object_id = metadata.
atomic_events[i].event_details.details_object_trackor.
object_id;
break;
default:
break;
}
}
}
if (metadata.events.size() > 0){
for (uint32_t i = 0; i < metadata.events.size(); i++){
metadata_content_new->events[i].start_time =
metadata.events[i].start_time;
metadata_content_new->events[i].composite_event.num_sub_events =
metadata.events[i].composite_event.num_sub_events;
strcpy(metadata_content_new->events[i].composite_event.
sub_event_id1.uuid, metadata.events[i].composite_event.
sub_event_id1.uuid.c_str());
if (metadata.events[i].composite_event.num_sub_events > 1){
strcpy(metadata_content_new->events[i].composite_event.
sub_event_id2.uuid, metadata.events[i].composite_event.
sub_event_id2.uuid.c_str());
}
strcpy(metadata_content_new->events[i].rule_name,
metadata.events[i].rule_name.c_str());
strcpy(metadata_content_new->events[i].event_id.uuid,
metadata.events[i].event_id.uuid.c_str());
strcpy(metadata_content_new->events[i].rule_id.uuid,
metadata.events[i].rule_id.uuid.c_str());
for (int k = 0; k < 5; k++){
metadata_content_new->events[i].reserve[k] = metadata.events[i].reserve[k];
strcpy(metadata_content_new->events[i].reserve_str[k], metadata.events[i].reserve_str[k]);
}
}
}
if (metadata.objects.size() > 0){
for (uint32_t i = 0; i < metadata.objects.size(); i++){
if (metadata_content_new->objects == 0)
{
// int flag = 1;
}
metadata_content_new->objects[i].object_id =
metadata.objects[i].object_id;
strcpy(metadata_content_new->objects[i].engine_type,
metadata.objects[i].engine_type.c_str());
metadata_content_new->objects[i].appearance_descriptor =
metadata.objects[i].appearance_descriptor;
metadata_content_new->objects[i].on_event.status =
metadata.objects[i].on_event.status;
metadata_content_new->objects[i].on_event.num_events =
metadata.objects[i].on_event.event_ids.size();
for (int k = 0; k < 5; k++){
metadata_content_new->objects[i].reserve[k] = metadata.objects[i].reserve[k];
strcpy(metadata_content_new->objects[i].reserve_str[k], metadata.objects[i].reserve_str[k]);
}
if (metadata_content_new->objects[i].on_event.num_events > 0){
for (uint32_t k = 0;
k < metadata_content_new->objects[i].on_event.num_events;
k++){
strcpy(metadata_content_new->objects[i].on_event.event_ids[k].uuid,
metadata.objects[i].on_event.event_ids[k].uuid);
}
}
}
}
if (metadata.object_trees.size() > 0){
for (uint32_t i = 0; i < metadata.object_trees.size(); i++){
metadata_content_new->object_trees[i].num_from =
metadata.object_trees[i].from.size();
metadata_content_new->object_trees[i].num_to =
metadata.object_trees[i].to.size();
metadata_content_new->object_trees[i].action =
metadata.object_trees[i].action;
for (uint32_t k = 0; k < metadata_content_new->object_trees[i].num_from;
k++){
metadata_content_new->object_trees[i].from[k] =
metadata.object_trees[i].from[k];
}
for (uint32_t k = 0; k < metadata_content_new->object_trees[i].num_to;
k++){
metadata_content_new->object_trees[i].to[k] =
metadata.object_trees[i].to[k];
}
}
}
if (metadata.heat_maps.size() > 0){
for (uint32_t i = 0; i < metadata.heat_maps.size(); i++){
metadata_content_new->heat_maps[i].cells_per_row =
metadata.heat_maps[i].cells_per_row;
metadata_content_new->heat_maps[i].rows_per_column =
metadata.heat_maps[i].rows_per_column;
metadata_content_new->heat_maps[i].start_time =
metadata.heat_maps[i].start_time;
metadata_content_new->heat_maps[i].end_time =
metadata.heat_maps[i].end_time;
if (metadata_content_new->heat_maps[i].data==0)
metadata_content_new->heat_maps[i].data =
(uint16_t *)malloc(metadata.heat_maps[i].cells_per_row *
metadata.heat_maps[i].rows_per_column * sizeof(uint16_t));
memcpy(metadata_content_new->heat_maps[i].data,
metadata.heat_maps[i].data,
metadata.heat_maps[i].cells_per_row *metadata.heat_maps[i].
rows_per_column * sizeof(uint16_t));
}
}
if (metadata.extensions.size() > 0){
for (uint32_t i = 0; i < metadata.extensions.size(); i++){
metadata_content_new->extensions[i].size_data =
metadata.extensions[i].data.length()+1;
strcpy(metadata_content_new->extensions[i].engine_id,
metadata.extensions[i].engine_id.c_str());
if (metadata_content_new->extensions[i].data){
free(metadata_content_new->extensions[i].data);
}
metadata_content_new->extensions[i].data =
(char*)malloc(metadata_content_new->extensions[i].size_data);
strcpy(metadata_content_new->extensions[i].data,
metadata.extensions[i].data.c_str());
}
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ConvertMetadataContentToMetadataFrame(
const struct metadata_content_t *metadata_content,
MetadataFrame &metadata)
{
metadata.camera_id.uuid = string(metadata_content->camera_id.uuid);
metadata.time_stamp = metadata_content->time_stamp;
if (metadata_content->cnt_atomic_events > 0){
for (uint32_t i = 0; i <metadata_content->cnt_atomic_events; i++){
VAAtomicEvent atomic_event;
atomic_event.start_time =
metadata_content->atomic_events[i].start_time;
atomic_event.rule_id.uuid =
string(metadata_content->atomic_events[i].rule_id.uuid);
atomic_event.event_id.uuid =
string(metadata_content->atomic_events[i].event_id.uuid);
atomic_event.event_type =
(MetadataEventType)metadata_content->atomic_events[i].event_type;
atomic_event.rule_name =
string(metadata_content->atomic_events[i].rule_name);
switch (metadata_content->atomic_events[i].event_type){
case METADATA_EVENT_CAMERA_TAMPER_DETECTED:
atomic_event.event_details.details_camera_tamper_detected.
tamper_type =
(enum CameraTamperType)metadata_content->atomic_events[i].
event_details.details_camera_tamper_detected.tamper_type;
break;
case METADATA_EVENT_MOTION_DETECTED:
atomic_event.event_details.details_motion_detected.
motion_activity =
metadata_content->atomic_events[i].event_details.
details_motion_detected.motion_activity;
atomic_event.event_details.details_motion_detected.
object_id=
metadata_content->atomic_events[i].event_details.
details_motion_detected.object_id;
break;
case METADATA_EVENT_INTRUSION_DETECTED:
case METADATA_EVENT_LINECROSSED:
case METADATA_EVENT_LOITERING_DETECTED:
case METADATA_EVENT_OBJECT_DETECTED:
atomic_event.event_details.
details_object_trackor.object_id =
metadata_content->atomic_events[i].event_details.
details_object_trackor.object_id;
break;
case METADATA_EVENT_OBJECT_COUNTED:
atomic_event.event_details.details_object_counted.count =
metadata_content->atomic_events[i].event_details.
details_object_counted.count;
break;
case METADATA_EVENT_FACE_DETECTED:
atomic_event.event_details.details_face_detected.object_id =
metadata_content->atomic_events[i].event_details.
details_face_detected.object_id;
break;
case METADATA_EVENT_FACE_RECOGNIZED:
atomic_event.event_details.details_face_recognized.group_name =
string(metadata_content->atomic_events[i].event_details.
details_face_recognized.group_name);
atomic_event.event_details.details_face_recognized.
display_name = string(metadata_content->atomic_events[i].
event_details.details_face_recognized.display_name);
atomic_event.event_details.details_face_recognized.object_id =
metadata_content->atomic_events[i].event_details.
details_face_recognized.object_id;
atomic_event.event_details.details_face_recognized.
person_id.uuid =
string(metadata_content->atomic_events[i].event_details.
details_face_recognized.person_id.uuid);
atomic_event.event_details.details_face_recognized.
group_id.uuid = string(metadata_content->atomic_events[i].
event_details.details_face_recognized.group_id.uuid) ;
break;
case METADATA_EVENT_OBJECT_CLASSIFIED:
atomic_event.event_details.details_object_trackor.object_id =
metadata_content->atomic_events[i].event_details.
details_object_trackor.object_id ;
break;
default:
break;
}
metadata.atomic_events.push_back(atomic_event);
}
}
if (metadata_content->cnt_events > 0){
VAEvent event;
for (uint32_t i = 0; i <metadata_content->cnt_events; i++){
event.start_time =
metadata_content->events[i].start_time;
event.composite_event.num_sub_events =
metadata_content->events[i].composite_event.num_sub_events;
event.composite_event.sub_event_id1.uuid =
string(metadata_content->events[i].composite_event.
sub_event_id1.uuid);
if (metadata_content->events[i].composite_event.num_sub_events >1){
event.composite_event.sub_event_id2.uuid =
string(metadata_content->events[i].composite_event.
sub_event_id2.uuid);
}
event.rule_name = string(metadata_content->events[i].rule_name);
event.event_id.uuid =
string(metadata_content->events[i].event_id.uuid);
event.rule_id.uuid =
string(metadata_content->events[i].rule_id.uuid);
metadata.events.push_back(event);
}
}
if (metadata_content->cnt_objects > 0){
for (uint32_t i = 0; i < metadata_content->cnt_objects; i++){
VAObject object;
object.object_id = metadata_content->objects[i].object_id;
object.engine_type =
string(metadata_content->objects[i].engine_type);
object.appearance_descriptor =
metadata_content->objects[i].appearance_descriptor;
object.on_event.status =
metadata_content->objects[i].on_event.status;
if (metadata_content->objects[i].on_event.num_events > 0){
for (uint32_t k = 0; k < metadata_content->objects[i].on_event.num_events; k++){
object.on_event.event_ids.push_back(metadata_content->objects[i].on_event.event_ids[k]);
}
}
metadata.objects.push_back(object);
}
}
if (metadata_content->cnt_object_trees > 0){
for (uint32_t i = 0; i < metadata_content->cnt_object_trees; i++){
VAObjectTree object_tree;
object_tree.action = metadata_content->object_trees[i].action;
for (uint32_t k = 0; k < metadata_content->object_trees[i].num_from; k++)
{
object_tree.from.push_back( metadata_content->object_trees[i].from[k]);
}
for (uint32_t k = 0; k < metadata_content->object_trees[i].num_to; k++){
object_tree.to.push_back(metadata_content->object_trees[i].to[k]);
}
metadata.object_trees.push_back(object_tree);
}
}
if (metadata_content->cnt_heat_maps > 0){
for (uint32_t i = 0; i < metadata_content->cnt_heat_maps; i++){
VAHeatMap heat_map;
heat_map.cells_per_row =
metadata_content->heat_maps[i].cells_per_row;
heat_map.rows_per_column =
metadata_content->heat_maps[i].rows_per_column;
heat_map.data = (uint16_t *)malloc(heat_map.cells_per_row *
heat_map.rows_per_column * sizeof(uint16_t));
heat_map.start_time = metadata_content->heat_maps[i].start_time;
heat_map.end_time = metadata_content->heat_maps[i].end_time;
memcpy(heat_map.data, metadata_content->heat_maps[i].data,
heat_map.cells_per_row * heat_map.rows_per_column *
sizeof(uint16_t));
metadata.heat_maps.push_back(heat_map);
}
}
if (metadata_content->cnt_extensions > 0){
for (uint32_t i = 0; i < metadata_content->cnt_extensions; i++){
VAExtension extension;
extension.engine_id = string(metadata_content->extensions[i].engine_id);
extension.data = string(metadata_content->extensions[i].data);
metadata.extensions.push_back(extension);
}
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::AllocateMetadataContent(
struct metadata_content_t *metadata_content)
{
metadata_content->atomic_events = (struct metadata_atomic_event_t*)
malloc(sizeof(struct metadata_atomic_event_t)*MD_ATOMIC_EVENT_MAX);
metadata_content->events = (struct metadata_event_t*)
malloc(sizeof(struct metadata_event_t)*MD_EVENT_MAX);
metadata_content->extensions = (struct metadata_extension_t*)
malloc(sizeof(struct metadata_extension_t)*MD_EXTENSION_MAX);
metadata_content->heat_maps = (struct metadata_heat_map_t*)
malloc(sizeof(struct metadata_heat_map_t)*MD_HEAT_MAP_MAX);
metadata_content->objects = (struct metadata_object_t*)
malloc(sizeof(struct metadata_object_t)*MD_OBJECT_MAX);
metadata_content->object_trees = (struct metadata_object_tree_t*)
malloc(sizeof(struct metadata_object_tree_t)*MD_OBJECT_TREE_MAX);
memset(metadata_content->atomic_events, 0, sizeof(struct metadata_atomic_event_t)*MD_ATOMIC_EVENT_MAX);
memset(metadata_content->events, 0, sizeof(struct metadata_event_t)*MD_EVENT_MAX);
memset(metadata_content->extensions, 0, sizeof(struct metadata_extension_t)*MD_EXTENSION_MAX);
memset(metadata_content->heat_maps, 0, sizeof(struct metadata_heat_map_t)*MD_HEAT_MAP_MAX);
memset(metadata_content->objects, 0, sizeof(struct metadata_object_t)*MD_OBJECT_MAX);
memset(metadata_content->object_trees, 0, sizeof(struct metadata_object_tree_t)*MD_OBJECT_TREE_MAX);
for (int i = 0; i < MD_HEAT_MAP_MAX; i++)
{
metadata_content->heat_maps[i].data = 0;
metadata_content->heat_maps[i].cells_per_row = 0;
metadata_content->heat_maps[i].rows_per_column = 0;
}
for (int i = 0; i < MD_EXTENSION_MAX; i++)
{
metadata_content->extensions[i].size_data = 0;
metadata_content->extensions[i].data = 0;
}
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::CopyMetadataContent(
const struct metadata_content_t metadata_content_src,
struct metadata_content_t *metadata_content_dst)
{
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::ReleaseMetadataContent(
struct metadata_content_t *metadata_content)
{
for (int i = 0; i < MD_HEAT_MAP_MAX; i++){
if (metadata_content->heat_maps[i].data)
free(metadata_content->heat_maps[i].data);
}
for (int i = 0; i < MD_EXTENSION_MAX; i++){
if (metadata_content->extensions[i].data)
free(metadata_content->extensions[i].data);
}
free(metadata_content->atomic_events);
free(metadata_content->events);
free(metadata_content->extensions);
free(metadata_content->heat_maps);
free(metadata_content->objects);
free(metadata_content->object_trees);
return JSON_VA_OK;
}
JSONVAStatus MetadataParser::SeekMetadataPos(uint64_t time_stamp)
{
bool found = false;
int idx = -1;
for (uint32_t i = 0; i < idx_records.size(); i++)
{
if (time_stamp == idx_records[i].time_stamp){
found = true;
idx = i;
break;
}
else if (time_stamp < idx_records[i].time_stamp){
return JSON_VA_INVALID;
}
}
if (found){
long size = 0;
for (int i = 0; i < idx; i++){
size += idx_records[i].frame_size;
}
cur_record_id_ = idx;
if(fseek(fp_json_, size, SEEK_CUR))
return JSON_VA_INVALID;
return JSON_VA_OK;
}
else
return JSON_VA_INVALID;
}
| [
"jagadeshkumar.s@pathpartnertech.com"
] | jagadeshkumar.s@pathpartnertech.com |
7af864abb5bd7b3e0117fe71f23363c3c5f5d07e | dccd1058e723b6617148824dc0243dbec4c9bd48 | /codeforces/802K.cpp | e6e854a066ca69e166dd1a6b1a9f3ce8250f7d82 | [] | no_license | imulan/procon | 488e49de3bcbab36c624290cf9e370abfc8735bf | 2a86f47614fe0c34e403ffb35108705522785092 | refs/heads/master | 2021-05-22T09:24:19.691191 | 2021-01-02T14:27:13 | 2021-01-02T14:27:13 | 46,834,567 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,641 | cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
using pi = pair<int,int>;
struct edge{int to; ll cost;};
const int V=100000;
int n,k;
vector<edge> G[V];
edge par[V];
vector<edge> ch[V];
int d[V];
ll cost[V]={};
ll dp[V];
ll dfs(int x)
{
if(dp[x]>=0) return dp[x];
ll ret=0;
priority_queue<pi> PQ;
map<int,ll> COST;
for(const auto &e:ch[x])
{
COST[e.to]=cost[e.to]+e.cost;
PQ.push(pi(COST[e.to],e.to));
}
int lastnum=-1;
ll sum=0;
set<int> S;
int ct=0;
while(ct<k && !PQ.empty())
{
++ct;
pi val = PQ.top();
PQ.pop();
sum += val.fi;
S.insert(val.se);
if(ct==k) lastnum = val.se;
}
// printf(" x(%d), S=\n", x);
// for(const auto &X:S) printf(" %d", X);
// printf("\n");
// k回行く方向を決める
for(const auto &e:ch[x])
{
ll add=sum;
if(S.count(e.to)) add -= COST[e.to];
else
{
if(lastnum!=-1)
{
add -= COST[lastnum];
// add += COST[e.to];
}
}
// printf(" x %d, nx %d add %lld (sum %lld)\n", x,e.to,add,sum);
ret = max(ret, dfs(e.to)+e.cost+add);
}
// printf("x %d -> %lld\n", x,ret);
return dp[x]=ret;
}
int main()
{
scanf(" %d %d", &n, &k);
// scanf(" %d", &n); k=1;
rep(i,n-1)
{
int u,v,c;
scanf(" %d %d %d", &u, &v, &c);
G[u].pb({v,c});
G[v].pb({u,c});
}
vector<bool> vis(n,false);
queue<int> que;
que.push(0);
fill(d,d+V,INT_MAX/3);
d[0] = 0;
vis[0]=true;
while(!que.empty())
{
int v=que.front();
que.pop();
for(const auto &e:G[v])
{
if(vis[e.to]) continue;
vis[e.to] = true;
que.push(e.to);
par[e.to] = (edge){v,e.cost};
ch[v].pb(e);
d[e.to] = d[v]+1;
}
}
vector<pi> TP(n);
rep(i,n) TP[i]=pi(-d[i],i);
sort(all(TP));
rep(i,n)
{
int v = TP[i].se;
priority_queue<int> pq;
for(const auto &e:ch[v])
{
pq.push(cost[e.to]+e.cost);
}
int ct=0;
while(ct<k-1 && !pq.empty())
{
int val = pq.top();
pq.pop();
cost[v] += val;
++ct;
}
}
memset(dp,-1,sizeof(dp));
printf("%lld\n", dfs(0));
return 0;
}
| [
"k0223.teru@gmail.com"
] | k0223.teru@gmail.com |
4d684bc72cd6fbbd50e91281c9bd79b74647de03 | 657c9e7b989e9e374a5e263c8359d63724ca52c6 | /movement.cpp | 6c87583b3e6f961daea409f7241af2635c6bf1a0 | [] | no_license | bzanardo/data-structures-project | 0ac348a5fbf64a877bb16c63b0b152b06542cbd2 | ca803e8d14b0e85cf00a099adeb630b37ac871a4 | refs/heads/master | 2021-01-23T00:35:39.624375 | 2017-05-04T18:36:17 | 2017-05-04T18:36:17 | 85,744,883 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 25,551 | cpp | // movement.cpp
// chess
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include "board.h"
#include "movement.h"
using namespace std;
/*** PAWN MOVEMENT ***/
bool move_pawn(Board b, string &turn, int player) {
int src_row = turn[0]-'0', src_col = turn[1]-'0', dest_row = turn[2]-'0', dest_col = turn[3]-'0';
char c = b.get_piece(src_row, src_col); // Piece to be moved
char d = b.get_piece(dest_row, dest_col);
if (player == 0) { // White piece
if ( (dest_row == src_row - 2) && (src_col == dest_col) ) { // Moving two squares on first move
return (src_row == 6);
}
if ((dest_row == src_row - 1) && (src_col == dest_col)) { // Moving one square forward
if (d != ' ') {
return false;
} else {
return true;
}
}
if ((dest_row == src_row - 1) && (dest_col == (src_col + 1 || src_col - 1))) { // Diagonal capture
if (d == ' ') { // No piece to be captured.
return false;
}
if (islower(d) == 0) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
if (player == 1) { // Black piece
if ( (dest_row == src_row + 2) && (src_col == dest_col) ) { // Moving two squares on first move
return (src_row == 1);
}
if ((dest_row == src_row + 1) && (src_col == dest_col)) { // Moving one square forward
if (d != ' ') {
return false;
} else {
return true;
}
}
if ((dest_row == src_row + 1) && (dest_col == (src_col + 1 || src_col - 1))) { // Diagonal capture
if (d == ' ') { // No piece to be captured.
return false;
}
if (isupper(d) == 0) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
}
/*** KNIGHT MOVEMENT ***/
bool move_knight(Board b, string &turn, int player) {
int src_row = turn[0]-'0', src_col = turn[1]-'0', dest_row = turn[2]-'0', dest_col = turn[3]-'0';
char c = b.get_piece(src_row, src_col); // Piece to be moved
char d = b.get_piece(dest_row, dest_col);
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false;
}
}
if ( (dest_row = src_row + 1) && (dest_col = src_col + 2) ) {
return true;
}
if ( (dest_row = src_row + 1) && (dest_col = src_col - 2) ) {
return true;
}
if ( (dest_row = src_row + 2) && (dest_col = src_col + 1) ) {
return true;
}
if ( (dest_row = src_row + 2) && (dest_col = src_col - 1) ) {
return true;
}
if ( (dest_row = src_row - 1) && (dest_col = src_col + 2) ) {
return true;
}
if ( (dest_row = src_row - 1) && (dest_col = src_col - 2) ) {
return true;
}
if ( (dest_row = src_row - 2) && (dest_col = src_col - 1) ) {
return true;
}
if ( (dest_row = src_row - 2) && (dest_col = src_col + 1) ) {
return true;
}
return false;
}
/*** ROOK MOVEMENT ***/
bool move_rook(Board b, string &turn, int player) {
int src_row = turn[0]-'0', src_col = turn[1]-'0', dest_row = turn[2]-'0', dest_col = turn[3]-'0';
char c = b.get_piece(src_row, src_col); // Piece to be moved
char d = b.get_piece(dest_row, dest_col);
// Moving vertically forward (i.e row number decreasing)
if ( (src_col == dest_col) && (dest_row < src_row) ) {
char p = b.get_piece(src_row - 1,src_col);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_row - 1); i > dest_row; i--) {
p = b.get_piece(i,src_col);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving vertically backward (i.e row number increasing)
if ( (src_col == dest_col) && (dest_row > src_row) ) {
char p = b.get_piece(src_row + 1,src_col);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_row + 1); i < dest_row; i++) {
p = b.get_piece(i,src_col);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving horizontally, to the right (i.e col number increasing)
if ( (src_row == dest_row) && (dest_col > src_col) ) {
char p = b.get_piece(src_row, src_col + 1);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_col + 1); i < dest_col; i++) {
p = b.get_piece(src_row, i);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving horizontally, to the left (i.e col number decreasing)
if ( (src_row == dest_row) && (dest_col < src_col) ) {
char p = b.get_piece(src_row, src_col - 1);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_col - 1); i > dest_col; i--) {
p = b.get_piece(src_row, i);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
return false;
}
/*** BISHOP MOVEMENT ***/
bool move_bishop(Board b, string &turn, int player) {
int src_row = turn[0]-'0', src_col = turn[1]-'0', dest_row = turn[2]-'0', dest_col = turn[3]-'0';
char c = b.get_piece(src_row, src_col); // Piece to be moved
char d = b.get_piece(dest_row, dest_col);
// Moving diagonally
if ( abs(src_row - dest_row) == abs(src_col - dest_col) ) {
int num = abs (src_row - dest_row);
// Moving down, to the right diagonal
if ( (dest_row - src_row > 0) && (dest_col - src_col > 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row + i, src_col + i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving down, to the left diagonal
if ( (dest_row - src_row > 0) && (dest_col - src_col < 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row + i, src_col - i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving up, to the right diagonal
if ( (dest_row - src_row < 0) && (dest_col - src_col > 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row - i, src_col + i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving up, to the left diagonal
if ( (dest_row - src_row < 0) && (dest_col - src_col < 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row - i, src_col - i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
}
return false;
}
/*** QUEEN MOVEMENT ***/
bool move_queen(Board b, string &turn, int player) {
int src_row = turn[0]-'0', src_col = turn[1]-'0', dest_row = turn[2]-'0', dest_col = turn[3]-'0';
char c = b.get_piece(src_row, src_col); // Piece to be moved
char d = b.get_piece(dest_row, dest_col);
// Moving vertically forward (i.e row number decreasing)
if ( (src_col == dest_col) && (dest_row < src_row) ) {
char p = b.get_piece(src_row - 1,src_col);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_row - 1); i > dest_row; i--) {
p = b.get_piece(i,src_col);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving vertically backward (i.e row number increasing)
if ( (src_col == dest_col) && (dest_row > src_row) ) {
char p = b.get_piece(src_row + 1,src_col);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_row + 1); i < dest_row; i++) {
p = b.get_piece(i,src_col);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving horizontally, to the right (i.e col number increasing)
if ( (src_row == dest_row) && (dest_col > src_col) ) {
char p = b.get_piece(src_row, src_col + 1);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_col + 1); i < dest_col; i++) {
p = b.get_piece(src_row, i);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving horizontally, to the left (i.e col number decreasing)
if ( (src_row == dest_row) && (dest_col < src_col) ) {
char p = b.get_piece(src_row, src_col - 1);
if ( (p != ' ') && (p != d) ) {
return false;
}
for (int i = (src_col - 1); i > dest_col; i--) {
p = b.get_piece(src_row, i);
if (p != ' ') { // Path is blocked by a piece.
return false;
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving diagonally
if ( abs(src_row - dest_row) == abs(src_col - dest_col) ) {
int num = abs (src_row - dest_row);
// Moving down, to the right diagonal
if ( (dest_row - src_row > 0) && (dest_col - src_col > 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row + i, src_col + i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving down, to the left diagonal
if ( (dest_row - src_row > 0) && (dest_col - src_col < 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row + i, src_col - i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving up, to the right diagonal
if ( (dest_row - src_row < 0) && (dest_col - src_col > 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row - i, src_col + i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving up, to the left diagonal
if ( (dest_row - src_row < 0) && (dest_col - src_col < 0) ) {
for (int i = 1; i < num; i++) {
char p = b.get_piece(src_row - i, src_col - i);
if (p != ' ') {
return false; // Path is blocked by a piece.
}
}
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
}
return false;
}
/*** KING MOVEMENT ***/
bool move_king(Board b, string &turn, int player) {
int src_row = turn[0]-'0', src_col = turn[1]-'0', dest_row = turn[2]-'0', dest_col = turn[3]-'0';
char c = b.get_piece(src_row, src_col); // Piece to be moved
char d = b.get_piece(dest_row, dest_col);
if ( (src_row == dest_row) && (dest_col == src_col + 1) ) { // Moving one square to the right
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
if ( (src_row == dest_row) && (dest_col == src_col - 1) ) { // Moving one square to the left
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
if ( (dest_row == src_row + 1) && (dest_col == src_col) ) { // Moving one square backwards
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
if ( (dest_row == src_row - 1) && (dest_col == src_col) ) { // Moving one square forward
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Diagonals:
// Moving one square back, to the right diagonal
if ( (dest_row == src_row + 1) && (dest_col == src_col + 1) ) {
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving one square back, to the left diagonal
if ( (dest_row == src_row + 1) && (dest_col == src_col - 1) ) {
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving one square forward, to the right diagonal
if ( (dest_row == src_row - 1) && (dest_col == src_col + 1) ) {
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
// Moving one square forward, to the left diagonal
if ( (dest_row == src_row - 1) && (dest_col == src_col - 1) ) {
if (player == 0) { // White player.
if ( (d != ' ') && (islower(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
if (player == 1) { // Black player.
if ( (d != ' ') && (isupper(d) == 0) ) {
return false; // Trying to capture a piece of the same color.
} else {
return true;
}
}
}
return false;
}
| [
"tfay@nd.edu"
] | tfay@nd.edu |
12273f522f24f9d09a20a93b13571cdbc3785998 | 752d9e4c3284870ecf2272a6ad065b4b382e89f7 | /include/settings.h | c0e783e9cd65d54d5106f75e6fe5a216f02fadee | [] | no_license | matheushs/text-compressor | 3a75a4cd84d4b8f27b15f4f644c693364df9fffe | 4fb69d868be5bf9f4d927710b7271022bd31f458 | refs/heads/master | 2021-01-17T09:53:26.213711 | 2016-07-01T00:55:29 | 2016-07-01T00:55:29 | 58,429,131 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 584 | h | #pragma once
#include <iostream>
#include <fstream>
#include <cstdlib>
#define GETBIT(data, index) ((bool)((data & (1 << index)) >> index))
/*
Configuracao de execucao
*/
struct Settings
{
// Controles
bool bwt = false;
bool huffman = false;
bool runLength = false;
// Tamanho de bloco
uint32_t textBlockSize = 0;
//Offset binario
unsigned char offset = 7;
// Nomes dos arquivos de input e output
std::string inputFilename;
std::string outputFilename;
// Ponteiros para os arquivos
std::ifstream* input;
std::ofstream* output;
std::fstream* auxiliar = nullptr;
}; | [
"gustavofceccon@live.com"
] | gustavofceccon@live.com |
417892fd133359beb604be87eda8feaddc7dd2cf | decfb47c9755924b5bfc28e2c54e616307ea3529 | /G42 Libraries/API 2.0/Include/g42macfl.h | 322b6c18a9c774270a0125fec7836165b6d5a2c3 | [] | no_license | dtison/graphics_lib | 860fcb7bfc98f1b8f686db5711d240980f9a7c29 | 5826a75dbc0cc9b4f659c2885c0b8f11f275f785 | refs/heads/master | 2021-01-10T12:23:29.211100 | 2017-03-20T02:35:12 | 2017-03-20T02:35:12 | 8,441,582 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 800 | h | // mac only stuff
#include "g42type.h"
#include "g42image.h"
#include "g42iview.h"
//#include "g42sview.h"
#ifdef MACOS
#if ! defined (G42MACFL_H)
#define G42MACFL_H
#include <Files.h>
class G42MacFile
{
public:
static void CopyComponent(char *& path, const unsigned char * component, Boolean colon);
static char *GetFullPath (Str63 name, long parID, short vRefNum);
static CInfoPBRec lastInfo;
/* Also stick the GWorld <-> G42Image things here for now */
static GWorldPtr GWorldFromG42Image (G42Image *image,
G42SimpleImageViewer *viewer, long flags = nil);
static PicHandle PICTFromG42Image (G42Image *image,
G42SimpleImageViewer *viewer, Boolean useSpecial = false);
/* Stuff I don't know where else to put */
static void Msg (Str255 msg);
};
#endif // G42MACFL_H
#endif // MACOS | [
"developer@dtison.net"
] | developer@dtison.net |
81e3b5646c883e7fb1ed95abbca14d45d4063a5a | dca653bb975528bd1b8ab2547f6ef4f48e15b7b7 | /tags/wxPy-2.8.6.0/src/mac/classic/radiobut.cpp | f58db33087810bec283f0371664aa71c88a0ee09 | [] | no_license | czxxjtu/wxPython-1 | 51ca2f62ff6c01722e50742d1813f4be378c0517 | 6a7473c258ea4105f44e31d140ea5c0ae6bc46d8 | refs/heads/master | 2021-01-15T12:09:59.328778 | 2015-01-05T20:55:10 | 2015-01-05T20:55:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,966 | cpp | /////////////////////////////////////////////////////////////////////////////
// Name: src/mac/classic/radiobut.cpp
// Purpose: wxRadioButton
// Author: AUTHOR
// Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox
// Created: ??/??/98
// RCS-ID: $Id$
// Copyright: (c) AUTHOR
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#include "wx/radiobut.h"
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
#include "wx/mac/uma.h"
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
return false;
Rect bounds ;
Str255 title ;
MacPreControlCreate( parent , id , label , pos , size ,style, validator , name , &bounds , title ) ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1,
kControlRadioButtonProc , (long) this ) ;
MacPostControlCreate() ;
m_cycle = this ;
if (HasFlag(wxRB_GROUP))
{
AddInCycle( NULL ) ;
}
else
{
/* search backward for last group start */
wxRadioButton *chief = (wxRadioButton*) NULL;
wxWindowList::Node *node = parent->GetChildren().GetLast();
while (node)
{
wxWindow *child = node->GetData();
if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) )
{
chief = (wxRadioButton*) child;
if (child->HasFlag(wxRB_GROUP)) break;
}
node = node->GetPrevious();
}
AddInCycle( chief ) ;
}
return true;
}
void wxRadioButton::SetValue(bool val)
{
wxRadioButton *cycle;
if ( GetControl32BitValue( (ControlHandle) m_macControl ) == val )
return ;
::SetControl32BitValue( (ControlHandle) m_macControl , val ) ;
if (val)
{
cycle=this->NextInCycle();
if (cycle!=NULL) {
while (cycle!=this) {
cycle->SetValue(false);
cycle=cycle->NextInCycle();
}
}
}
MacRedrawControl() ;
}
bool wxRadioButton::GetValue() const
{
return ::GetControl32BitValue( (ControlHandle) m_macControl ) ;
}
void wxRadioButton::Command (wxCommandEvent & event)
{
SetValue ( (event.GetInt() != 0) );
ProcessCommand (event);
}
void wxRadioButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
{
if ( GetValue() )
return ;
wxRadioButton *cycle, *old = NULL ;
cycle=this->NextInCycle();
if (cycle!=NULL) {
while (cycle!=this) {
if ( cycle->GetValue() ) {
old = cycle ;
cycle->SetValue(false);
}
cycle=cycle->NextInCycle();
}
}
SetValue(true) ;
if ( old ) {
wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, old->m_windowId );
event.SetEventObject(old);
event.SetInt( false );
old->ProcessCommand(event);
}
wxCommandEvent event2(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
event2.SetEventObject(this);
event2.SetInt( true );
ProcessCommand(event2);
}
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
{
wxRadioButton *next,*current;
if (cycle==NULL) {
m_cycle=this;
return(this);
}
else {
current=cycle;
while ((next=current->m_cycle)!=cycle)
current=current->m_cycle;
m_cycle=cycle;
current->m_cycle=this;
return(cycle);
}
}
| [
"RD@c3d73ce0-8a6f-49c7-b76d-6d57e0e08775"
] | RD@c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 |
4c78c39365e1ac7b03b01f22fcfbf32e664eb51e | cf1db2c8fb02d4f6f971863f3f0b1bf70766bfcc | /src/pocketpc/pocketpc_armyinfo.cpp | a33d27f762be17a71f99224d007d1d90e687b51d | [] | no_license | retrofw/fheroes2 | 4506c8a0421f955592e5000a74885291a832eb94 | 4d6fea34683d576f899823d87bec6ef83fc0809c | refs/heads/master | 2020-05-26T04:06:04.774339 | 2019-12-08T04:30:56 | 2019-12-08T04:30:56 | 188,100,929 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,151 | cpp | /***************************************************************************
* Copyright (C) 2009 by Andrey Afletdinov <fheroes2@gmail.com> *
* *
* Part of the Free Heroes2 Engine: *
* http://sourceforge.net/projects/fheroes2 *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "agg.h"
#include "cursor.h"
#include "settings.h"
#include "text.h"
#include "button.h"
#include "army.h"
#include "selectarmybar.h"
#include "army.h"
#include "battle_stats.h"
#include "pocketpc.h"
void DrawMonsterStats(const Point &, const Army::Troop &);
void DrawBattleStats(const Point &, const Battle2::Stats &);
Dialog::answer_t PocketPC::DialogArmyInfo(const Army::Troop & troop, u16 flags)
{
Cursor & cursor = Cursor::Get();
Display & display = Display::Get();
LocalEvent & le = LocalEvent::Get();
cursor.Hide();
cursor.SetThemes(cursor.POINTER);
const u16 window_w = 320;
const u16 window_h = 224;
Dialog::FrameBorder frameborder;
frameborder.SetPosition((display.w() - window_w) / 2 - BORDERWIDTH, (display.h() - window_h) / 2 - BORDERWIDTH, window_w, window_h);
frameborder.Redraw();
const Monster & mons = troop;
const Battle2::Stats* battle = troop.GetBattleStats();
const Rect & dst_rt = frameborder.GetArea();
const Sprite & background = AGG::GetICN(ICN::STONEBAK, 0);
display.Blit(background, Rect(0, 0, window_w, window_h), dst_rt);
// name
Text text;
text.Set(mons.GetName(), Font::BIG);
text.Blit(dst_rt.x + (dst_rt.w - text.w()) / 2, dst_rt.y + 10);
const Sprite & frame = AGG::GetICN(troop.ICNMonh(), 0);
display.Blit(frame, dst_rt.x + 50 - frame.w() / 2, dst_rt.y + 145 - frame.h());
std::string message;
String::AddInt(message, (battle ? battle->GetCount() : troop.GetCount()));
text.Set(message);
text.Blit(dst_rt.x + 50 - text.w() / 2, dst_rt.y + 150);
// stats
DrawMonsterStats(Point(dst_rt.x + 200, dst_rt.y + 40), troop);
if(battle)
DrawBattleStats(Point(dst_rt.x + 160, dst_rt.y + 160), *battle);
Button buttonDismiss(dst_rt.x + dst_rt.w / 2 - 160, dst_rt.y + dst_rt.h - 30, ICN::VIEWARMY, 1, 2);
Button buttonUpgrade(dst_rt.x + dst_rt.w / 2 - 60, dst_rt.y + dst_rt.h - 30, ICN::VIEWARMY, 5, 6);
Button buttonExit(dst_rt.x + dst_rt.w / 2 + 60, dst_rt.y + dst_rt.h - 30, ICN::VIEWARMY, 3, 4);
if(Dialog::READONLY & flags)
{
buttonDismiss.Press();
buttonDismiss.SetDisable(true);
}
if(!(Dialog::BATTLE & flags) && mons.isAllowUpgrade())
{
if(Dialog::UPGRADE & flags)
{
buttonUpgrade.SetDisable(false);
buttonUpgrade.Draw();
}
else if(Dialog::READONLY & flags)
{
buttonUpgrade.Press();
buttonUpgrade.SetDisable(true);
buttonUpgrade.Draw();
}
else buttonUpgrade.SetDisable(true);
}
else buttonUpgrade.SetDisable(true);
if(!(Dialog::BATTLE & flags))
{
buttonDismiss.Draw();
buttonExit.Draw();
}
cursor.Show();
display.Flip();
while(le.HandleEvents())
{
if(buttonUpgrade.isEnable()) le.MousePressLeft(buttonUpgrade) ? (buttonUpgrade).PressDraw() : (buttonUpgrade).ReleaseDraw();
if(buttonDismiss.isEnable()) le.MousePressLeft(buttonDismiss) ? (buttonDismiss).PressDraw() : (buttonDismiss).ReleaseDraw();
le.MousePressLeft(buttonExit) ? (buttonExit).PressDraw() : (buttonExit).ReleaseDraw();
if(buttonUpgrade.isEnable() && le.MouseClickLeft(buttonUpgrade)) return Dialog::UPGRADE;
else
if(buttonDismiss.isEnable() && le.MouseClickLeft(buttonDismiss)) return Dialog::DISMISS;
else
if(le.MouseClickLeft(buttonExit) || le.KeyPress(KEY_ESCAPE)) return Dialog::CANCEL;
}
return Dialog::ZERO;
}
| [
"pingflood@gmail.com"
] | pingflood@gmail.com |
46a09696524b2ebf9007077eaeae88e26b99156d | b63ffe89295fdc5f8173266b7e83b8f588ef53de | /05_led-programming-using-object-oriented (CPP) -inheritance/PowerLed.h | b0ecee34c1921e38ce6a4fb35c05c05e0b727c94 | [] | no_license | Suraj-Embedd-Os/embedded_system_programming_using_object_oriented_firmware | d0ac9857d6a6ba06734b9b2d3b168d64d78dc85d | 3244e6a61ba48940129766e9c1f129c5f21cfe69 | refs/heads/main | 2023-02-27T07:12:10.246791 | 2021-02-06T09:52:21 | 2021-02-06T09:52:21 | 334,325,848 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,005 | h | #ifndef _POWERLED_H
#define _POWERLED_H
#include "led.h"
typedef uint8_t led_elec_type;
typedef uint8_t led_dim_type;
typedef enum{
CURR_LOW =10,
CURR_NORMAL =20,
CURR_HIGH =40,
CURR_VERY_HIGH=60
}LedCurrent_Type;
typedef enum{
DIAM_2MM =2,
DIAM_4MM =4,
DIAM_7MM =7
}LedDimeter_Type;
typedef enum{
VOL_LOW =3,
VOL_NORMAL =5,
VOL_HIGH =9
}LedVoltage_Type;
class PowerLed : public Led{
private:
LedCurrent_Type current;
LedDimeter_Type diameter;
LedVoltage_Type voltage;
public:
PowerLed( LedColor_Type _color,
LedState_Type _state,
LedDimeter_Type _diameter,
LedCurrent_Type _current,
LedVoltage_Type _voltage);
void PowerLed_setCurrent(LedCurrent_Type _current);
void PowerLed_setVoltage(LedVoltage_Type _voltage);
void PowerLed_setDiameter(LedDimeter_Type _diameter);
led_elec_type PowerLed_ComputePower();
led_elec_type PowerLed_getCurrent();
led_elec_type PowerLed_getVoltage();
led_elec_type PowerLed_getDiameter();
};
#endif
| [
"iyengar.jahnavi@gmail.com"
] | iyengar.jahnavi@gmail.com |
685d1ae9a4c96290649155d562fc535210d466f0 | c8a8b1b2739ff50c3565cdc1497e6abf4492b3dd | /src/csapex_core/src/model/observer.cpp | a5b99f134ddee8db6dfe5b0bc2d4c114a212eb0f | [] | permissive | betwo/csapex | 645eadced88e65d6e78aae4049a2cda5f0d54b4b | dd8e24f14cdeef59bedb8f974ebdc0b0c656ab4c | refs/heads/master | 2022-06-13T06:15:10.306698 | 2022-06-01T08:50:51 | 2022-06-01T09:03:05 | 73,413,991 | 0 | 0 | BSD-3-Clause | 2020-01-02T14:01:01 | 2016-11-10T19:26:29 | C++ | UTF-8 | C++ | false | false | 445 | cpp | /// HEADER
#include <csapex/model/observer.h>
using namespace csapex;
Observer::~Observer()
{
}
void Observer::stopObserving()
{
observed_connections_.clear();
}
void Observer::manageConnection(slim_signal::ScopedConnection&& connection)
{
observed_connections_.emplace_back(std::move(connection));
}
void Observer::manageConnection(const slim_signal::Connection& connection)
{
observed_connections_.emplace_back(connection);
}
| [
"sebastian.buck@uni-tuebingen.de"
] | sebastian.buck@uni-tuebingen.de |
35e3caa8053238b71ab6523f958ef46312109026 | 4793d48171b6a042b8b8b384a06060deafc65a18 | /burn/capcom/dc_forgottn.cpp | 3034b25446f4fb21a878d872b23c6e05eaa801e8 | [] | no_license | squidrpi/pifba | 556ee9dc1169d3b3ee6c36d50753027d69632a3a | 9d3dd8476750adf29253c8922841b87ff36b930b | refs/heads/master | 2021-01-23T03:33:28.496022 | 2018-09-12T08:59:50 | 2018-09-12T08:59:50 | 86,088,358 | 9 | 7 | null | 2017-04-09T13:50:34 | 2017-03-24T16:24:37 | C++ | UTF-8 | C++ | false | false | 11,083 | cpp | // Forgotten Worlds
#include "cps.h"
#define A(a, b, c, d) {a, b, (unsigned char*)(c), d}
static struct BurnInputInfo DrvInputList[] =
{
{"P1 Coin" , BIT_DIGITAL, CpsInp018+0, "p1 coin"},
{"P1 Start" , BIT_DIGITAL, CpsInp018+4, "p1 start"},
{"P1 Up" , BIT_DIGITAL, CpsInp001+3, "p1 up"},
{"P1 Down" , BIT_DIGITAL, CpsInp001+2, "p1 down"},
{"P1 Left" , BIT_DIGITAL, CpsInp001+1, "p1 left"},
{"P1 Right" , BIT_DIGITAL, CpsInp001+0, "p1 right"},
{"P1 Attack" , BIT_DIGITAL, CpsInp001+4, "p1 fire 1"},
A("P1 Turn" , BIT_ANALOG_REL, &CpsInp055, "p1 z-axis"),
{"P2 Coin" , BIT_DIGITAL, CpsInp018+1, "p2 coin"},
{"P2 Start" , BIT_DIGITAL, CpsInp018+5, "p2 start"},
{"P2 Up" , BIT_DIGITAL, CpsInp000+3, "p2 up"},
{"P2 Down" , BIT_DIGITAL, CpsInp000+2, "p2 down"},
{"P2 Left" , BIT_DIGITAL, CpsInp000+1, "p2 left"},
{"P2 Right" , BIT_DIGITAL, CpsInp000+0, "p2 right"},
{"P2 Attack" , BIT_DIGITAL, CpsInp000+4, "p2 fire 1"},
A("P2 Turn" , BIT_ANALOG_REL, &CpsInp05d, "p2 z-axis"),
{"Reset" , BIT_DIGITAL, &CpsReset, "reset"},
{"Diagnostic" , BIT_DIGITAL, CpsInp018+6, "diag"},
{"Service" , BIT_DIGITAL, CpsInp018+2, "service"},
{"Dip A" , BIT_DIPSWITCH, &Cpi01A , "dip" },
{"Dip B" , BIT_DIPSWITCH, &Cpi01C , "dip" },
{"Dip C" , BIT_DIPSWITCH, &Cpi01E , "dip" },
};
#undef A
STDINPUTINFO(Drv);
static struct BurnDIPInfo forgottnDIPList[]=
{
// Defaults
{0x19, 0xff, 0xff, 0x00, NULL },
{0x1a, 0xff, 0xff, 0x00, NULL },
{0x1b, 0xff, 0xff, 0x00, NULL },
// Dip A
{0 , 0xfe, 0 , 8 , "Coin 1" },
{0x19, 0x01, 0x07, 0x07, "4 Coins 1 Credit" },
{0x19, 0x01, 0x07, 0x06, "3 Coins 1 Credit" },
{0x19, 0x01, 0x07, 0x05, "2 Coins 1 Credit" },
{0x19, 0x01, 0x07, 0x00, "1 Coin 1 Credit" },
{0x19, 0x01, 0x07, 0x01, "1 Coin 2 Credits" },
{0x19, 0x01, 0x07, 0x02, "1 Coin 3 Credits" },
{0x19, 0x01, 0x07, 0x03, "1 Coin 4 Credits" },
{0x19, 0x01, 0x07, 0x04, "1 Coin 6 Credits" },
{0 , 0xfe, 0 , 8 , "Coin 2" },
{0x19, 0x01, 0x38, 0x38, "4 Coins 1 Credit" },
{0x19, 0x01, 0x38, 0x30, "3 Coins 1 Credit" },
{0x19, 0x01, 0x38, 0x28, "2 Coins 1 Credit" },
{0x19, 0x01, 0x38, 0x00, "1 Coin 1 Credit" },
{0x19, 0x01, 0x38, 0x08, "1 Coin 2 Credits" },
{0x19, 0x01, 0x38, 0x10, "1 Coin 3 Credits" },
{0x19, 0x01, 0x38, 0x18, "1 Coin 4 Credits" },
{0x19, 0x01, 0x38, 0x20, "1 Coin 6 Credits" },
{0 , 0xfe, 0 , 2 , "Demo Sound" },
{0x19, 0x01, 0x40, 0x00, "Off" },
{0x19, 0x01, 0x40, 0x40, "On" },
{0 , 0xfe, 0 , 2 , "Flip" },
{0x19, 0x01, 0x80, 0x00, "Off" },
{0x19, 0x01, 0x80, 0x80, "On" },
// Dip B
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1a, 0x01, 0x01, 0x00, "Off" },
// {0x1a, 0x01, 0x01, 0x01, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1a, 0x01, 0x02, 0x00, "Off" },
// {0x1a, 0x01, 0x02, 0x02, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1a, 0x01, 0x04, 0x00, "Off" },
// {0x1a, 0x01, 0x04, 0x04, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1a, 0x01, 0x08, 0x00, "Off" },
// {0x1a, 0x01, 0x08, 0x08, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1a, 0x01, 0x10, 0x00, "Off" },
// {0x1a, 0x01, 0x10, 0x10, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1a, 0x01, 0x20, 0x00, "Off" },
// {0x1a, 0x01, 0x20, 0x20, "On" },
{0 , 0xfe, 0 , 2 , "Service Mode" },
{0x1a, 0x01, 0x40, 0x00, "Off" },
{0x1a, 0x01, 0x40, 0x40, "On" },
{0 , 0xfe, 0 , 2 , "Freeze" },
{0x1a, 0x01, 0x80, 0x00, "Off" },
{0x1a, 0x01, 0x80, 0x80, "On" },
// Dip C
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x01, 0x00, "Off" },
// {0x1b, 0x01, 0x01, 0x01, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x02, 0x00, "Off" },
// {0x1b, 0x01, 0x02, 0x02, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x04, 0x00, "Off" },
// {0x1b, 0x01, 0x04, 0x04, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x08, 0x00, "Off" },
// {0x1b, 0x01, 0x08, 0x08, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x10, 0x00, "Off" },
// {0x1b, 0x01, 0x10, 0x10, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x20, 0x00, "Off" },
// {0x1b, 0x01, 0x20, 0x20, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x40, 0x00, "Off" },
// {0x1b, 0x01, 0x40, 0x40, "On" },
// {0 , 0xfe, 0 , 2 , "Unknown" },
// {0x1b, 0x01, 0x80, 0x00, "Off" },
// {0x1b, 0x01, 0x80, 0x80, "On" },
};
STDDIPINFO(forgottn);
static int DrvInit()
{
int nRet=0;
Cps=1; Forgottn=1;
nCpsRomLen= 0x100000;
nCpsCodeLen=0; // not encrypted
nCpsGfxLen =8*0x080000 + 0x2000;
nCpsZRomLen= 0x010000;
nCpsAdLen =2*0x020000;
nRet=CpsInit(); if (nRet!=0) return 1;
CpsStar = CpsGfx + 8*0x080000;
nRet=BurnLoadRom(CpsRom+0x000001,0,2); if (nRet!=0) return 1;
nRet=BurnLoadRom(CpsRom+0x000000,1,2); if (nRet!=0) return 1;
nRet=BurnLoadRom(CpsRom+0x040001,2,2); if (nRet!=0) return 1;
nRet=BurnLoadRom(CpsRom+0x040000,3,2); if (nRet!=0) return 1;
nRet=BurnLoadRom(CpsRom+0x080000,4,1); if (nRet!=0) return 1;
// Load graphics roms
CpsLoadTiles(CpsGfx ,5);
CpsLoadTiles(CpsGfx+0x200000,9);
// Enable starfield layers
CpsLayEn[4]=0x30;
CpsLayEn[5]=0x30;
CpsLoadStars(CpsStar, 5);
MaskAddr[0]=0x68;
MaskAddr[1]=0x6a;
MaskAddr[2]=0x6c;
MaskAddr[3]=0x6e;
nRet=BurnLoadRom(CpsZRom,13,1); //changed to 13
nRet=BurnLoadRom(CpsAd ,14,1); //changed to 14
nRet=BurnLoadRom(CpsAd+0x20000,15,1); //changed to 15
nRet=CpsRunInit();
if (nRet!=0) return 1;
return 0;
}
static int DrvExit()
{
CpsRunExit();
CpsExit();
nCpsAdLen=0; nCpsZRomLen=0; nCpsGfxLen=0; nCpsRomLen=0;
Cps=0; Forgottn=0;
return 0;
}
//======================
//Forgotten Worlds (USA)
//======================
// Count possible zip names and (if pszName!=NULL) return them
// Rom information
static struct BurnRomInfo ForgottnRomDesc[] = {
{ "lwu11a", 0x20000, 0xddf78831, BRF_ESS | BRF_PRG }, // 0 even 68000 code
{ "lwu15a", 0x20000, 0xf7ce2097, BRF_ESS | BRF_PRG }, // 1 odd
{ "lwu10a", 0x20000, 0x8cb38c81, BRF_ESS | BRF_PRG }, // 2 even
{ "lwu14a", 0x20000, 0xd70ef9fd, BRF_ESS | BRF_PRG }, // 3 odd
{ "lw-07", 0x80000, 0xfd252a26, BRF_ESS | BRF_PRG }, // 4 both
// graphics:
{ "lw-02", 0x80000, 0x43e6c5c8, BRF_GRA }, // 5
{ "lw-09", 0x80000, 0x899cb4ad, BRF_GRA },
{ "lw-06", 0x80000, 0x5b9edffc, BRF_GRA },
{ "lw-13", 0x80000, 0x8e058ef5, BRF_GRA },
{ "lw-01", 0x80000, 0x0318f298, BRF_GRA }, // 9
{ "lw-08", 0x80000, 0x25a8e43c, BRF_GRA },
{ "lw-05", 0x80000, 0xe4552fd7, BRF_GRA },
{ "lw-12", 0x80000, 0x8e6a832b, BRF_GRA },
// z80 rom
{ "lwu00", 0x10000, 0x59df2a63, BRF_GRA }, // 13
// samples
{ "lw-03u", 0x20000, 0x807d051f, BRF_GRA },
{ "lw-04u", 0x20000, 0xe6cd098e, BRF_GRA },
{ "pal16l8.4a", 260, 0x00000000, BRF_NODUMP },
{ "pal16l8.9j", 260, 0x00000000, BRF_NODUMP },
{ "pal16l8.10f", 260, 0x00000000, BRF_NODUMP },
{ "pal16l8.13j", 260, 0x00000000, BRF_NODUMP },
{ "pal16l8.14j", 260, 0x00000000, BRF_NODUMP },
{ "epl16p8.15e", 263, 0x00000000, BRF_NODUMP },
{ "epl16p8.3a", 263, 0x00000000, BRF_NODUMP },
};
// Make The RomInfo/Name functions for the game
STD_ROM_PICK(Forgottn) STD_ROM_FN(Forgottn)
struct BurnDriver BurnDrvCpsForgottn = {
"forgottn", NULL, NULL, "1988",
"Forgotten Worlds (US)\0", NULL, "Capcom", "CPS1",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING,2,HARDWARE_CAPCOM_CPS1_GENERIC,
NULL,ForgottnRomInfo,ForgottnRomName,DrvInputInfo, forgottnDIPInfo,
DrvInit,DrvExit,Cps1Frame,CpsRedraw,CpsAreaScan,
&CpsRecalcPal,384,224,4,3
};
//===================
//Lost Worlds (Japan)
//===================
// Count possible zip names and (if pszName!=NULL) return them
// Rom information
static struct BurnRomInfo LostwrldRomDesc[] = {
{ "lw-11c.14f", 0x20000, 0x67e42546, BRF_ESS | BRF_PRG }, // 0 even 68000 code
{ "lw-15c.14g", 0x20000, 0x402e2a46, BRF_ESS | BRF_PRG }, // 1 odd
{ "lw-10c.13f", 0x20000, 0xc46479d7, BRF_ESS | BRF_PRG }, // 2 even
{ "lw-14c.13g", 0x20000, 0x97670f4a, BRF_ESS | BRF_PRG }, // 3 odd
{ "lw-07", 0x80000, 0xfd252a26, BRF_ESS | BRF_PRG }, // 4 both
// graphics:
{ "lw-02", 0x80000, 0x43e6c5c8, BRF_GRA }, // 5
{ "lw-09", 0x80000, 0x899cb4ad, BRF_GRA },
{ "lw-06", 0x80000, 0x5b9edffc, BRF_GRA },
{ "lw-13", 0x80000, 0x8e058ef5, BRF_GRA },
{ "lw-01", 0x80000, 0x0318f298, BRF_GRA }, // 9
{ "lw-08", 0x80000, 0x25a8e43c, BRF_GRA },
{ "lw-05", 0x80000, 0xe4552fd7, BRF_GRA },
{ "lw-12", 0x80000, 0x8e6a832b, BRF_GRA },
// z80 rom
{ "lwu00", 0x10000, 0x59df2a63, BRF_GRA }, // 13
// samples
{ "lw-03.14c", 0x20000, 0xce2159e7, BRF_GRA },
{ "lw-04.13c", 0x20000, 0x39305536, BRF_GRA },
};
// Make The RomInfo/Name functions for the game
STD_ROM_PICK(Lostwrld) STD_ROM_FN(Lostwrld)
struct BurnDriver BurnDrvCpsLostwrld = {
"lostwrld", "forgottn", NULL, "1988",
"Lost Worlds (Japan)\0", NULL, "Capcom", "CPS1",
NULL, NULL, NULL, NULL,
BDF_GAME_WORKING | BDF_CLONE,2,HARDWARE_CAPCOM_CPS1_GENERIC,
NULL,LostwrldRomInfo,LostwrldRomName,DrvInputInfo, forgottnDIPInfo,
DrvInit,DrvExit,Cps1Frame,CpsRedraw,CpsAreaScan,
&CpsRecalcPal,384,224,4,3
};
| [
"squidrpi@users.noreply.github.com"
] | squidrpi@users.noreply.github.com |
0207348f8bcc200bc213693f436620cc3e3bb3ec | c0f8da08db56be070854a6d75c83ecba7795d00a | /src/build-snmp_pro-Desktop_Qt_5_4_0_GCC_64bit-Debug/moc_BasicGraph.cpp | c6477b733ab3e32f5bb7a17e018550ad7fe307f3 | [] | no_license | fulongleo/snmp_monitor | bd2f24114b67f98e382f6d403572284dfc00113e | ea7d43b8325cac17e7b2b4d0f93a25824fe189d5 | refs/heads/master | 2020-08-29T06:21:33.345455 | 2018-12-19T18:22:14 | 2018-12-19T18:22:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,630 | cpp | /****************************************************************************
** Meta object code from reading C++ file 'BasicGraph.h'
**
** Created by: The Qt Meta Object Compiler version 67 (Qt 5.4.0)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../snmp_pro/PortFrame/BasicGraph.h"
#include <QtCore/qbytearray.h>
#include <QtCore/qmetatype.h>
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'BasicGraph.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 67
#error "This file was generated using the moc from 5.4.0. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
struct qt_meta_stringdata_BasicGraph_t {
QByteArrayData data[1];
char stringdata[11];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
qptrdiff(offsetof(qt_meta_stringdata_BasicGraph_t, stringdata) + ofs \
- idx * sizeof(QByteArrayData)) \
)
static const qt_meta_stringdata_BasicGraph_t qt_meta_stringdata_BasicGraph = {
{
QT_MOC_LITERAL(0, 0, 10) // "BasicGraph"
},
"BasicGraph"
};
#undef QT_MOC_LITERAL
static const uint qt_meta_data_BasicGraph[] = {
// content:
7, // revision
0, // classname
0, 0, // classinfo
0, 0, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
0 // eod
};
void BasicGraph::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
Q_UNUSED(_o);
Q_UNUSED(_id);
Q_UNUSED(_c);
Q_UNUSED(_a);
}
const QMetaObject BasicGraph::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_BasicGraph.data,
qt_meta_data_BasicGraph, qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};
const QMetaObject *BasicGraph::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}
void *BasicGraph::qt_metacast(const char *_clname)
{
if (!_clname) return Q_NULLPTR;
if (!strcmp(_clname, qt_meta_stringdata_BasicGraph.stringdata))
return static_cast<void*>(const_cast< BasicGraph*>(this));
return QWidget::qt_metacast(_clname);
}
int BasicGraph::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
return _id;
}
QT_END_MOC_NAMESPACE
| [
"359987082@qq.com"
] | 359987082@qq.com |
e865e97e4119af90eb98a270c5e6b7e9a2cacc5f | be20e0ac642304e7df959a4a18037e21ee79c61e | /svm_hog/svm_hog/test.cpp | e3819fc8e862950ae6f1e89a03c99522e586e014 | [] | no_license | kevin0525/multirobot_detect_windows | 000b5a5ddab2fca7e49c8056221b18e6961501af | fc1ffefdf4d6986e02f600c81c7539636afef396 | refs/heads/master | 2020-03-21T20:02:21.468764 | 2018-07-01T09:01:06 | 2018-07-01T09:01:06 | 138,983,227 | 0 | 0 | null | 2018-06-28T07:35:56 | 2018-06-28T07:35:56 | null | GB18030 | C++ | false | false | 512 | cpp | //#include <iostream>
//#include <fstream>
//#include <strstream>
//#include <opencv2/core/core.hpp>
//#include <opencv2/highgui/highgui.hpp>
//#include <opencv2/imgproc/imgproc.hpp>
//#include <opencv2/objdetect/objdetect.hpp>
//#include <opencv2/ml/ml.hpp>
//#include "someMethod.h"
//#include "parameter.h"
//
//using namespace std;
//using namespace cv;
//int main()
//{
// const char * sd1 = {"md " ResultVideoFile_1};//创建存放检测框图的文件夹
// system(sd1);
// return 0;
//} | [
"759424614@qq.com"
] | 759424614@qq.com |
82146bd267e552fece00dbfc2a930fcfd5d3d544 | 43a5e606e0531b22fa418039a8490c18fb44bd06 | /Ex.6/pe0605.cpp | 6274c12c7127aeb6e1812ec85d4a30175801ec66 | [] | no_license | l1zp/CppPrimerPlus | 2d1fec6cd9b51101b1382ef0c9ec10d0d8c28a57 | 45ce9d20377d368cd95b431934ff34376bc35326 | refs/heads/master | 2023-02-21T16:08:34.727612 | 2021-01-26T15:48:29 | 2021-01-26T15:48:29 | 275,595,015 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 635 | cpp | #include <iostream>
int main()
{
using namespace std;
double tvarps;
double tax;
cout << "Please enter the number of tvarps you earned this year." << endl
<< "Enter a negative number to quit: ";
while (cin >> tvarps and tvarps >= 0)
{
if (tvarps <= 5000)
tax = 0;
else if (tvarps <= 15000)
tax = (tvarps - 5000) * 0.1;
else if (tvarps <= 35000)
tax = 10000 * 0.1 + (tvarps - 15000) * 0.15;
else
tax = 10000 * 0.1 + 20000 * 0.15 + (tvarps - 35000) * 0.2;
cout << "You owe " << tax << " tvarps in taxes" << endl
<< "Enter a new income or a negative number to quit: ";
cin >> tvarps;
}
} | [
"lzpthu@163.com"
] | lzpthu@163.com |
7c4236d84aac5f4fa7c389662116ee2814d700f0 | 9a728b6c31bfd6963712d38b30a6963fd7c531a8 | /OrgXueBang/Classes/XueBangApp/View/Reading/MachineData.h | 990b890b61023f86b6e846d3260582528e4e7c71 | [] | no_license | daxingyou/MRK-OrgXueBang | 5fba171f759ccae2f1e28b4f4364df7d088fe5d2 | 09f10f3fd22c3791d0c9ec84c2042a36a7a8f22d | refs/heads/master | 2021-10-21T20:46:18.280434 | 2019-03-06T09:03:18 | 2019-03-06T09:03:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,443 | h | //
// MachinePageStdafx.h
// ReadingMate
//
// Created by hyp on 18/11/15.
//
//
#ifndef MachineData_hpp
#define MachineData_hpp
//#include "UtilsDefine.h"
#include "stdafx.h"
#include "BaseLoad.h"
//题的类型
typedef enum {
Type_1 = 9, //练习题一
Type_2 = 10,//练习题二
Type_3 = 11,//练习题三
Type_4 = 12,//练习题四
Type_5 = 13,//练习题五
Type_6 = 14,//练习题六
Type_7 = 15,//练习题七
Type_8 = 16,//练习题八
Type_9 = 17,//练习题九
Type_10 = 18,//练习题十
Type_11 = 19,//练习题十一
Type_12 = 20//等待页面
}QuestionType;
//每道题所包含的信息
struct QuestionInfo
{
MYDEF_GETSETVALUE(string,ID);
MYDEF_GETSETVALUE(string,OptionID);
MYDEF_GETSETVALUE(string,Type);
MYDEF_GETSETVALUE(string,Image);
MYDEF_GETSETVALUE(string,ImageUrl);
MYDEF_GETSETVALUE(string,Audio);
MYDEF_GETSETVALUE(string,GuideAudio);
MYDEF_GETSETVALUE(string,AudioUrl);
MYDEF_GETSETVALUE(string,Intro);
MYDEF_GETSETVALUE(string,Text);
MYDEF_GETSETVALUE(string,XmlUrl);
MYDEF_GETSETVALUE(string,XmlFile);
MYDEF_GETSETVALUE(string,Answer);
MYDEF_GETSETVALUE(string,TitleID);
MYDEF_GETSETVALUE(vector<string>,AnswerList);
MYDEF_GETSETVALUE(vector<string>,AnswerAudioList);
MYDEF_GETSETVALUE(vector<string>,QuestionList);
MYDEF_GETSETVALUE(vector<string>,QuestionAudioList);
~QuestionInfo(){
}
};
/*练习题数据类*/
class MachineData {
public:
/*初始化函数*/
bool init();
/*释放对象*/
void free();
/*数据重置*/
void reset();
public:
/*定义书的ID,课程ID,日期ID,课程名字等*/
MYDEF_GETSETVALUE(string,BookID);
MYDEF_GETSETVALUE(string,OptionID);
MYDEF_GETSETVALUE(string,ClassID);
MYDEF_GETSETVALUE(string,DayID);
MYDEF_GETSETVALUE(string,LessonName);
MYDEF_GETSETVALUE(string,StageId);
/*定义来源 是否是从练习题进来的*/
MYDEF_GETSETVALUE(bool,FromMachine);
/*定义当前使用时间*/
MYDEF_GETSETVALUE(int,CurTime);
/*定义结束的数据*/
MYDEF_GETSETVALUE(stuJson,EndData);
/*得到题库列表*/
vector<QuestionInfo>* getQuestionData();
/*解析服务器返回数据*/
bool receiveQuestionData(stuJson& booksJson);
private:
/*定义题库列表*/
vector<QuestionInfo> m_questions;
};
#endif /* MachineData_hpp */
| [
"autsck@163.com"
] | autsck@163.com |
65561c1c62f688f1c3cb74a90dca3e84e4a108b0 | 42cb7febe9698c1075f42c61eb8c8f40e082f7b9 | /UIRenderingConcepts/UIGraphicsDemo/source/UiDemoApp.cpp | ee3438621190b62fb79b10c318875f99be42f281 | [] | no_license | VulkanWorks/QtVulkanSceneGraphUiRenderingConcepts | fb60006e71a7c1c91a3e0238cfee66f83d19cf73 | 99dc0b744dcd13dd58172b5477d5a728450a1964 | refs/heads/master | 2020-07-03T22:53:30.406434 | 2019-07-27T05:52:34 | 2019-07-27T05:52:34 | 202,078,122 | 1 | 0 | null | 2019-08-13T06:21:58 | 2019-08-13T06:21:58 | null | UTF-8 | C++ | false | false | 12,925 | cpp | #include "UIDemoApp.h"
#include "UIDemo.h"
#include "UiMetalPaintEngine.h"
#include "Circle/Circle.h"
#include "Rectangle/Rect.h"
#include "../common/SceneGraph/Window.h"
#include <QApplication>
int main(int argc, char **argv)
{
QApplication qtApp(argc, argv);
UIDemoApp* app = new UIDemoApp();
app->EnableDepthBuffer(true);
app->EnableWindowResize(true);
app->Initialize();
app->ShowWindow();
qtApp.exec();
delete app;
return 0;
}
UIDemoApp::UIDemoApp()
{
VulkanHelper::GetInstanceLayerExtensionProperties();
}
UIDemoApp::~UIDemoApp()
{
delete m_Scene;
// delete m_ScenePainterEngine;
}
void UIDemoApp::Configure()
{
SetApplicationName("Metal performance test");
SetWindowDimension(1200 , 800);
#ifdef _WIN32
// Add Validation Layers
AddValidationLayer("VK_LAYER_LUNARG_standard_validation");
// Add Vulkan instance extensions
AddInstanceExtension(VK_KHR_SURFACE_EXTENSION_NAME);
AddInstanceExtension(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
AddInstanceExtension(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
#ifdef _WIN64
#else
#endif
#elif __APPLE__
AddInstanceExtension("VK_KHR_surface");
AddInstanceExtension("VK_MVK_macos_surface");
#endif
// // m_SceneVector.push_back(std::make_shared<Scene>(this));
// m_Scene = new Scene(this);//m_SceneVector[0].get();
// m_ScenePainterEngine = new Scene(this);//m_SceneVector[0].get();
// InitMetalEngine();
// //BoundingRegion bgDim(10, 10, 400, 50);
// //Node* background = new Rectangl(p_Scene, this, bgDim);
// //Node* m_Parent = new Rectangl(m_Scene, NULL, BoundingRegion(), "Node 1", (false ? SHAPE::SHAPE_RECTANGLE_MULTIDRAW : SHAPE::SHAPE_RECTANGLE_INSTANCED));
// m_Scene->SetEarlyDepthTest(true);
// Node* m_Parent = new Rectangl(m_Scene, NULL, BoundingRegion(500, 300, 20, 20), "Node 1", SHAPE::SHAPE_RECTANGLE_INSTANCED);
// m_Parent->SetColor(glm::vec4(1.0, 0.0, 1.0, 1.0));
// m_Parent->SetDefaultColor(glm::vec4(1.0, 0.0, 0.0, 1.0));
// m_Parent->SetMemPoolIdx(0);
// m_Parent->SetZOrder(15);
//// Node* m_Parent1 = new Rectangl(m_Scene, NULL, BoundingRegion(150, 150, 200, 200), "Node 2", SHAPE::SHAPE_RECTANGLE_MULTIDRAW);
//// m_Parent1->SetColor(glm::vec4(0.0, 1.0, 0.0, 1.0));
//// m_Parent1->SetDefaultColor(glm::vec4(0.0, 1.0, 0.0, 1.0));
//// m_Parent1->SetMemPoolIdx(0);
//// m_Parent1->SetZOrder(20);
// //m_UIDemo.Grid(m_Scene, m_WindowDimension.x, m_WindowDimension.y); // Grid demo
// //m_UIDemo.SliderFunc(m_Scene); // Slider
// //m_UIDemo.MixerView(m_Scene, m_WindowDimension.x, m_WindowDimension.y); // Mixer View demo
// m_UIDemo.TransformationConformTest(m_Scene); // Transformation test demo
}
void UIDemoApp::Setup()
{
m_Scene = new Scene(this);
m_Scene->SetSceneRect(0, 0, m_Window->width(), m_Window->height());
m_ScenePainterEngine = new Scene(this);
m_ScenePainterEngine->SetSceneRect(0, 0, m_Window->width(), m_Window->height());
InitMetalEngine();
//BoundingRegion bgDim(10, 10, 400, 50);
//Node* background = new Rectangl(p_Scene, this, bgDim);
//Node* m_Parent = new Rectangl(m_Scene, NULL, BoundingRegion(), "Node 1", (false ? SHAPE::SHAPE_RECTANGLE_MULTIDRAW : SHAPE::SHAPE_RECTANGLE_INSTANCED));
m_Scene->SetEarlyDepthTest(true);
Node* m_Parent = new Rectangl(m_Scene, NULL, BoundingRegion(0, 0, 20, 20), "Node 1", SHAPE::SHAPE_RECTANGLE_INSTANCED);
m_Parent->SetColor(glm::vec4(1.0, 0.0, 1.0, 1.0));
m_Parent->SetDefaultColor(glm::vec4(1.0, 0.0, 0.0, 1.0));
m_Parent->SetMemPoolIdx(0);
m_Parent->SetZOrder(15);
// Node* m_Parent1 = new Rectangl(m_Scene, NULL, BoundingRegion(150, 150, 200, 200), "Node 2", SHAPE::SHAPE_RECTANGLE_MULTIDRAW);
// m_Parent1->SetColor(glm::vec4(0.0, 1.0, 0.0, 1.0));
// m_Parent1->SetDefaultColor(glm::vec4(0.0, 1.0, 0.0, 1.0));
// m_Parent1->SetMemPoolIdx(0);
// m_Parent1->SetZOrder(20);
//m_UIDemo.Grid(m_Scene, m_WindowDimension.x, m_WindowDimension.y); // Grid demo
//m_UIDemo.SliderFunc(m_Scene); // Slider
m_UIDemo.MixerView(m_Scene, m_WindowDimension.x, m_WindowDimension.y); // Mixer View demo
//m_UIDemo.TransformationConformTest(m_Scene); // Transformation test demo
m_Scene->Setup();
m_ScenePainterEngine->Setup();
RecordRenderPass(1, SG_STATE_SETUP); // Parminder: Double check if this is required
// At least update the scene once so that in case UpdateMeAndMyChildren() is being used it has all transformation readily available
m_Scene->Update();
m_ScenePainterEngine->Update();
}
void UIDemoApp::Update()
{
m_Scene->Update();
m_ScenePainterEngine->Update();
}
bool UIDemoApp::Render()
{
QRectF rect;
m_MetalPaintEngine->drawRects(&rect, 1);
RecordRenderPass(1, SG_STATE_RENDER);
return VulkanApp::Render();
}
void UIDemoApp::MousePressEvent(QMouseEvent* p_Event)
{
m_Scene->mousePressEvent(p_Event);
}
void UIDemoApp::MouseReleaseEvent(QMouseEvent* p_Event)
{
m_Scene->mouseReleaseEvent(p_Event);
}
void UIDemoApp::MouseMoveEvent(QMouseEvent* p_Event)
{
m_Scene->mouseMoveEvent(p_Event);
}
void UIDemoApp::ResizeWindow(int p_Width, int p_Height)
{
VulkanApp::ResizeWindow(p_Width, p_Height);
RecordRenderPass(3, SG_STATE_RESIZE, p_Width, p_Height);
}
bool UIDemoApp::InitMetalEngine()
{
if (!m_MetalPaintEngine)
{
m_MetalPaintEngine.reset(new UiMetalPaintEngine());
return m_MetalPaintEngine->Init(m_ScenePainterEngine);
}
return true;
}
void UIDemoApp::RecordRenderPass(int p_Argcount, ...)
{
// va_list args;
// va_start(args, b);
// exampleV(b, args);
// va_end(args);
// va_list list;
// va_start(list, p_Argcount);
// m_Scene->RecordRenderPass(p_Argcount, list);
// va_end(list);
//return;
va_list list;
va_start(list, p_Argcount);
SCENE_GRAPH_STATES currentState = SG_STATE_NONE;
QSize resizedDimension;
for (int i = 0; i < p_Argcount; ++i)
{
switch (i)
{
case 0:
currentState = static_cast<SCENE_GRAPH_STATES>(va_arg(list, int));
break;
case 1:
resizedDimension.setWidth(va_arg(list, int));
break;
case 2:
resizedDimension.setHeight(va_arg(list, int));
break;
default:
{
if (currentState == SG_STATE_NONE)
{
va_end(list);
return;
}
break;
}
}
}
va_end(list);
// Specify the clear color value
VkClearValue clearColor[2];
clearColor[0].color.float32[0] = 0.0f;
clearColor[0].color.float32[1] = 0.0f;
clearColor[0].color.float32[2] = 0.0f;
clearColor[0].color.float32[3] = 0.0f;
// Specify the depth/stencil clear value
clearColor[1].depthStencil.depth = 1.0f;
clearColor[1].depthStencil.stencil = 0;
// Offset to render in the frame buffer
VkOffset2D renderOffset = { 0, 0 };
// Width & Height to render in the frame buffer
VkExtent2D renderExtent = m_swapChainExtent;
// For each command buffers in the command buffer list
for (size_t i = 0; i < m_hCommandBufferList.size(); i++)
{
VkCommandBufferBeginInfo beginInfo = {};
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
// Indicate that the command buffer can be resubmitted to the queue
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
// Begin command buffer
vkBeginCommandBuffer(m_hCommandBufferList[i], &beginInfo);
VkRenderPassBeginInfo renderPassInfo = {};
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = m_hRenderPass;
renderPassInfo.framebuffer = m_hFramebuffers[i];
renderPassInfo.renderArea.offset = renderOffset;
renderPassInfo.renderArea.extent = renderExtent;
renderPassInfo.clearValueCount = 2;
renderPassInfo.pClearValues = clearColor;
// Begin render pass
vkCmdBeginRenderPass(m_hCommandBufferList[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
switch (currentState)
{
case SG_STATE_SETUP:
case SG_STATE_RENDER:
m_Scene->Render(static_cast<void*>(m_hCommandBufferList[i]));
m_ScenePainterEngine->Render(static_cast<void*>(m_hCommandBufferList[i]));
break;
case SG_STATE_RESIZE:
m_Scene->Resize(resizedDimension.width(), resizedDimension.height());
m_ScenePainterEngine->Resize(resizedDimension.width(), resizedDimension.height());
break;
default:
break;
}
// End the Render pass
vkCmdEndRenderPass(m_hCommandBufferList[i]);
// End the Command buffer
VkResult vkResult = vkEndCommandBuffer(m_hCommandBufferList[i]);
if (vkResult != VK_SUCCESS)
{
VulkanHelper::LogError("vkEndCommandBuffer() failed!");
assert(false);
}
}
}
//void UIDemoApp::RecordRenderPass(int p_Argcount, ...)
//{
// va_list list;
// va_start(list, p_Argcount);
// SCENE_GRAPH_STATES currentState = SG_STATE_NONE;
// QSize resizedDimension;
// for (int i = 0; i < p_Argcount; ++i)
// {
// switch (i)
// {
// case 0:
// currentState = static_cast<SCENE_GRAPH_STATES>(va_arg(list, int));
// break;
// case 1:
// resizedDimension.setWidth(va_arg(list, int));
// break;
// case 2:
// resizedDimension.setHeight(va_arg(list, int));
// break;
// default:
// {
// if (currentState == SG_STATE_NONE)
// {
// va_end(list);
// return;
// }
// break;
// }
// }
// }
// va_end(list);
// // Specify the clear color value
// VkClearValue clearColor[2];
// clearColor[0].color.float32[0] = 0.0f;
// clearColor[0].color.float32[1] = 0.0f;
// clearColor[0].color.float32[2] = 0.0f;
// clearColor[0].color.float32[3] = 0.0f;
// // Specify the depth/stencil clear value
// clearColor[1].depthStencil.depth = 1.0f;
// clearColor[1].depthStencil.stencil = 0;
// // Offset to render in the frame buffer
// VkOffset2D renderOffset = { 0, 0 };
// // Width & Height to render in the frame buffer
// VkExtent2D renderExtent = m_swapChainExtent;
// // For each command buffers in the command buffer list
// for (size_t i = 0; i < m_hCommandBufferList.size(); i++)
// {
// VkCommandBufferBeginInfo beginInfo = {};
// beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
// // Indicate that the command buffer can be resubmitted to the queue
// beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT;
// // Begin command buffer
// vkBeginCommandBuffer(m_hCommandBufferList[i], &beginInfo);
// VkRenderPassBeginInfo renderPassInfo = {};
// renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
// renderPassInfo.renderPass = m_hRenderPass;
// renderPassInfo.framebuffer = m_hFramebuffers[i];
// renderPassInfo.renderArea.offset = renderOffset;
// renderPassInfo.renderArea.extent = renderExtent;
// renderPassInfo.clearValueCount = 2;
// renderPassInfo.pClearValues = clearColor;
// // Begin render pass
// vkCmdBeginRenderPass(m_hCommandBufferList[i], &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
// switch (currentState)
// {
// case SG_STATE_SETUP:
// case SG_STATE_RENDER:
// m_Scene->Render(m_hCommandBufferList[i]);
// m_ScenePainterEngine->Render(m_hCommandBufferList[i]);
// break;
// case SG_STATE_RESIZE:
// m_Scene->Resize(m_hCommandBufferList[i], resizedDimension.width(), resizedDimension.height());
// m_ScenePainterEngine->Resize(m_hCommandBufferList[i], resizedDimension.width(), resizedDimension.height());
// break;
// default:
// break;
// }
// // End the Render pass
// vkCmdEndRenderPass(m_hCommandBufferList[i]);
// // End the Command buffer
// VkResult vkResult = vkEndCommandBuffer(m_hCommandBufferList[i]);
// if (vkResult != VK_SUCCESS)
// {
// VulkanHelper::LogError("vkEndCommandBuffer() failed!");
// assert(false);
// }
// }
//}
| [
"engineer.parminder@gmail.com"
] | engineer.parminder@gmail.com |
ec2f42b52732aa801c69fd2ed7444dceb2be3d16 | 83c489d0e7fca84beb4ecb5a8a3d7f666b076fcf | /src/RcppExports.cpp | 6d9ef69e2d1fb2364ad01d9dd81419cea0ad8162 | [] | no_license | tohein/linearMTL | 9f3a02640b5b6e51425f62005744ef3047683a06 | bd27f8e90ea297ddca7c6f5e110e6b62ba0cff55 | refs/heads/master | 2021-03-27T14:40:25.364761 | 2018-11-09T15:37:36 | 2018-11-09T15:37:36 | 106,738,759 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 938 | cpp | // Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include <RcppArmadillo.h>
#include <Rcpp.h>
using namespace Rcpp;
// RcppShrink
arma::mat RcppShrink(arma::mat A, arma::mat ranges);
RcppExport SEXP _LinearMTL_RcppShrink(SEXP ASEXP, SEXP rangesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< arma::mat >::type A(ASEXP);
Rcpp::traits::input_parameter< arma::mat >::type ranges(rangesSEXP);
rcpp_result_gen = Rcpp::wrap(RcppShrink(A, ranges));
return rcpp_result_gen;
END_RCPP
}
static const R_CallMethodDef CallEntries[] = {
{"_LinearMTL_RcppShrink", (DL_FUNC) &_LinearMTL_RcppShrink, 2},
{NULL, NULL, 0}
};
RcppExport void R_init_LinearMTL(DllInfo *dll) {
R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
R_useDynamicSymbols(dll, FALSE);
}
| [
"tohein@stud.uni-saarland.de"
] | tohein@stud.uni-saarland.de |
c9429594983c1f9891119cc478bee63ab7f23293 | b13b47c86458391b7c168cc8189816907adf3be4 | /Eternity/Source/r3dDebug.cpp | 30e041ecc7e6d305f0464eb903a70a9827109ae7 | [] | no_license | gamedevforks/UndeadAlpha | 7f96c68edc170de730d5c98b7c5927114b385abe | 8117fc7202d3bed66ed0f1e342666fde0287d732 | refs/heads/master | 2020-05-21T16:47:23.089908 | 2014-12-02T19:51:08 | 2014-12-02T19:51:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,767 | cpp | #include "r3dPCH.h"
#include "r3d.h"
#include "r3dDebug.h"
#include <windows.h>
#ifndef FINAL_BUILD
#include <tlhelp32.h>
#endif
#include "dbghelp/include/dbghelp.h"
#ifndef DISABLE_CRASHRPT
#pragma comment(lib, "../External/CrashRpt/Lib/CrashRpt1301.lib")
#include "CrashRpt/include/CrashRpt.h"
#endif
//#include "errorrep.h"
extern void r3dCloseLogFile();
bool CreateConfigPath(char* dest);
bool CreateWorkPath(char* dest);
static BOOL CALLBACK MyMiniDumpCallback(PVOID pParam,
const PMINIDUMP_CALLBACK_INPUT pInput,
PMINIDUMP_CALLBACK_OUTPUT pOutput
)
{
BOOL bRet = FALSE;
// Check parameters
if( pInput == 0 )
return FALSE;
if( pOutput == 0 )
return FALSE;
// Process the callbacks
switch( pInput->CallbackType )
{
case IncludeModuleCallback:
{
// Include the module into the dump
bRet = TRUE;
}
break;
case IncludeThreadCallback:
{
// Include the thread into the dump
bRet = TRUE;
}
break;
case ModuleCallback:
{
// Does the module have ModuleReferencedByMemory flag set ?
if( !(pOutput->ModuleWriteFlags & ModuleReferencedByMemory) )
{
// No, it does not - exclude it
//r3dOutToLog( "Excluding module: %s \n", pInput->Module.FullPath );
pOutput->ModuleWriteFlags &= (~ModuleWriteModule);
}
bRet = TRUE;
}
break;
case ThreadCallback:
{
// Include all thread information into the minidump
bRet = TRUE;
}
break;
case ThreadExCallback:
{
// Include this information
bRet = TRUE;
}
break;
case MemoryCallback:
{
// We do not include any information here -> return FALSE
bRet = FALSE;
}
break;
case CancelCallback:
break;
}
return bRet;
}
static TCHAR szPath[MAX_PATH+1];
static LONG WINAPI CreateMiniDump( EXCEPTION_POINTERS* pep )
{
r3dOutToLog("Creating minidump!!\n");
// Open the file
char miniDumpPath[1024];
if(CreateConfigPath(miniDumpPath))
{
strcat( miniDumpPath, "MiniDump.dmp" );
r3dOutToLog("Minidump path: %s\n", miniDumpPath);
HANDLE hFile = CreateFile( miniDumpPath, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
if( ( hFile != NULL ) && ( hFile != INVALID_HANDLE_VALUE ) )
{
// Create the minidump
MINIDUMP_EXCEPTION_INFORMATION mdei;
mdei.ThreadId = GetCurrentThreadId();
mdei.ExceptionPointers = pep;
mdei.ClientPointers = FALSE;
MINIDUMP_CALLBACK_INFORMATION mci;
mci.CallbackRoutine = (MINIDUMP_CALLBACK_ROUTINE)MyMiniDumpCallback;
mci.CallbackParam = 0;
MINIDUMP_TYPE mdt = (MINIDUMP_TYPE)(MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory);
BOOL rv = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(),
hFile, mdt, (pep != 0) ? &mdei : 0, 0, &mci );
if( !rv )
r3dOutToLog( "MiniDumpWriteDump failed. Error: %u \n", GetLastError() );
else
r3dOutToLog( "Minidump created.\n" );
// Close the file
CloseHandle( hFile );
}
else
{
r3dOutToLog( "CreateFile failed. Error: %u \n", GetLastError() );
}
r3dOutToLog("\n!!!Crash!!!\nPlease send '%s' to support@thewarz.com\nThank you.", miniDumpPath);
// hide window, hopefully will work in fullscreen
ShowWindow(win::hWnd, SW_FORCEMINIMIZE);
// show message box to user
char tempStr[2048];
sprintf(tempStr, "Application crashed.\nPlease send '%s' and r3dLog.txt (in install folder of the game) to support@thewarz.com along with description of what you were doing at the time of crash.\nThank you and sorry for inconvenience.", miniDumpPath);
MessageBox(0, tempStr, "Crash", MB_OK);
}
r3dCloseLogFile();
// call WINDOWS ERROR REPORTING, in case if user will not send us crashdump
LONG lRet = EXCEPTION_CONTINUE_SEARCH;
lRet = EXCEPTION_EXECUTE_HANDLER;
return lRet ;
}
// The following function returns TRUE if the correct CrashRpt DLL was loaded,
// otherwise it returns FALSE
/*BOOL CheckCrashRptVersion()
{
BOOL bExitCode = FALSE;
TCHAR szModuleName[_MAX_PATH] = _T("");
HMODULE hModule = NULL;
DWORD dwBuffSize = 0;
LPBYTE pBuff = NULL;
VS_FIXEDFILEINFO* fi = NULL;
UINT uLen = 0;
// Get handle to loaded CrashRpt.dll module
hModule = GetModuleHandle(_T("CrashRpt.dll"));
if(hModule==NULL)
goto cleanup; // No "CrashRpt.dll" module loaded
// Get module file name
GetModuleFileName(hModule, szModuleName, _MAX_PATH);
// Get module version
dwBuffSize = GetFileVersionInfoSize(szModuleName, 0);
if(dwBuffSize==0)
goto cleanup; // Invalid buffer size
pBuff = (LPBYTE)GlobalAlloc(GPTR, dwBuffSize);
if(pBuff==NULL)
goto cleanup;
if(0==GetFileVersionInfo(szModuleName, 0, dwBuffSize, pBuff))
goto cleanup; // No version info found
VerQueryValue(pBuff, _T("\\"), (LPVOID*)&fi, &uLen);
WORD dwVerMajor = HIWORD(fi->dwProductVersionMS);
WORD dwVerMinor = LOWORD(fi->dwProductVersionMS);
WORD dwVerBuild = LOWORD(fi->dwProductVersionLS);
DWORD dwModuleVersion = dwVerMajor*1000+dwVerMinor*100+dwVerBuild;
if(CRASHRPT_VER==dwModuleVersion)
bExitCode = TRUE; // Version match!
cleanup:
if(pBuff)
{
// Free buffer
GlobalFree((HGLOBAL)pBuff);
pBuff = NULL;
}
return bExitCode;
}
*/
BOOL CALLBACK r3dCrashRptCallback(__reserved LPVOID lpvState)
{
r3dCloseLogFile();
return TRUE;
}
r3dThreadAutoInstallCrashHelper::r3dThreadAutoInstallCrashHelper(DWORD dwFlags)
{
#ifndef DISABLE_CRASHRPT
m_nInstallStatus = crInstallToCurrentThread2(dwFlags);
#endif
}
r3dThreadAutoInstallCrashHelper::~r3dThreadAutoInstallCrashHelper()
{
#ifndef DISABLE_CRASHRPT
crUninstallFromCurrentThread();
#endif
}
static const wchar_t* crashRpgGetLangFile()
{
static const wchar_t* en = L"crashrpt_lang.ini";
// if(_waccess(ru, 0) != 0)
// return en;
// russia & ukraine using 1251 codepage
// if(GetACP() == 1251)
// return ru;
return en;
}
void r3dThreadEntryHelper(threadEntry_fn fn, DWORD in)
{
/*if(!CheckCrashRptVersion())
{
// An invalid CrashRpt.dll loaded!
MessageBox(NULL, "The version of CrashRpt.dll is invalid.", "CRASH RPT ERROR", MB_OK);
return;
}*/
if(!IsDebuggerPresent())
{
#ifdef DISABLE_CRASHRPT
SetUnhandledExceptionFilter(CreateMiniDump);
#else
// detect language file
wchar_t curDir[MAX_PATH];
wchar_t langFile[MAX_PATH];
GetCurrentDirectoryW(sizeof(curDir), curDir);
swprintf(langFile, MAX_PATH, L"%s\\%s", curDir, crashRpgGetLangFile());
// use wide versino of structure, as pszLangFilePath *require* full path by some reasons
CR_INSTALL_INFOW info;
memset(&info, 0, sizeof(CR_INSTALL_INFOW));
info.cb = sizeof(CR_INSTALL_INFOW);
#ifdef FINAL_BUILD
info.pszAppName = L"WarZ";
#else
info.pszAppName = L"Studio";
#endif
info.pszAppVersion = L"1.0";
info.pszEmailTo = NULL;
info.pszUrl = L"https://127.0.0.1/UndeadAlpha/api/php/api_CrashRpt.php";
info.pszCrashSenderPath = NULL;
info.pfnCrashCallback = &r3dCrashRptCallback;
info.uPriorities[CR_HTTP] = 1;
info.uPriorities[CR_SMTP] = CR_NEGATIVE_PRIORITY; // skip it
info.uPriorities[CR_SMAPI] = CR_NEGATIVE_PRIORITY; // skip it
info.dwFlags |= CR_INST_ALL_EXCEPTION_HANDLERS;
info.dwFlags |= CR_INST_HTTP_BINARY_ENCODING;
info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS;
//we should not restart app, as GNA using command line to pass login info
//info.dwFlags |= CR_INST_APP_RESTART;
//info.pszRestartCmdLine = __r3dCmdLine;
info.pszPrivacyPolicyURL = L"https://127.0.0.1/UndeadAlpha/PrivacyPolicy_WarZ.htm";
info.pszLangFilePath = langFile;
int res = crInstallW(&info);
if(res !=0)
{
// Something goes wrong. Get error message.
TCHAR szErrorMsg[512] = _T("");
crGetLastErrorMsg(szErrorMsg, 512);
r3dOutToLog(("%s\n"), szErrorMsg);
//return 1;
}
// add files to crash report
char filePath[1024];
res = crAddFile2(_T("r3dlog.txt"), NULL, _T("Log file"), CR_AF_MAKE_FILE_COPY|CR_AF_MISSING_FILE_OK);
CreateConfigPath(filePath);
strcat(filePath, "gameSettings.ini");
res = crAddFile2(filePath, NULL, _T("Game Settings file"), CR_AF_MAKE_FILE_COPY|CR_AF_MISSING_FILE_OK);
CreateConfigPath(filePath);
strcat(filePath, "GPU.txt");
res = crAddFile2(filePath, NULL, _T("GPU information file"), CR_AF_MAKE_FILE_COPY|CR_AF_MISSING_FILE_OK);
#endif
}
//crEmulateCrash(CR_CPP_NEW_OPERATOR_ERROR);
fn(in);
#ifndef DISABLE_CRASHRPT
if(!IsDebuggerPresent())
{
crUninstall();
}
#endif
}
//------------------------------------------------------------------------
#ifndef FINAL_BUILD
static r3dTL::TArray< int > g_BreakPointThreads( 64 );
#endif
static R3D_FORCEINLINE void SetBits(unsigned long& dw, int lowBit, int bits, int newValue)
{
int mask = (1 << bits) - 1; // e.g. 1 becomes 0001, 2 becomes 0011, 3 becomes 0111
dw = (dw & ~(mask << lowBit)) | (newValue << lowBit);
}
int r3dSetDataBreakpoint( void* address, r3dDataBreakpointByteLen byteLen, int condition )
{
#ifndef FINAL_BUILD
g_BreakPointThreads.Clear();
HANDLE hThreadSnap = INVALID_HANDLE_VALUE;
THREADENTRY32 te32;
// Take a snapshot of all running threads
hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
if( hThreadSnap == INVALID_HANDLE_VALUE )
return 0;
// Fill in the size of the structure before using it.
te32.dwSize = sizeof(THREADENTRY32 );
// Retrieve information about the first thread,
// and exit if unsuccessful
if( !Thread32First( hThreadSnap, &te32 ) )
{
return 0;
}
DWORD currProcessID = GetCurrentProcessId();
// Now walk the thread list of the system,
// and display information about each thread
// associated with the specified process
do
{
if( te32.th32OwnerProcessID == currProcessID )
{
g_BreakPointThreads.PushBack( te32.th32ThreadID );
}
} while( Thread32Next(hThreadSnap, &te32 ) );
// Don't forget to clean up the snapshot object.
CloseHandle( hThreadSnap );
//------------------------------------------------------------------------
int currentThreadId = GetCurrentThreadId();
for( int i = 0; i < (int)g_BreakPointThreads.Count(); i ++ )
{
CONTEXT cxt;
int threadId = g_BreakPointThreads[ i ];
HANDLE threadHandle = OpenThread( THREAD_ALL_ACCESS, FALSE, threadId );
if( threadHandle == INVALID_HANDLE_VALUE )
return 0;
if( threadId != currentThreadId )
SuspendThread( threadHandle );
int len = 0;
switch( byteLen )
{
case R3D_DATABREAKPOINT_1_BYTE: len = 0; break;
case R3D_DATABREAKPOINT_2_BYTES: len = 1; break;
case R3D_DATABREAKPOINT_4_BYTES: len = 3; break;
default: r3d_assert(false); // invalid length
}
// The only registers we care about are the debug registers
cxt.ContextFlags = CONTEXT_DEBUG_REGISTERS;
// Read the register values
if( !GetThreadContext(threadHandle, &cxt) )
{
CloseHandle( threadHandle );
return 0;
}
// Find an available hardware register
int index = 0;
for( index = 0; index < 4; ++index )
{
if( ( cxt.Dr7 & ( 1 << ( index * 2 ) ) ) == 0 )
break;
}
r3d_assert( index < 4 ); // All hardware breakpoint registers are already being used
switch ( index )
{
case 0: cxt.Dr0 = (DWORD) address; break;
case 1: cxt.Dr1 = (DWORD) address; break;
case 2: cxt.Dr2 = (DWORD) address; break;
case 3: cxt.Dr3 = (DWORD) address; break;
default: assert(false); // m_index has bogus value
}
SetBits(cxt.Dr7, 16 + (index*4), 2, condition);
SetBits(cxt.Dr7, 18 + (index*4), 2, len);
SetBits(cxt.Dr7, index*2, 1, 1);
// Write out the new debug registers
int failed = 0;
if ( !SetThreadContext(threadHandle, &cxt) )
failed = 1;
if( threadId != currentThreadId )
ResumeThread( threadHandle );
CloseHandle( threadHandle );
if( failed )
return 0;
}
#endif
return 1;
} | [
"muvucasbars@outlook.com"
] | muvucasbars@outlook.com |
ca9ce0e4987625857bbd0065efc18a4a0a8b48fe | cecfda84e25466259d3ef091953c3ac7b44dc1fc | /UVa Online Judge/volume123/12356 Army Buddies/program.cpp | c7f52df3ad77b6a68d253d2a5b4d19fa74f2c7a3 | [] | no_license | metaphysis/Code | 8e3c3610484a8b5ca0bb116bc499a064dda55966 | d144f4026872aae45b38562457464497728ae0d6 | refs/heads/master | 2023-07-26T12:44:21.932839 | 2023-07-12T13:39:41 | 2023-07-12T13:39:41 | 53,327,611 | 231 | 57 | null | null | null | null | UTF-8 | C++ | false | false | 1,789 | cpp | // Army Buddies
// UVa ID: 12356
// Verdict: Accepted
// Submission Date: 2018-01-01
// UVa Run Time: 0.040s
//
// 版权所有(C)2018,邱秋。metaphysis # yeah dot net
#include <bits/stdc++.h>
using namespace std;
inline int nextChar()
{
const int LENGTH = 1048576;
static char buffer[LENGTH], *p = buffer, *end = buffer;
if (p == end) {
if ((end = buffer + fread(buffer, 1, LENGTH, stdin)) == buffer) return EOF;
p = buffer;
}
return *p++;
}
inline bool nextInt(int &x)
{
static char negative = 0, c = nextChar();
negative = 0, x = 0;
while ((c < '0' || c > '9') && c != '-') { if (c == EOF) return false; c = nextChar(); }
if (c == '-') { negative = 1; c = nextChar(); }
do x = (x << 3) + (x << 1) + c - '0'; while ((c = nextChar()) >= '0');
if (negative) x = -x;
return true;
}
int main(int argc, char *argv[])
{
cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
int s, b, left, right;
int leftBuddies[100010], rightBuddies[100010];
while (true)
{
nextInt(s), nextInt(b);
if (s == 0) break;
for (int i = 1; i <= s; i++)
{
leftBuddies[i] = i - 1;
rightBuddies[i] = i + 1;
}
for (int i = 1; i <= b; i++)
{
nextInt(left), nextInt(right);
if (leftBuddies[left] > 0) printf("%d", leftBuddies[left]);
else printf("*");
printf(" ");
if (rightBuddies[right] <= s) printf("%d", rightBuddies[right]);
else printf("*");
printf("\n");
leftBuddies[rightBuddies[right]] = leftBuddies[left];
rightBuddies[leftBuddies[left]] = rightBuddies[right];
}
printf("-\n");
}
return 0;
}
| [
"metaphysis@yeah.net"
] | metaphysis@yeah.net |
a5b7e8f4e94f435fa62ae71f834958aff72ac9c9 | 5dd2ec8717248d25c502a7e73182be11dd249fb3 | /chrome/browser/share/share_features.cc | 51472e6ddebaf4ce87fe3338ea497789ccc731a3 | [
"BSD-3-Clause"
] | permissive | sunnyps/chromium | 32491c4799a2802fe6ece0c05fb23e00d88020e6 | 9550e527d46350377a6e84cd6e09e1b32bf2d936 | refs/heads/main | 2023-08-30T10:34:39.941312 | 2021-10-09T20:13:18 | 2021-10-09T20:13:18 | 217,597,965 | 0 | 0 | BSD-3-Clause | 2021-09-28T18:16:02 | 2019-10-25T19:01:58 | null | UTF-8 | C++ | false | false | 522 | cc | // Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/share/share_features.h"
namespace share {
const base::Feature kUpcomingSharingFeatures{"UpcomingSharingFeatures",
base::FEATURE_DISABLED_BY_DEFAULT};
bool AreUpcomingSharingFeaturesEnabled() {
return base::FeatureList::IsEnabled(kUpcomingSharingFeatures);
}
} // namespace share
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
fa19db10810f04faf04b9c4694142cd32495655c | cc3e1a5d300167f98b1620a59813fad8cf481120 | /examples/Ethernet/Basic_Select/Basic_Select.ino | feba79535eb487a7b4f99d39f352f0076682f414 | [
"MIT"
] | permissive | superfloh247/MySQL_MariaDB_Generic | 6b115e1528ea7136224e85cf4a5ffa5b938324ac | 94f281235e12d6edfee7347f309f25cfb68f6954 | refs/heads/master | 2022-12-21T14:53:24.538419 | 2020-09-09T07:26:55 | 2020-09-09T07:26:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,537 | ino | /*********************************************************************************************************************************
Basic_Select.ino
Library for communicating with a MySQL or MariaDB Server
Based on and modified from Dr. Charles A. Bell's MySQL_Connector_Arduino Library https://github.com/ChuckBell/MySQL_Connector_Arduino
to support nRF52, SAMD21/SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, ESP8266, ESP32, etc. boards using W5x00, ENC28J60, LAM8742A Ethernet,
WiFiNINA, ESP-AT, built-in ESP8266/ESP32 WiFi.
The library provides simple and easy Client interface to MySQL or MariaDB Server.
Built by Khoi Hoang https://github.com/khoih-prog/MySQL_MariaDB_Generic
Licensed under MIT license
Version: 1.0.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 13/08/2020 Initial coding/porting to support nRF52, SAM DUE and SAMD21/SAMD51 boards using W5x00 Ethernet
(Ethernet, EthernetLarge, Ethernet2, Ethernet3 library), WiFiNINA and ESP8266/ESP32-AT shields
1.0.1 K Hoang 18/08/2020 Add support to Ethernet ENC28J60. Fix bug, optimize code.
1.0.2 K Hoang 20/08/2020 Fix crashing bug when timeout. Make code more error-proof. Drop support to ESP8266_AT_Webserver.
**********************************************************************************************************************************/
/*
MySQL Connector/Arduino Example : basic select
This example demonstrates how to issue a SELECT query with no parameters
and use the data returned. For this, we use the Cursor class to execute
the query and get the results.
It demonstrates who methods for running queries. The first allows you to
allocate memory for the cursor and later reclaim it, the second shows how
to use a single instance of the cursor use throughout a sketch.
NOTICE: You must download and install the World sample database to run
this sketch unaltered. See http://dev.mysql.com/doc/index-other.html.
CAUTION: Don't mix and match the examples. Use one or the other in your
own sketch -- you'll get compilation errors at the least.
For more information and documentation, visit the wiki:
https://github.com/ChuckBell/MySQL_Connector_Arduino/wiki.
INSTRUCTIONS FOR USE
1) Change the address of the server to the IP address of the MySQL server
2) Change the user and password to a valid MySQL user and password
3) Connect a USB cable to your Arduino
4) Select the correct board and port
5) Compile and upload the sketch to your Arduino
6) Once uploaded, open Serial Monitor (use 115200 speed) and observe
Note: The MAC address can be anything so long as it is unique on your network.
Created by: Dr. Charles A. Bell
*/
#include "defines.h"
#include <MySQL_Generic_Ethernet.h>
// Select the static Local IP address according to your local network
IPAddress ip(192, 168, 2, 222);
IPAddress server_addr(192, 168, 2, 112);
uint16_t server_port = 5698; //3306;
char user[] = "invited-guest"; // MySQL user login username
char password[] = "the-invited-guest"; // MySQL user login password
char default_database[] = "world"; //"test_arduino";
char default_table[] = "city"; //"test_arduino";
String default_column = "population";
String default_value = "Toronto";
String query = String("SELECT ") + default_column + " FROM " + default_database + "." + default_table
+ " WHERE name = '" + default_value + "'";
MySQL_Connection conn((Client *)&client);
// Create an instance of the cursor passing in the connection
MySQL_Query sql_query = MySQL_Query(&conn);
void setup()
{
Serial.begin(115200);
while (!Serial); // wait for serial port to connect
Serial.print("\nStarting Basic_Select on " + String(BOARD_NAME));
#if USE_ETHERNET
Serial.println(" using W5x00/Ethernet Library");
#elif USE_ETHERNET_LARGE
Serial.println(" using W5x00/EthernetLarge Library");
#elif USE_ETHERNET2
Serial.println(" using W5x00/Ethernet2 Library");
#elif USE_ETHERNET3
Serial.println(" using W5x00/Ethernet3 Library");
#elif USE_ETHERNET_LAN8742A
Serial.println(" using LAN8742A/STM32Ethernet Library");
#elif USE_ETHERNET_ESP8266
Serial.println(" using W5x00/Ethernet_ESP8266 Library");
#elif USE_UIP_ETHERNET
Serial.println(" using ENC28J60/UIPEthernet Library");
#elif USE_CUSTOM_ETHERNET
Serial.println(" using W5x00/Ethernet Custom Library");
#else
// Backup if none is selected
Serial.println(" using W5x00/Ethernet Library");
#endif
MYSQL_LOGWARN(F("========================="));
MYSQL_LOGWARN(F("Default SPI pinout:"));
MYSQL_LOGWARN1(F("MOSI:"), MOSI);
MYSQL_LOGWARN1(F("MISO:"), MISO);
MYSQL_LOGWARN1(F("SCK:"), SCK);
MYSQL_LOGWARN1(F("SS:"), SS);
MYSQL_LOGWARN(F("========================="));
#if defined(ESP8266)
// For ESP8266, change for other boards if necessary
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN D2 // For ESP8266
#endif
MYSQL_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN);
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 )
// For ESP8266
// Pin D0(GPIO16) D1(GPIO5) D2(GPIO4) D3(GPIO0) D4(GPIO2) D8
// Ethernet 0 X X X X 0
// Ethernet2 X X X X X 0
// Ethernet3 X X X X X 0
// EthernetLarge X X X X X 0
// Ethernet_ESP8266 0 0 0 0 0 0
// D2 is safe to used for Ethernet, Ethernet2, Ethernet3, EthernetLarge libs
// Must use library patch for Ethernet, EthernetLarge libraries
Ethernet.init (USE_THIS_SS_PIN);
#elif USE_ETHERNET3
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
#ifndef ETHERNET3_MAX_SOCK_NUM
#define ETHERNET3_MAX_SOCK_NUM 4
#endif
Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
#elif defined(ESP32)
// You can use Ethernet.init(pin) to configure the CS pin
//Ethernet.init(10); // Most Arduino shields
//Ethernet.init(5); // MKR ETH shield
//Ethernet.init(0); // Teensy 2.0
//Ethernet.init(20); // Teensy++ 2.0
//Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
//Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 22 // For ESP32
#endif
MYSQL_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN);
// For other boards, to change if necessary
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 )
// Must use library patch for Ethernet, EthernetLarge libraries
// ESP32 => GPIO2,4,5,13,15,21,22 OK with Ethernet, Ethernet2, EthernetLarge
// ESP32 => GPIO2,4,5,15,21,22 OK with Ethernet3
//Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (USE_THIS_SS_PIN);
#elif USE_ETHERNET3
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
#ifndef ETHERNET3_MAX_SOCK_NUM
#define ETHERNET3_MAX_SOCK_NUM 4
#endif
Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
#else //defined(ESP8266)
// unknown board, do nothing, use default SS = 10
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 10 // For other boards
#endif
MYSQL_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN);
// For other boards, to change if necessary
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 )
// Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
Ethernet.init (USE_THIS_SS_PIN);
#elif USE_ETHERNET3
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
#ifndef ETHERNET3_MAX_SOCK_NUM
#define ETHERNET3_MAX_SOCK_NUM 4
#endif
Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
#endif //defined(ESP8266)
// start the ethernet connection and the server:
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;
// Use Static IP
//Ethernet.begin(mac[index], ip);
Ethernet.begin(mac[index]);
// Just info to know how to connect correctly
MYSQL_LOGWARN(F("========================="));
MYSQL_LOGWARN(F("Currently Used SPI pinout:"));
MYSQL_LOGWARN1(F("MOSI:"), MOSI);
MYSQL_LOGWARN1(F("MISO:"), MISO);
MYSQL_LOGWARN1(F("SCK:"), SCK);
MYSQL_LOGWARN1(F("SS:"), SS);
MYSQL_LOGWARN(F("========================="));
Serial.print("Using mac index = ");
Serial.println(index);
Serial.print("Connected! IP address: ");
Serial.println(Ethernet.localIP());
Serial.print("Connecting to SQL Server @ ");
Serial.print(server_addr);
Serial.println(String(", Port = ") + server_port);
Serial.println(String("User = ") + user + String(", PW = ") + password + String(", DB = ") + default_database);
}
void runQuery(void)
{
row_values *row = NULL;
long head_count = 0;
Serial.println("1) Demonstrating using a dynamically allocated query.");
// Initiate the query class instance
MySQL_Query query_mem = MySQL_Query(&conn);
// Execute the query
Serial.println(query);
// Execute the query
// KH, check if valid before fetching
if ( !query_mem.execute(query.c_str()) )
{
Serial.println("Querying error");
return;
}
// Fetch the columns (required) but we don't use them.
column_names *columns = query_mem.get_columns();
// Read the row (we are only expecting the one)
do
{
row = query_mem.get_next_row();
if (row != NULL)
{
head_count = atol(row->values[0]);
}
} while (row != NULL);
// Show the result
Serial.print(" Toronto pop = ");
Serial.println(head_count);
delay(500);
Serial.println("2) Demonstrating using a local, global query.");
// Execute the query
Serial.println(query);
sql_query.execute(query.c_str());
// Fetch the columns (required) but we don't use them.
sql_query.get_columns();
// Read the row (we are only expecting the one)
do
{
row = sql_query.get_next_row();
if (row != NULL)
{
head_count = atol(row->values[0]);
}
} while (row != NULL);
// Now we close the cursor to free any memory
sql_query.close();
// Show the result but this time do some math on it
Serial.print(" Toronto pop = ");
Serial.println(head_count);
Serial.print(" Toronto pop increased by 11725 = ");
Serial.println(head_count + 11725);
}
void loop()
{
Serial.println("Connecting...");
//if (conn.connect(server_addr, server_port, user, password))
if (conn.connectNonBlocking(server_addr, server_port, user, password) != RESULT_FAIL)
{
delay(500);
runQuery();
conn.close(); // close the connection
}
else
{
Serial.println("\nConnect failed. Trying again on next iteration.");
}
Serial.println("\nSleeping...");
Serial.println("================================================");
delay(60000);
}
| [
"noreply@github.com"
] | superfloh247.noreply@github.com |
d2f140350b7e5dfa6d636ba07c0fe9795e987040 | f32a24e4cacb917617c017c1da1d1f70024fba65 | /cpc/src/chg050.cxx | c688d4b5241297d38e99eed71a46a7faadfdbcab | [] | no_license | yamasdais/iroha-nihoheto | 61629750c8028d3f9836e4c5f1793aaf7fb2ae57 | 033f69bd400d586b0297c8ff97846d01f42ffc55 | refs/heads/master | 2022-09-24T13:44:34.189177 | 2022-09-16T12:59:56 | 2022-09-16T12:59:56 | 116,883,187 | 0 | 0 | null | 2022-09-12T16:52:47 | 2018-01-09T23:36:23 | C++ | UTF-8 | C++ | false | false | 1,017 | cxx | #include <regex>
#include <algorithm>
#include <concepts>
#include <ranges>
#include "challenge.h"
#include "coro_util.h"
template <std::ranges::forward_range Range>
requires std::convertible_to<std::iter_value_t<Range>, std::string>
cpc::generator<std::string, false>
filter_dial_country(Range const& range, std::string const& countryCode) {
std::regex re(std::string(R"(^\s*\+?)") + countryCode);
auto const filter = std::views::filter([&re](auto const& dial) { return std::regex_search(dial, re); });
for (auto const& dial : range | filter) {
co_yield dial;
}
}
void test0() {
std::vector<std::string> dials{
"+40744909080",
"44 7520 112233",
"+44 7652 12345",
"40 33492442",
"7555 23442",
"044 23423442",
" 44 23423442",
};
auto result = filter_dial_country(dials, "44");
for (auto const& dial : result) {
std::cout << dial << std::endl;
}
}
int main(int, char**) {
test0();
return 0;
}
| [
"yamasdais@gmail.com"
] | yamasdais@gmail.com |
f3a4ea2e29217d5e1971eaf83f4cb86b8f37a596 | c1e73f3dcd104570ecf363f6a86d843d2b5050e5 | /AnimationComponents.h | 0fd3da4109e5b34fc8932ebdbfd45bdeeee416ba | [] | no_license | Kol9n9/SimpleGame | 46904e95a55e869c21f2f5d20ce3d174fc5ee15f | bcdb0d5879f3aafe3496dd4d7df3bb6350de5905 | refs/heads/master | 2020-08-28T12:10:47.386022 | 2019-11-10T17:07:34 | 2019-11-10T17:07:34 | 217,696,215 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,148 | h | #pragma once
#ifndef ANIMATIONCOMPONENTS_H
#define ANIMATIONCOMPONENTS_H
#include <iostream>
#include <map>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
class AnimationComponents
{
private:
class Animation {
public:
sf::Texture& TextureSheet;
sf::Sprite& Sprite;
float AnimationTimer;
float Timer;
int Height;
int Width;
sf::IntRect StartRect;
sf::IntRect EndRect;
sf::IntRect CurrentRect;
Animation(sf::Sprite &Sprite, sf::Texture& TextureSheet, float AnimationTimer, int StartFrameX, int StartFrameY, int EndFrameX, int EndFrameY, int Width, int Height)
: Sprite(Sprite), TextureSheet(TextureSheet), AnimationTimer(AnimationTimer), Width(Width), Height(Height)
{
this->Timer = 0;
this->StartRect = sf::IntRect(StartFrameX*this->Width, StartFrameY*this->Height, this->Width, this->Height);
this->EndRect = sf::IntRect(EndFrameX*this->Width, EndFrameY*this->Height, this->Width, this->Height);
this->CurrentRect = this->StartRect;
this->Sprite.setTexture(this->TextureSheet);
this->Sprite.setTextureRect(this->StartRect);
}
//Function
void Play(const float &dt)
{
this->Timer += 100.f * dt;
if (this->Timer >= this->AnimationTimer)
{
this->Timer = 0;
if (this->CurrentRect != this->EndRect)
this->CurrentRect.left += this->Width;
else this->CurrentRect.left = this->StartRect.left;
this->Sprite.setTextureRect(this->CurrentRect);
}
}
void Reset()
{
this->Timer = this->AnimationTimer;
this->CurrentRect = this->StartRect;
}
};
//VARIABLES
std::map<std::string, Animation*> AnimationList;
Animation* LastAnimation;
sf::Sprite& Sprite;
sf::Texture& TextureSheet;
//INITIALIZER FUNCTIONS
public:
AnimationComponents(sf::Sprite& Sprite, sf::Texture& TextureSheet);
virtual ~AnimationComponents();
//FUNCTIONS
void AddAnimation(const std::string key, float AnimationTimer, int StartFrameX, int StartFrameY, int EndFrameX, int EndFrameY, int Width, int Height);
void Play(const std::string key, const float& dt);
};
#endif // !ANIMATIONCOMPONENTS_H | [
"slezenkonikolay@mail.ru"
] | slezenkonikolay@mail.ru |
d13d46b1241c1fd11c0c52d2d422bf444a860037 | 5908c584b22d8f152deeb4082ff6003d841deaa9 | /Physics_RT/Havok/Source/Physics2012/Dynamics/World/Simulation/Multithreaded/Spu/hkpSpuConfig.h | d05a37af44b8e52e68c345c3660ac015e6d4cb10 | [] | no_license | imengyu/Physics_RT | 1e7b71912e54b14679e799e7327b7d65531811f5 | b8411b4bc483d6ce5c240ae4c004f3872c64d073 | refs/heads/main | 2023-07-17T20:55:39.303641 | 2021-08-28T18:25:01 | 2021-08-28T18:25:01 | 399,414,182 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 9,448 | h | /*
*
* Confidential Information of Telekinesys Research Limited (t/a Havok). Not for disclosure or distribution without Havok's
* prior written consent. This software contains code, techniques and know-how which is confidential and proprietary to Havok.
* Product and Trade Secret source code contains trade secrets of Havok. Havok Software (C) Copyright 1999-2013 Telekinesys Research Limited t/a Havok. All Rights Reserved. Use of this software is subject to the terms of an end user license agreement.
*
*/
#ifndef HK_SPU_CONFIG_H
#define HK_SPU_CONFIG_H
#include <Physics2012/Collide/Query/Multithreaded/Spu/hkpSpuConfig.h>
#include <Physics2012/Collide/Agent/hkpProcessCollisionData.h>
#include <Physics/ConstraintSolver/Solve/hkpSolve.h>
//
// Note: This file references symbols in other files.
// You might have to include another file to use them properly
//
// Important: after modifying those values, check that you have at least 16k left for the normal stack
// Also use the simulator to verify this size
// ************************************************************************
// ******* General defines and limits of the engine ******
// ******* These values are Havok tunable + require a full rebuild ******
// ************************************************************************
// The maximum number of contact points which are created between 2 objects
#define HK_MAX_NUM_CONTACT_POINTS_IN_CONSTRAINT_ON_SPU HK_MAX_CONTACT_POINT
// The size of the cache lines on SPU. Only collision agents using shapes
// with a size smaller than this value are processed on the spu; all others are left on PPU.
#define HK_SPU_AGENT_SECTOR_JOB_MAX_SHAPE_SIZE HK_SPU_MAXIMUM_SHAPE_SIZE
#define HK_SPU_AGENT_SECTOR_JOB_MAX_UNTYPED_CACHE_LINE_SIZE HK_SPU_UNTYPED_CACHE_LINE_SIZE
#define HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_LINE_SIZE 512
// The maximum number of jacobians for a normal constraint (excluding contact point constraint)
// This maximum is currently reached by a powered ragdoll constraint with friction and limits (hkpRagdollConstraintData::Runtime)
#define HK_SPU_CONSTRAINT_RUNTIME_BUFFER_SIZE (16 * 11)
// This is the maximum number of hits in a MOPP query, this includes the HK_INVALID_SHAPE_KEY end flag
#define HK_MAX_AGENTS_IN_1N_MACHINE HK_MAX_NUM_HITS_PER_AABB_QUERY
// ******************************************************
// ******* General flags to tune the performance ******
// ******* client rebuild required ******
// ******************************************************
//
// Collision detection buffers
//
// This is the size of the top level shape cache cache. A cache miss is not really expensive, as the DMA is prefetched.
// Must be power of 2, minimum 1k
#define HK_SPU_AGENT_SECTOR_JOB_ROOT_SHAPE_CACHE_SIZE 2048
// This is the cache used by the user of shapes with child shapes. A cache miss is stalling and expensive
// Must be power of 2, minimum 1k
#define HK_SPU_AGENT_SECTOR_JOB_UNTYPED_CACHE_SIZE 4096
// This is the cache used by the MOPP.
// Must be power of 2, minimum 2k
#define HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_SIZE 8192
#define HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_SIZE_MIN 2048
// *******************************************************
// ******* Internal data, don't touch ******
// *******************************************************
//
// Collision detection
//
// the number of rows, each of them has 4 lines
enum { HK_SPU_AGENT_SECTOR_JOB_ROOT_SHAPE_NUM_CACHE_ROWS = HK_SPU_AGENT_SECTOR_JOB_ROOT_SHAPE_CACHE_SIZE / (4*HK_SPU_AGENT_SECTOR_JOB_MAX_SHAPE_SIZE) };
enum { HK_SPU_AGENT_SECTOR_JOB_UNTYPED_NUM_CACHE_ROWS = HK_SPU_AGENT_SECTOR_JOB_UNTYPED_CACHE_SIZE / (4*HK_SPU_AGENT_SECTOR_JOB_MAX_UNTYPED_CACHE_LINE_SIZE) };
enum { HK_SPU_AGENT_SECTOR_JOB_MOPP_NUM_CACHE_ROWS = HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_SIZE / (4*HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_LINE_SIZE) };
enum { HK_SPU_TOTAL_PHYSICS_BUFFER_SIZE = 56000 + HK_SPU_AGENT_SECTOR_JOB_ROOT_SHAPE_CACHE_SIZE + HK_SPU_AGENT_SECTOR_JOB_UNTYPED_CACHE_SIZE + HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_SIZE };
// reduced versions (for static compound ELF)
enum { HK_SPU_AGENT_SECTOR_JOB_MOPP_NUM_CACHE_ROWS_MIN = HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_SIZE_MIN / (4*HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_LINE_SIZE) };
enum { HK_SPU_TOTAL_STATIC_COMPOUND_ELF_BUFFER_SIZE = 54000 + HK_SPU_AGENT_SECTOR_JOB_ROOT_SHAPE_CACHE_SIZE + HK_SPU_AGENT_SECTOR_JOB_UNTYPED_CACHE_SIZE + HK_SPU_AGENT_SECTOR_JOB_MOPP_CACHE_SIZE_MIN };
//
// Solver
//
// - for schemas writer, when this buffer is full a DMA write is triggered
#define HK_SPU_SCHEMA_WRITER_BASE_BUFFER_SIZE (1024 + 128)
// this is the overflow buffer size.
// it has to accommodate the entire max contact constraint == some 6000 bytes ??
// it also has to accommodate all the modifiers that my be attached to the constraint
enum { HK_SPU_SCHEMA_WRITER_OVERFLOW_BUFFER_SIZE = (128 + (HK_MAX_CONTACT_POINT/2) * hkpJacobianSchemaInfo::PairContact::Sizeof + (HK_MAX_CONTACT_POINT%2) * hkpJacobianSchemaInfo::SingleContact::Sizeof + hkpJacobianSchemaInfo::Friction3D::Sizeof + hkpJacobianSchemaInfo::Header::Sizeof + 2 *(hkpJacobianSchemaInfo::SetMass::Sizeof + hkpJacobianSchemaInfo::AddVelocity::Sizeof + hkpJacobianSchemaInfo::SetCenterOfMass::Sizeof) + 3 * hkpJacobianSchemaInfo::Header::Sizeof), };
#define HK_SPU_SOLVE_SCHEMA_READER_BASE_BUFFER_SIZE (512)
#define HK_SPU_SOLVE_SCHEMA_READER_OVERFLOW_BUFFER_SIZE (1024)
enum { HK_SPU_SOLVE_MORE_LESS_MAX_SIZE_OF_CONTACT_SCHEMAS_WITHOUT_BUFFER_CHECK = (4 * hkpJacobianSchemaInfo::PairContact::Sizeof + hkpJacobianSchemaInfo::SingleContact::Sizeof + 1 * hkpJacobianSchemaInfo::Header::Sizeof + (hkpJacobianSchemaInfo::SetMass::Sizeof + 2 * hkpJacobianSchemaInfo::AddVelocity::Sizeof + hkpJacobianSchemaInfo::SetCenterOfMass::Sizeof)), };
// this below is 880
enum { HK_SPU_SOLVE_MORE_THAN_MAX_SIZE_OF_CONTACT_SCHEMAS_WITHOUT_BUFFER_CHECK = ( 4 * hkpJacobianSchemaInfo::PairContact::Sizeof + hkpJacobianSchemaInfo::SingleContact::Sizeof + 4 * hkpJacobianSchemaInfo::Header::Sizeof + 2 * (hkpJacobianSchemaInfo::SetMass::Sizeof + hkpJacobianSchemaInfo::AddVelocity::Sizeof + hkpJacobianSchemaInfo::SetCenterOfMass::Sizeof)), };
// solverTempElems for ragdoll:
// 3 * (frictionAngular+motorAngular+limitAngular+linear) == 3 * (2+3+1+1) = 21
// solverTempElems for contact point (we have accessor checks every 8th contact point)
// ((8+1) * cp + 3d friction) == (8+1) * 1 + 4 = 13
#define HK_SPU_SOLVE_ELEM_TEMP_READER_BASE_BUFFER_SIZE 256
#define HK_SPU_SOLVE_ELEM_TEMP_READER_OVERFLOW_BUFFER_SIZE 128
// Solver export : solver results writer buffer sizes
#define HK_SPU_SOLVE_RESULTS_WRITER_BASE_BUFFER_SIZE 512
#define HK_SPU_SOLVE_RESULTS_WRITER_OVERFLOW_BUFFER_SIZE 128
// - for accumulator fetching (sizeof(hkpVelocityAccumulator) == 128, cacheRow = 4*cacheLine, cacheLine = hkpVelocityAccumulator + 2*int)
#define HK_SPU_ACCUMULATOR_CACHE_NUM_CACHE_ROWS 16
// - for constraintAtoms
#define HK_CONSTRAINTATOM_SIZE_PER_CONTACT_POINT (sizeof(hkContactPoint) + sizeof(hkpContactPointProperties))
#define HK_SPU_CONSTRAINT_ATOM_BUFFER_SIZE ( HK_NEXT_MULTIPLE_OF(16, HK_MAX_NUM_CONTACT_POINTS_IN_CONSTRAINT_ON_SPU * HK_CONSTRAINTATOM_SIZE_PER_CONTACT_POINT) + sizeof(hkpSimpleContactConstraintAtom))
// **********************************
// ******* Internal dma groups ******
// **********************************
// These groups are for reference only.
// If you use sub functions to the relevant jobs,
// you should avoid conflicts with DMA groups
/// DMA groups used by the Jacobians builder.
namespace hkSpuBuildJacobiansJobDmaGroups
{
enum
{
GET_QUERYIN_DMA_GROUP = 0,
GET_DATA_BASE_DMA_GROUP = 1, // we are using double buffering, so we need to reserve 2 DMA groups for this!
WRITE_BACK_CONTACT_CONSTRAINT_ATOM_DMA_GROUP = 3,
WRITE_BACK_RUNTIME_DMA_GROUP = 4,
// next free dma group to use: 5
};
}
namespace hkSpuAgentSectorJobDmaGroups
{
enum
{
GET_ELEMENT_PTRS_DMA_GROUP = 1,
GET_ENTRY_DATA_DMA_GROUP = 2, // we use 5 pipeline stages, so we need to reserve 5 DMA groups
GET_BIG_ATOMS_DMA_GROUP = 7,
GET_UNTYPED_CACHE_DATA = 8,
SHAPE_KEY_TRACK_DMA_GROUP = 9 // Only used in split pipeline.
};
}
namespace hk1nMachineDmaGroups // these groups should not collide with hkSpuAgentSectorJobDmaGroups
{
enum
{
GET_SECTOR_POINTERS_DMA_GROUP = 10,
GET_SECTOR_DMA_GROUP = 12,
WRITE_SECTOR_DMA_GROUP = 14,
};
}
#endif // HK_SPU_CONFIG_H
/*
* Havok SDK - Base file, BUILD(#20131218)
*
* Confidential Information of Havok. (C) Copyright 1999-2013
* Telekinesys Research Limited t/a Havok. All Rights Reserved. The Havok
* Logo, and the Havok buzzsaw logo are trademarks of Havok. Title, ownership
* rights, and intellectual property rights in the Havok software remain in
* Havok and/or its suppliers.
*
* Use of this software for evaluation purposes is subject to and indicates
* acceptance of the End User licence Agreement for this product. A copy of
* the license is included with this software and is also available from salesteam@havok.com.
*
*/
| [
"1501076885@qq.com"
] | 1501076885@qq.com |
06b25adb694a7848655128fb2faeefd5e39e462a | 983424bb42cdbef82975287229652d490dd8f521 | /Sorting 12.cpp | 33c5e158ad907cfa9d93c4d2d72d5a9df02c4817 | [] | no_license | namnguyen215/Thuc_hanh_tin | d6802641b73576fdda951f38bb6b5ab31d7d5d7f | c6958a8f9a1ca4a3fc578054cfc289fd9e935bae | refs/heads/main | 2023-07-17T07:32:51.408534 | 2021-08-06T14:29:34 | 2021-08-06T14:29:34 | 305,582,293 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 269 | cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
long n,m;
cin>>n>>m;
long long a[n+1],b[m+1];
for(long i=0;i<n;i++) cin>>a[i];
for(long i=0;i<m;i++) cin>>b[i];
sort(a,a+n);sort(b,b+n);
cout<<a[n-1]*b[0]<<endl;
}
}
| [
"namnguyenphuong215@gmail.com"
] | namnguyenphuong215@gmail.com |
efdd64ea054270ff7d902a7fd5d3549bb20c704a | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /chrome/browser/ui/views/omnibox/omnibox_result_view_unittest.cc | bc514d77aa398f8df2e08141eba44c3b82c47362 | [
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 3,215 | cc | // Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/omnibox/omnibox_result_view.h"
#include "testing/gtest/include/gtest/gtest.h"
TEST(OmniboxResultViewTest, CheckComputeMatchWidths) {
int contents_max_width, description_max_width;
const int separator_width = 10;
// Both contents and description fit fine.
OmniboxResultView::ComputeMatchMaxWidths(
100, separator_width, 50, 200, false, true, &contents_max_width,
&description_max_width);
EXPECT_EQ(-1, contents_max_width);
EXPECT_EQ(-1, description_max_width);
// Contents should be given as much space as it wants up to 300 pixels.
OmniboxResultView::ComputeMatchMaxWidths(
100, separator_width, 50, 100, false, true, &contents_max_width,
&description_max_width);
EXPECT_EQ(-1, contents_max_width);
EXPECT_EQ(0, description_max_width);
// Description should be hidden if it's at least 75 pixels wide but doesn't
// get 75 pixels of space.
OmniboxResultView::ComputeMatchMaxWidths(
300, separator_width, 75, 384, false, true, &contents_max_width,
&description_max_width);
EXPECT_EQ(-1, contents_max_width);
EXPECT_EQ(0, description_max_width);
// Both contents and description will be limited.
OmniboxResultView::ComputeMatchMaxWidths(
310, separator_width, 150, 400, false, true, &contents_max_width,
&description_max_width);
EXPECT_EQ(300, contents_max_width);
EXPECT_EQ(400 - 300 - separator_width, description_max_width);
// Contents takes all available space.
OmniboxResultView::ComputeMatchMaxWidths(
400, separator_width, 0, 200, false, true, &contents_max_width,
&description_max_width);
EXPECT_EQ(-1, contents_max_width);
EXPECT_EQ(0, description_max_width);
// Half and half.
OmniboxResultView::ComputeMatchMaxWidths(
395, separator_width, 395, 700, false, true, &contents_max_width,
&description_max_width);
EXPECT_EQ((700 - separator_width) / 2, contents_max_width);
EXPECT_EQ((700 - separator_width) / 2, description_max_width);
// When we disallow shrinking the contents, it should get as much space as
// it wants.
OmniboxResultView::ComputeMatchMaxWidths(
395, separator_width, 395, 700, false, false, &contents_max_width,
&description_max_width);
EXPECT_EQ(-1, contents_max_width);
EXPECT_EQ(295, description_max_width);
// (available_width - separator_width) is odd, so contents gets the extra
// pixel.
OmniboxResultView::ComputeMatchMaxWidths(
395, separator_width, 395, 699, false, true, &contents_max_width,
&description_max_width);
EXPECT_EQ((700 - separator_width) / 2, contents_max_width);
EXPECT_EQ((700 - separator_width) / 2 - 1, description_max_width);
// Not enough space to draw anything.
OmniboxResultView::ComputeMatchMaxWidths(
1, 1, 1, 0, false, true, &contents_max_width, &description_max_width);
EXPECT_EQ(0, contents_max_width);
EXPECT_EQ(0, description_max_width);
}
| [
"enrico.weigelt@gr13.net"
] | enrico.weigelt@gr13.net |
b4e1ed7293aadfee796e885c8849da09913d34be | 9433cf978aa6b010903c134d77c74719f22efdeb | /src/svl/Mat.cpp | 7ad818ded478cf117e5f7ab58ec65a95a5986625 | [] | no_license | brandonagr/gpstracktime | 4666575cb913db2c9b3b8aa6b40a3ba1a3defb2f | 842bfd9698ec48debb6756a9acb2f40fd6041f9c | refs/heads/master | 2021-01-20T07:10:58.579764 | 2008-09-24T05:44:56 | 2008-09-24T05:44:56 | 32,090,265 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 14,309 | cpp | /*
File: Mat.cpp
Function: Implements Mat.h
Author(s): Andrew Willmott
Copyright: (c) 1995-2001, Andrew Willmott
*/
#include "svl/Mat.h"
#include <cctype>
#include <cstring>
#include <cstdarg>
#include <iomanip>
// --- Mat Constructors & Destructors -----------------------------------------
Mat::Mat(Int rows, Int cols, ZeroOrOne k) : rows(rows), cols(cols)
{
Assert(rows > 0 && cols > 0, "(Mat) illegal matrix size");
data = new Real[rows * cols];
MakeDiag(k);
}
Mat::Mat(Int rows, Int cols, Block k) : rows(rows), cols(cols)
{
Assert(rows > 0 && cols > 0, "(Mat) illegal matrix size");
data = new Real[rows * cols];
MakeBlock(k);
}
Mat::Mat(Int rows, Int cols, double elt0, ...) : rows(rows), cols(cols)
// The double is hardwired here because it is the only type that will work
// with var args and C++ real numbers.
{
Assert(rows > 0 && cols > 0, "(Mat) illegal matrix size");
va_list ap;
Int i, j;
data = new Real[rows * cols];
va_start(ap, elt0);
SetReal(data[0], elt0);
for (i = 1; i < cols; i++)
SetReal(Elt(0, i), va_arg(ap, double));
for (i = 1; i < rows; i++)
for (j = 0; j < cols; j++)
SetReal(Elt(i, j), va_arg(ap, double));
va_end(ap);
}
Mat::Mat(const Mat &m) : cols(m.cols)
{
Assert(m.data != 0, "(Mat) Can't construct from null matrix");
rows = m.Rows();
UInt elts = rows * cols;
data = new Real[elts];
#ifdef VL_USE_MEMCPY
memcpy(data, m.data, elts * sizeof(Real));
#else
for (UInt i = 0; i < elts; i++)
data[i] = m.data[i];
#endif
}
Mat::Mat(const Mat2 &m) : data(m.Ref()), rows(2 | VL_REF_FLAG), cols(2)
{
}
Mat::Mat(const Mat3 &m) : data(m.Ref()), rows(3 | VL_REF_FLAG), cols(3)
{
}
Mat::Mat(const Mat4 &m) : data(m.Ref()), rows(4 | VL_REF_FLAG), cols(4)
{
}
// --- Mat Assignment Operators -----------------------------------------------
Mat &Mat::operator = (const Mat &m)
{
if (!IsRef())
SetSize(m.Rows(), m.Cols());
else
Assert(Rows() == m.Rows(), "(Mat::=) Matrix rows don't match");
for (Int i = 0; i < Rows(); i++)
SELF[i] = m[i];
return(SELF);
}
Mat &Mat::operator = (const Mat2 &m)
{
if (!IsRef())
SetSize(m.Rows(), m.Cols());
else
Assert(Rows() == m.Rows(), "(Mat::=) Matrix rows don't match");
for (Int i = 0; i < Rows(); i++)
SELF[i] = m[i];
return(SELF);
}
Mat &Mat::operator = (const Mat3 &m)
{
if (!IsRef())
SetSize(m.Rows(), m.Cols());
else
Assert(Rows() == m.Rows(), "(Mat::=) Matrix rows don't match");
for (Int i = 0; i < Rows(); i++)
SELF[i] = m[i];
return(SELF);
}
Mat &Mat::operator = (const Mat4 &m)
{
if (!IsRef())
SetSize(m.Rows(), m.Cols());
else
Assert(Rows() == m.Rows(), "(Mat::=) Matrix rows don't match");
for (Int i = 0; i < Rows(); i++)
SELF[i] = m[i];
return(SELF);
}
Void Mat::SetSize(Int nrows, Int ncols)
{
UInt elts = nrows * ncols;
Assert(nrows > 0 && ncols > 0, "(Mat::SetSize) Illegal matrix size.");
UInt oldElts = Rows() * Cols();
if (IsRef())
{
// Abort! We don't allow this operation on references.
_Error("(Mat::SetSize) Trying to resize a matrix reference");
}
rows = nrows;
cols = ncols;
// Don't reallocate if we already have enough storage
if (elts <= oldElts)
return;
// Otherwise, delete old storage and reallocate
delete[] data;
data = 0;
data = new Real[elts]; // may throw an exception
}
Void Mat::SetSize(const Mat &m)
{
SetSize(m.Rows(), m.Cols());
}
Void Mat::MakeZero()
{
#ifdef VL_USE_MEMCPY
memset(data, 0, sizeof(Real) * Rows() * Cols());
#else
Int i;
for (i = 0; i < Rows(); i++)
SELF[i] = vl_zero;
#endif
}
Void Mat::MakeDiag(Real k)
{
Int i, j;
for (i = 0; i < Rows(); i++)
for (j = 0; j < Cols(); j++)
if (i == j)
Elt(i,j) = k;
else
Elt(i,j) = vl_zero;
}
Void Mat::MakeDiag()
{
Int i, j;
for (i = 0; i < Rows(); i++)
for (j = 0; j < Cols(); j++)
Elt(i,j) = (i == j) ? vl_one : vl_zero;
}
Void Mat::MakeBlock(Real k)
{
Int i;
for (i = 0; i < Rows(); i++)
SELF[i].MakeBlock(k);
}
Void Mat::MakeBlock()
{
Int i, j;
for (i = 0; i < Rows(); i++)
for (j = 0; j < Cols(); j++)
Elt(i,j) = vl_one;
}
// --- Mat Assignment Operators -----------------------------------------------
Mat &Mat::operator += (const Mat &m)
{
Assert(Rows() == m.Rows(), "(Mat::+=) matrix rows don't match");
Int i;
for (i = 0; i < Rows(); i++)
SELF[i] += m[i];
return(SELF);
}
Mat &Mat::operator -= (const Mat &m)
{
Assert(Rows() == m.Rows(), "(Mat::-=) matrix rows don't match");
Int i;
for (i = 0; i < Rows(); i++)
SELF[i] -= m[i];
return(SELF);
}
Mat &Mat::operator *= (const Mat &m)
{
Assert(Cols() == m.Cols(), "(Mat::*=) matrix columns don't match");
Int i;
for (i = 0; i < Rows(); i++)
SELF[i] = SELF[i] * m;
return(SELF);
}
Mat &Mat::operator *= (Real s)
{
Int i;
for (i = 0; i < Rows(); i++)
SELF[i] *= s;
return(SELF);
}
Mat &Mat::operator /= (Real s)
{
Int i;
for (i = 0; i < Rows(); i++)
SELF[i] /= s;
return(SELF);
}
// --- Mat Comparison Operators -----------------------------------------------
Bool operator == (const Mat &m, const Mat &n)
{
Assert(n.Rows() == m.Rows(), "(Mat::==) matrix rows don't match");
Int i;
for (i = 0; i < m.Rows(); i++)
if (m[i] != n[i])
return(0);
return(1);
}
Bool operator != (const Mat &m, const Mat &n)
{
Assert(n.Rows() == m.Rows(), "(Mat::!=) matrix rows don't match");
Int i;
for (i = 0; i < m.Rows(); i++)
if (m[i] != n[i])
return(1);
return(0);
}
// --- Mat Arithmetic Operators -----------------------------------------------
Mat operator + (const Mat &m, const Mat &n)
{
Assert(n.Rows() == m.Rows(), "(Mat::+) matrix rows don't match");
Mat result(m.Rows(), m.Cols());
Int i;
for (i = 0; i < m.Rows(); i++)
result[i] = m[i] + n[i];
return(result);
}
Mat operator - (const Mat &m, const Mat &n)
{
Assert(n.Rows() == m.Rows(), "(Mat::-) matrix rows don't match");
Mat result(m.Rows(), m.Cols());
Int i;
for (i = 0; i < m.Rows(); i++)
result[i] = m[i] - n[i];
return(result);
}
Mat operator - (const Mat &m)
{
Mat result(m.Rows(), m.Cols());
Int i;
for (i = 0; i < m.Rows(); i++)
result[i] = -m[i];
return(result);
}
Mat operator * (const Mat &m, const Mat &n)
{
Assert(m.Cols() == n.Rows(), "(Mat::*m) matrix cols don't match");
Mat result(m.Rows(), n.Cols());
Int i;
for (i = 0; i < m.Rows(); i++)
result[i] = m[i] * n;
return(result);
}
Vec operator * (const Mat &m, const Vec &v)
{
Assert(m.Cols() == v.Elts(), "(Mat::*v) matrix and vector sizes don't match");
Int i;
Vec result(m.Rows());
for (i = 0; i < m.Rows(); i++)
result[i] = dot(v, m[i]);
return(result);
}
Mat operator * (const Mat &m, Real s)
{
Int i;
Mat result(m.Rows(), m.Cols());
for (i = 0; i < m.Rows(); i++)
result[i] = m[i] * s;
return(result);
}
Mat operator / (const Mat &m, Real s)
{
Int i;
Mat result(m.Rows(), m.Cols());
for (i = 0; i < m.Rows(); i++)
result[i] = m[i] / s;
return(result);
}
// --- Mat Mat-Vec Functions --------------------------------------------------
Vec operator * (const Vec &v, const Mat &m) // v * m
{
Assert(v.Elts() == m.Rows(), "(Mat::v*m) vector/matrix sizes don't match");
Vec result(m.Cols(), vl_zero);
Int i;
for (i = 0; i < m.Rows(); i++)
result += m[i] * v[i];
return(result);
}
// --- Mat Special Functions --------------------------------------------------
Mat trans(const Mat &m)
{
Int i,j;
Mat result(m.Cols(), m.Rows());
for (i = 0; i < m.Rows(); i++)
for (j = 0; j < m.Cols(); j++)
result.Elt(j,i) = m.Elt(i,j);
return(result);
}
Real trace(const Mat &m)
{
Int i;
Real result = vl_0;
for (i = 0; i < m.Rows(); i++)
result += m.Elt(i,i);
return(result);
}
Mat &Mat::Clamp(Real fuzz)
// clamps all values of the matrix with a magnitude
// smaller than fuzz to zero.
{
Int i;
for (i = 0; i < Rows(); i++)
SELF[i].Clamp(fuzz);
return(SELF);
}
Mat &Mat::Clamp()
{
return(Clamp(1e-7));
}
Mat clamped(const Mat &m, Real fuzz)
// clamps all values of the matrix with a magnitude
// smaller than fuzz to zero.
{
Mat result(m);
return(result.Clamp(fuzz));
}
Mat clamped(const Mat &m)
{
return(clamped(m, 1e-7));
}
Mat oprod(const Vec &a, const Vec &b)
// returns outerproduct of a and b: a * trans(b)
{
Mat result;
Int i;
result.SetSize(a.Elts(), b.Elts());
for (i = 0; i < a.Elts(); i++)
result[i] = a[i] * b;
return(result);
}
// --- Mat Input & Output -----------------------------------------------------
ostream &operator << (ostream &s, const Mat &m)
{
Int i, w = s.width();
s << '[';
for (i = 0; i < m.Rows() - 1; i++)
s << setw(w) << m[i] << endl;
s << setw(w) << m[i] << ']' << endl;
return(s);
}
inline Void CopyPartialMat(const Mat &m, Mat &n, Int numRows)
{
for (Int i = 0; i < numRows; i++)
n[i] = m[i];
}
istream &operator >> (istream &s, Mat &m)
{
Int size = 1;
Char c;
Mat inMat;
// Expected format: [row0 row1 row2 ...]
while (isspace(s.peek())) // chomp white space
s.get(c);
if (s.peek() == '[')
{
Vec row;
s.get(c);
s >> row;
inMat.SetSize(2 * row.Elts(), row.Elts());
inMat[0] = row;
while (isspace(s.peek())) // chomp white space
s.get(c);
while (s.peek() != ']') // resize if needed
{
if (size == inMat.Rows())
{
Mat holdMat(inMat);
inMat.SetSize(size * 2, inMat.Cols());
CopyPartialMat(holdMat, inMat, size);
}
s >> row; // read a row
inMat[size++] = row;
if (!s)
{
_Warning("Couldn't read matrix row");
return(s);
}
while (isspace(s.peek())) // chomp white space
s.get(c);
}
s.get(c);
}
else
{
s.clear(ios::failbit);
_Warning("Error: Expected '[' while reading matrix");
return(s);
}
m.SetSize(size, inMat.Cols());
CopyPartialMat(inMat, m, size);
return(s);
}
// --- Matrix Inversion -------------------------------------------------------
#if !defined(CL_CHECKING) && !defined(VL_CHECKING)
// we #define away pAssertEps if it is not used, to avoid
// compiler warnings.
#define pAssertEps
#endif
Mat inv(const Mat &m, Real *determinant, Real pAssertEps)
// matrix inversion using Gaussian pivoting
{
Assert(m.IsSquare(), "(inv) Matrix not square");
Int i, j, k;
Int n = m.Rows();
Real t, pivot, det;
Real max;
Mat A(m);
Mat B(n, n, vl_I);
// ---------- Forward elimination ---------- ------------------------------
det = vl_1;
for (i = 0; i < n; i++) // Eliminate in column i, below diag
{
max = -1.0;
for (k = i; k < n; k++) // Find a pivot for column i
if (len(A[k][i]) > max)
{
max = len(A[k][i]);
j = k;
}
Assert(max > pAssertEps, "(inv) Matrix not invertible");
if (j != i) // Swap rows i and j
{
for (k = i; k < n; k++)
Swap(A.Elt(i, k), A.Elt(j, k));
for (k = 0; k < n; k++)
Swap(B.Elt(i, k), B.Elt(j, k));
det = -det;
}
pivot = A.Elt(i, i);
Assert(abs(pivot) > pAssertEps, "(inv) Matrix not invertible");
det *= pivot;
for (k = i + 1; k < n; k++) // Only do elements to the right of the pivot
A.Elt(i, k) /= pivot;
for (k = 0; k < n; k++)
B.Elt(i, k) /= pivot;
// We know that A(i, i) will be set to 1, so don't bother to do it
for (j = i + 1; j < n; j++)
{ // Eliminate in rows below i
t = A.Elt(j, i); // We're gonna zero this guy
for (k = i + 1; k < n; k++) // Subtract scaled row i from row j
A.Elt(j, k) -= A.Elt(i, k) * t; // (Ignore k <= i, we know they're 0)
for (k = 0; k < n; k++)
B.Elt(j, k) -= B.Elt(i, k) * t;
}
}
// ---------- Backward elimination ---------- -----------------------------
for (i = n - 1; i > 0; i--) // Eliminate in column i, above diag
{
for (j = 0; j < i; j++) // Eliminate in rows above i
{
t = A.Elt(j, i); // We're gonna zero this guy
for (k = 0; k < n; k++) // Subtract scaled row i from row j
B.Elt(j, k) -= B.Elt(i, k) * t;
}
}
if (determinant)
*determinant = det;
return(B);
}
| [
"BrandonAGr@0fd8bb18-9850-0410-888e-21b4c4172e3e"
] | BrandonAGr@0fd8bb18-9850-0410-888e-21b4c4172e3e |
b60d3203764edb1e0783a1d32860419726c350e9 | 0dde4e977c748fe1dfa5458d9bf790e38ae5b3be | /trunk/analysis/ClasTool/MapTools/TFloatBuffer.h | 99c6dfcc362dd9705c9b3daae2af4b059c8a4ea7 | [] | no_license | jasonbono/CLAS | e27a48f96b753e11a97803bbe4c782319c4f8534 | c899062b8740cdb6ef04916d74f22cebc5d2c5f8 | refs/heads/master | 2020-05-24T03:56:12.542417 | 2019-05-16T17:50:31 | 2019-05-16T17:50:31 | 187,074,934 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 702 | h |
#ifndef __TFLOATBUFFER__
#define __TFLOATBUFFER__
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include <iomanip>
using std::cout;
using std::endl;
// ROOT includes
#include "TROOT.h"
#include "TObject.h"
#include "TString.h"
class TFloatBuffer{
private:
Float_t *lBuffer;
Int_t lBuffLength;
public:
TFloatBuffer();
TFloatBuffer(int gLength);
virtual ~TFloatBuffer();
void SetSize(int gSize);
Int_t GetSize();
void AllocateBuffer(int gLength);
void ResetBuffer();
int BoundCheck(int gPos);
void Set(int gPos, float gValue);
Float_t Get(int gPos);
void Print();
ClassDef(TFloatBuffer,1) // Class for keeping Array of Floats (with bound check)
};
#endif
| [
"jason.s.bono@gmail.com"
] | jason.s.bono@gmail.com |
83699bad7b2e08261bbdac52e55a9488d93922a5 | 701d19cedb341099cafd5602314a0a48ca3e7a50 | /RSEngine/RSObjVS.h | 56c72deb0e322b6b35c8b4542213b2b51411b99e | [] | no_license | denghc/danmugame | 9ab9da54f96b12484689154c2588de7263d775c2 | 12ec3147a95585709d97eae51f82aa1074a56b91 | refs/heads/master | 2021-01-01T18:21:54.764551 | 2012-06-11T06:55:54 | 2012-06-11T06:55:54 | 4,621,859 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 759 | h | #pragma once
#include "vertexshaderclass.h"
#include "Structures.h"
class RSObjVS :
public VertexShaderClass
{
public:
RSObjVS(string tag);
RSObjVS(void);
~RSObjVS(void);
virtual bool Initialize(ID3D11Device*, HWND, WCHAR*, CHAR*);
virtual bool InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, CHAR* entryFuncName);
virtual bool InitializeConstantBuffer(ID3D11Device*);
virtual bool SetRenderParameters(ID3D11DeviceContext* device, D3DXMATRIX worldMatrix,
D3DXMATRIX viewMatrix, D3DXMATRIX projectionMatrix);
virtual void Shutdown();
private:
virtual void ShutdownConstantBuffer();
virtual void ShutdownShader();
private:
ID3D11VertexShader* m_vertexShader;
ID3D11InputLayout* m_layout;
ID3D11Buffer* m_rsObjBuffer;
};
| [
"denghc09@gmail.com"
] | denghc09@gmail.com |
08e62cc4c7758481e0654341a25b23ebd593dd1a | 7e85951f968dbb36dd8149df26f70ee5ac0f5083 | /main.cpp | 0e82329feb88062ac8cb4bd339cf009ce83a18e3 | [] | no_license | helga1507/coursera_white | ee14de20ad963a196a2da31a926be3f152f3d524 | d4db300cadc4f97e0e1b70e99adfd702cc2fe07e | refs/heads/master | 2022-12-13T14:53:14.165926 | 2020-09-07T20:06:12 | 2020-09-07T20:06:12 | 283,464,911 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,627 | cpp | #include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
using namespace std;
const char SEPARATOR_DATE = '-';
const string COMMAND_ADD = "Add";
const string COMMAND_DEL = "Del";
const string COMMAND_FIND = "Find";
const string COMMAND_PRINT = "Print";
class Date {
public:
Date (int new_year, int new_month, int new_day) {
if (new_month < 1 || new_month > 12)
throw logic_error("Month value is invalid: " + to_string(month));
if (day < 1 || day > 31)
throw logic_error("Day value is invalid: " + to_string(day));
this->year = new_year;
this->month = new_month;
this->day = new_day;
}
int GetYear() const {
return this->year;
};
int GetMonth() const {
return this->month;
};
int GetDay() const {
return this->day;
};
private:
int year, month, day;
};
bool operator<(const Date& lhs, const Date& rhs) {
if (lhs.GetYear() != rhs.GetYear())
return lhs.GetYear() < rhs.GetYear();
if (lhs.GetMonth() != rhs.GetMonth())
return lhs.GetMonth() < rhs.GetMonth();
return lhs.GetDay() < rhs.GetDay();
};
class Database {
public:
void AddEvent(const Date& date, const string& event) {
this->events[date].insert(event);
};
bool DeleteEvent(const Date& date, const string& event) {
if (this->events.count(date) == 0)
return false;
return this->events.at(date).erase(event) != 0;
};
int DeleteDate(const Date& date) {
if (this->events.count(date) == 0)
return 0;
int n = this->events.at(date).size();
this->events.erase(date);
return n;
};
void Find(const Date& date) const {
vector<string> v_str;
if (this->events.count(date) == 0)
return;
for (const string& event : this->events.at(date))
cout << event << endl;
};
void Print() const {
for (const auto& [date, set_values] : this->events) {
for (const auto& event : set_values) {
cout << setw(4) << setfill('0') << date.GetYear() << "-" <<
setw(2) << setfill('0') << date.GetMonth() << "-" <<
setw(2) << setfill('0') << date.GetDay() << " " <<
event << endl;
}
}
};
private:
map<Date, set<string>> events;
};
Date parseDate (const string& str_date) {
stringstream ss(str_date);
string error_str;
string trash_text;
int year, month, day;
char sep, sep2;
ss >> year >> sep >> month >> sep2 >> day;
if (!ss || sep != SEPARATOR_DATE || sep2 != SEPARATOR_DATE || ss.rdbuf()->in_avail() != 0)
throw runtime_error("Wrong date format: " + str_date);
return { year, month, day };
}
bool CheckCorrectCommand (const string& command) {
return command == COMMAND_ADD || command == COMMAND_DEL || command == COMMAND_FIND || command == COMMAND_PRINT;
}
void FillCommandsData (stringstream& ss, string& command, Date& date, string& event) {
string temp;
istream& ist = getline(ss, command, ' ');
if (ss.eof() || !CheckCorrectCommand(command))
return;
getline(ss, temp, ' ');
date = parseDate(temp);
if (ss.eof())
return;
getline(ss, event, ' ');
}
int main() {
Database db;
string command_line;
while (getline(cin, command_line)) {
stringstream ss(command_line);
string command;
Date date(0, 0, 0);
string event;
try {
FillCommandsData(ss, command, date, event);
if (command.empty())
continue;
if (command == COMMAND_ADD) {
db.AddEvent(date, event);
}
else if (command == COMMAND_DEL && !event.empty()) {
bool is_deleted = db.DeleteEvent(date, event);
cout << (is_deleted ? "Deleted successfully" : "Event not found") << endl;
}
else if (command == COMMAND_DEL) {
int n = db.DeleteDate(date);
cout << "Deleted " << n << " events" << endl;
}
else if (command == COMMAND_FIND) {
db.Find(date);
}
else if (command == COMMAND_PRINT) {
db.Print();
}
else {
throw runtime_error("Unknown command: " + command);
}
} catch (exception& err) {
cout << err.what() << endl;
}
}
return 0;
} | [
"lashkul@skytracking.ru"
] | lashkul@skytracking.ru |
36a1bc3e5057f9d5b91b56593e679c5e6f187741 | 497295beab134b883f9b1eb835117aadada06a84 | /AI.cpp | 08d49e318da3271e54ae692b7cac2dbcf692367d | [] | no_license | Curtainf2f/Gomoku | e51178460362571d348e101f163e4434e46ca084 | 795cfdc76dde146a6329fce1ec2a8b15abdfef13 | refs/heads/master | 2020-05-24T00:25:38.761981 | 2019-05-16T11:53:40 | 2019-05-16T11:53:40 | 187,016,376 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 14,680 | cpp | #include "graphics.h"
#include "art.h"
#include "mystruct.h"
#include "AI.h"
#include <stack>
#include <queue>
#include <cstring>
#include "rule.h"
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <string>
#include <ctime>
using namespace std;
//#define DEBUG
clock_t start_time;
const int timelimit = 930;
extern int map_wzq[15][15];
extern std::stack<chesspiece*> chess;
thinkpiece *tempchess;
bool piececlosed(int x,int y)
{
int next[8][2]= {1,0,-1,0,0,1,0,-1,1,1,-1,-1,1,-1,-1,1};
int tx,ty,sum;
for(int i=0; i<4; i++)
{
for(int j=0; j<2; j++)
{
sum=1;
tx=x;
ty=y;
while(1)
{
if(sum>3) break;
tx+=next[i*2+j][0];
ty+=next[i*2+j][1];
if(tx<0||ty<0||tx>=15||ty>=15) break;
if(map_wzq[tx][ty]==0)
sum+=1;
else
return true;
}
}
}
return false;
}
int analysis(char s[])
{
///长连
if (strstr(s,"OOOOO")!=NULL)
return 0;
///活四
else if (strstr(s,"_OOOO_")!=NULL)
return 1;
else if (strstr(s,"O_OOO_O")!=NULL)
return 1;
///冲四
else if (strstr(s,"OOO_O")!=NULL)
return 2;
else if (strstr(s,"_OOOOH")!=NULL)
return 2;
else if (strstr(s,"OO_OO")!=NULL)
return 2;
///活三
else if (strstr(s,"__OOO_")!=NULL)
return 3;
else if (strstr(s,"_OO_O_")!=NULL)
return 3;
///眠三
else if (strstr(s,"OHHH_O")!=NULL)
return 4;
else if (strstr(s,"OHH_HO")!=NULL)
return 4;
else if (strstr(s,"__OOOH")!=NULL)
return 4;
else if (strstr(s,"_O_OOH")!=NULL)
return 4;
else if (strstr(s,"_OO_OH")!=NULL)
return 4;
else if (strstr(s,"O__OO")!=NULL)
return 4;
else if (strstr(s,"O_O_O")!=NULL)
return 4;
else if (strstr(s,"H_OOO_H")!=NULL)
return 4;
///活二
else if (strstr(s,"__OO__")!=NULL)
return 5;
else if (strstr(s,"__O_O_")!=NULL)
return 5;
else if (strstr(s,"_O__O_")!=NULL)
return 5;
else if (strstr(s,"___OO_")!=NULL)
return 5;
///眠二
else if (strstr(s,"___OOH")!=NULL)
return 6;
else if (strstr(s,"__O_OH")!=NULL)
return 6;
else if (strstr(s,"_O__OH")!=NULL)
return 6;
else if (strstr(s,"H_O_O_H")!=NULL)
return 6;
else if (strstr(s,"H_OO__H")!=NULL)
return 6;
return 7;
}
bool vct;
int countscore(thinkpiece piece,int c)
{
int position[15][15] =
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
{ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0 },
{ 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 5, 6, 6, 6, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 5, 5, 5, 5, 5, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 3, 2, 1, 0 },
{ 0, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 0 },
{ 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0 },
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
int v=0;
int tx,ty;
char s[4][13];
int len[4];
int situation[8];
int next[8][2]= {1,0,-1,0,0,1,0,-1,1,1,-1,-1,1,-1,-1,1};
v+=position[piece.x][piece.y];
memset(situation,0,sizeof(situation));
for(int i=0; i<4; i++)
{
for(int j=0; j<2; j++)
{
len[j]=0;
tx=piece.x;
ty=piece.y;
while(1)
{
if(len[j]>4) break;
tx+=next[i*2+j][0];
ty+=next[i*2+j][1];
if(tx>=0&&ty>=0&&tx<15&&ty<15)
{
if(map_wzq[tx][ty]==0)
s[j][len[j]++]='_';
else if(map_wzq[tx][ty]==c)
s[j][len[j]++]='O';
else
{
s[j][len[j]++]='H';
}
}
else
{
s[j][len[j]++]='H';
break;
}
}
s[j][len[j]]='\0';
}
len[2]=0;
len[3]=0;
for(int k=len[0]-1; k>=0; k--)
s[2][len[2]++]=s[0][k];
s[2][len[2]++]='O';
for(int k=0; k<len[1]; k++)
s[2][len[2]++]=s[1][k];
s[2][len[2]]='\0';
for(int k=len[2]-1; k>=0; k--)
s[3][len[3]++]=s[2][k];
s[3][len[3]]='\0';
situation[std::min(analysis(s[2]),analysis(s[3]))]++;
}
//长连0 活四1 眠四2 活三3 眠三4 活二5 眠二6
if(situation[0]) v+=1000000;
else if(situation[1]||situation[2]>=2||(situation[2]&&situation[3])) v+=100000;
else if(situation[3]>=2) v+=50000;
else if(situation[2] && vct) v+=6000;
else if(situation[3] && (situation[4] || situation[5])) v += 5500;
else if(situation[2] && (situation[4] || situation[5])) v += 5500;
else if(situation[3] || situation[2]) v+=5000;
else if(situation[4] >= 2) v+=400*situation[4];
else if(situation[4]) v+=200 + situation[5]*20;
else if(situation[5]) v+=80*situation[5];
else if(situation[6]) v+=10*situation[6];
return v;
}
bool vctf(thinkpiece piece, int range, int c, int depth);
int delscore(int c);
thinkpiece maxpiece;
bool isme;
int pdf;
#ifdef DEBUG
FILE *fp;
#endif // DEBUG
bool protect(thinkpiece piece, int c, int v, int depth)
{
clock_t end_time = clock();
if(static_cast<double>(end_time - start_time)/CLOCKS_PER_SEC*1000 >= timelimit)
{
return true;
}
int b;
if(c==1) b=2;
else b=1;
queue<thinkpiece> consider;
int x = piece.x;
int y = piece.y;
int next[8][2]= {1,0,-1,0,0,1,0,-1,1,1,-1,-1,1,-1,-1,1};
int tx,ty,sum;
for(int i=0; i<4; i++)
{
for(int j=0; j<2; j++)
{
sum=1;
tx=x;
ty=y;
while(1)
{
if(sum>4) break;
tx+=next[i*2+j][0];
ty+=next[i*2+j][1];
if(tx<0||ty<0||tx>=15||ty>=15) break;
if(map_wzq[tx][ty]==0)
{
consider.push(thinkpiece(tx, ty));
}
sum+=1;
}
}
}
while(!consider.empty())
{
thinkpiece now = consider.front();
consider.pop();
map_wzq[now.x][now.y] = c;
int del = delscore(b);
if(del >= 10000)
{
map_wzq[now.x][now.y] = 0;
continue;
}
else
{
#ifdef DEBUG
fprintf(fp,"%d %d try to protect\n", now.x, now.y);
for(int i = 0; i < 15; i ++)
{
for(int j = 0; j < 15; j ++)
{
fprintf(fp,"%d ", map_wzq[j][i]);
}
fprintf(fp,"\n");
}
#endif // DEBUG
if(!vctf(piece, 4, b, depth - 1))
{
map_wzq[now.x][now.y] = 0;
return true;
}
}
map_wzq[now.x][now.y] = 0;
}
return false;
}
bool vctf(thinkpiece piece, int range, int c, int depth) // range 2 or 14
{
clock_t end_time = clock();
if(static_cast<double>(end_time - start_time)/CLOCKS_PER_SEC*1000 >= timelimit)
{
return false;
}
if(depth <= 0)
return false;
int b;
if(c==1) b=2;
else b=1;
int left, right, up, down;
if(piece.x - range >= 0) left = piece.x - range;
else left = 0;
if(piece.x + range < 15) right = piece.x + range;
else right = 14;
if(piece.y - range >= 0) up = piece.y - range;
else up = 0;
if(piece.y + range < 15) down = piece.y + range;
else down = 14;
for(int y=up; y<=down; y++)
{
for(int x=left; x<=right; x++)
{
if(!map_wzq[x][y]&&piececlosed(x, y))
{
map_wzq[x][y] = c;
int v = countscore(thinkpiece(x, y), c);
int del;
if(v >= 10000)
{
del = delscore(b);
if(v - del >= -10)
{
#ifdef DEBUG
fprintf(fp, "test 10000\n");
for(int i = 0; i < 15; i ++)
{
for(int j = 0; j < 15; j ++)
{
fprintf(fp,"%d ", map_wzq[j][i]);
}
fprintf(fp, "\n");
}
#endif // DEBUG
map_wzq[x][y] = 0;
if(isme)
maxpiece = thinkpiece(x,y);
return true;
}
}
else if(v >= pdf)
{
del = delscore(b);
if(v - del >= -10)
{
#ifdef DEBUG
fprintf(fp, "test 6000\n");
for(int i = 0; i < 15; i ++)
{
for(int j = 0; j < 15; j ++)
{
fprintf(fp,"%d ", map_wzq[j][i]);
}
fprintf(fp, "\n");
}
#endif // DEBUG
if(!protect(thinkpiece(x, y), b, v, depth - 3))
{
map_wzq[x][y] = 0;
if(isme)
maxpiece = thinkpiece(x,y);
return true;
}
}
}
else if(v >= 5000)
{
del = delscore(b);
if(v - del >= -10)
{
#ifdef DEBUG
fprintf(fp, "test 5000\n");
for(int i = 0; i < 15; i ++)
{
for(int j = 0; j < 15; j ++)
{
fprintf(fp,"%d ", map_wzq[j][i]);
}
fprintf(fp, "\n");
}
#endif // DEBUG
if(!protect(thinkpiece(x, y), b, v, depth - 1))
{
map_wzq[x][y] = 0;
if(isme)
maxpiece = thinkpiece(x,y);
return true;
}
}
}
map_wzq[x][y] = 0;
}
}
}
return false;
}
int delscore(int c)
{
queue<thinkpiece> add;
thinkpiece piece;
int vmax=-9999999, v;
for(int y=0; y<15; y++)
for(int x=0; x<15; x++)
if(!map_wzq[x][y]&&piececlosed(x,y))
{
piece.x=x;
piece.y=y;
add.push(piece);
}
while(!add.empty())
{
map_wzq[add.front().x][add.front().y]=c;
v=countscore(add.front(),c);
if(v > vmax)
{
vmax = v;
}
map_wzq[add.front().x][add.front().y]=0;
add.pop();
}
return vmax;
}
void AIthinking(int c)
{
if(chess.empty())
{
putchesspieces(7,7,c);
return ;
}
else if(chess.size() == 1 && !(chess.top()->x ==7 && chess.top()->y == 7))
{
if(chess.top()->x>7)
{
putchesspieces(chess.top()->x-1,chess.top()->y,c);
}
else
{
putchesspieces(chess.top()->x+1,chess.top()->y,c);
}
return ;
}
int b;
if(c==1) b=2;
else b=1;
thinkpiece piece, vmaxpiece;
piece.x = chess.top()->x;
piece.y = chess.top()->y;
isme = 1;
vct = 1;
pdf = 6000;
#ifdef DEBUG
fp = fopen("1.txt", "w");
#endif // DEBUG
if(vctf(piece, 14, c, 11))
{
#ifdef DEBUG
puts("win");
#endif // DEBUG
putchesspieces(maxpiece.x,maxpiece.y,c);
return ;
#ifdef DEBUG
fclose(fp);
#endif // DEBUG
}
#ifdef DEBUG
fclose(fp);
puts("test1");
#endif // DEBUG
isme = 0;
vct = 0;
pdf = 6000;
queue<thinkpiece> add;
int vmax=-9999999, vvmax = -9999999,v;
for(int y=0; y<15; y++)
for(int x=0; x<15; x++)
if(!map_wzq[x][y]&&piececlosed(x,y))
{
piece.x=x;
piece.y=y;
add.push(piece);
}
while(!add.empty())
{
map_wzq[add.front().x][add.front().y]=c;
v=countscore(add.front(),c);
int del = delscore(b);
v -= del;
if(v >= vvmax)
{
if(v >= -10)
{
#ifdef DEBUG
fp = fopen("23.txt", "a");
#endif // DEBUG
vct = 1;
if(!vctf(add.front(), 14, b, 11))
{
#ifdef DEBUG
puts("ok2");
#endif // DEBUG
if(v > vvmax)
{
vvmax = v;
vmaxpiece = add.front();
}
if(v >= vvmax - 1)
{
if(rand() & 1)
{
vmaxpiece = add.front();
}
}
}
vct = 0;
#ifdef DEBUG
fclose(fp);
#endif // DEBUG
}
else
{
if(v > vmax){
vmax = v;
maxpiece = add.front();
}
if(v >= vmax - 1){
if(rand() & 1)
{
maxpiece = add.front();
}
}
}
}
if(vvmax != -9999999)
{
maxpiece = vmaxpiece;
}
// printf("[%d %d] +%d -%d =%d\n", add.front().x, add.front().y, addv, del, v);
map_wzq[add.front().x][add.front().y]=0;
add.pop();
}
putchesspieces(maxpiece.x,maxpiece.y,c);
return ;
}
| [
"835074923@qq.com"
] | 835074923@qq.com |
2c9cbb5833abc8bc50a4fbe00343aa7d35ac0a5c | be332b45dc5875246336b3f340f5ccbaa4f299f8 | /Conch/source/common/imageLib/JCGifImg.h | adb8cbf4e0af9e60e9788a22322dadc381a24537 | [] | no_license | chen1234219/LayaNative2.0 | cd1c7cb9f8f8236721a1b0fcfd733565b1d80053 | 2a210f0a4b988fc3efc824d88cea1ccc54cd0e17 | refs/heads/main | 2023-08-13T17:44:19.282053 | 2021-10-11T07:03:50 | 2021-10-11T07:03:50 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 8,989 | h | /**
@file JCGifImg.h
@brief
@author James
@version 1.0
@date 2016_7_13
*/
#ifndef __JCGifImg_H__
#define __JCGifImg_H__
#include <fstream>
#include <iostream>
using namespace std;
namespace laya
{
/*
* 图像扩展参数
*/
typedef struct
{
bool active; //本结构中的其它参数是否可用
unsigned int disposalMethod; //处理方法(见gif89a.doc,可忽略)
bool userInputFlag; //是否期待用户输入
bool trsFlag; //是否有透明色
unsigned short delayTime; //延时时间(单位1/100秒)
unsigned int trsColorIndex; //透明色调色板索引
}GCTRLEXT;
/*
* 一帧图象的参数
*/
typedef struct
{
unsigned short imageLPos; //图象左边沿到逻辑屏幕的距离(单位像素)
unsigned short imageTPos; //图象上边沿到逻辑屏幕的距离(单位像素)
unsigned short imageWidth; //图象的宽度(单位像素)
unsigned short imageHeight; //图象的高度(单位像素)
bool lFlag; //是否有局部调色板(决定其他调色板参数是否有效)
bool interlaceFlag; //图象数据是否交错
bool sortFlag; //局部调色板数据是否按优先排序
unsigned int lSize; //局部调色板大小(有多少个实际入口)
unsigned char* pColorTable; //指向局部调色板的指针(256个入口,每个入口三字节)
unsigned char* dataBuf; //调色板格式请参看gif89a.doc
GCTRLEXT ctrlExt; //图象数据指针
}FRAME; //图象扩展参数(与透明背景和动画有关)
typedef FRAME *LPFRAME;
typedef const FRAME *LPCFRAME;
/*
* GIF文件的全局参数
*/
typedef struct
{ //GIF文件的全局参数
unsigned int frames; //文件中图象帧数
unsigned short scrWidth, scrHeight; //逻辑屏幕的宽度和高度(单位像素)
bool gFlag; //是否有全局调色板(决定其他调色板参数是否有效)
unsigned int colorRes; //色彩分辨率(不使用)
bool gSort; //全局调色板是否按优先排序
unsigned int gSize; //全局调色板大小(有多少个实际入口)
unsigned int BKColorIdx; //背景色的调色板索引
unsigned int pixelAspectRatio; //像素长宽比例
unsigned char *gColorTable; //指向全局调色板的指针(256个入口,每个入口三字节)
}GLOBAL_INFO; //调色板格式请参看gif89a.doc
typedef GLOBAL_INFO *LPGLOBAL_INFO;
typedef const GLOBAL_INFO *LPCGLOBAL_INFO;
/*
*
*/
typedef struct
{
unsigned int len;
unsigned char* p;
}STRING_TABLE_ENTRY;
class BufferIOStream
{
public:
BufferIOStream(char* p_sBuffer, int p_nBufferSize)
{
m_pBuffer = p_sBuffer;
m_nSize = p_nBufferSize;
m_nCurPos = 0;
}
~BufferIOStream()
{
close();
}
bool read(char* p_pRet, int p_nSize)
{
if ((m_nCurPos + p_nSize) > m_nSize)
{
return false;
}
char* pCur = m_pBuffer + m_nCurPos;
memcpy(p_pRet, pCur, p_nSize);
m_nCurPos += p_nSize;
return true;
}
bool good()
{
return true;
}
int tellg()
{
return m_nCurPos;
}
void close()
{
/*直接拿的指针应该在外面释放
if( m_pBuffer != NULL )
{
delete[] m_pBuffer;
m_pBuffer = NULL;
}
*/
m_nSize = 0;
m_nCurPos = 0;
}
bool eof()
{
return (m_nCurPos >= m_nSize);
}
void seekg(int p_nPos)
{
m_nCurPos = p_nPos;
}
void seekg(int p_nPos, int p_nMark)
{
if (p_nMark == 0)
{
m_nCurPos = 0 + p_nPos;
}
else if (p_nMark == 1)
{
m_nCurPos += p_nPos;
}
else if (p_nMark == 2)
{
m_nCurPos = m_nSize + p_nPos;
}
}
protected:
char* m_pBuffer;
int m_nSize;
int m_nCurPos;
};
/**
* Gif类
*/
class GifLoader
{
public:
/** @brief
* 构造函数
*/
GifLoader(void);
/** @brief 构造函数
* @param[in] 文件名字
* @param[in] 是否一次性读取完成
* @return
*/
GifLoader(const char* p_sFileName, bool p_bInMem);
GifLoader(unsigned char* p_pBuffer, int p_nBufferSize);
/** @brief
* 析构函数
*/
~GifLoader(void);
/** @brief
* 重载错误符号
*/
bool operator!(void);
/** @brief 打开图片
* @param[in] 图片路径
* @param[in] 是否一次性读取完成
* @return
*/
bool open(const char* p_sFileName, bool p_bInMem);
/** @brief 关闭
*
*/
void close(void);
/** @brief 获得版本
*
*/
char* getVersion(void);
/** @brief 获得下一帧
*
*/
LPCFRAME getNextFrame(void);
/** @brief 获得图片的全局信息
*
*/
LPCGLOBAL_INFO getGlobalInfo();
/*
*
*/
public:
//从内存读取的方法 现在代码比较恶心,回头把ifstream 和 bufferIOStream 封装成一个类
bool open(void);
unsigned int checkFrames(BufferIOStream& p_kStrteam);
bool getAllFrames(BufferIOStream& p_kIOStream);
bool extractData(FRAME* p_pFrame, BufferIOStream& p_kStrteam);
private:
/*
功能 :检查文件中图象帧数。
参数 :ifs:对文件流的引用。
返回值:文件中图象帧数。
*/
unsigned int checkFrames(ifstream& p_kStrteam);
/*
功能 :将所有图象帧数据读入内存。
参数 :ifs:对文件流的引用。
返回值:操作是否成功,为真成功,为假失败。
*/
bool getAllFrames(ifstream& p_kStrteam);
/*
功能 :解压缩一帧图象数据。
参数 :f:指向用于保存图象数据的结构。
ifs:对文件流的引用。
返回值:操作是否成功,为真成功,为假失败。
*/
bool extractData(FRAME* p_pFrame, ifstream& p_kStrteam);
/*
功能 :初始化字符串表。
参数 :strTable:指向字符串表的指针。
rootSize:初始化的入口数。
返回值:操作是否成功,为真成功,为假失败。
*/
bool initStrTable(STRING_TABLE_ENTRY* p_pSTable, unsigned int p_nRootSize);
/*
功能 :在字符串表中增加一项。
参数 :strTable:指向字符串表的指针。
addIdx:增加的入口索引。
idx:用于构造要增加的字符串的入口索引。
c:用于构造要增加的字符串的字符。
返回值:操作是否成功,为真成功,为假失败。
*/
bool addStrTable(STRING_TABLE_ENTRY* p_pSTable, unsigned int p_nAddInedx, unsigned int p_nIndex, unsigned char p_cBuf);
public:
FRAME* m_vAllFrames; //指向所有图象帧的指针(inMem为真时用)
private:
GLOBAL_INFO m_kGInfo; //GIF文件的全局参数
FRAME m_kCurFrame; //当前帧的参数(inMem为假时用)
GCTRLEXT m_kCtrlExt; //图象扩展参数(读入数据时临时使用)
private:
BufferIOStream* m_pBufferIOStream; //用于读取内存的
ifstream m_kIOStream; //用于读文件的文件流
char m_sVersion[4]; //版本字符串
bool m_bError; //类实例变量创建时是否出错的标志
bool m_bOpened; //是否处于打开状态
bool m_bInMem; //图象数据是否一次读入内存
unsigned char m_vGColorTable[256 * 3]; //全局调色板
unsigned char m_vLColorTable[256 * 3]; //局部调色板(inMem为假时用)
streampos m_kDataStart; //保存文件流中图象数据开始的地方
unsigned int m_nCurIndex; //当前帧的索引(inMem为真时用)
};
}
//------------------------------------------------------------------------------
#endif //__JCGifImg_H__
//-----------------------------END FILE-------------------------------- | [
"775331175@qq.com"
] | 775331175@qq.com |
5e47aecb530c8df13b47b4bf197cca0016f9a74e | 3438e8c139a5833836a91140af412311aebf9e86 | /third_party/WebKit/Source/core/workers/WorkletBackingThreadHolder.h | 2f47c61734dda64b74139cabff3bdf08246560a3 | [
"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",
"MIT",
"Apache-2.0"
] | permissive | Exstream-OpenSource/Chromium | 345b4336b2fbc1d5609ac5a67dbf361812b84f54 | 718ca933938a85c6d5548c5fad97ea7ca1128751 | refs/heads/master | 2022-12-21T20:07:40.786370 | 2016-10-18T04:53:43 | 2016-10-18T04:53:43 | 71,210,435 | 0 | 2 | BSD-3-Clause | 2022-12-18T12:14:22 | 2016-10-18T04:58:13 | null | UTF-8 | C++ | false | false | 816 | h | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WorkletBackingThreadHolder_h
#define WorkletBackingThreadHolder_h
#include "core/CoreExport.h"
#include "wtf/PtrUtil.h"
namespace blink {
class WorkerBackingThread;
class WaitableEvent;
class CORE_EXPORT WorkletBackingThreadHolder {
public:
WorkerBackingThread* thread() { return m_thread.get(); }
protected:
explicit WorkletBackingThreadHolder(std::unique_ptr<WorkerBackingThread>);
virtual void initializeOnThread() = 0;
void shutdownAndWait();
void shutdownOnThread(WaitableEvent*);
std::unique_ptr<WorkerBackingThread> m_thread;
bool m_initialized;
};
} // namespace blink
#endif // WorkletBackingThreadHolder_h
| [
"support@opentext.com"
] | support@opentext.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.