blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2 values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905 values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 10.4M | extension stringclasses 115 values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1d466e6c23876c6dab4d9e7a76fc2bed45d0e653 | 150fcfbade19dadc4cca7f8fc2d70093173c293a | /WarmmingUPLast/WarmmingUPLast/Question5.cpp | 408b285a6b6ac7f2253a2990bef8810c214fc76b | [] | no_license | newmri/API | 4e369cc02db05bde7e646c8f8cf0d95652919484 | 7c1ab621239628332a9a791a4e36b352fb63e871 | refs/heads/master | 2021-01-19T20:31:12.222307 | 2017-04-30T11:57:52 | 2017-04-30T11:57:52 | 83,756,338 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,584 | cpp | #include "Question5.h"
Question5::Question5()
{
m_lvalue = 0;
m_rvalue = 0;
m_result = 0;
m_errchk = false;
}
void Question5::CheckError()
{
for (int i = 0; i < MAX_SIZE; ++i) {
if (1 & i == 1) {
if ('*' != m_equation[i] && '/' != m_equation[i] && '+' != m_equation[i] && '-' != m_equation[i]) {
m_errchk = true;
return;
}
}
else if(1 & i == 0){
if ('*' == m_equation[i] || '/' == m_equation[i] || '+' == m_equation[i] || '-' == m_equation[i]) {
m_errchk = true;
return;
}
}
}
}
bool Question5::GetEquation()
{
cout << "Input numbers: ";
cin >> m_equation;
CheckError();
if (m_errchk) {
cout << "Error has been ocuured bud! Ex) 1+2+3+4" << endl;
return false;
}
DevideEquation();
return true;
}
void Question5::DevideEquation()
{
for (int i = 0; i < MAX_SIZE; ++i) {
switch (m_equation[i]) {
case '*':
m_temparray[i - 1] = atoi(&m_equation[i - 1]);
m_temparray[i] = 7;
m_temparray[i + 1] = atoi(&m_equation[i + 1]);
break;
case '/':
m_temparray[i - 1] = atoi(&m_equation[i - 1]);
m_temparray[i] = 6;
m_temparray[i + 1] = atoi(&m_equation[i + 1]);
break;
case '+':
m_temparray[i - 1] = atoi(&m_equation[i - 1]);
m_temparray[i] = 5;
m_temparray[i + 1] = atoi(&m_equation[i + 1]);
break;
case '-':
m_temparray[i - 1] = atoi(&m_equation[i - 1]);
m_temparray[i] = 4;
m_temparray[i + 1] = atoi(&m_equation[i + 1]);
break;
}
}
unsigned int tmp{};
unsigned int tem2{};
for (int i = 0; i < MAX_SIZE; i++) {
for (int j = 0; j < MAX_SIZE - i - 1; j++) {
if (j & 1 == 1) {
if (m_temparray[j] < m_temparray[j + 2]) {
tmp = m_temparray[j];
m_temparray[j] = m_temparray[j + 2];
m_temparray[j + 2] = tmp;
tem2 = m_temparray[j - 1];
m_temparray[j - 1] = m_temparray[j + 1];
m_temparray[j + 1] = tem2;
tem2 = m_temparray[j +1];
m_temparray[j + 1] = m_temparray[j + 3];
m_temparray[j + 3] = tem2;
}
}
}
}
for (int i = 0; i < MAX_SIZE; ++i) {
cout << m_temparray[i] << endl;
}
//m_temparray[MAX_SIZE] = '\0';
//cout << m_temparray << endl;
}
void Question5::CalculateByOperator()
{
for (int i = 0; i < MAX_SIZE; ++i) {
if (!(2 & i == 1)) {
}
switch (m_temparray[1]) {
case '*':
m_result = m_lvalue*m_rvalue;
break;
case '/':
m_result = m_lvalue / m_rvalue;
break;
case '+':
m_result = m_lvalue + m_rvalue;
break;
case '-':
m_result = m_lvalue - m_rvalue;
break;
}
}
//cout << m_result << endl;
} | [
"newmri@naver.com"
] | newmri@naver.com |
f2b4c49dd586c1c70d57438b20956cfcc94097b7 | 22c9de6760dc2b99b0189b1ce3b836ed749c0e2d | /crux-toolkit-master/src/model/MatchCollection.h | 9494c68ef69c051bc75c535f3fd50942ddda9763 | [
"Apache-2.0"
] | permissive | jkubath/protein_research | 6a8df5d48582165063b5a6bfa9e24967424dada9 | 788b48545b402534d4782dd6b78a58a31d1120a7 | refs/heads/master | 2020-04-26T09:07:30.739950 | 2019-04-23T20:10:35 | 2019-04-23T20:10:35 | 173,444,748 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,772 | h | /**
* \file MatchCollection.h
* $Revision: 1.38 $
* \brief A set of peptide spectrum matches for one spectrum.
*
* Object for given a database and a spectrum, generate all match objects
* Creating a match collection generates all matches (searches a
* spectrum against a database.
*/
#ifndef MATCH_COLLECTION_H
#define MATCH_COLLECTION_H
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include <map>
#include <time.h>
#include "io/carp.h"
#include "Spectrum.h"
#include "io/SpectrumCollection.h"
#include "Ion.h"
#include "IonSeries.h"
#include "util/crux-utils.h"
#include "model/objects.h"
#include "parameter.h"
#include "Scorer.h"
#include "Match.h"
#include "PeptideSrc.h"
#include "ProteinIndex.h"
#include "util/modifications.h"
#include "ModifiedPeptidesIterator.h"
#include "io/MatchFileWriter.h"
#include "MatchIterator.h"
#include "io/PepXMLWriter.h"
using namespace std;
static const int _PSM_SAMPLE_SIZE = 500;
///< max number of peptides a single match collection can hold
class MatchCollection {
friend class MatchIterator;
protected:
std::vector<Crux::Match*> match_; ///< array of match object
int experiment_size_; ///< total matches before any truncation
int target_experiment_size_; ///< total target matches for same spectrum
SpectrumZState zstate_; ///< zstate of the associated spectrum
bool null_peptide_collection_; ///< are the peptides shuffled
bool scored_type_[NUMBER_SCORER_TYPES];
///< TRUE if matches have been scored by the type
SCORER_TYPE_T last_sorted_;
///< the last type by which it's been sorted ( -1 if unsorted)
bool iterator_lock_;
///< has an itterator been created? if TRUE can't manipulate matches
bool has_distinct_matches_; ///< does the match collection have distinct matches?
bool has_decoy_indexes_;
// Values for fitting the Weibull distribution
FLOAT_T eta_; ///< The eta parameter for the Weibull distribution.
FLOAT_T beta_; ///< The beta parameter for the Weibull distribution.
FLOAT_T shift_; ///< The location parameter for the Weibull distribution.
FLOAT_T correlation_; ///< The correlation parameter for the Weibull distribution.
vector<FLOAT_T> xcorrs_; ///< xcorrs to be used for weibull
// The following features (post_*) are only valid when
// post_process_collection boolean is true
bool post_process_collection_;
///< Is this a post process match_collection?
Crux::Match* top_scoring_sp_; ///< the match with Sp rank == 1
/**
* initializes a MatchCollection object
*/
void init();
public:
bool exact_pval_search_;
/**
* \brief Creates a new match collection with no matches in it. Sets
* member variables from parameter.c. The charge and null_collection
* variables are set with the method add_matches(). Search is
* conducted in add_matches().
*
* \returns A newly allocated match collection with member variables set.
*/
MatchCollection(bool is_decoy = false);
/**
* free the memory allocated match collection
*/
virtual ~MatchCollection();
/**
* sort the match collection by score_type(SP, XCORR, ... )
*\returns true, if successfully sorts the match_collection
*/
void sort(
SCORER_TYPE_T score_type ///< the score type (SP, XCORR) -in
);
/**
* Rank matches in a collection based on the given score type.
* Requires that match_collection was already scored for that score type.
* Rank 1, means highest score
* \returns true, if populates the match rank in the match collection
*/
bool populateMatchRank(
SCORER_TYPE_T score_type ///< the score type (SP, XCORR) -in
);
/**
* match_collection get, set method
*/
/**
*\returns true, if the match collection has been scored by score_type
*/
bool getScoredType(
SCORER_TYPE_T score_type ///< the score_type (MATCH_SP, MATCH_XCORR) -in
);
/**
* sets the score_type to value
*/
void setScoredType(
SCORER_TYPE_T score_type, ///< the score_type (MATCH_SP, MATCH_XCORR) -in
bool value
);
void getCustomScoreNames(
std::vector<std::string>& custom_score_names
);
void preparePostProcess();
/**
*\returns true, if there is a match_iterators instantiated by match collection
*/
bool getIteratorLock();
/**
*\returns the total match objects avaliable in current match_collection
*/
int getMatchTotal();
/**
* Sets the total peptides searched in the experiment in match_collection
*/
void setExperimentSize(int size);
/**
*\returns the total peptides searched in the experiment in match_collection
*/
int getExperimentSize();
/**
* Sets the total number of target peptides searched for this
* spectrum. Only to be used by decoy match collections.
*/
void setTargetExperimentSize(int numMatches);
/**
* \returns the number of target matches that this spectrum had.
* Different than getExperimentSize() for decoy match collections.
*/
int getTargetExperimentSize();
/**
* Set the filepath for all matches in the collection
* \returns the associated file idx
*/
int setFilePath(
const std::string& file_path, ///< File path to set
bool overwrite = false ///< Overwrite existing files?
);
/**
* \returns true if the match_collection only contains decoy matches,
* else (all target or mixed) returns false.
*/
bool isDecoy();
/**
*\returns the charge of the spectrum that the match collection was created
*/
int getCharge();
bool calculateDeltaCn();
// Take a vector of scores and return a vector of <deltaCn, deltaLCn>
static std::vector< std::pair<FLOAT_T, FLOAT_T> > calculateDeltaCns(
std::vector<FLOAT_T>, SCORER_TYPE_T type);
/**
* \brief Transfer the Weibull distribution parameters, including the
* correlation from one match_collection to another. No check to see
* that the parameters have been estimated.
*/
static void transferWeibull(
MatchCollection* from_collection,
MatchCollection* to_collection
);
/**
* \brief Add a single match to a collection.
* Only puts a copy of the pointer to the match in the
* match_collection, does not allocate a new match.
*/
bool addMatch(
Crux::Match* match ///< add this match
);
/**
* \brief Print the given match collection for one spectrum to all
* appropriate files.
*/
void print(
Crux::Spectrum* spectrum,
bool is_decoy,
FILE* psm_file,
FILE* sqt_file,
FILE* decoy_file,
FILE* tab_file,
FILE* decoy_tab_file
);
/**
* \brief Print the given match collection for several spectra to all
* appropriate files. Takes the spectrum information from the matches
* in the collection.
*/
void printMultiSpectra(
MatchFileWriter* tab_file,
MatchFileWriter* decoy_tab_file
);
/**
* \brief Print the given match collection for several spectra to
* xml files only. Takes the spectrum information from the
* matches in the collection. At least for now, prints all matches in
* the collection rather than limiting by top-match parameter.
*/
void printMultiSpectraXml(
PepXMLWriter* output
);
/*
* Print the XML file header
*/
static void printXmlHeader(FILE* outfile, const string& ms2file);
/*
* Print the SQT file header
*/
static void printSqtHeader(
FILE* outfile,
const char* type,
string database,
int num_proteins,
bool exact_pval_search_ = false
);
/*
* Print the tab delimited file header
*/
static void printTabHeader(
FILE* outfile
);
/*
* Print the XML file footer
*/
static void printXmlFooter(
FILE* outfile
);
/**
* Print the psm features to output file up to 'top_match' number of
* top peptides among the match_collection in xml file format
* returns true, if sucessfully print xml format of the PSMs, else false
*/
bool printXml(
PepXMLWriter* output,
int top_match,
Crux::Spectrum* spectrum,
SCORER_TYPE_T main_score
);
/**
* Print the psm features to output file upto 'top_match' number of
* top peptides among the match_collection in sqt file format
*\returns true, if sucessfully print sqt format of the PSMs, else false
*/
bool printSqt(
FILE* output, ///< the output file -out
int top_match, ///< the top matches to output -in
Crux::Spectrum* spectrum ///< the spectrum to print sqt -in
);
/**
* Print the psm features to output file upto 'top_match' number of
* top peptides among the match_collection in tab delimited file format
*\returns true, if sucessfully print sqt format of the PSMs, else false
*/
bool printTabDelimited(
MatchFileWriter* output, ///< the output file -out
int top_match, ///< the top matches to output -in
Crux::Spectrum* spectrum, ///< the spectrum to print sqt -in
SCORER_TYPE_T main_score ///< the main score to report -in
);
/**
* Retrieve the calibration parameter eta.
*/
FLOAT_T getCalibrationEta();
/**
* Retrieve the calibration parameter beta.
*/
FLOAT_T getCalibrationBeta();
/**
* Retrieve the calibration parameter shift.
*/
FLOAT_T getCalibrationShift();
/**
* Retrieve the calibration parameter correlation.
*/
FLOAT_T getCalibrationCorr();
bool getHasDistinctMatches();
void setHasDistinctMatches(bool distinct_matches);
bool hasDecoyIndexes() const;
void setHasDecoyIndexes(bool value);
/**
* Try setting the match collection's zstate. Successful if the
* current charge is 0 (i.e. hasn't yet been set) or if the current
* charge is the same as the given value. Otherwise, returns false
*
* \returns true if the match_collection's zstate was changed.
*/
bool setZState(
SpectrumZState& zstate ///< new zstate
);
/**
* Extract a given type of score into a vector.
*/
std::vector<FLOAT_T> extractScores(
SCORER_TYPE_T score_type ///< Type of score to extract.
) const;
/**
* Given a hash table that maps from a score to its q-value, assign
* q-values to all of the matches in a given collection.
*/
void assignQValues(
const map<FLOAT_T, FLOAT_T>* score_to_qvalue_hash,
SCORER_TYPE_T score_type,
SCORER_TYPE_T derived_score_type
);
/*******************************************
* match_collection post_process extension
******************************************/
bool addMatchToPostMatchCollection(Crux::Match* match);
};
#endif
/*
* Local Variables:
* mode: c
* c-basic-offset: 2
* End:
*/
| [
"jkubath1@gmail.com"
] | jkubath1@gmail.com |
2dfad14998c8ae2b7ba34679723111c09e23fed3 | 4857d86e09d369f686cac2f8ae83b6ea28ce890f | /Engine/Input/InputSystem.cpp | b357544aaccc9b98de9e2eef402d395266ed4fbd | [] | no_license | Ghostninja2451/GAT150 | 423cdf4f689acd4c867a49aedd0b7758905689c5 | bde4f0f859c68f804eb16ffe7eb064c50c7e664a | refs/heads/master | 2023-07-20T19:58:48.593201 | 2021-08-17T21:41:49 | 2021-08-17T21:41:49 | 392,098,386 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,836 | cpp | #include "InputSystem.h"
namespace henry
{
void InputSystem::Startup()
{
const Uint8* keyboardStateSDL = SDL_GetKeyboardState(&numKeys);
keyboardState.resize(numKeys);
std::copy(keyboardStateSDL, keyboardStateSDL + numKeys, keyboardState.begin());
prevKeyboardState = keyboardState;
}
void InputSystem::Shutdown()
{
}
void InputSystem::Update(float dt)
{
prevKeyboardState = keyboardState;
const Uint8* keyboardStateSDL = SDL_GetKeyboardState(nullptr);
std::copy(keyboardStateSDL, keyboardStateSDL + numKeys, keyboardState.begin());
prevMouseButtonState = mouseButtonState;
int x, y;
Uint32 buttons = SDL_GetMouseState(&x, &y);
mousePosition = henry::Vector2{ x, y };
mouseButtonState[0] = buttons & SDL_BUTTON_LMASK; // buttons [0001] & [ORML]
mouseButtonState[1] = buttons & SDL_BUTTON_MMASK; // buttons [0010] & [ORML]
mouseButtonState[2] = buttons & SDL_BUTTON_RMASK; // buttons [0100] & [ORML]
}
InputSystem::eKeyState InputSystem::GetKeyState(int id)
{
eKeyState state = eKeyState::Idle;
bool keyDown = IsKeyDown(id);
bool prevKeyDown = IsPreviousKeyDown(id);
if (keyDown)
{
state = (prevKeyDown) ? eKeyState::Held : eKeyState::Pressed ;
}
else
{
state = (prevKeyDown) ? eKeyState::Release: eKeyState::Idle;
}
return state;
}
bool InputSystem::IsKeyDown(int id)
{
return keyboardState[id];
}
bool InputSystem::IsPreviousKeyDown(int id)
{
return prevKeyboardState[id];
}
InputSystem::eKeyState InputSystem::GetButtonState(int id)
{
eKeyState state = eKeyState::Idle;
bool keyDown = IsButtonDown(id);
bool prevKeyDown = IsPrevButtonDown(id);
if (keyDown)
{
state = (prevKeyDown) ? eKeyState::Held : eKeyState::Pressed;
}
else
{
state = (prevKeyDown) ? eKeyState::Release : eKeyState::Idle;
}
return state;
}
}
| [
"80051664+Ghostninja2451@users.noreply.github.com"
] | 80051664+Ghostninja2451@users.noreply.github.com |
e3f0645e97848f949f603beedd3aa97e6cc6c0f9 | 2b67f9827514224900469bc111f07f3f7aaec525 | /10.cpp | c9b08bdd81286a59af4bcf52cf1072763217a454 | [] | no_license | ZoeVonFeng/Project_Euler | b3c39aab02e7c54463a98371ac668b22f9214364 | c294088a7dd13ba57b781521d6bde5c5b0b5a40c | refs/heads/master | 2021-06-14T05:07:20.381498 | 2017-05-02T05:21:06 | 2017-05-02T05:21:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 613 | cpp | /*The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million. */
#include <iostream>
#include <cmath>
using namespace std;
bool is_prime(unsigned long long);
int main ()
{
unsigned long long sum = 0;
for (unsigned long long i = 2; i < 2000000; ++i)
if (is_prime(i))
sum += i;
cout << "Sum = " << sum << endl;
}
bool is_prime(unsigned long long n)
{
unsigned long long i,sq,count=0;
if(n==1 || n==2)
return true;
if(n%2==0)
return false;
sq=sqrt(n);
for(i=2;i<=sq;i++)
{
if(n%i==0)
return false;
}
return true;
}
| [
"ziyi.feng@sjsu.edu"
] | ziyi.feng@sjsu.edu |
d7724365595f6cd059e254dd8ec894db3124ece4 | 41d6b7e3b34b10cc02adb30c6dcf6078c82326a3 | /src/plugins/poshuku/plugins/dcac/ssecommon.h | 478baa151f1e718f54072dc9fe5778d93bbe5ad8 | [
"BSL-1.0"
] | permissive | ForNeVeR/leechcraft | 1c84da3690303e539e70c1323e39d9f24268cb0b | 384d041d23b1cdb7cc3c758612ac8d68d3d3d88c | refs/heads/master | 2020-04-04T19:08:48.065750 | 2016-11-27T02:08:30 | 2016-11-27T02:08:30 | 2,294,915 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,296 | h | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2014 Georg Rudoy
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#pragma once
#include <util/sll/intseq.h>
namespace LeechCraft
{
namespace Poshuku
{
namespace DCAC
{
template<int Alignment, typename F>
void HandleLoopBegin (const uchar * const scanline, int width, int& x, int& bytesCount, F&& f)
{
const auto beginUnaligned = (scanline - static_cast<const uchar*> (nullptr)) % Alignment;
bytesCount = width * 4;
if (beginUnaligned)
{
x += Alignment - beginUnaligned;
bytesCount -= Alignment - beginUnaligned;
for (int i = 0; i < Alignment - beginUnaligned; i += 4)
f (i);
}
bytesCount -= bytesCount % Alignment;
}
template<typename F>
void HandleLoopEnd (int width, int x, F&& f)
{
for (int i = x; i < width * 4; i += 4)
f (i);
}
template<char From, char To, char ByteNum, char BytesPerElem>
struct GenSeq;
template<char From, char To, char ByteNum, char BytesPerElem>
using EpiSeq = typename GenSeq<From, To, ByteNum, BytesPerElem>::type;
template<char From, char To, char ByteNum, char BytesPerElem>
struct GenSeq
{
using type = Util::IntSeq::Concat<EpiSeq<From, From, ByteNum, BytesPerElem>, EpiSeq<From - 1, To, ByteNum, BytesPerElem>>;
};
template<char E, char ByteNum, char BytesPerElem>
struct GenSeq<E, E, ByteNum, BytesPerElem>
{
using type = Util::IntSeq::Concat<
Util::IntSeq::Repeat<uchar, 0x80, BytesPerElem - ByteNum - 1>,
std::integer_sequence<uchar, E>,
Util::IntSeq::Repeat<uchar, 0x80, ByteNum>
>;
};
template<size_t BytesCount, size_t Bucket, char ByteNum, char BytesPerElem>
struct GenRevSeqS
{
static constexpr uchar EndValue = BytesCount * BytesPerElem - BytesPerElem;
static constexpr auto TotalCount = BytesCount * BytesPerElem;
static constexpr auto BeforeEmpty = BytesCount * Bucket;
static constexpr auto AfterEmpty = TotalCount - BytesCount - BeforeEmpty;
static_assert (AfterEmpty >= 0, "negative sequel size");
static_assert (BeforeEmpty >= 0, "negative prequel size");
template<uchar... Is>
static auto BytesImpl (std::integer_sequence<uchar, Is...>)
{
return std::integer_sequence<uchar, (EndValue - Is * BytesPerElem + ByteNum)...> {};
}
using type = Util::IntSeq::Concat<
Util::IntSeq::Repeat<uchar, 0x80, AfterEmpty>,
decltype (BytesImpl (std::make_integer_sequence<uchar, BytesCount> {})),
Util::IntSeq::Repeat<uchar, 0x80, BeforeEmpty>
>;
};
template<size_t BytesCount, size_t Bucket, char ByteNum, char BytesPerElem>
using GenRevSeq = typename GenRevSeqS<BytesCount, Bucket, ByteNum, BytesPerElem>::type;
template<uint16_t>
struct Tag {};
template<uchar... Is>
auto MakeMaskImpl (Tag<128>, std::integer_sequence<uchar, Is...>)
{
return _mm_set_epi8 (Is...);
}
template<uchar... Is>
__attribute__ ((target ("avx")))
auto MakeMaskImpl (Tag<256>, std::integer_sequence<uchar, Is...>)
{
return _mm256_set_epi8 (Is..., Is...);
}
template<uint32_t Bits, char From, char To, char ByteNum = 0>
auto MakeMask ()
{
constexpr char BytesPerElem = 16 / (From - To + 1);
return MakeMaskImpl (Tag<Bits> {}, EpiSeq<From, To, ByteNum, BytesPerElem> {});
}
template<uchar... Is>
auto MakeRevMaskImpl (Tag<128>, std::integer_sequence<uchar, Is...>)
{
return _mm_set_epi8 (Is...);
}
template<uchar... Is>
__attribute__ ((target ("avx")))
auto MakeRevMaskImpl (Tag<256>, std::integer_sequence<uchar, Is...>)
{
return _mm256_set_epi8 (Is..., Is...);
}
template<uint32_t Bits, size_t BytesCount, size_t Bucket, char ByteNum = 0>
auto MakeRevMask ()
{
constexpr char BytesPerElem = 16 / BytesCount;
return MakeRevMaskImpl (Tag<Bits> {}, GenRevSeq<BytesCount, Bucket, ByteNum, BytesPerElem> {});
}
}
}
}
| [
"0xd34df00d@gmail.com"
] | 0xd34df00d@gmail.com |
18ac75857656d2c584a1eef0a0d1d6cce7f379a5 | 752562564130a952c145ed053b0171cfa0b2501f | /include/foonathan/lex/parser.hpp | d3da46d5d41a1f75487c40a596a671d23d4b9c71 | [
"BSL-1.0"
] | permissive | foonathan/lex | 81e9c3d5c2d70f5cbc980a5b9e6f29f7389fc7b0 | 2d0177d453f8c36afc78392065248de0b48c1e7d | refs/heads/master | 2021-06-28T14:20:02.766922 | 2020-12-01T13:54:18 | 2020-12-01T13:54:18 | 148,897,732 | 145 | 10 | NOASSERTION | 2018-10-17T14:58:40 | 2018-09-15T11:55:07 | C++ | UTF-8 | C++ | false | false | 2,315 | hpp | // Copyright (C) 2018-2019 Jonathan Müller <jonathanmueller.dev@gmail.com>
// This file is subject to the license terms in the LICENSE file
// found in the top-level directory of this distribution.
#ifndef FOONATHAN_LEX_PARSER_HPP_INCLUDED
#define FOONATHAN_LEX_PARSER_HPP_INCLUDED
#include <foonathan/lex/grammar.hpp>
#include <foonathan/lex/parse_error.hpp>
#include <foonathan/lex/parse_result.hpp>
#include <foonathan/lex/tokenizer.hpp>
namespace foonathan
{
namespace lex
{
namespace detail
{
template <class Token, class TokenSpec>
constexpr auto parse_token_impl(int, token<TokenSpec> token)
-> static_token<Token, decltype(Token::parse(token))>
{
using type = static_token<Token, decltype(Token::parse(token))>;
return type(token, Token::parse(token));
}
template <class Token, class TokenSpec>
constexpr auto parse_token_impl(short, token<TokenSpec> token)
{
return static_token<Token>(token);
}
template <class Token, class TokenSpec>
constexpr auto parse_token(token<TokenSpec> token)
{
return parse_token_impl<Token>(0, token);
}
} // namespace detail
template <class Grammar, class Func>
constexpr auto parse(tokenizer<typename Grammar::token_spec>& tokenizer, Func&& f)
{
auto result = Grammar::start::parse(tokenizer, f);
if (result.is_success() && !tokenizer.is_done())
{
unexpected_token<Grammar, typename Grammar::start, eof_token>
error(typename Grammar::start{}, eof_token{});
detail::report_error(f, error, tokenizer);
}
return result;
}
template <class Grammar, class Func>
constexpr auto parse(const char* str, std::size_t size, Func&& f)
{
tokenizer<typename Grammar::token_spec> tok(str, size);
return parse<Grammar>(tok, static_cast<Func&&>(f));
}
template <class Grammar, class Func>
constexpr auto parse(const char* begin, const char* end, Func&& f)
{
tokenizer<typename Grammar::token_spec> tok(begin, end);
return parse<Grammar>(tok, static_cast<Func&&>(f));
}
} // namespace lex
} // namespace foonathan
#endif // FOONATHAN_LEX_PARSER_HPP_INCLUDED
| [
"git@foonathan.net"
] | git@foonathan.net |
027923fb25f6170457c5c52d75a4ca31e55f7f6a | b7388fa0fe9912e8b24a62fe9255f698af17079b | /pheet/ds/CircularArray/TwoLevelGrowing/TwoLevelGrowingCircularArray.h | 1f36234bdbd1d09ae23a00219030ca6a2f16770d | [] | no_license | ginkgo/AMP-LockFreeSkipList | 2764b4f528ac6969f21ee3fd0e2ba2444d36e04c | dc68750f5c9fd6d2491e656161ac7c8073f5389c | refs/heads/master | 2021-01-20T07:50:51.818369 | 2014-07-01T01:21:04 | 2014-07-01T01:21:04 | 20,526,178 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,259 | h | /*
* TwoLevelGrowingCircularArray.h
*
* Created on: 12.04.2011
* Author: Martin Wimmer
* License: Boost Software License 1.0 (BSL1.0)
*/
#ifndef TWOLEVELGROWINGCIRCULARARRAY_H_
#define TWOLEVELGROWINGCIRCULARARRAY_H_
#include <pheet/settings.h>
#include <pheet/misc/bitops.h>
namespace pheet {
template <class Pheet, typename TT, size_t MaxBuckets = 32>
class TwoLevelGrowingCircularArrayImpl {
public:
typedef TT T;
template<size_t NewVal>
using WithMaxBuckets = TwoLevelGrowingCircularArrayImpl<Pheet, TT, NewVal>;
TwoLevelGrowingCircularArrayImpl();
TwoLevelGrowingCircularArrayImpl(size_t initial_capacity);
~TwoLevelGrowingCircularArrayImpl();
size_t get_capacity();
bool is_growable();
// return value NEEDS to be const. When growing we cannot guarantee that the reference won't change
T const& get(size_t i);
void put(size_t i, T value);
void grow(size_t bottom, size_t top);
private:
const size_t initial_buckets;
size_t buckets;
size_t capacity;
T* data[MaxBuckets];
};
template <class Pheet, typename T, size_t MaxBuckets>
TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::TwoLevelGrowingCircularArrayImpl()
: initial_buckets(5), buckets(initial_buckets), capacity(1 << (buckets - 1)) {
pheet_assert(buckets <= MaxBuckets);
T* ptr = new T[capacity];
data[0] = ptr;
ptr++;
for(size_t i = 1; i < buckets; i++)
{
data[i] = ptr;
ptr += 1 << (i - 1);
}
}
template <class Pheet, typename T, size_t MaxBuckets>
TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::TwoLevelGrowingCircularArrayImpl(size_t initial_capacity)
: initial_buckets(find_last_bit_set(initial_capacity - 1) + 1), buckets(initial_buckets), capacity(1 << (buckets - 1)) {
pheet_assert(initial_capacity > 0);
pheet_assert(buckets <= MaxBuckets);
T* ptr = new T[capacity];
data[0] = ptr;
ptr++;
for(size_t i = 1; i < buckets; i++)
{
data[i] = ptr;
ptr += 1 << (i - 1);
}
}
template <class Pheet, typename T, size_t MaxBuckets>
TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::~TwoLevelGrowingCircularArrayImpl() {
delete[] (data[0]);
for(size_t i = initial_buckets; i < buckets; i++)
delete [](data[i]);
}
template <class Pheet, typename T, size_t MaxBuckets>
size_t TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::get_capacity() {
return capacity;
}
template <class Pheet, typename T, size_t MaxBuckets>
bool TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::is_growable() {
return buckets < MaxBuckets;
}
// return value NEEDS to be const. When growing we cannot guarantee that the reference won't change
template <class Pheet, typename T, size_t MaxBuckets>
inline T const& TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::get(size_t i) {
i = i % capacity;
size_t hb = find_last_bit_set(i);
return data[hb][i ^ ((1 << (hb)) >> 1)];
}
template <class Pheet, typename T, size_t MaxBuckets>
void TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::put(size_t i, T value) {
i = i % capacity;
size_t hb = find_last_bit_set(i);
data[hb][i ^ ((1 << (hb)) >> 1)] = value;
}
template <class Pheet, typename T, size_t MaxBuckets>
void TwoLevelGrowingCircularArrayImpl<Pheet, T, MaxBuckets>::grow(size_t bottom, size_t top) {
pheet_assert(is_growable());
data[buckets] = new T[capacity];
buckets++;
size_t newCapacity = capacity << 1;
size_t start = top;
size_t startMod = top % capacity;
if(startMod == (top % newCapacity))
{ // Make sure we don't iterate through useless indices
start += capacity - startMod;
}
for(size_t i = start; i < bottom; i++) {
size_t oldI = i % capacity;
size_t newI = i % newCapacity;
if(oldI != newI)
{
size_t oldBit = find_last_bit_set(oldI);
size_t newBit = find_last_bit_set(newI);
data[newBit][newI ^ ((1 << (newBit)) >> 1)] =
data[oldBit][oldI ^ ((1 << (oldBit)) >> 1)];
}
else
{ // Make sure we don't iterate through useless indices
break;
}
}
// Do we really need this? I guess we have to ensure that threads don't have
// some senseless pointers in their data array
MEMORY_FENCE ();
capacity = newCapacity;
}
template<class Pheet, typename TT>
using TwoLevelGrowingCircularArray = TwoLevelGrowingCircularArrayImpl<Pheet, TT>;
}
#endif /* TWOLEVELGROWINGCIRCULARARRAY_H_ */
| [
"weber.t@cg.tuwien.at"
] | weber.t@cg.tuwien.at |
4cb43716d084c5fce066041e2e1507e9be8c2ec6 | 628aca1e8bf74174e7cde5bec365042240d3aaf7 | /test/obj_develop/obj_develop/01_domain.cpp | 48f9d4534f93308decdfedeadfd0e2668450b024 | [
"Apache-2.0"
] | permissive | nvoronetskiy/obj | bbbdf59b745a33d1b7532a1bd078782b58aa6dbe | f44c4c71310b0be70e51c2759662dd04e32c747a | refs/heads/main | 2023-03-19T22:00:41.674227 | 2021-03-07T20:51:43 | 2021-03-07T20:51:43 | 345,824,025 | 0 | 0 | Apache-2.0 | 2021-03-08T23:28:24 | 2021-03-08T23:28:23 | null | UTF-8 | C++ | false | false | 5,517 | cpp | // Copyright 2016 Aether authors. All Rights Reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// =============================================================================
#include <iostream>
#include <fstream>
#include <map>
#include <set>
#include <filesystem>
#include "../../../aether/obj/obj.h"
// * - domain initially loaded
// # - domain initially unloaded
// 0 - zero pointer
// B0 - class B, instance 0
// () - class factory
// ZeroObjPointers: nullptr reference to the object
// A0*
// |-B = 0
// SingleObjReference
// A0*
// |-B0
// BaseClassReference: serialization/deserialization through reference to the base class
// A0*
// |-B0 (Obj::ptr)
// MultipleObjReference: referencing different objects of a single class
// A0*
// |-B0
// |-B1
// Hierarchy
// A0*
// |-B0
// |-C0
// HierachichalDomains
// A0*
// |-B*
// |-C0*
// |-C1#
// SharedReference: C0 is referenced twice
// A0*
// |-C0
// |-C0
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// SharedReference: C0 is referenced with child domain
// A0*
// |-C0
// |-B0*
// |-C0
// CrossRerefenceDifferentLevel
// A0*
// |-B0
// |-A0
// CrossRerefenceSameLevel
// A0*
// |-B0
// |-B1
// |-B1
// |-B0
// LoadUnload: the state is saved/restored
// Cross references within a single level
// Cross references with different level
// A0*
// |-C0
// |-B0#
// |-C0
// |-B0
// |-C1
// |-C1
// |-C0
/*
#include <fstream>
static std::unordered_map<aether::ObjStorage, std::string> storage_to_path_;
static auto saver = [](const std::string& path, aether::ObjStorage storage, const AETHER_OMSTREAM& os){
std::filesystem::create_directories(std::filesystem::path{"state"} / storage_to_path_[storage]);
auto p = std::filesystem::path{"state"} / storage_to_path_[storage] / path;
std::ofstream f(p.c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
// bool b = f.good();
f.write((const char*)os.stream_.data(), os.stream_.size());
std::cout << p.c_str() << " size: " << os.stream_.size() << "\n";
};
static auto loader = [](const std::string& path, aether::ObjStorage storage, AETHER_IMSTREAM& is){
auto p = std::filesystem::path{"state"} / storage_to_path_[storage] / path;
std::ifstream f(p.c_str(), std::ios::in | std::ios::binary);
f.seekg (0, f.end);
std::streamoff length = f.tellg();
f.seekg (0, f.beg);
is.stream_.resize(length);
f.read((char*)is.stream_.data(), length);
};
class B : public aether::Obj {
public:
AETHER_CLS(B);
AETHER_SERIALIZE(B);
AETHER_INTERFACES(B);
B() = default;
B(float f) : f_(f) {}
virtual ~B() { std::cout << "~B[ " << id_.ToString() << " ]: " << f_ << "\n"; }
float f_;
std::vector<B::ptr> o_;
template <typename T> void Serializator(T& s, int flags) {
s & f_ & o_;
}
};
AETHER_IMPL(B);
class Root : public aether::Obj {
public:
AETHER_CLS(Root);
AETHER_SERIALIZE(Root);
AETHER_INTERFACES(Root);
Root() = default;
Root(int i) : i_(i) {}
virtual ~Root() { std::cout << "~Root " << i_ << "\n"; }
int i_;
std::vector<B::ptr> o_;
template <typename T> void Serializator(T& s, int flags) {
s & i_ & o_;
}
};
AETHER_IMPL(Root);
void DomainTest() {
std::filesystem::remove_all("state");
// {
// Root::ptr root(new Root(123));
// root.SetFlags(aether::ObjFlags::kLoadable | aether::ObjFlags::kLoaded);
// B::ptr b(new B(2.71f));
// B::ptr b2(new B(3.14f));
// b->o_.push_back(b2);
// b2->o_.push_back(b);
// root->o_.push_back(b);
// root->o_.push_back(b2);
// b = nullptr;
// b2 = nullptr;
// root.Serialize(saver, aether::Obj::Serialization::kConsts | aether::Obj::Serialization::kRefs | aether::Obj::Serialization::kData);
// root.Unload();
// Root::ptr r1 = root.Clone(loader);
// int sdf=0;
// root = nullptr;
// r1 = nullptr;
// }
Root::ptr root(new Root(123));
root.SetId(666);
{
B::ptr b1(new B(2.71f));
b1->o_.push_back({});
B::ptr b2(new B(3.14f));
b2.SetFlags(aether::ObjFlags::kLoadable | aether::ObjFlags::kLoaded);
b2->o_.push_back(b1);
b1->o_.push_back(b2);
root->o_.push_back(b2);
root->o_.push_back({});
// root->o_.push_back(b1);
}
{
root->o_[0].Serialize(saver, aether::Obj::Serialization::kConsts | aether::Obj::Serialization::kRefs | aether::Obj::Serialization::kData);
root->o_[0].Unload();
root.Serialize(saver, aether::Obj::Serialization::kConsts | aether::Obj::Serialization::kRefs | aether::Obj::Serialization::kData);
root = nullptr;
int sdf=0;
}
{
std::cout << "Restoring...\n";
Root::ptr root;
root.SetId(666);
root.SetFlags(aether::ObjFlags::kLoaded);
root.Load(loader);
B::ptr r1 = root->o_[0].Clone(loader);
B::ptr r2 = root->o_[0].Clone(loader);
root->o_.push_back(r2);
root->o_[0].Load(loader);
r1 = nullptr;
r2 = nullptr;
root.Unload();
int sfd=0;
}
}
*/
| [
"aethernetio@gmail.com"
] | aethernetio@gmail.com |
2d3e34fb92d7efa079940b12150b540f88985856 | 8e4f0c31c5ddc1eef16a61bf359a043b8cb3a6c3 | /src/agent/jvm_readers_factory.cc | 62759a9454adee39aec14771993e70fe21e517d4 | [
"Apache-2.0"
] | permissive | botdevops/cloud-debug-java | 22d90d8a95402cd4ffd96b9eeb41fdafd806b4a4 | b18ab8cfec4b70dee6c5b1e28e4e35d00e33ae9c | refs/heads/master | 2021-06-15T01:14:56.926516 | 2017-03-29T21:04:31 | 2017-03-29T21:56:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,728 | cc | /**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "jvm_readers_factory.h"
#include <algorithm>
#include "class_indexer.h"
#include "class_metadata_reader.h"
#include "class_path_lookup.h"
#include "jvm_object_array_reader.h"
#include "jvm_primitive_array_reader.h"
#include "jvmti_buffer.h"
#include "messages.h"
#include "method_locals.h"
#include "model.h"
#include "safe_method_caller.h"
#include "type_util.h"
namespace devtools {
namespace cdbg {
JvmReadersFactory::JvmReadersFactory(
JvmEvaluators* evaluators,
jmethodID method,
jlocation location)
: evaluators_(evaluators),
method_(method),
location_(location) {
}
string JvmReadersFactory::GetEvaluationPointClassName() {
jvmtiError err = JVMTI_ERROR_NONE;
jclass cls = nullptr;
err = jvmti()->GetMethodDeclaringClass(method_, &cls);
if (err != JVMTI_ERROR_NONE) {
LOG(ERROR) << "GetMethodDeclaringClass failed, error: " << err;
return string();
}
JniLocalRef auto_cls(cls);
JvmtiBuffer<char> class_signature_buffer;
err = jvmti()->GetClassSignature(
cls,
class_signature_buffer.ref(),
nullptr);
if (err != JVMTI_ERROR_NONE) {
LOG(ERROR) << "GetClassSignature failed, error: " << err;
return string();
}
return TypeNameFromJObjectSignature(class_signature_buffer.get());
}
JniLocalRef JvmReadersFactory::FindClassByName(
const string& class_name,
FormatMessageModel* error_message) {
ClassIndexer* class_indexer = evaluators_->class_indexer;
JniLocalRef cls;
*error_message = {};
// Case 1: class name is fully qualified (i.e. includes the package name)
// and has been already loaded by the JVM.
cls = class_indexer->FindClassByName(class_name);
if (cls != nullptr) {
return cls;
}
// Case 2: class name is relative to "java.lang" package. We assume that
// the class has been already loaded in this case.
cls = class_indexer->FindClassByName("java.lang." + class_name);
if (cls != nullptr) {
return cls;
}
// Case 3: class name is relative to the current scope.
string current_class_name = GetEvaluationPointClassName();
size_t name_pos = current_class_name.find_last_of('.');
if ((name_pos > 0) && (name_pos != string::npos)) {
cls = class_indexer->FindClassByName(
current_class_name.substr(0, name_pos + 1) + class_name);
if (cls != nullptr) {
return cls;
}
}
// Case 4: the class is either unqualified (i.e. doesn't include the package
// name) or hasn't been loaded yet. Note that this will not include JDK
// classes (like java.lang.String). These classes are usually loaded very
// eary and we don't want to waste resources indexing all of them.
std::vector<string> candidates =
evaluators_->class_path_lookup->FindClassesByName(class_name);
std::sort(candidates.begin(), candidates.end());
switch (candidates.size()) {
case 0:
*error_message = { InvalidIdentifier, { class_name } };
return nullptr;
case 1:
cls = class_indexer->FindClassBySignature(candidates[0]);
if (cls != nullptr) {
return cls;
}
*error_message = {
ClassNotLoaded,
{ TypeNameFromJObjectSignature(candidates[0]) }
};
return nullptr;
case 2:
*error_message = {
AmbiguousClassName2,
{
class_name,
TypeNameFromJObjectSignature(candidates[0]),
TypeNameFromJObjectSignature(candidates[1])
}
};
return nullptr;
case 3:
*error_message = {
AmbiguousClassName3,
{
class_name,
TypeNameFromJObjectSignature(candidates[0]),
TypeNameFromJObjectSignature(candidates[1]),
TypeNameFromJObjectSignature(candidates[2])
}
};
return nullptr;
default:
*error_message = {
AmbiguousClassName4OrMore,
{
class_name,
TypeNameFromJObjectSignature(candidates[0]),
TypeNameFromJObjectSignature(candidates[1]),
TypeNameFromJObjectSignature(candidates[2]),
std::to_string(candidates.size() - 3)
}
};
return nullptr;
}
}
bool JvmReadersFactory::IsAssignable(
const string& from_signature,
const string& to_signature) {
ClassIndexer* class_indexer = evaluators_->class_indexer;
// Currently array types not supported in this function.
if (IsArrayObjectSignature(from_signature) ||
IsArrayObjectSignature(to_signature)) {
return false;
}
// Get the class object corresponding to "from_signature".
JniLocalRef from_cls = class_indexer->FindClassBySignature(from_signature);
if (from_cls == nullptr) {
return false;
}
// Get the class object corresponding to "to_signature".
JniLocalRef to_cls = class_indexer->FindClassBySignature(to_signature);
if (to_cls == nullptr) {
return false;
}
return jni()->IsAssignableFrom(
static_cast<jclass>(from_cls.get()),
static_cast<jclass>(to_cls.get()));
}
std::unique_ptr<LocalVariableReader>
JvmReadersFactory::CreateLocalVariableReader(
const string& variable_name,
FormatMessageModel* error_message) {
std::shared_ptr<const MethodLocals::Entry> method =
evaluators_->method_locals->GetLocalVariables(method_);
for (const std::unique_ptr<LocalVariableReader>& local : method->locals) {
if (local->IsDefinedAtLocation(location_) &&
(variable_name == local->GetName())) {
return local->Clone();
}
}
return nullptr;
}
std::unique_ptr<LocalVariableReader>
JvmReadersFactory::CreateLocalInstanceReader() {
std::shared_ptr<const MethodLocals::Entry> method =
evaluators_->method_locals->GetLocalVariables(method_);
if (method->local_instance == nullptr) {
return nullptr;
}
return method->local_instance->Clone();
}
std::unique_ptr<InstanceFieldReader>
JvmReadersFactory::CreateInstanceFieldReader(
const string& class_signature,
const string& field_name,
FormatMessageModel* error_message) {
JniLocalRef cls =
evaluators_->class_indexer->FindClassBySignature(class_signature);
if (cls == nullptr) {
// JVM does not defer loading field types, so it should never happen.
LOG(WARNING) << "Class not found: " << class_signature;
*error_message = {
ClassNotLoaded,
{ TypeNameFromJObjectSignature(class_signature) }
};
return nullptr;
}
const ClassMetadataReader::Entry& metadata =
evaluators_->class_metadata_reader->GetClassMetadata(
static_cast<jclass>(cls.get()));
for (const auto& field : metadata.instance_fields) {
if (field->GetName() == field_name) {
return field->Clone();
}
}
*error_message = {
InstanceFieldNotFound,
{ field_name, TypeNameFromJObjectSignature(class_signature) }
};
return nullptr; // No instance field named "field_name" found Java class.
}
std::unique_ptr<StaticFieldReader> JvmReadersFactory::CreateStaticFieldReader(
const string& field_name,
FormatMessageModel* error_message) {
jvmtiError err = JVMTI_ERROR_NONE;
jclass cls = nullptr;
err = jvmti()->GetMethodDeclaringClass(method_, &cls);
if (err != JVMTI_ERROR_NONE) {
LOG(ERROR) << "GetMethodDeclaringClass failed, error: " << err;
return nullptr;
}
JniLocalRef auto_cls(cls);
std::unique_ptr<StaticFieldReader> reader =
CreateStaticFieldReader(cls, field_name);
if (reader == nullptr) {
*error_message = { InvalidIdentifier, { field_name } };
}
return reader;
}
std::unique_ptr<StaticFieldReader> JvmReadersFactory::CreateStaticFieldReader(
const string& class_name,
const string& field_name,
FormatMessageModel* error_message) {
JniLocalRef cls = FindClassByName(class_name, error_message);
if (cls == nullptr) {
return nullptr;
}
std::unique_ptr<StaticFieldReader> reader =
CreateStaticFieldReader(static_cast<jclass>(cls.get()), field_name);
if (reader == nullptr) {
*error_message = { StaticFieldNotFound, { field_name, class_name } };
}
return reader;
}
std::unique_ptr<StaticFieldReader> JvmReadersFactory::CreateStaticFieldReader(
jclass cls,
const string& field_name) {
const ClassMetadataReader::Entry& metadata =
evaluators_->class_metadata_reader->GetClassMetadata(cls);
for (const auto& field : metadata.static_fields) {
if (field->GetName() == field_name) {
return field->Clone();
}
}
return nullptr; // No static field named "field_name" found Java class.
}
std::vector<ClassMetadataReader::Method>
JvmReadersFactory::FindLocalInstanceMethods(
const string& method_name) {
std::shared_ptr<const MethodLocals::Entry> method =
evaluators_->method_locals->GetLocalVariables(method_);
if (method->local_instance == nullptr) {
return {}; // This is a static method, no matches.
}
return FindInstanceMethods(
method->local_instance->GetStaticType().object_signature,
method_name);
}
std::vector<ClassMetadataReader::Method>
JvmReadersFactory::FindInstanceMethods(
const string& class_signature,
const string& method_name) {
JniLocalRef cls =
evaluators_->class_indexer->FindClassBySignature(class_signature);
if (cls == nullptr) {
LOG(ERROR) << "Local instance class not found: " << class_signature;
return {};
}
return FindClassMethods(static_cast<jclass>(cls.get()), false, method_name);
}
std::vector<ClassMetadataReader::Method>
JvmReadersFactory::FindStaticMethods(
const string& method_name) {
JniLocalRef cls = GetMethodDeclaringClass(method_);
if (cls == nullptr) {
return {};
}
return FindClassMethods(static_cast<jclass>(cls.get()), true, method_name);
}
std::vector<ClassMetadataReader::Method>
JvmReadersFactory::FindStaticMethods(
const string& class_name,
const string& method_name) {
FormatMessageModel error_message; // TODO(vlif): propagate this error.
JniLocalRef cls = FindClassByName(class_name, &error_message);
if (cls == nullptr) {
return {};
}
return FindClassMethods(static_cast<jclass>(cls.get()), true, method_name);
}
std::vector<ClassMetadataReader::Method> JvmReadersFactory::FindClassMethods(
jclass cls,
bool is_static,
const string& method_name) {
const ClassMetadataReader::Entry& class_metadata =
evaluators_->class_metadata_reader->GetClassMetadata(cls);
std::vector<ClassMetadataReader::Method> matches;
for (const auto& class_method : class_metadata.methods) {
if ((class_method.is_static() == is_static) &&
(class_method.name == method_name)) {
matches.push_back(class_method);
}
}
return matches;
}
std::unique_ptr<ArrayReader> JvmReadersFactory::CreateArrayReader(
const JSignature& array_signature) {
if (!IsArrayObjectType(array_signature)) {
return nullptr;
}
const JSignature array_element_signature =
GetArrayElementJSignature(array_signature);
switch (array_element_signature.type) {
case JType::Void:
return nullptr; // Bad "array_signature".
case JType::Boolean:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jboolean>);
case JType::Byte:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jbyte>);
case JType::Char:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jchar>);
case JType::Short:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jshort>);
case JType::Int:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jint>);
case JType::Long:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jlong>);
case JType::Float:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jfloat>);
case JType::Double:
return std::unique_ptr<ArrayReader>(
new JvmPrimitiveArrayReader<jdouble>);
case JType::Object:
return std::unique_ptr<ArrayReader>(new JvmObjectArrayReader);
}
return nullptr;
}
} // namespace cdbg
} // namespace devtools
| [
"vlif@google.com"
] | vlif@google.com |
8c25b627e263b7f2567d28fe9f7f7033a1a57081 | 73bdf06846b5c0e71d446581264b7b1e67a3bdd6 | /741_Burrows_Wheeler_Decoder.cpp | 706438393720624bbbb52e49b049a9bb614dfc72 | [] | no_license | RasedulRussell/uva_problem_solve | 0c11d7341316f4aca78e3c14a102aba8e65bd5e1 | c3a2b8da544b9c05b2d459e81ee38c96f89eaffe | refs/heads/master | 2021-06-13T09:10:42.936870 | 2021-03-24T15:49:15 | 2021-03-24T15:49:15 | 160,766,749 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 771 | cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define MAX 10005
#define INF 100000000
#define EPS 1e-9
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
///741_Burrows_Wheeler_Decoder.cpp
int32_t main(){
__FastIO;
string str;
int pos;
int cs = 0;
while(cin >> str >> pos){
if(str == "END" && pos == 0)break;
if(cs){
cout << "\n";
}
cs = 1;
int n = str.size();
vector<string>ans(n);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
ans[j].insert(ans[j].begin(), str[j]);
}
sort(ans.begin(), ans.end());
}
cout << ans[pos - 1] << "\n";
}
return 0;
} | [
"rasedulrussell@gmail.com"
] | rasedulrussell@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 |
88971ed091455f01cd78b7d2200270da7f0dd428 | 11b679228b7f3fbb7521946adda9a4b3ba22aa3a | /ros/flytcore/include/dji_sdk/MissionStatusRequest.h | a55a580695c3417edb227695061273c6cb99b02f | [] | no_license | IgorLebed/spiiran_drone | 7f49513a2fa3f2dffd54e43990b76145db9ae542 | d73221243cabcf89090e7311de5a18fa0faef10c | refs/heads/master | 2020-05-02T19:45:15.132838 | 2020-03-20T08:18:08 | 2020-03-20T08:18:08 | 178,167,867 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,111 | h | // Generated by gencpp from file dji_sdk/MissionStatusRequest.msg
// DO NOT EDIT!
#ifndef DJI_SDK_MESSAGE_MISSIONSTATUSREQUEST_H
#define DJI_SDK_MESSAGE_MISSIONSTATUSREQUEST_H
#include <string>
#include <vector>
#include <map>
#include <ros/types.h>
#include <ros/serialization.h>
#include <ros/builtin_message_traits.h>
#include <ros/message_operations.h>
namespace dji_sdk
{
template <class ContainerAllocator>
struct MissionStatusRequest_
{
typedef MissionStatusRequest_<ContainerAllocator> Type;
MissionStatusRequest_()
{
}
MissionStatusRequest_(const ContainerAllocator& _alloc)
{
(void)_alloc;
}
typedef boost::shared_ptr< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> > Ptr;
typedef boost::shared_ptr< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> const> ConstPtr;
}; // struct MissionStatusRequest_
typedef ::dji_sdk::MissionStatusRequest_<std::allocator<void> > MissionStatusRequest;
typedef boost::shared_ptr< ::dji_sdk::MissionStatusRequest > MissionStatusRequestPtr;
typedef boost::shared_ptr< ::dji_sdk::MissionStatusRequest const> MissionStatusRequestConstPtr;
// constants requiring out of line definition
template<typename ContainerAllocator>
std::ostream& operator<<(std::ostream& s, const ::dji_sdk::MissionStatusRequest_<ContainerAllocator> & v)
{
ros::message_operations::Printer< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >::stream(s, "", v);
return s;
}
} // namespace dji_sdk
namespace ros
{
namespace message_traits
{
// BOOLTRAITS {'IsFixedSize': True, 'IsMessage': True, 'HasHeader': False}
// {'nav_msgs': ['/opt/ros/kinetic/share/nav_msgs/cmake/../msg'], 'dji_sdk': ['/home/flytpod/flytos/src/flytOS/flyt_core/core_nodes/dji/dji_sdk/msg'], 'std_msgs': ['/opt/ros/kinetic/share/std_msgs/cmake/../msg'], 'actionlib_msgs': ['/opt/ros/kinetic/share/actionlib_msgs/cmake/../msg'], 'sensor_msgs': ['/opt/ros/kinetic/share/sensor_msgs/cmake/../msg'], 'geometry_msgs': ['/opt/ros/kinetic/share/geometry_msgs/cmake/../msg']}
// !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types']
template <class ContainerAllocator>
struct IsFixedSize< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsFixedSize< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
: TrueType
{ };
template <class ContainerAllocator>
struct IsMessage< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> const>
: TrueType
{ };
template <class ContainerAllocator>
struct HasHeader< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
: FalseType
{ };
template <class ContainerAllocator>
struct HasHeader< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> const>
: FalseType
{ };
template<class ContainerAllocator>
struct MD5Sum< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
{
static const char* value()
{
return "d41d8cd98f00b204e9800998ecf8427e";
}
static const char* value(const ::dji_sdk::MissionStatusRequest_<ContainerAllocator>&) { return value(); }
static const uint64_t static_value1 = 0xd41d8cd98f00b204ULL;
static const uint64_t static_value2 = 0xe9800998ecf8427eULL;
};
template<class ContainerAllocator>
struct DataType< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
{
static const char* value()
{
return "dji_sdk/MissionStatusRequest";
}
static const char* value(const ::dji_sdk::MissionStatusRequest_<ContainerAllocator>&) { return value(); }
};
template<class ContainerAllocator>
struct Definition< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
{
static const char* value()
{
return "\n\
";
}
static const char* value(const ::dji_sdk::MissionStatusRequest_<ContainerAllocator>&) { return value(); }
};
} // namespace message_traits
} // namespace ros
namespace ros
{
namespace serialization
{
template<class ContainerAllocator> struct Serializer< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
{
template<typename Stream, typename T> inline static void allInOne(Stream&, T)
{}
ROS_DECLARE_ALLINONE_SERIALIZER
}; // struct MissionStatusRequest_
} // namespace serialization
} // namespace ros
namespace ros
{
namespace message_operations
{
template<class ContainerAllocator>
struct Printer< ::dji_sdk::MissionStatusRequest_<ContainerAllocator> >
{
template<typename Stream> static void stream(Stream&, const std::string&, const ::dji_sdk::MissionStatusRequest_<ContainerAllocator>&)
{}
};
} // namespace message_operations
} // namespace ros
#endif // DJI_SDK_MESSAGE_MISSIONSTATUSREQUEST_H
| [
"hazz808@gmail.com"
] | hazz808@gmail.com |
7e4f2ade420d88727d49e5b531f33bbab897a4eb | eb7047d5a8c00d4370a55c2806a2f051287b452d | /modulesrc/meshio/OutputTrigger.i | ec8c64b7338e2b8e109ac9d7b3e5d40c77cb1705 | [
"MIT"
] | permissive | mousumiroy-unm/pylith | 8361a1c0fbcde99657fd3c4e88678a8b5fc8398b | 9a7b6b4ee8e1b89bc441bcedc5ed28a3318e2468 | refs/heads/main | 2023-05-27T18:40:57.145323 | 2021-06-09T19:32:19 | 2021-06-09T19:32:19 | 373,931,160 | 0 | 0 | MIT | 2021-06-04T18:40:09 | 2021-06-04T18:40:09 | null | UTF-8 | C++ | false | false | 1,674 | i | // -*- C++ -*-
//
// ======================================================================
//
// Brad T. Aagaard, U.S. Geological Survey
// Charles A. Williams, GNS Science
// Matthew G. Knepley, University of Chicago
//
// This code was developed as part of the Computational Infrastructure
// for Geodynamics (http://geodynamics.org).
//
// Copyright (c) 2010-2016 University of California, Davis
//
// See COPYING for license information.
//
// ======================================================================
//
/**
* @file modulesrc/meshio/OutputTrigger.i
*
* @brief Python interface to C++ OutputTrigger object.
*/
namespace pylith {
namespace meshio {
class pylith::meshio::OutputTrigger : public pylith::utils::PyreComponent {
// PUBLIC METHODS ///////////////////////////////////////////////////////
public:
/// Constructor
OutputTrigger(void);
/// Destructor
virtual ~OutputTrigger(void);
/** Set time scale for nondimensionalizing time.
*
* @param[in] value Time scale.
*/
void setTimeScale(const PylithReal value);
/** Check whether we want to write output at time t.
*
* @param[in] t Time of proposed write.
* @param[in] tindex Inxex of current time step.
* @returns True if output should be written at time t, false otherwise.
*/
virtual
bool shouldWrite(const PylithReal t,
const PylithInt tindex) = 0;
}; // OutputTrigger
} // meshio
} // pylith
// End of file
| [
"baagaard@usgs.gov"
] | baagaard@usgs.gov |
6592b5ce8809c27e03ae2c35f7e36348fefd6d19 | dabcf701173ddccf9bb12be43587b5d3432beed5 | /Source/TRDsample/Private/ActionTRD.cpp | d2a86b5c21a9b1ceb736b1b32b0a27f0e54e805e | [] | no_license | emperor-katax/ThreadCPP | 601984e969d369c4435e52e5f1215befeb4ccd88 | a43dc5d7c3f2f114e2e95aa45bfd1a56261911e5 | refs/heads/main | 2023-07-09T04:38:11.810020 | 2021-08-10T08:25:13 | 2021-08-10T08:25:13 | 394,575,670 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,038 | cpp | // Fill out your copyright notice in the Description page of Project Settings.
#include "ActionTRD.h"
FAsyncTask<TRDAbandonableTaskTest>* Tasker_01; // define thread variable
// Sets default values for this component's properties
UActionTRD::UActionTRD(){
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UActionTRD::BeginPlay(){
Super::BeginPlay();
}
// Called every frame
void UActionTRD::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction){
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
}
void UActionTRD::SetupItems(int max, float range, FVector shiftLoc, int seg ) {
maxArrayItems = max;
areaRange = range;
areaSegment = seg;
makeArray();
calibrateEmplace(shiftLoc);
}
void UActionTRD::makeArray(){
for (int i = 0; i < maxArrayItems; i++) {
arrEmplace.Emplace(FMath::VRand());
items.Emplace(nullptr);
}
}
void UActionTRD::calibrateEmplace(FVector shiftLoc){
int segmentCounter = 1;
for (int i = 0; i < arrEmplace.Num(); i++) {
arrEmplace[i] = (arrEmplace[i] * ((areaRange / areaSegment) * segmentCounter)) + shiftLoc;
if (i > (segmentCounter * maxArrayItems / areaSegment)) segmentCounter++;
}
}
void UActionTRD::checkTarget(FVector targetLocation, float range){
(new FAutoDeleteAsyncTask<TRDAbandonableTaskTest>(range, targetLocation, maxArrayItems, arrEmplace, items, od))->StartBackgroundTask();
}
void UActionTRD::ActivateItems(int index, bool b) {
const FString cmd = FString::Printf(TEXT("SetColor %s"), b ? TEXT("true") : TEXT("false"));
if (items[index]) items[index]->CallFunctionByNameWithArguments(*cmd, od, NULL, true);
}
TArray<FVector> UActionTRD::getLocations() {
return arrEmplace;
}
void UActionTRD::setItems(int index, AActor* obj) {
items.EmplaceAt(index, obj);
}
///////////////////////////////////
// ----------- // destroy thread
void UActionTRD::DestroyThread(){
if (Tasker_01){
Tasker_01->EnsureCompletion();
delete Tasker_01;
Tasker_01 = NULL;
}
}
| [
"katax.emperor@gmail.com"
] | katax.emperor@gmail.com |
cb176bef4268c7e83ee388a1aec1ada9ebaea5b7 | 05331297eca32128a5267ba82e4285d601277189 | /src/headers/Object.h | e584ebc97e8c305a363a92262400365366d25c5f | [
"BSD-2-Clause"
] | permissive | joao29a/checkersGame | 5a7eb21d637a24506c78f2ddbed8c4cdf6981a43 | 53982765a596fa2de7d9fb6d579bfb94f5bcf0aa | refs/heads/master | 2021-01-10T19:04:45.378549 | 2013-07-28T03:56:41 | 2013-07-28T03:56:41 | 11,494,051 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 331 | h | #ifndef OBJECT_H
#define OBJECT_H
#include <map>
#include <vector>
#include "defines.h"
class Object{
public:
Object(int color);
virtual ~Object(){}
int color;
int type;
virtual map<int,int> positionValues(int id,
vector<Object*> board);
virtual void removeUnkilledPositions(map<int,int>* values);
};
#endif
| [
"john@john-programmer.(none)"
] | john@john-programmer.(none) |
701f085a9d5c76aa5839cb65bf8b17d673b5ca4b | 6814e6556e620bbcbcf16f0dce7a15134b7830f1 | /Projects/Skylicht/Engine/Source/Animation/CAnimationTrack.h | fa6e975b5569be683201a5537c473597c85cf666 | [
"MIT"
] | permissive | blizmax/skylicht-engine | 1bfc506635a1e33b59ad0ce7b04183bcf87c7fc1 | af99999f0a428ca8f3f144e662c1b23fd03b9ceb | refs/heads/master | 2023-08-07T11:50:02.370130 | 2021-10-09T16:10:20 | 2021-10-09T16:10:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,634 | h | /*
!@
MIT License
Copyright (c) 2019 Skylicht Technology CO., LTD
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This file is part of the "Skylicht Engine".
https://github.com/skylicht-lab/skylicht-engine
!#
*/
#pragma once
namespace Skylicht
{
class CFrameData
{
public:
struct SPositionKey
{
f32 frame;
core::vector3df position;
};
struct SScaleKey
{
f32 frame;
core::vector3df scale;
};
struct SRotationKey
{
f32 frame;
core::quaternion rotation;
};
struct SEventKey
{
f32 frame;
core::stringc event;
};
core::array<CFrameData::SPositionKey> PositionKeys;
core::array<CFrameData::SScaleKey> ScaleKeys;
core::array<CFrameData::SRotationKey> RotationKeys;
core::array<CFrameData::SEventKey> EventKeys;
core::quaternion DefaultRot;
core::vector3df DefaultPos;
core::vector3df DefaultScale;
CFrameData()
{
}
};
class CAnimationTrack
{
protected:
s32 m_posHint;
s32 m_scaleHint;
s32 m_rotHint;
CFrameData *m_data;
public:
std::string Name;
bool HaveAnimation;
public:
CAnimationTrack();
virtual ~CAnimationTrack();
static void quaternionSlerp(core::quaternion& result, core::quaternion q1, core::quaternion q2, float t);
void getFrameData(f32 frame,
core::vector3df &position,
core::vector3df &scale,
core::quaternion &rotation);
CFrameData* getAnimData();
void clearAllKeyFrame()
{
m_data = NULL;
m_posHint = 0;
m_scaleHint = 0;
m_rotHint = 0;
Name = "";
HaveAnimation = false;
}
void setFrameData(CFrameData *data)
{
m_data = data;
}
CFrameData* getFrameData()
{
return m_data;
}
};
} | [
"hongduc.pr@gmail.com"
] | hongduc.pr@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 |
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 |
399b58b42eb97acf8c8559fd82f8ad49b8861f93 | e8936f52c4d9e13407f4acaebaaa5d333c32675d | /include/boglfw/GUI/GuiHelper.h | 30d5e4a47d97ea75d9176a40f56068648004045b | [
"MIT"
] | permissive | bog2k3/boglfw | 1c5501a1f17f0d98a85ea008e8ce2f38f6b9459a | ecf297b368c54b2f85c31e94231041fef05da0f9 | refs/heads/master | 2021-06-07T16:26:56.222107 | 2020-03-05T08:34:03 | 2020-03-05T08:34:03 | 113,235,860 | 0 | 1 | null | 2020-03-05T08:34:05 | 2017-12-05T21:39:40 | C++ | UTF-8 | C++ | false | false | 1,221 | h | /*
* GuiHelper.h
*
* Created on: Mar 25, 2015
* Author: bog
*/
#ifndef GUI_GUIHELPER_H_
#define GUI_GUIHELPER_H_
#include <glm/vec2.hpp>
#include <memory>
class GuiBasicElement;
class GuiContainerElement;
namespace GuiHelper {
// searches recursively for the top-most element at the specified point.
// the function assumes the elements in containers are sorted from lowest to highest z-index (top-most last).
// if a container is found at the position, the function recurses within the container to find the deepest element at the point.
// if a container's body is at the point, but none of its children and the container's background is not trasparent, the container is returned.
// x and y are in local container's space (not client space)
std::shared_ptr<GuiBasicElement> getTopElementAtPosition(GuiContainerElement const& container, float x, float y);
// transforms coordinates from parent's client space into element's local space
glm::vec2 parentToLocal(GuiBasicElement const& el, glm::vec2 pcoord);
// transforms coordinates from viewport's space into element's local space
glm::vec2 viewportToLocal(GuiBasicElement const& el, glm::vec2 vcoord);
} // namespace
#endif /* GUI_GUIHELPER_H_ */
| [
"bog2k3@gmail.com"
] | bog2k3@gmail.com |
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 |
53c0480850cdb601b60f1b83158d8e139c641da5 | ba6ef4e867d6b611b0058fc8d33a72ca6074e02a | /node_mgmt/chapter.cpp | adbcbc1bfe281d225790fa1eaa75e4923b2886df | [] | no_license | Proxmiff/XaraVG-lib | 3d3f8c9d8176678a887672ab251b593e3913988c | 8fd443b42c94c9fce26e4e4337dec4647756c530 | refs/heads/master | 2021-01-11T13:33:51.866796 | 2016-05-14T14:48:36 | 2016-05-14T14:48:36 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,955 | cpp |
// NodeRenderableChapter class
#include "camtypes.h"
#include "chapter.h"
#include "cxftags.h"
CC_IMPLEMENT_DYNAMIC(Chapter, NodeRenderablePaper)
/*********************************************************************************************
> Chapter::Chapter()
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 13/5/93
Inputs: -
Outputs:
Returns: -
Purpose: This constructor creates a Chapter linked to no other nodes, with all status
flags false, and NULL bounding and pasteboard rectangles.
Errors:
**********************************************************************************************/
Chapter::Chapter(): NodeRenderablePaper()
{
FoldLineXCoord = 0;
ShowFoldLine = FALSE;
}
/***********************************************************************************************
> Chapter::Chapter
(
Node* ContextNode,
AttachNodeDirection Direction,
MILLIPOINT FldLineXCoord,
BOOL Locked = FALSE,
BOOL Mangled = FALSE,
BOOL Marked = FALSE,
BOOL Selected = FALSE,
)
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 26/4/93
Inputs: ContextNode: Pointer to a node which this node is to be attached to.
Direction:
Specifies the direction in which this node is to be attached to the
ContextNode. The values this variable can take are as follows:
PREV : Attach node as a previous sibling of the context node
NEXT : Attach node as a next sibling of the context node
FIRSTCHILD: Attach node as the first child of the context node
LASTCHILD : Attach node as a last child of the context node
FldLineXCoord: X Coordinate of the main fold line for the spreads in the chapter
The remaining inputs specify the status of the node:
Locked: Is node locked ?
Mangled: Is node mangled ?
Marked: Is node marked ?
Selected: Is node selected ?
Outputs: -
Returns: -
Purpose: This method initialises the node and links it to ContextNode in the
direction specified by Direction. All neccesary tree links are
updated.
Errors: An assertion error will occur if ContextNode is NULL
***********************************************************************************************/
Chapter::Chapter(Node* ContextNode,
AttachNodeDirection Direction,
MILLIPOINT FldLineXCoord,
BOOL Locked,
BOOL Mangled,
BOOL Marked,
BOOL Selected
): NodeRenderablePaper(ContextNode, Direction, Locked, Mangled,
Marked, Selected)
{
FoldLineXCoord = FldLineXCoord;
ShowFoldLine = TRUE;
}
/********************************************************************************************
> virtual String Chapter::Describe(BOOL Plural, BOOL Verbose = TRUE)
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 21/6/93
Inputs: Plural: Flag indicating if the string description should be plural or
singular.
Outputs: -
Returns: Description of the object
Purpose: To return a description of the Node object in either the singular or the
plural. This method is called by the DescribeRange method.
The description will always begin with a lower case letter.
Errors: A resource exception will be thrown if a problem occurs when loading the
string resource.
SeeAlso: -
********************************************************************************************/
/*
Technical Notes:
The String resource identifiers should be of the form: ID_<Class>_DescriptionS for the
singular description and ID_<Class>_DescriptionP for the plural.
*/
String Chapter::Describe(BOOL Plural, BOOL Verbose)
{
if (Plural)
return(String(_R(IDS_CHAPTER_DESCRP)));
else
return(String(_R(IDS_CHAPTER_DESCRS)));
};
/***********************************************************************************************
> Chapter* Chapter::FindPreviousChapter()
Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Created: 16/5/93
Inputs: -
Outputs: -
Returns: The previous sibling chapter or NULL if there are no more chapters
Purpose: For finding the previous sibling chapter
Errors: -
SeeAlso: -
***********************************************************************************************/
Chapter* Chapter::FindPreviousChapter()
{
Node* CurrentNode = FindPrevious();
while (CurrentNode != 0)
{
if (CurrentNode->IsChapter())
return (Chapter*) CurrentNode;
CurrentNode = CurrentNode->FindPrevious();
}
return 0; // No chapter found
}
/***********************************************************************************************
> void Chapter::Render( RenderRegion* )
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 16/5/93
***********************************************************************************************/
void Chapter::Render( RenderRegion* )
{
}
/***********************************************************************************************
> Spread* Chapter::FindFirstSpread()
Author: Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Created: 11/8/94
Inputs: -
Outputs: -
Returns: Returns the first spread in the chapter (or NULL if there are no spreads)
Purpose: Returns the first spread which is an immediate child of the chapter
Errors: -
SeeAlso: -
***********************************************************************************************/
Spread* Chapter::FindFirstSpread()
{
Node* pNode = FindFirstChild();
while(pNode != 0 && !pNode->IsSpread())
pNode = pNode->FindNext();
return (Spread*) pNode;
}
/***********************************************************************************************
> void Chapter::SetFoldLineXCoord(MILLIPOINT value, BOOL DisplayFoldLine = TRUE)
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 11/5/93
Inputs: value: New value for the X coordinate of the chapters fold line
DisplayFoldLine - TRUE if the fold line should be displayed
FALSE to disable display of the fold line altogether
Purpose: For setting the X coordinate of the chapters fold line, and enabling/disabling
the display of the fold line (for single page spreads the fold line is disabled)
Notes: The fold line is rendered in spread.cpp
After setting this value, you'll need to redraw the document appropriately
SeeAlso: Chapter::ShouldShowFoldLine; Chapter::GetFoldLineXCoord
***********************************************************************************************/
void Chapter::SetFoldLineXCoord(MILLIPOINT value, BOOL DisplayFoldLine)
{
FoldLineXCoord = value;
ShowFoldLine = DisplayFoldLine;
}
/***********************************************************************************************
> BOOL Chapter::ShouldShowFoldLine(void) const
Author: Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Created: 13/3/95
Returns: TRUE if the chapter fold line should be displayed
FALSE if the chapter fold line should not be displayed
Purpose: To determine if the chapter fold line is intended to be displayed
SeeAlso: Chapter::SetFoldLineXCoord
***********************************************************************************************/
BOOL Chapter::ShouldShowFoldLine(void) const
{
return(ShowFoldLine);
}
/***********************************************************************************************
> MILLIPOINT Chapter::GetFoldLineXCoord() const
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 11/5/93
Inputs: -
Outputs: -
Returns: The value of the X coordinate of the chapters fold line
Purpose: For finding the X coordinate of the chapters fold line
Errors: -
SeeAlso: -
***********************************************************************************************/
MILLIPOINT Chapter::GetFoldLineXCoord() const
{
return (FoldLineXCoord);
}
/***********************************************************************************************
> Node* Chapter::SimpleCopy()
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 28/4/93
Inputs: -
Outputs:
Returns: A copy of the node, or NULL if memory runs out
Purpose: This method returns a shallow copy of the node with all Node pointers NULL.
The function is virtual, and must be defined for all derived classes.
Errors: If memory runs out when trying to copy, then ERROR is called with an out of memory
error and the function returns NULL.
Scope: protected
**********************************************************************************************/
Node* Chapter::SimpleCopy()
{
Chapter* NodeCopy;
NodeCopy = new Chapter();
ERRORIF(NodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL);
CopyNodeContents(NodeCopy);
return (NodeCopy);
}
/***********************************************************************************************
> void Chapter::PolyCopyNodeContents(Chapter* pNodeCopy)
Author: Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Created: 18/12/2003
Outputs: -
Purpose: Polymorphically copies the contents of this node to another
Errors: An assertion failure will occur if NodeCopy is NULL
Scope: protected
***********************************************************************************************/
void Chapter::PolyCopyNodeContents(NodeRenderable* pNodeCopy)
{
ENSURE(pNodeCopy, "Trying to copy a node's contents into a NULL node");
ENSURE(IS_A(pNodeCopy, Chapter), "PolyCopyNodeContents given wrong dest node type");
if (IS_A(pNodeCopy, Chapter))
CopyNodeContents((Chapter*)pNodeCopy);
}
/***********************************************************************************************
> void Chapter::CopyNodeContents(Chapter* NodeCopy)
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 28/4/93
Inputs:
Outputs: A copy of this node
Returns: -
Purpose: This method copies the node's contents to the node pointed to by NodeCopy.
Errors: An assertion failure will occur if NodeCopy is NULL
Scope: protected
***********************************************************************************************/
void Chapter::CopyNodeContents(Chapter* NodeCopy)
{
ENSURE(NodeCopy != NULL,"Trying to copy node contents to\na node pointed to by a NULL pointer");
NodeRenderablePaper::CopyNodeContents(NodeCopy);
NodeCopy->FoldLineXCoord = FoldLineXCoord;
}
/********************************************************************************************
> XLONG Chapter::GetChapterDepth()
Author: Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Created: 15/12/93
Returns: Depth of the Chapter
Purpose: Find the depth of a chapter in logical coords.
i.e. how far from the top of the document the top of the chapter's
pasteboard is.
********************************************************************************************/
XLONG Chapter::GetChapterDepth()
{
XLONG Depth = 0;
// Loop through document tree calculating the logical coordinate offset for the
// current chapter
// Chapter *pChapter = Node::FindFirstChapter(FindOwnerDoc());
Node* pNode = FindParent();
ERROR2IF(!(pNode->IsNodeDocument()), 0, "Parent of Chapter is not NodeDocument");
Chapter *pChapter = (Chapter*)pNode->FindFirstChild(CC_RUNTIME_CLASS(Chapter));
ENSURE(pChapter != NULL, "Couldn't find first chapter in Chapter::GetChapterDepth");
while ((pChapter != NULL) && (pChapter != this))
{
ENSURE(pChapter->IsKindOf(CC_RUNTIME_CLASS(Chapter)),
"Chapter's sibling is not a Chapter");
const DocRect ChapRect = pChapter->GetPasteboardRect();
// Accumulate logical offset
Depth += ChapRect.Height();
pChapter = (Chapter *) pChapter->FindNext();
}
return Depth;
}
#ifdef _DEBUG
void Chapter::ShowDebugTreeDetails() const
{
TRACE( _T("Chapter ") );
Node::ShowDebugTreeDetails();
}
#endif
/********************************************************************************************
> void* Chapter::GetDebugDetails(StringBase* Str)
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 21/9/93
Inputs: -
Outputs: Str: String giving debug info about the node
Returns: -
Purpose: For obtaining debug information about the Node
Errors: -
SeeAlso: -
********************************************************************************************/
void Chapter::GetDebugDetails(StringBase* Str)
{
NodeRenderablePaper::GetDebugDetails(Str);
String_256 TempStr;
TempStr._MakeMsg(TEXT("\r\nFoldLine X Coord = #1%ld\r\n"),
FoldLineXCoord);
(*Str)+=TempStr;
}
/********************************************************************************************
> virtual UINT32 Chapter::GetNodeSize() const
Author: Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Created: 6/10/93
Inputs: -
Outputs: -
Returns: The size of the node in bytes
Purpose: For finding the size of the node
SeeAlso: Node::GetSubtreeSize
********************************************************************************************/
UINT32 Chapter::GetNodeSize() const
{
return (sizeof(Chapter));
}
/*********************************************************************************************
> BOOL Chapter::IsChapter(void) const
Author: Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Created: 28/04/95
Returns: TRUE
Purpose: For finding if a node is a chapter node.
**********************************************************************************************/
BOOL Chapter::IsChapter() const
{
return TRUE;
}
/********************************************************************************************
> virtual BOOL Chapter::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Created: 31/7/96
Inputs: pFilter = ptr to filter to write to
Returns: TRUE if the node has written out a record to the filter
FALSE otherwise
Purpose: Web files don't write out a chapter records.
This code assumes the document will only contain one chapter
SeeAlso: CanWriteChildrenWeb(), WritePostChildrenWeb()
********************************************************************************************/
BOOL Chapter::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
{
return FALSE;
}
/********************************************************************************************
> virtual BOOL Chapter::WritePreChildrenWeb(BaseCamelotFilter* pFilter)
Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Created: 31/7/96
Inputs: pFilter = ptr to filter to write to
Returns: TRUE if the node has written out a record to the filter
FALSE otherwise
Purpose: Writes out a chapter record.
SeeAlso: CanWriteChildrenWeb(), WritePostChildrenWeb()
********************************************************************************************/
BOOL Chapter::WritePreChildrenNative(BaseCamelotFilter* pFilter)
{
#ifdef DO_EXPORT
BOOL RecordWritten = FALSE;
// Always write out the spread record in native files
CXaraFileRecord Rec(TAG_CHAPTER,TAG_CHAPTER_SIZE);
if (pFilter->Write(&Rec) != 0)
RecordWritten = TRUE;
else
pFilter->GotError(_R(IDE_FILE_WRITE_ERROR));
return RecordWritten;
#else
return FALSE;
#endif
}
/********************************************************************************************
> BOOL Chapter::WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter)
Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Created: 1/8/96
Inputs: pFilter = ptr to the filter to write to
Outputs: -
Returns: TRUE ok, FALSE otherwise
Purpose: Begins the child record sequence for chapter in the web format
Web export doesn't write out chapter records, so this overrides the default
behaviour in Node by ensuring the Down record does not get written
SeeAlso: WritePreChildrenNative()
********************************************************************************************/
BOOL Chapter::WriteBeginChildRecordsWeb(BaseCamelotFilter* pFilter)
{
return TRUE;
}
/********************************************************************************************
> BOOL Chapter::WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter)
Author: Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Created: 1/8/96
Inputs: pFilter = ptr to the filter to write to
Outputs: -
Returns: TRUE ok, FALSE otherwise
Purpose: Ends the child record sequence for chapter in the web format
Web export doesn't write out chapter records, so this overrides the default
behaviour in Node by ensuring the Up record does not get written
SeeAlso: WritePreChildrenNative()
********************************************************************************************/
BOOL Chapter::WriteEndChildRecordsWeb(BaseCamelotFilter* pFilter)
{
return TRUE;
}
//-------------------------------------------------------------------------
// Stubs put here in case they need implementing
BOOL Chapter::WriteBeginChildRecordsNative(BaseCamelotFilter* pFilter)
{
return Node::WriteBeginChildRecordsNative(pFilter);
}
BOOL Chapter::WriteEndChildRecordsNative(BaseCamelotFilter* pFilter)
{
return Node::WriteEndChildRecordsNative(pFilter);
}
| [
"neon.king.fr@gmail.com"
] | neon.king.fr@gmail.com |
83a4691b7f22c91980ba3db85865a1b384872cc8 | edd5c16bfa896a91fc93a149b2fc72882a48a0e2 | /Leetcode/Arrays/SpiralMatrix.cpp | e9c5476643a0ca7b2beddd2dab05a5a9d0c9b5c6 | [] | no_license | prateeek1/DS-Algo | 7b4d2fe849363ad8d7415530ebffc22b4126e5bc | db5c258ba44b4fbd6a369cbbaae673e44ae56c19 | refs/heads/master | 2023-08-10T01:31:24.548219 | 2021-09-16T15:14:56 | 2021-09-16T15:14:56 | 376,521,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,110 | cpp | class Solution {
public:
vector<int> spiralOrder(vector<vector<int>>& matrix) {
vector<int>ans;
int n = matrix.size();
int m = matrix[0].size();
int rowBegin = 0;
int rowEnd = n - 1;
int colBegin = 0;
int colEnd = m - 1;
while (rowBegin <= rowEnd and colBegin <= colEnd)
{
for (int i = colBegin; i <= colEnd; i++)
{
ans.push_back(matrix[rowBegin][i]);
}
rowBegin++;
for (int i = rowBegin; i <= rowEnd; i++)
{
ans.push_back(matrix[i][colEnd]);
}
colEnd--;
for (int i = colEnd; i >= colBegin; i--)
{
if (rowBegin <= rowEnd)
ans.push_back(matrix[rowEnd][i]);
}
rowEnd--;
for (int i = rowEnd; i >= rowBegin; i--)
{
if (colBegin <= colEnd)
ans.push_back(matrix[i][colBegin]);
}
colBegin++;
}
return ans;
}
}; | [
"bahukhandiprateek@gmail.com"
] | bahukhandiprateek@gmail.com |
4ea7d5140b2b8d0ad9a3990cc6fd9acc7eb979a5 | bd2139703c556050403c10857bde66f688cd9ee6 | /valhalla/62/webrev.00/src/hotspot/share/oops/valueKlass.cpp | a5f5377d3328f55189de99c62115611045b5b3ae | [] | no_license | isabella232/cr-archive | d03427e6fbc708403dd5882d36371e1b660ec1ac | 8a3c9ddcfacb32d1a65d7ca084921478362ec2d1 | refs/heads/master | 2023-02-01T17:33:44.383410 | 2020-12-17T13:47:48 | 2020-12-17T13:47:48 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 19,932 | cpp | /*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc/shared/barrierSet.hpp"
#include "gc/shared/collectedHeap.inline.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "interpreter/interpreter.hpp"
#include "logging/log.hpp"
#include "memory/metaspaceClosure.hpp"
#include "memory/metadataFactory.hpp"
#include "oops/access.hpp"
#include "oops/compressedOops.inline.hpp"
#include "oops/fieldStreams.inline.hpp"
#include "oops/instanceKlass.inline.hpp"
#include "oops/method.hpp"
#include "oops/oop.inline.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/valueKlass.inline.hpp"
#include "oops/valueArrayKlass.hpp"
#include "runtime/fieldDescriptor.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/thread.inline.hpp"
#include "utilities/copy.hpp"
// Constructor
ValueKlass::ValueKlass(const ClassFileParser& parser)
: InstanceKlass(parser, InstanceKlass::_misc_kind_inline_type, InstanceKlass::ID) {
_adr_valueklass_fixed_block = valueklass_static_block();
// Addresses used for value type calling convention
*((Array<SigEntry>**)adr_extended_sig()) = NULL;
*((Array<VMRegPair>**)adr_return_regs()) = NULL;
*((address*)adr_pack_handler()) = NULL;
*((address*)adr_pack_handler_jobject()) = NULL;
*((address*)adr_unpack_handler()) = NULL;
assert(pack_handler() == NULL, "pack handler not null");
*((int*)adr_default_value_offset()) = 0;
*((Klass**)adr_value_array_klass()) = NULL;
set_prototype_header(markWord::always_locked_prototype());
}
oop ValueKlass::default_value() {
oop val = java_mirror()->obj_field_acquire(default_value_offset());
assert(oopDesc::is_oop(val), "Sanity check");
assert(val->is_value(), "Sanity check");
assert(val->klass() == this, "sanity check");
return val;
}
int ValueKlass::first_field_offset_old() {
#ifdef ASSERT
int first_offset = INT_MAX;
for (AllFieldStream fs(this); !fs.done(); fs.next()) {
if (fs.offset() < first_offset) first_offset= fs.offset();
}
#endif
int base_offset = instanceOopDesc::base_offset_in_bytes();
// The first field of value types is aligned on a long boundary
base_offset = align_up(base_offset, BytesPerLong);
assert(base_offset == first_offset, "inconsistent offsets");
return base_offset;
}
int ValueKlass::raw_value_byte_size() {
int heapOopAlignedSize = nonstatic_field_size() << LogBytesPerHeapOop;
// If bigger than 64 bits or needs oop alignment, then use jlong aligned
// which for values should be jlong aligned, asserts in raw_field_copy otherwise
if (heapOopAlignedSize >= longSize || contains_oops()) {
return heapOopAlignedSize;
}
// Small primitives...
// If a few small basic type fields, return the actual size, i.e.
// 1 byte = 1
// 2 byte = 2
// 3 byte = 4, because pow2 needed for element stores
int first_offset = first_field_offset();
int last_offset = 0; // find the last offset, add basic type size
int last_tsz = 0;
for (AllFieldStream fs(this); !fs.done(); fs.next()) {
if (fs.access_flags().is_static()) {
continue;
} else if (fs.offset() > last_offset) {
BasicType type = Signature::basic_type(fs.signature());
if (is_java_primitive(type)) {
last_tsz = type2aelembytes(type);
} else if (type == T_VALUETYPE) {
// Not just primitives. Layout aligns embedded value, so use jlong aligned it is
return heapOopAlignedSize;
} else {
guarantee(0, "Unknown type %d", type);
}
assert(last_tsz != 0, "Invariant");
last_offset = fs.offset();
}
}
// Assumes VT with no fields are meaningless and illegal
last_offset += last_tsz;
assert(last_offset > first_offset && last_tsz, "Invariant");
return 1 << upper_log2(last_offset - first_offset);
}
instanceOop ValueKlass::allocate_instance(TRAPS) {
int size = size_helper(); // Query before forming handle.
instanceOop oop = (instanceOop)Universe::heap()->obj_allocate(this, size, CHECK_NULL);
assert(oop->mark().is_always_locked(), "Unlocked value type");
return oop;
}
instanceOop ValueKlass::allocate_instance_buffer(TRAPS) {
int size = size_helper(); // Query before forming handle.
instanceOop oop = (instanceOop)Universe::heap()->obj_buffer_allocate(this, size, CHECK_NULL);
assert(oop->mark().is_always_locked(), "Unlocked value type");
return oop;
}
int ValueKlass::nonstatic_oop_count() {
int oops = 0;
int map_count = nonstatic_oop_map_count();
OopMapBlock* block = start_of_nonstatic_oop_maps();
OopMapBlock* end = block + map_count;
while (block != end) {
oops += block->count();
block++;
}
return oops;
}
oop ValueKlass::read_flattened_field(oop obj, int offset, TRAPS) {
oop res = NULL;
this->initialize(CHECK_NULL); // will throw an exception if in error state
if (is_empty_inline_type()) {
res = (instanceOop)default_value();
} else {
Handle obj_h(THREAD, obj);
res = allocate_instance_buffer(CHECK_NULL);
value_copy_payload_to_new_oop(((char*)(oopDesc*)obj_h()) + offset, res);
}
assert(res != NULL, "Must be set in one of two paths above");
return res;
}
void ValueKlass::write_flattened_field(oop obj, int offset, oop value, TRAPS) {
if (value == NULL) {
THROW(vmSymbols::java_lang_NullPointerException());
}
if (!is_empty_inline_type()) {
value_copy_oop_to_payload(value, ((char*)(oopDesc*)obj) + offset);
}
}
// Arrays of...
bool ValueKlass::flatten_array() {
if (!ValueArrayFlatten) {
return false;
}
// Too big
int elem_bytes = raw_value_byte_size();
if ((ValueArrayElemMaxFlatSize >= 0) && (elem_bytes > ValueArrayElemMaxFlatSize)) {
return false;
}
// Too many embedded oops
if ((ValueArrayElemMaxFlatOops >= 0) && (nonstatic_oop_count() > ValueArrayElemMaxFlatOops)) {
return false;
}
// Declared atomic but not naturally atomic.
if (is_declared_atomic() && !is_naturally_atomic()) {
return false;
}
// VM enforcing ValueArrayAtomicAccess only...
if (ValueArrayAtomicAccess && (!is_naturally_atomic())) {
return false;
}
return true;
}
void ValueKlass::remove_unshareable_info() {
InstanceKlass::remove_unshareable_info();
*((Array<SigEntry>**)adr_extended_sig()) = NULL;
*((Array<VMRegPair>**)adr_return_regs()) = NULL;
*((address*)adr_pack_handler()) = NULL;
*((address*)adr_pack_handler_jobject()) = NULL;
*((address*)adr_unpack_handler()) = NULL;
assert(pack_handler() == NULL, "pack handler not null");
*((Klass**)adr_value_array_klass()) = NULL;
}
void ValueKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, PackageEntry* pkg_entry, TRAPS) {
InstanceKlass::restore_unshareable_info(loader_data, protection_domain, pkg_entry, CHECK);
oop val = allocate_instance(CHECK);
set_default_value(val);
}
Klass* ValueKlass::array_klass_impl(bool or_null, int n, TRAPS) {
if (flatten_array()) {
return value_array_klass(or_null, n, THREAD);
} else {
return InstanceKlass::array_klass_impl(or_null, n, THREAD);
}
}
Klass* ValueKlass::array_klass_impl(bool or_null, TRAPS) {
return array_klass_impl(or_null, 1, THREAD);
}
Klass* ValueKlass::value_array_klass(bool or_null, int rank, TRAPS) {
Klass* vak = acquire_value_array_klass();
if (vak == NULL) {
if (or_null) return NULL;
ResourceMark rm;
{
// Atomic creation of array_klasses
MutexLocker ma(THREAD, MultiArray_lock);
if (get_value_array_klass() == NULL) {
vak = allocate_value_array_klass(CHECK_NULL);
Atomic::release_store((Klass**)adr_value_array_klass(), vak);
}
}
}
if (or_null) {
return vak->array_klass_or_null(rank);
}
return vak->array_klass(rank, THREAD);
}
Klass* ValueKlass::allocate_value_array_klass(TRAPS) {
if (flatten_array()) {
return ValueArrayKlass::allocate_klass(this, THREAD);
}
return ObjArrayKlass::allocate_objArray_klass(1, this, THREAD);
}
void ValueKlass::array_klasses_do(void f(Klass* k)) {
InstanceKlass::array_klasses_do(f);
if (get_value_array_klass() != NULL)
ArrayKlass::cast(get_value_array_klass())->array_klasses_do(f);
}
// Value type arguments are not passed by reference, instead each
// field of the value type is passed as an argument. This helper
// function collects the fields of the value types (including embedded
// value type's fields) in a list. Included with the field's type is
// the offset of each field in the value type: i2c and c2i adapters
// need that to load or store fields. Finally, the list of fields is
// sorted in order of increasing offsets: the adapters and the
// compiled code need to agree upon the order of fields.
//
// The list of basic types that is returned starts with a T_VALUETYPE
// and ends with an extra T_VOID. T_VALUETYPE/T_VOID pairs are used as
// delimiters. Every entry between the two is a field of the value
// type. If there's an embedded value type in the list, it also starts
// with a T_VALUETYPE and ends with a T_VOID. This is so we can
// generate a unique fingerprint for the method's adapters and we can
// generate the list of basic types from the interpreter point of view
// (value types passed as reference: iterate on the list until a
// T_VALUETYPE, drop everything until and including the closing
// T_VOID) or the compiler point of view (each field of the value
// types is an argument: drop all T_VALUETYPE/T_VOID from the list).
int ValueKlass::collect_fields(GrowableArray<SigEntry>* sig, int base_off) {
int count = 0;
SigEntry::add_entry(sig, T_VALUETYPE, base_off);
for (AllFieldStream fs(this); !fs.done(); fs.next()) {
if (fs.access_flags().is_static()) continue;
int offset = base_off + fs.offset() - (base_off > 0 ? first_field_offset() : 0);
if (fs.is_flattened()) {
// Resolve klass of flattened value type field and recursively collect fields
Klass* vk = get_value_field_klass(fs.index());
count += ValueKlass::cast(vk)->collect_fields(sig, offset);
} else {
BasicType bt = Signature::basic_type(fs.signature());
if (bt == T_VALUETYPE) {
bt = T_OBJECT;
}
SigEntry::add_entry(sig, bt, offset);
count += type2size[bt];
}
}
int offset = base_off + size_helper()*HeapWordSize - (base_off > 0 ? first_field_offset() : 0);
SigEntry::add_entry(sig, T_VOID, offset);
if (base_off == 0) {
sig->sort(SigEntry::compare);
}
assert(sig->at(0)._bt == T_VALUETYPE && sig->at(sig->length()-1)._bt == T_VOID, "broken structure");
return count;
}
void ValueKlass::initialize_calling_convention(TRAPS) {
// Because the pack and unpack handler addresses need to be loadable from generated code,
// they are stored at a fixed offset in the klass metadata. Since value type klasses do
// not have a vtable, the vtable offset is used to store these addresses.
if (is_scalarizable() && (ValueTypeReturnedAsFields || ValueTypePassFieldsAsArgs)) {
ResourceMark rm;
GrowableArray<SigEntry> sig_vk;
int nb_fields = collect_fields(&sig_vk);
Array<SigEntry>* extended_sig = MetadataFactory::new_array<SigEntry>(class_loader_data(), sig_vk.length(), CHECK);
*((Array<SigEntry>**)adr_extended_sig()) = extended_sig;
for (int i = 0; i < sig_vk.length(); i++) {
extended_sig->at_put(i, sig_vk.at(i));
}
if (ValueTypeReturnedAsFields) {
nb_fields++;
BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, nb_fields);
sig_bt[0] = T_METADATA;
SigEntry::fill_sig_bt(&sig_vk, sig_bt+1);
VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair, nb_fields);
int total = SharedRuntime::java_return_convention(sig_bt, regs, nb_fields);
if (total > 0) {
Array<VMRegPair>* return_regs = MetadataFactory::new_array<VMRegPair>(class_loader_data(), nb_fields, CHECK);
*((Array<VMRegPair>**)adr_return_regs()) = return_regs;
for (int i = 0; i < nb_fields; i++) {
return_regs->at_put(i, regs[i]);
}
BufferedValueTypeBlob* buffered_blob = SharedRuntime::generate_buffered_value_type_adapter(this);
*((address*)adr_pack_handler()) = buffered_blob->pack_fields();
*((address*)adr_pack_handler_jobject()) = buffered_blob->pack_fields_jobject();
*((address*)adr_unpack_handler()) = buffered_blob->unpack_fields();
assert(CodeCache::find_blob(pack_handler()) == buffered_blob, "lost track of blob");
}
}
}
}
void ValueKlass::deallocate_contents(ClassLoaderData* loader_data) {
if (extended_sig() != NULL) {
MetadataFactory::free_array<SigEntry>(loader_data, extended_sig());
}
if (return_regs() != NULL) {
MetadataFactory::free_array<VMRegPair>(loader_data, return_regs());
}
cleanup_blobs();
InstanceKlass::deallocate_contents(loader_data);
}
void ValueKlass::cleanup(ValueKlass* ik) {
ik->cleanup_blobs();
}
void ValueKlass::cleanup_blobs() {
if (pack_handler() != NULL) {
CodeBlob* buffered_blob = CodeCache::find_blob(pack_handler());
assert(buffered_blob->is_buffered_value_type_blob(), "bad blob type");
BufferBlob::free((BufferBlob*)buffered_blob);
*((address*)adr_pack_handler()) = NULL;
*((address*)adr_pack_handler_jobject()) = NULL;
*((address*)adr_unpack_handler()) = NULL;
}
}
// Can this value type be scalarized?
bool ValueKlass::is_scalarizable() const {
return ScalarizeValueTypes;
}
// Can this value type be returned as multiple values?
bool ValueKlass::can_be_returned_as_fields() const {
return return_regs() != NULL;
}
// Create handles for all oop fields returned in registers that are going to be live across a safepoint
void ValueKlass::save_oop_fields(const RegisterMap& reg_map, GrowableArray<Handle>& handles) const {
Thread* thread = Thread::current();
const Array<SigEntry>* sig_vk = extended_sig();
const Array<VMRegPair>* regs = return_regs();
int j = 1;
for (int i = 0; i < sig_vk->length(); i++) {
BasicType bt = sig_vk->at(i)._bt;
if (bt == T_OBJECT || bt == T_ARRAY) {
VMRegPair pair = regs->at(j);
address loc = reg_map.location(pair.first());
oop v = *(oop*)loc;
assert(v == NULL || oopDesc::is_oop(v), "not an oop?");
assert(Universe::heap()->is_in_or_null(v), "must be heap pointer");
handles.push(Handle(thread, v));
}
if (bt == T_VALUETYPE) {
continue;
}
if (bt == T_VOID &&
sig_vk->at(i-1)._bt != T_LONG &&
sig_vk->at(i-1)._bt != T_DOUBLE) {
continue;
}
j++;
}
assert(j == regs->length(), "missed a field?");
}
// Update oop fields in registers from handles after a safepoint
void ValueKlass::restore_oop_results(RegisterMap& reg_map, GrowableArray<Handle>& handles) const {
assert(ValueTypeReturnedAsFields, "inconsistent");
const Array<SigEntry>* sig_vk = extended_sig();
const Array<VMRegPair>* regs = return_regs();
assert(regs != NULL, "inconsistent");
int j = 1;
for (int i = 0, k = 0; i < sig_vk->length(); i++) {
BasicType bt = sig_vk->at(i)._bt;
if (bt == T_OBJECT || bt == T_ARRAY) {
VMRegPair pair = regs->at(j);
address loc = reg_map.location(pair.first());
*(oop*)loc = handles.at(k++)();
}
if (bt == T_VALUETYPE) {
continue;
}
if (bt == T_VOID &&
sig_vk->at(i-1)._bt != T_LONG &&
sig_vk->at(i-1)._bt != T_DOUBLE) {
continue;
}
j++;
}
assert(j == regs->length(), "missed a field?");
}
// Fields are in registers. Create an instance of the value type and
// initialize it with the values of the fields.
oop ValueKlass::realloc_result(const RegisterMap& reg_map, const GrowableArray<Handle>& handles, TRAPS) {
oop new_vt = allocate_instance(CHECK_NULL);
const Array<SigEntry>* sig_vk = extended_sig();
const Array<VMRegPair>* regs = return_regs();
int j = 1;
int k = 0;
for (int i = 0; i < sig_vk->length(); i++) {
BasicType bt = sig_vk->at(i)._bt;
if (bt == T_VALUETYPE) {
continue;
}
if (bt == T_VOID) {
if (sig_vk->at(i-1)._bt == T_LONG ||
sig_vk->at(i-1)._bt == T_DOUBLE) {
j++;
}
continue;
}
int off = sig_vk->at(i)._offset;
assert(off > 0, "offset in object should be positive");
VMRegPair pair = regs->at(j);
address loc = reg_map.location(pair.first());
switch(bt) {
case T_BOOLEAN: {
new_vt->bool_field_put(off, *(jboolean*)loc);
break;
}
case T_CHAR: {
new_vt->char_field_put(off, *(jchar*)loc);
break;
}
case T_BYTE: {
new_vt->byte_field_put(off, *(jbyte*)loc);
break;
}
case T_SHORT: {
new_vt->short_field_put(off, *(jshort*)loc);
break;
}
case T_INT: {
new_vt->int_field_put(off, *(jint*)loc);
break;
}
case T_LONG: {
#ifdef _LP64
new_vt->double_field_put(off, *(jdouble*)loc);
#else
Unimplemented();
#endif
break;
}
case T_OBJECT:
case T_ARRAY: {
Handle handle = handles.at(k++);
new_vt->obj_field_put(off, handle());
break;
}
case T_FLOAT: {
new_vt->float_field_put(off, *(jfloat*)loc);
break;
}
case T_DOUBLE: {
new_vt->double_field_put(off, *(jdouble*)loc);
break;
}
default:
ShouldNotReachHere();
}
*(intptr_t*)loc = 0xDEAD;
j++;
}
assert(j == regs->length(), "missed a field?");
assert(k == handles.length(), "missed an oop?");
return new_vt;
}
// Check the return register for a ValueKlass oop
ValueKlass* ValueKlass::returned_value_klass(const RegisterMap& map) {
BasicType bt = T_METADATA;
VMRegPair pair;
int nb = SharedRuntime::java_return_convention(&bt, &pair, 1);
assert(nb == 1, "broken");
address loc = map.location(pair.first());
intptr_t ptr = *(intptr_t*)loc;
if (is_set_nth_bit(ptr, 0)) {
// Oop is tagged, must be a ValueKlass oop
clear_nth_bit(ptr, 0);
assert(Metaspace::contains((void*)ptr), "should be klass");
ValueKlass* vk = (ValueKlass*)ptr;
assert(vk->can_be_returned_as_fields(), "must be able to return as fields");
return vk;
}
#ifdef ASSERT
// Oop is not tagged, must be a valid oop
if (VerifyOops) {
oopDesc::verify(oop((HeapWord*)ptr));
}
#endif
return NULL;
}
void ValueKlass::verify_on(outputStream* st) {
InstanceKlass::verify_on(st);
guarantee(prototype_header().is_always_locked(), "Prototype header is not always locked");
}
void ValueKlass::oop_verify_on(oop obj, outputStream* st) {
InstanceKlass::oop_verify_on(obj, st);
guarantee(obj->mark().is_always_locked(), "Header is not always locked");
}
void ValueKlass::metaspace_pointers_do(MetaspaceClosure* it) {
InstanceKlass::metaspace_pointers_do(it);
ValueKlass* this_ptr = this;
it->push_internal_pointer(&this_ptr, (intptr_t*)&_adr_valueklass_fixed_block);
}
| [
"robin.westberg@oracle.com"
] | robin.westberg@oracle.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 |
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 |
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 |
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 |
2e47aef57fa1257405b9a1dba824430b2c447a60 | 9acf665d0348a11d032a3a880bdbfb28a98ea3db | /DFAltisLife.Altis/The-Programmer/Iphone_X/dialogs/Gang.hpp | b417a5d5ea930acb0980221a7a27a743d0224970 | [] | no_license | RoberioJr/DFAltisLife | 4d605b51cefcf684b2d073fd25d68edb5ba226ca | 4b90450e5b256cdb2162e4fc6b6f1c5914cb87f1 | refs/heads/master | 2022-09-30T10:42:39.506374 | 2019-05-04T04:03:04 | 2019-05-04T04:03:04 | 144,479,757 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,853 | hpp | /*
Author: Jean_Park
Teamspeak 3: ts.the-programmer.com
Web site: www.the-programmer.com
Discord : https://discord.gg/DhFUFsq
Terms of use:
- This file is forbidden unless you have permission from the author. If you have this file without permission to use it please do not use it and do not share it.
- If you have permission to use this file, you can use it on your server however it is strictly forbidden to share it.
- Out of respect for the author please do not delete this information.
License number:
Server's name:
Owner's name:
*/
class The_Programmer_Iphone_Gang_Menu {
idd = 2620;
name = "The_Programmer_Iphone_Gang_Menu";
movingenable = 0;
enablesimulation = 1;
onload = "";
class controlsBackground
{
class Life_RscTitleBackground : Life_RscPicture
{
text = "";
idc = 2000;
x = 0.6379405 * safezoneW + safezoneX;
y = 0.288744481809243 * safezoneH + safezoneY;
w = 0.21 * safezoneW;
h = 0.7 * safezoneH;
};
};
class controls
{
class GangMemberList : Life_RscListBox
{
idc = 2621;
text = "";
colorbackground[] = {1,1,1,0};
sizeex = 0.035;
x = 0.668854166666667 * safezoneW + safezoneX;
y = 0.514670599803343 * safezoneH + safezoneY;
w = 0.148 * safezoneW;
h = 0.185 * safezoneH;
};
class Fermer : Life_RscButtonInvisible
{
idc = -1;
tooltip = "Home";
onbuttonclick = "closeDialog 0; [] spawn the_programmer_iphone_fnc_phone_init;";
x = 0.732093666666666 * safezoneW + safezoneX;
y = 0.907587959685349 * safezoneH + safezoneY;
w = 0.025877 * safezoneW;
h = 0.0439812 * safezoneH;
};
class Augementer : Life_RscButtonInvisible
{
idc = 2622;
onbuttonclick = "[] spawn life_fnc_gangUpgrade;";
x = 0.659583333333333 * safezoneW + safezoneX;
y = 0.802625368731563 * safezoneH + safezoneY;
w = 0.17 * safezoneW;
h = 0.03 * safezoneH;
};
class GangKick : Life_RscButtonInvisible
{
idc = 2624;
onbuttonclick = "[] call life_fnc_gangKick;";
x = 0.717395833333333 * safezoneW + safezoneX;
y = 0.7670796460177 * safezoneH + safezoneY;
w = 0.05 * safezoneW;
h = 0.03 * safezoneH;
};
class GangLeader : Life_RscButtonInvisible
{
idc = 2625;
text = "";
onbuttonclick = "[] spawn life_fnc_gangNewLeader;";
x = 0.776770833333333 * safezoneW + safezoneX;
y = 0.7670796460177 * safezoneH + safezoneY;
w = 0.05 * safezoneW;
h = 0.03 * safezoneH;
};
class InviteMember : Life_RscButtonInvisible
{
idc = 2630;
text = "";
onbuttonclick = "[] spawn life_fnc_gangInvitePlayer;";
y = 0.724208456243855 * safezoneH + safezoneY;
x = 0.800625 * safezoneW + safezoneX;
w = 0.03 * safezoneW;
h = 0.03 * safezoneH;
};
class DisbandGang : Life_RscButtonInvisible
{
idc = 2631;
text = "";
onbuttonclick = "";
y = 0.837581120943953 * safezoneH + safezoneY;
w = 0.17 * safezoneW;
h = 0.03 * safezoneH;
x = 0.659583333333333 * safezoneW + safezoneX;
};
class ColorList : Life_RscCombo
{
idc = 2632;
x = 0.664583333333333 * safezoneW + safezoneX;
y = 0.728 * safezoneH + safezoneY;
w = 0.13 * safezoneW;
h = 0.022 * safezoneH;
};
class GangBank : Life_RscStructuredText
{
idc = 601;
style = 1;
text = "";
w = 0.115 * safezoneW;
h = 0.04 * safezoneH;
x = 0.6965625 * safezoneW + safezoneX;
y = 0.410422812192723 * safezoneH + safezoneY;
};
class Nom : Life_RscStructuredText
{
idc = 2629;
style = 1;
text = "";
sizeex = 0.045;
w = 0.1 * safezoneW;
h = 0.025 * safezoneH;
x = 0.705416666666667 * safezoneW + safezoneX;
y = 0.471779744346115 * safezoneH + safezoneY;
};
class Reboot : Life_RscButtonInvisible
{
idc = -1;
tooltip = "Reboot";
onbuttonclick = "[] call the_programmer_iphone_fnc_reboot;";
x = 0.807894833333333 * safezoneW + safezoneX;
y = 0.312326017502458 * safezoneH + safezoneY;
w = 0.01 * safezoneW;
h = 0.02 * safezoneH;
};
};
};
| [
"rrpontesjunior10@gmail.com"
] | rrpontesjunior10@gmail.com |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 | |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.