blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 2 247 | content_id stringlengths 40 40 | detected_licenses listlengths 0 57 | license_type stringclasses 2 values | repo_name stringlengths 4 111 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 58 | visit_date timestamp[ns]date 2015-07-25 18:16:41 2023-09-06 10:45:08 | revision_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | committer_date timestamp[ns]date 1970-01-14 14:03:36 2023-09-06 06:22:19 | github_id int64 3.89k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 25 values | gha_event_created_at timestamp[ns]date 2012-06-07 00:51:45 2023-09-14 21:58:52 ⌀ | gha_created_at timestamp[ns]date 2008-03-27 23:40:48 2023-08-24 19:49:39 ⌀ | gha_language stringclasses 159 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 7 10.5M | extension stringclasses 111 values | filename stringlengths 1 195 | text stringlengths 7 10.5M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
014ca76e47684290242a7ab1f240dca42ee70ed2 | 91f3aa600ce13aeb351b3577bd98a28ebfb7ee17 | /Scene.h | 7bff2f560279b3742bb6313f1acc4dd52b7b36d2 | [
"MIT"
] | permissive | ostlerc/raytracer | d538f84f2e17c05230fd0bd6442de4d1f443f611 | 1b20ef2ffdde1fe1cb2423f9a6752eb5f10dbc32 | refs/heads/master | 2021-01-10T21:11:34.494525 | 2013-08-05T06:01:45 | 2013-08-05T06:01:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,956 | h | Scene.h |
#ifndef Scene_h
#define Scene_h
#include "Color.h"
#include <string>
#include <vector>
class Background;
class Camera;
class Color;
class Image;
class Light;
class Object;
class RenderContext;
class Ray;
class Scene {
public:
Scene();
virtual ~Scene();
inline Object* getObject() const {
return object;
}
void setObject(Object* obj) {
object = obj;
}
inline Background* getBackground() const {
return background;
}
void setBackground(Background* bg) {
background = bg;
}
inline Camera* getCamera() const {
return camera;
}
void setCamera(Camera* cam) {
camera = cam;
}
inline Image* getImage() const {
return image;
}
void setImage(Image* im) {
image = im;
}
void addLight(Light* light) {
lights.push_back(light);
}
const std::vector<Light*>& getLights() const {
return lights;
}
Color getAmbient() const {
return ambient;
}
void setAmbient(const Color& amb) {
ambient = amb;
}
int getMaxRayDepth() const {
return maxRayDepth;
}
void setMaxRayDepth(int rd) {
maxRayDepth = rd;
}
double getMinAttenuation() const {
return minAttenuation;
}
void setMinAttenuation(double atten) {
minAttenuation = atten;
}
int getSampleSize() const {
return sampleSize;
}
void setSampleSize(int ss) {
sampleSize = ss;
}
void preprocess(int maxTime);
void render(int time);
double traceRay(Color& result, const RenderContext& context, const Ray& ray, const Color& attenuation, int depth) const;
double traceRay(Color& result, const RenderContext& context, const Object* obj, const Ray& ray, const Color& attenuation, int depth) const;
private:
Scene(const Scene&);
Scene& operator=(const Scene&);
Background* background;
Camera* camera;
Color ambient;
Image* image;
Object* object;
std::vector<Light*> lights;
int maxRayDepth;
int sampleSize;
double minAttenuation;
};
#endif
|
052f8b12dab3c45cd9977202ecbe52339ff8a36c | a071753a94d6d247bdfc8468661e99046a92e376 | /opencl/test/unit_test/gen12lp/dg1/excludes_dg1.cpp | 4b6d30cacab3414be06dc9b79c985fff6d38cbe2 | [
"MIT"
] | permissive | JacekDanecki/compute-runtime | dd17bd773dc5a97fee38259d35bf103eaa006176 | 156c55e6a61c84d78ea530970c3092c94f055ffc | refs/heads/master | 2022-03-22T02:24:10.485771 | 2021-05-21T11:30:24 | 2021-05-21T11:37:22 | 119,974,462 | 1 | 6 | MIT | 2019-03-26T17:26:08 | 2018-02-02T11:37:53 | C++ | UTF-8 | C++ | false | false | 1,729 | cpp | excludes_dg1.cpp | /*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "test.h"
namespace NEO {
HWCMDTEST_EXCLUDE_FAMILY(ProfilingTests, GivenCommandQueueBlockedWithProfilingWhenWalkerIsDispatchedThenMiStoreRegisterMemIsPresentInCS, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(ProfilingTests, GivenCommandQueueWithProflingWhenWalkerIsDispatchedThenMiStoreRegisterMemIsPresentInCS, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(EventProfilingTest, givenEventWhenCompleteIsZeroThenCalcProfilingDataSetsEndTimestampInCompleteTimestampAndDoesntCallOsTimeMethods, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(EventProfilingTests, givenRawTimestampsDebugModeWhenDataIsQueriedThenRawDataIsReturned, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(EventProfilingTest, givenRawTimestampsDebugModeWhenStartTimeStampLTQueueTimeStampThenIncreaseStartTimeStamp, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(ProfilingWithPerfCountersTests, GivenCommandQueueWithProfilingPerfCountersWhenWalkerIsDispatchedThenRegisterStoresArePresentInCS, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(TimestampEventCreate, givenEventTimestampsWhenQueryKernelTimestampThenCorrectDataAreSet, IGFX_DG1);
} // namespace NEO
HWCMDTEST_EXCLUDE_FAMILY(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsTakenThenTimeStampAddressIsProgrammedCorrectly, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(ProfilingCommandsTest, givenKernelWhenProfilingCommandStartIsNotTakenThenTimeStampAddressIsProgrammedCorrectly, IGFX_DG1);
HWCMDTEST_EXCLUDE_FAMILY(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryIsUnalignedToCachelineButReadOnlyThenL3CacheShouldBeStillOn, IGFX_DG1)
HWCMDTEST_EXCLUDE_FAMILY(BufferSetSurfaceTests, givenAlignedCacheableReadOnlyBufferThenChoseOclBufferPolicy, IGFX_DG1);
|
2450f49920d7cf43a7bde114d9313f4eedd6db15 | 2182d5af50bcaa771eb47306ab8bcd35297fdb62 | /src/qt/bitcoinstrings.cpp | 45aadd49a5dbe306dccf9fc43b12012118abf2f6 | [
"MIT"
] | permissive | lachesis/bitcoin | 812e489d6e81fd936a6d02c89895e6d8ca47b762 | 5c5d310a0a94ec00d08c52637d38f3344a6e2c6f | refs/heads/master | 2021-01-17T23:21:48.902560 | 2011-10-04T14:41:00 | 2011-10-04T14:41:00 | 1,426,670 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,940 | cpp | bitcoinstrings.cpp | #include <QtGlobal>
// Automatically generated by extract_strings.py
static const char *bitcoin_strings[] = {QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin version"),
QT_TRANSLATE_NOOP("bitcoin-core", "Usage:"),
QT_TRANSLATE_NOOP("bitcoin-core", "Send command to -server or bitcoind\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "List commands\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Get help for a command\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Options:\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify configuration file (default: bitcoin.conf)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify pid file (default: bitcoind.pid)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Generate coins\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Don't generate coins\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Start minimized\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify data directory\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Specify connection timeout (in milliseconds)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect through socks4 proxy\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Allow DNS lookups for addnode and connect\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Add a node to connect to\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connect only to the specified node\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Don't accept connections from outside\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Don't attempt to use UPnP to map the listening port\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Attempt to use UPnP to map the listening port\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Fee per KB to add to transactions you send\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Accept command line and JSON-RPC commands\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Run in the background as a daemon and accept commands\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Password for JSON-RPC connections\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Listen for JSON-RPC connections on <port> (default: 8332)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Allow JSON-RPC connections from specified IP address\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Send commands to node running on <ip> (default: 127.0.0.1)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Set key pool size to <n> (default: 100)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Rescan the block chain for missing wallet transactions\n"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"\n"
"SSL options: (see the Bitcoin Wiki for SSL setup instructions)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Use OpenSSL (https) for JSON-RPC connections\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Server certificate file (default: server.cert)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Server private key (default: server.pem)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:"
"@STRENGTH)\n"),
QT_TRANSLATE_NOOP("bitcoin-core", "This help message\n"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Cannot obtain a lock on data directory %s. Bitcoin is probably already "
"running."),
QT_TRANSLATE_NOOP("bitcoin-core", "Loading addresses..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading addr.dat \n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Loading block index..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading blkindex.dat \n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Loading wallet..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat: Wallet corrupted \n"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Error loading wallet.dat: Wallet requires newer version of Bitcoin \n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error loading wallet.dat \n"),
QT_TRANSLATE_NOOP("bitcoin-core", "Rescanning..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Done loading"),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid -proxy address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid amount for -paytxfee=<amount>"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Warning: -paytxfee is set very high. This is the transaction fee you will "
"pay if you send a transaction."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: CreateThread(StartNode) failed"),
QT_TRANSLATE_NOOP("bitcoin-core", "Warning: Disk space is low "),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Unable to bind to port %d on this computer. Bitcoin is probably already "
"running."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"This transaction is over the size limit. You can still send it for a fee of "
"%s, which goes to the nodes that process your transaction and helps to "
"support the network. Do you want to pay the fee?"),
QT_TRANSLATE_NOOP("bitcoin-core", "Enter the current passphrase to the wallet."),
QT_TRANSLATE_NOOP("bitcoin-core", "Passphrase"),
QT_TRANSLATE_NOOP("bitcoin-core", "Please supply the current wallet decryption passphrase."),
QT_TRANSLATE_NOOP("bitcoin-core", "The passphrase entered for the wallet decryption was incorrect."),
QT_TRANSLATE_NOOP("bitcoin-core", "Status"),
QT_TRANSLATE_NOOP("bitcoin-core", "Date"),
QT_TRANSLATE_NOOP("bitcoin-core", "Description"),
QT_TRANSLATE_NOOP("bitcoin-core", "Debit"),
QT_TRANSLATE_NOOP("bitcoin-core", "Credit"),
QT_TRANSLATE_NOOP("bitcoin-core", "Open for %d blocks"),
QT_TRANSLATE_NOOP("bitcoin-core", "Open until %s"),
QT_TRANSLATE_NOOP("bitcoin-core", "%d/offline?"),
QT_TRANSLATE_NOOP("bitcoin-core", "%d/unconfirmed"),
QT_TRANSLATE_NOOP("bitcoin-core", "%d confirmations"),
QT_TRANSLATE_NOOP("bitcoin-core", "Generated"),
QT_TRANSLATE_NOOP("bitcoin-core", "Generated (%s matures in %d more blocks)"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Generated - Warning: This block was not received by any other nodes and will "
"probably not be accepted!"),
QT_TRANSLATE_NOOP("bitcoin-core", "Generated (not accepted)"),
QT_TRANSLATE_NOOP("bitcoin-core", "From: "),
QT_TRANSLATE_NOOP("bitcoin-core", "Received with: "),
QT_TRANSLATE_NOOP("bitcoin-core", "Payment to yourself"),
QT_TRANSLATE_NOOP("bitcoin-core", "To: "),
QT_TRANSLATE_NOOP("bitcoin-core", " Generating"),
QT_TRANSLATE_NOOP("bitcoin-core", "(not connected)"),
QT_TRANSLATE_NOOP("bitcoin-core", " %d connections %d blocks %d transactions"),
QT_TRANSLATE_NOOP("bitcoin-core", "Wallet already encrypted."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Enter the new passphrase to the wallet.\n"
"Please use a passphrase of 10 or more random characters, or eight or more "
"words."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: The supplied passphrase was too short."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"WARNING: If you encrypt your wallet and lose your passphrase, you will LOSE "
"ALL OF YOUR BITCOINS!\n"
"Are you sure you wish to encrypt your wallet?"),
QT_TRANSLATE_NOOP("bitcoin-core", "Please re-enter your new wallet passphrase."),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: the supplied passphrases didn't match."),
QT_TRANSLATE_NOOP("bitcoin-core", "Wallet encryption failed."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Wallet Encrypted.\n"
"Remember that encrypting your wallet cannot fully protect your bitcoins from "
"being stolen by malware infecting your computer."),
QT_TRANSLATE_NOOP("bitcoin-core", "Wallet is unencrypted, please encrypt it first."),
QT_TRANSLATE_NOOP("bitcoin-core", "Enter the new passphrase for the wallet."),
QT_TRANSLATE_NOOP("bitcoin-core", "Re-enter the new passphrase for the wallet."),
QT_TRANSLATE_NOOP("bitcoin-core", "Wallet Passphrase Changed."),
QT_TRANSLATE_NOOP("bitcoin-core", "New Receiving Address"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"You should use a new address for each payment you receive.\n"
"\n"
"Label"),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>Status:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", ", has not been successfully broadcast yet"),
QT_TRANSLATE_NOOP("bitcoin-core", ", broadcast through %d node"),
QT_TRANSLATE_NOOP("bitcoin-core", ", broadcast through %d nodes"),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>Date:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>Source:</b> Generated<br>"),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>From:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", "unknown"),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>To:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", " (yours, label: "),
QT_TRANSLATE_NOOP("bitcoin-core", " (yours)"),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>Credit:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", "(%s matures in %d more blocks)"),
QT_TRANSLATE_NOOP("bitcoin-core", "(not accepted)"),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>Debit:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>Transaction fee:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", "<b>Net amount:</b> "),
QT_TRANSLATE_NOOP("bitcoin-core", "Message:"),
QT_TRANSLATE_NOOP("bitcoin-core", "Comment:"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Generated coins must wait 120 blocks before they can be spent. When you "
"generated this block, it was broadcast to the network to be added to the "
"block chain. If it fails to get into the chain, it will change to \"not "
"accepted\" and not be spendable. This may occasionally happen if another "
"node generates a block within a few seconds of yours."),
QT_TRANSLATE_NOOP("bitcoin-core", "Cannot write autostart/bitcoin.desktop file"),
QT_TRANSLATE_NOOP("bitcoin-core", "Main"),
QT_TRANSLATE_NOOP("bitcoin-core", "&Start Bitcoin on window system startup"),
QT_TRANSLATE_NOOP("bitcoin-core", "&Minimize on close"),
QT_TRANSLATE_NOOP("bitcoin-core", "version %s"),
QT_TRANSLATE_NOOP("bitcoin-core", "Error in amount "),
QT_TRANSLATE_NOOP("bitcoin-core", "Send Coins"),
QT_TRANSLATE_NOOP("bitcoin-core", "Amount exceeds your balance "),
QT_TRANSLATE_NOOP("bitcoin-core", "Total exceeds your balance when the "),
QT_TRANSLATE_NOOP("bitcoin-core", " transaction fee is included "),
QT_TRANSLATE_NOOP("bitcoin-core", "Payment sent "),
QT_TRANSLATE_NOOP("bitcoin-core", "Sending..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid address "),
QT_TRANSLATE_NOOP("bitcoin-core", "Sending %s to %s"),
QT_TRANSLATE_NOOP("bitcoin-core", "CANCELLED"),
QT_TRANSLATE_NOOP("bitcoin-core", "Cancelled"),
QT_TRANSLATE_NOOP("bitcoin-core", "Transfer cancelled "),
QT_TRANSLATE_NOOP("bitcoin-core", "Error: "),
QT_TRANSLATE_NOOP("bitcoin-core", "Insufficient funds"),
QT_TRANSLATE_NOOP("bitcoin-core", "Connecting..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Unable to connect"),
QT_TRANSLATE_NOOP("bitcoin-core", "Requesting public key..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Received public key..."),
QT_TRANSLATE_NOOP("bitcoin-core", "Recipient is not accepting transactions sent by IP address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Transfer was not accepted"),
QT_TRANSLATE_NOOP("bitcoin-core", "Invalid response received"),
QT_TRANSLATE_NOOP("bitcoin-core", "Creating transaction..."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"This transaction requires a transaction fee of at least %s because of its "
"amount, complexity, or use of recently received funds"),
QT_TRANSLATE_NOOP("bitcoin-core", "Transaction creation failed"),
QT_TRANSLATE_NOOP("bitcoin-core", "Transaction aborted"),
QT_TRANSLATE_NOOP("bitcoin-core", "Lost connection, transaction cancelled"),
QT_TRANSLATE_NOOP("bitcoin-core", "Sending payment..."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"The transaction was rejected. This might happen if some of the coins in "
"your wallet were already spent, such as if you used a copy of wallet.dat and "
"coins were spent in the copy but not marked as spent here."),
QT_TRANSLATE_NOOP("bitcoin-core", "Waiting for confirmation..."),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"The payment was sent, but the recipient was unable to verify it.\n"
"The transaction is recorded and will credit to the recipient,\n"
"but the comment information will be blank."),
QT_TRANSLATE_NOOP("bitcoin-core", "Payment was sent, but an invalid response was received"),
QT_TRANSLATE_NOOP("bitcoin-core", "Payment completed"),
QT_TRANSLATE_NOOP("bitcoin-core", "Name"),
QT_TRANSLATE_NOOP("bitcoin-core", "Address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Label"),
QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin Address"),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"This is one of your own addresses for receiving payments and cannot be "
"entered in the address book. "),
QT_TRANSLATE_NOOP("bitcoin-core", "Edit Address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Edit Address Label"),
QT_TRANSLATE_NOOP("bitcoin-core", "Add Address"),
QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin"),
QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin - Generating"),
QT_TRANSLATE_NOOP("bitcoin-core", "Bitcoin - (not connected)"),
QT_TRANSLATE_NOOP("bitcoin-core", "&Open Bitcoin"),
QT_TRANSLATE_NOOP("bitcoin-core", "&Send Bitcoins"),
QT_TRANSLATE_NOOP("bitcoin-core", "O&ptions..."),
QT_TRANSLATE_NOOP("bitcoin-core", "E&xit"),
QT_TRANSLATE_NOOP("bitcoin-core", "Program has crashed and will terminate. "),
QT_TRANSLATE_NOOP("bitcoin-core", ""
"Warning: Please check that your computer's date and time are correct. If "
"your clock is wrong Bitcoin will not work properly."),
QT_TRANSLATE_NOOP("bitcoin-core", "beta"),
}; |
3d753a84a48f362f67a5db859dac6010927c5ece | 476af59c3267d2c865fef50a84a256dcf6dbe191 | /competition/First Half 2021/May 30. 2021/Solution1.cpp | ec054c9fcfbc4ca5afabc60cf078bb7733a272df | [] | no_license | yogurt-shadow/leetcode | fb3c2f47e77c3b40b06fa65cffe63095bd6542e7 | c824fa13237421afa69d05bb48026e7a2e407d02 | refs/heads/master | 2023-08-29T04:09:43.859492 | 2021-11-11T15:16:15 | 2021-11-11T15:16:15 | 325,449,621 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 749 | cpp | Solution1.cpp | #include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <string>
using ll = long long;
using namespace std;
class Solution1 {
public:
string convert(string x)
{
string ans = "";
for (auto ele : x)
{
ans = ans + (char)((ele - 'a') + '0');
}
return ans;
}
bool isSumEqual(string firstWord, string secondWord, string targetWord)
{
string s1 = convert(firstWord);
string s2 = convert(secondWord);
string s3 = convert(targetWord);
//cout << s1 << " " << s2 << " " << s3 << endl;
return stoi(s3) == stoi(s1) + stoi(s2);
}
}; |
be6dff8d56b7e61f7158eeef28901b7bfcd53f35 | 9344f03d92998cd82249090793327ca8b330f31d | /main.cpp | 4455cc35a998d28614e5930aa1ea0dc8be7ed2f8 | [] | no_license | manproffi/computorV1 | 71d009c3dd64f92401517b8d05fbe590f6bc8922 | 3a2915e4a498b5a7d1b845d891b879875fa64628 | refs/heads/master | 2020-03-30T04:00:29.987628 | 2018-10-08T18:21:34 | 2018-10-08T18:21:34 | 150,719,590 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 500 | cpp | main.cpp | #include <iostream>
//#include "lexer.h"
#include "validation.h"
#include "calculation.h"
int main(int argc, char *argv[])
{
if (argc == 2) {
validation val(argv[1]);
if (val.checking()) {
// std::cout << "Calculate" << std::endl;
calculation calc(val.getMap());
calc.startCalculation();
}
} else {
std::cout << "usage: ./computer \"polynomial equation\"" << std::endl;
}
// std::cout << std::endl;
return 0;
}
|
def7c7ae94e4d5951d039d3f3ca2a9cc0ce1586b | dd4168d088a0d70c80e8760880ada2b251fd07d0 | /src/log.cc | 5d3f869c64353acc875d94556f975697e768dd5a | [] | no_license | jfpu/epoll_event_processer | 75eeacd233cabf182be0942e8b5d35b41cb61fd2 | 05ccadc5ab23316fa2a899b86d58360ae3623b63 | refs/heads/master | 2020-06-05T07:52:14.445386 | 2015-07-09T10:46:53 | 2015-07-09T10:46:53 | 33,773,248 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,259 | cc | log.cc | #include "log.h"
wbl::log::async_writer_thread so_awt;
wbl::log::async_writer_thread sys_awt;
pid_t g_currentpid;
wbl::log::logger g_syslog;
wbl::log::logger g_solog;
bool SysLogInit(const string& file,
size_t level,
const string& format, size_t size) {
bool ret = g_syslog.initialize(level,
sys_awt.async_file(file + ".log",
wbl::log::cut_by_size_and_day(size)),
format.c_str());
if (ret) {
return sys_awt.start();
}
return false;
}
void SysLogReInit(size_t level) {
g_syslog.set_priority((wbl::log::logger::ELogPriority)level);
}
bool SoLogInit(const string& file,
size_t level,
const string& format, size_t size) {
bool ret = g_solog.initialize(level,
so_awt.async_file(file + ".log",
wbl::log::cut_by_day(size)),
format.c_str());
if (ret) {
return so_awt.start();
}
return true;
}
void SoLogReInit(size_t level) {
g_solog.set_priority((wbl::log::logger::ELogPriority)level);
}
|
4c76a0624aa5784765c23190812f550a65e559a8 | af9b093999a73245372003fb8c1ad6017be012a5 | /CodeForces/div2-551/B551.cpp | b4768bf5b7b34322ff3d484aab01bf4d7cec6de7 | [] | no_license | Dariiio/competitiveProgramming | 5463657cb5df2d96771d622622a9b26ec7e9bfec | ffb7f429bdea6ff08d3fdded68ce5f0e1301f540 | refs/heads/master | 2021-06-12T15:22:54.441439 | 2020-05-26T04:56:48 | 2020-05-26T04:56:48 | 128,706,958 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 493 | cpp | B551.cpp | #include <bits/stdc++.h>
// https://codeforces.com/contest/1153/problem/B
//ACCEPTED
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n,m,h,left[110],front[110],top[110][110];
cin>>n>>m>>h;
for(int i=0;i<m;i++) cin>>front[i];
for(int i=0;i<n;i++) cin>>left[i];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>top[i][j];
if(top[i][j]){
top[i][j] = min(front[j],left[i]);
}
cout<<top[i][j]<<" ";
}
cout<<"\n";
}
return 0;
}
|
73c41078236162d65c400eb7a1715fdc087786ef | b452e6308d47ba80161aed1bb5129ef69aa541f2 | /day03/ex01/ScavTrap.hpp | a12292abd7d9d0765fa04b39ce2b4c135664e955 | [] | no_license | AlexTiniakov/Piscine_CPP | 3dbc27c24c6ad5e634063ddb90b8f3a29d9730cd | 80cef87fde790d25ef6740da9083e80f12bb7413 | refs/heads/master | 2020-03-30T11:08:19.383653 | 2018-10-15T09:00:31 | 2018-10-15T09:00:31 | 151,155,242 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,614 | hpp | ScavTrap.hpp | // ************************************************************************** //
// //
// ::: :::::::: //
// ScavTrap.hpp :+: :+: :+: //
// +:+ +:+ +:+ //
// By: otiniako <otiniako@student.unit.ua> +#+ +:+ +#+ //
// +#+#+#+#+#+ +#+ //
// Created: 2018/10/04 23:03:18 by otiniako #+# #+# //
// Updated: 2018/10/04 23:03:18 by otiniako ### ########.fr //
// //
// ************************************************************************** //
#ifndef SCAVTRAP_HPP
# define SCAVTRAP_HPP
# include <string>
# include <iostream>
class ScavTrap
{
private:
std::string _Name;
int _Hit_points;
int _Max_hit_points;
int _Energy_points;
int _Max_energy_points;
int _Level;
int _Melee_attack_damage;
int _Ranged_attack_damage;
int _Armor_damage_reduction;
public:
ScavTrap(void);//+
~ScavTrap(void);//+
ScavTrap(const ScavTrap &rhs);//+
ScavTrap(std::string name);//+
ScavTrap &operator=(const ScavTrap &rhs);//+
void rangedAttack(std::string const & target);//+
void meleeAttack(std::string const & target);//+
void takeDamage(unsigned int amount);//+
void beRepaired(unsigned int amount);
void challengeNewcomer(void);
};
#endif |
ade0477aa90f36b812e2fe8330555fca3539f710 | 08033e5d145a469668b090fdde7477c260833141 | /HW12/6/main.cc | 1133673f7f51449c6c15b270ea2864cc38da250d | [] | no_license | austinschneider/schneider_PHYS401 | bd467b1436c71e4638ad76878d6210fad81df414 | b319b909fe72c89eef4d6574c66b4173da0cce02 | refs/heads/master | 2021-05-29T10:54:47.456526 | 2015-04-24T23:13:24 | 2015-04-24T23:13:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,509 | cc | main.cc | #include <iostream>
#include <tgmath.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <omp.h>
struct rule_set {
unsigned int size;
unsigned int rule_size;
bool * rules;
};
void next_state(bool * current, bool * next, unsigned int size, rule_set & rs) {
unsigned int id;
#pragma omp parallel
{
#pragma omp for private(id)
for(int i=0; i<size; ++i) {
id = 0;
id |= current[(i+size-1) % size] << 0x2;
id |= current[i] << 0x1;
id |= current[(i+1) % size] << 0x0;
next[i] = rs.rules[id];
}
}
}
void print(std::ostream & os, bool * state, unsigned int size) {
for(int i=0; i<size; ++i) {
if(state[i])
os << '#';
else
os << ' ';
}
os << std::endl;
}
rule_set make_rules(unsigned int size, unsigned int rule_num) {
rule_set r;
r.size = size;
r.rule_size = log2(size);
r.rules = new bool[size];
for(int i=0; i<size; ++i) {
r.rules[i] = (rule_num >> i) & 0x1;
}
return r;
}
void test_rules(std::ostream & os, unsigned int n_rules, unsigned int rule_num, unsigned int lattice_size, unsigned int n_iterations) {
bool * l0 = new bool[lattice_size]; memset(l0, 0, sizeof(l0));
bool * l1 = new bool[lattice_size]; memset(l1, 0, sizeof(l1));
bool * current = l0;
bool * next = l1;
current[lattice_size/2] = true;
rule_set rs = make_rules(n_rules, rule_num);
for(int i=0; i<n_iterations; ++i) {
print(os, current, lattice_size);
next_state(current, next, lattice_size, rs);
bool * t = current;
current = next;
next = t;
usleep(25000);
}
print(os, current, lattice_size);
}
int main(int argc, char * argv[]) {
int n_cores = omp_get_num_procs();
int n_threads = n_cores - 2;
omp_set_dynamic(n_threads);
unsigned int rule_num = 222;
unsigned int n_iterations = 100;
unsigned int rule_size = 8;
unsigned int lattice_size = 74;
if(argc <= 1) {
std::cout << "# Usage:" << std::endl;
std::cout << "main rule_num [n_iterations] [rule_size] [lattice_size]" << std::endl;
return 1;
}
if(argc > 1)
rule_num = atoi(argv[1]);
if(argc > 2)
n_iterations = atoi(argv[2]);
if(argc > 3)
rule_size = atoi(argv[3]);
if(argc > 4)
lattice_size = atoi(argv[4]);
test_rules(std::cout, rule_size, rule_num, lattice_size, n_iterations);
return 0;
}
|
6fb48eb4301538723af4e8c7431bbc1615aa1f54 | 866f29a61aa1a2f2a827349055ce599aa7dcb2a2 | /main.cpp | fc25efc8b37436106b6352faa94705a4212559d9 | [] | no_license | synich/finabook | 4e806ac34a79946ffa7d456a79163de91c175feb | f6d6d9e4da477397f44c8e17ccf30fba1654921d | refs/heads/master | 2016-09-06T19:11:30.601169 | 2014-03-17T15:09:28 | 2014-03-17T15:09:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,875 | cpp | main.cpp | #include "fina.h"
#include "stdio.h"
#include "FL/fl_ask.h"
#include "FL/Fl_Double_Window.H"
#include "FL/Fl_Button.H"
#include "FL/Fl_Input.H"
#include "FL/Fl_Output.H"
sqlite3* db;
const char* colname[] = {"id", "mon", "day", "type", "num", "memo", "ext"};
FinaTable::FinaTable(int x, int y, int w, int h, const char* l):Fl_Table(x, y, w, h, l){
row = 0;
memset(colvalue, 0, sizeof(colvalue));
rows(1);
row_header(1);
cols(7);
col_header(1);
col_width(5, 120);
end();
}
void FinaTable::draw_cell(TableContext context, int ROW, int COL, int X, int Y, int W, int H){
char s[64] = {0};
switch(context){
case CONTEXT_ROW_HEADER:
sprintf(s, "%d", ROW);
DrawHeader(s, X, Y, W, H);
return;
case CONTEXT_COL_HEADER:
DrawHeader(colname[COL], X, Y, W, H);
return;
case CONTEXT_CELL:
DrawData(colvalue[ROW][COL], X, Y, W, H);
return;
default:
return;
}
}
static void dispatch_select(Fl_Widget* w, void* v, int page){
sel_param *sp = (sel_param*)v;
const char* input = (sp->input)->value();
sp->table->row = 0; //Reset & Redraw Table
int ret = cb_sqlselect(input, sp, page);
if(ret != SQLITE_OK){
fl_message("Something wrong in your input! Error code=%d", ret);
}
return;
}
//Using this to decupling UI and Logic, so it's easy to change UI Library
static void cb_btnselect(Fl_Widget* w, void* v){
dispatch_select(w, v, 0);
}
static void cb_btnprevselect(Fl_Widget* w, void* v){
dispatch_select(w, v, -1);
}
static void cb_btnnextselect(Fl_Widget* w, void* v){
dispatch_select(w, v, 1);
}
static void cb_btninsert(Fl_Widget* w, void* v){
const char* input = ((Fl_Input*)w)->value();
int ret = cb_sqlinsert(input, NULL);
if(ret != SQLITE_OK){
fl_message("Something wrong in your insert statement! Error code=%d", ret);
}
return;
}
static void cb_winclose(Fl_Widget* w, void* v){
cb_sqlclose(v);
}
int main(int argc, char** argv){
int ret = sqlite3_open(DBPATH, &db);
if(ret != SQLITE_OK) return -1;
Fl_Double_Window win(900, 600, "Finace Table");
Fl_Input select_input(10, 10, 780, 25);
Fl_Button prew_sel(800, 10, 40, 25, "prev");
Fl_Button next_sel(850, 10, 40, 25, "next");
Fl_Input insert_input(10, 40, 880, 25);
FinaTable table(10,70,880,510);
win.end();
win.callback(cb_winclose, (void*)db);
win.resizable(table);
sel_param st_sp;
st_sp.table = &table;
st_sp.input = &select_input;
select_input.value("select * from y14h1 where type='income'");
select_input.when(FL_WHEN_ENTER_KEY_ALWAYS);
select_input.callback(cb_btnselect, &st_sp);
prew_sel.callback(cb_btnprevselect, &st_sp);
next_sel.callback(cb_btnnextselect, &st_sp);
insert_input.value("'food', -100, 'vegetable'");
insert_input.when(FL_WHEN_ENTER_KEY_ALWAYS);
insert_input.callback(cb_btninsert, NULL);
win.show(argc,argv);
return(Fl::run());
}
|
d2034343a3cacfa4700b637c153faf7c739c6b89 | 774f677194dde866a2d953f7d38c85d0f95d5414 | /cplusplus/boost_eigen_example /src/boost_eigen_example.cpp | 0b805c7a6846dc6f3db5b0e2bb473b654a907fcb | [] | no_license | arohamirai/my_awesome_project | 777bf567938e81ec228f1c1e858c3b3440e4ab30 | 42adbd172b4b20e894d34d7b6d8cd532a3d37c3e | refs/heads/master | 2021-06-18T13:20:03.465575 | 2021-03-04T07:16:04 | 2021-03-04T07:16:04 | 180,282,316 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 350 | cpp | boost_eigen_example.cpp | #include "Eigen/Core"
#include "Eigen/Geometry"
#include <boost/variant.hpp>
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
boost::variant<int, double, std::string> v;
v = 1;
std::cout << boost::get<int>(v) << std::endl;
v = "hello world";
std::cout << boost::get<std::string>(v) << std::endl;
return 0;
}
|
66781ae14d7851c291611be0e2833ab49b7e7a0d | cd64475ecbbf76a2768616c8900f4c3a308ed440 | /Autobackup/auto-backup.cpp | b63fdbb4f9b3a07a869e022fba64465b4aceed33 | [] | no_license | HJfod/gdtools | b3b777ecbcbabf3e2e74377d1058f5bc1d93f4bf | 66b85d3ece752c21a4cd3c7290fb222bc1c530d9 | refs/heads/master | 2022-12-31T09:10:32.340109 | 2020-10-23T07:57:22 | 2020-10-23T07:57:22 | 289,895,698 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,771 | cpp | auto-backup.cpp | #include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <ShlObj.h>
#include <sstream>
#include <tchar.h>
#include <windows.h>
#include <psapi.h>
#include <winuser.h>
#include <thread>
#include <chrono>
#include <ctime>
#include <time.h>
#include <direct.h>
//#include "zipper/zipper.h"
#define GD_NOT_OPEN 5
#define GD_IS_OPEN 6
#define ERR_GET_PROCESS_LIST 10
#define ERR_NO_SRC_DIR_SET 11
#define ERR_NO_DEST_DIR_SET 12
#define ERR_SRC_DOESNT_EXIST 13
#define ERR_DEST_DOESNT_EXIST 14
#define ERR_SETTINGS_FILE_NOT_FOUND 2
#define ERR_UNKNOWN 3
#define ERR_INSUFFICIENT_SETTINGS 4
#define BACKUP_SUCCESS 20
#define ERR_CCLOCALLEVELS_NOT_FOUND 21
#define ERR_CCGAMEMANAGER_NOT_FOUND 22
#define ERR_COPY_FILE_FROM_NOT_FOUND 25
#define COPY_SUCCESS 26
#define ERR_BACKUP_CANT_CREATE_DIR 23
#define ERR_BACKUP_CANT_CREATE_DEL_FILE 27
#define DEBUG false
#define VERSION "v1.0"
#define LOGFILE ".errlog"
#define BACKUPTEXT "GDTOOLS_BACKUP_"
#define DELETEFILE "autoRemove.txt"
#define COMPRESSEXT "gdb"
// clang++ auto-backup.cpp -o ab.exe -lshell32 -lole32
// TODO :
//
// -delete autobackups over limit
// -create at set rate
const std::string deleteText(std::string _am) {
return "This file will be deleted once your set limit of " + _am + " backups has been reached.\n\nIf you'd like to preserve this backup, delete this text file.";
}
std::string GetCCPath(std::string WHICH = "LocalLevels", std::string PATH = "") {
if (PATH != "") return PATH + "\\CC" + WHICH + ".dat";
wchar_t* localAppData = 0;
SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &localAppData);
std::wstring CCW (localAppData);
std::string RESULT ( CCW.begin(), CCW.end() );
RESULT += "\\GeometryDash\\CC" + WHICH + ".dat";
CoTaskMemFree(static_cast<void*>(localAppData));
return RESULT;
}
inline bool FileDirExists (const std::string& name) {
struct stat buffer;
return (stat (name.c_str(), &buffer) == 0);
}
void writeLog(std::string _log) {
std::ofstream logfile (LOGFILE);
if (logfile.is_open()) {
logfile << _log;
logfile.close();
}
}
void quit(int _CODE) {
writeLog("Application quit with error code " + std::to_string(_CODE) +
"\nCheck https://github.com/HJfod/gdtools/blob/master/Autobackup/ErrorCodes.md for details");
std::cout << "Error code: " << _CODE << std::endl;
std::exit(_CODE);
}
namespace sett {
std::string src = "";
std::string dest = "";
bool enabled = false;
unsigned int rate = 0;
unsigned int limit = 1;
unsigned long lastbackup = 0;
bool create_on_gd_close = 0;
bool compress = 0;
unsigned int gd_check_rate = 10;
bool debug = 0;
unsigned int gd_check_length = 3;
std::string compressed_ext = COMPRESSEXT;
}
enum SETT_CODES {
SRCDIR, DESTDIR, ENABLED, RATE, LIMIT, LAST, ONCLOSE, COMPRESS, CHECKRATE, DEBUGMODE, CHECKLENGTH, COMPEXT
};
int GetCode(std::string _line) {
if (_line == "src") return SRCDIR;
if (_line == "dest") return DESTDIR;
if (_line == "enabled") return ENABLED;
if (_line == "rate") return RATE;
if (_line == "limit") return LIMIT;
if (_line == "lastbackup") return LAST;
if (_line == "create_on_gd_close") return ONCLOSE;
if (_line == "compress") return COMPRESS;
if (_line == "gd_check_rate") return CHECKRATE;
if (_line == "debug") return DEBUGMODE;
if (_line == "gd_check_length") return CHECKLENGTH;
if (_line == "compress_ext") return COMPEXT;
return 0;
}
std::string GetProcessName(DWORD processID) {
TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>");
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processID);
if (hProcess != NULL) {
HMODULE hMod;
DWORD cbNeeded;
if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
GetModuleBaseName(hProcess, hMod, szProcessName, sizeof(szProcessName)/sizeof(TCHAR));
}
CloseHandle(hProcess);
std::basic_string<TCHAR> w = szProcessName;
return std::string(w.begin(), w.end());
}
int CopyFile(std::string from, std::string to) {
if (!FileDirExists(from))
quit(ERR_COPY_FILE_FROM_NOT_FOUND);
std::ifstream src(from, std::ios::binary);
std::ofstream dst(to, std::ios::binary);
dst << src.rdbuf();
return COPY_SUCCESS;
}
int CheckBackupsAmount() {
return 0;
}
int CreateBackup(std::string *ret) {
std::string ccll = GetCCPath("LocalLevels", sett::src);
std::string ccgm = GetCCPath("GameManager", sett::src);
if (!FileDirExists(ccll)) quit(ERR_CCLOCALLEVELS_NOT_FOUND);
if (!FileDirExists(ccgm)) quit(ERR_CCGAMEMANAGER_NOT_FOUND);
std::time_t t = std::time(0);
std::tm now;
localtime_s(&now, &t);
std::stringstream nams;
nams << sett::dest << "\\" << BACKUPTEXT
<< (now.tm_year + 1900) << '-' << (now.tm_mon + 1) << '-' << now.tm_mday;
std::string backuppath = nams.str();
if (_mkdir(backuppath.c_str()) != 0)
quit(ERR_BACKUP_CANT_CREATE_DIR);
std::ofstream delfile (backuppath + "\\" + DELETEFILE);
if (delfile.is_open()) {
delfile << deleteText(std::to_string(sett::limit));
delfile.close();
} else quit(ERR_BACKUP_CANT_CREATE_DEL_FILE);
CopyFile(ccll, backuppath + "\\CCLocalLevels.dat");
CopyFile(ccgm, backuppath + "\\CCGameManager.dat");
/*
if (sett::compress) {
std::ifstream gmf(backuppath + "\\CCLocalLevels.dat");
std::ifstream llf(backuppath + "\\CCGameManager.dat");
zipper::Zipper zipper(backuppath + "." + sett::compressed_ext);
zipper.add(gmf, "CCGameManager.dat");
zipper.add(llf, "CCLocalLevels.dat");
zipper.close();
std::system(("rd /s /q " + backuppath).c_str());
*ret = backuppath + "." + sett::compressed_ext;
} else */
*ret = backuppath;
return BACKUP_SUCCESS;
}
int CheckGDOpen() {
DWORD proc[1024], cb;
if (!EnumProcesses(proc, sizeof(proc), &cb)) return ERR_GET_PROCESS_LIST;
for (int i = 0; i < cb / sizeof(DWORD); i++)
if (proc[i] != 0)
if (GetProcessName(proc[i]) == "GeometryDash.exe")
return GD_IS_OPEN;
return GD_NOT_OPEN;
}
void GDOnCloseBackuper() {
unsigned int makeOnNext = 0;
while (sett::create_on_gd_close) {
switch (CheckGDOpen()) {
case GD_IS_OPEN:
makeOnNext += 1;
break;
case GD_NOT_OPEN:
if (makeOnNext >= sett::gd_check_length) {
std::cout << "Creating backup..." << std::endl;
std::string succ;
switch (CreateBackup(&succ)) {
case BACKUP_SUCCESS:
std::cout << "Succesfully made backup!" << std::endl << succ << std::endl;
break;
default:
quit(ERR_UNKNOWN);
}
}
break;
default:
quit(ERR_GET_PROCESS_LIST);
}
std::this_thread::sleep_for(std::chrono::seconds(sett::gd_check_rate));
}
}
int main() {
std::string line;
std::ifstream settings_file (".autobackup");
std::cout << "GDTools Autobackup " << VERSION << std::endl;
std::cout << "Developed by HJfod" << std::endl;
std::cout << "Loading .autobackup " << (DEBUG ? "[DEBUG ON]" : "") << "..." << std::endl;
std::chrono::steady_clock::time_point time;
#ifdef DEBUG
time = std::chrono::high_resolution_clock::now();
#endif
if (settings_file.is_open()) {
while ( getline (settings_file, line) ) {
std::string val = line.substr(line.find(" ") + 1);
switch (GetCode(line.substr(0, line.find(" ")))) {
case SRCDIR: sett::src = val; break;
case DESTDIR: sett::dest = val; break;
case ENABLED: sett::enabled = val == "1"; break;
case RATE: sett::rate = std::stoi(val); break;
case LIMIT: sett::limit = std::stoi(val); break;
case LAST: sett::lastbackup = std::stol(val); break;
case ONCLOSE: sett::create_on_gd_close = val == "1"; break;
case COMPRESS: sett::compress = val == "1"; break;
case CHECKRATE: sett::gd_check_rate = std::stoi(val); break;
case DEBUGMODE: sett::debug = val == "1"; break;
case CHECKLENGTH: sett::gd_check_length = std::stoi(val); break;
case COMPEXT: sett::compressed_ext = val; break;
}
}
settings_file.close();
} else quit(ERR_SETTINGS_FILE_NOT_FOUND);
if (!sett::enabled)
return 0;
//if (sett::src.empty()) quit(ERR_NO_SRC_DIR_SET);
if (sett::dest.empty()) quit(ERR_NO_DEST_DIR_SET);
if (!FileDirExists(sett::src.empty() ? GetCCPath() : sett::src)) quit(ERR_SRC_DOESNT_EXIST);
if (!FileDirExists(sett::dest)) quit(ERR_DEST_DOESNT_EXIST);
if (DEBUG || sett::debug) {
if (DEBUG) std::cout << std::endl << "Loaded in " << (std::chrono::high_resolution_clock::now() - time).count() << "ns" << std::endl;
std::cout << "Settings" << std::endl;
std::cout << "src: " << sett::src << std::endl;
std::cout << "dest: " << sett::dest << std::endl;
std::cout << "enabled: " << sett::enabled << std::endl;
std::cout << "rate: " << sett::rate << std::endl;
std::cout << "limit: " << sett::limit << std::endl;
std::cout << "lastbackup: " << sett::lastbackup << std::endl;
std::cout << "create_on_gd_close: " << sett::create_on_gd_close << std::endl;
std::cout << "compress: " << sett::compress << std::endl;
std::cout << "gd_check_rate: " << sett::gd_check_rate << std::endl;
std::cout << "gd_check_length: " << sett::gd_check_length << std::endl;
std::cout << "debug: " << sett::debug << std::endl << std::endl;
} else {
std::cout << "Backups directory: " << sett::dest << std::endl << std::endl;
}
if (sett::create_on_gd_close) {
std::thread thr(GDOnCloseBackuper);
thr.join();
}
return 0;
} |
135b31a020b3ff0864766e22ba382950b9cbf4d6 | da9c4798a6e30152382eb1ba876718b51b9bd4f2 | /UnionFindSet/main.cpp | 334b7432bb11110fbad9885a3d36715bee3774c6 | [] | no_license | zivyou/labofziv | cb2b51f48b3315a8f408eafa940fdc04e1797bfa | e0319d6bc1bbb417f49275bdd07c28019e4b4089 | refs/heads/master | 2023-08-17T03:10:05.615780 | 2023-08-07T06:42:05 | 2023-08-07T06:42:05 | 6,417,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 216 | cpp | main.cpp | #include <iostream>
#include "UnionFindSet.h"
int main() {
std::cout << "Hello, World!" << std::endl;
UnionFindSet ufs(5);
ufs.Union(0, 1);
ufs.Union(2, 3);
ufs.Union(3, 4);
ufs.display();
return 0;
}
|
5aa1c3210d116e2a6086c76150621a4456d9addd | 81361fbb260f3a43f2dfd05474c1bb06c5160d9c | /Codeforces/Accepted/155B.cpp | f4416be7b45286364ededa09b9326e3093631ab9 | [] | no_license | enamcse/ACM-Programming-Codes | 9307a22aafb0be6d8f64920e46144f2f813c493a | 70b57c35ec551eae6322959857b3ac37bcf615fa | refs/heads/master | 2022-10-09T19:35:54.894241 | 2022-09-30T01:26:24 | 2022-09-30T01:26:24 | 33,211,745 | 3 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 997 | cpp | 155B.cpp | #include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define sz 100
#define pb(a) push_back(a)
#define pp pop_back()
#define ll long long
#define fread freopen("input.txt","r",stdin)
#define fwrite freopen("output.txt","w",stdout)
#define inf (1<<30-1)
#define clr(abc,z) memset(abc,z,sizeof(abc))
#define PI acos(-1)
using namespace std;
struct data{
int a,b;
bool operator< (const data &z) const{
if(z.b==b) return z.a>a;
else return z.b>b;
}
data(int x, int y){
a = x;
b = y;
}
};
priority_queue<data> pq;
int main()
{
_
int n, p,q, k = 1, point=0;
scanf("%d", &n);
for (int i =0;i<n; i++)
{
scanf("%d %d", &p, &q);
pq.push(data(p,q));
}
while(!pq.empty()&&k)
{
point+= pq.top().a;
k+= pq.top().b;
k--;
// cout<<pq.top().a<<" "<<pq.top().b<<" "<<k<<endl;
pq.pop();
}
cout<<point;
return 0;
}
|
8ebe985f0c1bf02f7658a33094383fa2eab3d4ee | a4a71609cb38e8d2bac69c39bc423c19e5ff7737 | /algo/dp/purmutation/permutation.cpp | ec600200ec123f69c8de6e4162bc51901696adcb | [] | no_license | fahadahmedocean/srbd | 3822c1e6de3de2f484d0dafe11882f2a22e5382a | 6aa656fcdd9fbdb2cdc98c74c73cd64fb355ff28 | refs/heads/master | 2020-04-27T12:31:51.941635 | 2019-03-07T12:14:01 | 2019-03-07T12:14:01 | 174,334,763 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,071 | cpp | permutation.cpp | #include<iostream>
using namespace std;
long long int cnt=0,pos;
int visit[100]= {0};
void change(char *a,int i,int j)
{
int temp = a[j];
while(j>i)
{
a[j] = a[j-1];
j--;
}
a[j] = temp;
}
void revert(char *a,int i,int j)
{
int temp = a[i];
while(i<j)
{
a[i] = a[i+1];
i++;
}
a[i] = temp;
}
void permute(char *a,int i, int n)
{
if(i==n)
{
cout<<a<<endl;
return;
}
for(int j=i; j<=n; j++)
{
if(visit[i]==0)
{
visit[i]=1;
change(a,i,j);
permute(a,i+1,n);
//backtrack
visit[i]=0;
revert(a,i,j);
}
}
}
int main()
{
int test;
cin>>test;
while(test--)
{
visit[100]= {0};
char a[50];
cin>>a;
int sz=0;
while(a[sz]!='\0')
{
sz++;
}
// cin>>pos;
permute(a,0,sz-1);
}
return 0;
}
|
ed7cc44543a47c242aa173a7102ecc5439ffd4b9 | e972f2484e92e68cf90353c7b3b392024795fe78 | /gltfscene.h | 917f3a7731338b670cb57f74a418064b1d644cc7 | [] | no_license | wtrsltnk/gltf-viewer | 2550e1beaa04ffe1cfcd727c9aa0fbb33662cdb2 | 46211b212179e24172cd113b81b476fc6c1c3234 | refs/heads/master | 2023-04-15T16:09:36.334767 | 2023-04-11T20:51:14 | 2023-04-11T20:51:14 | 96,828,543 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,053 | h | gltfscene.h | /* gltfscene - v0.1 - public domain gltf 2.0 model renderer for opengl
Do this:
#define GLSCENE_IMPLEMENTATION
before you include this file in *one* C or C++ file to create the implementation.
Release notes:
v0.1 (2017-07-13) initial version based on tiny_gltf glview.cc
LICENSE
This software is in the public domain. Where that dedication is not
recognized, you are granted a perpetual, irrevocable license to copy,
distribute, and modify this file as you see fit.
*/
#ifndef GLSCENE_H
#define GLSCENE_H
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <GL/gl.h>
#include "tiny_gltf.h"
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
class GLScene
{
typedef struct { GLuint vb; } GLBufferState;
typedef struct {
std::map<int, GLuint> diffuseTex; // for each primitive in mesh
} GLMeshState;
tinygltf::Model _model;
std::map<int, GLBufferState> _buffers;
std::map<std::string, GLMeshState> _meshStates;
std::map<std::string, GLint> _attribs;
public:
GLScene();
virtual ~GLScene();
bool Load(const std::string& filename);
void Setup(GLuint prog);
void DrawMesh(int index);
void DrawNode(int index);
void Draw();
void Cleanup();
};
#endif // GLSCENE_H
#ifdef GLSCENE_IMPLEMENTATION
std::string GetFilePathExtension(const std::string &FileName)
{
if (FileName.find_last_of(".") != std::string::npos)
return FileName.substr(FileName.find_last_of(".") + 1);
return "";
}
GLScene::GLScene() { }
GLScene::~GLScene() { }
bool GLScene::Load(const std::string& filename)
{
std::string err;
std::string ext = GetFilePathExtension(filename);
bool ret = false;
if (ext.compare("glb") == 0) // assume binary glTF.
{
ret = tinygltf::TinyGLTF().LoadBinaryFromFile(&this->_model, &err, filename.c_str());
}
else // assume ascii glTF.
{
ret = tinygltf::TinyGLTF().LoadASCIIFromFile(&this->_model, &err, filename.c_str());
}
if (!err.empty()) std::cerr << "ERR: " << err << std::endl;
return ret;
}
void GLScene::Setup(GLuint prog)
{
glUseProgram(prog);
this->_attribs["POSITION"] = glGetAttribLocation(prog, "in_vertex");
this->_attribs["NORMAL"] = glGetAttribLocation(prog, "in_normal");
this->_attribs["TEXCOORD_0"] = glGetAttribLocation(prog, "in_texcoord");
for (size_t i = 0; i < this->_model.bufferViews.size(); i++)
{
auto bufferView = this->_model.bufferViews[i];
if (bufferView.target == 0)
{
std::cout << "WARN: bufferView.target is zero" << std::endl;
continue; // Unsupported bufferView.
}
auto buffer = this->_model.buffers[bufferView.buffer];
GLBufferState state;
glGenBuffers(1, &state.vb);
glBindBuffer(bufferView.target, state.vb);
glBufferData(bufferView.target, bufferView.byteLength, &buffer.data.at(0) + bufferView.byteOffset, GL_STATIC_DRAW);
glBindBuffer(bufferView.target, 0);
this->_buffers[i] = state;
}
// Texture
{
for (auto mesh : this->_model.meshes) {
for (auto primitive : mesh.primitives) {
if (primitive.material < 0) {
continue;
}
auto mat = this->_model.materials[primitive.material];
auto baseColorTexture = mat.values["baseColorTexture"];
auto imageIndex = baseColorTexture.json_double_value["index"];
auto image = this->_model.images[imageIndex];
GLuint texId;
glGenTextures(1, &texId);
_meshStates[mesh.name].diffuseTex[primitive.material] = texId;
glBindTexture(GL_TEXTURE_2D, texId);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// Ignore Texture.fomat.
GLenum format = GL_RGBA;
if (image.component == 3) format = GL_RGB;
glTexImage2D(GL_TEXTURE_2D, 0, format, image.width,
image.height, 0, format, GL_UNSIGNED_BYTE,
&image.image.at(0));
glBindTexture(GL_TEXTURE_2D, 0);
}
}
}
}
void GLScene::DrawMesh(int index)
{
auto mesh = this->_model.meshes[index];
for (auto primitive : mesh.primitives)
{
if (primitive.indices < 0) return;
if (primitive.material >= 0)
{
glBindTexture(GL_TEXTURE_2D, this->_meshStates[mesh.name].diffuseTex[primitive.material]);
}
for (auto it : primitive.attributes)
{
if (it.second < 0) continue;
auto accessor = this->_model.accessors[it.second];
glBindBuffer(GL_ARRAY_BUFFER, this->_buffers[accessor.bufferView].vb);
int count = 1;
if (accessor.type == TINYGLTF_TYPE_SCALAR) count = 1;
else if (accessor.type == TINYGLTF_TYPE_VEC2) count = 2;
else if (accessor.type == TINYGLTF_TYPE_VEC3) count = 3;
else if (accessor.type == TINYGLTF_TYPE_VEC4) count = 4;
else assert(0);
if ((it.first.compare("POSITION") == 0) || (it.first.compare("NORMAL") == 0) || (it.first.compare("TEXCOORD_0") == 0))
{
auto attr = this->_attribs[it.first];
if (attr >= 0)
{
glVertexAttribPointer(attr, count, accessor.componentType, GL_FALSE, 0, BUFFER_OFFSET(accessor.byteOffset));
glEnableVertexAttribArray(attr);
}
}
}
auto indexAccessor = this->_model.accessors[primitive.indices];
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->_buffers[indexAccessor.bufferView].vb);
int mode = -1;
if (primitive.mode == TINYGLTF_MODE_TRIANGLES) mode = GL_TRIANGLES;
else if (primitive.mode == TINYGLTF_MODE_TRIANGLE_STRIP) mode = GL_TRIANGLE_STRIP;
else if (primitive.mode == TINYGLTF_MODE_TRIANGLE_FAN) mode = GL_TRIANGLE_FAN;
else if (primitive.mode == TINYGLTF_MODE_POINTS) mode = GL_POINTS;
else if (primitive.mode == TINYGLTF_MODE_LINE) mode = GL_LINES;
else if (primitive.mode == TINYGLTF_MODE_LINE_LOOP) mode = GL_LINE_LOOP;
glDrawElements(mode, indexAccessor.count, indexAccessor.componentType, BUFFER_OFFSET(indexAccessor.byteOffset));
for (auto it : primitive.attributes)
{
if ((it.first.compare("POSITION") == 0) || (it.first.compare("NORMAL") == 0) || (it.first.compare("TEXCOORD_0") == 0))
{
auto attr = this->_attribs[it.first];
if (attr >= 0) glDisableVertexAttribArray(attr);
}
}
}
}
void GLScene::DrawNode(int index)
{
auto node = this->_model.nodes[index];
glPushMatrix();
if (node.matrix.size() == 16)
{
// Use `matrix' attribute
glMultMatrixd(node.matrix.data());
}
else
{
if (node.translation.size() == 3)
{
glTranslated(node.translation[0], node.translation[1], node.translation[2]);
}
if (node.rotation.size() == 4)
{
glRotated(node.rotation[0], node.rotation[1], node.rotation[2], node.rotation[3]);
}
if (node.scale.size() == 3)
{
glScaled(node.scale[0], node.scale[1], node.scale[2]);
}
}
if (node.mesh >= 0) DrawMesh(node.mesh);
// Draw child nodes.
for (auto child : node.children) DrawNode(child);
glPopMatrix();
}
void GLScene::Draw()
{
if (this->_model.defaultScene < 0) return;
auto scene = this->_model.scenes[this->_model.defaultScene];
for (auto node : scene.nodes)
{
DrawNode(node);
}
}
void GLScene::Cleanup()
{
}
#endif // GLSCENE_IMPLEMENTATION
|
ad5f130dca2b8f3e56981d75d50c983895c695a2 | 210f8682934b43c815ae36ff0bb0e00a6e7958fe | /game/source/Particles.cpp | f0a41c6535781e4d7de8550d587b2edc3ed512b6 | [] | no_license | bpetar/leonline | 267b17d32f6d62f76d812746fb593814aefbf95d | cc3570f6e5540e8a7d5fa040121f8cf3e45f1723 | refs/heads/master | 2021-01-22T07:04:14.616110 | 2013-03-20T22:32:37 | 2013-03-20T22:32:37 | 33,636,342 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 595 | cpp | Particles.cpp | /**
* \file Particles.cpp
* \brief CParticles class is containing Particle effects.
*
* \author Petar Bajic, MPE (C) All Rights Reserved, Homepage: www.mystic-peanut.com
* \date October, 21 2011.
*/
#include <irrlicht.h>
using namespace irr;
using namespace io;
#include "Particles.h"
#include "GameManager.h"
/**
* \brief Standard constructor.
* \author Petar Bajic
* \date October, 21 2011.
*/
CParticles::CParticles()
{
}
/**
* \brief Standard destructor.
* \author Petar Bajic
* \date October, 21 2011.
*/
CParticles::~CParticles()
{
}
|
50d608b4cbfb3f03a2e3d3d0fa05bc2f3dab5928 | a27d15c62bdd55ab50ffff17e868052704dacf64 | /Source.cpp | 2c12910b356828b1c6f8c73708b1f519694bf44a | [] | no_license | chwaqarali6/Fractional-Calculator-Problem | b89b17cc5e17169b4ae25e44256dd3104c8f0c26 | 8d0159a4593f390b6a15261121be105e328fa3fc | refs/heads/master | 2020-03-24T14:08:57.286655 | 2018-07-29T14:12:21 | 2018-07-29T14:12:21 | 142,760,488 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,430 | cpp | Source.cpp | #include <iostream>
#include <conio.h>
using namespace std;
void main()
{
//Initializing Variables
int Numerator1 = 0, Numerator2 = 0, Denominator1 = 0, Denominator2 = 0, FinalNumerator = 0, FinalDenominator = 0, Divider = 0;
char opt;
//Taking Inputs
cout << "Please Enter The Numerator Of Fraction 1:- ";
cin >> Numerator1;
cout << "Please Enter The Denominator Of Fraction 1:- ";
cin >> Denominator1;
cout << "Please Enter The Operator ( + - * / ):- ";
cin >> opt;
cout << "Please Enter The Numerator Of Fraction 2:- ";
cin >> Numerator2;
cout << "Please Enter The Denominator Of Fraction 2:- ";
cin >> Denominator2;
//Checking Conditions For Operator Used
if (opt == '+')
{
FinalNumerator = (Numerator1*Denominator2) + (Numerator2*Denominator1);
FinalDenominator = (Denominator1*Denominator2);
//Calculating The Lowest Fraction & Finding Undefined Fraction
Divider = FinalDenominator;
while (Divider >= 2)
{
if (FinalNumerator%Divider == 0 && FinalDenominator%Divider == 0)
{
FinalNumerator = FinalNumerator / Divider;
FinalDenominator = FinalDenominator / Divider;
}
else
{
Divider--;
}
}
if (FinalDenominator == 0)
{
cout << "The Answer Is Undefined";
}
else
{
cout << "The Answer Is " << FinalNumerator << "/" << FinalDenominator;
}
}
else if (opt == '-')
{
FinalNumerator = (Numerator1*Denominator2) - (Numerator2*Denominator1);
FinalDenominator = (Denominator1*Denominator2);
//Calculating The Lowest Fraction & Finding Undefined Fraction
Divider = FinalDenominator;
while (Divider >= 2)
{
if (FinalNumerator%Divider == 0 && FinalDenominator%Divider == 0)
{
FinalNumerator = FinalNumerator / Divider;
FinalDenominator = FinalDenominator / Divider;
}
else
{
Divider--;
}
}
if (FinalDenominator == 0)
{
cout << "The Answer Is Undefined";
}
else
{
cout << "The Answer Is " << FinalNumerator << "/" << FinalDenominator;
}
}
else if (opt == '*')
{
FinalNumerator = (Numerator1*Numerator2);
FinalDenominator = (Denominator1*Denominator2);
//Calculating The Lowest Fraction & Finding Undefined Fraction
Divider = FinalDenominator;
while (Divider >= 2)
{
if (FinalNumerator%Divider == 0 && FinalDenominator%Divider == 0)
{
FinalNumerator = FinalNumerator / Divider;
FinalDenominator = FinalDenominator / Divider;
}
else
{
Divider--;
}
}
if (FinalDenominator == 0)
{
cout << "The Answer Is Undefined";
}
else
{
cout << "The Answer Is " << FinalNumerator << "/" << FinalDenominator;
}
}
else if (opt == '/')
{
FinalNumerator = (Numerator1*Denominator2);
FinalDenominator = (Denominator1*Numerator2);
//Calculating The Lowest Fraction & Finding Undefined Fraction
Divider = FinalDenominator;
while (Divider >= 2)
{
if (FinalNumerator%Divider == 0 && FinalDenominator%Divider == 0)
{
FinalNumerator = FinalNumerator / Divider;
FinalDenominator = FinalDenominator / Divider;
}
else
{
Divider--;
}
}
if (FinalDenominator == 0)
{
cout << "The Answer Is Undefined";
}
else
{
cout << "The Answer Is " << FinalNumerator << "/" << FinalDenominator;
}
}
else
{
cout << "Invalid Operator";
}
_getch();
} |
28fa3d0a466b0a424b0825849f0e56abe5d3582f | eb7c3395b5edc43f1333cd13db1272a5124532b6 | /deptran/rcc/commo.h | ef6377612c10ee6cf1d68f0f03eb49b6959d1edc | [] | no_license | lolo-pop/dast | 6febd59ed5efe6fa2f8c227cd874e0512cc31f84 | 3a3dcb5225e0690bcd874be1d9d7f80f168735c1 | refs/heads/master | 2023-03-19T20:08:32.370128 | 2021-03-16T14:40:40 | 2021-03-16T14:40:40 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,229 | h | commo.h | #pragma once
#include "../__dep__.h"
#include "../commo.h"
namespace rococo {
class SimpleCommand;
class RccGraph;
class RccCommo : public RococoCommunicator {
public:
using RococoCommunicator::RococoCommunicator;
virtual void SendDispatch(vector<SimpleCommand> &cmd,
const function<void(int res,
TxnOutput& cmd,
RccGraph& graph)>&) ;
virtual void SendHandoutRo(SimpleCommand &cmd,
const function<void(int res,
SimpleCommand& cmd,
map<int, mdb::version_t>& vers)>&) ;
virtual void SendFinish(parid_t pid,
txnid_t tid,
RccGraph& graph,
const function<void(map<innid_t,
map<int32_t, Value>>&
output)> &callback) ;
virtual void SendInquire(parid_t pid,
epoch_t epoch,
txnid_t tid,
const function<void(RccGraph& graph)>&);
};
} // namespace rococo |
55e62516bec2bf1d23a6b19efa1b17725637fe7f | 3c237996251c0cb3c0a2bc01a02110d7c8bba22a | /Tweet.h | a1df7b2d30df6db041bec37c59ff5458cbc6ebaf | [] | no_license | WizKIDz/cpp-twitter | 37ac0c6f90f858ed212124986ab76fdaca54fb68 | 02d8131b446c90d54774b20bfb3fb90e26582b05 | refs/heads/master | 2016-08-12T09:38:04.849511 | 2015-11-24T04:51:41 | 2015-11-24T04:51:41 | 46,693,851 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 743 | h | Tweet.h | //
// Tweet.h
// TwitterRESTInterface
//
// Created by austin crane on 9/18/15.
// Copyright (c) 2015 OzDreams. All rights reserved.
//
#ifndef __TwitterRESTInterface__Tweet__
#define __TwitterRESTInterface__Tweet__
#include <stdio.h>
#include <json/json.h>
#include <string>
#include "TwitterUser.h"
class Tweet{
public:
Tweet():t_id(0),t_text(""),t_retweeted(false),t_retweets(0){};
Tweet(Json::Value j);
// Constructors
// Accessors
std::string get_text();
// Setters
void set_text(std::string text);
TwitterUser getUser();
private:
int t_id;
std::string t_text;
TwitterUser t_user;
bool t_retweeted;
int t_retweets;
};
#endif /* defined(__TwitterRESTInterface__Tweet__) */
|
600f4c50406b196583af5a98c402d41151b7d823 | dea178f52fed5236874ee1c11f1c969e5ffada74 | /Libooxml/trunk/Libooxml/dml-main/CT_TextFont.cpp | fb5be0f754ba20274e46eaae09fc0c12723fd546 | [] | no_license | andrew2015/ooxmlpp | 411d1d43b35b82ee00d371ad0e3eeda0278a52b9 | 3bf26fe79d8932d873bbb3595ba1e5de20017cee | refs/heads/master | 2021-06-16T16:24:39.555456 | 2012-10-01T20:29:21 | 2012-10-01T20:29:21 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,308 | cpp | CT_TextFont.cpp | #include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <dml-main.h>
using namespace drawingml::main;
CT_TextFont::CT_TextFont(ST_TextTypeface &_typeface) {
typeface = _typeface;
}
CT_TextFont::CT_TextFont(CT_TextFont &b) {
pitchAndFamily = b.pitchAndFamily;
charset = b.charset;
typeface = b.typeface;
panose = b.panose;
}
CT_TextFont::CT_TextFont(xercesc_3_1::DOMNodeList *nodelist, xercesc_3_1::DOMNamedNodeMap *attributes) {
if (attributes->getNamedItem(L"pitchAndFamily")) {
pitchAndFamily = attributes->getNamedItem(L"pitchAndFamily")->getNodeValue();
}
if (attributes->getNamedItem(L"charset")) {
charset = attributes->getNamedItem(L"charset")->getNodeValue();
}
if (attributes->getNamedItem(L"typeface")) {
typeface = attributes->getNamedItem(L"typeface")->getNodeValue();
}
if (attributes->getNamedItem(L"panose")) {
panose = attributes->getNamedItem(L"panose")->getNodeValue();
}
for (int i = 0; i < nodelist->getLength();++i) {
}
}
CT_TextFont& CT_TextFont::operator=(CT_TextFont &b) {
pitchAndFamily = b.pitchAndFamily;
charset = b.charset;
typeface = b.typeface;
panose = b.panose;
return *this;
}
CT_TextFont::~CT_TextFont() {
}
std::wstring CT_TextFont::Xml() {
return L"";
}
|
bd5abe65c4d3d395692d79317adf1911f8af2e8f | 8775fa748f40950d10122016ff4fe44c03f4e0c5 | /polygonRSA/Vector.tpp | 6568a345bb19e02107e50d625485bb89dbc02341 | [] | no_license | misiekc/polygonRSA | 2f7561a524d08ab384ea8da8b784761085bafc95 | f286d80b9a0aec672085a6e4c7adb16d2abc0a4e | refs/heads/master | 2021-06-24T06:20:33.419569 | 2021-01-06T15:12:05 | 2021-01-06T15:12:05 | 186,135,672 | 5 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,363 | tpp | Vector.tpp | //--------------------------------------------------------------------------------------------
// Class representing vectors and operations on them. Template definitions
//--------------------------------------------------------------------------------------------
// (C)PKua 2017
//--------------------------------------------------------------------------------------------
// Addition
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
Vector<DIM, E> operator+(const Vector<DIM, E> & _v1, const Vector<DIM, E> & _v2)
{
return Vector<DIM, E>(std::move(_v1.v + _v2.v));
}
// Subtration
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
Vector<DIM, E> operator-(const Vector<DIM, E> & _v1, const Vector<DIM, E> & _v2)
{
return Vector<DIM, E>(std::move(_v1.v - _v2.v));
}
// Multiplication by scalar
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
Vector<DIM, E> operator*(E _x, const Vector<DIM, E> & _v)
{
return Vector<DIM, E>(std::move(_x * _v.v));
}
// Multiplication by scalar (different operands order)
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
Vector<DIM, E> operator*(const Vector<DIM, E> & _v, E _x)
{
return Vector<DIM, E>(std::move(_x * _v.v));
}
// Division by scalar
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
Vector<DIM, E> operator/(const Vector<DIM, E> & _v, E _x)
{
return Vector<DIM, E>(std::move(_v.v / _x));
}
// Scalar product
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
E operator*(const Vector<DIM, E> & _v1, const Vector<DIM, E> & _v2)
{
E prod = 0;
for (std::size_t i = 0; i < DIM; i++)
prod += _v1._get(i) * _v2._get(i);
return prod;
}
// Linear transformation (multiplication of matrix and this)
//--------------------------------------------------------------------------------------------
template <std::size_t DIM1, std::size_t DIM2, typename E>
Vector<DIM2, E> operator*(const Matrix<DIM2, DIM1, E> & _m, const Vector<DIM1, E> & _v)
{
return Vector<DIM2, E>(std::move(_m * _v.v));
}
// Equality
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
bool operator==(const Vector<DIM, E> & _v1, const Vector<DIM, E> & _v2)
{
return (_v1.v == _v2.v);
}
// Inequality
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
bool operator!=(const Vector<DIM, E> & _v1, const Vector<DIM, E> & _v2)
{
return (_v1.v != _v2.v);
}
/*
// Cross product
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
Vector<DIM, E>::enabled<DIM == 3, Vector<DIM, E>>
operator^(const Vector<DIM, E> & _v1, const Vector<DIM, E> & _v2)
{
return Vector<3, E>({
_v1._get(1) * _v2._get(2) - _v1._get(2) * _v2._get(1),
_v1._get(2) * _v2._get(0) - _v1._get(0) * _v2._get(2),
_v1._get(0) * _v2._get(1) - _v1._get(1) * _v2._get(0) });
}
*/
// Cross product
//--------------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
Vector<DIM, E> operator^(const Vector<DIM, E> & _v1, const Vector<DIM, E> & _v2)
{
return Vector<3, E>({
_v1._get(1) * _v2._get(2) - _v1._get(2) * _v2._get(1),
_v1._get(2) * _v2._get(0) - _v1._get(0) * _v2._get(2),
_v1._get(0) * _v2._get(1) - _v1._get(1) * _v2._get(0) });
}
// Print vector to _ostr output stream
//-----------------------------------------------------------------------------------------
template <std::size_t DIM, typename E>
std::ostream & operator<<(std::ostream & _ostr, const Vector<DIM, E> & _v)
{
_ostr << "{";
for (std::size_t i = 0; i < DIM - 1; i++)
_ostr << _v.v(i, 0) << ", ";
_ostr << _v.v(DIM - 1, 0) << "}";
return _ostr;
}
|
a23131cde5d206cfc0a6e62dfc0381687543aef5 | b1529e253d5dc9f9e459128589cfef1b09af156d | /src/atomics.h | d3aa9d8ba8b3be15b2497c9f863be19265b6ba5b | [
"LGPL-3.0-or-later",
"Zlib",
"MIT",
"LicenseRef-scancode-other-permissive",
"ISC",
"LGPL-2.0-or-later",
"MPL-2.0",
"BSD-3-Clause",
"GPL-2.0-only",
"BSL-1.0",
"GPL-2.0-or-later",
"Apache-2.0",
"MPL-1.0",
"BSD-2-Clause"
] | permissive | PallHaraldsson/julia | f265c0b8643f0ee4dde42db3fb552058a8511d89 | 618d3f2f5d1c92bb3995d83f733518beb552315a | refs/heads/master | 2023-05-27T06:31:22.948176 | 2020-10-22T20:41:50 | 2020-10-22T20:41:50 | 21,274,816 | 4 | 0 | MIT | 2023-08-09T23:02:59 | 2014-06-27T12:25:21 | Julia | UTF-8 | C++ | false | false | 13,194 | h | atomics.h | // This file is a part of Julia. License is MIT: https://julialang.org/license
#ifndef JL_ATOMICS_H
#define JL_ATOMICS_H
// Low-level atomic operations
#if defined(__i386__) && defined(__GNUC__) && !defined(__SSE2__)
# error Julia can only be built for architectures above Pentium 4. Pass -march=pentium4, or set MARCH=pentium4 and ensure that -march is not passed separately with an older architecture.
#endif
#ifdef _COMPILER_MICROSOFT_
# include <intrin.h>
# include <type_traits>
#endif
#if defined(_CPU_X86_64_) || defined(_CPU_X86_)
# include <immintrin.h>
#endif
#ifndef _OS_WINDOWS_
# include <pthread.h>
#endif
#include <signal.h>
/**
* Thread synchronization primitives:
*
* These roughly follows the c11/c++11 memory model and the act as memory
* barriers at both the compiler level and the hardware level.
* The only exception is the GC safepoint and GC state transitions for which
* we use only a compiler (signal) barrier and use the signal handler to do the
* synchronization in order to lower the mutator overhead as much as possible.
*
* We use the compiler intrinsics to implement a similar API to the c11/c++11
* one instead of using it directly because,
*
* 1. We support GCC 4.7 and GCC add support for c11 atomics in 4.9.
* Luckily, the __atomic intrinsics were added in GCC 4.7.
* 2. (most importantly) we need interoperability between code written
* in different languages.
* The current c++ standard (c++14) does not allow using c11 atomic
* functions or types and there's currently no guarantee that the two
* types are compatible (although most of them probably are).
* We also need to access these atomic variables from the LLVM JIT code
* which is very hard unless the layout of the object is fully
* specified.
*/
#if defined(__GNUC__)
# define jl_fence() __atomic_thread_fence(__ATOMIC_SEQ_CST)
# define jl_fence_release() __atomic_thread_fence(__ATOMIC_RELEASE)
# define jl_signal_fence() __atomic_signal_fence(__ATOMIC_SEQ_CST)
# define jl_atomic_fetch_add_relaxed(obj, arg) \
__atomic_fetch_add(obj, arg, __ATOMIC_RELAXED)
# define jl_atomic_fetch_add(obj, arg) \
__atomic_fetch_add(obj, arg, __ATOMIC_SEQ_CST)
# define jl_atomic_add_fetch(obj, arg) \
__atomic_add_fetch(obj, arg, __ATOMIC_SEQ_CST)
# define jl_atomic_fetch_and_relaxed(obj, arg) \
__atomic_fetch_and(obj, arg, __ATOMIC_RELAXED)
# define jl_atomic_fetch_and(obj, arg) \
__atomic_fetch_and(obj, arg, __ATOMIC_SEQ_CST)
# define jl_atomic_fetch_or_relaxed(obj, arg) \
__atomic_fetch_or(obj, arg, __ATOMIC_RELAXED)
# define jl_atomic_fetch_or(obj, arg) \
__atomic_fetch_or(obj, arg, __ATOMIC_SEQ_CST)
// Returns the original value of `obj`
// Use the legacy __sync builtins for now, this can also be written using
// the __atomic builtins or c11 atomics with GNU extension or c11 _Generic
# define jl_atomic_compare_exchange(obj, expected, desired) \
__sync_val_compare_and_swap(obj, expected, desired)
# define jl_atomic_bool_compare_exchange(obj, expected, desired) \
__sync_bool_compare_and_swap(obj, expected, desired)
# define jl_atomic_exchange(obj, desired) \
__atomic_exchange_n(obj, desired, __ATOMIC_SEQ_CST)
# define jl_atomic_exchange_relaxed(obj, desired) \
__atomic_exchange_n(obj, desired, __ATOMIC_RELAXED)
// TODO: Maybe add jl_atomic_compare_exchange_weak for spin lock
# define jl_atomic_store(obj, val) \
__atomic_store_n(obj, val, __ATOMIC_SEQ_CST)
# define jl_atomic_store_relaxed(obj, val) \
__atomic_store_n(obj, val, __ATOMIC_RELAXED)
# if defined(__clang__) || defined(__ICC) || defined(__INTEL_COMPILER) || \
!(defined(_CPU_X86_) || defined(_CPU_X86_64_))
// ICC and Clang doesn't have this bug...
# define jl_atomic_store_release(obj, val) \
__atomic_store_n(obj, val, __ATOMIC_RELEASE)
# else
// Workaround a GCC bug when using store with release order by using the
// stronger version instead.
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67458
# define jl_atomic_store_release(obj, val) do { \
jl_signal_fence(); \
__atomic_store_n(obj, val, __ATOMIC_RELEASE); \
} while (0)
# endif
# define jl_atomic_load(obj) \
__atomic_load_n(obj, __ATOMIC_SEQ_CST)
# define jl_atomic_load_acquire(obj) \
__atomic_load_n(obj, __ATOMIC_ACQUIRE)
#ifdef JL_TSAN_ENABLED
// For the sake of tsan, call these loads consume ordering since they will act
// as such on the processors we support while normally, the compiler would
// upgrade this to acquire ordering, which is strong (and slower) than we want.
# define jl_atomic_load_relaxed(obj) \
__atomic_load_n(obj, __ATOMIC_CONSUME)
#else
# define jl_atomic_load_relaxed(obj) \
__atomic_load_n(obj, __ATOMIC_RELAXED)
#endif
#elif defined(_COMPILER_MICROSOFT_)
// TODO: these only define compiler barriers, and aren't correct outside of x86
# define jl_fence() _ReadWriteBarrier()
# define jl_fence_release() _WriteBarrier()
# define jl_signal_fence() _ReadWriteBarrier()
// add
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 1, T>::type
jl_atomic_fetch_add(T *obj, T2 arg)
{
return (T)_InterlockedExchangeAdd8((volatile char*)obj, (char)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 2, T>::type
jl_atomic_fetch_add(T *obj, T2 arg)
{
return (T)_InterlockedExchangeAdd16((volatile short*)obj, (short)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 4, T>::type
jl_atomic_fetch_add(T *obj, T2 arg)
{
return (T)_InterlockedExchangeAdd((volatile LONG*)obj, (LONG)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 8, T>::type
jl_atomic_fetch_add(T *obj, T2 arg)
{
return (T)_InterlockedExchangeAdd64((volatile __int64*)obj, (__int64)arg);
}
#define jl_atomic_fetch_add_relaxed(obj, arg) jl_atomic_fetch_add(obj, arg)
// and
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 1, T>::type
jl_atomic_fetch_and(T *obj, T2 arg)
{
return (T)_InterlockedAnd8((volatile char*)obj, (char)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 2, T>::type
jl_atomic_fetch_and(T *obj, T2 arg)
{
return (T)_InterlockedAnd16((volatile short*)obj, (short)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 4, T>::type
jl_atomic_fetch_and(T *obj, T2 arg)
{
return (T)_InterlockedAnd((volatile LONG*)obj, (LONG)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 8, T>::type
jl_atomic_fetch_and(T *obj, T2 arg)
{
return (T)_InterlockedAnd64((volatile __int64*)obj, (__int64)arg);
}
#define jl_atomic_fetch_and_relaxed(obj, arg) jl_atomic_fetch_and(obj, arg)
// or
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 1, T>::type
jl_atomic_fetch_or(T *obj, T2 arg)
{
return (T)_InterlockedOr8((volatile char*)obj, (char)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 2, T>::type
jl_atomic_fetch_or(T *obj, T2 arg)
{
return (T)_InterlockedOr16((volatile short*)obj, (short)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 4, T>::type
jl_atomic_fetch_or(T *obj, T2 arg)
{
return (T)_InterlockedOr((volatile LONG*)obj, (LONG)arg);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 8, T>::type
jl_atomic_fetch_or(T *obj, T2 arg)
{
return (T)_InterlockedOr64((volatile __int64*)obj, (__int64)arg);
}
#define jl_atomic_fetch_or_relaxed(obj, arg) jl_atomic_fetch_or(obj, arg)
// Returns the original value of `obj`
template<typename T, typename T2, typename T3>
static inline typename std::enable_if<sizeof(T) == 1, T>::type
jl_atomic_compare_exchange(volatile T *obj, T2 expected, T3 desired)
{
return (T)_InterlockedCompareExchange8((volatile char*)obj,
(char)desired, (char)expected);
}
template<typename T, typename T2, typename T3>
static inline typename std::enable_if<sizeof(T) == 2, T>::type
jl_atomic_compare_exchange(volatile T *obj, T2 expected, T3 desired)
{
return (T)_InterlockedCompareExchange16((volatile short*)obj,
(short)desired, (short)expected);
}
template<typename T, typename T2, typename T3>
static inline typename std::enable_if<sizeof(T) == 4, T>::type
jl_atomic_compare_exchange(volatile T *obj, T2 expected, T3 desired)
{
return (T)_InterlockedCompareExchange((volatile LONG*)obj,
(LONG)desired, (LONG)expected);
}
template<typename T, typename T2, typename T3>
static inline typename std::enable_if<sizeof(T) == 8, T>::type
jl_atomic_compare_exchange(volatile T *obj, T2 expected, T3 desired)
{
return (T)_InterlockedCompareExchange64((volatile __int64*)obj,
(__int64)desired, (__int64)expected);
}
// TODO: jl_atomic_bool_compare_exchange
// atomic exchange
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 1, T>::type
jl_atomic_exchange(volatile T *obj, T2 val)
{
return _InterlockedExchange8((volatile char*)obj, (char)val);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 2, T>::type
jl_atomic_exchange(volatile T *obj, T2 val)
{
return _InterlockedExchange16((volatile short*)obj, (short)val);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 4, T>::type
jl_atomic_exchange(volatile T *obj, T2 val)
{
return _InterlockedExchange((volatile LONG*)obj, (LONG)val);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 8, T>::type
jl_atomic_exchange(volatile T *obj, T2 val)
{
return _InterlockedExchange64((volatile __int64*)obj, (__int64)val);
}
#define jl_atomic_exchange_relaxed(obj, val) jl_atomic_exchange(obj, val)
// atomic stores
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 1>::type
jl_atomic_store(volatile T *obj, T2 val)
{
_InterlockedExchange8((volatile char*)obj, (char)val);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 2>::type
jl_atomic_store(volatile T *obj, T2 val)
{
_InterlockedExchange16((volatile short*)obj, (short)val);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 4>::type
jl_atomic_store(volatile T *obj, T2 val)
{
_InterlockedExchange((volatile LONG*)obj, (LONG)val);
}
template<typename T, typename T2>
static inline typename std::enable_if<sizeof(T) == 8>::type
jl_atomic_store(volatile T *obj, T2 val)
{
_InterlockedExchange64((volatile __int64*)obj, (__int64)val);
}
template<typename T, typename T2>
static inline void jl_atomic_store_release(volatile T *obj, T2 val)
{
jl_signal_fence();
*obj = (T)val;
}
template<typename T, typename T2>
static inline void jl_atomic_store_relaxed(volatile T *obj, T2 val)
{
*obj = (T)val;
}
// atomic loads
template<typename T>
static inline T jl_atomic_load(volatile T *obj)
{
// Trick to generate cheaper instructions compare to `_InterlockedOr`
// Note that we don't care whether the exchange succeeded or not...
return jl_atomic_compare_exchange(obj, T(0), T(0));
}
template<typename T>
static inline T jl_atomic_load_acquire(volatile T *obj)
{
T val = *obj;
jl_signal_fence();
return val;
}
#else
# error "No atomic operations supported."
#endif
#ifdef __clang_analyzer__
// for the purposes of the analyzer, we can turn these into non-atomic expressions with similar properties
#undef jl_atomic_exchange
#undef jl_atomic_exchange_relaxed
#define jl_atomic_exchange(obj, desired) \
(__extension__({ \
__typeof__((obj)) p = (obj); \
__typeof__(*p) temp = *p; \
*p = desired; \
temp; \
}))
#define jl_atomic_exchange_relaxed jl_atomic_exchange
#undef jl_atomic_compare_exchange
#define jl_atomic_compare_exchange(obj, expected, desired) ((expected), jl_atomic_exchange((obj), (desired)))
#undef jl_atomic_bool_compare_exchange
#define jl_atomic_bool_compare_exchange(obj, expected, desired) ((expected) == jl_atomic_exchange((obj), (desired)))
#undef jl_atomic_store
#undef jl_atomic_store_release
#undef jl_atomic_store_relaxed
#define jl_atomic_store(obj, val) (*(obj) = (val))
#define jl_atomic_store_release(obj, val) (*(obj) = (val))
#define jl_atomic_store_relaxed(obj, val) (*(obj) = (val))
#undef jl_atomic_load
#undef jl_atomic_load_acquire
#undef jl_atomic_load_relaxed
#define jl_atomic_load(obj) (*(obj))
#define jl_atomic_load_acquire(obj) (*(obj))
#define jl_atomic_load_relaxed(obj) (*(obj))
#endif
#endif // JL_ATOMICS_H
|
06a9c3146f105b2b4160dd201b4806f564f4b6f3 | 60d88a8557b290a64b54aead43c33174829b0e1d | /Skills.cpp | 1bef4e8d151ba2a3585180c7fab3eb9aaeeb65ff | [] | no_license | vx-c/Dungeon-Crawler | e88d5a46cc91f8c476f78000f27369b038badc3a | 45a651d81d2ccbf561b910d2aeaf0ed0137eeb09 | refs/heads/main | 2023-02-22T17:53:53.840624 | 2021-01-30T00:01:10 | 2021-01-30T00:01:10 | 308,446,977 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 743 | cpp | Skills.cpp | #include "Skills.h"
Skill::Skill(ID id, TargetingID targeting, std::wstring name, std::wstring text)
: id(id), targeting(targeting), name(name), text(text)
{
}
Skill Skills::basicAttack = Skill(Skill::ID::BasicAttack, Skill::TargetingID::Single, L"BasicAttack", L"attacks");
Skill Skills::cleave = Skill(Skill::ID::Cleave, Skill::TargetingID::Single, L"Cleave", L"cleaves");
Skill Skills::fireball = Skill(Skill::ID::Fireball, Skill::TargetingID::Single, L"Fireball", L"casts fireball on");
Skill Skills::firewave = Skill(Skill::ID::Firewave, Skill::TargetingID::Single, L"Firewave", L"casts firewave on");
Skill Skills::doNothing = Skill(Skill::ID::DoNothing, Skill::TargetingID::Single, L"DoNothing", L"does nothing to");
|
359df2be970939de76ed382e715a6365cf681b62 | b7d403ca9bfd218d3ec76d169d030e5ca3d2ad07 | /include/UbiForm/ResourceDiscovery/ResourceDiscoveryConnEndpoint.h | 3fdd965f7e2a5f81ef63f67347558a5fb8ea5293 | [
"MIT"
] | permissive | J2G8W/UbiForm | 3c73756a3c3589f0bc14e4ca1bd393edf0ec4684 | 723945f4a6c07a852101e09b80f22f663985f7dc | refs/heads/main | 2023-04-19T06:37:16.703649 | 2021-05-10T18:35:17 | 2021-05-10T18:35:17 | 310,634,420 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,904 | h | ResourceDiscoveryConnEndpoint.h | #ifndef UBIFORM_RESOURCEDISCOVERYCONNENDPOINT_H
#define UBIFORM_RESOURCEDISCOVERYCONNENDPOINT_H
#include <vector>
#include <string>
#include "ComponentRepresentation.h"
#include "../Endpoints/RequestEndpoint.h"
class Component;
class ResourceDiscoveryConnEndpoint {
private:
// Map from url to our id on that rdh
std::map<std::string, std::string> resourceDiscoveryHubs;
std::map<std::string, std::unique_ptr<RequestEndpoint> > resourceDiscoveryEndpoints;
Component *component;
SystemSchemas &systemSchemas;
static void handleAsyncReceive(EndpointMessage* sm, void* data);
std::unique_ptr<EndpointMessage> sendRequest(const std::string &url, EndpointMessage &request, bool waitForResponse);
// We purposely delete copy and assignment operators such that there isn't stray references to this
ResourceDiscoveryConnEndpoint(ResourceDiscoveryConnEndpoint &) = delete;
ResourceDiscoveryConnEndpoint &operator=(ResourceDiscoveryConnEndpoint &) = delete;
public:
ResourceDiscoveryConnEndpoint(Component *component, SystemSchemas &ss) : component(component), systemSchemas(ss){}
///@{
/**
* @name RequestGenerators
* @return The generated request
*/
std::unique_ptr<EndpointMessage> generateRegisterRequest();
std::unique_ptr<EndpointMessage> generateFindBySchemaRequest(const std::string &endpointType,
std::map<std::string, std::string> &otherValues);
///@}
/**
* Send a request to a ResourceDiscoveryHub at url and if it comes back successfully we register it as a Hub we can talk to.
* Note that it doesn't throw exceptions, just outputs to cerr
* @param url - The COMPLETE url of the RDH
*/
void registerWithHub(const std::string &url);
/**
* Request ALL the IDs that a hub has.
* @param url - The COMPLETE url of the RDH
* @return Vector of IDs that hub has or an empty vector on error in contact
*/
std::vector<std::string> getComponentIdsFromHub(const std::string &url);
/**
* Request the representation of a single component from an RDH
* @param url - The COMPLETE url of the RDH
* @param id - The id of the component we want
* @return std::unique_ptr to a ComponentRepresentation from the RDH
* @throws std::logic_error when the RDH doesn't reply properly or has not component
*/
std::unique_ptr<ComponentRepresentation> getComponentById(const std::string &url, const std::string &id);
/**
* Sends requests to all the RDHs we know about, for the components which match the endpointType we request.
* Assumes we only want DataReceiverEndpoints back
* @param endpointType - Reference to the endpointType in our componentManifest
* @return Vector of SocketMessages (which handle memory themselves) which follow Schema "SystemsSchemas/resource_discovery_by_schema_response"
*/
std::vector<std::unique_ptr<EndpointMessage>>
getComponentsBySchema(const std::string &endpointType, std::map<std::string, std::string> &otherValues);
std::map<std::string, std::unique_ptr<ComponentRepresentation>>
getComponentsByProperties(std::map<std::string, std::string> &properties);
/**
* Uses the getComponentsBySchema function to actually create connections to ALL of the available endpoints from our RDHs.
* Should not throw any errors, we catch any creation errors. We do record in std::cerr when we can't connect to
* any of the URLs for a component
* @param endpointType - Reference to the endpointType in our ComponentManifest
*/
void createEndpointBySchema(const std::string &endpointType);
/**
* Get our ID on the RDH represented
* @param RdhUrl - RDH we want our ID for
* @return ID
* @throws std::out_of_range when we haven't registered with that RDH yet
*/
std::string getId(const std::string &RdhUrl) {
return resourceDiscoveryHubs.at(RdhUrl);
}
/**
* Get the COMPLETE urls of all the RDHs we are connected to
* @return Vector of complete urls (including port numbers)
*/
std::vector<std::string> getResourceDiscoveryHubs() {
std::vector<std::string> rdhs;
for (auto url : resourceDiscoveryHubs) {
rdhs.push_back(url.first);
}
return rdhs;
}
/**
* Update our manifest with each RDH we are registered with
*/
void updateManifestWithHubs();
/**
* Deregister a third party component from the given rdhUrl. This should be used largely for when we are unable to
* contact a component and so deem that the component should be removed from the RDH
*/
void deRegisterThirdPartyFromHub(const std::string &rdhUrl, const std::string componentId);
/**
* Deregister from the hub given. This means we no longer contact the hub
*/
void deRegisterFromHub(const std::string &rdhUrl);
/**
* We search for resource discovery hubs by looking for components with background listeners. We then try to connect
* to the given RDHs, when we find 1 we stop as this is a slowwww process. We look for background listeners as each
* component has a background listener but there may just be one RDH on the network, so we are more likely
* to get a positive result
*/
void searchForResourceDiscoveryHubs();
/**
* Deregister from the all the hubs we currently have connection to
*/
void deRegisterFromAllHubs();
/**
* Tell all hubs that we have added a listenerPort for the given endpoint at port
* @param endpointType - The endpoint type to update
* @param port - The new port
*/
void addListenerPortForAllHubs(const std::string& endpointType, int port);
void checkLivenessOfHubs();
};
#endif //UBIFORM_RESOURCEDISCOVERYCONNENDPOINT_H
|
c30d56b89f7b1860c80778f059b43d54a0f2a0ed | 5f6a1f69ae06231044bd9a3901433fea8ca8b249 | /kernel/screen.cpp | e328eda3bbe16871f4e62a67fb0a47dee0f0c44d | [] | no_license | chipot/kpp | 7dcad4bceebeed8f1aa3e678446bbff015af34de | 8ef28413a04fe1554b19df47d37ccfb5444ff21b | refs/heads/master | 2021-01-20T04:32:33.306852 | 2012-10-22T21:57:13 | 2012-10-22T21:57:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,358 | cpp | screen.cpp | #include "Screen.h"
screen::tty tty;
namespace screen {
/*
* 'scrollup' scrolle l'ecran (la console mappee en ram) vers le haut
* de n lignes (de 0 a 25).
*/
void tty::scrollup(unsigned int n)
{
unsigned char *video, *tmp;
for (video = (unsigned char *) RAMSCREEN;
video < (unsigned char *) SCREENLIM; video += 2) {
tmp = (unsigned char *) (video + n * 160);
if (tmp < (unsigned char *) SCREENLIM) {
*video = *tmp;
*(video + 1) = *(tmp + 1);
} else {
*video = 0;
*(video + 1) = 0x07;
}
}
this->y -= n;
if (this->y < 0)
this->y = 0;
}
void tty::putcar(uchar c)
{
unsigned char *video;
int i;
if (c == 10) { /* CR-NL */
this->x = 0;
this->y++;
} else if (c == 9) { /* TAB */
this->x = this->x + 8 - (this->x % 8);
} else if (c == 13) { /* CR */
this->x = 0;
} else { /* autres caracteres */
video = (unsigned char *) (RAMSCREEN + 2 * this->x + 160 * this->y);
*video = c;
*(video + 1) = this->_attr;
this->x++;
if (this->x > 79) {
this->x = 0;
this->y++;
}
}
if (this->y > 24)
scrollup(this->y - 24);
}
/*
* 'print' affiche a l'ecran, a la position courante du curseur, une chaine
* de caracteres terminee par \0.
*/
void tty::puts(char const *string)
{
while (*string != 0) /* tant que le caractere est different de 0x0 */
{
putcar(*string);
string++;
}
}
}
|
27418eef34fc9a77e8a7dca8129c061546a4218f | dccb136394c3c7f4a636f17f444ebaf95e24ab66 | /Baekjoon/baekjoon_17829.cpp | d6f349fc518ff3bc0a52a017d4457c7f1b001036 | [] | no_license | Oh-kyung-tak/Algorithm | e2b88f6ae8e97130259dedfc30bb48591ae5b2fd | be63f972503170eb8ce06002a2eacd365ade7787 | refs/heads/master | 2020-04-25T22:37:41.799025 | 2020-01-19T08:55:42 | 2020-01-19T08:55:42 | 173,117,722 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 627 | cpp | baekjoon_17829.cpp | #include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;
int N;
int CNN[1024][1024];
int second_max(int x, int y)
{
vector<int> temp;
for (int i = x; i < x + 2; i++)
for (int j = y; j < y + 2; j++)
temp.push_back(CNN[i][j]);
sort(temp.begin(), temp.end());
return temp[2];
}
int main()
{
cin >> N;
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
cin >> CNN[i][j];
while (N != 1)
{
for(int i = 0; i < N; i += 2)
for (int j = 0; j < N; j += 2)
CNN[i / 2][j / 2] = second_max(i, j);
N /= 2;
}
cout << CNN[0][0] << endl;
} |
5ad9b61a3a97c37e64b76cab8f0de509297942f6 | 2bc60fb13ee17d62f4ce694c94f144ba8a1b1bc7 | /GnuplotSink.cpp | ba31262b4c59cfa8e95c5a5e852f8f2f5e721859 | [] | no_license | fpga-tom/cmpxchg | 18600a43b73cf139388767c5370c4d271bf50876 | da3fe3b5bada9a1a1dc70d22c94d90558db09be2 | refs/heads/master | 2020-04-09T05:30:09.579687 | 2019-02-04T16:23:11 | 2019-02-04T16:23:11 | 160,066,919 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 998 | cpp | GnuplotSink.cpp | //
// Created by tomas on 12/2/18.
//
#include "GnuplotSink.h"
#include "gnuplot_i.hpp"
Gnuplot gp("gnuplot");
GnuplotSink::GnuplotSink(const int buf_size) : buf_size(buf_size) {
Task & t_sdl = create_task("gnuplot", {
TagPortIn("p_in", (uint8_t )module::gnuuplot::port::paint ::p_in)
},[this, buf_size](uint8_t** d_in, uint8_t **d_out) -> int {
fps.start();
float * d = reinterpret_cast<float *>(d_in[0]);
std::vector<std::pair<float, float>> x_vec(buf_size);
for(int i = 0; i < buf_size; i++) {
x_vec[i] = std::make_pair(i, d[i]);
}
gp << "set xrange [0:1024]\nset yrange [0:130]\nset grid\n";
gp << "plot '-' with lines\n";
gp.send1d(x_vec);
//Cap the frame rate
if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
{
std::this_thread::sleep_for(std::chrono::milliseconds(( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() ));
}
return 0;
});
}
|
e40e291629f0c4eb4b1cbcaba127af2cf03dd936 | c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64 | /Engine/Source/Runtime/Slate/Public/Widgets/Docking/SDockableTab.h | 08a1985d6089a6daf284e934fdf93b7ad908b413 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | windystrife/UnrealEngine_NVIDIAGameWorks | c3c7863083653caf1bc67d3ef104fb4b9f302e2a | b50e6338a7c5b26374d66306ebc7807541ff815e | refs/heads/4.18-GameWorks | 2023-03-11T02:50:08.471040 | 2022-01-13T20:50:29 | 2022-01-13T20:50:29 | 124,100,479 | 262 | 179 | MIT | 2022-12-16T05:36:38 | 2018-03-06T15:44:09 | C++ | UTF-8 | C++ | false | false | 3,353 | h | SDockableTab.h | // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Misc/Attribute.h"
#include "Layout/Margin.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SWidget.h"
#include "Widgets/Docking/SDockTab.h"
class FMenuBuilder;
class SDockTabStack;
DECLARE_DELEGATE_TwoParams(
FOnTabStackMenuOpening,
/** Builder for the menu that will be opened */
FMenuBuilder& ,
/** Tab stack that this menu is being opened in */
const TSharedRef<SDockTabStack>& );
/**
* A tab widget that also holds on to some content that should be shown when this tab is selected.
* Intended to be used in conjunction with SDockTabStack.
*/
class SLATE_API SDockableTab
{
public:
DECLARE_DELEGATE_OneParam(FOnTabClosedCallback, TSharedRef<SDockableTab>);
SLATE_BEGIN_ARGS(SDockableTab)
{}
SLATE_END_ARGS()
/** Construct the widget from the declaration. */
void Construct( const FArguments& InArgs );
void SetContent( TSharedRef<SWidget> InContent );
/** @return True if this tab is currently focused */
bool IsActive() const;
/** @return True if this tab appears active; False otherwise */
bool IsForeground() const;
/** @return the content associated with this tab */
TSharedRef<SWidget> GetContent();
/** Gets the dock tab stack this dockable tab resides within, if any */
TSharedPtr<SDockTabStack> GetParentDockTabStack() const;
/** Brings this tab to the front of its parent's tab well, if applicable. */
void BringToFrontInParent();
/** Should this tab be sized based on its content. */
bool ShouldAutosize() const;
/** Set delegate to invoke when tab stack menu is opening */
void SetOnTabStackMenuOpening( const FOnTabStackMenuOpening& InHandler );
/**
* Requests that the tab be closed. Tabs may prevent closing depending on their state
*/
void RequestCloseTab();
/**
* Pulls this tab out of it's parent tab stack and destroys it
* Note: This does not check if its safe to remove the tab. Use RequestCloseTab to do this safely.
*/
void RemoveTabFromParent();
/**
* Make this tab active in its tabwell
* @param InActivationMethod How this tab was activated.
*/
void ActivateInParent(ETabActivationCause InActivationCause);
protected:
/** The tab's layout identifier */
FName LayoutIdentifier;
/** Is this an MajorTab? A tool panel tab? */
ETabRole TabRole;
/** The width that this tab will overlap with side-by-side tabs. */
float OverlapWidth;
/** The label on the tab */
TAttribute<FString> TabLabel;
/** Callback to call when this tab is destroyed */
FOnTabClosedCallback OnTabClosed;
/** Delegate to execute to determine if we can close this tab */
SDockTab::FCanCloseTab OnCanCloseTab;
/**
* The brush that the SDockTabStack should use to draw the content associated with this tab
* Documents, Apps, and Tool Panels have different backgrounds
*/
const FSlateBrush* ContentAreaBrush;
TAttribute<FMargin> ContentAreaPadding;
const FSlateBrush* TabWellBrush;
FMargin TabWellPadding;
/** Called when the the tab stack's context menu is open; gives the currently focused tab a change to add custom */
FOnTabStackMenuOpening OnTabStackMenuOpeningHandler;
/** Should this tab be auto-sized based on its content? */
bool bShouldAutosize;
/** Color of this tab */
FLinearColor TabColorScale;
};
|
b6d706315654fdb3eb961e6fdd3c8988ec10cf1b | 5a76eaf44e1da6cb80bd1692d7dd100e2c06d8eb | /kernel.hpp | 1ab99f248fbb47c3a81cbb166985c68145748336 | [] | no_license | fishcorn/mwumkl2 | 3aa561e8d12d61b1c616e841e21274aaca2a29c9 | 5cf064e331fe5ffd9e2b95f6716b454e572a7180 | refs/heads/master | 2021-01-01T19:01:46.201045 | 2013-08-04T04:54:51 | 2013-08-04T04:54:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,673 | hpp | kernel.hpp | #include "mwu_main.h"
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <functional>
#include <limits>
#include <typeinfo>
#include <iostream>
namespace mwumkl { namespace kernel {
struct dot_elem {
inline double operator()(double r, double c) {
return r*c;
}
};
struct diff_sq_elem {
inline double operator()(double r, double c) {
double out = r - c;
return out*out;
}
};
struct outer_fun {
typedef double first_argument_type;
typedef double second_argument_type;
typedef double result_type;
};
struct identity_outer_fun : outer_fun {
double operator()(double in, double) const {
return in;
}
};
struct poly_outer_fun : outer_fun {
double operator()(double in, double param) const {
return std::pow(in+1, param);
}
};
struct tanh_outer_fun : outer_fun {
double operator()(double in, double param) const {
return std::tanh(param*in);
}
};
struct logistic_outer_fun : outer_fun {
double operator()(double in, double param) const {
return 1/(std::exp(-param*in) + 1);
}
};
struct gauss_outer_fun : outer_fun {
double operator()(double in, double param) const {
return std::exp(-in/param);
}
};
template < typename AggElem, typename OuterFun = identity_outer_fun >
struct gram {
// double entry(int r, int c, const std::vector<double * > & features) const {
// double out = 0.0;
// int d = features.size();
// AggElem agg;
// for (int i = 0; i < d; ++i) {
// out += agg(features[i][r], features[i][c]);
// }
// return OuterFun()(out, param);
// }
template < typename RandIt >
void column(RandIt out, int n, int c, const std::vector<const double * > & features) const {
int d = features.size();
AggElem e;
std::fill(out, out+n, 0.0);
for (int k = 0; k < d; ++k) {
const double * feature = features[k];
for (int j = 0; j < n; ++j) {
out[j] += e(feature[j], feature[c]);
}
}
std::transform(out, out+n, out, std::bind2nd(OuterFun(), param));
}
template < typename RandIt >
void predict(RandIt out,
double * alpha, int * ytr,
int ntr, int nte,
const std::vector<const double *> & features_tr,
const std::vector<const double *> & features_te) const
{
int d = features_te.size();
AggElem e;
OuterFun o;
std::fill(out, out+nte, 0.0);
std::vector<double> kern(ntr, 0.0);
for (int t = 0; t < nte; ++t) {
kern.assign(ntr, 0.0);
for (int k = 0; k < d; ++k) {
const double * feat_tr = features_tr[k];
const double * feat_te = features_te[k];
for (int j = 0; j < ntr; ++j) {
kern[j] += e(feat_tr[j], feat_te[t]);
}
}
for (int j = 0; j < ntr; ++j) {
out[t] += o(kern[j], param)*alpha[j]*ytr[j];
}
}
}
double trace(int n, const std::vector<const double *> & features) const {
double trace = 0.0;
int d = features.size();
AggElem e;
OuterFun o;
for (int j = 0; j < n; ++j) {
double elem = 0.0;
for (int i = 0; i < d; ++i) {
double el = features[i][j];
elem += e(el, el);
}
trace += o(elem, param);
}
return trace;
}
explicit gram(double param_) : param(param_) {}
double param;
};
class Kernel {
std::vector<const double *> features_tr;
std::vector<const double *> features_te;
virtual void column_(std::vector<double>::iterator out, int c) const = 0;
virtual double trace_() const = 0;
virtual void predict_(std::vector<double>::iterator out,
double * alpha, int * ytr) const = 0;
void build_features(std::vector<const double *> & features, int n, const double * X) const {
if (features.empty()) {
if (feature < 0) {
features.assign(-feature, (const double *)NULL);
for (int i = 0; i < -feature; ++i) {
features[i] = X + i*n;
}
}
else {
features.assign(1, X + n*feature);
}
}
}
protected:
const std::vector<const double *> & features_tr_() const { return features_tr; }
const std::vector<const double *> & features_te_() const { return features_te; }
public:
Kernel(int ntr_, int nte_, double * Xtr_, double * Xte_,
int feature_)
: ntr(ntr_), nte(nte_), Xtr(Xtr_), Xte(Xte_), feature(feature_)
{}
const int ntr, nte;
const double * const Xtr;
const double * const Xte;
const int feature;
void gram_column(std::vector<double>::iterator out, int c) {
build_features(features_tr, ntr, Xtr);
column_(out, c);
}
double gram_trace() {
build_features(features_tr, ntr, Xtr);
return trace_();
}
template < typename RandIt >
void predict(RandIt out, double * alpha, int * ytr) {
build_features(features_tr, ntr, Xtr);
build_features(features_te, nte, Xte);
predict_(out, alpha, ytr);
}
template < typename OutIt >
static void MakeKernels(OutIt oi,
int * kerns,
double * kern_params,
int * feature_sel,
double * Xtr,
double * Xte,
int m,
int ntr,
int nte,
int d);
};
template < typename AggFun, typename OuterFun >
class KernelImp : public Kernel, private gram< AggFun, OuterFun >
{
typedef gram< AggFun, OuterFun > gram_base;
virtual void column_(std::vector<double>::iterator out, int c) const {
gram_base::column(out, ntr, c, features_tr_());
}
virtual double trace_() const {
return gram_base::trace(ntr, features_tr_());
}
virtual void predict_(std::vector<double>::iterator out,
double * alpha, int * ytr) const {
gram_base::predict(out, alpha, ytr, ntr, nte,
features_tr_(), features_te_());
}
public:
KernelImp(double param_,
int ntr_, int nte_, double * Xtr_, double * Xte_,
int feature_)
: Kernel(ntr_, nte_, Xtr_, Xte_, feature_),
gram_base(param_)
{}
};
typedef KernelImp< dot_elem, identity_outer_fun > LinearKern; // LINEAR
typedef KernelImp< dot_elem, poly_outer_fun > PolyKern; // POLY
typedef KernelImp< diff_sq_elem, gauss_outer_fun > RbfKern; // RBF, GAUSSIAN
typedef KernelImp< dot_elem, logistic_outer_fun > LogisticKern; // LOGISTIC, SIGMOID
typedef KernelImp< dot_elem, tanh_outer_fun > TanhKern; // TANH
template < typename RandIt >
void Kernel::MakeKernels(RandIt out,
int * kerns,
double * kern_params,
int * feature_sel,
double * Xtr,
double * Xte,
int m,
int ntr,
int nte,
int d)
{
for (int i = 0; i < m; ++i) {
int feature = feature_sel[i] < 0 ? -d : feature_sel[i];
switch (kerns[i]) {
case LINEAR:
out[i] = new LinearKern(kern_params[i], ntr, nte, Xtr, Xte, feature);
break;
case POLY:
out[i] = new PolyKern(kern_params[i], ntr, nte, Xtr, Xte, feature);
break;
case RBF: // case GAUSSIAN:
out[i] = new RbfKern(kern_params[i], ntr, nte, Xtr, Xte, feature);
break;
case LOGISTIC: // case SIGMOID:
out[i] = new LogisticKern(kern_params[i], ntr, nte, Xtr, Xte, feature);
break;
case TANH:
out[i] = new TanhKern(kern_params[i], ntr, nte, Xtr, Xte, feature);
break;
default:
out[i] = NULL;
};
}
}
} // namespace kernel
} // namespace mwumkl
|
84ebb984ead849942d9d30561d61055f89d71bb9 | 09882ac9f3d0949cadc9743544f24a7b12f962fd | /src/frontend/viewport.h | c9bcbfa634d9a66330f73bda1b721c34084aae51 | [] | no_license | ousttrue/w3m1 | ddcc240c5d9017ce78dd41cca3197c6bd191f0a1 | eaf5969cdacb3f9ae19e1fa32a652c88695fbf4c | refs/heads/master | 2022-12-08T23:58:04.264222 | 2020-09-03T13:30:24 | 2020-09-03T13:30:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,082 | h | viewport.h | #pragma once
#include <tuple>
#include <math.h>
//
// viewport for buffer
//
struct Viewport
{
// viewport top left corner
short rootX = 0;
short rootY = 0;
// viewport size
short cols = 0;
short lines = 0;
// // buffer local cursor position
// short cursorX = 0;
// short cursorY = 0;
short right() const { return rootX + cols; }
short bottom() const { return rootY + lines; }
// void resetCursor()
// {
// cursorX = 0;
// cursorY = 0;
// }
// std::tuple<int, int> globalXY() const
// {
// return std::make_pair(
// rootX + cursorX,
// rootY + cursorY);
// }
// void updateRootX(int lastRealLineNumber)
// {
// if (rootX == 0)
// {
// if (lastRealLineNumber)
// rootX = (int)(log(lastRealLineNumber + 0.1) / log(10)) + 2;
// if (rootX < 5)
// rootX = 5;
// if (rootX > cols)
// rootX = cols;
// cols = cols - rootX;
// }
// }
};
|
73830c82655b7f8fa4bbe978cb1686e479b30a8a | 5282d14780eef9c50f000176794ec2c116afefc6 | /Root2CalMCP.cpp | 1e2db3faf40233b1f8ef0f316eebe81825cce8ba | [
"BSD-3-Clause"
] | permissive | LeavesWang/E18009Src | 732ef5fa3ab574b9352765f2385bb4b9cbe83162 | 6b774b90dae5a289a9fba5cb5276fcd8e95c520d | refs/heads/main | 2023-04-28T21:39:42.259136 | 2021-05-10T16:42:03 | 2021-05-10T16:42:03 | 366,094,440 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,287 | cpp | Root2CalMCP.cpp | #include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <unistd.h>
#include "TFile.h"
#include "TTree.h"
#include "TRandom3.h"
#include "TStyle.h"
using namespace std;
struct StrtMesytec
{
int modID;
int data[32];
int modRes;
int modEC_TS;
};
void Root2CalMCP()
{
const int QdcUp = 3840;
int QdcLow[32] = {0}; //pedestal values
QdcLow[9] = 300;
QdcLow[11] = 120;
QdcLow[13] = 160;
QdcLow[15] = 180;
string sRoot, sCalMcp;
StrtMesytec mqdcMCP;
int i = 0, j = 0, k = 0;
int run = 0;
double ampTR = 0, ampTL = 0, ampBL = 0, ampBR = 0;
double xRaw = 0, yRaw = 0;
long long iEnt = 0, nEnt = 0;
int runMin, runMax, runNum;
cout << "Input minimum and maximum numbers of run: ";
cin >> runMin >> runMax;
if (access("../AnaData", F_OK) != 0)
system("mkdir ../AnaData");
sCalMcp = "../AnaData/calMCP-run-" + to_string(runMin) + "--" + to_string(runMax) + ".root";
TFile *fCalMcp = new TFile(sCalMcp.c_str(), "RECREATE");
TTree *tCalMcp = new TTree("tCalMcp", "tree for calibrating MCP");
tCalMcp->Branch("run", &run, "run/I");
tCalMcp->Branch("ampTR", &TR, "ampTR/D");
tCalMcp->Branch("ampTL", &TL, "ampTL/D");
tCalMcp->Branch("ampBR", &BR, "ampBR/D");
tCalMcp->Branch("ampBL", &BL, "ampBL/D");
tCalMcp->Branch("xRaw", &xRaw, "xRaw/D");
tCalMcp->Branch("yRaw", &yRaw, "yRaw/D");
ostringstream ssRun;
for (runNum = runMin; runNum <= runMax; runNum++)
{
ssRun.str("");
ssRun << setw(4) << setfill('0') << runNum;
sRoot = "../RootData/run-" + ssRun.str() + "-00.root";
printf("\n**********Now converting %s to %s!**********\n\n", sRoot.c_str(), sCalMcp.c_str());
TFile *fRoot = new TFile(sRoot.c_str());
if (fRoot->IsZombie())
{
cout << "Error in opening " << sRoot << "!\n";
continue;
}
TTree *tData;
fRoot->GetObject("tData", tData);
if (!tData)
{
cout << "Error read the tree of tData!\n";
continue;
}
memset(&mqdcMCP, 0, sizeof(mqdcMCP));
tData->SetBranchAddress("mqdcMCP", &mqdcMCP);
nEnt = tData->GetEntries();
for (iEnt = 0; iEnt < nEnt; iEnt++)
{
tData->GetEntry(iEnt);
TRandom3 r(0);
run = runNum;
ampTR = 0;
ampTL = 0;
ampBL = 0;
ampBR = 0;
xRaw = 0;
yRaw = 0;
if (mqdcMCP.data[9] > QdcLow[9] && mqdcMCP.data[9] < QdcUp)
ampBR = mqdcMCP.data[9] - QdcLow[9] + r.Uniform(-0.5, 0.5);
if (mqdcMCP.data[11] > QdcLow[11] && mqdcMCP.data[11] < QdcUp)
ampTL = mqdcMCP.data[11] - QdcLow[11] + r.Uniform(-0.5, 0.5);
if (mqdcMCP.data[13] > QdcLow[13] && mqdcMCP.data[13] < QdcUp)
ampBL = mqdcMCP.data[13] - QdcLow[13] + r.Uniform(-0.5, 0.5);
if (mqdcMCP.data[15] > QdcLow[15] && mqdcMCP.data[15] < QdcUp)
ampTR = mqdcMCP.data[15] - QdcLow[15] + r.Uniform(-0.5, 0.5);
if (ampBR > 0 && ampTL > 0 && ampBL > 0 && ampTR > 0)
{
xRaw = (ampBR + ampTR - ampTL - ampBL) / (ampBR + ampTR + ampTL + ampBL);
yRaw = (ampTL + ampTR - ampBR - ampBL) / (ampBR + ampTR + ampTL + ampBL);
tCalMcp->Fill();
}
}
fRoot->Close();
}
fCalMcp->cd();
tCalMcp->Write();
fCalMcp->Close();
}
#ifndef __CINT__
int main()
{
Root2CalMCP();
return 0;
}
#endif |
42680edc7dd09a9d7f7366648964926858734d8c | 3405a45610a34156e7cbdb7381e19fed9dc0b3b4 | /lib_/utils/ConnectingSocket.h | 2daa0ed19442939f044ef7a4c55cbd6c22d7efd3 | [] | no_license | shri314/misc | 31c679620003de9c5706f3b743ba9091ecbee895 | 44ed89f543b140a6ff355fb45759973bfd08f7d8 | refs/heads/master | 2021-01-10T23:55:17.086453 | 2018-03-11T16:06:57 | 2018-03-11T16:06:57 | 70,785,260 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 611 | h | ConnectingSocket.h | #ifndef ConnectingSocket_h
#define ConnectingSocket_h
#include "utils/SocketImplBase.h"
class ConnectingSocket : SocketImplBase
{
public:
ConnectingSocket(const std::string& rendpoint /* 127.0.0.1:9999 */, const std::string& lendpoint, bool nonblocking = false)
: SocketImplBase(lendpoint, nonblocking)
{
Connect(rendpoint);
}
ConnectingSocket(const std::string& rendpoint /* 127.0.0.1:9999 */, bool nonblocking = false)
: SocketImplBase("0.0.0.0:0", nonblocking)
{
Connect(rendpoint);
}
using SocketImplBase::Talk;
using SocketImplBase::SocketFD;
};
#endif
|
f9b4c48b0cb96c2368ebca316f64db4850d61f54 | c05bc1c96979107eeb1d1463a7fc01b5144452c8 | /Common/Servers/Sardara/src/SardaraImpl.cpp | bea435bcb0192b510d7ad2b37cc100ba9e3a872e | [] | no_license | discos/discos | 1587604ae737d8301f10011d21bfa012dd3c411f | 87dc57a160f3b122af46a9927ee6abb62fdf4159 | refs/heads/master | 2023-08-30T21:39:55.339786 | 2023-06-21T13:39:20 | 2023-06-21T13:39:20 | 87,530,078 | 4 | 4 | null | 2023-09-07T07:57:43 | 2017-04-07T09:37:08 | C++ | UTF-8 | C++ | false | false | 31,535 | cpp | SardaraImpl.cpp | // $Id: SardaraImpl.cpp,v 1.1 2011-03-14 14:15:07 a.orlati Exp $
#include "SardaraImpl.h"
#include <Definitions.h>
#include <ComponentErrors.h>
#include <LogFilter.h>
#include "Common.h"
#include "DevIOAttenuation.h"
#include "DevIOBandWidth.h"
#include "DevIOTime.h"
#include "DevIOFrequency.h"
#include "DevIOPolarization.h"
#include "DevIOInputsNumber.h"
#include "DevIOSampleRate.h"
#include "DevIOBins.h"
#include "DevIOIntegration.h"
#include "DevIOStatus.h"
#include "DevIOBusy.h"
#include "DevIOFeed.h"
#include "DevIOTsys.h"
#include "DevIOInputSection.h"
#include "DevIOSectionsNumber.h"
#include "SenderThread.h"
static char *rcsId="@(#) $Id: SardaraImpl.cpp,v 1.1 2011-03-14 14:15:07 a.orlati Exp $";
static void *use_rcsId = ((void)&use_rcsId,(void *) &rcsId);
using namespace SimpleParser;
_IRA_LOGFILTER_DECLARE;
SardaraImpl::SardaraImpl(const ACE_CString &CompName,maci::ContainerServices *containerServices) :
BulkDataSenderDefaultImpl(CompName,containerServices),
m_ptime(this),
m_pbackendName(this),
m_pbandWidth(this),
m_pfrequency(this),
m_psampleRate(this),
m_pattenuation(this),
m_ppolarization(this),
m_pbins(this),
m_pinputsNumber(this),
m_pintegration(this),
m_pstatus(this),
m_pbusy(this),
m_pfeed(this),
m_ptsys(this),
m_psectionsNumber(this),
m_pinputSection(this)
{
AUTO_TRACE("SardaraImpl::SardaraImpl");
m_initialized=false;
m_senderThread=NULL;
m_controlThread=NULL;
}
SardaraImpl::~SardaraImpl()
{
AUTO_TRACE("SardaraImpl::~SardaraImpl()");
// if the initialization failed...clear everything as well.
// otherwise it is called by the cleanUp procedure.
if (!m_initialized) deleteAll();
}
void SardaraImpl::initialize() throw (ACSErr::ACSbaseExImpl)
{
CError Err;
CSenderThread::TSenderParameter threadPar;
CCommandLine* line;
//IRA::CString hostName,hostAddress;
AUTO_TRACE("SardaraImpl::initialize()");
ACS_LOG(LM_FULL_INFO,"SardaraImpl::initialize()",(LM_INFO,"COMPSTATE_INITIALIZING"));
ACS_LOG(LM_FULL_INFO,"SardaraImpl::initialize()",(LM_INFO,"READING_CONFIGURATION"));
// could throw an ComponentErrors::CDBAccessExImpl exception
m_configuration.init(getContainerServices());
ACS_LOG(LM_FULL_INFO,"SardaraImpl::initialize()",(LM_INFO,"CONFIGURATION_OK"));
ACS_LOG(LM_FULL_INFO,"SardaraImpl::initialize()",(LM_INFO,"INITIALIIZING_COMMUNICATION_LINES"));
_IRA_LOGFILTER_ACTIVATE(m_configuration.getRepetitionCacheTime(),m_configuration.getRepetitionExpireTime());
try {
line=new CCommandLine(getContainerServices());
m_commandLine=new CSecureArea<CCommandLine>(line);
}
catch (std::bad_alloc& ex) {
_EXCPT(ComponentErrors::MemoryAllocationExImpl,dummy,"SardaraImpl::initialize()");
throw dummy;
}
try {
m_ptime=new ROuLongLong(getContainerServices()->getName()+":time",getComponent(),
new DevIOTime(m_commandLine),true);
m_pbackendName=new ROstring(getContainerServices()->getName()+":backendName",getComponent());
m_pbandWidth=new ROdoubleSeq(getContainerServices()->getName()+":bandWidth",getComponent(),
new DevIOBandWidth(m_commandLine),true);
m_pfrequency=new ROdoubleSeq(getContainerServices()->getName()+":frequency",getComponent(),
new DevIOFrequency(m_commandLine),true);
m_psampleRate=new ROdoubleSeq(getContainerServices()->getName()+":sampleRate",getComponent(),
new DevIOSampleRate(m_commandLine),true);
m_pattenuation=new ROdoubleSeq(getContainerServices()->getName()+":attenuation",getComponent(),
new DevIOAttenuation(m_commandLine),true);
m_ppolarization=new ROlongSeq(getContainerServices()->getName()+":polarization",getComponent(),
new DevIOPolarization(m_commandLine),true);
m_pinputsNumber=new ROlong(getContainerServices()->getName()+":inputsNumber",getComponent(),
new DevIOInputsNumber(m_commandLine),true);
m_pbins=new ROlongSeq(getContainerServices()->getName()+":bins",getComponent(),
new DevIOBins(m_commandLine),true);
m_pintegration=new ROlong(getContainerServices()->getName()+":integration",getComponent(),
new DevIOIntegration(m_commandLine),false);
m_pstatus=new ROpattern(getContainerServices()->getName()+":status",getComponent(),
new DevIOStatus(m_commandLine),true);
m_pbusy=new ROEnumImpl<ACS_ENUM_T(Management::TBoolean),POA_Management::ROTBoolean>
(getContainerServices()->getName()+":busy",getComponent(), new DevIOBusy(m_commandLine),true);
m_pfeed=new ROlongSeq(getContainerServices()->getName()+":feed",getComponent(),new DevIOFeed(m_commandLine),true);
m_ptsys=new ROdoubleSeq(getContainerServices()->getName()+":systemTemperature",getComponent(),new DevIOTsys(m_commandLine),true);
m_psectionsNumber=new ROlong(getContainerServices()->getName()+":sectionsNumber",getComponent(),
new DevIOSectionsNumber(m_commandLine),true);
m_pinputSection=new ROlongSeq(getContainerServices()->getName()+":inputSection",getComponent(),new DevIOInputSection(m_commandLine),true);
m_parser=new CParser<CCommandLine>(line,10);
}
catch (std::bad_alloc& ex) {
_EXCPT(ComponentErrors::MemoryAllocationExImpl,dummy,"SardaraImpl::initialize()");
throw dummy;
}
// command parser configuration
m_parser->add("integration",new function1<CCommandLine,non_constant,void_type,I<long_type> >(line,&CCommandLine::setIntegration),1);
m_parser->add("calSwitch",new function1<CCommandLine,non_constant,void_type,I<long_type> >(line,&CCommandLine::activateCalSwitching),1 );
m_parser->add("setSection", new function7<CCommandLine,non_constant,void_type,I<long_type>,I<double_type>,I<double_type>,I<long_type>,I<enum_type<PolarizationToString> >,I<double_type>,I<long_type> >(line,&CCommandLine::setConfiguration),7 );
m_parser->add("setAttenuation", new function2<CCommandLine,non_constant,void_type,I<long_type>,I<double_type> >(line,&CCommandLine::setAttenuation),2 );
m_parser->add("enable",new function1<CCommandLine,non_constant,void_type,I<longSeq_type> >(line,&CCommandLine::setEnabled),1 );
m_parser->add("getIntegration",new function1<CCommandLine,constant,void_type,O<long_type> >(line,&CCommandLine::getIntegration),0 );
m_parser->add("getFrequency",new function1<CCommandLine,constant,void_type,O<doubleSeq_type> >(line,&CCommandLine::getFrequency),0 );
m_parser->add("getSampleRate",new function1<CCommandLine,constant,void_type,O<doubleSeq_type> >(line,&CCommandLine::getSampleRate),0 );
m_parser->add("getBins",new function1<CCommandLine,constant,void_type,O<longSeq_type> >(line,&CCommandLine::getBins),0 );
m_parser->add("getPolarization",new function1<CCommandLine,constant,void_type,O<longSeq_type> >(line,&CCommandLine::getPolarization),0 );
m_parser->add("getBandWidth",new function1<CCommandLine,non_constant,void_type,O<doubleSeq_type> >(line,&CCommandLine::getBandWidth),0 );
m_parser->add("getAttenuation",new function1<CCommandLine,non_constant,void_type,O<doubleSeq_type> >(line,&CCommandLine::getAttenuation),0 );
m_parser->add("getTpi",new function1<CCommandLine,non_constant,void_type,O<doubleSeq_type> >(line,&CCommandLine::getTpi),0 );
m_parser->add("getZero",new function1<CCommandLine,non_constant,void_type,O<doubleSeq_type> >(line,&CCommandLine::getZero),0 );
m_parser->add("getTime",new function1<CCommandLine,non_constant,void_type,O<time_type> >(line,&CCommandLine::getTime),0 );
m_parser->add("initialize",new function1<CCommandLine,non_constant,void_type,I<string_type> >(line,&CCommandLine::setup),1 );
m_parser->add("getRms",new function1<CCommandLine,non_constant,void_type,O<doubleSeq_type> >(line,&CCommandLine::getRms),0 );
m_parser->add("setTsysRange", new function2<CCommandLine,non_constant,void_type,I<double_type>,I<double_type> >(line,&CCommandLine::setTsysRange),2 );
threadPar.sender=this;
threadPar.command=m_commandLine;
threadPar.configuration=&m_configuration;
//threadPar.dataLine=&m_dataLine;
try {
CSenderThread::TSenderParameter *temp=&threadPar;
m_senderThread=getContainerServices()->getThreadManager()->create<CSenderThread,CSenderThread::TSenderParameter*> (
"DATAPUSHER",temp,m_configuration.getSenderResponseTime()*10,m_configuration.getSenderSleepTime()*10);
m_controlThread=getContainerServices()->getThreadManager()->create<CControlThread,CSecureArea<CCommandLine> * > (
"SUPERVISOR",m_commandLine,m_configuration.getControlResponseTime()*10,m_configuration.getControlSleepTime()*10);
}
catch (acsthreadErrType::acsthreadErrTypeExImpl& ex) {
_ADD_BACKTRACE(ComponentErrors::ThreadErrorExImpl,_dummy,ex,"SardaraImpl::initialize()");
throw _dummy;
}
catch (...) {
_THROW_EXCPT(ComponentErrors::UnexpectedExImpl,"SardaraImpl::initialize()");
}
m_initialized=true;
ACS_LOG(LM_FULL_INFO,"SardaraImpl::initialize()",(LM_INFO,"COMPSTATE_INITIALIZED"));
}
void SardaraImpl::execute() throw (ACSErr::ACSbaseExImpl)
{
AUTO_TRACE("SardaraImpl::execute()");
ACS::Time time;
IRA::CError error;
ACS_LOG(LM_FULL_INFO,"SardaraImpl::execute()",(LM_INFO,"BACKEND_INITIAL_CONFIGURATION"));
try {
//sets the property defaults....some of them cannot be changed any more (hardware dependent)
m_pbackendName->getDevIO()->write(getComponent()->getName(),time);
}
catch (ACSErr::ACSbaseExImpl& ex) {
_ADD_BACKTRACE(ComponentErrors::InitializationProblemExImpl,impl,ex,"SardaraImpl::execute()");
throw impl;
}
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
ACS_LOG(LM_FULL_INFO,"SardaraImpl::execute()",(LM_INFO,"SOCKET_CONNECTING"));
try {
ACS_LOG(LM_FULL_INFO,"SardaraImpl::execute()",(LM_INFO,"HARDWARE_INITIALIZATION"));
line->Init(&m_configuration); // this could throw an ACS exception.....
//line->setTime(); // this could throw ACS exceptions....
}
catch (ACSErr::ACSbaseExImpl& ex) {
deleteAll();
throw ex;
}
//resume the threads
//m_senderThread->resume();
//m_controlThread->resume();
try {
startPropertiesMonitoring();
}
catch (acsthreadErrType::CanNotStartThreadExImpl& E) {
_ADD_BACKTRACE(ComponentErrors::ThreadErrorExImpl,__dummy,E,"SardaraImpl::execute");
deleteAll();
throw __dummy;
}
catch (ACSErrTypeCommon::NullPointerExImpl& E) {
_ADD_BACKTRACE(ComponentErrors::ThreadErrorExImpl,__dummy,E,"SardaraImpl::execute");
deleteAll();
throw __dummy;
}
ACS_LOG(LM_FULL_INFO,"SardaraImpl::execute()",(LM_INFO,"COMPSTATE_OPERATIONAL"));
}
void SardaraImpl::deleteAll()
{
IRA::CError err;
if (m_initialized) {
if (m_senderThread!=NULL) {
m_senderThread->suspend();
}
if (m_controlThread!=NULL) {
m_controlThread->suspend();
}
if (m_commandLine) {
delete m_commandLine;
m_commandLine=NULL;
}
if (m_senderThread!=NULL) {
getContainerServices()->getThreadManager()->destroy(m_senderThread);
m_senderThread=NULL;
}
if (m_controlThread!=NULL) {
getContainerServices()->getThreadManager()->destroy(m_controlThread);
m_senderThread=NULL;
}
if (m_parser) {
delete m_parser;
m_parser=NULL;
}
// need to be closed before the thread that makes use of it
// m_dataLine.Close(err);
// ACS_LOG(LM_FULL_INFO,"SardaraImpl::deleteAll()",(LM_INFO,"DATA_LINE_CLOSED"));
_IRA_LOGFILTER_FLUSH;
_IRA_LOGFILTER_DESTROY;
ACS_LOG(LM_FULL_INFO,"SardaraImpl::deleteAll()",(LM_INFO,"LOGS_FLUSHED"));
m_initialized=false;
}
}
void SardaraImpl::cleanUp()
{
AUTO_TRACE("SardaraImpl::cleanUp()");
stopPropertiesMonitoring();
deleteAll();
CharacteristicComponentImpl::cleanUp();
}
void SardaraImpl::aboutToAbort()
{
AUTO_TRACE("SardaraImpl::aboutToAbort()");
deleteAll();
}
void SardaraImpl::sendHeader() throw (CORBA::SystemException, BackendsErrors::BackendsErrorsEx,
ComponentErrors::ComponentErrorsEx)
{
AUTO_TRACE("SardaraImpl::sendHeader()");
Backends::TMainHeader header;
Backends::TSectionHeader chHeader[MAX_SECTION_NUMBER];
//DWORD tpi[MAX_SECTION_NUMBER];
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
line->fillMainHeader(header);
line->fillChannelHeader(chHeader,MAX_SECTION_NUMBER);
/*try {
line->setTime();
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::sendHeader()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
*/
char buffer[sizeof(Backends::TMainHeader)+header.sections*sizeof(Backends::TSectionHeader)];
memcpy(buffer,(void *)&header,sizeof(Backends::TMainHeader));
memcpy(buffer+sizeof(Backends::TMainHeader),(void *)chHeader,header.sections*sizeof(Backends::TSectionHeader));
#ifndef BKD_DEBUG
try {
getSender()->startSend(FLOW_NUMBER,(const char*)buffer,
sizeof(Backends::TMainHeader)+header.sections*sizeof(Backends::TSectionHeader));
}
catch (AVStartSendErrorExImpl& ex) {
_ADD_BACKTRACE(BackendsErrors::TXErrorExImpl,impl,ex,"SardaraImpl::sendHeader()");
impl.setDetails("main header could not be sent");
impl.log(LM_DEBUG);
throw impl.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,impl,"SardaraImpl::sendHeader()");
impl.log(LM_DEBUG);
throw impl.getComponentErrorsEx();
}
#else
/*printf("Sects: %d beams: %d integration: %d sampleSize: %d\n",header.sections,header.beams,
header.integration,header.sampleSize);
for(int h=0;h<header.sections;h++) {
printf("id: %d bins: %d pol: %d bw: %lf freq: %lf att L: %lf att R: %lf sr: %lf feed: %d\n",
chHeader[h].id,
chHeader[h].bins,
chHeader[h].polarization,
chHeader[h].bandWidth,
chHeader[h].frequency,
chHeader[h].attenuation[0],
chHeader[h].attenuation[1],
chHeader[h].sampleRate,
chHeader[h].feed);
}*/
#endif
ACS_LOG(LM_FULL_INFO,"SardaraImpl::sendHeader()",(LM_INFO,"HEADERS_SENT"));
// inform the sender thread about the configuration......
m_senderThread->saveDataHeader(&header,chHeader);
// measure the zero tpi
#ifndef BKD_DEBUG
/*try {
//line->getZeroTPI(tpi);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::sendHeader()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}*/
#else
//for(int i=0;i<MAX_INPUT_NUMBER;tpi[i]=0,i++);
#endif
// now comunicate the reading to the sender thread.....
//m_senderThread->saveZero(tpi);
// start the job for the backend.....
try {
line->startDataAcquisition();
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::sendHeader()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::terminate() throw (CORBA::SystemException, BackendsErrors::BackendsErrorsEx,
ComponentErrors::ComponentErrorsEx)
{
AUTO_TRACE("SardaraImpl::terminate()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->stopDataAcquisition();
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::terminate()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::sendData(ACS::Time startTime) throw (CORBA::SystemException, BackendsErrors::BackendsErrorsEx,
ComponentErrors::ComponentErrorsEx)
{
AUTO_TRACE("SardaraImpl::sendData()");
TIMEVALUE now;
ACS::Time expectedStartTime;
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
expectedStartTime=line->resumeDataAcquisition(startTime);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::sendData()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
// if the resume succeeds....than set the start time accordingly.
//I explicitly release the mutex before accessing the sender thread because it also make use of the command line...just to make sure to avoid deadlock
line.Release();
m_senderThread->saveStartTime(expectedStartTime);
//m_senderThread->resumeTransfer();
}
void SardaraImpl::sendStop() throw (CORBA::SystemException, BackendsErrors::BackendsErrorsEx,
ComponentErrors::ComponentErrorsEx)
{
AUTO_TRACE("SardaraImpl::sendStop()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->suspendDataAcquisition();
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::sendStop()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
//I explicity release the mutex before accessing the sender thread because it also make use of the command line...just to make sure to avoid deadlock
//line.Release();
//m_senderThread->suspendTransfer();
try {
getSender()->stopSend(FLOW_NUMBER);
}
catch (AVStopSendErrorExImpl& ex) {
_ADD_BACKTRACE(BackendsErrors::TXErrorExImpl,impl,ex,"SardaraImpl::sendStop()");
impl.setDetails("stop message could not be sent");
throw impl.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,impl,"SardaraImpl::sendStop()");
throw impl.getComponentErrorsEx();
}
try {
line->sendTargetFileName();
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::sendStop()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::setSection(CORBA::Long input,CORBA::Double freq,CORBA::Double bw,CORBA::Long feed,CORBA::Long pol,CORBA::Double sr,CORBA::Long bins) throw (
CORBA::SystemException,ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::setSection()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->setConfiguration(input,freq,bw,feed,pol,sr,bins);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::setSection()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::setTargetFileName (const char * fileName) throw (CORBA::SystemException,ComponentErrors::ComponentErrorsEx,
BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::setTargetFileName()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
line->setTargetFileName(fileName);
}
ACS::doubleSeq *SardaraImpl::getRms() throw (CORBA::SystemException,
ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::getRms()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
ACS::doubleSeq_var rms=new ACS::doubleSeq;
try {
line->getRms(rms);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::getRms()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
return rms._retn();
}
ACS::doubleSeq *SardaraImpl::getTpi() throw (CORBA::SystemException,
ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::getTpi()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
ACS::doubleSeq_var tpi=new ACS::doubleSeq;
try {
line->getSample(tpi,false);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::getTpi()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
return tpi._retn();
}
ACS::doubleSeq * SardaraImpl::getZero () throw (CORBA::SystemException,
ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::getZero()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
ACS::doubleSeq_var tpi=new ACS::doubleSeq;
//TODO: how many sections????
//tpi->length(2);
try {
line->getSample(tpi,true);
//tpi[0]=0.0;
//tpi[1]=0.0;
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::getZero()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
return tpi._retn();
}
void SardaraImpl::setKelvinCountsRatio(const ACS::doubleSeq& ratio, const ACS::doubleSeq& tsys) throw (CORBA::SystemException)
{
AUTO_TRACE("SardaraImpl::setKelvinCountsRatio()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
line->saveTsys(tsys,ratio);
//if (m_senderThread) {
//m_senderThread->setKelvinCountsRatio(ratio);
//ACS_LOG(LM_FULL_INFO,"SardaraImpl::setKelvinCountsRatio()",(LM_INFO,"KELVIN_COUNTS_CONVERSION_FACTOR_SET"));
//}
}
void SardaraImpl::enableChannels(const ACS::longSeq& enable) throw (CORBA::SystemException,ComponentErrors::ComponentErrorsEx,
BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::enableChannels()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->setEnabled(enable);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::enableChannels()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::setTime() throw (CORBA::SystemException,ComponentErrors::ComponentErrorsEx,
BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::setTime()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->setTime();
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::setTime()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::setAttenuation(CORBA::Long input,CORBA::Double att) throw (CORBA::SystemException,ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::setAttenutation()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->setAttenuation(input,att);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::setAttenutation()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::setTsysRange(CORBA::Double freq,CORBA::Double bw) throw (CORBA::SystemException,ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::setTsysRange()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->setTsysRange(freq,bw);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::setTsysRange()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
CORBA::Long SardaraImpl::getInputs(ACS::doubleSeq_out freq,ACS::doubleSeq_out bandWidth,ACS::longSeq_out feed,ACS::longSeq_out ifNumber) throw (CORBA::SystemException,
ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
long inputs;
ACS::longSeq pol;
AUTO_TRACE("SardaraImpl::getInputs()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
//no need to take care of freeing allocated memory in case of exception because there are no except........
freq=new ACS::doubleSeq;
bandWidth=new ACS::doubleSeq;
feed=new ACS::longSeq;
ifNumber=new ACS::longSeq;
line->getFeed(*feed);
line->getFrequency(*freq);
line->getInputsNumber(inputs);
line->getBandWidth(*bandWidth);
line->getIFs(*ifNumber);
return inputs;
}
void SardaraImpl::activateNoiseCalibrationSwitching(CORBA::Long interleave) throw (CORBA::SystemException,
ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::activateNoiseCalibrationSwitching()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->activateCalSwitching(interleave); // NOT YET AVAILABLE
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::activateNoiseCalibrationSwitching()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::initialize(const char * configuration) throw (CORBA::SystemException,
ComponentErrors::ComponentErrorsEx,BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::initialize()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->setup(configuration);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::initialize()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::setIntegration(CORBA::Long Integration) throw (CORBA::SystemException,ComponentErrors::ComponentErrorsEx,
BackendsErrors::BackendsErrorsEx)
{
AUTO_TRACE("SardaraImpl::setIntegration()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->setIntegration(Integration);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::setIntegration()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::getConfiguration (CORBA::String_out configuration) throw (CORBA::SystemException)
{
AUTO_TRACE("SardaraImpl::getIntegration()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->getConfiguration(configuration);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::getConfiguration()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
void SardaraImpl::getCommProtVersion (CORBA::String_out version) throw (CORBA::SystemException)
{
AUTO_TRACE("SardaraImpl::getCommProtVersion()");
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
line->getCommProtVersion(version);
}
catch (ComponentErrors::ComponentErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getComponentErrorsEx();
}
catch (BackendsErrors::BackendsErrorsExImpl& ex) {
ex.log(LM_DEBUG);
throw ex.getBackendsErrorsEx();
}
catch (...) {
_EXCPT(ComponentErrors::UnexpectedExImpl,dummy,"SardaraImpl::getCommProtVersion()");
dummy.log(LM_DEBUG);
throw dummy.getComponentErrorsEx();
}
}
CORBA::Boolean SardaraImpl::command(const char *cmd,CORBA::String_out answer) throw (CORBA::SystemException)
{
AUTO_TRACE("SardaraImpl::command()");
IRA::CString out;
bool res;
// this is a cheat....it forces the acquisition of the mutex before the parser. It works only because the parser has no async behaviour configured
CSecAreaResourceWrapper<CCommandLine> line=m_commandLine->Get();
try {
m_parser->run(cmd,out);
res=true;
}
catch (ParserErrors::ParserErrorsExImpl &ex) {
res=false;
}
catch (ACSErr::ACSbaseExImpl& ex) {
ex.log(LM_ERROR); // the errors resulting from the execution are logged here as stated in the documentation of CommandInterpreter interface, while the parser errors are never logged.
res=false;
}
answer=CORBA::string_dup((const char *)out);
return res;
}
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROuLongLong,m_ptime,time);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROstring,m_pbackendName,backendName);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROdoubleSeq,m_pbandWidth,bandWidth);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROdoubleSeq,m_pfrequency,frequency);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROdoubleSeq,m_psampleRate,sampleRate);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROdoubleSeq,m_pattenuation,attenuation);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROlongSeq,m_ppolarization,polarization);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROlongSeq,m_pbins,bins);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROlong,m_pinputsNumber,inputsNumber);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROlong,m_pintegration,integration);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROpattern,m_pstatus,status);
_PROPERTY_REFERENCE_CPP(SardaraImpl,Management::ROTBoolean,m_pbusy,busy);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROlongSeq,m_pfeed,feed);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROdoubleSeq,m_ptsys,systemTemperature);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROlong,m_psectionsNumber,sectionsNumber);
_PROPERTY_REFERENCE_CPP(SardaraImpl,ACS::ROlongSeq,m_pinputSection,inputSection);
/* --------------- [ MACI DLL support functions ] -----------------*/
#include <maciACSComponentDefines.h>
MACI_DLL_SUPPORT_FUNCTIONS(SardaraImpl)
|
7a5bb491b80c87b78e80ba7f1023b3389e30ce03 | 4e7c3a072bbb1fcb313d972765680172833e72d0 | /war3x/war3x/nightelf.inl | 70198cf1e39e3ee4f921b21949efaea9dbde882a | [] | no_license | Geesu/wc3mods | f0ace84ca867bb2cb63e3c8ea308a35f775f8c5a | 3e3d47de8bed96c81bd03ee3a0bba1070ab2f417 | refs/heads/master | 2020-04-21T10:16:09.351004 | 2013-10-18T21:18:22 | 2013-10-18T21:18:22 | 13,690,144 | 14 | 5 | null | null | null | null | UTF-8 | C++ | false | false | 24,595 | inl | nightelf.inl | // Begin NIGHTELF.INL
/* - Events ----------------------------------------------------- */
public NE_skills_offensive( attacker, victim, weapon, iDamage, headshot ) {
if ( g_PlayerInfo[attacker][CURRENT_RACE] == RACE_NIGHTELF && get_user_team( attacker ) != get_user_team( victim ) )
{
// Trueshot Aura
if ( g_PlayerInfo[attacker][CURRENT_SKILL3] && weapon != CSW_KNIFE && weapon != CSW_HEGRENADE && cs_get_weapon_type_( weapon ) != CS_WEAPON_TYPE_SNIPER && get_user_health( victim ) > 0 )
NE_S_TRUESHOT( attacker, victim, weapon, iDamage, headshot );
}
return PLUGIN_HANDLED;
}
public NE_skills_defensive( attacker, victim, weapon, iDamage, headshot ) {
if ( g_PlayerInfo[victim][CURRENT_RACE] == RACE_NIGHTELF )
{
// Elune's Grace ( called from WAR3_damage() as well to catch all bonus damage )
if ( iDamage && weapon == CSW_KNIFE && get_user_team( attacker ) != get_user_team( victim ) )
{
iDamage -= NE_S_ELUNES_get_physical( victim, weapon, iDamage );
}
// Evasion
if ( g_PlayerInfo[victim][CURRENT_SKILL1] && get_user_health( victim ) > 0 )
{
if ( g_bEvadeNextShot[victim] )
NE_S_EVASION( attacker, victim, weapon, iDamage, headshot );
NE_S_EVASION_prep( victim );
NE_S_EVASION_health( victim );
}
}
return PLUGIN_HANDLED;
}
public NE_ultimates( caster, target ) {
// Rejuvenation
if ( g_PlayerInfo[caster][CURRENT_ULTIMATE] == ULTIMATE_REJUVENATION && get_user_team( target ) == get_user_team( caster ) )
{
if ( g_PlayerRejuv[target] )
{
new szMessage[128];
formatex( szMessage, 127, "%L", caster, "REJUVINATE_ALREADY" );
WAR3_status_text( caster, szMessage, 0.5 );
Ultimate_Beep( caster );
}
else
{
if ( get_user_health( target ) == WAR3_get_maxhealth( target ) )
{
new szMessage[64];
if ( caster == target )
{
formatex( szMessage, 63, "%L", caster, "FULLHEALTH_SELF" );
}
else
{
formatex( szMessage, 63, "%L", caster, "FULLHEALTH_TARGET" );
}
WAR3_status_text( caster, szMessage, 0.5 );
Ultimate_Beep( caster );
}
else
{
NE_U_REJUVENATION( caster, target );
Ultimate_Cooldown( caster, ULTIMATE_COOLDOWNDEFAULT );
SHARED_INVIS_cooldown( caster );
}
}
}
// Entangling Roots
else if ( g_PlayerInfo[caster][CURRENT_ULTIMATE] == ULTIMATE_ROOTS && get_user_team( target ) != get_user_team( caster ) && !g_PlayerRooted[target] )
{
NE_U_ROOT( caster, target );
Ultimate_Cooldown( caster, ULTIMATE_COOLDOWNDEFAULT );
SHARED_INVIS_cooldown( caster );
}
// Shadowstrike
else if ( g_PlayerInfo[caster][CURRENT_ULTIMATE] == ULTIMATE_SHADOWSTRIKE && get_user_team( target ) != get_user_team( caster ) )
{
if ( g_PlayerStruck[target] )
NE_U_SHADOWSTRIKE_remove( target );
NE_U_SHADOWSTRIKE( caster, target );
Ultimate_Cooldown( caster, ULTIMATE_COOLDOWNDEFAULT );
SHARED_INVIS_cooldown( caster );
}
else
{
Ultimate_Beep( caster );
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
/* - Racial Ability --------------------------------------------- */
// Elune's Grace
public NE_S_ELUNES_get_physical( id, weapon, iDamage ) {
if ( get_user_health( id ) > WAR3_get_minhealth( id ) )
{
new iLevel = WAR3_get_level( g_PlayerInfo[id][CURRENT_XP] );
// Set new damage amount
new Float:fAbsorb = float( iDamage ) * NE_S_ELUNES_get_knife( iLevel );
new iAbsorb = floatround( fAbsorb );
iDamage -= iAbsorb;
NE_S_ELUNES_absorb( id, iAbsorb );
// Give health back ( physical damage has already been dealt )
set_user_health( id, get_user_health( id ) + iAbsorb );
WAR3_check_health( id );
return ( iAbsorb );
}
return ( 0 );
}
public NE_S_ELUNES_get_bonus( id, weapon, iDamage ) {
new iLevel = WAR3_get_level( g_PlayerInfo[id][CURRENT_XP] );
// Set new damage amount
if ( weapon == CSW_KNIFE )
{
new Float:fAbsorb = float( iDamage ) * NE_S_ELUNES_get_knife( iLevel );
new iAbsorb = floatround( fAbsorb );
NE_S_ELUNES_absorb( id, iAbsorb );
return ( iAbsorb );
}
else if ( WAR3_is_ultimate( weapon ) )
{
new Float:fAbsorb = float( iDamage ) * NE_S_ELUNES_get_magic( iLevel );
new iAbsorb = floatround( fAbsorb );
NE_S_ELUNES_absorb( id, iAbsorb );
return ( iAbsorb );
}
return ( 0 );
}
public Float:NE_S_ELUNES_get_knife( iLevel ) {
new Float:fLevel = float( iLevel );
if ( fLevel > LEVEL_RACIALCAP )
fLevel = LEVEL_RACIALCAP;
new Float:fAbsorb = NE_fElunes_knife[0] + ( ( ( NE_fElunes_knife[1] - NE_fElunes_knife[0] ) / LEVEL_RACIALCAP ) * fLevel );
if ( fAbsorb < NE_fElunes_knife[1] )
fAbsorb = NE_fElunes_knife[1];
// Check if Night bonus applies ( coming soon )
// if ( g_bIsNighttime )
// fAbsorb *= ELUNES_NIGHTBONUS;
return ( fAbsorb );
}
public Float:NE_S_ELUNES_get_magic( iLevel ) {
new Float:fLevel = float( iLevel );
if ( fLevel > LEVEL_RACIALCAP )
fLevel = LEVEL_RACIALCAP;
new Float:fAbsorb = NE_fElunes_magic[0] + ( ( ( NE_fElunes_magic[1] - NE_fElunes_magic[0] ) / LEVEL_RACIALCAP ) * fLevel );
if ( fAbsorb < NE_fElunes_magic[1] )
fAbsorb = NE_fElunes_magic[1];
// Check if Night bonus applies ( coming soon )
// if ( g_bIsNighttime )
// fAbsorb *= ELUNES_NIGHTBONUS;
return ( fAbsorb );
}
static NE_S_ELUNES_absorb( id, iAbsorbed ) {
if ( iAbsorbed )
{
new iLevel = WAR3_get_level( g_PlayerInfo[id][CURRENT_XP] );
// Hud Message
new szMessage[64];
formatex( szMessage, 63, "%L", id, "DAMAGE_ELUNE", iAbsorbed );
WAR3_status_text( id, szMessage, 3.0 );
new iFadeAlpha = iAbsorbed * 3;
if ( iFadeAlpha > GLOW_MAX )
iFadeAlpha = GLOW_MAX;
new Shell[3];
for ( new i = 0; i < 3; i++ )
{
new Float:fColor = float( ELUNES_SHELL_RGB[i] ) / LEVEL_RACIALCAP;
fColor += fColor * float( iLevel );
new iColor = floatround( fColor );
Shell[i] = iColor;
}
// Glow shell
SHARED_GLOW_set( id, 0.1, Shell, 48 );
// Screen Fade
Create_ScreenFade( id, (1<<10), (1<<10), FADE_OUT, ELUNES_SHELL_RGB[GLOW_R] * 2, ELUNES_SHELL_RGB[GLOW_G] * 2, ELUNES_SHELL_RGB[GLOW_B] * 2, iFadeAlpha );
}
return PLUGIN_HANDLED;
}
/* - Skills ----------------------------------------------------- */
// Nature's Blessing ( speed )
public Float:NE_S_BLESSING_get_speed( id ) {
new weapon, iClip, iAmmo;
weapon = get_user_weapon( id, iClip, iAmmo );
new Float:fSpeed = CS_WEAPON_SPEED[weapon];
if ( g_bPlayerZoomed[id] )
fSpeed = CS_WEAPON_SPEED_ZOOM[weapon];
new Float:fBlessingSpeed = fSpeed + ( fSpeed * NE_fBlessing_speed[g_PlayerInfo[id][CURRENT_SKILL2] - 1] );
// Do not exceed cap
if ( fBlessingSpeed > BLESSING_MAXSPEED )
fBlessingSpeed = BLESSING_MAXSPEED;
return ( fBlessingSpeed );
}
public NE_S_BLESSING_set_speed( id ) {
// Check if restricted
if ( !WAR3_skill_enabled( id, RACE_NIGHTELF, SKILL_2 ) )
return PLUGIN_HANDLED;
new Float:fBlessingSpeed = NE_S_BLESSING_get_speed( id );
set_user_maxspeed( id, fBlessingSpeed );
return PLUGIN_HANDLED;
}
public NE_S_BLESSING_set_armor( id ) {
// coming soon..
return PLUGIN_HANDLED;
}
// Trueshot Aura
static NE_S_TRUESHOT( attacker, victim, weapon, iDamage, headshot ) {
// Check if restricted
if ( !WAR3_skill_enabled( attacker, RACE_NIGHTELF, SKILL_3 ) )
return PLUGIN_HANDLED;
new Float:fBonusDamage = float( iDamage ) * NE_fTrueshotAura[g_PlayerInfo[attacker][CURRENT_SKILL3] - 1];
new iBonusDamage = floatround( fBonusDamage );
// Add to player stats array
if ( get_cvar_num( "mp_war3stats" ) )
{
playerSkill3Info[attacker][0] += iBonusDamage;
}
// Apply Damage
if ( iBonusDamage > 0 )
WAR3_damage( attacker, victim, weapon, iBonusDamage, headshot, DAMAGE_CHECKARMOR );
return PLUGIN_HANDLED;
}
// Evasion
static NE_S_EVASION( attacker, victim, weapon, iDamage, headshot ) {
// Player dies to team attack / fall with evade
if ( get_user_health( victim ) <= 1024 && get_user_team( attacker ) == get_user_team( victim ) )
WAR3_death( attacker, victim, weapon, headshot );
// Attacked by Wind Walker
else if ( get_user_health( victim ) <= 1024 && g_bPlayerWalk[attacker] )
WAR3_death( attacker, victim, weapon, headshot );
// Player takes grenade / knife damage ( not evadeable )
else if ( weapon == CSW_KNIFE || weapon == CSW_HEGRENADE )
{
if ( get_user_health( victim ) <= 1024 )
WAR3_death( attacker, victim, weapon, headshot );
}
// Evadeable damage
else if ( get_user_health( victim ) > 0 && get_user_team( victim ) != get_user_team( attacker ) )
{
g_bEvadeNextShot[victim] = false;
new iHealth = get_user_health( victim ) + iDamage;
new iNewHealth = iHealth - 1024;
set_user_health( victim, iNewHealth );
g_fEvasionTime[victim] = get_gametime();
g_iEvasionDamage[victim] += iDamage;
// Decrease damage from attacker for kill assist
g_KillAssist_iTotalDamage[attacker][victim] -= iDamage;
// Inform player
new szMessage[128];
formatex( szMessage, 127, "%L", victim, "DAMAGE_EVASION", iDamage );
WAR3_status_text( victim, szMessage, 3.0 );
// Set task to re-check for evasion
new parm_Evasion[1];
parm_Evasion[0] = victim;
new task = TASK_EVASION + victim;
set_task( EVASION_SHOTGAP, "NE_S_EVASION_cooldown", task, parm_Evasion, 1 );
// Add to player stats array
if ( get_cvar_num( "mp_war3stats" ) )
{
playerSkill1Info[victim][0] += iDamage;
}
new iFadeAlpha = iDamage;
if ( iFadeAlpha > GLOW_MAX )
iFadeAlpha = GLOW_MAX;
// Glow
new iRGB[3];
iRGB[GLOW_B] = iFadeAlpha;
SHARED_GLOW_set( victim, glow_duration( iFadeAlpha ), iRGB, 36 );
// Screen Fade
Create_ScreenFade( victim, (1<<10), (1<<10), FADE_OUT, 0, 0, 255, iFadeAlpha );
}
return PLUGIN_HANDLED;
}
public NE_S_EVASION_prep( id ) {
if ( !WAR3_skill_enabled( id, RACE_NIGHTELF, SKILL_1 ) || g_iEvasionDamage[id] >= EVASION_MAXDAMAGE )
{
g_fEvasionTime[id] = get_gametime() + 1000.0;
return PLUGIN_HANDLED;
}
// Don't prep for evasion if EVASION_SHOTGAP not met
if ( get_gametime() - g_fEvasionTime[id] < EVASION_SHOTGAP )
return PLUGIN_HANDLED;
new Float:fEvadeChance = NE_fEvasion[g_PlayerInfo[id][CURRENT_SKILL1] - 1];
new Float:fRandomNum = random_float( 0.0, 1.0 );
if ( fEvadeChance >= fRandomNum )
g_bEvadeNextShot[id] = true;
return PLUGIN_HANDLED;
}
public NE_S_EVASION_cooldown( parm_Evasion[1] ) {
new id = parm_Evasion[0];
g_fEvasionTime[id] = 0.0;
NE_S_EVASION_prep( id );
NE_S_EVASION_health( id );
return PLUGIN_HANDLED;
}
public NE_S_EVASION_health( id ) {
new iMaxHealth = 100;
// Any health bonus checks go here
if ( g_bEvadeNextShot[id] && get_user_health( id ) <= iMaxHealth )
{
new iNewHealth = get_user_health( id ) + 1024;
set_user_health( id, iNewHealth );
}
else if ( !g_bEvadeNextShot[id] && get_user_health( id ) > 1024 )
{
new iNewHealth = get_user_health( id ) - 1024;
set_user_health( id, iNewHealth );
}
return PLUGIN_HANDLED;
}
/* - Entangling Roots ------------------------------------------- */
static NE_U_ROOT( caster, target ) {
g_PlayerRooted[target] = caster;
// Display message ( to target )
new szMessage[128], szPlayerName[32];
get_user_name( caster, szPlayerName, 31 );
formatex( szMessage, 127, "%L", target, "CAST_ROOTS", szPlayerName );
WAR3_status_text( target, szMessage, 3.0 );
// Trail effect
Create_TE_BEAMFOLLOW( SHOWTO_ALL_BROADCAST, target, SPR_BEAMFOLLOW, 10, 3, 10, 108, 23, 255 );
new parm[1];
parm[0] = target;
NE_U_ROOT_immobilize( parm );
return PLUGIN_HANDLED;
}
public NE_U_ROOT_immobilize( parmRoot[1] ) {
new target = parmRoot[0];
if ( get_entity_flags( target ) & FL_ONGROUND )
{
// Effect(s)
NE_U_ROOT_effects( target );
// Remove Trail
Remove_TE_BEAMFOLLOW( SEENBY_ALL, target );
// Check for Amulet
if ( g_PlayerInfo[target][CURRENT_ITEM] == ITEM_AMULET )
{
ITEM_AMULET_block( target, g_PlayerRooted[target] );
g_PlayerRooted[target] = 0;
return PLUGIN_HANDLED;
}
set_entity_velocity( target, {0,0,0} );
g_bPlayerCantMove[target] = true;
WAR3_set_speed( target );
Icon_DispellMe( target );
new Float:fDuration = ROOT_DURATION;
new iCounter = floatround( fDuration );
new parm_Dot[2];
parm_Dot[0] = target;
parm_Dot[1] = iCounter;
new task = TASK_ROOT + target;
set_task( 1.0, "NE_U_ROOT_dot", task, parm_Dot, 2 );
}
else
{
new task = TASK_ROOT + target;
set_task( 0.1, "NE_U_ROOT_immobilize", task, parmRoot, 1 );
}
return PLUGIN_HANDLED;
}
public NE_U_ROOT_dot( parm[2] ) {
new target = parm[0];
new caster = g_PlayerRooted[target];
new iCounter = parm[1];
new Float:fDuration = ROOT_DURATION;
new iDuration = floatround( fDuration );
new iDamage = ( ROOT_MAXDAMAGE / iDuration );
// Blood decals
static const BLOOD_SMALL[7] = {190,191,192,193,194,195,197};
new Origin[3];
get_user_origin( target, Origin );
Origin[0] += random_num( -100,100 );
Origin[1] += random_num( -100,100 );
Origin[2] -= 36;
Create_TE_WORLDDECAL( SHOWTO_ALL_BROADCAST, Origin, BLOOD_SMALL[random_num(0,6)] );
// Apply Damage
WAR3_damage( caster, target, CSW_ROOT, iDamage, CS_HEADSHOT_NO, DAMAGE_NOCHECKARMOR );
if ( is_user_alive( target ) )
{
// Poison Damage
Create_Damage( target, 0, 0, CS_DMG_POISON );
// Screen Fade
if ( !g_bPlayerSleeping[target] )
{
Create_ScreenFade( target, (1<<10), (1<<10), FADE_OUT, 10, 108, 23, 20 );
}
iCounter--;
if ( iCounter )
{
parm[1] = iCounter;
new task = TASK_ROOT + target;
set_task( 1.0, "NE_U_ROOT_dot", task, parm, 2 );
}
else
{
// Play Client-Only Soundfile
client_cmd( target, "speak warcraft3/bonus/EntanglingRootsDecay1.wav" );
NE_U_ROOT_remove( target );
}
}
return PLUGIN_HANDLED;
}
static NE_U_ROOT_effects( target ) {
new x1, y1, x2, y2;
new iRadius = 20, iCounter = 0;
new Float:fDuration = ROOT_DURATION;
new iDuration = floatround( fDuration );
new TargetOrigin[3];
get_user_origin( target, TargetOrigin );
// Play Sound
emit_sound( target, CHAN_STATIC, SOUND_ROOTS, 1.0, ATTN_NORM, 0, PITCH_NORM );
// Draw Coil
while ( iCounter <= 7 )
{
switch ( iCounter )
{
case 0,8: x1 = -iRadius;
case 1,7: x1 = -iRadius * 100 / 141;
case 2,6: x1 = 0;
case 3,5: x1 = iRadius * 100 / 141;
case 4: x1 = iRadius;
}
if ( iCounter <= 4 )
y1 = sqrt( iRadius * iRadius - x1 * x1 );
else
y1 = sqrt( iRadius * iRadius - x1 * x1 ) * -1;
iCounter++;
switch ( iCounter )
{
case 0,8: x2 = -iRadius;
case 1,7: x2 = -iRadius * 100 / 141;
case 2,6: x2 = 0;
case 3,5: x2 = iRadius * 100 / 141;
case 4: x2 = iRadius;
}
if ( iCounter <= 4 )
y2 = sqrt( iRadius * iRadius - x2 * x2 );
else
y2 = sqrt( iRadius * iRadius - x2 * x2 ) * -1;
new iHeight = 16 + ( 2 * iCounter );
while ( iHeight > -40 )
{
new Origin1[3];
Origin1[0] = TargetOrigin[0] + x1;
Origin1[1] = TargetOrigin[1] + y1;
Origin1[2] = TargetOrigin[2] + iHeight;
new Origin2[3];
Origin2[0] = TargetOrigin[0] + x2;
Origin2[1] = TargetOrigin[1] + y2;
Origin2[2] = TargetOrigin[2] + iHeight + 2;
Create_TE_BEAMPOINTS( SHOWTO_ALL_BROADCAST, Origin1, Origin2, SPR_ROOT, 0, 0, iDuration * 10, 10, 5, 10, 108, 23, 255, 0 );
iHeight -= 16;
}
}
// Plants
for ( new iPlantNum = 1; iPlantNum <= 8; iPlantNum++ )
{
new xOffset, yOffset;
switch ( iPlantNum )
{
case 1: xOffset = random_num( 10,25 );
case 2: xOffset = random_num( -25,-10 );
case 3: yOffset = random_num( 10,25 );
case 4: yOffset = random_num( -25,-10 );
case 5:
{
xOffset = random_num( 10,25 );
yOffset = random_num( 10,25 );
}
case 6:
{
xOffset = random_num( -25,-10 );
yOffset = random_num( -25,-10 );
}
case 7:
{
xOffset = random_num( 10,25 );
yOffset = random_num( -25,-10 );
}
case 8:
{
xOffset = random_num( -25,-10 );
yOffset = random_num( 10,25 );
}
}
new plantOrigin[3];
plantOrigin[0] = TargetOrigin[0] + xOffset;
plantOrigin[1] = TargetOrigin[1] + yOffset;
plantOrigin[2] = TargetOrigin[2] - 34;
if ( get_user_button( target ) & IN_DUCK )
plantOrigin[2] += 18;
NE_U_ROOT_effect_plant( target, plantOrigin );
}
return PLUGIN_HANDLED;
}
static NE_U_ROOT_effect_plant( target, Origin[3] ) {
// Select plant model
new szModelName[64];
switch ( random_num( 1,3 ) )
{
case 1: copy( szModelName, 63, "models/uplant1.mdl" );
case 2: copy( szModelName, 63, "models/uplant2.mdl" );
case 3: copy( szModelName, 63, "models/uplant3.mdl" );
}
new Float:fOrigin[3];
fOrigin[0] = float( Origin[0] );
fOrigin[1] = float( Origin[1] );
fOrigin[2] = float( Origin[2] );
new plant = WAR3_ENTITY_create( "ROOT_PLANT", szModelName, fOrigin, MOVETYPE_TOSS, SOLID_NOT, 0.0 );
entity_set_edict( plant, EV_ENT_owner, target );
// Animate
entity_set_int( plant, EV_INT_sequence, 0 );
entity_set_float( plant, EV_FL_frame, random_float( 1.0, 50.0 ) );
entity_set_float( plant, EV_FL_framerate, random_float( 1.0, 2.0 ) );
return PLUGIN_HANDLED;
}
public NE_U_ROOT_remove( id ) {
new task = TASK_ROOT + id;
remove_task( task, 0 );
g_PlayerRooted[id] = 0;
Remove_TE_BEAMFOLLOW( SEENBY_ALL, id );
SHARED_IMMOBILIZE_remove( id );
WAR3_set_speed( id );
Icon_DispellMe( id );
return PLUGIN_HANDLED;
}
/* - Shadow Strike ---------------------------------------------- */
static NE_U_SHADOWSTRIKE( caster, target ) {
// Play sound
emit_sound( target, CHAN_STATIC, SOUND_SHADOWSTRIKE, 1.0, ATTN_NORM, 0, PITCH_NORM );
// Implosion
new TargetOrigin[3];
get_user_origin( target, TargetOrigin );
Create_TE_IMPLOSION( SHOWTO_ALL_BROADCAST, TargetOrigin, 100, 120, 4 );
// "Fizzy" explosion
Create_TE_EXPLODEMODEL( SHOWTO_ALL_BROADCAST, TargetOrigin, 250, MDL_HORNET, 40, 50 );
// Check for Amulet
if ( g_PlayerInfo[target][CURRENT_ITEM] == ITEM_AMULET )
{
ITEM_AMULET_block( target, caster );
return PLUGIN_HANDLED;
}
// Hud message
new szPlayerName[32];
get_user_name( caster, szPlayerName, 31 );
new szMessage[128];
formatex( szMessage, 127, "%L", target, "CAST_SHADOWSTRIKE", szPlayerName );
WAR3_status_text2( target, szMessage, 3.0 );
// Adjust armor
if ( get_user_armor( target ) )
{
new iNewArmor = get_user_armor( target ) - SHADOWSTRIKE_ARMOR;
if ( iNewArmor < 0 )
iNewArmor = 0;
set_user_armor( target, iNewArmor );
}
// Apply damage
WAR3_damage( caster, target, CSW_SHADOWSTRIKE, SHADOWSTRIKE_DAMAGE, CS_HEADSHOT_NO, DAMAGE_NOCHECKARMOR );
if ( is_user_alive( target ) )
{
// Set globals
g_PlayerStruck[target] = caster;
g_bPlayerSlowed[target] = true;
// Set player speed
new Velocity[3];
get_entity_velocity( target, Velocity );
Velocity[0] = 0;
Velocity[1] = 0;
set_entity_velocity( target, Velocity );
WAR3_set_speed( target );
// Set damage over time
new parm_Dot[3];
parm_Dot[0] = caster;
parm_Dot[1] = target;
parm_Dot[2] = SHADOWSTRIKE_DURATION;
new task = TASK_SHADOWSTRIKE + caster;
set_task( 1.0, "NE_U_SHADOWSTRIKE_dot", task, parm_Dot, 3 );
Icon_DispellMe( target );
}
return PLUGIN_HANDLED;
}
public NE_U_SHADOWSTRIKE_dot( parm_Dot[3] ) {
new caster = parm_Dot[0];
new target = parm_Dot[1];
new iCounter = parm_Dot[2];
new iDamage = SHADOWSTRIKE_DOT / SHADOWSTRIKE_DURATION;
// Apply Damage
WAR3_damage( caster, target, CSW_SHADOWSTRIKE, iDamage, CS_HEADSHOT_NO, DAMAGE_NOCHECKARMOR );
if ( is_user_alive( target ) )
{
// Poison Damage
Create_Damage( target, 0, 0, CS_DMG_POISON );
// Screen Fade
if ( !g_bPlayerSleeping[target] )
{
Create_ScreenFade( target, (1<<10), (1<<10), FADE_OUT, 255, 255, 0, 20 );
}
// Check DOT Counter
iCounter--;
if ( iCounter )
{
parm_Dot[2] = iCounter;
new task = TASK_SHADOWSTRIKE + caster;
set_task( 1.0, "NE_U_SHADOWSTRIKE_dot", task, parm_Dot, 3 );
}
else
{
NE_U_SHADOWSTRIKE_remove( target );
}
}
return PLUGIN_HANDLED;
}
public NE_U_SHADOWSTRIKE_remove( target ) {
new caster = g_PlayerStruck[target];
new task = TASK_SHADOWSTRIKE + caster;
remove_task( task, 0 );
g_PlayerStruck[target] = 0;
SHARED_SLOW_remove( target );
WAR3_set_speed( target );
Icon_DispellMe( target );
return PLUGIN_HANDLED;
}
/* - Rejuvenation ----------------------------------------------- */
static NE_U_REJUVENATION( caster, target ) {
g_PlayerRejuv[target] = caster;
new szMessage[64];
// Status text
if ( caster == target )
{
formatex( szMessage, 127, "%L", caster, "REJUVINATE_SELF" );
WAR3_status_text( caster, szMessage, 3.0 );
}
else
{
new szCastMessage[64];
formatex( szCastMessage, 63, "%L", caster, "HEAL_CAST" );
WAR3_status_text( caster, szCastMessage, 1.0 );
new szPlayerName[32];
get_user_name( caster, szPlayerName, 31 );
formatex( szMessage, 127, "%L", target, "REJUVINATE_TARGET", szPlayerName );
WAR3_status_text( target, szMessage, 3.0 );
}
// Play sound
emit_sound( target, CHAN_STATIC, SOUND_REJUVENATION, 1.0, ATTN_NORM, 0, PITCH_NORM );
new parmHot[3];
parmHot[0] = caster;
parmHot[1] = target;
parmHot[2] = REJUVENATION_WAVES;
NE_U_REJUVENATION_hot( parmHot );
return PLUGIN_HANDLED;
}
public NE_U_REJUVENATION_effects( parm_Effects[2] ) {
new target = parm_Effects[0];
new iCounter = parm_Effects[1];
// Flares!
for ( new i = 0; i < 4; i++ )
{
new Float:fTargetOrigin[3];
entity_get_vector( target, EV_VEC_origin, fTargetOrigin );
// Randomize
fTargetOrigin[0] = random_float( fTargetOrigin[0] - 20.0, fTargetOrigin[0] + 20.0 );
fTargetOrigin[1] = random_float( fTargetOrigin[1] - 20.0, fTargetOrigin[1] + 20.0 );
fTargetOrigin[2] = random_float( fTargetOrigin[2] - 20.0, fTargetOrigin[2] + 20.0 );
// Sprite
new szSpriteName[64];
switch ( random_num( 1,2 ) )
{
case 1: copy( szSpriteName, 63, "sprites/blueflare2.spr" );
case 2: copy( szSpriteName, 63, "sprites/muz7.spr" );
}
new flare = WAR3_ENTITY_create( "REJUV_FLARE", szSpriteName, fTargetOrigin, MOVETYPE_NOCLIP, SOLID_NOT, 0.4 );
// Project Upwards
new Float:fVelocity[3];
fVelocity[2] = random_float( 125.0, 175.0 );
entity_set_vector( flare, EV_VEC_velocity, fVelocity );
// Create Trail
Create_TE_BEAMFOLLOW( SHOWTO_ALL_BROADCAST, flare, SPR_BEAMFOLLOW, 5, random_num( 1,3 ), random_num( 127,255 ), 0, random_num( 127,255 ), 128 );
// Create Lighting ( on player )
Create_TE_ELIGHT( SHOWTO_ALL_BROADCAST, target, random_num( 25,100 ), random_num( 127,255 ), 0, random_num( 127,255 ), 5, 5 );
// Render
entity_set_float( flare, EV_FL_renderamt, 128.0 );
entity_set_int( flare, EV_INT_rendermode, kRenderTransAdd );
entity_set_int( flare, EV_INT_renderfx, kRenderFxNone );
entity_set_float( flare, EV_FL_scale, random_float( 0.2, 0.6 ) );
}
iCounter++;
if ( iCounter <= 6 )
{
parm_Effects[1] = iCounter;
new task = 2000;
set_task( 0.1, "NE_U_REJUVENATION_effects", task, parm_Effects, 2 );
}
return PLUGIN_HANDLED;
}
public NE_U_REJUVENATION_hot( parmHot[3] ) {
new caster = parmHot[0];
new target = parmHot[1];
new iCounter = parmHot[2];
// Adjust Health
new iWaves = REJUVENATION_WAVES;
new iHealAmount = REJUVENATION_MAXHEALTH;
new Float:fBonusHealth = float( iHealAmount ) / float( iWaves );
if ( caster == target )
fBonusHealth *= SELFHEAL_MODIFIER;
new iBonusHealth = floatround( fBonusHealth );
// Heal player
WAR3_heal( caster, target, iBonusHealth );
// Add to total health array ( for hud message )
if ( caster != target )
g_iRejuvHealth[caster] += iBonusHealth;
// Add to player stats array
if ( get_cvar_num( "mp_war3stats" ) )
{
playerSkill2Info[caster][1] += iBonusHealth;
}
// Generate Effect(s)
new parm_Effects[2];
parm_Effects[0] = target;
NE_U_REJUVENATION_effects( parm_Effects );
iCounter--;
if ( iCounter )
{
parmHot[2] = iCounter;
new iWaves = REJUVENATION_WAVES;
new Float:fRate = REJUVENATION_DURATION / ( float( iWaves ) - 1.0 );
new task = TASK_REJUV + target;
set_task( fRate, "NE_U_REJUVENATION_hot", task, parmHot, 3 );
}
else
{
NE_U_REJUVENATION_remove( target );
}
return PLUGIN_HANDLED;
}
public NE_U_REJUVENATION_remove( target ) {
new caster = g_PlayerRejuv[target];
// Give support XP
XP_Support_Heal( caster, g_iRejuvHealth[caster] );
g_iRejuvHealth[caster] = 0;
// Unset
g_PlayerRejuv[target] = 0;
new task = TASK_REJUV + target;
remove_task( task, 0 );
return PLUGIN_HANDLED;
}
// ------------------------------------------------- End. - //
|
ef1ad3fc5451bd6319aae33fd7f69d8306d6bdf5 | 4882c595c1af3a7901c299c2d76a7332e92cfcc2 | /Proyecto/RedBrickSky/RedBrickSky/SoundManager.cpp | 9a7fea9601a0bf53297c7df03e936bb7433efd08 | [] | no_license | AmpersandStudio/Proyecto2 | 9a379e6a66c91f08d00def1949b7f8b07456f4ad | ccb86973408f265aac04f5c375c3b990b4596c48 | refs/heads/master | 2021-05-03T13:50:06.329071 | 2018-05-25T11:48:51 | 2018-05-25T11:48:51 | 120,511,852 | 0 | 0 | null | null | null | null | ISO-8859-1 | C++ | false | false | 2,005 | cpp | SoundManager.cpp | #include "SoundManager.h"
SoundManager* SoundManager::s_pInstance = 0;
// Metodo para cargar musica y sonidos
bool SoundManager::load(std::string fileName, std::string id, sound_type type)
{
if (type == SOUND_MUSIC)
{
Mix_Music* pMusic = Mix_LoadMUS(fileName.c_str());
if (pMusic == 0)
{
//std::cout << "Could not load music! SDL_mixer error: " << Mix_GetError() << std::endl;
return false;
}
m_music[id] = pMusic;
return true;
}
else if (type == SOUND_SFX)
{
Mix_Chunk* pChunk = Mix_LoadWAV(fileName.c_str());
if (pChunk == 0)
{
//std::cout << "Could not load SFX! SDL_mixer error: " << Mix_GetError() << std::endl;
return false;
}
m_sfxs[id] = pChunk;
return true;
}
return false;
}
// Metodos para reproducir musica y sonidos
void SoundManager::playMusic(std::string id, int loop)
{
Mix_PlayMusic(m_music[id], loop);
}
void SoundManager::PlaySoundInChannel(int c, std::string id, int loop) {
Mix_PlayChannel(c , m_sfxs[id], loop);
}
void SoundManager::playSound(std::string id, int loop)
{
Mix_PlayChannel(-1, m_sfxs[id], loop);
}
void SoundManager::playSoundFood()
{
if (Mix_Playing(1) == 0) Mix_PlayChannel(1, m_sfxs["food"], 0);
}
int SoundManager::isPlayingMusic() {
return Mix_PlayingMusic();
}
//Para la ejecución de TODOS los sonidos, pero no los libera (no los borra)
void SoundManager::stopMusic() {
Mix_HaltMusic();
}
/*Solo funciona con los SOUND_SFX.
*Valores sobre el máximo MIX_MAX_VOLUME hacen default a MIX_MAX_VOLUME
*/
void SoundManager::setChunkVolume(std::string id, int volume) {
Mix_VolumeChunk(m_sfxs[id], volume);
}
//Volumen general de la música
void SoundManager::setMusicVolume(int volume) {
Mix_VolumeMusic(volume);
}
//Cerrar canal
void SoundManager::closeChannel(int c) {
Mix_HaltChannel(c);
}
bool SoundManager::isPlayingChannel(int c) {
return Mix_Playing(c);
}
// Metodo para liberar el mapa de musica y sonido
void SoundManager::clear()
{
m_music.clear();
m_sfxs.clear();
Mix_CloseAudio();
}
|
9f3953309001bed4a0387de1964b25647ae8d321 | d09460da0e4b6af14a50bd3b2800c70b47058e92 | /perspectiveCamera.cpp | ad1b6524276d97599f68ee26843afb319ee956d9 | [] | no_license | kllilizxc/rayTracer | f66218ec65024573aac40ac50affa60678e9fc61 | 5b661cd60f694febe0eeecc4389fe8c8c2050d3b | refs/heads/master | 2021-01-24T18:25:55.435627 | 2017-03-16T06:23:25 | 2017-03-16T06:23:25 | 84,436,345 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,820 | cpp | perspectiveCamera.cpp | //
// Created by 54179 on 2016/10/12.
//
#include <GL/gl.h>
#include <GL/glu.h>
#include "perspectiveCamera.h"
#include "matrix.h"
PerspectiveCamera::PerspectiveCamera(Vec3f center, Vec3f &direction, Vec3f &up, float angle) : center(center),
direction(direction),
angle(angle) {
this->direction.Normalize();
this->up = up - up * this->direction;
this->up.Normalize();
Vec3f::Cross3(this->horizontal, this->direction, this->up);
this->horizontal.Normalize();
}
Ray PerspectiveCamera::generateRay(Vec2f point) {
// Vec3f dirX = point.x() * tan(angle / 2) * horizontal;
// Vec3f dirY = point.y() * tan(angle / 2) * up;
Vec3f dirX = tan(angle / 2 * point.x()) * horizontal;
Vec3f dirY = tan(angle / 2 * point.y()) * up;
Vec3f dir = direction + dirX + dirY;
dir.Normalize();
return Ray(center, dir);
}
float PerspectiveCamera::getTMin() const {
return 0;
}
// ====================================================================
// ====================================================================
// ====================================================================
// Create a perspective camera with the appropriate dimensions that
// crops or stretches in the x-dimension as necessary
// ====================================================================
void PerspectiveCamera::glInit(int w, int h) {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(angle * 180.0 / 3.14159, (float) w / float(h), 0.5, 40.0);
}
// ====================================================================
// Place a perspective camera within an OpenGL scene
// ====================================================================
void PerspectiveCamera::glPlaceCamera(void) {
gluLookAt(center.x(), center.y(), center.z(), center.x() + direction.x(), center.y() + direction.y(),
center.z() + direction.z(), up.x(), up.y(), up.z());
}
// ====================================================================
// dollyCamera, truckCamera, and RotateCamera
//
// Asumptions:
// - up is really up (i.e., it hasn't been changed
// to point to "screen up")
// - up and direction are normalized
// Special considerations:
// - If your constructor precomputes any vectors for
// use in 'generateRay', you will likely to recompute those
// values at athe end of the these three routines
// ====================================================================
// ====================================================================
// dollyCamera: Move camera along the direction vector
// ====================================================================
void PerspectiveCamera::dollyCamera(float dist) {
center += direction * dist;
// ===========================================
// ASSIGNMENT 3: Fix any other affected values
// ===========================================
}
// ====================================================================
// truckCamera: Translate camera perpendicular to the direction vector
// ====================================================================
void PerspectiveCamera::truckCamera(float dx, float dy) {
Vec3f screenUp;
Vec3f::Cross3(screenUp, horizontal, direction);
center += horizontal * dx + screenUp * dy;
// ===========================================
// ASSIGNMENT 3: Fix any other affected values
// ===========================================
}
// ====================================================================
// rotateCamera: Rotate around the up and horizontal vectors
// ====================================================================
void PerspectiveCamera::rotateCamera(float rx, float ry) {
// Don't let the model flip upside-down (There is a singularity
// at the poles when 'up' and 'direction' are aligned)
float tiltAngle = acos(up.Dot3(direction));
if (tiltAngle - ry > 3.13) ry = tiltAngle - 3.13; else if (tiltAngle - ry < 0.01) ry = tiltAngle - 0.01;
Matrix rotMat = Matrix::MakeAxisRotation(up, rx);
rotMat *= Matrix::MakeAxisRotation(horizontal, ry);
rotMat.Transform(center);
rotMat.TransformDirection(direction);
direction.Normalize();
// ===========================================
// ASSIGNMENT 3: Fix any other affected values
// ===========================================
rotMat.TransformDirection(up);
rotMat.TransformDirection(horizontal);
direction.Normalize();
up.Normalize();
horizontal.Normalize();
}
// ====================================================================
// ====================================================================
|
9e1b887b9fc71240eebe9e567611a25d99647ab6 | 091afb7001e86146209397ea362da70ffd63a916 | /inst/include/nt2/include/functions/allbits.hpp | 81da93e9da153c7da5a5cc479614c0c46b057995 | [] | no_license | RcppCore/RcppNT2 | f156b58c08863243f259d1e609c9a7a8cf669990 | cd7e548daa2d679b6ccebe19744b9a36f1e9139c | refs/heads/master | 2021-01-10T16:15:16.861239 | 2016-02-02T22:18:25 | 2016-02-02T22:18:25 | 50,460,545 | 15 | 1 | null | 2019-11-15T22:08:50 | 2016-01-26T21:29:34 | C++ | UTF-8 | C++ | false | false | 161 | hpp | allbits.hpp | #ifndef NT2_INCLUDE_FUNCTIONS_ALLBITS_HPP_INCLUDED
#define NT2_INCLUDE_FUNCTIONS_ALLBITS_HPP_INCLUDED
#include <nt2/core/include/functions/allbits.hpp>
#endif
|
c7f74a519d6a19582b4e153f6d46916e1a864761 | e25be42d4104432a64f602c6f45926cb117b2e69 | /11831.cpp | d6eaf5e9d82784663452d53589a61949e34e1253 | [] | no_license | ermahechap/UVa-Solutions | bcd8e3f19b75fb22bcd70ce8d85f39aeca6a5042 | 52940c4aa793821698dac9ac6bb390ea10f86dee | refs/heads/master | 2021-09-24T20:06:44.241702 | 2018-10-13T23:53:25 | 2018-10-13T23:53:25 | 118,072,432 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,664 | cpp | 11831.cpp | #include<bits/stdc++.h>
using namespace std;
//N,L,S,O
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
int N,M,S;
int x,y;
string dat[150];
string dir;
int d(char n){
return (n=='N')?0:(n=='L')?1:(n=='S')?2:3;
}
void showD(){
for (int i = 0; i < N; i++) {
cout<<dat[i]<<endl;
}
}
int main(){
//freopen("test.in","r",stdin);
while (cin>>N>>M>>S && (N!=0 && M!=0 && S!=0)) {
for (int i = 0; i < N; i++) {
cin>>dat[i];
for (int j = 0;j<M;j++){
if(dat[i][j]=='N' || dat[i][j]=='S' || dat[i][j]=='L' || dat[i][j]=='O'){x=i;y=j;}
}
}
cin>>dir;
int ans = 0;
int curDir = d(dat[x][y]);
//showD();
//cout<<"dir "<<curDir<<" - "<<x<<","<<y<<"///"<<dx[curDir]<<","<<dy[curDir]<<" + "<<curDir<<"\n\n";
for (int i = 0 ;i<S;i++){
if(dir[i]=='D'){
curDir = (curDir+1)%4;
}else if(dir[i]=='E'){
if(curDir-1<0)curDir=3;
else curDir -= 1;
}else{
if(x+dx[curDir]>=N || x+dx[curDir]<0)continue;
if(y+dy[curDir]>=M || y+dy[curDir]<0)continue;
if(dat[x+dx[curDir]][y+dy[curDir]]=='#')continue;
if(dat[x+dx[curDir]][y+dy[curDir]]=='*')ans++;
dat[x+dx[curDir]][y+dy[curDir]] =dat[x][y];
dat[x][y]='.';
x=x+dx[curDir];
y = y+dy[curDir];
}
//showD();
//cout<<">>>dir "<<curDir<<" - "<<x<<","<<y<<"///"<<dx[curDir]<<","<<dy[curDir]<<" + "<<curDir<<"\n\n";
}
cout<<ans<<endl;
}
}
|
fd32a6abd381a4c49fc0e9a2d67c293a9e9520ff | bb04852798c8cfe2b807ab19323b2feeca5aaa18 | /OpenHolo_DepthMap/graphics/vec.h | f3d983a8e335ec26af80f5ba05a8d25dda3319da | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | ShimaRafiei-IUT/OpenHologram | 1acdcb45347bbd6601a81c00287749e9290b244e | c6cdddb5106fe0079d9810eea588d28aa71f0023 | refs/heads/master | 2023-03-15T15:31:21.576826 | 2018-08-03T11:36:43 | 2018-08-03T11:36:43 | 591,491,027 | 1 | 0 | NOASSERTION | 2023-01-20T22:15:17 | 2023-01-20T22:15:16 | null | UTF-8 | C++ | false | false | 23,348 | h | vec.h | #ifndef __vec_h
#define __vec_h
// Description:
// Mathematical tools to handle n-dimensional vectors
//
// Author:
// Myung-Joon Kim
// Dae-Hyun Kim
#include "graphics/real.h"
#include "graphics/ivec.h"
#include "graphics/epsilon.h"
#include <math.h>
#include <stdio.h>
namespace graphics {
/**
* @brief structure for 2-dimensional real type vector and its arithmetic.
*/
struct vec2 {
real v[2];
static const int n;
inline vec2() { }
inline vec2(real a)
{
v[1 - 1] = a; v[2 - 1] = a;
}
inline vec2(real v_1 , real v_2 )
{
v[1 - 1] = v_1; v[2 - 1] = v_2;
}
inline vec2(const ivec2& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1];
}
inline vec2(const vec2& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1];
}
inline vec2& operator=(const vec2& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1];
return *this;
}
inline real& operator[] (int i) { return v[i]; }
inline const real& operator[] (int i) const { return v[i]; }
inline real& operator() (int i) { return v[i % 2]; }
inline const real& operator() (int i) const { return v[i % 2]; }
bool unit();
real length() const;
inline bool is_zero() const { return (v[0] == 0.0 && v[1] == 0.0); }
inline bool is_tiny(real tiny_tol = epsilon) const {
return (fabs(v[0]) <= tiny_tol && fabs(v[1]) <= tiny_tol);
}
//
// returns 1: this and other vectors are parallel
// -1: this and other vectors are anti-parallel
// 0: this and other vectors are not parallel
// or at least one of the vectors is zero
int is_parallel(
const vec2&, // other vector
real = angle_tolerance // optional angle tolerance (radians)
) const;
// returns true: this and other vectors are perpendicular
// false: this and other vectors are not perpendicular
// or at least one of the vectors is zero
bool is_perpendicular(
const vec2&, // other vector
real = angle_tolerance // optional angle tolerance (radians)
) const;
//
// set this vector to be perpendicular to another vector
bool perpendicular( // Result is not unitized.
// returns false if input vector is zero
const vec2&
);
//
// set this vector to be perpendicular to a line defined by 2 points
bool perpendicular(
const vec2&,
const vec2&
);
};
//| binary op : componentwise
inline vec2 operator + (const vec2& a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] + b[i]; }
return c;
}
inline vec2 operator + (real a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a + b[i]; }
return c;
}
inline vec2 operator + (const vec2& a, real b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] + b; }
return c;
}
inline vec2 operator - (const vec2& a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] - b[i]; }
return c;
}
inline vec2 operator - (real a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a - b[i]; }
return c;
}
inline vec2 operator - (const vec2& a, real b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] - b; }
return c;
}
inline vec2 operator * (const vec2& a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] * b[i]; }
return c;
}
inline vec2 operator * (real a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a * b[i]; }
return c;
}
inline vec2 operator * (const vec2& a, real b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] * b; }
return c;
}
inline vec2 operator / (const vec2& a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] / b[i]; }
return c;
}
inline vec2 operator / (real a, const vec2& b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a / b[i]; }
return c;
}
inline vec2 operator / (const vec2& a, real b)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = a[i] / b; }
return c;
}
//| cumulative op : componentwise
inline vec2 operator += (vec2& a, const vec2& b)
{
return a = (a + b);
}
inline vec2 operator += (vec2& a, real b)
{
return a = (a + b);
}
inline vec2 operator -= (vec2& a, const vec2& b)
{
return a = (a - b);
}
inline vec2 operator -= (vec2& a, real b)
{
return a = (a - b);
}
inline vec2 operator *= (vec2& a, const vec2& b)
{
return a = (a * b);
}
inline vec2 operator *= (vec2& a, real b)
{
return a = (a * b);
}
inline vec2 operator /= (vec2& a, const vec2& b)
{
return a = (a / b);
}
inline vec2 operator /= (vec2& a, real b)
{
return a = (a / b);
}
//| logical op : componentwise
inline int operator == (const vec2& a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] == b[i]; }
return c;
}
inline int operator == (real a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a == b[i]; }
return c;
}
inline int operator == (const vec2& a, real b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] == b; }
return c;
}
inline int operator < (const vec2& a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] < b[i]; }
return c;
}
inline int operator < (real a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a < b[i]; }
return c;
}
inline int operator < (const vec2& a, real b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] < b; }
return c;
}
inline int operator <= (const vec2& a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] <= b[i]; }
return c;
}
inline int operator <= (real a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a <= b[i]; }
return c;
}
inline int operator <= (const vec2& a, real b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] <= b; }
return c;
}
inline int operator > (const vec2& a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] > b[i]; }
return c;
}
inline int operator > (real a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a > b[i]; }
return c;
}
inline int operator > (const vec2& a, real b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] > b; }
return c;
}
inline int operator >= (const vec2& a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] >= b[i]; }
return c;
}
inline int operator >= (real a, const vec2& b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a >= b[i]; }
return c;
}
inline int operator >= (const vec2& a, real b)
{
int c = 1;
for(int i = 0; i < 2;++i) { c = c && a[i] >= b; }
return c;
}
//| unary op : componentwise
inline vec2 operator - (const vec2& a)
{
vec2 c;
for(int i = 0; i < 2;++i) { c[i] = - a[i]; }
return c;
}
//| R^n -> R
inline real sum(const vec2& a)
{
real s = 0;
s += a[1 - 1];
s += a[2 - 1];
return s;
}
inline real inner(const vec2& a, const vec2& b)
{
vec2 tmp = a * b;
return sum(tmp);
}
inline real norm(const vec2& a)
{
return sqrt(inner(a, a));
}
inline real squaredNorm(const vec2& a) {
return inner(a, a);
}
inline vec2 unit(const vec2& a)
{
real n = norm(a);
if(n < epsilon)
return 0;
else
return a / n;
}
inline real angle(const vec2& a, const vec2& b)
{
real ang = inner(unit(a), unit(b));
if(ang > 1 - epsilon)
return 0;
else if(ang < -1 + epsilon)
return M_PI;
else
return acos(ang);
}
inline vec2 proj(const vec2& axis, const vec2& a)
{
vec2 u = unit(axis);
return inner(a, u) * u;
}
inline vec2 absolute(const vec2& val)
{
return vec2(fabs(val[0]), fabs(val[1]));
}
void store(FILE* fp, const vec2& v);
int scan(FILE* fp, const vec2& v);
int apx_equal(const vec2& a, const vec2& b);
int apx_equal(const vec2& a, const vec2& b, real eps);
/**
* @brief structure for 3-dimensional real type vector and its arithmetic.
*/
struct vec3 {
real v[3];
static const int n;
inline vec3() { }
inline vec3(real a)
{
v[1 - 1] = a; v[2 - 1] = a; v[3 - 1] = a;
}
inline vec3(real v_1 , real v_2 , real v_3 )
{
v[1 - 1] = v_1; v[2 - 1] = v_2; v[3 - 1] = v_3;
}
inline vec3(const ivec3& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1]; v[3 - 1] = a[3 - 1];
}
inline vec3(const vec3& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1]; v[3 - 1] = a[3 - 1];
}
inline vec3& operator=(const vec3& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1]; v[3 - 1] = a[3 - 1];
return *this;
}
inline real& operator[] (int i) { return v[i]; }
inline const real& operator[] (int i) const { return v[i]; }
inline real& operator() (int i) { return v[i % 3]; }
inline const real& operator() (int i) const { return v[i % 3]; }
inline bool is_zero() const { return (v[0] == 0.0 && v[1] == 0.0 && v[2] == 0.0); }
inline bool is_tiny(real tiny_tol = epsilon) const {
return (fabs(v[0]) <= tiny_tol && fabs(v[1]) <= tiny_tol && fabs(v[2]) <= tiny_tol );
}
bool unit();
real length() const;
//
// returns 1: this and other vectors are parallel
// -1: this and other vectors are anti-parallel
// 0: this and other vectors are not parallel
// or at least one of the vectors is zero
int is_parallel(
const vec3&, // other vector
real = angle_tolerance // optional angle tolerance (radians)
) const;
//
// returns true: this and other vectors are perpendicular
// false: this and other vectors are not perpendicular
// or at least one of the vectors is zero
bool is_perpendicular(
const vec3&, // other vector
real = angle_tolerance // optional angle tolerance (radians)
) const;
//
// set this vector to be perpendicular to another vector
bool perpendicular( // Result is not unitized.
// returns false if input vector is zero
const vec3&
);
//
// set this vector to be perpendicular to a plane defined by 3 points
// returns false if points are coincident or colinear
bool perpendicular(
const vec3&, const vec3&, const vec3&
);
};
//| binary op : componentwise
inline vec3 operator + (const vec3& a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] + b[i]; }
return c;
}
inline vec3 operator + (real a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a + b[i]; }
return c;
}
inline vec3 operator + (const vec3& a, real b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] + b; }
return c;
}
inline vec3 operator - (const vec3& a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] - b[i]; }
return c;
}
inline vec3 operator - (real a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a - b[i]; }
return c;
}
inline vec3 operator - (const vec3& a, real b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] - b; }
return c;
}
inline vec3 operator * (const vec3& a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] * b[i]; }
return c;
}
inline vec3 operator * (real a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a * b[i]; }
return c;
}
inline vec3 operator * (const vec3& a, real b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] * b; }
return c;
}
inline vec3 operator / (const vec3& a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] / b[i]; }
return c;
}
inline vec3 operator / (real a, const vec3& b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a / b[i]; }
return c;
}
inline vec3 operator / (const vec3& a, real b)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = a[i] / b; }
return c;
}
//| cumulative op : componentwise
inline vec3 operator += (vec3& a, const vec3& b)
{
return a = (a + b);
}
inline vec3 operator += (vec3& a, real b)
{
return a = (a + b);
}
inline vec3 operator -= (vec3& a, const vec3& b)
{
return a = (a - b);
}
inline vec3 operator -= (vec3& a, real b)
{
return a = (a - b);
}
inline vec3 operator *= (vec3& a, const vec3& b)
{
return a = (a * b);
}
inline vec3 operator *= (vec3& a, real b)
{
return a = (a * b);
}
inline vec3 operator /= (vec3& a, const vec3& b)
{
return a = (a / b);
}
inline vec3 operator /= (vec3& a, real b)
{
return a = (a / b);
}
//| logical op : componentwise
inline int operator == (const vec3& a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] == b[i]; }
return c;
}
inline int operator == (real a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a == b[i]; }
return c;
}
inline int operator == (const vec3& a, real b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] == b; }
return c;
}
inline int operator < (const vec3& a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] < b[i]; }
return c;
}
inline int operator < (real a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a < b[i]; }
return c;
}
inline int operator < (const vec3& a, real b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] < b; }
return c;
}
inline int operator <= (const vec3& a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] <= b[i]; }
return c;
}
inline int operator <= (real a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a <= b[i]; }
return c;
}
inline int operator <= (const vec3& a, real b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] <= b; }
return c;
}
inline int operator > (const vec3& a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] > b[i]; }
return c;
}
inline int operator > (real a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a > b[i]; }
return c;
}
inline int operator > (const vec3& a, real b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] > b; }
return c;
}
inline int operator >= (const vec3& a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] >= b[i]; }
return c;
}
inline int operator >= (real a, const vec3& b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a >= b[i]; }
return c;
}
inline int operator >= (const vec3& a, real b)
{
int c = 1;
for(int i = 0; i < 3;++i) { c = c && a[i] >= b; }
return c;
}
//| unary op : componentwise
inline vec3 operator - (const vec3& a)
{
vec3 c;
for(int i = 0; i < 3;++i) { c[i] = - a[i]; }
return c;
}
inline vec3 absolute(const vec3& val)
{
return vec3(fabs(val[0]), fabs(val[1]), fabs(val[2]));
}
//| R^n -> R
inline real sum(const vec3& a)
{
real s = 0;
s += a[1 - 1];
s += a[2 - 1];
s += a[3 - 1];
return s;
}
inline real inner(const vec3& a, const vec3& b)
{
vec3 tmp = a * b;
return sum(tmp);
}
inline real squaredNorm(const vec3& a) {
return inner(a, a);
}
inline real norm(const vec3& a)
{
return sqrt(inner(a, a));
}
inline vec3 unit(const vec3& a)
{
real n = norm(a);
if(n < zero_epsilon)
return 0;
else
return a / n;
}
inline real angle(const vec3& a, const vec3& b)
{
real ang = inner(unit(a), unit(b));
if(ang > 1 - epsilon)
return 0;
else if(ang < -1 + epsilon)
return M_PI;
else
return acos(ang);
}
inline vec3 proj(const vec3& axis, const vec3& a)
{
vec3 u = unit(axis);
return inner(a, u) * u;
}
void store(FILE* fp, const vec3& v);
int scan(FILE* fp, const vec3& v);
int apx_equal(const vec3& a, const vec3& b);
int apx_equal(const vec3& a, const vec3& b, real eps);
/**
* @brief structure for 4-dimensional real type vector and its arithmetic.
*/
struct vec4 {
real v[4];
static const int n;
inline vec4() { }
inline vec4(real a)
{
v[1 - 1] = a; v[2 - 1] = a; v[3 - 1] = a; v[4 - 1] = a;
}
inline vec4(real v_1 , real v_2 , real v_3 , real v_4 )
{
v[1 - 1] = v_1; v[2 - 1] = v_2; v[3 - 1] = v_3; v[4 - 1] = v_4;
}
inline vec4(const ivec4& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1]; v[3 - 1] = a[3 - 1]; v[4 - 1] = a[4 - 1];
}
inline vec4(const vec4& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1]; v[3 - 1] = a[3 - 1]; v[4 - 1] = a[4 - 1];
}
inline vec4& operator=(const vec4& a)
{
v[1 - 1] = a[1 - 1]; v[2 - 1] = a[2 - 1]; v[3 - 1] = a[3 - 1]; v[4 - 1] = a[4 - 1];
return *this;
}
inline real& operator[] (int i) { return v[i]; }
inline const real& operator[] (int i) const { return v[i]; }
inline real& operator() (int i) { return v[i % 4]; }
inline const real& operator() (int i) const { return v[i % 4]; }
inline bool is_zero() const { return (v[0] == 0.0 && v[1] == 0.0 && v[2] == 0.0 && v[3] == 0.0); }
inline bool is_tiny(real tiny_tol = epsilon) const {
return (fabs(v[0]) <= tiny_tol && fabs(v[1]) <= tiny_tol && fabs(v[2]) <= tiny_tol && fabs(v[3]) <= tiny_tol);
}
bool unit();
real length() const;
};
//| binary op : componentwise
inline vec4 operator + (const vec4& a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] + b[i]; }
return c;
}
inline vec4 operator + (real a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a + b[i]; }
return c;
}
inline vec4 operator + (const vec4& a, real b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] + b; }
return c;
}
inline vec4 operator - (const vec4& a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] - b[i]; }
return c;
}
inline vec4 operator - (real a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a - b[i]; }
return c;
}
inline vec4 operator - (const vec4& a, real b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] - b; }
return c;
}
inline vec4 operator * (const vec4& a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] * b[i]; }
return c;
}
inline vec4 operator * (real a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a * b[i]; }
return c;
}
inline vec4 operator * (const vec4& a, real b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] * b; }
return c;
}
inline vec4 operator / (const vec4& a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] / b[i]; }
return c;
}
inline vec4 operator / (real a, const vec4& b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a / b[i]; }
return c;
}
inline vec4 operator / (const vec4& a, real b)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = a[i] / b; }
return c;
}
//| cumulative op : componentwise
inline vec4 operator += (vec4& a, const vec4& b)
{
return a = (a + b);
}
inline vec4 operator += (vec4& a, real b)
{
return a = (a + b);
}
inline vec4 operator -= (vec4& a, const vec4& b)
{
return a = (a - b);
}
inline vec4 operator -= (vec4& a, real b)
{
return a = (a - b);
}
inline vec4 operator *= (vec4& a, const vec4& b)
{
return a = (a * b);
}
inline vec4 operator *= (vec4& a, real b)
{
return a = (a * b);
}
inline vec4 operator /= (vec4& a, const vec4& b)
{
return a = (a / b);
}
inline vec4 operator /= (vec4& a, real b)
{
return a = (a / b);
}
//| logical op : componentwise
inline int operator == (const vec4& a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] == b[i]; }
return c;
}
inline int operator == (real a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a == b[i]; }
return c;
}
inline int operator == (const vec4& a, real b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] == b; }
return c;
}
inline int operator < (const vec4& a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] < b[i]; }
return c;
}
inline int operator < (real a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a < b[i]; }
return c;
}
inline int operator < (const vec4& a, real b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] < b; }
return c;
}
inline int operator <= (const vec4& a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] <= b[i]; }
return c;
}
inline int operator <= (real a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a <= b[i]; }
return c;
}
inline int operator <= (const vec4& a, real b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] <= b; }
return c;
}
inline int operator > (const vec4& a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] > b[i]; }
return c;
}
inline int operator > (real a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a > b[i]; }
return c;
}
inline int operator > (const vec4& a, real b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] > b; }
return c;
}
inline int operator >= (const vec4& a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] >= b[i]; }
return c;
}
inline int operator >= (real a, const vec4& b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a >= b[i]; }
return c;
}
inline int operator >= (const vec4& a, real b)
{
int c = 1;
for(int i = 0; i < 4;++i) { c = c && a[i] >= b; }
return c;
}
//| unary op : componentwise
inline vec4 operator - (const vec4& a)
{
vec4 c;
for(int i = 0; i < 4;++i) { c[i] = - a[i]; }
return c;
}
inline vec4 absolute(const vec4& val)
{
return vec4(fabs(val[0]), fabs(val[1]), fabs(val[2]), fabs(val[3]));
}
//| R^n -> R
inline real sum(const vec4& a)
{
real s = 0;
s += a[1 - 1];
s += a[2 - 1];
s += a[3 - 1];
s += a[4 - 1];
return s;
}
inline real inner(const vec4& a, const vec4& b)
{
vec4 tmp = a * b;
return sum(tmp);
}
inline real squaredNorm(const vec4& a) {
return inner(a, a);
}
inline real norm(const vec4& a)
{
return sqrt(inner(a, a));
}
inline vec4 unit(const vec4& a)
{
real n = norm(a);
if(n < epsilon)
return 0;
else
return a / n;
}
inline real angle(const vec4& a, const vec4& b)
{
real ang = inner(unit(a), unit(b));
if(ang > 1 - epsilon)
return 0;
else if(ang < -1 + epsilon)
return M_PI;
else
return acos(ang);
}
inline vec4 proj(const vec4& axis, const vec4& a)
{
vec4 u = unit(axis);
return inner(a, u) * u;
}
void store(FILE* fp, const vec4& v);
int scan(FILE* fp, const vec4& v);
int apx_equal(const vec4& a, const vec4& b);
int apx_equal(const vec4& a, const vec4& b, real eps);
vec3 cross(const vec3& a, const vec3& b);
}; //namespace graphics
#endif
|
8576c19d9d6c7cd5db468084eb40564c297c5419 | a6442784f6ef39e9ae0eb9a87d2d9e1a4a2a267a | /Proyects/App1Proyecto/src/Person.cpp | ef49b38122787038f1dad28d098793721374b6e4 | [] | no_license | ricardoaguillen/OMFG-I-AM-WAY-TO-DUMB-TO-HAVE-A-LOCAL-PROJECT | 2e373b6b6692540e799715b32142411949d95610 | e8085639b1c4ddd4b1d6551c55f40586608f47e9 | refs/heads/main | 2023-06-06T11:39:06.085608 | 2021-06-29T06:19:27 | 2021-06-29T06:19:27 | 380,423,208 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,386 | cpp | Person.cpp | //
// Created by Madera_Eonica on 25/6/2021.
//
#include "Person.h"
Person::Person() {
id = 0;
name = "";
phoneNumber = "";
email = "";
}
Person::Person(double id, const std::string &name, const std::string &phoneNumber, const std::string &email) :
id(id),name(name),phoneNumber(phoneNumber),email(email) {}
Person::~Person() {
}
double Person::getId() const {
return id;
}
void Person::setId(double id) {
Person::id = id;
}
const std::string &Person::getName() const {
return name;
}
void Person::setName(const std::string &name) {
Person::name = name;
}
const std::string &Person::getPhoneNumber() const {
return phoneNumber;
}
void Person::setPhoneNumber(const std::string &phoneNumber) {
Person::phoneNumber = phoneNumber;
}
const std::string &Person::getEmail() const {
return email;
}
void Person::setEmail(const std::string &email) {
Person::email = email;
}
std::string Person::toString() const{
std::stringstream tostringPerson;
tostringPerson.precision(20);
tostringPerson << "Id: " << getId() << std::fixed << std::endl;
tostringPerson << "Name: " << getName() << std::endl;
tostringPerson << "Phone Number: " << getPhoneNumber() << std::endl;
tostringPerson << "Email: " << getEmail() << std::endl;
return tostringPerson.str();
}
|
d0d791c5c22bd565143a75ef92b76179fc7d8acb | 36541500fcb52101577939e5f786fc056e0f43b6 | /proj_DataAndMC_multiplots_T2TR.cc | 4514b24a0eddf6d84475cef155d5060de7a80be0 | [] | no_license | cardaci/T2TopPlusPhoton | 5ebadfecac3e835b34bd8a3095f53c05922ddaee | 12c9ec1cc083fe5c73bc40878e2568df13f327ee | refs/heads/master | 2021-01-18T09:15:37.106612 | 2013-12-10T00:21:18 | 2013-12-10T00:21:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 20,177 | cc | proj_DataAndMC_multiplots_T2TR.cc | #include "TTree.h"
#include "TH1F.h"
#include "TH3D.h"
#include "TH2D.h"
#include "TFile.h"
#include "interface/format.h"
#include "interface/MCTruth.h"
#include "interface/TriggerBooking.h"
#include "interface/HitFitInfoBranches.h"
#include "interface/DPHI.h"
#include "interface/DR.h"
//#include "interface/samples_tr.h"
#include "interface/samples_tr_1lepton4jets.h"
//#include "interface/samples.h"
#include "interface/DRAWSTACK.h"
#include "interface/HistMerge.h"
#include "interface/checkEvt.h"
#include "interface/RecoLeptonSelection.h"
#include "interface/RecoPhotonSelection.h"
#include "interface/RecoJetSelection.h"
#include "interface/ReduceTree.h"
//#include "interface/TMVAClassification_CutsD.class.C"
#include "TChain.h"
#include "TNtuple.h"
#include "TLorentzVector.h"
#include "interface/RecoZbosonFordiPhoton.h"
#include <math.h>
#include <string>
#include <iostream>
#include "TCanvas.h"
#include "TROOT.h"
#include "TStyle.h"
#include "THStack.h"
#include "TLegend.h"
#include "stdlib.h"
#include <fstream>
#include <map>
#include <vector>
#include <time.h>
#include <math.h>
#include "interface/RecoZboson.h"
#include "interface/RecoMoflljj.h"
#include "interface/RecoMZb.h"
int RunStatus_ = Normal; // Normal, UncXsecPlus, UncXsecMinus, UncPUPlus, UncPUMinus
double Weight3D_[50][50][50];
enum plots_order{
_NOfVertexb4PU,
_NOfVertexafPU,
_Nj,
_Np,
_Ne,
_Nu,
_PhotonPt,
_JetPt,
_ElectronPt,
_MuonPt,
_ST,
_ST2p2j,
_ST2p2j1l,
_ST2p2j2l,
_MR2p2j,
_Mtstar,
_check,
_RT,
_Zmass,
_plots_order_size
};
struct plots_struct{
char PlotName[128];
char YaxisTitle_[128];
char XaxisTitle_[128];
char XUnit_[128];
int Ndivide_;
double XminBond_;
double XmaxBond_;
int rebin_;
};
struct plots_struct PLOTS[_plots_order_size] = {
{"_NOfVertexb4PU","Yields","N(Vertices)","-",30,0,30,1},
{"_NOfVertexafPU","Yields","N(Vertices)","-",30,0,30,1},
{"_Nj","Yields","N(jets)","-",11,0,11,1},
{"_Np","Yields","N(photons)","-",11,0,11,1},
{"_Ne","Yields","N(electrons)","-",11,0,11,1},
{"_Nu","Yields","N(muons)","-",11,0,11,1},
{"_PhotonPt","Yields","Photon Pt","GeV/c",200,0,200,5},
{"_JetPt","Yields","Jet Pt","GeV/c",200,0,200,5},
{"_ElectronPt","Yields","Electron Pt","GeV/c",200,0,200,5},
{"_MuonPt","Yields","Muon Pt","GeV/c",200,0,200,5},
{"_ST","Yields","ST","GeV/c",1800,200,2000,100},
{"_ST2p2j","Yields","ST(2#gamma+2j channel)","GeV/c",1500,0,3000,100},
{"_ST2p2j1l","Yields","ST(2#gamma+2j+1l channel)","GeV/c",1500,0,3000,100},
{"_ST2p2j2l","Yields","ST(2#gamma+2j+2l channel)","GeV/c",1500,0,3000,100},
{"_MR2p2j","Yields","MR(2#gamma+2j channel)","GeV/c^{2}",1500,0,3000,100},
{"_Mtstar","Yields","M(t*)","GeV/c^{2}",1000,0,2000,10},
{"_check","Yields","1","-",2,0,2,1},
{"_RT","Yields","RT","GeV/c",200,0,200,10},
{"_Zmass","Yields","M(l^{+}l^{-})","GeV/c^{2}",180,20,200,5}
};
/*
For Excited Quark :
(lepb_label+Wlep+gluon1_label) = (hadb_label+hadw1_label+hadw2_label+gluon2_label)
(11 + Wlep + 16 ) = (12 + 13 + 14 + 17)
*/
void analyze(int sample_idx,TH1F *ExcitedQuarkPlots[], TH2D *ExcitedQuark2DPlots, double weight_)
{
TChain *root = new TChain("bprimeKit/root");
root->Add(SAMPLE[sample_idx].filename);
EvtInfoBranches EvtInfo;
EvtInfo.Register(root);
GenInfoBranches GenInfo;
GenInfo.Register(root);
LepInfoBranches LepInfo;
LepInfo.Register(root,"PFLepInfo");
JetInfoBranches JetInfo;
JetInfo.Register(root,"PFJetInfo");
VertexInfoBranches VertexInfo;
VertexInfo.Register(root);
PhotonInfoBranches PhotonInfo;
PhotonInfo.Register(root);
ReduceTree(root);
double weight = weight_;
//for(int i=0;i<_plots_order_size;i++) ExcitedQuarkPlots[i]->Sumw2();
map< pair<int, int>, int > evtlist;
int nevents_total = root->GetEntries();
for(int entry=0;entry<root->GetEntries();entry++) {
if ((entry%10000) == 0) printf("Loading event #%d of %d.\n",entry,nevents_total);
root->GetEntry(entry);
// Trigger requirement -- start --
bool Trigee = false;
bool Trigmm = false;
bool Trigem = false;
char DATA_TAG[128] ="data";
if(!strcmp(SAMPLE[sample_idx].tag,DATA_TAG)){
//if(!EvtInfo.McFlag) {
//if(EvtInfo.RunNo>173692) continue; // 2180.3 /pb
//DoublePh
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v3]==1) Trigee = true;
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v4]==1) Trigee = true;
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v5]==1) Trigee = true;
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v6]==1) Trigee = true;
// remove duplicate event
map< pair<int, int> , int>::iterator evtitr;
evtitr = evtlist.find( pair<int, int>(EvtInfo.RunNo, EvtInfo.EvtNo) );
if( evtitr == evtlist.end() )
evtlist.insert( pair<pair<int, int>, int>(pair<int, int>(EvtInfo.RunNo, EvtInfo.EvtNo), 1));
else
continue;
// pick up good events according to golden json file
if(!isGoodEvt(EvtInfo.RunNo,EvtInfo.LumiNo)) continue;
}else{
// For MC
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v3]==1) Trigee = true;
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v4]==1) Trigee = true;
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v5]==1) Trigee = true;
if(EvtInfo.TrgBook[HLT_Photon36_CaloId10_Iso50_Photon22_CaloId10_Iso50_v6]==1) Trigee = true;
}
//if(!(Trigee||Trigmm||Trigem)) continue;
Trigee = true; // turn off HLT, since the samples are passing through single lepton trigger
if(!Trigee) continue;
// Trigger requirement -- end --
// Object selection -- start --
int NMuons = 0;
int NElectrons = 0;
int NLeptons = 0;
int NPhotons = 0;
int NJets = 0;
int M_Index[MAX_LEPTONS/2];
int E_Index[MAX_LEPTONS/2];
int L_Index[MAX_LEPTONS/2*2];
int P_Index[MAX_PHOTONS];
int J_Index[MAX_JETS];
for(int m=0;m<MAX_LEPTONS/2;m++) M_Index[m] = 0;
for(int e=0;e<MAX_LEPTONS/2;e++) E_Index[e] = 0;
for(int l=0;l<MAX_LEPTONS/2*2;l++) L_Index[l] = 0;
for(int p=0;p<MAX_PHOTONS;p++) P_Index[p] = 0;
for(int j=0;j<MAX_JETS;j++) J_Index[j] = 0;
RecoLeptonSelection(EvtInfo,LepInfo,NMuons,M_Index,NElectrons,E_Index,NLeptons,L_Index);
RecoPhotonSelection(LepInfo,PhotonInfo,NMuons,M_Index,NElectrons,E_Index,NPhotons,P_Index,EvtInfo.RhoPU[0]);
RecoJetSelection(LepInfo,JetInfo, PhotonInfo,NMuons,M_Index,NElectrons,E_Index,NJets,J_Index,NPhotons,P_Index);
if(!((NPhotons>=2)&&NJets>=2)) continue;
// Object selection -- end --
// number of vertex -- start --
int NOfVertex_=0;
int V_Index[50];
for(int v=0;v<50;v++) V_Index[v] = 0;
for(int j=0;j<VertexInfo.Size;j++) {
if(VertexInfo.isValid[j]!=1) continue;
if(VertexInfo.Type[j]!=0) continue;
if(VertexInfo.Ndof[j]<=4) continue;
if(fabs(VertexInfo.Rho[j])>=2) continue;
if(fabs(VertexInfo.z[j])>=24) continue;
V_Index[NOfVertex_] = j;
NOfVertex_++;
}
if(NOfVertex_<1) continue;
//if(strcmp(SAMPLE[sample_idx].tag,DATA_TAG)) weight = weight_*Weight3D_[EvtInfo.nPU[0]][EvtInfo.nPU[1]][EvtInfo.nPU[2]];
// number of vertex -- end --
double _Zmass_ = RecoZboson(LepInfo,NMuons,M_Index,NElectrons,E_Index);
ExcitedQuarkPlots[_NOfVertexb4PU]->Fill(NOfVertex_,weight_);
ExcitedQuarkPlots[_NOfVertexafPU]->Fill(NOfVertex_,weight);
double MassRecoZbosonFordiPhoton_ = RecoZbosonFordiPhoton(PhotonInfo,NPhotons,P_Index);
if(fabs(MassRecoZbosonFordiPhoton_-Z_MASS)<10) continue;
ExcitedQuarkPlots[_Nj]->Fill(NJets,weight);
ExcitedQuarkPlots[_Np]->Fill(NPhotons,weight);
ExcitedQuarkPlots[_Ne]->Fill(NElectrons,weight);
ExcitedQuarkPlots[_Nu]->Fill(NMuons,weight);
double _ST_ = 0.;
for(int j=0;j<NJets;j++) _ST_ += JetInfo.Pt[J_Index[j]];
for(int m=0;m<NMuons;m++) _ST_ += LepInfo.Pt[M_Index[m]];
for(int e=0;e<NElectrons;e++) _ST_ += LepInfo.Pt[E_Index[e]];
for(int p=0;p<NPhotons;p++) _ST_ += PhotonInfo.Pt[P_Index[p]];
ExcitedQuarkPlots[_ST]->Fill(_ST_,weight);
for(int j=0;j<NJets;j++) ExcitedQuarkPlots[_JetPt]->Fill(JetInfo.Pt[J_Index[j]],weight);
for(int p=0;p<NPhotons;p++) ExcitedQuarkPlots[_PhotonPt]->Fill(PhotonInfo.Pt[P_Index[p]],weight);
for(int e=0;e<NElectrons;e++) ExcitedQuarkPlots[_ElectronPt]->Fill(LepInfo.Pt[E_Index[e]],weight);
for(int m=0;m<NMuons;m++) ExcitedQuarkPlots[_MuonPt]->Fill(LepInfo.Pt[M_Index[m]],weight);
//if(NJets>=2&&NPhotons>=2) ExcitedQuarkPlots[_ST2p2j]->Fill(_ST_,weight);
if(NJets>=2&&NPhotons>=2&&(NMuons+NElectrons)==1) ExcitedQuarkPlots[_ST2p2j1l]->Fill(_ST_,weight);
if(NJets>=2&&NPhotons>=2&&(NMuons+NElectrons)>=2) ExcitedQuarkPlots[_ST2p2j2l]->Fill(_ST_,weight);
TLorentzVector photons[2];
photons[0].SetPtEtaPhiM(PhotonInfo.Pt[P_Index[0]],
PhotonInfo.Eta[P_Index[0]],
PhotonInfo.Phi[P_Index[0]],
0);
photons[1].SetPtEtaPhiM(PhotonInfo.Pt[P_Index[1]],
PhotonInfo.Eta[P_Index[1]],
PhotonInfo.Phi[P_Index[1]],
0);
//double MR_ = sqrt(pow(photons[0].E()+photons[1].E(),2)-pow(photons[0].Pz()+photons[1].Pz(),2));
double MR_ = 0.0;
MR_ = sqrt(pow(photons[0].E()+photons[1].E(),2)-pow(photons[0].Pz()+photons[1].Pz(),2));
if(NJets>=2&&NPhotons==2){
ExcitedQuarkPlots[_check]->Fill(1.0,weight);
ExcitedQuarkPlots[_MR2p2j]->Fill(MR_,weight);
ExcitedQuarkPlots[_ST2p2j]->Fill(_ST_,weight);
ExcitedQuarkPlots[_Mtstar]->Fill(0.5*(MR_+sqrt(MR_*MR_+4*top_MASS*top_MASS)),weight);
}
double _RT_ = _ST_ - JetInfo.Pt[J_Index[0]] - JetInfo.Pt[J_Index[1]] - LepInfo.Pt[L_Index[0]] - LepInfo.Pt[L_Index[1]];
ExcitedQuarkPlots[_RT]->Fill(_RT_,weight);
//double _Zmass_ = RecoZboson(LepInfo,NMuons,M_Index,NElectrons,E_Index);
ExcitedQuarkPlots[_Zmass]->Fill(_Zmass_,weight);
}
root->Delete();
}
void integralWithCut(TH1F *h1,double cut){
double leftNumber = 0;
double rightNumber = 0;
for(int i=0;i<h1->GetXaxis()->GetNbins();i++){
if(h1->GetXaxis()->GetBinCenter(i)<cut){
leftNumber += h1->GetBinContent(i);
}else{
rightNumber += h1->GetBinContent(i);
}
}
std::cout<<"cut ( "<<cut<<" ) , rightNumber : "<<rightNumber<<" , leftNumber : "<<leftNumber<<std::endl;
}
void proj_DataAndMC_multiplots_T2TR(){
double time1,time2,time3; time1=time(NULL);
TFile *PUFile;
switch(RunStatus_){
case UncPUPlus:
PUFile = new TFile("interface/Weight3DPlus.root");
break;
case UncPUMinus:
PUFile = new TFile("interface/Weight3DMinus.root");
break;
default :
PUFile = new TFile("interface/Weight3D.root");
break;
}
TH3D *PUReweight_ = (TH3D*) PUFile->Get("WHist");
for(int i=0;i<50;i++)
for(int j=0;j<50;j++)
for(int k=0;k<50;k++) Weight3D_[i][j][k] = (double)PUReweight_->GetBinContent(i+1,j+1,k+1);
gROOT->ProcessLine(".L interface/setTDRStyle.C");
gROOT->ProcessLine("setTDRStyle()");
gStyle->SetErrorX(0.5);
string jsonfile = "interface/final_SingleLepton_193752-208686.json";
MakeJsonMap(jsonfile);
double weight[samples_order_size];
for(int i=0;i<samples_order_size;i++) {
switch(RunStatus_){
case UncXsecPlus:
weight[i] = (1+SAMPLE[i].unc)*(SAMPLE[i].xsec*LUMINOSITY)/(SAMPLE[i].ngen);
break;
case UncXsecMinus:
weight[i] = (1-SAMPLE[i].unc)*(SAMPLE[i].xsec*LUMINOSITY)/(SAMPLE[i].ngen);
break;
default:
weight[i] = (SAMPLE[i].xsec*LUMINOSITY)/(SAMPLE[i].ngen);
break;
}
}
// histograms
const int Nmerge = 5;
char buffer_1[128];
TH1F *ExcitedQuarkPlots[samples_order_size][_plots_order_size];
TH1F *ExcitedQuarkPlotsSwap[_plots_order_size][samples_order_size];
TH1F *ExcitedQuarkPlotsMerge[_plots_order_size][Nmerge];
TH2D *ExcitedQuark2DPlots[samples_order_size];
TCanvas *c[_plots_order_size];
TLegend *legend_nm[_plots_order_size];
THStack *Stacks1[_plots_order_size];
THStack *Stacks1_[_plots_order_size];
for(int i =0;i<_plots_order_size;i++) {
sprintf(buffer_1,"c%i",i);
c[i]= new TCanvas(buffer_1,"",640,640);
sprintf(buffer_1,"Stacks1_%i",i);
Stacks1[i] = new THStack(buffer_1,"");
sprintf(buffer_1,"Stacks1_%i_",i);
Stacks1_[i] = new THStack(buffer_1,"");
}
for(int i=0;i<samples_order_size;i++) {
//if(i==Data) continue;
//if(i==TTJets_MassiveBinDECAY_TuneZ2star_8TeV_madgraph_tauola_Summer12_DR53X_PU_S10_START53_V7A_v1) continue;
std::cout<<"file : "<<SAMPLE[i].tag<<std::endl;
for(int j=0;j<_plots_order_size;j++) {
sprintf(buffer_1,"ExcitedQuarkPlots_%i_%i",i,j);
ExcitedQuarkPlots[i][j] = new TH1F(buffer_1,"",PLOTS[j].Ndivide_,PLOTS[j].XminBond_,PLOTS[j].XmaxBond_);
}
sprintf(buffer_1,"ExcitedQuark2DPlots_%i",i);
ExcitedQuark2DPlots[i] = new TH2D(buffer_1,"",
//PLOTS[_fisherResponse].Ndivide_,PLOTS[_fisherResponse].XminBond_,PLOTS[_fisherResponse].XmaxBond_,
PLOTS[_ST].Ndivide_,PLOTS[_ST].XminBond_,PLOTS[_ST].XmaxBond_,
PLOTS[_ST].Ndivide_,
PLOTS[_ST].XminBond_,PLOTS[_ST].XmaxBond_);
analyze(i, ExcitedQuarkPlots[i], ExcitedQuark2DPlots[i] , weight[i]);
}
for(int i=0;i<_plots_order_size;i++) {
for(int j=0;j<samples_order_size;j++) {
ExcitedQuarkPlotsSwap[i][j] = (TH1F*) ExcitedQuarkPlots[j][i]->Clone();
}
}
for(int i=0;i<_plots_order_size;i++) {
for(int j=0;j<Nmerge;j++) {
sprintf(buffer_1,"ExcitedQuarkPlotsMerge_%i_%i",i,j);
ExcitedQuarkPlotsMerge[i][j] = new TH1F(buffer_1,"",PLOTS[i].Ndivide_,PLOTS[i].XminBond_,PLOTS[i].XmaxBond_);
}
}
// For templates -- start --
// templates for limit
int template_indx = _Mtstar; // default = _ExcitedQuarkMass, test : _MR , _leading1jet, _leading2jets, _MfromMR
sprintf(buffer_1,"hData%s",RunStatusNames[RunStatus_].c_str());
TH1F *hData = new TH1F(buffer_1,"",
PLOTS[template_indx].Ndivide_,PLOTS[template_indx].XminBond_,PLOTS[template_indx].XmaxBond_);
sprintf(buffer_1,"hSigMC_500%s",RunStatusNames[RunStatus_].c_str());
TH1F *hSigMC_500 = new TH1F(buffer_1,"",
PLOTS[template_indx].Ndivide_,PLOTS[template_indx].XminBond_,PLOTS[template_indx].XmaxBond_);
sprintf(buffer_1,"hSigMC_400%s",RunStatusNames[RunStatus_].c_str());
TH1F *hSigMC_400 = new TH1F(buffer_1,"",
PLOTS[template_indx].Ndivide_,PLOTS[template_indx].XminBond_,PLOTS[template_indx].XmaxBond_);
sprintf(buffer_1,"hMCBG%s",RunStatusNames[RunStatus_].c_str());
TH1F *hMCBG = new TH1F(buffer_1,"",
PLOTS[template_indx].Ndivide_,PLOTS[template_indx].XminBond_,PLOTS[template_indx].XmaxBond_);
hData->Add(ExcitedQuarkPlots[Data][template_indx]);
hSigMC_500->Add(ExcitedQuarkPlots[Tgamma800GeV][template_indx]);
hSigMC_400->Add(ExcitedQuarkPlots[Tgamma800GeV][template_indx]);
for(int i= QCD_Pt_15to30_TuneZ2star_8TeV_pythia6_Summer12_DR53X_PU_S10_START53_V7A_v2;
i<=TTZJets_8TeV_madgraph_v2_Summer12_DR53X_PU_S10_START53_V7A_v1;i++)
hMCBG->Add(ExcitedQuarkPlots[i][template_indx]);
hData->Rebin(PLOTS[template_indx].rebin_);
hSigMC_500->Rebin(PLOTS[template_indx].rebin_);
hSigMC_400->Rebin(PLOTS[template_indx].rebin_);
hMCBG->Rebin(PLOTS[template_indx].rebin_);
std::cout<<"---------------------------------------"<<std::endl;
std::cout<<"hData : "; integralWithCut(hData,0);
std::cout<<"hMCBG : "; integralWithCut(hMCBG,0);
std::cout<<"hSigMC_400 : "; integralWithCut(hSigMC_400,0);
std::cout<<"hSigMC_500 : "; integralWithCut(hSigMC_500,0);
std::cout<<"---------------------------------------"<<std::endl;
/*
for(int i=0;i<samples_order_size;i++)
std::cout<<SAMPLE[i].tag<<" : "<<ExcitedQuarkPlots[i][template_indx]->Integral() <<" ( "<<weight[i]<<" )"<<std::endl;
std::cout<<"---------------------------------------"<<std::endl;
for(int i=0;i<samples_order_size;i++)
std::cout<<SAMPLE[i].tag<<" : "<<ExcitedQuarkPlots[i][_NOfVertexb4PU]->Integral() <<" ( "<<weight[i]<<" )"<<std::endl;
std::cout<<"---------------------------------------"<<std::endl;
*/
for(int i=0;i<samples_order_size;i++)
std::cout<<SAMPLE[i].tag<<" : "<<ExcitedQuarkPlots[i][_ST2p2j]->Integral() <<" ( "<<weight[i]<<" )"<<std::endl;
std::cout<<"---------------------------------------"<<std::endl;
for(int i=0;i<samples_order_size;i++)
std::cout<<SAMPLE[i].tag<<" : "<<ExcitedQuarkPlots[i][_MR2p2j]->Integral() <<" ( "<<weight[i]<<" )"<<std::endl;
std::cout<<"---------------------------------------"<<std::endl;
for(int i=0;i<samples_order_size;i++)
std::cout<<SAMPLE[i].tag<<" : "<<ExcitedQuarkPlots[i][_check]->Integral() <<" ( "<<weight[i]<<" )"<<std::endl;
std::cout<<"---------------------------------------"<<std::endl;
hData->SaveAs("templates/hData.root");
sprintf(buffer_1,"templates/hSigMC_500%s.root",RunStatusNames[RunStatus_].c_str());
hSigMC_500->SaveAs(buffer_1);
sprintf(buffer_1,"templates/hSigMC_400%s.root",RunStatusNames[RunStatus_].c_str());
hSigMC_400->SaveAs(buffer_1);
sprintf(buffer_1,"templates/hMCBG%s.root",RunStatusNames[RunStatus_].c_str());
hMCBG->SaveAs(buffer_1);
// For templates -- end --
for(int i =0;i<_plots_order_size;i++) {
c[i]->cd();
HistMerge(ExcitedQuarkPlotsSwap[i], ExcitedQuarkPlotsMerge[i]);
DRAWSTACK(Stacks1[i],
ExcitedQuarkPlotsMerge[i],
ExcitedQuarkPlots[Tgamma800GeV][i],
ExcitedQuarkPlots[Data][i],
legend_nm[i],
PLOTS[i].YaxisTitle_,PLOTS[i].XaxisTitle_,PLOTS[i].XUnit_, PLOTS[i].rebin_);
//sprintf(buffer_1,"PLOTS/%s_400GeV.pdf",PLOTS[i].PlotName);
sprintf(buffer_1,"PLOTS/%s.root",PLOTS[i].PlotName);
//sprintf(buffer_1,"PLOTS/%s.pdf",PLOTS[i].PlotName);
c[i]->SaveAs(buffer_1);
}
TCanvas *checkpdf = new TCanvas("checkpdf","",640,640);
checkpdf->cd();
for(int i =0;i<_plots_order_size;i++) {
DRAWSTACK(Stacks1_[i],
ExcitedQuarkPlotsMerge[i],
ExcitedQuarkPlots[Tgamma800GeV][i],
ExcitedQuarkPlots[Data][i],
legend_nm[i],
PLOTS[i].YaxisTitle_,PLOTS[i].XaxisTitle_,PLOTS[i].XUnit_, 1);
if(_plots_order_size!=1){
if(i==0){
checkpdf->Print("checkpdf.pdf(");
}else if(i==_plots_order_size-1){
checkpdf->Print("checkpdf.pdf)");
}else{
checkpdf->Print("checkpdf.pdf");
}
}else{
checkpdf->Print("checkpdf.pdf");
}
}
delete checkpdf;
time2=time(NULL); time3=time2-time1; cout<<"---- Spending time : " << (time3/60.0) <<" (mins) ----"<<endl;
std::cout<<"done "<<std::endl;
}
|
c9d52701375ca8274bb852945e47c51fe236299d | 8f864d034a666ae46d7ccf8b31b6adc3dd4acb4c | /PiggyBreaker/BallColor.cpp | 0a354c7eee9799a49b71d8de3102dc4172c36148 | [] | no_license | guyllaumedemers/SDL-Piggybreaker | efe982ecfe91770ad3e2ed1fe72f71ec3ef0e48a | b15aece2c8fb16b743fb5f2cb325813e6e24778b | refs/heads/master | 2023-05-31T02:17:15.515754 | 2021-06-16T13:31:45 | 2021-06-16T13:31:45 | 367,116,980 | 0 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 811 | cpp | BallColor.cpp | #include "BallColor.h"
Color BallColor::getColor(ballColors color)
{
Color ballColor{ 0,0,0,0 };
switch (color) {
case BallColor::ballColors::RED:
ballColor = Color(255, 0, 0, SDL_ALPHA_OPAQUE);
break;
case BallColor::ballColors::GREEN:
ballColor = Color(0, 255, 0, SDL_ALPHA_OPAQUE);
break;
case BallColor::ballColors::BLUE:
ballColor = Color(0, 0, 255, SDL_ALPHA_OPAQUE);
break;
case BallColor::ballColors::YELLOW:
ballColor = Color(255, 255, 0, SDL_ALPHA_OPAQUE);
break;
case BallColor::ballColors::ORANGE:
ballColor = Color(255, 150, 0, SDL_ALPHA_OPAQUE);
break;
case BallColor::ballColors::PINK:
ballColor = Color(255, 0, 255, SDL_ALPHA_OPAQUE);
break;
case BallColor::ballColors::AQUA:
ballColor = Color(0, 255, 255, SDL_ALPHA_OPAQUE);
break;
}
return ballColor;
}
|
e34d4588cb502f4b45e7827de2283ebc41999cf3 | 4bdbcca97afe9cfbab0247164580f6f05f6f885f | /tables.h | c8f46fc719653ad8d8bed61fe451e50dd9e9c69b | [] | no_license | yanwumo/DistributedWanderJoin | c080407338df423d4ebb7446218318b4fc370fbf | 16149c153b896bbbc234279171c47d5209920cd4 | refs/heads/master | 2021-10-21T02:11:20.488491 | 2018-05-08T06:22:46 | 2018-05-08T06:22:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,030 | h | tables.h | //
// Created by yanwumo on 4/28/18.
//
#ifndef DISTRIBUTEDWANDERJOIN_TABLES_H
#define DISTRIBUTEDWANDERJOIN_TABLES_H
#include <vector>
#include <unordered_map>
#include <fstream>
#include <random>
#include <chrono>
#include "entries.h"
#include "index.h"
template <class T>
class BaseTable {
private:
std::mt19937 randomNumberGenerator;
protected:
std::vector<T> table;
public:
BaseTable() {
auto seed = std::chrono::system_clock::now().time_since_epoch().count();
randomNumberGenerator.seed(static_cast<unsigned int>(seed));
}
size_t size() {
return table.size();
}
size_t getRandomNumberOfSize(const size_t &size) {
std::uniform_int_distribution<size_t> distribution(0, size - 1);
return distribution(randomNumberGenerator);
}
void fromStream(std::ifstream &fin) {
std::string line;
while (getline(fin, line)) {
table.emplace_back(line);
}
}
T *sampleFromAllEntries() {
return &table[getRandomNumberOfSize(table.size())];
}
};
class RegionTable : public BaseTable<Region> {
};
class NationTable : public BaseTable<Nation> {
};
class SupplierTable : public BaseTable<Supplier> {
};
class PartsuppTable : public BaseTable<Partsupp> {
};
class CustomerTable : public BaseTable<Customer> {
public:
PrimaryKey<uint32_t, Customer> indexCustkey;
SecondaryIndex<uint32_t, Customer> indexNationkey;
SecondaryIndex<std::string, Customer> indexMktsegment;
void buildPrimaryKey();
void buildSecondaryIndexes();
};
class OrdersTable : public BaseTable<Orders> {
public:
PrimaryKey<uint32_t, Orders> indexOrderkey;
SecondaryIndex<uint32_t, Orders> indexCustkey;
void buildPrimaryKey();
void buildSecondaryIndexes();
};
class LineitemTable : public BaseTable<Lineitem> {
public:
SecondaryIndex<uint32_t, Lineitem> indexOrderkey;
void buildSecondaryIndexes();
};
class PartTable : public BaseTable<Part> {
};
#endif //DISTRIBUTEDWANDERJOIN_TABLES_H
|
abef0c06e6573ed9e7821c684005260982f53844 | 80cf3b9bf777ec3d966c1691b3481ea6fc0eb146 | /src/butil/bind_helpers.cc | 487f29177644730391380bc50961acf3a861b634 | [
"Apache-2.0"
] | permissive | nlln/brpc | be55ecb7771dd3a0359e40f8e05006b286cb6471 | ee377b5daa7d9fa41abb26958b9cfb3bde9268aa | refs/heads/master | 2021-06-28T13:53:28.192395 | 2017-09-14T11:18:54 | 2017-09-14T11:18:54 | 103,529,488 | 1 | 0 | null | 2017-09-14T12:29:35 | 2017-09-14T12:29:35 | null | UTF-8 | C++ | false | false | 295 | cc | bind_helpers.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 "butil/bind_helpers.h"
#include "butil/callback.h"
namespace butil {
void DoNothing() {
}
} // namespace butil
|
3e745f97e9d38b29a3272a22f37056a86cdc85ea | 10267622c1b67a81d7dc8f34a63641c8bb5f92e6 | /include/OCarray+Printer.hh | e8c955e9dc3e65be8f2f33885dee68b5c68c1915 | [
"Apache-2.0"
] | permissive | applesnake/OCX | edb660bc87839b6702884b5aed501775157d1c84 | 8dad54e26f72cd1bedd947b02cc5774584feab61 | refs/heads/master | 2020-05-20T12:27:54.801653 | 2016-11-13T07:22:43 | 2016-11-13T07:22:43 | 70,272,764 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 129 | hh | OCarray+Printer.hh | #pragma once
#import "OCarray.hh"
@interface OCarray (Printer)
-(void) print;
-(void) printWithSeperator:(const char*)sp;
@end
|
c98abf6b7e4ca8669d2fb18b5f08774ce4d8ae91 | 13894c5eb473f4c03886a3f8883ed8c04f818620 | /ListsAndMergeSort/IntList.cpp | c2eefe3e08c6f8030db7f90cecba024d817968b5 | [] | no_license | shawnq8861/Data-Structures | fecd9c9f1f783c123fa29ad103472d7a78a0dc16 | f0e261dca5b4cd02923aa3f39aa1f3e335ee33f4 | refs/heads/master | 2021-01-20T22:22:25.791891 | 2016-06-07T17:34:08 | 2016-06-07T17:34:08 | 60,544,087 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,669 | cpp | IntList.cpp | /*****************************************************************************
*
* file IntList.cpp
* the implementation file for the IntList class
*
* Shawn Quinn
* quinnms1
* 11/08/2014
*
****************************************************************************/
#include "IntList.h"
/*****************************************************************************
* constructor
*
* initialize head, tail and numItems
*
****************************************************************************/
IntList::IntList() : head(nullptr), tail(nullptr), numItems(0)
{
}
/*****************************************************************************
* destructor
*
* call method emptyList to free all allocated memory
*
****************************************************************************/
IntList::~IntList()
{
emptyList();
}
/*****************************************************************************
* public method add
*
* create a new Node
* - initialize the data member to the argument passed in
* - initialize the next member to nullptr
* - if the list is empty, set head and tail to new node
* - otherwise, set the next member of the tail to the new node
* - and then set the tail to the new node
*
****************************************************************************/
void IntList::add(int item)
{
Node* tempNode = new Node;
tempNode->data = item;
tempNode->next = nullptr;
if(numItems == 0)
{
head = tempNode;
tail = head;
head->next = tail;
}
else
{
tail->next = tempNode;
tail = tempNode;
}
++numItems;
}
/*****************************************************************************
* public method insert
*
* - check whether the item number is in the list or at the end of the list
* - create a new Node, set data member to itemVal
* - traverse the list to the item just prior to the item number to be
* inserted
* - set the next member of the new node to the next member of the node prior
* to the insertion location
* - set the next member of the node prior to the insertion point to the
* new node
* - check for special cases: insert head, node after nead, or tail
*
****************************************************************************/
void IntList::insert(int itemNum, int itemVal)
{
if(((1 + getNumItems()) >= itemNum) && itemNum > 0)
{
Node* insNode = new Node;
insNode->data = itemVal;
insNode->next = nullptr;
if(itemNum == 1) // insert head node
{
if(numItems == 0) // empty list
{
head = insNode;
tail = head;
head->next = tail;
}
else if(numItems == 1)
{
insNode->next = head;
tail = head; // assign tail node
tail->next = nullptr;
head = insNode; // reassign head node
}
else
{
insNode->next = head;
head = insNode; // reassign head node
}
}
else if(itemNum == 2) // insert node after head node
{
if(numItems == 1) // head node is only node
{
head->next = insNode;
tail = insNode; // assign tail
tail->next = nullptr;
}
else
{
insNode->next = head->next;
head->next = insNode;
}
}
else
{
Node* iterNode = head; // start at head node
for(int i = 1; i < itemNum - 1; i++)
{
iterNode = iterNode->next; // point to next node
}
// iterNode now points to node prior to insertion point
if(itemNum == numItems + 1) // check if end of list
{
iterNode->next = insNode;
tail = insNode; // reassign tail
}
else
{
insNode->next = iterNode->next;
iterNode->next = insNode;
}
}
++numItems;
}
else
{
cout << "item number not in list..." << endl;
}
}
/*****************************************************************************
* public method remove
*
* - check whether the item number is in the list
* - create a temporary local node variable to be used for traversal
* - traverse the list to the item just prior to the item number to be deleted
* - set the next member of the temp node to one node after the next member
* - delete the node just after the temporary node
* - set the deleted node to nullptr
* - check for special cases: deleting head, node after nead, or tail
*
****************************************************************************/
void IntList::remove(int itemNum)
{
if((getNumItems() >= itemNum) && itemNum > 0)
{
if(itemNum == 1) // remove head node
{
Node* iterNode = head; // point to node to delete
if(tail == head)
{
delete iterNode;
iterNode = nullptr;
head = nullptr;
tail = nullptr;
}
else
{
head = head->next; // reassign head node
delete iterNode;
iterNode = nullptr;
}
}
else if(itemNum == 2) // remove node after head node
{
Node* iterNode = head->next; // point to node to delete
if(iterNode == tail)
{
tail = head;
head->next = nullptr;
}
else
{
head->next = iterNode->next;
delete iterNode;
iterNode = nullptr;
}
}
else
{
Node* iterNode = head; // start at head node
for(int i = 1; i < itemNum - 1; i++)
{
iterNode = iterNode->next; // point to next node
}
// iterNode points to the item prior to the item to delete
if(tail == iterNode->next)
{
// deleting tail, move tail up one spot
tail = iterNode;
iterNode = iterNode->next;
delete iterNode;
iterNode = nullptr;
}
else
{
// iterNode->next is the item to delete
Node* delNode = iterNode->next;
iterNode->next = delNode->next;
delete delNode;
delNode = nullptr;
}
}
--numItems;
}
else
{
cout << "item number not in list..." << endl;
}
}
/*****************************************************************************
* public method emptyList
*
* call the remove method on the head item until the list is empty
*
****************************************************************************/
void IntList::emptyList(void)
{
while(getNumItems() > 0)
{
remove(1); // remove the head item until list empty
}
}
/*****************************************************************************
* public method printList
*
* print the items in the list in order
*
****************************************************************************/
void IntList::printList(void)
{
cout << endl << "printing the list ..." << endl << endl;
Node* tempNode = head;
for(int i = 1; i <= getNumItems(); i++)
{
cout << "item number " << i << " = " << tempNode->data << endl;
tempNode = tempNode->next;
}
}
/*****************************************************************************
* public method getNumItems
*
* return the number of items in the list
*
****************************************************************************/
const int IntList::getNumItems(void) const
{
return numItems;
}
/*****************************************************************************
* public method getItemVal
*
* return the data value of the item at itemNum
*
****************************************************************************/
int IntList::getItemVal(int itemNum) const
{
Node* tempNode = head;
for(int i = 1; i < itemNum; i++)
{
tempNode = tempNode->next;
}
return tempNode->data;
}
/*****************************************************************************
* public method operator=
*
* - clear the list by calling emptyList
* - add each item from the right hand list one at a time by calling add
* - return the new list
*
****************************************************************************/
IntList& IntList::operator=(IntList& rhsList)
{
emptyList();
for(int i = 1; i <= rhsList.getNumItems(); i++)
{
add(rhsList.getItemVal(i));
}
return *this;
}
/*****************************************************************************
* public method mergeSort
*
* - create a temporary IntList to hold values during sorting
* - create 2 temporary Node pointers to allow accessing small sublists
* of the larger list that is being sorted
* - start with the smallest sublist possible, size == 1
* - at the beginning of each pass through the list, intialize one node
* pointer to the head of the list, and the other to the list immediately
* after the first sublist
* - compare values in each list, adding smaller values first to the
* temporary list
* - increment number of merges for each sublist merged
* - after each pass through the list, doble the size of the sublist
* and repeat the sublist merge step
* - continue looping until the number of merges after a merge loop is 1
*
****************************************************************************/
void IntList::mergeSort(void)
{
Node* p; // create temporary nodes
Node* q; // for use in sorting
IntList T; // create a empty temporary list
int k = 1; // initial size of sublist
int psize = 0;
int qsize = 0;
int numMerges = 0; // initialize number of merges to zero
while(numMerges != 1) // repeat until number of merges equals 1
{
p = head;
numMerges = 0;
while(p != nullptr) // while p != NULL do
{
++numMerges; // keep track of number of merges
q = p;
int i = 0;
// Step q along the list k items (or until end of list)
while(i < k && q != tail)
{
q = q->next;
i++;
}
psize = i; // Set psize to actual number of items skipped
qsize = k; // qsize = k {Merge a list of length psize, starting
// merge step, loop through sublists, adding values to T in order
while(psize > 0 || (qsize > 0 && q != nullptr))
{
if(qsize == 0 || q == nullptr) //if q is empty, add p
{
T.add(p->data);
p = p->next;
--psize; // keep track of added items
}
else if(psize == 0) // if p is empty, add q
{
T.add(q->data);
q = q->next;
--qsize;
}
else // otherwise, compare and add smaller value
{
if(p->data < q->data)
{
T.add(p->data);
p = p->next;
--psize;
}
else
{
T.add(q->data);
q = q->next;
--qsize;
}
}
}
p = q; // point to next list
}// end while
*this = T;
T.emptyList();
k = k * 2;
}// until number of merges equals 1
} |
12bc714affa74453f636ea42721b48ec23dc1153 | 4bab98acf65c4625a8b3c757327a8a386f90dd32 | /ros2-windows/include/trajectory_msgs/msg/dds_connext/JointTrajectoryPoint_.h | 513b6904041582d2c010698b258684ccb47ebf37 | [] | no_license | maojoejoe/Peach-Thinning-GTRI-Agricultural-Robotics-VIP | e2afb08b8d7b3ac075e071e063229f76b25f883a | 8ed707edb72692698f270317113eb215b57ae9f9 | refs/heads/master | 2023-01-15T06:00:22.844468 | 2020-11-25T04:16:15 | 2020-11-25T04:16:15 | 289,108,482 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,928 | h | JointTrajectoryPoint_.h |
/*
WARNING: THIS FILE IS AUTO-GENERATED. DO NOT MODIFY.
This file was generated from JointTrajectoryPoint_.idl using "rtiddsgen".
The rtiddsgen tool is part of the RTI Connext distribution.
For more information, type 'rtiddsgen -help' at a command shell
or consult the RTI Connext manual.
*/
#ifndef JointTrajectoryPoint__177430957_h
#define JointTrajectoryPoint__177430957_h
#ifndef NDDS_STANDALONE_TYPE
#ifndef ndds_cpp_h
#include "ndds/ndds_cpp.h"
#endif
#else
#include "ndds_standalone_type.h"
#endif
#include "builtin_interfaces/msg/dds_connext/Duration_.h"
namespace trajectory_msgs {
namespace msg {
namespace dds_ {
extern const char *JointTrajectoryPoint_TYPENAME;
struct JointTrajectoryPoint_Seq;
#ifndef NDDS_STANDALONE_TYPE
class JointTrajectoryPoint_TypeSupport;
class JointTrajectoryPoint_DataWriter;
class JointTrajectoryPoint_DataReader;
#endif
class JointTrajectoryPoint_
{
public:
typedef struct JointTrajectoryPoint_Seq Seq;
#ifndef NDDS_STANDALONE_TYPE
typedef JointTrajectoryPoint_TypeSupport TypeSupport;
typedef JointTrajectoryPoint_DataWriter DataWriter;
typedef JointTrajectoryPoint_DataReader DataReader;
#endif
DDS_DoubleSeq positions_ ;
DDS_DoubleSeq velocities_ ;
DDS_DoubleSeq accelerations_ ;
DDS_DoubleSeq effort_ ;
builtin_interfaces::msg::dds_::Duration_ time_from_start_ ;
};
#if (defined(RTI_WIN32) || defined (RTI_WINCE)) && defined(NDDS_USER_DLL_EXPORT_trajectory_msgs)
/* If the code is building on Windows, start exporting symbols.
*/
#undef NDDSUSERDllExport
#define NDDSUSERDllExport __declspec(dllexport)
#endif
NDDSUSERDllExport DDS_TypeCode* JointTrajectoryPoint__get_typecode(void); /* Type code */
DDS_SEQUENCE(JointTrajectoryPoint_Seq, JointTrajectoryPoint_);
NDDSUSERDllExport
RTIBool JointTrajectoryPoint__initialize(
JointTrajectoryPoint_* self);
NDDSUSERDllExport
RTIBool JointTrajectoryPoint__initialize_ex(
JointTrajectoryPoint_* self,RTIBool allocatePointers,RTIBool allocateMemory);
NDDSUSERDllExport
RTIBool JointTrajectoryPoint__initialize_w_params(
JointTrajectoryPoint_* self,
const struct DDS_TypeAllocationParams_t * allocParams);
NDDSUSERDllExport
void JointTrajectoryPoint__finalize(
JointTrajectoryPoint_* self);
NDDSUSERDllExport
void JointTrajectoryPoint__finalize_ex(
JointTrajectoryPoint_* self,RTIBool deletePointers);
NDDSUSERDllExport
void JointTrajectoryPoint__finalize_w_params(
JointTrajectoryPoint_* self,
const struct DDS_TypeDeallocationParams_t * deallocParams);
NDDSUSERDllExport
void JointTrajectoryPoint__finalize_optional_members(
JointTrajectoryPoint_* self, RTIBool deletePointers);
NDDSUSERDllExport
RTIBool JointTrajectoryPoint__copy(
JointTrajectoryPoint_* dst,
const JointTrajectoryPoint_* src);
#if (defined(RTI_WIN32) || defined (RTI_WINCE)) && defined(NDDS_USER_DLL_EXPORT_trajectory_msgs)
/* If the code is building on Windows, stop exporting symbols.
*/
#undef NDDSUSERDllExport
#define NDDSUSERDllExport
#endif
} /* namespace dds_ */
} /* namespace msg */
} /* namespace trajectory_msgs */
#endif /* JointTrajectoryPoint_ */
|
0b627d4d4002946236ed3f4bccd098bf1bbbbd54 | 51c728f93657b01bfbc8dcba44235d4ded97feea | /src/shaders/shading.h | d8be748bc498adbda8a49a89070cde4848d936d1 | [
"MIT"
] | permissive | bdkamenov/raytracer | 607e09f6fdb517b2ac35f6f30980dbfc1f952321 | be7915f5f448c43b4977103f45182814810e62f0 | refs/heads/master | 2020-07-01T09:18:38.340924 | 2019-10-21T19:58:19 | 2019-10-21T19:58:19 | 201,124,515 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,364 | h | shading.h | /**
* @File shading.h
* @Brief Contains declarations of shader classes
*/
#ifndef __SHADING_H__
#define __SHADING_H__
#include "maths/ray.h"
#include "geometries/geometry.h"
#include "color/color.h"
#include "materials/bitmap.h"
class Texture
{
public:
virtual ~Texture() = default;
virtual Color sample(const IntersectionInfo& info) = 0;
};
class CheckerTexture: public Texture
{
public:
CheckerTexture(const Color& c1, const Color& c2, size_t size = 1): color1_(c1), color2_(c2), scaling_(size) {}
~CheckerTexture() override = default;
Color sample(const IntersectionInfo& info) override;
private:
Color color1_;
Color color2_;
size_t scaling_;
};
class BitmapTexture: public Texture
{
public:
BitmapTexture(const std::string& filename, double scaling = 1.0);
~BitmapTexture() = default;
Color sample(const IntersectionInfo& info) override;
private:
std::unique_ptr<Bitmap> bitmap_;
double scaling_;
};
class Shader
{
public:
virtual ~Shader() = default;
virtual Color shade(const Ray& ray, IntersectionInfo& info) = 0;
};
class Lambert : public Shader
{
public:
Lambert(const Color& color = {0.f, 0.f, 0.f}, std::unique_ptr<Texture> texture = nullptr)
: color_(color)
, texture_(std::move(texture))
{}
~Lambert() override = default;
Color shade(const Ray& ray, IntersectionInfo& info) override;
private:
Color color_; // used if the texture is null
std::unique_ptr<Texture> texture_;
};
class Phong : public Shader
{
public:
Phong(double a, double b, const Color& color = {0.f, 0.f, 0.f}, std::unique_ptr<Texture> texture = nullptr)
: specularMultiplier_(a)
, specularExponent_(b)
, color_(color)
, texture_(std::move(texture)) {}
~Phong() override = default;
Color shade(const Ray& ray, IntersectionInfo& info) override;
double specularMultiplier_; // defines how bright the flashes will be
double specularExponent_; // defines how fine the flashes will be
private:
Color color_; // used if the texture is null
std::unique_ptr<Texture> texture_;
};
struct Node
{
//Node(std::unique_ptr<Geometry> geometry, std::unique_ptr<Shader> shader): geometry_(geometry.get()), shader_(shader.get()) {}
std::unique_ptr<Geometry> geometry_;
std::unique_ptr<Shader> shader_;
};
#endif // __SHADING_H__
|
37e3bd7756d65b13766a4aab3c80dbedfe533c4a | 799d21efc423e5b8ea223afcf43a0ee67aa6bdbd | /client/includes/components/__BASIC_COMPONENT__.HPP | 1d7815bab72e1fe1aacdd57aa923056ec062ef29 | [] | no_license | brucelevis/CPP-RType | 8af517a1a167bbc39cf0cc8d45a8eba1468c2b69 | ffe247694cdc61677c1546a3f5ac6ec336a44570 | refs/heads/main | 2023-02-08T09:29:23.594952 | 2021-01-05T15:36:41 | 2021-01-05T15:36:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 392 | hpp | __BASIC_COMPONENT__.HPP | /*
** EPITECH PROJECT, 2020
** B-CPP-501-PAR-5-1-rtype-aurele.auboin
** File description:
** Component ChangeMe
*/
#ifndef CLIENTCOMPONENTCHANGEME_HPP_
#define CLIENTCOMPONENTCHANGEME_HPP_
#include "components/AComponent.hpp"
namespace rtype {
namespace component {
struct ChangeMe : public AComponent
{
};
}
}
#endif /* !CLIENTCOMPONENTCHANGEME_HPP_ */
|
d317be3e972f71122b3d46550ed4bbfbfb210cee | f809b88dc36ff059cef12c07f18c3cdd5afcb56b | /Source/GhostProj/UI/InfoInteractWidget.h | 97b61c4b1fec1ff1ffa1492de52bf03afcd3b081 | [] | no_license | alexeydr/GhostProj | 2a48a5cb63a84d8ba06597d085b296c43523411d | 9dcbcd280ce5924188cdd2f91eaf71dfe051e02f | refs/heads/master | 2020-12-14T03:21:17.304674 | 2020-06-21T17:44:41 | 2020-06-21T17:44:41 | 234,609,500 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 580 | h | InfoInteractWidget.h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components\TextBlock.h"
#include "Blueprint/UserWidget.h"
#include "InfoInteractWidget.generated.h"
/**
*
*/
UCLASS()
class GHOSTPROJ_API UInfoInteractWidget : public UUserWidget
{
GENERATED_BODY()
protected:
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (BindWidget))
UTextBlock* Name;
public:
FORCEINLINE void SetInteractActorName(FString ActorName) {
if (Name)
{
Name->SetText(FText::FromString(ActorName));
}
};
};
|
ec408d98fd40de7f3900b875d427ddccdb789f0e | 0e3ab186e07482b3c7d8b6bdddcb13e765a3f208 | /PriorityQueue_Heap/UsefulHeap.cpp | 3fc039028fd751f610ed1943390c428141d6ee3b | [] | no_license | 201710757/DataS | 7fda8a6e68b775530d2903dbd338cac8d40523f1 | 5d61166dc37f5ab3a037d32f2c254404465a9704 | refs/heads/master | 2023-02-05T06:48:35.123531 | 2020-12-28T14:29:52 | 2020-12-28T14:29:52 | 293,270,327 | 1 | 0 | null | 2020-12-28T14:29:53 | 2020-09-06T12:16:49 | C++ | UTF-8 | C++ | false | false | 1,620 | cpp | UsefulHeap.cpp | #include "UsefulHeap.h"
#include <iostream>
using namespace std;
int GetParentIDX(int idx)
{
return idx/2;
}
Heap::Heap(PriorityComp pc)
{
this->comp = pc;
this->numOfData = 0;
}
int Heap::HIsEmpty()
{
if(this->numOfData == 0)
return TRUE;
else return FALSE;
}
void Heap::HInsert(HData d)
{
int idx = this->numOfData + 1;
while(idx != 1)
{
if(this->comp(d, this->heapArr[GetParentIDX(idx)]) > 0)
{
this->heapArr[idx] = this->heapArr[GetParentIDX(idx)];
idx = GetParentIDX(idx);
}
else break;
}
this->heapArr[idx] = d;
this->numOfData += 1;
}
int GetLChildIDX(int idx)
{
return idx*2;
}
int GetRChildIDX(int idx)
{
return GetLChildIDX(idx) + 1;
}
int GetHiPriChildIDX(Heap * h, int idx)
{
if(GetLChildIDX(idx) > h->numOfData) return 0;
else if(GetLChildIDX(idx) == h->numOfData) return GetLChildIDX(idx);
else
{
if(h->comp(h->heapArr[GetLChildIDX(idx)], h->heapArr[GetRChildIDX(idx)]) < 0)
return GetRChildIDX(idx);
else return GetLChildIDX(idx);
}
}
HData Heap::HDelete()
{
HData lastElement = this->heapArr[this->numOfData];
HData delData = this->heapArr[1];
int parentIdx = 1;
int childIdx;
while(childIdx = GetHiPriChildIDX(this, parentIdx))
{
if(this->comp(lastElement, this->heapArr[childIdx]) >= 0) break;
this->heapArr[parentIdx] = this->heapArr[childIdx];
parentIdx = childIdx;
}
this->heapArr[parentIdx] = lastElement;
this->numOfData -= 1;
return delData;
}
|
d180be9517789ae1281df3080012e3bebebfd44d | 4af5535125e74f31fbc44816d0c3b907014578b1 | /src/core/Object.h | ebecc6d1a032047cd7cd67710a98cf328208e8f6 | [] | no_license | hazer-hazer/KnotGE | 609aa081ad13361f5f3d2a56ddd0c073de58c874 | a15205b912aa3cde89aff5d3b3e139481f3cab92 | refs/heads/master | 2021-04-07T12:32:49.563306 | 2020-04-13T13:10:01 | 2020-04-13T13:10:01 | 248,675,893 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 781 | h | Object.h | /**
* Object is the base class for all Engine system classes
*/
#ifndef OBJECT_H
#define OBJECT_H
#include <iostream>
#include "core/EventHandler.h"
class Object : public EventHandler {
#define CLASS(m_class, m_parent) \
public: \
virtual std::string get_class(){ \
return #m_class; \
} \
virtual std::string get_parent_class(){ \
return #m_parent; \
} \
virtual std::string print(std::string message, bool print = true){ \
message = std::string("[")+ #m_class +"]: " + message; \
if(print){ \
std::cout << message << std::endl; \
} \
return message; \
}
CLASS(Object, EventHandler);
public:
Object();
virtual ~Object() = default;
void error(std::string message, bool thr = true);
virtual std::string to_string();
};
#endif |
34f5dcfb0bfa8248e78b86a3c1e4ec4ef528a85e | 9028d5e85e3321869e94c3accf24bf67e0e07ee0 | /Prata-Capture_1-14/Capture 10/Task 2/Task 2.cpp | 916a17f2cc8d90414955bc2007b36f86919ea416 | [] | no_license | pukala2/old_stuff | 525dc8b3601df9141cbcfe215c2e9971e6fef3ed | 2e45b8465b900b00c3781e716686c5df665f06d2 | refs/heads/master | 2020-03-24T08:11:37.674093 | 2018-07-27T14:50:55 | 2018-07-27T14:50:55 | 142,587,686 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,060 | cpp | Task 2.cpp | // zad 2 rozdzial 10.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cstring>
class Person {
private:
static const int LIMIT = 256;
std::string lname;//imie
char fname[LIMIT]; //nazwisko
public:
Person() { lname = ""; fname[0] = '\0'; }
Person(const std::string & ln, const char *fn = "HejTy");
void show()const;//wyswiwtla imie nazwisko
void formalshow()const;//nazwisko imie
};
int main()
{
Person one;
Person two("Staszek");
Person three("Jacek", "Placek");
one.show();
std::cout << std::endl;
one.formalshow();
two.formalshow();
two.show();
three.formalshow();
three.show();
system("PAUSE");
return 0;
}
void Person::show()const {
std::cout << fname << std::endl;
std::cout << lname << std::endl;
}
void Person::formalshow()const {
std::cout << lname << std::endl;
std::cout << fname << std::endl;
}
Person::Person(const std::string & ln, const char *fn) {
lname = ln;
strcpy_s(fname, fn);
} |
454449170cadc088b6a9e1b71bd15d883fe08511 | 74f8a44af74bd12951c5abc0fe4af82f5601aba1 | /others/11718/main.cpp | 0570243b73af0cdcdd5cc64037c33d10ea5a12cc | [] | no_license | skeleton625/BOJ | 104060269a4a6996536558e65921c5302d58daee | 936dbb405846de1b358aecfda1d0c0bb19b12d7b | refs/heads/master | 2023-01-09T16:46:12.112568 | 2023-01-08T12:05:00 | 2023-01-08T12:05:00 | 176,702,443 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 172 | cpp | main.cpp | #include <iostream>
#include <string>
using namespace std;
string i1;
int main() {
ios::sync_with_stdio(false);
while (getline(cin, i1)) cout << i1 << endl;
return 0;
} |
bf0d2bfb3a9259e6ae7b75bab8a0f8524651e384 | 2e6a65aa5065293e693eadd1f0e8918c0be69557 | /GUI_QT_Study/Thread_Practice/qdicethread.cpp | fb57c02a52b8421060ae742c9f4992f3af20c049 | [] | no_license | NLS-SP/SLAM_Basics | dece764f7a95862dab4747b0c6d2f3f89b1a959b | 23fb7417e75f955b640170a8cabeab4ed8d68b7a | refs/heads/master | 2022-11-17T00:34:37.168785 | 2021-03-21T13:55:08 | 2021-03-21T13:55:08 | 229,234,194 | 3 | 3 | null | 2022-11-04T07:42:26 | 2019-12-20T09:33:43 | C++ | UTF-8 | C++ | false | false | 588 | cpp | qdicethread.cpp | #include "qdicethread.h"
#include <Qtime>
QDiceThread::QDiceThread()
{
}
void QDiceThread::diceBegin(){
m_paused = false;
}
void QDiceThread::dicePause(){
m_paused = true;
}
void QDiceThread::stopThread(){
m_stop = true;
}
void QDiceThread::run(){
m_stop = false;
m_seq = 0;
qsrand(QTime::currentTime().msec());
while(!m_stop){
if(!m_paused){
m_diceValue = qrand();
m_diceValue = (m_diceValue % 6) + 1;
m_seq++;
emit newValue(m_seq, m_diceValue);
}
msleep(500);
}
quit();
}
|
38ca7c9f068b71236f3787a555695a599b062d2c | ef444ab3913077e83753a9e44e08c3bf58af4810 | /DynamicRouterRIP(최종판)/stdafx.h | 43467da795e812adc5854913755afa5a876886b8 | [] | no_license | sungjoonhh/Network | b57ad13dbdf0d30c6ac554b6b408ff6828fad789 | 882774a7419e682e2336b55d461523ed7ab49474 | refs/heads/master | 2021-01-25T12:50:08.292928 | 2018-03-02T02:29:43 | 2018-03-02T02:29:43 | null | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 5,908 | h | stdafx.h |
// stdafx.h : 자주 사용하지만 자주 변경되지는 않는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 일부 CString 생성자는 명시적으로 선언됩니다.
// MFC의 공통 부분과 무시 가능한 경고 메시지에 대한 숨기기를 해제합니다.
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC 핵심 및 표준 구성 요소입니다.
#include <afxext.h> // MFC 확장입니다.
/* 추가 header */
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // Internet Explorer 4 공용 컨트롤에 대한 MFC 지원입니다.
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // Windows 공용 컨트롤에 대한 MFC 지원입니다.
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxcontrolbars.h> // MFC의 리본 및 컨트롤 막대 지원
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
/* 추가 매크로 */
#define MAX_LAYER_NUMBER 0xff
#define ETHER_MAX_SIZE 1514
#define ETHER_HEADER_SIZE 14
#define ETHER_MAX_DATA_SIZE ( ETHER_MAX_SIZE - ETHER_HEADER_SIZE )
#define IP_PROTOTYPE_UDP 0x11 // UDP : 17
#define IP_PROTOTYPE_TCP 0x06 // TCP : 6
#define IP_PROTOTYPE_ICMP 0x1 // ICMP : 1
#define ICMP_DATA_SIZE 32
#define ICMP_TYPE_REQUEST 0x08
#define ICMP_TYPE_REPLY 0x00
#define UDP_PORT_SRC 520
#define RIP_CMD_REQUEST 0x1
#define RIP_CMD_REPLY 0x2
#define RIP_VER_RIP1 0x1
#define RIP_VER_RIP2 0x2
#define RIP_RD_DEFAULT 0x00
#define RIP_ADDRFAMI_UNSPEC 0x0000
#define RIP_ADDRFAMI_IP 0x0002
#define RIP_ROUTETAG_DEFAULT 0x00
#define RIP_ROUTETAG_BGP 0x01
#define RIP_ROUTETAG_EGP 0x02
#define RIP_HOP_DEFAULT 0
#define RIP_HOP_INFINITY 16
#define ARP_HARDTYPE 0x0001 // Ethernet frame
#define ARP_PROTOTYPE_IP 0x0800
#define ARP_PROTOTYPE_ARP 0x0806
#define ARP_PROTOTYPE_RARP 0x0835
#define ARP_OPCODE_REQUEST 0x0001
#define ARP_OPCODE_REPLY 0x0002
#define ARP_HEADER_SIZE 28
#define CACHE_INCOMPLETE 0x00
#define CACHE_COMPLETE 0x01
#define CACHE_TTL 10
#define TIMER_REPLY 3000 // 30초
#define TIMER_VALID 12000 // 120초
#define TIMER_EXPIRE 18000 // 180초
#define TIMER_UPDATE 1000 // 15초
#define TIMER_ID_UPDATE 8000
#define TIMER_ID_INIT 9999
#define TIMER_ID_REPLY 9998
#define TIMER_ID_CHK_LVALID 9997
#define TIMER_ID_CHK_RVALID 9996
#define TIMER_ID_INF_RVALID 9003
#define TIMER_ID_INF_LVALID 9002
#define TIMER_ID_LEFT_RECEIVE 9001
#define TIMER_ID_RIGHT_RECEIVE 9000
#define NI_COUNT_NIC 10
#define PM_DEVICE_NAME_LENGTH 20
#define RT_DEVICE_NAME_LENGTH 20
#define IP_HEADER_SIZE ( sizeof(unsigned short) * 4 + \
sizeof(unsigned char) * 12 )
#define IP_DATA_SIZE ( ETHER_MAX_SIZE - ( IP_HEADER_SIZE + \
ETHER_HEADER_SIZE ))
#define UDP_HEADER_SIZE ( sizeof(unsigned short) * 4 )
#define UDP_DATA_SIZE ( ETHER_MAX_SIZE - ( ETHER_HEADER_SIZE + \
IP_HEADER_SIZE + \
UDP_HEADER_SIZE))
#define RIP_HEADER_SIZE ( sizeof(unsigned char) * 2 + \
sizeof(unsigned short) )
#define RIP_DATA_SIZE ( sizeof(unsigned short) * 2 + \
sizeof(unsigned char) * 4 * 3 + \
sizeof(unsigned int) )
#define RIP_MAX_DATA_SIZE RIP_DATA_SIZE * 25
#define ICMP_HEADER_SIZE ( sizeof(unsigned short) * 3 + \
sizeof(unsigned char) * 2 )
#define DELG_START 0
#define DELG_END 1
#define DELG_RESET 2
#define DELG_SETTING 3
// Ethernet Address
typedef struct _ETHERNET_ADDR
{
union {
struct { unsigned char e0, e1, e2, e3, e4, e5; } s_un_byte ;
unsigned char s_ether_addr[6] ;
} S_un ;
#define addr_e0 S_un.s_un_byte.e0
#define addr_e1 S_un.s_un_byte.e1
#define addr_e2 S_un.s_un_byte.e2
#define addr_e3 S_un.s_un_byte.e3
#define addr_e4 S_un.s_un_byte.e4
#define addr_e5 S_un.s_un_byte.e5
#define addrs_e S_un.s_ether_addr
} ETHERNET_ADDR, *LPETHERNET_ADDR ;
// IP Address
typedef struct _IP_ADDR
{
union {
struct { unsigned char i0, i1, i2, i3; } s_un_byte ;
unsigned char s_ip_addr[4] ;
} S_un ;
#define addr_i0 S_un.s_un_byte.i0
#define addr_i1 S_un.s_un_byte.i1
#define addr_i2 S_un.s_un_byte.i2
#define addr_i3 S_un.s_un_byte.i3
#define addrs_i S_un.s_ip_addr
} IP_ADDR, *LPIP_ADDR ;
// CACHE Entry
typedef struct _CACHE_ENTRY
{
IP_ADDR cache_ipaddr;
ETHERNET_ADDR cache_enetaddr;
unsigned char cache_interface[RT_DEVICE_NAME_LENGTH];
unsigned char cache_flag[4];
}CACHE_ENTRY, *LPCACHE_ENTRY;
// Linked List
typedef struct _ARP_NODE
{
CACHE_ENTRY key;
struct _ARP_NODE *next;
}ARP_NODE, *LPARP_NODE;
// PROXY Entry
typedef struct _PROXY_ENTRY
{
IP_ADDR proxy_ipaddr;
ETHERNET_ADDR proxy_enetaddr;
unsigned char proxy_devname[PM_DEVICE_NAME_LENGTH];
}PROXY_ENTRY, *LPPROXY_ENTRY;
// Linked List
typedef struct _PARP_NODE
{
PROXY_ENTRY key;
struct _PARP_NODE *next;
}PARP_NODE, *LPPARP_NODE;
// Router Entry
typedef struct _ROUT_ENTRY //* router entry에 있는것들.
{
IP_ADDR rout_router;
IP_ADDR rout_subnet;
IP_ADDR rout_nexthop;
unsigned int rout_metric;
IP_ADDR rout_outport;
unsigned char rout_flag[4];
unsigned char rout_interface[RT_DEVICE_NAME_LENGTH];
int rout_ttl;
}ROUT_ENTRY, *LPROUT_ENTRY;
// Linked List
typedef struct _ROUT_NODE
{
ROUT_ENTRY key;
struct _ROUT_NODE *next;
}ROUT_NODE, *LPROUT_NODE; |
88135da31b389c437e79f4c9f3491f59e5d72d65 | 308f5596f1c7d382520cfce13ceaa5dff6f4f783 | /hphp/runtime/base/builtin-functions.cpp | 31386ee34e5d0a63535abf67d880f831726003cd | [
"PHP-3.01",
"Zend-2.0",
"MIT"
] | permissive | facebook/hhvm | 7e200a309a1cad5304621b0516f781c689d07a13 | d8203129dc7e7bf8639a2b99db596baad3d56b46 | refs/heads/master | 2023-09-04T04:44:12.892628 | 2023-09-04T00:43:05 | 2023-09-04T00:43:05 | 455,600 | 10,335 | 2,326 | NOASSERTION | 2023-09-14T21:24:04 | 2010-01-02T01:17:06 | C++ | UTF-8 | C++ | false | false | 43,452 | cpp | builtin-functions.cpp | /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "hphp/runtime/base/builtin-functions.h"
#include "hphp/runtime/base/backtrace.h"
#include "hphp/runtime/base/code-coverage.h"
#include "hphp/runtime/base/container-functions.h"
#include "hphp/runtime/base/execution-context.h"
#include "hphp/runtime/base/file-util.h"
#include "hphp/runtime/base/opaque-resource.h"
#include "hphp/runtime/base/request-injection-data.h"
#include "hphp/runtime/base/runtime-option.h"
#include "hphp/runtime/base/unit-cache.h"
#include "hphp/runtime/base/variable-serializer.h"
#include "hphp/runtime/base/variable-unserializer.h"
#include "hphp/runtime/debugger/debugger.h"
#include "hphp/runtime/ext/core/ext_core_closure.h"
#include "hphp/runtime/ext/std/ext_std_function.h"
#include "hphp/runtime/ext/string/ext_string.h"
#include "hphp/runtime/vm/event-hook.h"
#include "hphp/runtime/vm/func.h"
#include "hphp/runtime/vm/jit/translator-inline.h"
#include "hphp/runtime/vm/jit/translator.h"
#include "hphp/runtime/vm/method-lookup.h"
#include "hphp/runtime/vm/reified-generics.h"
#include "hphp/runtime/vm/type-constraint.h"
#include "hphp/runtime/vm/unit-util.h"
#include "hphp/runtime/vm/unit.h"
#include "hphp/system/systemlib.h"
#include "hphp/util/logger.h"
#include "hphp/util/process.h"
#include "hphp/util/string-vsnprintf.h"
#include "hphp/util/text-util.h"
#include <folly/Format.h>
#include <algorithm>
namespace HPHP {
using std::string;
///////////////////////////////////////////////////////////////////////////////
// static strings
const StaticString
s_Array("Array"),
s_offsetExists("offsetExists"),
s___invoke("__invoke"),
s_self("self"),
s_parent("parent"),
s_static("static");
const StaticString s_cmpWithCollection(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"a collection with an integer, double, string, array, or object"
);
const StaticString s_cmpWithVec(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"a vec with a non-vec"
);
const StaticString s_cmpWithDict(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"dicts"
);
const StaticString s_cmpWithKeyset(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"keysets"
);
const StaticString s_cmpWithClsMeth(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"a clsmeth"
);
const StaticString s_cmpWithRClsMeth(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"a reified class meth"
);
const StaticString s_cmpWithRFunc(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) with "
"reified functions"
);
const StaticString s_cmpWithOpaqueResource(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) with "
"opaque values"
);
const StaticString s_cmpWithNonArr(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"a PHP array with a non-array"
);
const StaticString s_cmpWithFunc(
"Cannot use relational comparison operators (<, <=, >, >=, <=>) to compare "
"funcs"
);
///////////////////////////////////////////////////////////////////////////////
bool array_is_valid_callback(const Array& arr) {
if (!arr.isVec() && !arr.isDict()) return false;
if (arr.size() != 2 || !arr.exists(int64_t(0)) || !arr.exists(int64_t(1))) {
return false;
}
auto const elem0 = arr.lookup(0);
if (!isStringType(elem0.type()) && !isObjectType(elem0.type()) &&
!isClassType(elem0.type()) && !isLazyClassType(elem0.type())) {
return false;
}
auto const elem1 = arr.lookup(1);
if (!isStringType(elem1.type()) && !isFuncType(elem1.type())) {
return false;
}
return true;
}
const StaticString
s__invoke("__invoke"),
s_Closure__invoke("Closure::__invoke"),
s_colon2("::");
bool is_callable(const Variant& v) {
CallCtx ctx;
vm_decode_function(v, ctx, DecodeFlags::LookupOnly);
return ctx.func != nullptr && !ctx.func->isAbstract();
}
bool is_callable(const Variant& v, bool syntax_only, Variant* name) {
bool ret = true;
if (LIKELY(!syntax_only)) {
ret = is_callable(v);
if (LIKELY(!name)) return ret;
}
auto const tv_func = v.asTypedValue();
if (isFuncType(tv_func->m_type)) {
auto func_name = tv_func->m_data.pfunc->fullName();
if (name) *name = Variant{func_name, Variant::PersistentStrInit{}};
return true;
}
if (isClsMethType(tv_func->m_type)) {
auto const clsmeth = tv_func->m_data.pclsmeth;
if (name) {
*name = concat3(
clsmeth->getCls()->nameStr(), "::", clsmeth->getFunc()->nameStr());
}
return true;
}
if (isStringType(tv_func->m_type)) {
if (name) *name = v;
return ret;
}
if (isVecType(tv_func->m_type) ||
isDictType(tv_func->m_type)) {
auto const arr = Array(tv_func->m_data.parr);
auto const clsname = arr.lookup(int64_t(0));
auto const mthname = arr.lookup(int64_t(1));
if (arr.size() != 2 || !clsname.is_init() ||
(!isStringType(mthname.type()) && !isFuncType(mthname.type()))) {
if (name) *name = s_Array;
return false;
}
StringData* clsString = nullptr;
if (isObjectType(clsname.type())) {
clsString = clsname.val().pobj->getClassName().get();
} else if (isStringType(clsname.type())) {
clsString = clsname.val().pstr;
} else if (isLazyClassType(clsname.type())) {
clsString = const_cast<StringData*>(clsname.val().plazyclass.name());
} else if (isClassType(clsname.type())) {
clsString = const_cast<StringData*>(clsname.val().pclass->name());
} else {
if (name) *name = s_Array;
return false;
}
if (isFuncType(mthname.type())) {
if (name) {
*name = Variant{mthname.val().pfunc->fullName(),
Variant::PersistentStrInit{}};
}
return true;
}
if (name) {
*name = concat3(String{clsString},
s_colon2,
String{mthname.val().pstr});
}
return ret;
}
if (tv_func->m_type == KindOfObject) {
ObjectData *d = tv_func->m_data.pobj;
const Func* invoke = d->getVMClass()->lookupMethod(s__invoke.get());
if (name) {
if (d->instanceof(c_Closure::classof())) {
// Hack to stop the mangled name from showing up
*name = s_Closure__invoke;
} else {
*name = d->getClassName().asString() + "::__invoke";
}
}
return invoke != nullptr;
}
return false;
}
namespace {
Class* vm_decode_class_from_name(
const String& clsName,
const String& funcName,
bool nameContainsClass,
ActRec* ar,
bool& forwarding,
Class* ctx,
DecodeFlags flags) {
Class* cls = nullptr;
if (clsName.get()->isame(s_self.get())) {
if (ctx) {
cls = ctx;
}
if (!nameContainsClass) {
forwarding = true;
}
} else if (clsName.get()->isame(s_parent.get())) {
if (ctx && ctx->parent()) {
cls = ctx->parent();
}
if (!nameContainsClass) {
forwarding = true;
}
} else if (clsName.get()->isame(s_static.get())) {
if (ar && ar->func()->cls()) {
if (ar->hasThis()) {
cls = ar->getThis()->getVMClass();
} else {
cls = ar->getClass();
}
if (flags != DecodeFlags::NoWarn && cls) {
if (RuntimeOption::EvalWarnOnSkipFrameLookup) {
raise_warning(
"vm_decode_function() used to decode a LSB class "
"method on %s",
cls->name()->data()
);
}
}
}
} else {
if (flags == DecodeFlags::Warn && nameContainsClass) {
String nameClass = funcName.substr(0, funcName.find("::"));
if (nameClass.get()->isame(s_self.get()) ||
nameClass.get()->isame(s_static.get())) {
raise_warning("behavior of call_user_func(array('%s', '%s')) "
"is undefined", clsName.data(), funcName.data());
}
}
cls = Class::load(clsName.get());
}
return cls;
}
const Func* vm_decode_func_from_name(
const String& funcName,
ActRec* ar,
bool forwarding,
ObjectData*& this_,
Class*& cls,
Class* ctx,
Class* cc,
DecodeFlags flags) {
CallType lookupType = this_ ? CallType::ObjMethod : CallType::ClsMethod;
auto const moduleName =
ar ? ar->func()->unit()->moduleName() : (const StringData*)nullptr;
auto const callCtx = MemberLookupContext(ctx, moduleName);
auto f = lookupMethodCtx(cc, funcName.get(), callCtx, lookupType,
MethodLookupErrorOptions::NoErrorOnModule);
if (f && (f->attrs() & AttrStatic)) {
// If we found a method and its static, null out this_
this_ = nullptr;
} else {
if (!this_ && ar && ar->func()->cls() && ar->hasThis()) {
// If we did not find a static method AND this_ is null AND there is a
// frame ar, check if the current instance from ar is compatible
auto const obj = ar->getThis();
if (obj->instanceof(cls)) {
this_ = obj;
cls = obj->getVMClass();
}
if (flags != DecodeFlags::NoWarn && this_) {
if (RuntimeOption::EvalWarnOnSkipFrameLookup) {
raise_warning(
"vm_decode_function() used to decode a method on $this, an "
"instance of %s, from the caller, %s",
cls->name()->data(),
ar->func()->fullName()->data()
);
}
}
}
if (!f) {
if (lookupType == CallType::ClsMethod) {
this_ = nullptr;
}
// Bail out if we couldn't find the method
if (flags == DecodeFlags::Warn) {
raise_invalid_argument_warning("function: method '%s' not found",
funcName.data());
}
return nullptr;
}
}
if (!this_ && !f->isStaticInPrologue()) {
if (flags != DecodeFlags::LookupOnly) throw_missing_this(f);
}
assertx(f && f->preClass());
// If this_ is non-NULL, then this_ is the current instance and cls is
// the class of the current instance.
assertx(!this_ || this_->getVMClass() == cls);
// If we are doing a forwarding call and this_ is null, set cls
// appropriately to propagate the current late bound class.
if (!this_ && forwarding && ar && ar->func()->cls()) {
auto const fwdCls = ar->hasThis() ?
ar->getThis()->getVMClass() : ar->getClass();
// Only forward the current late bound class if it is the same or
// a descendent of cls
if (fwdCls->classof(cls)) {
cls = fwdCls;
}
if (flags != DecodeFlags::NoWarn && fwdCls) {
if (RuntimeOption::EvalWarnOnSkipFrameLookup) {
raise_warning(
"vm_decode_function() forwarded the calling context, %s",
fwdCls->name()->data()
);
}
}
}
if (flags != DecodeFlags::NoWarn && !f->isPublic()) {
if (RuntimeOption::EvalWarnOnSkipFrameLookup) {
raise_warning(
"vm_decode_function() used to decode a %s method: %s",
f->attrs() & AttrPrivate ? "private" : "protected",
f->fullName()->data()
);
}
}
return f;
}
}
bool checkMethCallerTarget(const Func* meth, const Class* ctx, bool error) {
if (meth->isStaticInPrologue()) {
if (!error) return false;
SystemLib::throwInvalidArgumentExceptionObject(folly::sformat(
"meth_caller(): method {} is static",
meth->fullName()->data()
));
}
if (meth->isPublic() || ctx == meth->cls()) return true;
if (ctx && (meth->attrs() & AttrProtected) && ctx->classof(meth->cls())) {
return true;
}
// Executing this meth_caller() can still be an error but we won't know until
// we know precisely what instance it's being invoked on.
// XXX: Do we want this behavior?
if (meth->hasPrivateAncestor() && meth->cls()->classof(ctx)) {
auto const cmeth = ctx->lookupMethod(meth->name());
if (cmeth && cmeth->cls() == ctx && (cmeth->attrs() & AttrPrivate)) {
return true;
}
}
if (error) {
SystemLib::throwInvalidArgumentExceptionObject(folly::sformat(
"meth_caller(): method {} cannot be called from this context",
meth->fullName()->data()
));
}
return false;
}
void checkMethCaller(const Func* func, const Class* ctx) {
auto const cls = Class::load(func->methCallerClsName());
if (!cls) {
SystemLib::throwInvalidArgumentExceptionObject(folly::sformat(
"meth_caller(): class {} not found", func->methCallerClsName()->data()
));
}
if (isTrait(cls)) {
SystemLib::throwInvalidArgumentExceptionObject(folly::sformat(
"meth_caller(): class {} is a trait", func->methCallerClsName()->data()
));
}
auto const meth = [&] () -> const Func* {
if (auto const m = cls->lookupMethod(func->methCallerMethName())) return m;
for (auto const i : cls->allInterfaces().range()) {
if (auto const m = i->lookupMethod(func->methCallerMethName())) return m;
}
return nullptr;
}();
if (!meth) {
SystemLib::throwInvalidArgumentExceptionObject(folly::sformat(
"meth_caller(): method {}::{} not found",
func->methCallerClsName()->data(),
func->methCallerMethName()->data()
));
}
checkMethCallerTarget(meth, ctx, true);
}
const HPHP::Func*
vm_decode_function(const_variant_ref function,
ActRec* ar,
ObjectData*& this_,
HPHP::Class*& cls,
bool& dynamic,
DecodeFlags flags /* = DecodeFlags::Warn */,
bool genericsAlreadyGiven /* = false */) {
bool forwarding = false;
dynamic = true;
if (function.isFunc()) {
dynamic = false;
this_ = nullptr;
cls = nullptr;
return function.toFuncVal();
}
if (function.isClsMeth()) {
dynamic = false;
this_ = nullptr;
auto const clsmeth = function.toClsMethVal();
cls = clsmeth->getCls();
return clsmeth->getFunc();
}
if (function.isString() || function.isArray()) {
HPHP::Class* ctx = nullptr;
if (ar) ctx = arGetContextClass(ar);
// Decode the 'function' parameter into this_, cls, name, pos, and
// nameContainsClass.
this_ = nullptr;
cls = nullptr;
String name;
int pos = String::npos;
bool nameContainsClass = false;
if (function.isString()) {
// If 'function' is a string we simply assign it to name and
// leave this_ and cls set to NULL.
name = function.toString();
pos = name.find("::");
nameContainsClass =
(pos != 0 && pos != String::npos && pos + 2 < name.size());
} else {
// If 'function' is an array with exactly two indices 0 and 1, we
// assign the value at index 1 to name and we use the value at index
// 0 to populate cls (if the value is a string) or this_ and cls (if
// the value is an object).
assertx(function.isArray());
Array arr = function.toArray();
if (!array_is_valid_callback(arr)) {
if (flags == DecodeFlags::Warn) {
raise_invalid_argument_warning("function: not a valid callback array");
}
return nullptr;
}
Variant elem0 = arr[0];
Variant elem1 = arr[1];
if (elem1.isFunc()) {
if (elem0.isObject()) {
this_ = elem0.getObjectData();
cls = this_->getVMClass();
} else if (elem0.isClass()) {
cls = elem0.toClassVal();
} else if (elem0.isLazyClass()) {
cls = Class::load(elem0.toLazyClassVal().name());
} else {
raise_error("calling an ill-formed array without resolved "
"object/class pointer");
return nullptr;
}
return elem1.toFuncVal();
}
assertx(elem1.isString());
name = elem1.toString();
pos = name.find("::");
nameContainsClass =
(pos != 0 && pos != String::npos && pos + 2 < name.size());
if (elem0.isString() || elem0.isLazyClass()) {
auto const clsName = elem0.isString() ?
elem0.toString() : StrNR{elem0.toLazyClassVal().name()};
cls = vm_decode_class_from_name(
clsName, name, nameContainsClass, ar, forwarding, ctx,
flags);
if (!cls) {
if (flags == DecodeFlags::Warn) {
raise_invalid_argument_warning("function: class not found");
}
return nullptr;
}
} else if (elem0.isClass()) {
cls = elem0.toClassVal();
} else {
assertx(elem0.isObject());
this_ = elem0.getObjectData();
cls = this_->getVMClass();
}
}
HPHP::Class* cc = cls;
if (nameContainsClass) {
String c = name.substr(0, pos);
name = name.substr(pos + 2);
if (c.get()->isame(s_self.get())) {
if (cls) {
cc = cls;
} else if (ctx) {
cc = ctx;
}
if (!this_) {
forwarding = true;
}
} else if (c.get()->isame(s_parent.get())) {
if (cls) {
cc = cls->parent();
} else if (ctx && ctx->parent()) {
cc = ctx->parent();
}
if (!this_) {
forwarding = true;
}
} else if (c.get()->isame(s_static.get())) {
if (ar && ar->func()->cls()) {
if (ar->hasThis()) {
cc = ar->getThis()->getVMClass();
} else {
cc = ar->getClass();
}
}
if (flags != DecodeFlags::NoWarn && cc) {
if (RuntimeOption::EvalWarnOnSkipFrameLookup) {
raise_warning(
"vm_decode_function() used to decode a LSB class "
"method on %s",
cc->name()->data()
);
}
}
} else {
cc = Class::load(c.get());
}
if (!cc) {
if (flags == DecodeFlags::Warn) {
raise_invalid_argument_warning("function: class not found");
}
return nullptr;
}
if (cls) {
if (!cls->classof(cc)) {
if (flags == DecodeFlags::Warn) {
raise_warning("call_user_func expects parameter 1 to be a valid "
"callback, class '%s' is not a subclass of '%s'",
cls->preClass()->name()->data(),
cc->preClass()->name()->data());
}
return nullptr;
}
}
// If there is not a current instance, cc trumps cls.
if (!this_) {
cls = cc;
}
}
if (!cls) {
HPHP::Func* f = HPHP::Func::load(name.get());
if (!f) {
if (flags == DecodeFlags::Warn) {
raise_invalid_argument_warning("function: method '%s' not found",
name.data());
}
return nullptr;
}
assertx(f && f->preClass() == nullptr);
if (f->hasReifiedGenerics() && !genericsAlreadyGiven &&
!f->getReifiedGenericsInfo().allGenericsSoft()) {
raise_invalid_argument_warning(
"You may not call the reified function '%s' "
"without reified arguments",
f->fullName()->data());
return nullptr;
}
return f;
}
assertx(cls);
return vm_decode_func_from_name(
name, ar, forwarding, this_, cls, ctx, cc, flags);
}
if (function.isObject()) {
this_ = function.asCObjRef().get();
cls = nullptr;
dynamic = false;
const HPHP::Func *f = this_->getVMClass()->lookupMethod(s___invoke.get());
if (f != nullptr && f->isStaticInPrologue()) {
// If __invoke is static, invoke it as such
cls = this_->getVMClass();
this_ = nullptr;
}
if (flags == DecodeFlags::Warn && f == nullptr) {
raise_warning("call_user_func() expects parameter 1 to be a valid "
"callback, object of class %s given (no __invoke "
"method found)", this_->getVMClass()->name()->data());
}
return f;
}
if (flags == DecodeFlags::Warn) {
raise_invalid_argument_warning("function: not string, closure, or array");
}
return nullptr;
}
Variant vm_call_user_func(const_variant_ref function, const Variant& params,
RuntimeCoeffects providedCoeffects
/* = RuntimeCoeffects::fixme() */,
bool checkRef /* = false */,
bool allowDynCallNoPointer /* = false */) {
CallCtx ctx;
vm_decode_function(function, ctx);
if (ctx.func == nullptr || (!isContainer(params) && !params.isNull())) {
return uninit_null();
}
return Variant::attach(
g_context->invokeFunc(ctx.func, params, ctx.this_, ctx.cls,
providedCoeffects, ctx.dynamic,
checkRef, allowDynCallNoPointer)
);
}
Variant
invoke(const String& function, const Variant& params,
bool allowDynCallNoPointer /* = false */) {
Func* func = Func::load(function.get());
if (func && (isContainer(params) || params.isNull())) {
auto ret = Variant::attach(
g_context->invokeFunc(func, params, nullptr, nullptr,
RuntimeCoeffects::fixme(), true, false,
allowDynCallNoPointer)
);
return ret;
}
throw ExtendedException("(1) call the function without enough arguments OR "
"(2) Unable to find function \"%s\" OR "
"(3) function was not in invoke table OR "
"(4) function was renamed to something else.",
function.c_str());
}
Variant invoke_static_method(const String& s, const String& method,
const Variant& params, bool fatal /* = true */) {
HPHP::Class* class_ = Class::lookup(s.get());
if (class_ == nullptr) {
o_invoke_failed(s.data(), method.data(), fatal);
return uninit_null();
}
const HPHP::Func* f = class_->lookupMethod(method.get());
if (f == nullptr || !f->isStaticInPrologue() ||
(!isContainer(params) && !params.isNull())) {
o_invoke_failed(s.data(), method.data(), fatal);
return uninit_null();
}
auto ret = Variant::attach(
g_context->invokeFunc(f, params, nullptr, class_, RuntimeCoeffects::fixme())
);
return ret;
}
Variant o_invoke_failed(const char *cls, const char *meth,
bool fatal /* = true */) {
if (fatal) {
string msg = "Unknown method ";
msg += cls;
msg += "::";
msg += meth;
raise_fatal_error(msg.c_str());
} else {
raise_warning("call_user_func to non-existent method %s::%s", cls, meth);
return false;
}
}
void throw_has_this_need_static(const Func* f) {
auto const msg = folly::sformat(
"Static method {}() cannot be called on instance",
f->fullName()->data()
);
SystemLib::throwBadMethodCallExceptionObject(msg);
}
void throw_missing_this(const Func* f) {
auto const msg = folly::sformat(
"Non-static method {}() cannot be called statically",
f->fullName()->data()
);
SystemLib::throwBadMethodCallExceptionObject(msg);
}
void NEVER_INLINE throw_invalid_property_name(const String& name) {
if (!name.size()) {
raise_error("Cannot access empty property");
}
raise_error("Cannot access property started with '\\0'");
}
void throw_instance_method_fatal(const char *name) {
raise_error("Non-static method %s() cannot be called statically", name);
}
void throw_call_reified_func_without_generics(const Func* f) {
auto const msg = folly::sformat(
"Cannot call the reified function '{}' without the reified generics",
f->fullName()->data()
);
SystemLib::throwBadMethodCallExceptionObject(msg);
}
void throw_implicit_context_exception(std::string s) {
SystemLib::throwInvalidOperationExceptionObject(s);
}
void raise_implicit_context_warning(std::string s) {
raise_warning(s);
}
void throw_iterator_not_valid() {
SystemLib::throwInvalidOperationExceptionObject(
"Iterator is not valid");
}
void throw_collection_property_exception() {
SystemLib::throwInvalidOperationExceptionObject(
"Cannot access a property on a collection");
}
void throw_invalid_collection_parameter() {
SystemLib::throwInvalidArgumentExceptionObject(
"Parameter must be an array or an instance of Traversable");
}
void throw_invalid_operation_exception(StringData* str) {
SystemLib::throwInvalidOperationExceptionObject(Variant{str});
}
void throw_division_by_zero_exception() {
SystemLib::throwDivisionByZeroExceptionObject();
}
void throw_collection_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithCollection);
}
void throw_vec_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithVec);
}
void throw_dict_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithDict);
}
void throw_rfunc_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithRFunc);
}
void throw_opaque_resource_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithOpaqueResource);
}
void throw_keyset_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithKeyset);
}
void throw_clsmeth_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithClsMeth);
}
void throw_rclsmeth_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithRClsMeth);
}
void throw_func_compare_exception() {
SystemLib::throwInvalidOperationExceptionObject(s_cmpWithFunc);
}
void throw_param_is_not_container() {
static const string msg("Parameter must be an array or collection");
SystemLib::throwInvalidArgumentExceptionObject(msg);
}
void throw_invalid_inout_base() {
SystemLib::throwInvalidArgumentExceptionObject(
"Parameters marked inout must be contained in locals, vecs, dicts, "
"keysets, and arrays"
);
}
void throw_cannot_modify_immutable_object(const char* className) {
auto msg = folly::sformat(
"Cannot modify immutable object of type {}",
className
);
SystemLib::throwInvalidOperationExceptionObject(msg);
}
void throw_cannot_modify_const_object(const char* className) {
auto msg = folly::sformat(
"Cannot modify const object of type {}",
className
);
SystemLib::throwInvalidOperationExceptionObject(msg);
}
void throw_object_forbids_dynamic_props(const char* className) {
auto msg = folly::sformat(
"Class {} does not allow use of dynamic (non-declared) properties",
className
);
SystemLib::throwInvalidOperationExceptionObject(msg);
}
void throw_cannot_modify_const_prop(const char* className,
const char* propName)
{
auto msg = folly::sformat(
"Cannot modify const property {} of class {} after construction",
propName, className
);
SystemLib::throwInvalidOperationExceptionObject(msg);
}
void throw_cannot_modify_static_const_prop(const char* className,
const char* propName)
{
auto msg = folly::sformat(
"Cannot modify static const property {} of class {}.",
propName, className
);
SystemLib::throwInvalidOperationExceptionObject(msg);
}
void throw_local_must_be_value_type(const char* locName)
{
auto const msg = folly::sformat("Local {} must be a value type.", locName);
SystemLib::throwReadonlyViolationExceptionObject(msg);
}
namespace {
[[noreturn]]
void throw_readonly_violation(const char* className, const char* propName,
const char* msg) {
std::string fmtMsg;
string_printf(fmtMsg, msg, propName, className);
SystemLib::throwReadonlyViolationExceptionObject(fmtMsg);
}
}
void throw_must_be_readonly(const char* className, const char* propName) {
throw_readonly_violation(className, propName, Strings::MUST_BE_READONLY);
}
void throw_must_be_mutable(const char* className, const char* propName) {
throw_readonly_violation(className, propName, Strings::MUST_BE_MUTABLE);
}
void throw_must_be_enclosed_in_readonly(const char* className, const char* propName) {
throw_readonly_violation(className, propName, Strings::MUST_BE_ENCLOSED_IN_READONLY);
}
void throw_must_be_value_type(const char* className, const char* propName) {
throw_readonly_violation(className, propName, Strings::MUST_BE_VALUE_TYPE);
}
void throw_cannot_modify_readonly_collection() {
SystemLib::throwReadonlyViolationExceptionObject(
Strings::READONLY_COLLECTIONS_CANNOT_BE_MODIFIED
);
}
bool readonlyLocalShouldThrow(TypedValue tv, ReadonlyOp op) {
if (op == ReadonlyOp::CheckROCOW || op == ReadonlyOp::CheckMutROCOW) {
vmMInstrState().roProp = true;
if (type(tv) == KindOfObject) return true;
}
return false;
}
void checkReadonly(const TypedValue* tv,
const Class* cls,
const StringData* name,
bool readonly,
ReadonlyOp op,
bool writeMode) {
if ((op == ReadonlyOp::CheckMutROCOW && readonly) || op == ReadonlyOp::CheckROCOW) {
vmMInstrState().roProp = true;
}
if (readonly) {
if (op == ReadonlyOp::CheckMutROCOW || op == ReadonlyOp::CheckROCOW) {
if (type(tv) == KindOfObject) {
throw_must_be_value_type(cls->name()->data(), name->data());
}
} else if (op == ReadonlyOp::Mutable) {
if (writeMode) {
throw_must_be_mutable(cls->name()->data(), name->data());
} else {
throw_must_be_enclosed_in_readonly(cls->name()->data(), name->data());
}
}
} else if (op == ReadonlyOp::Readonly || op == ReadonlyOp::CheckROCOW) {
throw_must_be_readonly(cls->name()->data(), name->data());
}
}
NEVER_INLINE
void throw_late_init_prop(const Class* cls,
const StringData* propName,
bool isSProp) {
SystemLib::throwInvalidOperationExceptionObject(
folly::sformat(
"Accessing <<__LateInit>> {} '{}::{}' before initialization",
isSProp ? "static property" : "property",
cls->name(),
propName
)
);
}
NEVER_INLINE
void throw_parameter_wrong_type(TypedValue tv,
const Func* callee,
unsigned int arg_num,
const StringData* expected_type) {
auto const msg = param_type_error_message(
callee->name()->data(), arg_num, expected_type->data(), tv);
if (RuntimeOption::PHP7_EngineExceptions) {
SystemLib::throwTypeErrorObject(msg);
}
SystemLib::throwRuntimeExceptionObject(msg);
}
void check_collection_cast_to_array() {
if (RuntimeOption::WarnOnCollectionToArray) {
raise_warning("Casting a collection to an array is an expensive operation "
"and should be avoided where possible. To convert a "
"collection to an array without raising a warning, use the "
"toArray() method.");
}
}
Object create_object_only(const String& s) {
return Object::attach(g_context->createObjectOnly(s.get()));
}
Object init_object(const String& s, const Array& params, ObjectData* o) {
return Object{g_context->initObject(s.get(), params, o)};
}
Object
create_object(const String& s, const Array& params, bool init /* = true */) {
return Object::attach(g_context->createObject(s.get(), params, init));
}
void throw_object(const Object& e) {
throw req::root<Object>(e);
}
#if ((__GNUC__ != 4) || (__GNUC_MINOR__ != 8))
void throw_object(Object&& e) {
throw req::root<Object>(std::move(e));
}
#endif
/*
* This function is used when another thread is segfaulting---we just
* want to wait forever to give it a chance to write a stacktrace file
* (and maybe a core file).
*/
void pause_forever() {
for (;;) sleep(300);
}
bool is_constructor_name(const char* fn) {
auto const len = strlen(fn);
const char construct[] = "__construct";
auto const clen = sizeof(construct) - 1;
if (len >= clen && !strcmp(fn + len - clen, construct)) {
if (len == clen || (len > clen + 2 &&
fn[len - clen - 1] == ':' &&
fn[len - clen - 2] == ':')) {
return true;
}
}
return false;
}
void throw_missing_arguments_nr(const char *fn, int expected, int got) {
SystemLib::throwRuntimeExceptionObject(folly::sformat(
"{}() expects exactly {} parameter{}, {} given",
fn,
expected,
expected == 1 ? "" : "s",
got
));
}
void raise_bad_type_warning(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
std::string msg;
string_vsnprintf(msg, fmt, ap);
va_end(ap);
raise_warning("Invalid operand type was used: %s", msg.c_str());
}
void raise_expected_array_warning(const char* fn /*=nullptr*/) {
if (!fn) {
fn = fromLeaf([&](const BTFrame& frm) {
return frm.func()->name()->data();
}, backtrace_detail::true_pred, "(unknown)");
}
raise_bad_type_warning("%s expects array(s)", fn);
}
void raise_expected_array_or_collection_warning(const char* fn /*=nullptr*/) {
if (!fn) {
fn = fromLeaf([&](const BTFrame& frm) {
return frm.func()->name()->data();
}, backtrace_detail::true_pred, "(unknown)");
}
raise_bad_type_warning("%s expects array(s) or collection(s)", fn);
}
void raise_invalid_argument_warning(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
string msg;
string_vsnprintf(msg, fmt, ap);
va_end(ap);
raise_warning("Invalid argument: %s", msg.c_str());
}
Variant throw_fatal_unset_static_property(const char *s, const char *prop) {
raise_error("Attempt to unset static property %s::$%s", s, prop);
return uninit_null();
}
Variant unserialize_ex(const char* str, int len,
VariableUnserializer::Type type,
const Array& options /* = null_array */,
bool pure /* = false */) {
if (str == nullptr || len <= 0) {
return false;
}
VariableUnserializer vu(str, len, type,
/* allowUnknownSerializableClass = */ true,
options);
if (pure) vu.setPure();
Variant v;
try {
v = vu.unserialize();
} catch (FatalErrorException& e) {
throw;
} catch (InvalidAllowedClassesException& e) {
raise_warning(
"unserialize(): allowed_classes option should be array or boolean"
);
return false;
} catch (Exception& e) {
raise_notice("Unable to unserialize: [%.*s]. %s.",
std::min(len, 1000), str, e.getMessage().c_str());
return false;
}
return v;
}
Variant unserialize_ex(const String& str,
VariableUnserializer::Type type,
const Array& options /* = null_array */,
bool pure /* = false */) {
return unserialize_ex(str.data(), str.size(), type, options, pure);
}
String concat3(const String& s1, const String& s2, const String& s3) {
auto r1 = s1.slice();
auto r2 = s2.slice();
auto r3 = s3.slice();
auto len = r1.size() + r2.size() + r3.size();
auto str = String::attach(StringData::Make(len));
auto const r = str.mutableData();
memcpy(r, r1.data(), r1.size());
memcpy(r + r1.size(), r2.data(), r2.size());
memcpy(r + r1.size() + r2.size(), r3.data(), r3.size());
str.setSize(len);
return str;
}
String concat4(const String& s1, const String& s2, const String& s3,
const String& s4) {
auto r1 = s1.slice();
auto r2 = s2.slice();
auto r3 = s3.slice();
auto r4 = s4.slice();
auto len = r1.size() + r2.size() + r3.size() + r4.size();
auto str = String::attach(StringData::Make(len));
auto const r = str.mutableData();
memcpy(r, r1.data(), r1.size());
memcpy(r + r1.size(), r2.data(), r2.size());
memcpy(r + r1.size() + r2.size(), r3.data(), r3.size());
memcpy(r + r1.size() + r2.size() + r3.size(), r4.data(), r4.size());
str.setSize(len);
return str;
}
static bool invoke_file_impl(Variant& res, const String& path, bool once,
const char *currentDir,
bool callByHPHPInvoke) {
bool initial;
auto const u = lookupUnit(path.get(), currentDir, &initial, nullptr, false);
if (u == nullptr) return false;
if (!once || initial) {
*res.asTypedValue() = g_context->invokeUnit(u, callByHPHPInvoke);
}
return true;
}
static NEVER_INLINE Variant throw_missing_file(const char* file) {
throw PhpFileDoesNotExistException(file);
}
static Variant invoke_file(const String& s,
bool once,
const char *currentDir,
bool callByHPHPInvoke) {
Variant r;
if (invoke_file_impl(r, s, once, currentDir, callByHPHPInvoke)) {
return r;
}
return throw_missing_file(s.c_str());
}
Variant include_impl_invoke(const String& file, bool once,
const char *currentDir, bool callByHPHPInvoke) {
if (FileUtil::isAbsolutePath(file.toCppString())) {
if (RuntimeOption::SandboxMode || !RuntimeOption::AlwaysUseRelativePath) {
try {
return invoke_file(file, once, currentDir, callByHPHPInvoke);
} catch(PhpFileDoesNotExistException& e) {}
}
try {
String rel_path(FileUtil::relativePath(RuntimeOption::SourceRoot,
string(file.data())));
// Don't try/catch - We want the exception to be passed along
return invoke_file(rel_path, once, currentDir, callByHPHPInvoke);
} catch(PhpFileDoesNotExistException& e) {
throw PhpFileDoesNotExistException(file.c_str());
}
} else {
// Don't try/catch - We want the exception to be passed along
return invoke_file(file, once, currentDir, callByHPHPInvoke);
}
}
/**
* Used by include_impl. resolve_include() needs some way of checking the
* existence of a file path, which for hphpc means attempting to invoke it.
* This struct carries some context information needed for the invocation, as
* well as a place for the return value of invoking the file.
*/
struct IncludeImplInvokeContext {
bool once;
const char* currentDir;
Variant returnValue;
};
static bool include_impl_invoke_context(const String& file, void* ctx) {
struct IncludeImplInvokeContext* context = (IncludeImplInvokeContext*)ctx;
bool invoked_file = false;
try {
context->returnValue = include_impl_invoke(file, context->once,
context->currentDir);
invoked_file = true;
} catch (PhpFileDoesNotExistException& e) {
context->returnValue = false;
}
return invoked_file;
}
/**
* tryFile is a pointer to a function that resolve_include() will use to
* determine if a path references a real file. ctx is a pointer to some context
* information that will be passed through to tryFile. (It's a hacky closure)
*/
String resolve_include(const String& file, const char* currentDir,
bool (*tryFile)(const String& file, void*), void* ctx) {
const char* c_file = file.data();
auto const getCwd = [] () -> String {
if (LIKELY(!g_context.isNull())) return g_context->getCwd();
return String(Process::CurrentWorkingDirectory, CopyString);
};
if (!File::IsPlainFilePath(file)) {
// URIs don't have an include path
if (tryFile(file, ctx)) {
return file;
}
} else if (FileUtil::isAbsolutePath(file.toCppString())) {
String can_path = FileUtil::canonicalize(file);
if (tryFile(can_path, ctx)) {
return can_path;
}
} else if ((c_file[0] == '.' && (c_file[1] == '/' || (
c_file[1] == '.' && c_file[2] == '/')))) {
String path(String(getCwd() + "/" + file));
String can_path = FileUtil::canonicalize(path);
if (tryFile(can_path, ctx)) {
return can_path;
}
} else {
if (!RequestInfo::s_requestInfo.isNull()) {
auto const& includePaths = RID().getIncludePaths();
for (auto const& includePath : includePaths) {
String path("");
auto const is_stream_wrapper =
includePath.find("://") != std::string::npos;
if (!is_stream_wrapper && !FileUtil::isAbsolutePath(includePath)) {
path += (getCwd() + "/");
}
path += includePath;
if (path[path.size() - 1] != '/') {
path += "/";
}
path += file;
String can_path;
if (!is_stream_wrapper) {
can_path = FileUtil::canonicalize(path);
} else {
can_path = String(path.c_str());
}
if (tryFile(can_path, ctx)) {
return can_path;
}
}
}
if (FileUtil::isAbsolutePath(currentDir)) {
String path(currentDir);
path += "/";
path += file;
String can_path = FileUtil::canonicalize(path);
if (tryFile(can_path, ctx)) {
return can_path;
}
} else {
String path(getCwd() + "/" + currentDir + file);
String can_path = FileUtil::canonicalize(path);
if (tryFile(can_path, ctx)) {
return can_path;
}
}
}
return String();
}
static Variant include_impl(const String& file, bool once,
const char *currentDir, bool required,
bool raiseNotice) {
struct IncludeImplInvokeContext ctx = {once, currentDir};
String can_path = resolve_include(file, currentDir,
include_impl_invoke_context, (void*)&ctx);
if (can_path.isNull()) {
// Failure
if (raiseNotice) {
raise_notice("Tried to invoke %s but file not found.", file.data());
}
if (required) {
String ms = "Required file that does not exist: ";
ms += file;
raise_fatal_error(ms.data());
}
return false;
}
return ctx.returnValue;
}
Variant require(const String& file,
bool once,
const char* currentDir,
bool raiseNotice) {
return include_impl(file, once, currentDir, true, raiseNotice);
}
bool function_exists(const String& function_name) {
auto f = Func::lookup(function_name.get());
return f != nullptr;
}
///////////////////////////////////////////////////////////////////////////////
// debugger and code coverage instrumentation
void throw_exception(const Object& e) {
if (!e.instanceof(SystemLib::getThrowableClass())) {
raise_error("Exceptions must implement the Throwable interface.");
}
DEBUGGER_ATTACHED_ONLY(phpDebuggerExceptionThrownHook(e.get()));
throw req::root<Object>(e);
}
///////////////////////////////////////////////////////////////////////////////
}
|
9a591e6b895d14a53801d2059358b409d80db4d2 | 197c05e4546df7b95391105aef4a279f98a02932 | /cpp/hackerrank/src/jumping-on-the-clouds.cpp | 2cf4026759644f92b6a00a9401a196c42d7ccbac | [] | no_license | sergey-pashaev/practice | c269c0f6f7495701f175c566d0942ab5d52f661a | e92ef5c17f0e89c274f89b7ad8f1326e526ce91c | refs/heads/master | 2023-02-18T20:42:14.503574 | 2023-02-13T18:01:13 | 2023-02-13T18:01:13 | 167,481,051 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,980 | cpp | jumping-on-the-clouds.cpp | // jumping on the clouds
// Emma is playing a new mobile game that starts with consecutively
// numbered clouds. Some of the clouds are thunderheads and others are
// cumulus. She can jump on any cumulus cloud having a number that is
// equal to the number of the current cloud plus 1 or 2. She must avoid
// the thunderheads. Determine the minimum number of jumps it will
// take Emma to jump from her starting postion to the last cloud. It
// is always possible to win the game.
// For each game, Emma will get an array of clouds numbered 0 if they
// are safe or 1 if they must be avoided. For example, c = [0, 1, 0, 0, 0, 1, 0]
// indexed from 0 ... 6. The number on each cloud is its index in the list so
// she must avoid the clouds at indexes 1 and 5. She could follow the following
// two paths: 0 -> 2 -> 4 -> 6 or 0 -> 2 -> 3 -> 4 -> 6. The first path takes 3
// jumps while the second takes 4.
// Function Description
// Complete the jumpingOnClouds function in the editor below. It
// should return the minimum number of jumps required, as an integer.
// jumpingOnClouds has the following parameter(s):
// c: an array of binary integers
#include <catch2/catch.hpp>
#include <cassert>
#include <vector>
using namespace std;
int jumps(const vector<int>& path) {
assert(path.size() > 1);
assert(path.front() == 0);
assert(path.back() == 0);
int jumps = 0;
int n = path.size();
for (int i = 0; i < n - 1;) {
if (i + 2 < n && path[i + 2] == 0) {
// try long jump at first
i += 2;
++jumps;
} else if (i + 1 < n && path[i + 1] == 0) {
// short jump at second
++i;
++jumps;
} else {
return -1;
}
}
return jumps;
}
TEST_CASE("jumping on the clouds") {
REQUIRE(jumps({0, 0, 1, 0, 0, 1, 0}) == 4);
REQUIRE(jumps({0, 0, 0, 0, 1, 0}) == 3);
REQUIRE(jumps({0, 0}) == 1);
REQUIRE(jumps({0, 0, 0}) == 1);
}
|
96c67bb192caba94706c218f966c15a9fba97f17 | 552a0a2212ce235cb0fd97089557966657afcd9e | /Oving4/CardDeck.h | 2aca749309f0a8f510578ad9d2d611c3bad28dc7 | [] | no_license | thmmsn/TDT4102 | 4ba2fceef1fb24d6eaac74328645f943c749a706 | b0fedf496eff2abf69025e33d51dd790501e7eea | refs/heads/master | 2021-05-29T11:05:13.824226 | 2015-05-24T20:06:49 | 2015-05-24T20:06:49 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 496 | h | CardDeck.h | //
// CardDeck.h
// Oving4
//
// Created by fredrik on 12/02/15.
// Copyright (c) 2015 fredrik. All rights reserved.
//
#ifndef __Oving4__CardDeck__
#define __Oving4__CardDeck__
#include <stdio.h>
#include "card.h"
class CardDeck{
private:
Card cards[52];
int currentCardIndex;
void swap(int x, int y);
bool shuffled;
public:
void shuffle();
CardDeck();
void print();
void printShort();
Card drawCard();
};
#endif /* defined(__Oving4__CardDeck__) */
|
45b70fc9d54ddad955a0c9a5119657463779c0f9 | c21d1235a65ad3dc39cd8efb112734da102ad773 | /RayTracer/Logger.h | 4b6010d1538939235443cd6b5eb32e378b970f9d | [] | no_license | parikshit6321/RayTracer | d48270d7f72c0681a02880e710a326e4049811e5 | af5e9bce8bf48079f96eeffd0949fc383f00c832 | refs/heads/master | 2021-01-10T05:25:01.355797 | 2016-03-19T16:00:46 | 2016-03-19T16:00:46 | 53,166,892 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 508 | h | Logger.h | #pragma once
#include <fstream>
#include "Timer.h"
class Logger
{
public:
Logger() {}
static void Initialize()
{
std::ofstream outFile;
outFile.open("log.log", std::ios::out | std::ios::trunc);
outFile.close();
}
static void Log(const char* message)
{
std::ofstream outFile;
outFile.open("log.log", std::ios::app);
outFile << "( " << Timer::GetTime() << " sec ) \t:\t";
outFile << message;
outFile << "\n";
outFile.close();
}
~Logger() {}
private:
static int currentLine;
}; |
188d5a3853967bd5bc8d3a27daed64cfe4ff21de | 4b811ff3fd7152cb652165eadb751c91e352e91c | /Source/Cells/ArmorType.h | eacf1f58b3525b97ee2a8741eeb28dc4604f66e7 | [] | no_license | SimonPiCarter/cells_ue | d093ade43a0b479424e72c20f5dced7a387c36f9 | 07a8d3b8e62747e256cd81101eef3856b72919cb | refs/heads/master | 2023-06-21T18:15:35.231686 | 2021-07-25T10:14:33 | 2021-07-25T10:14:33 | 378,737,342 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 771 | h | ArmorType.h | #pragma once
#include <iostream>
#include "ArmorType.generated.h"
UENUM(BlueprintType)
enum class ArmorType : uint8
{
Standard,
Resilient,
Heavy,
Light
};
inline std::ostream& operator<<(std::ostream& os_p, ArmorType type_p)
{
switch (type_p)
{
case ArmorType::Standard:
os_p << "Standard";
break;
case ArmorType::Resilient:
os_p << "Resilient";
break;
case ArmorType::Heavy:
os_p << "Heavy";
break;
case ArmorType::Light:
os_p << "Light";
break;
}
return os_p;
}
inline ArmorType fromStringToArmorType(std::string const& str_p)
{
if (str_p == "Resilient")
{
return ArmorType::Resilient;
}
if (str_p == "Heavy")
{
return ArmorType::Heavy;
}
if (str_p == "Light")
{
return ArmorType::Light;
}
return ArmorType::Standard;
}
|
3fd4f4955639595cc07344cff15f47aab469647b | 52c0949315583ba8898694cceacfaafaeab6f902 | /test/include/test_util/sql_table_test_util.h | 3a6b115db4b53ac92a0705d23a4e7d206a3602d8 | [
"MIT"
] | permissive | cmu-db/noisepage | 97093adcc9474419e063fdd97a5aa7a7ea6f3150 | 79276e68fe83322f1249e8a8be96bd63c583ae56 | refs/heads/master | 2023-08-29T05:51:04.628704 | 2021-11-05T14:12:08 | 2021-11-05T14:12:08 | 140,325,970 | 1,245 | 287 | MIT | 2022-11-08T02:06:48 | 2018-07-09T18:22:34 | C++ | UTF-8 | C++ | false | false | 11,931 | h | sql_table_test_util.h | #pragma once
#include <algorithm>
#include <map>
#include <unordered_map>
#include <utility>
#include <vector>
#include "catalog/catalog.h"
#include "gtest/gtest.h"
#include "storage/garbage_collector.h"
#include "test_util/storage_test_util.h"
#include "test_util/test_harness.h"
#include "transaction/transaction_context.h"
#include "transaction/transaction_manager.h"
namespace noisepage {
class LargeSqlTableTestObject;
class RandomSqlTableTransaction;
using TupleEntry = std::pair<storage::TupleSlot, storage::ProjectedRow *>;
using TableSnapshot = std::unordered_map<storage::TupleSlot, storage::ProjectedRow *>;
using VersionedSnapshots = std::map<transaction::timestamp_t, TableSnapshot>;
/**
* Defines the test configurations to be used for a LargeSqlTableTestObject
*/
class LargeSqlTableTestConfiguration {
public:
/**
* Builder class for LargeSqlTableTestConfiguration
*/
class Builder {
public:
/**
* @param num_databases the number of databases in the generated test object
* @return self-reference for method chaining
*/
Builder &SetNumDatabases(uint16_t num_databases) {
builder_num_databases_ = num_databases;
return *this;
}
/**
* @param num_tables the number of tables PER DATABASE in the generated test object
* @return self-reference for method chaining
*/
Builder &SetNumTables(uint16_t num_tables) {
builder_num_tables_ = num_tables;
return *this;
}
/**
* @param max_columns the max number of columns in the generated test tables
* @return self-reference for method chaining
*/
Builder &SetMaxColumns(uint16_t max_columns) {
builder_max_columns_ = max_columns;
return *this;
}
/**
* @param initial_table_size number of tuples each table should have initially
* @return self-reference for method chaining
*/
Builder &SetInitialTableSize(uint32_t initial_table_size) {
builder_initial_table_size_ = initial_table_size;
return *this;
}
/**
* @param txn_length length of every simulated transaction, in number of operations (select or update)
* @return self-reference for method chaining
*/
Builder &SetTxnLength(uint32_t txn_length) {
builder_txn_length_ = txn_length;
return *this;
}
/**
* @param insert_update_select_delete_ratio the ratio of inserts vs. updates vs. select vs. deletes in the generated
* transaction (e.g. {0.1, 0.2, 0.6. 0.1} will be 10% inserts, 20% updates, 60% reads, and 10% deletes)
* @warning the number of deletes should not exceed the number of tuples inserted initially
* @return self-reference for method chaining
*/
Builder &SetInsertUpdateSelectDeleteRatio(std::vector<double> ratios) {
NOISEPAGE_ASSERT(ratios.size() == 4, "Ratio must have four values");
builder_insert_update_select_delete_ratio_ = std::move(ratios);
return *this;
}
/**
* @param varlen_allowed if we allow varlen columns to show up in the block layout
* @return self-reference for method chaining
*/
Builder &SetVarlenAllowed(bool varlen_allowed) {
builder_varlen_allowed_ = varlen_allowed;
return *this;
}
/**
* @return the constructed LargeSqlTableTestConfiguration using the parameters provided
* (or default ones if not supplied).
*/
LargeSqlTableTestConfiguration Build() {
return {builder_num_databases_, builder_num_tables_, builder_max_columns_,
builder_initial_table_size_, builder_txn_length_, builder_insert_update_select_delete_ratio_,
builder_varlen_allowed_};
}
private:
uint16_t builder_num_databases_ = 1;
uint16_t builder_num_tables_ = 1;
uint16_t builder_max_columns_ = 25;
uint32_t builder_initial_table_size_ = 25;
uint32_t builder_txn_length_ = 25;
std::vector<double> builder_insert_update_select_delete_ratio_;
bool builder_varlen_allowed_ = false;
};
/**
* @param num_databases number of databases to create
* @param num_tables number of tables per database to create
* @param max_columns the max number of columns in each generated test table
* @param initial_table_size number of tuples each table should have
* @param txn_length length of every simulated transaction, in number of operations (select or update)
* @param insert_update_select_delete_ratio the ratio of inserts vs. updates vs. select vs. deletes in the generated
* transaction (e.g. {0.1, 0.2, 0.6. 0.1} will be 10% inserts, 20% updates, 60% reads, and 10% deletes)
* @param varlen_allowed true if varlen columns are allowed
*/
LargeSqlTableTestConfiguration(const uint16_t num_databases, const uint16_t num_tables, const uint16_t max_columns,
const uint32_t initial_table_size, const uint32_t txn_length,
std::vector<double> insert_update_select_delete_ratio, const bool varlen_allowed)
: num_databases_(num_databases),
num_tables_(num_tables),
max_columns_(max_columns),
initial_table_size_(initial_table_size),
txn_length_(txn_length),
insert_update_select_delete_ratio_(std::move(insert_update_select_delete_ratio)),
varlen_allowed_(varlen_allowed) {}
private:
friend class LargeSqlTableTestObject;
uint16_t num_databases_;
uint16_t num_tables_;
uint16_t max_columns_;
uint32_t initial_table_size_;
uint32_t txn_length_;
std::vector<double> insert_update_select_delete_ratio_;
bool varlen_allowed_;
};
/**
* A RandomSqlTableTransaction class provides a simple interface to simulate a transaction that interfaces with the
* SqlTable layer running in the system. Does not provide bookkeeping for correctness functionality.
*/
class RandomSqlTableTransaction {
public:
/**
* Initializes a new RandomSqlTableTransaction to work on the given test object
* @param test_object the test object that runs this transaction
*/
explicit RandomSqlTableTransaction(LargeSqlTableTestObject *test_object);
/**
* Destructs a random workload transaction. Does not delete underlyign txn,
* garbage collection will clean that up.
*/
~RandomSqlTableTransaction() = default;
/**
* Inserts a tuple with random data, using the given generator as source of randomness.
*
* @tparam Random the type of random generator to use
* @param generator the random generator to use
*/
template <class Random>
void RandomInsert(Random *generator);
/**
* Randomly updates a tuple, using the given generator as source of randomness.
*
* @tparam Random the type of random generator to use
* @param generator the random generator to use
*/
template <class Random>
void RandomUpdate(Random *generator);
/**
* Randomly deletes a tuple, using the given generator as source of randomness.
*
* @tparam Random the type of random generator to use
* @param generator the random generator to use
*/
template <class Random>
void RandomDelete(Random *generator);
/**
* Randomly selects a tuple, using the given generator as source of randomness.
*
* @tparam Random the type of random generator to use
* @param generator the random generator to use
*/
template <class Random>
void RandomSelect(Random *generator);
/**
* Finish the simulation of this transaction. The underlying transaction will either commit or abort.
*/
void Finish();
private:
friend class LargeSqlTableTestObject;
LargeSqlTableTestObject *test_object_;
transaction::TransactionContext *txn_;
// extra bookkeeping for abort count
bool aborted_;
// We defer adding our inserted tuples into our test objects metadata until we commit
std::unordered_map<catalog::db_oid_t, std::unordered_map<catalog::table_oid_t, std::vector<storage::TupleSlot>>>
inserted_tuples_;
};
// TODO(Gus): Add indexes
/**
* A LargeSqlTableTestObject can bootstrap multiple databases and tables, and runs randomly generated workloads
* concurrently against the tables to simulate a real run of the system.
*
* The test object supports, updates, selects, and deletes
*/
class LargeSqlTableTestObject {
private:
/*
* Holds meta data for tables created by test object
*/
struct SqlTableMetadata {
// Column oids for this table. We cache them to generate random updates. They never change because we don't make ddl
// changes
std::vector<catalog::col_oid_t> col_oids_;
// Tuple slots inserted into this sql table
std::vector<storage::TupleSlot> inserted_tuples_;
// Latch to protect inserted tuples to allow for concurrent transactions
common::SpinLatch inserted_tuples_latch_;
// Buffer for select queries. Not thread safe, but since we aren't doing bookkeeping, it doesn't matter
byte *buffer_;
};
public:
/**
* Initializes a test object with the given configuration
* @param test configuration object
* @param txn_manager txn manager to use for test object
* @param catalog catalog to use for test object
* @param block_store block store for table creation
* @param generator the random generator to use for the test
*/
LargeSqlTableTestObject(const LargeSqlTableTestConfiguration &config, transaction::TransactionManager *txn_manager,
catalog::Catalog *catalog, storage::BlockStore *block_store,
std::default_random_engine *generator);
/**
* Destructs a LargeSqlTableTestObject
*/
~LargeSqlTableTestObject();
/**
* Simulate an oltp workload, running the specified number of total transactions while allowing the specified number
* of transactions to run concurrently. Transactions are generated using the configuration provided on construction.
*
* @param num_transactions total number of transactions to run
* @param num_concurrent_txns number of transactions allowed to run concurrently
* @return number of aborted transactions
*/
uint64_t SimulateOltp(uint32_t num_transactions, uint32_t num_concurrent_txns);
/**
* @return map of databases to tables created by the test object
*/
const std::unordered_map<catalog::db_oid_t, std::vector<catalog::table_oid_t>> &GetTables() const {
return table_oids_;
}
const std::vector<storage::TupleSlot> &GetTupleSlotsForTable(catalog::db_oid_t db_oid,
catalog::table_oid_t table_oid) {
NOISEPAGE_ASSERT(tables_.find(db_oid) != tables_.end(), "Requested database was not created");
NOISEPAGE_ASSERT(tables_[db_oid].find(table_oid) != tables_[db_oid].end(), "Requested table was not created");
return tables_[db_oid][table_oid]->inserted_tuples_;
}
private:
void SimulateOneTransaction(RandomSqlTableTransaction *txn, uint32_t txn_id);
template <class Random>
void PopulateInitialTables(uint16_t num_databases, uint16_t num_tables, uint16_t max_columns, uint32_t num_tuples,
bool varlen_allowed, storage::BlockStore *block_store, Random *generator);
friend class RandomSqlTableTransaction;
FRIEND_TEST(RecoveryTests, DoubleRecoveryTest);
uint32_t txn_length_;
std::vector<double> insert_update_select_delete_ratio_;
std::default_random_engine *generator_;
transaction::TransactionManager *txn_manager_;
catalog::Catalog *catalog_;
transaction::TransactionContext *initial_txn_;
uint64_t abort_count_ = 0;
// So we can easily get a random database and table oid
std::vector<catalog::db_oid_t> database_oids_;
std::unordered_map<catalog::db_oid_t, std::vector<catalog::table_oid_t>> table_oids_;
// Maps database and table oids to struct holding testing metadata for each table
std::unordered_map<catalog::db_oid_t, std::unordered_map<catalog::table_oid_t, SqlTableMetadata *>> tables_;
};
} // namespace noisepage
|
a316010bc71ac176d0341b83f65a7ab11075375a | 86b1592303ea98c738d317cadcd1e5605931428b | /tf2/detours.cpp | 6ba9c05088307da032916d512983eb0e5708642c | [] | no_license | JeremyDF93/nyxtools | abdfa0f3d88e4ce5ab56b8bc6beab34db6aface2 | 306f8f0bc9cfecd8c1fbb43570a9b86535691fb5 | refs/heads/master | 2022-02-28T06:35:41.892042 | 2022-01-31T02:51:35 | 2022-01-31T02:51:35 | 229,148,116 | 5 | 1 | null | 2020-11-11T21:44:06 | 2019-12-19T22:23:25 | SourcePawn | UTF-8 | C++ | false | false | 3,195 | cpp | detours.cpp | #include "detours.h"
#include "tf2/tf2.h"
CDetour *Detour_EventKilled = nullptr;
CDetour *Detour_CycleMission = nullptr;
CDetour *Detour_GameModeUsesUpgrades = nullptr;
CDetour *Detour_ClientCommandKeyValues = nullptr;
IForward *g_pFwdEventKilled = nullptr;
class CTakeDamageInfo;
DETOUR_DECL_MEMBER1(EventKilled, void, CTakeDamageInfo const&, info) {
if (!g_bUpgradesEnabled || !g_bReviveEnabled) {
DETOUR_MEMBER_CALL(EventKilled)(info);
return;
}
bool &m_bPlayingMannVsMachine = *(bool *)((intptr_t)gamerules + g_iPlayingMannVsMachineOffs);
bool orig = m_bPlayingMannVsMachine;
m_bPlayingMannVsMachine = true;
DETOUR_MEMBER_CALL(EventKilled)(info);
m_bPlayingMannVsMachine = orig;
}
DETOUR_DECL_MEMBER0(CycleMission, void) {
if (!g_bUpgradesEnabled) {
DETOUR_MEMBER_CALL(CycleMission)();
return;
}
g_pSM->LogMessage(myself, "Blocking CPopulationManager::CycleMission");
}
DETOUR_DECL_MEMBER0(GameModeUsesUpgrades, bool) {
if (!g_bUpgradesEnabled) {
return DETOUR_MEMBER_CALL(GameModeUsesUpgrades)();
}
//g_pSM->LogMessage(myself, "Blocking CTFGameRules::GameModeUsesUpgrades");
return true;
}
DETOUR_DECL_MEMBER2(ClientCommandKeyValues, void, edict_t *, pEntity, KeyValues *, pCommand) {
if (!g_bUpgradesEnabled) {
DETOUR_MEMBER_CALL(ClientCommandKeyValues)(pEntity, pCommand);
return;
}
bool &m_bPlayingMannVsMachine = *(bool *)((intptr_t)gamerules + g_iPlayingMannVsMachineOffs);
bool orig = m_bPlayingMannVsMachine;
m_bPlayingMannVsMachine = true;
DETOUR_MEMBER_CALL(ClientCommandKeyValues)(pEntity, pCommand);
m_bPlayingMannVsMachine = orig;
}
void CreateDetours() {
Detour_EventKilled = DETOUR_CREATE_MEMBER(EventKilled, "CTFPlayer::Event_Killed");
if (Detour_EventKilled != nullptr) {
Detour_EventKilled->EnableDetour();
} else {
g_pSM->LogError(myself, "Failed to get signature for CTFPlayer::Event_Killed");
}
Detour_CycleMission = DETOUR_CREATE_MEMBER(CycleMission, "CPopulationManager::CycleMission");
if (Detour_CycleMission != nullptr) {
Detour_CycleMission->EnableDetour();
} else {
g_pSM->LogError(myself, "Failed to get signature for CPopulationManager::CycleMission");
}
Detour_GameModeUsesUpgrades = DETOUR_CREATE_MEMBER(GameModeUsesUpgrades, "CTFGameRules::GameModeUsesUpgrades");
if (Detour_GameModeUsesUpgrades != nullptr) {
Detour_GameModeUsesUpgrades->EnableDetour();
} else {
g_pSM->LogError(myself, "Failed to get signature for CTFGameRules::GameModeUsesUpgrades");
}
Detour_ClientCommandKeyValues = DETOUR_CREATE_MEMBER(ClientCommandKeyValues, "CServerGameClients::ClientCommandKeyValues");
if (Detour_ClientCommandKeyValues != nullptr) {
Detour_ClientCommandKeyValues->EnableDetour();
} else {
g_pSM->LogError(myself, "Failed to get signature for CServerGameClients::ClientCommandKeyValues");
}
}
void DestroyDetours() {
if (Detour_EventKilled) Detour_EventKilled->Destroy();
if (Detour_CycleMission) Detour_CycleMission->Destroy();
if (Detour_GameModeUsesUpgrades) Detour_GameModeUsesUpgrades->Destroy();
if (Detour_ClientCommandKeyValues) Detour_ClientCommandKeyValues->Destroy();
}
|
7a1bdc031ddde3ced651ec72ceb24da42f66b5af | 24ec559a976ba67e46daeaf576997c9603e814ae | /GRS_Pro/GRS_Core/source/GRS_SharedMemory.cpp | 7a2c9fca09902684456afaebf8296f812de54ac5 | [] | no_license | chxb1987/GSK_Robot_Sys | 6147f64e7905513de46ae5a5b15a33cc92aab7c2 | 6452ff993b9fac70f62bd5f3782990a714712d61 | refs/heads/master | 2020-04-14T22:11:13.675860 | 2018-06-22T05:17:55 | 2018-06-22T05:17:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,149 | cpp | GRS_SharedMemory.cpp | #define SHAREDMEMORY_GLOBALS
#include "GRS_SharedMemory.h"
#include <QtGlobal>
#ifdef Q_OS_LINUX
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#elif defined(Q_OS_WIN)
#include <Windows.h>
#define pwstr_size 32
//存放文件映射对象的句柄,因为释放时需要用到,所以做成全局变量。
static HANDLE hFileMapping_InputData;
static HANDLE hFileMapping_OutputData;
static HANDLE hFileMapping_MotSetData;
#endif
typedef enum{
SHM_InputData,
SHM_OutputData,
SHM_MotSetData
}SharedMemoryTypes;
#ifdef Q_OS_LINUX
void getSharedMemory_linux(SharedMemoryTypes type, void **pSharedMemory)
{
int shmid = 0;
int shmflg = 0;
// Open a shared memory, not create.
switch (type) {
case SHM_InputData:
shmid = shmget(ITP_Key_InputShareMem, sizeof(ITP_InputData), 0666);
break;
case SHM_OutputData:
{ // read only
shmid = shmget(ITP_Key_OutputShareMem, sizeof(ITP_OutputData), 0444);
shmflg = SHM_RDONLY;
}
break;
case SHM_MotSetData:
shmid = shmget(ITP_Key_ParaShareMem, sizeof(ITP_MotSetData), 0666);
break;
default:
shmid = -1;
break;
}
// Attache the shared memory segment to the address space of the calling process.
if(shmid > 0) {*pSharedMemory = shmat(shmid, NULL, shmflg);}
else {*pSharedMemory = NULL;}
}
#elif defined(Q_OS_WIN)
void getSharedMemory_win(SharedMemoryTypes type, void **pSharedMemory)
{
char *cstr;
DWORD dwDesiredAccess = FILE_MAP_READ | FILE_MAP_WRITE;
HANDLE *handle;
switch (type) {
case SHM_InputData:
{
cstr = "ITP_ShareMem_InputData";
handle = &hFileMapping_InputData;
}
break;
case SHM_OutputData:
{
cstr = "ITP_ShareMem_OutputData";
dwDesiredAccess = FILE_MAP_READ;
handle = &hFileMapping_OutputData;
}
break;
case SHM_MotSetData:
{
cstr = "ITP_ShareMem_MotSetData";
handle = &hFileMapping_MotSetData;
}
break;
default:
*pSharedMemory = NULL;
return;
}
/* ***** Type (char *) switch to type (wchar_t *) ***** */
size_t cstr_len = strlen(cstr);
size_t n = (size_t)MultiByteToWideChar(CP_ACP,0,(const char*)cstr,(int)cstr_len,NULL,0);
wchar_t pwstr[pwstr_size];
if(n>=pwstr_size) n = pwstr_size-1;
MultiByteToWideChar(CP_ACP,0,(const char*)cstr,(int)cstr_len,pwstr,(int)n);
pwstr[n]=0;
/* ***** switch over ***** */
//尝试打开指定命名的共享内存,获取相应对象的句柄
*handle = OpenFileMapping(dwDesiredAccess, 0, pwstr);
if(NULL != *handle)//判断句柄是否指向有效的命名对象,否则初始化失败
{
// 将文件映射内核对象handle映射到当前应用程序的进程地址
*pSharedMemory = MapViewOfFile(*handle, dwDesiredAccess, 0, 0, 0);
}
else {*pSharedMemory = NULL;}
}
#endif
/*
* @brief 共享内存初始化函数
*
* @param 无
*
* @return 成功返回0,失败返回1
*
* @description 平台无关的共享内存初始化函数,该版本只支持LINUX和WINDOWS两类操作系统,
* 用于打开插补模块提供的共享内存,并连接到本地全局变量。
*/
int G_SharedMemoryInit()
{
#ifdef Q_OS_LINUX
getSharedMemory_linux(SHM_InputData, (void **)&pInputData);
getSharedMemory_linux(SHM_OutputData, (void **)&pOutputData);
getSharedMemory_linux(SHM_MotSetData, (void **)&pMotSetData);
#elif defined(Q_OS_WIN)
getSharedMemory_win(SHM_InputData, (void **)&pInputData);
getSharedMemory_win(SHM_OutputData, (void **)&pOutputData);
getSharedMemory_win(SHM_MotSetData, (void **)&pMotSetData);
#else
// This version only support LINUX and WINDOWS operating system.
qDebug("Sorry, the application don't suit for your OS.");
return 1;
#endif
// As long as one of above shared memory attached unsuccessfully, it would be return 1,
// i.e, those shared memorys initialize failed. You have to recall this function if you don't want to exit.
if(pInputData == NULL || pOutputData == NULL || pMotSetData == NULL)
{
G_SharedMemoryCleanup();
qDebug("Shared Memory Initialization Failed!");
return 1;
}
return 0;
}
void G_SharedMemoryCleanup()
{
#ifdef Q_QS_LINUX
if(NULL != pInputData) {shmdt(pInputData);}
if(NULL != pOutputData) {shmdt(pOutputData);}
if(NULL != pMotSetData) {shmdt(pMotSetData);}
return ;
#elif defined(Q_OS_WIN)
if(NULL != pInputData) {UnmapViewOfFile(pInputData);}
if(NULL != pOutputData) {UnmapViewOfFile(pOutputData);}
if(NULL != pMotSetData) {UnmapViewOfFile(pMotSetData);}
if(NULL != hFileMapping_InputData)
{
CloseHandle(hFileMapping_InputData);
hFileMapping_InputData = NULL;
}
if(NULL != hFileMapping_OutputData)
{
CloseHandle(hFileMapping_OutputData);
hFileMapping_OutputData = NULL;
}
if(NULL != hFileMapping_MotSetData)
{
CloseHandle(hFileMapping_MotSetData);
hFileMapping_MotSetData = NULL;
}
return ;
#endif
}
|
6768aec58ebf30dc87ac57cacd737e80ede41774 | fd0588bba5f7922079b6b5c4d5e7d84eaf643dbe | /Project/JSONExercise/JSONExercise/JSONExercise/JSON.cpp | b3fc68fdd23d2473f3c776d8fa23cbf901f48d8b | [] | no_license | Bandyck/Serious2DProject | 154ecc2f9a9d3010dd0c0320c3296d135cc1912b | 6c7b83f7b2dc2bb8cafa00d764b45172d2f9bdd3 | refs/heads/master | 2022-12-04T07:27:48.877810 | 2020-08-31T08:26:22 | 2020-08-31T08:26:22 | 291,211,349 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 6,043 | cpp | JSON.cpp | #define _CRT_SECURE_NO_WARNINGS // fopen 보안 경고로 인한 컴파일 에러 방지
#include <stdio.h> // 파일 처리 함수가 선언된 헤더 파일
#include <stdlib.h> // malloc, free 함수가 선언된 헤더 파일
#include <stdbool.h> // bool, true, false가 정의된 헤더 파일
#include <string.h> // strchr, memset, memcpy 함수가 선언된 헤더 파일
#include <string>
#include <iostream>
using namespace std;
// 토큰 종류 열거형
typedef enum _TOKEN_TYPE {
TOKEN_STRING, // 문자열 토큰
TOKEN_NUMBER, // 숫자 토큰
} TOKEN_TYPE;
// 토큰 구조체
typedef struct _TOKEN {
TOKEN_TYPE type; // 토큰 종류
union { // 두 종류 중 한 종류만 저장할 것이므로 공용체로 만듦
char *string; // 문자열 포인터
double number; // 실수형 숫자
};
bool isArray; // 현재 토큰이 배열인지 표시
} TOKEN;
#define TOKEN_COUNT 400 // 토큰의 최대 개수
// JSON 구조체
typedef struct _JSON {
TOKEN tokens[TOKEN_COUNT]; // 토큰 배열
} JSON;
char *readFile(char *filename, int *readSize) // 파일을 읽어서 내용을 반환하는 함수
{
FILE *fp = fopen(filename, "rb");
if (fp == NULL)
return NULL;
int size;
char *buffer;
// 파일 크기 구하기
fseek(fp, 0, SEEK_END);
size = ftell(fp);
fseek(fp, 0, SEEK_SET);
// 파일 크기 + NULL 공간만큼 메모리를 할당하고 0으로 초기화
buffer = (char *)malloc(size + 1);
memset(buffer, 0, size + 1);
// 파일 내용 읽기
if (fread(buffer, size, 1, fp) < 1)
{
*readSize = 0;
free(buffer);
fclose(fp);
return NULL;
}
// 파일 크기를 넘겨줌
*readSize = size;
fclose(fp); // 파일 포인터 닫기
return buffer;
}
void parseJSON(char *doc, int size, JSON *json) // JSON 파싱 함수
{
int tokenIndex = 0; // 토큰 인덱스
int pos = 0; // 문자 검색 위치를 저장하는 변수
if (doc[pos] != '[') // 문서의 시작이 [ 인지 검사
return;
pos++; // 다음 문자로
if (doc[pos] != '{') // 다음 문자가 { 인지 검사
return;
while (pos < size) // 문서 크기만큼 반복
{
switch (doc[pos]) // 문자의 종류에 따라 분기
{
case '"': // 문자가 "이면 문자열
{
// 문자열의 시작 위치를 구함. 맨 앞의 "를 제외하기 위해 + 1
char *begin = doc + pos + 1;
// 문자열의 끝 위치를 구함. 다음 "의 위치
char *end = strchr(begin, '"');
if (end == NULL) // "가 없으면 잘못된 문법이므로
break; // 반복을 종료
int stringLength = end - begin; // 문자열의 실제 길이는 끝 위치 - 시작 위치
// 토큰 배열에 문자열 저장, 토큰 종류는 문자열
json->tokens[tokenIndex].type = (_TOKEN_TYPE)TOKEN_STRING;
// 문자열 길이 + NULL 공간만큼 메모리 할당
json->tokens[tokenIndex].string = (char*)malloc(stringLength + 1);
// 할당한 메모리를 0으로 초기화
memset(json->tokens[tokenIndex].string, 0, stringLength + 1);
// 문서에서 문자열을 토큰에 저장
// 문자열 시작 위치에서 문자열 길이만큼만 복사
memcpy(json->tokens[tokenIndex].string, begin, stringLength);
tokenIndex++; // 토큰 인덱스 증가
pos = pos + stringLength + 1; // 현재 위치 + 문자열 길이 + "(+ 1)
}
break;
case '0': case '1': case '2': case '3': case '4': case '5': // 문자가 숫자이면
case '6': case '7': case '8': case '9': case '-': // -는 음수일 때
{
// 문자열의 시작 위치를 구함
char *begin = doc + pos;
char *end;
char *buffer;
// 문자열의 끝 위치를 구함. ,가 나오거나
end = strchr(doc + pos, ',');
if (end == NULL)
{
// } 가 나오면 문자열이 끝남
end = strchr(doc + pos, '}');
if (end == NULL) // }가 없으면 잘못된 문법이므로
break; // 반복을 종료
}
int stringLength = end - begin; // 문자열의 실제 길이는 끝 위치 - 시작 위치
// 문자열 길이 + NULL 공간만큼 메모리 할당
buffer = (char*)malloc(stringLength + 1);
// 할당한 메모리를 0으로 초기화
memset(buffer, 0, stringLength + 1);
// 문서에서 문자열을 버퍼에 저장
// 문자열 시작 위치에서 문자열 길이만큼만 복사
memcpy(buffer, begin, stringLength);
// 토큰 종류는 숫자
json->tokens[tokenIndex].type = TOKEN_NUMBER;
// 문자열을 숫자로 변환하여 토큰에 저장
json->tokens[tokenIndex].number = atof(buffer);
free(buffer); // 버퍼 해제
tokenIndex++; // 토큰 인덱스 증가
pos = pos + stringLength + 1; // 현재 위치 + 문자열 길이 + , 또는 }(+ 1)
}
break;
}
pos++; // 다음 문자로
}
}
void freeJSON(JSON *json) // JSON 해제 함수
{
for (int i = 0; i < TOKEN_COUNT; i++) // 토큰 개수만큼 반복
{
if (json->tokens[i].type == TOKEN_STRING) // 토큰 종류가 문자열이면
free(json->tokens[i].string); // 동적 메모리 해제
}
}
int main()
{
int size; // 문서 크기
// 파일에서 JSON 문서를 읽음, 문서 크기를 구함
char *doc = readFile("Problem.json", &size);
if (doc == NULL)
return -1;
JSON json; // JSON 구조체 변수 선언 및 초기화
parseJSON(doc, size, &json); // JSON 문서 파싱
cout << json.tokens[5].string << endl;
cout << json.tokens[25].string << endl;
//printf("Title: %s\n", json.tokens[1].string); // 토큰에 저장된 문자열 출력(Title)
//printf("Genre: %s\n", json.tokens[3].string); // 토큰에 저장된 문자열 출력(Genre)
//printf("Director: %s\n", json.tokens[5].string); // 토큰에 저장된 문자열 출력(Director)
freeJSON(&json); // json 안에 할당된 동적 메모리 해제
free(doc); // 문서 동적 메모리 해제
return 0;
} |
a77f0d34ff2f32d6a604822ca070749057817f7e | b60514dc246386144edb585eb7d9c0c92bd548de | /Maths for Games/Week 1/Maths For Games/UnitTest/UnitTest/Matrix2.cpp | c37ab4c89fb1e4611ed332a6d0bf9660c07813f6 | [] | no_license | sammydeedge/AIE2018 | 9addce918bf010ae840cdf294ba4077ae5bdeff7 | b23ce54e4572df3c00ad8517498cd11c47a41df2 | refs/heads/master | 2020-03-31T19:41:40.338376 | 2018-10-22T23:17:39 | 2018-10-22T23:17:39 | 141,961,746 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,340 | cpp | Matrix2.cpp | #include "Matrix2.h"
Matrix2::Matrix2()
{
mm[0][0] = 1; //Each Matrix is 3 rows, 3 columns, first number is column, second is row
mm[0][1] = 0;
mm[1][0] = 0;
mm[1][1] = 1;
}
Matrix2::Matrix2(float Xx, float Xy,float Yx, float Yy)
{
mm[0][0] = Xx; //Each Matrix is 3 rows, 3 columns, first number is column, second is row
mm[0][1] = Xy;
mm[1][0] = Yx;
mm[1][1] = Yy;
}
Vector2& Matrix2::operator [] (int index)
{
return axis[index];
}
Matrix2::operator float* () { return &m[0]; }
Matrix2::operator const float* () const { return &m[0]; }
Matrix2 Matrix2::operator * (const Matrix2& other) const
{
Matrix2 result;
for (int c = 0; c < 2; ++c)
{
for (int r = 0; r < 2; ++r)
{
result.mm[c][r] = mm[0][r] * other.mm[c][0] + mm[1][r] * other.mm[c][1];
}
}
return result;
}
Vector2 Matrix2::operator * (const Vector2& vect) const
{
Vector2 result;
for (int r = 0; r < 2; ++r)
{
result.data[r] = mm[0][r] * vect[0] + mm[1][r] * vect[1];
}
return result;
}
Matrix2& Matrix2::operator=(const Matrix2& other)
{
for (int c = 0; c < 2; ++c)
{
for (int r = 0; r < 2; ++r)
{
mm[r][c] = other.mm[r][c];
}
}
return *this;
}
//Sets rotational matrix for given angle
void Matrix2::setRotate(float angle)
{
mm[0][0] = cos(angle);
mm[0][1] = sin(angle);
mm[1][0] = -sin(angle);
mm[1][1] = cos(angle);
} |
97fc85d23aa3d98379a07dd44720b7af1c1676bb | 0930b1a1538f3fabd74c792983f71ba71a79decc | /SceneEnhancement/DecorationModel.cpp | ca439e367f8a79fa6b62839e10e00a81bf5c43ae | [] | no_license | zhsuiy/SmallObjectArrangementQtCpp | c097b9f47eed27ca3564bb1abfb8a4420670936e | d156127b61d1fbc374247fc8dbef981fdc3e3429 | refs/heads/master | 2021-05-08T20:06:55.912263 | 2018-04-11T19:05:17 | 2018-04-11T19:05:17 | 119,594,433 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 3,405 | cpp | DecorationModel.cpp | #include "DecorationModel.h"
#include "Utility.h"
#include "Assets.h"
#include "Parameter.h"
DecorationModel::DecorationModel(QString furnitureType, QString decType,
QVector<DecorationLocationType> locTypes, float scale, QVector3D relativeTranslate, QString path)
:Model()
{
Type = decType;
SupportModelType = furnitureType;
SupportModel = Assets::GetAssetsInstance()->GetFurnitureModelByType(SupportModelType);
SupportModel->AddDecorationModel(this); // add current decoration model to furniture model
m_translate = SupportModel->GetTranslate();
m_rotate = SupportModel->GetRotate();
m_scale = scale;
//m_relative_translate = SupportModel->GetRelativePosition(this);
m_relative_translate = relativeTranslate;
// set locationtype
LocationTypes =locTypes;
QString modelPath;
if (path.compare("Random") == 0)
modelPath = Utility::GetDecorationModelPath(decType);
else
modelPath = Utility::GetDecorationModelPath(decType,path);
this->loadModel(modelPath);
//directory = modelPath;
//this->updateVertexPosition();
//m_relative_translate = SupportModel->GetRelativePosition(this);
init(); // update normal and boundingbox
this->SetModelMatrix(); // setup modelmatrix for rendering
this->UpdateBoundingBoxWorldCoordinates();
}
DecorationModel::DecorationModel(QString decType, float scale, QString& path)
:Model()
{
IsAssigned = false;
Type = decType;
//SupportModelType = furnitureType;
//SupportModel = Assets::GetAssetsInstance()->GetFurnitureModelByType(SupportModelType);
//SupportModel->AddDecorationModel(this); // add current decoration model to furniture model
//m_translate = SupportModel->GetTranslate();
//m_rotate = SupportModel->GetRotate();
m_scale = scale;
//m_relative_translate = SupportModel->GetRelativePosition(this);
//m_relative_translate = relativeTranslate;
// set locationtype
//LocationTypes = locTypes;
QString modelPath = Utility::GetDecorationModelPath(decType, path);
Name = path;
this->loadModel(modelPath);
//directory = modelPath;
init(); // update normal and boundingbox
this->SetModelMatrix(); // setup modelmatrix for rendering
this->UpdateBoundingBoxWorldCoordinates();
}
void DecorationModel::SetModelMatrix()
{
modelMatrix.setToIdentity();
modelMatrix.translate(m_translate);
// 旋转本来是在这里
modelMatrix.translate(m_relative_translate);
modelMatrix.scale(m_scale);
// 改到了这里
modelMatrix.rotate(m_rotate.x(), 1, 0, 0);
modelMatrix.rotate(m_rotate.y(), 0, 1, 0);
modelMatrix.rotate(m_rotate.z(), 0, 0, 1);
}
void DecorationModel::Draw(QOpenGLShaderProgram* program)
{
program->setUniformValue("modelMatrix", modelMatrix);
if (Parameter::GetParameterInstance()->IsDrawDecorationModel)
{
for (int i = 0; i < meshes.size(); i++)
{
meshes[i]->Draw(program);
}
}
if (Parameter::GetParameterInstance()->IsDrawDecorationBoundingBox && boundingBox != nullptr)
{
boundingBox->Draw(program);
}
if (boundingBox != nullptr && IsSelected
&& Parameter::GetParameterInstance()->IsDrawSelectedBoundingBox)
{
boundingBox->Draw(program);
}
}
void DecorationModel::SetRelativeTranslate(float tx, float ty, float tz)
{
m_relative_translate.setX(tx);
m_relative_translate.setY(ty);
m_relative_translate.setZ(tz);
this->SetModelMatrix();
this->UpdateBoundingBoxWorldCoordinates();
}
QVector3D& DecorationModel::GetRelativeTranslate()
{
return m_relative_translate;
}
|
3d4570bd9eac136fb5dd40e0f3348fa34a36859b | 996d645e6df24cf3555d11b55fdbadb7dabf47da | /chart.h | f694bb8ee1c9e3eb7b3691d221debccb27ebcd4b | [] | no_license | cabalpit/lxcmanager | 09acd7f53d7a97bb34eb336b6c48750a1a438363 | 8d7ffe6f79900b763a60614948e89ba93e7155bc | refs/heads/master | 2023-09-05T16:04:32.993421 | 2021-11-26T00:32:16 | 2021-11-26T00:32:16 | 427,664,122 | 6 | 0 | null | 2021-11-26T00:37:45 | 2021-11-13T12:53:05 | C++ | UTF-8 | C++ | false | false | 1,081 | h | chart.h | #ifndef CHART_H
#define CHART_H
#include <QtCharts>
#include <QValueAxis>
#include <QSplineSeries>
#include <QVector>
#include <QDebug>
#include "businesslayer/monitorutils.h"
/*!
* \class Chart
* \brief The Chart class draw the spline series to chartview monitor.
* \vesion 1.0
* \since 2021-10-08
* \author Peter Cata
*
* The Chart class draw axis and lines to chart view. The lines are cpu and memory usage.
* The yAxis is bounded from 0 to 100%
*/
class Chart : public QChart
{
Q_OBJECT
public:
explicit Chart(QGraphicsItem *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
virtual ~Chart();
pid_t pid() const;
void setPid(pid_t pid);
int getStep() const;
void setStep(int step);
void setMaxSeconde(int second = 60);
public slots:
void updateChart(const QVector<businesslayer::Stats> &containerStat);
private:
pid_t m_pid;
QSplineSeries *m_cpuSeries;
QSplineSeries *m_memSeries;
QValueAxis *m_xAxis;
QValueAxis *m_yAxis;
int m_second;
int m_step;
int m_maxSecond;
};
#endif // CHART_H
|
fc68fc957d6988192bccc1111f72509ef75bbfc8 | 06567efe9fba2568cf6453c7afff2278ebd8f764 | /tests/test-nndt/test-nndt.cpp | 9572e78f95a221398846595611724353c92ea152 | [] | permissive | craigsapp/humlib | c2cf553cab58dd17a049d72f028197f4cddc5b12 | 9e633fb0ef8eeb4e713386afb57ecccdedc5cdbc | refs/heads/master | 2023-08-31T18:23:20.791857 | 2023-08-23T13:41:35 | 2023-08-23T13:41:35 | 40,472,572 | 28 | 9 | BSD-2-Clause | 2023-07-10T14:03:30 | 2015-08-10T08:50:40 | C++ | UTF-8 | C++ | false | false | 641 | cpp | test-nndt.cpp |
#include "humlib.h"
using namespace std;
using namespace hum;
void processFile(HumdrumFile& infile);
int main(int argc, char** argv) {
Options options;
options.process(argc, argv);
HumdrumFileStream instream(options);
HumdrumFile infile;
while (instream.read(infile)) {
processFile(infile);
}
return 0;
}
//////////////////////////////
//
// processFile --
//
void processFile(HumdrumFile& infile) {
infile.analyzeNonNullDataTokens();
for (int i=0; i<infile.getLineCount(); i++) {
HTp token = infile.token(i, 0);
cerr << "LINE " << i << endl;
cout << "\t" << infile[i] << "\t" << token->getNextNNDT() << endl;
}
}
|
1545396949acc512ffa3de99aab55786132a034d | 16f3ff84b858fcba990bfdd79dde1aed1cb23d79 | /stringTests.cpp | b2a6ba733fe07ad6217fe6e7216a65836b7683d6 | [] | no_license | yuuurchyk/Michael-Scott-Concurrent-Queue | 5aed6f2e0d155fa56186e70660385094cd18e1fd | 87ef6254a7855d98001c8a7ba82621c20380caf8 | refs/heads/master | 2022-02-12T08:08:35.728801 | 2019-08-27T10:41:27 | 2019-08-27T10:41:27 | 145,522,857 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,375 | cpp | stringTests.cpp | #include <string>
#include <set>
#include <thread>
#include <vector>
#include <functional>
#include <iostream>
#include <gtest/gtest.h>
#include "ConcurrentQueueBase/ConcurrentQueueBase.hpp"
#include "ConcurrentQueueSimple/ConcurrentQueueSimple.hpp"
#include "ConcurrentQueueExtended/ConcurrentQueueExtended.hpp"
template <typename T>
class ConcurrentQueueTest: public ::testing::Test { };
TYPED_TEST_CASE_P(ConcurrentQueueTest);
namespace{
const std::string kSampleText{"Loremipsumdolorsitamet,consecteturadipiscingelit.Utfelisante,portainullamcorperid,vehiculavelpurus.Prointristiqueconsecteturarcuutvenenatis.Etiammetusdiam,dictumsedmetuseget,consequatfinibuslorem.Inhachabitasseplateadictumst.Crasacmauriseuarcususcipiteuismod.Nullacursusliberonondapibuspellentesque.Suspendissepotenti.Aliquamvestibulumluctusdolor.Vestibulumnunclectus,rutrumutipsumac,tristiqueauctorneque.Maurisquisbibendumeros.Aliquameratvolutpat.Donecaliquamnisietligulahendrerit,idaccumsannuncfermentum.Suspendissepotenti.Proinaccumsannibhutnuncluctuseuismod.Utsitamettincidunttellus,sedfermentumurna."};
const std::string kPill{""};
size_t kSamplesNum{0};
const size_t kProducersNum{
std::max(
std::thread::hardware_concurrency() / 2,
static_cast<unsigned int>(1)
)
};
bool check(const std::string &s){
std::stringstream ss(s);
std::set<size_t> pieces{};
std::string current{};
while(ss >> current){
if(current != "Sample")
return false;
size_t currentPiece;
if(!(ss >> currentPiece))
return false;
if(pieces.find(currentPiece) != pieces.end())
return false;
pieces.insert(currentPiece);
if(!(ss >> current))
return false;
if(current != kSampleText)
return false;
}
return pieces.size() == kSamplesNum;
}
std::string generate(size_t pieceNum){
std::stringstream ss;
ss << "Sample " << pieceNum << " " << kSampleText << " ";
return ss.str();
}
void produce(size_t remainder, ConcurrentQueueBase<std::string> &target){
for(size_t i = remainder; i < kSamplesNum; i += kProducersNum)
target.push(generate(i));
}
void consume(ConcurrentQueueBase<std::string> &target){
std::string first{""}, second{""}, third{""};
std::unique_lock<std::recursive_mutex> lck(target.getPopMutex());
lck.unlock();
while(true){
lck.lock();
if(!target.tryPop(&first)){
// rule 1
lck.unlock();
continue;
}
if(!target.tryPop(&second)){
lck.unlock();
// rule 2
if(first == kPill)
return target.push(first);
// rule 3
target.push(first);
continue;
}
if(!target.tryPop(&third)){
lck.unlock();
// rule 4
if(
first == kPill ||
second == kPill
)
{
target.push(first);
target.push(second);
return;
}
// rule 5
target.push(first + second);
continue;
}
lck.unlock();
// make death pill be in third number
if(first == kPill)
std::swap(first, third);
if(second == kPill)
std::swap(second, third);
// rule 6
if(third != kPill){
target.push(first + second + third);
continue;
}
// rule 7
target.push(first + second);
target.push(third);
continue;
}
}
}
TYPED_TEST_P(ConcurrentQueueTest, Init){
// Check whether initialization is ok
TypeParam q;
}
TYPED_TEST_P(ConcurrentQueueTest, ConcatenationSequential){
// Check whether push is ok sequentially
TypeParam q{};
for(size_t i = 0; i < kSamplesNum; ++i)
q.push(generate(i));
std::string res{""};
for(size_t i = 0; i < kSamplesNum; ++i){
std::string current{""};
ASSERT_TRUE(q.tryPop(¤t));
res += current;
}
{
std::string dummy{""};
ASSERT_FALSE(q.tryPop(&dummy));
}
ASSERT_TRUE(check(res));
}
TYPED_TEST_P(ConcurrentQueueTest, ConcatenationMultiThreadProducer){
// Check whether push is ok
TypeParam q{};
std::vector<std::thread> producers{};
for(size_t i = 0; i < kProducersNum; ++i)
producers.push_back(std::thread(produce, i, std::ref(q)));
for(auto &producer: producers)
producer.join();
std::string res{""};
std::string current{""};
while(q.tryPop(¤t))
res += current;
ASSERT_TRUE(check(res));
}
TYPED_TEST_P(ConcurrentQueueTest, ConcatenationMPMC){
// Check whether push and pop work fine in parallel
// Logic and rules are the same as in tests.cpp AddNumbers test
TypeParam q{};
size_t
consumersNum = std::max(
std::thread::hardware_concurrency() / 2,
static_cast<unsigned int>(1)
);
std::vector<std::thread>
consumerThreads{},
producerThreads{};
for(size_t i = 0; i < kProducersNum; ++i)
producerThreads.push_back(std::thread(produce, i, std::ref(q)));
for(size_t i = 0; i < consumersNum; ++i)
consumerThreads.push_back(std::thread(consume, std::ref(q)));
for(auto &it: producerThreads)
it.join();
q.push(kPill);
for(auto &it: consumerThreads)
it.join();
std::string first{""}, second{""};
ASSERT_TRUE(q.tryPop(&first));
ASSERT_TRUE(q.tryPop(&second));
{
std::string dummy{""};
ASSERT_FALSE(q.tryPop(&dummy));
}
if(first == kPill)
std::swap(first, second);
ASSERT_TRUE(check(first));
}
REGISTER_TYPED_TEST_CASE_P(
ConcurrentQueueTest,
Init,
ConcatenationSequential,
ConcatenationMultiThreadProducer,
ConcatenationMPMC
);
typedef ::testing::Types<ConcurrentQueueSimple<std::string>, ConcurrentQueueExtended<std::string>> ConcurrentQueueTypes;
INSTANTIATE_TYPED_TEST_CASE_P(ConcurrentQueueInstantiation, ConcurrentQueueTest, ConcurrentQueueTypes);
int main(int argc, char **argv){
{
size_t defaultN = 100;
std::stringstream ss{""};
switch(argc){
case 0: case 1:
kSamplesNum = defaultN;
break;
case 2:
ss.str(*(++argv));
if(!(ss>>kSamplesNum))
throw std::runtime_error("Invalid argument");
--argv;
break;
default:
throw std::runtime_error("Invalid number of arguments");
break;
}
}
std::cout << "Testing:" << std::endl;
std::cout << "\tSamples num: " << kSamplesNum << std::endl;
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
70abf0b3d3494ca97f9d1c12de7190d53e5764bd | 548f96ccdb907a60dd745a8ed28277e1fb9596d5 | /main.cpp | 65e91f8a08e7e2abf0f325152c3d08052ac808ef | [] | no_license | YassirBouigherdaine/Tic-tac-toe-cpp | d75151bf1fc5e8e148e687a157a6046dce1124f0 | 2369357de4690160c733362c6423c5d7c16ce10f | refs/heads/main | 2023-01-12T08:18:22.029899 | 2020-11-13T14:27:11 | 2020-11-13T14:27:11 | 312,404,421 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 175 | cpp | main.cpp | // tic tac toe game
#include"game_func.h"
int main()
{
bool game_over = false;
draw_board();
while (!game_over)
{
game();
game_over = true;
}
return 0;
}
|
686af2f21386a44f4289b6104d911499b68c9c19 | 3bb7b3d39125d0f72d72ecdafe5806c7a30db525 | /片野裕哉/3Dゲーム制作/3D_GAME/wall.cpp | 184f109eb9755a013e570c1bb9e746c37a8b74e3 | [] | no_license | fu-ta-15/3DtameB | 58f272ee39cfd84d7bc4a0ee4dda145b58b7f1e4 | 75dc2e390c0d31e1207336dff124bf04c3346f0d | refs/heads/master | 2023-04-08T19:04:17.376418 | 2021-04-02T02:21:16 | 2021-04-02T02:21:16 | 314,190,199 | 0 | 0 | null | null | null | null | SHIFT_JIS | C++ | false | false | 9,925 | cpp | wall.cpp | //=========================================================================================================================
//
// 壁(ウォール) [wall.cpp]
// Author:Katano Hiroya
//
//=========================================================================================================================
#include "wall.h"
//
// マクロ定義
//
#define WALL_SIZE (200) // 壁の大きさ
#define WALL_X (2) // 壁の横
#define WALL_Y (2) // 壁の縦
//
// グローバル変数
//
LPDIRECT3DVERTEXBUFFER9 g_pVtxBuffWall = NULL; // 頂点バッファへのポインタ
LPDIRECT3DINDEXBUFFER9 g_pIdxBuffWall = NULL; // インデックスバッファへのポインタ
LPDIRECT3DTEXTURE9 g_pTextureWall = NULL; // テクスチャへのポインタ
Wall g_aWall[MAX_WALL]; // 壁の情報
//
// 初期化処理
//
HRESULT InitWall(void)
{
LPDIRECT3DDEVICE9 pDevice;
Wall *pWall = &g_aWall[0]; // 壁の構造体のポインタ
// デバイスの取得
pDevice = GetDevice();
for (int nCnt = 0; nCnt < MAX_WALL; nCnt++, pWall++)
{
pWall->pos = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
pWall->rot = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
pWall->bUse = false;
}
// テクスチャの読み込み
D3DXCreateTextureFromFile(pDevice, "data\\TEXTURE\\wall002.jpg", &g_pTextureWall);
// 頂点バッファの生成
if (FAILED(pDevice->CreateVertexBuffer(
sizeof(VERTEX_3D) * ((WALL_X + 1) * (WALL_Y + 1)) * MAX_WALL,
D3DUSAGE_WRITEONLY,
FVF_VERTEX_3D,
D3DPOOL_MANAGED,
&g_pVtxBuffWall,
NULL)))
{
return E_FAIL;
}
VERTEX_3D *pVtx; // 頂点情報へのポインタ
// 頂点バッファをロックし、頂点データへのポインタを取得
g_pVtxBuffWall->Lock(0, 0, (void**)&pVtx, 0);
for (int nCnt = 0; nCnt < MAX_WALL; nCnt++)
{
// 頂点座標の設定
pVtx[0].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
pVtx[1].pos = D3DXVECTOR3(pWall->pos.x - 0.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
pVtx[2].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
pVtx[3].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE / 2, pWall->pos.z);
pVtx[4].pos = D3DXVECTOR3(pWall->pos.x + 0.0f, pWall->pos.y + WALL_SIZE / 2, pWall->pos.z);
pVtx[5].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE / 2, pWall->pos.z);
pVtx[6].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y, pWall->pos.z);
pVtx[7].pos = D3DXVECTOR3(pWall->pos.x - 0.0f, pWall->pos.y, pWall->pos.z);
pVtx[8].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y, pWall->pos.z);
// 法線ベクトルの設定
pVtx[0].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[1].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[2].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[3].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[4].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[5].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[6].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[7].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
pVtx[8].nor = D3DXVECTOR3(0.0f, 0.0f, -1.0f);
// カラーの設定
pVtx[0].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[1].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[2].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[3].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[4].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[5].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[6].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[7].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
pVtx[8].col = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
// テクスチャ座標
pVtx[0].tex = D3DXVECTOR2(0.0f, 0.0f);
pVtx[1].tex = D3DXVECTOR2(1.0f, 0.0f);
pVtx[2].tex = D3DXVECTOR2(2.0f, 0.0f);
pVtx[3].tex = D3DXVECTOR2(0.0f, 1.0f);
pVtx[4].tex = D3DXVECTOR2(1.0f, 1.0f);
pVtx[5].tex = D3DXVECTOR2(2.0f, 1.0f);
pVtx[6].tex = D3DXVECTOR2(0.0f, 2.0f);
pVtx[7].tex = D3DXVECTOR2(1.0f, 2.0f);
pVtx[8].tex = D3DXVECTOR2(2.0f, 2.0f);
pVtx += ((WALL_X + 1) * (WALL_Y + 1));
}
// 頂点バッファをアンロックする
g_pVtxBuffWall->Unlock();
// インデックスバッファの生成
if (FAILED(pDevice->CreateIndexBuffer(
sizeof(WORD) * ((WALL_X * WALL_Y) * 3 + (WALL_Y - 1) * 2),
D3DUSAGE_WRITEONLY,
D3DFMT_INDEX16,
D3DPOOL_MANAGED,
&g_pIdxBuffWall,
NULL)))
{
return E_FAIL;
}
WORD *pIdx; // インデックス情報へのポインタ
// インデックスバッファをロックし、番号データへのポインタを取得
g_pIdxBuffWall->Lock(0, 0, (void**)&pIdx, 0);
// 番号データの設定
pIdx[0] = 3;
pIdx[1] = 0;
pIdx[2] = 4;
pIdx[3] = 1;
pIdx[4] = 5;
pIdx[5] = 2;
pIdx[6] = 2;
pIdx[7] = 6;
pIdx[8] = 6;
pIdx[9] = 3;
pIdx[10] = 7;
pIdx[11] = 4;
pIdx[12] = 8;
pIdx[13] = 5;
// インデックスバッファをアンロックする
g_pIdxBuffWall->Unlock();
for (int SetCntWall = 0; SetCntWall < 2; SetCntWall++)
{
SetWall(D3DXVECTOR3(-50.0f + WALL_SIZE * SetCntWall, 0.0f, 100.0f), D3DXVECTOR3(0.0f, 0.0f, 0.0f));
SetWall(D3DXVECTOR3(50.0f + -WALL_SIZE * SetCntWall, 0.0f, -100.0f), D3DXVECTOR3(0.0f, D3DX_PI, 0.0f));
SetWall(D3DXVECTOR3(100.0f, 0.0f, 50.0f + -WALL_SIZE * SetCntWall), D3DXVECTOR3(0.0f, D3DX_PI / 2, 0.0f));
SetWall(D3DXVECTOR3(-100.0f, 0.0f, -50.0f + WALL_SIZE * SetCntWall), D3DXVECTOR3(0.0f, -D3DX_PI / 2, 0.0f));
}
return S_OK;
}
//
// 終了処理
//
void UninitWall(void)
{
// テクスチャの開放
if (g_pTextureWall != NULL)
{
g_pTextureWall->Release();
g_pTextureWall = NULL;
}
// 頂点バッファの開放
if (g_pVtxBuffWall != NULL)
{
g_pVtxBuffWall->Release();
g_pVtxBuffWall = NULL;
}
// インデックスバッファの破棄
if (g_pVtxBuffWall != NULL)
{
g_pIdxBuffWall->Release();
g_pIdxBuffWall = NULL;
}
}
//
// 更新処理
//
void UpdateWall(void)
{
}
//
// 描画処理
//
void DrawWall(void)
{
LPDIRECT3DDEVICE9 pDevice = GetDevice(); // デバイスへのポインタ
Wall *pWall = &g_aWall[0]; // 壁の構造体のポインタ
D3DXMATRIX mtxRot, mtxTrans; // 計算用マトリックス
for (int nCnt = 0; nCnt < MAX_WALL; nCnt++, pWall++)
{
if (pWall->bUse == true)
{
// ワールドマトリックスの初期化
D3DXMatrixIdentity(&pWall->mtxWorld);
// 向きを反映
D3DXMatrixRotationYawPitchRoll(&mtxRot, pWall->rot.y, pWall->rot.x, pWall->rot.z);
D3DXMatrixMultiply(&pWall->mtxWorld, &pWall->mtxWorld, &mtxRot);
// 位置を反映
D3DXMatrixTranslation(&mtxTrans, pWall->pos.x, pWall->pos.y, pWall->pos.z);
D3DXMatrixMultiply(&pWall->mtxWorld, &pWall->mtxWorld, &mtxTrans);
// ワールドマトリックスの設定
pDevice->SetTransform(D3DTS_WORLD, &pWall->mtxWorld);
// 頂点バッファをデータストリームに設定
pDevice->SetStreamSource(0, g_pVtxBuffWall, 0, sizeof(VERTEX_3D));
// インデックスバッファをデータストリームに設定
pDevice->SetIndices(g_pIdxBuffWall);
// 頂点フォーマットの設定
pDevice->SetFVF(FVF_VERTEX_3D);
// テクスチャの設定
pDevice->SetTexture(0, g_pTextureWall);
// ポリゴンの描画
pDevice->DrawIndexedPrimitive(
D3DPT_TRIANGLESTRIP, // プリミティブの種類
0, //
0, //
((WALL_X + 1) * (WALL_Y + 1)), // 頂点の数
0, // 描画を開始する頂点インデックス
WALL_X * WALL_Y * 2 + (WALL_Y - 1) * 4); // 描画するプリミティブの数
}
}
}
//
// 壁の配置
//
void SetWall(D3DXVECTOR3 pos, D3DXVECTOR3 rot)
{
// 構造体のポインタ変数
Wall *pWall = &g_aWall[0];
for (int nCnt = 0; nCnt < MAX_WALL; nCnt++, pWall++)
{
if (pWall->bUse == false)
{
// 位置の設定
pWall->pos = pos;
// 角度の設定
pWall->rot = rot;
// 頂点座標の設定
SetVertexWall(nCnt);
// 使用状態をtrueにする
pWall->bUse = true;
break;
}
}
}
//-----------------------------------------------------------------
// 壁の頂点座標の設定
//-----------------------------------------------------------------
void SetVertexWall(int nIdx)
{
// 構造体のポインタ変数
VERTEX_3D *pVtx;
Wall *pWall = &g_aWall[0];
// 頂点バッファをロックし、頂点情報へのポインタを取得
g_pVtxBuffWall->Lock(0, 0, (void**)&pVtx, 0);
// 何番目か
pVtx += nIdx * ((WALL_X + 1) * (WALL_Y + 1));
pWall += nIdx;
// 頂点座標の設定
//pVtx[0].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y, pWall->pos.z);
//pVtx[1].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
//pVtx[2].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y, pWall->pos.z);
//pVtx[3].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
pVtx[0].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
pVtx[1].pos = D3DXVECTOR3(pWall->pos.x - 0.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
pVtx[2].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE, pWall->pos.z);
pVtx[3].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE / 2, pWall->pos.z);
pVtx[4].pos = D3DXVECTOR3(pWall->pos.x + 0.0f, pWall->pos.y + WALL_SIZE / 2, pWall->pos.z);
pVtx[5].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y + WALL_SIZE / 2, pWall->pos.z);
pVtx[6].pos = D3DXVECTOR3(pWall->pos.x - WALL_SIZE / 2.0f, pWall->pos.y, pWall->pos.z);
pVtx[7].pos = D3DXVECTOR3(pWall->pos.x - 0.0f, pWall->pos.y, pWall->pos.z);
pVtx[8].pos = D3DXVECTOR3(pWall->pos.x + WALL_SIZE / 2.0f, pWall->pos.y, pWall->pos.z);
// 頂点バッファをアンロックする
g_pVtxBuffWall->Unlock();
}
//
// 壁の取得
//
Wall *GetWall(void)
{
return &g_aWall[0];
}
|
33291a53cd4ffed8651ce2064f16750c38fffb60 | 4c1b73237eb1c9ea8dfca83ec1a0a1d3dd0fcb79 | /ArduinoLog.h | 6f05a50978dfd2527eff21d853f575d0b6cf61bb | [
"MIT"
] | permissive | georg-koch/Arduino-Log | ef6f9eeeb7ee810b4874ee849f635621cbba8b2d | 632ab6547531eb2ab0415e293b38a361e3bb021a | refs/heads/master | 2020-04-04T06:57:10.868101 | 2018-11-15T23:20:59 | 2018-11-15T23:20:59 | 155,763,211 | 0 | 1 | MIT | 2018-11-15T23:21:00 | 2018-11-01T19:10:00 | C++ | UTF-8 | C++ | false | false | 5,824 | h | ArduinoLog.h | /*
* MIT License <http://opensource.org/licenses/MIT>.
*/
#ifndef LOGGING_H
#define LOGGING_H
#include <inttypes.h>
#include <stdarg.h>
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
typedef void (*printfunction)(Print *);
#define LOG_LEVEL_SILENT 0
#define LOG_LEVEL_FATAL 1
#define LOG_LEVEL_ERROR 2
#define LOG_LEVEL_WARNING 3
#define LOG_LEVEL_DEBUG 4
#define LOG_LEVEL_TRACE 5
#define LOG_LEVEL_VERBOSE 6
#define CR "\n"
/*
Logging is a helper class to output informations over RS232.
Different loglevels can be used to extend or reduce output
All methods are able to handle any number of output parameters.
All methods print out a formated string (like printf).<br>
To reduce output and program size, reduce loglevel.
Output format string can contain wildcards:
- %s replace with an string (char*)
- %c replace with an character
- %d replace with an integer value
- %l replace with an long value
- %x replace and convert integer value into hex
- %X like %x but combine with 0x123AB
- %b replace and convert integer value into binary
- %B like %x but combine with 0b10100011
- %t replace and convert boolean value into "t" or "f"
- %T like %t but convert into "true" or "false"
Supported Loglevels:
- LOG_LEVEL_SILENT 0 no output
- LOG_LEVEL_FATAL 1 fatal errors
- LOG_LEVEL_ERROR 2 all errors
- LOG_LEVEL_WARNING 3 errors and warnings
- LOG_LEVEL_DEBUG 4 errors, warnings and debug
- LOG_LEVEL_TRACE 5 errors, warnings, debug, traces
- LOG_LEVEL_VERBOSE 6 all
*/
class Logging
{
private:
int _level;
bool _showLevel;
long _baud;
Print *_logOutput;
public:
/*!
* default Constructor
*/
Logging()
: _level(LOG_LEVEL_SILENT),
_showLevel(true),
_logOutput(NULL) {}
/**
* Initializing, must be called as first.
* @param level - logging levels <= this will be logged.
* @param baud - baud rate.
* @return void
*/
void init(int level, long baud);
/**
* Initializing, must be called as first. Note that if you use
* this variant of Init, you need to initialize the baud rate
* yourself, if printer happens to be a serial port.
* @param level - logging levels <= this will be logged.
* @param printer - place that logging output will be sent to.
* @return void
*/
void init(int level, Print *output, bool showLevel = true);
/**
* Sets a function to be called before each log command.
*/
void setPrefix(printfunction);
/**
* Sets a function to be called after each log command.
*/
void setSuffix(printfunction);
/**
* Output a fatal error message. Output message contains
* F: followed by original message
* Fatal error messages are printed out at
* loglevels >= LOG_LEVEL_FATAL
*
* @param msg format string to output
* @param ... any number of variables
* @return void
*/
template <class T, typename... Args>
void fatal(T msg, Args... args)
{
#ifndef DISABLE_LOGGING
printLevel(LOG_LEVEL_FATAL, msg, args...);
#endif
}
/**
* Output an error message. Output message contains
* E: followed by original message
* Error messages are printed out at
* loglevels >= LOG_LEVEL_ERROR
*
* @param msg format string to output
* @param ... any number of variables
* @return void
*/
template <class T, typename... Args>
void error(T msg, Args... args)
{
#ifndef DISABLE_LOGGING
printLevel(LOG_LEVEL_ERROR, msg, args...);
#endif
}
/**
* Output a warning message. Output message contains
* W: followed by original message
* Warning messages are printed out at
* loglevels >= LOG_LEVEL_WARNING
*
* @param msg format string to output
* @param ... any number of variables
* @return void
*/
template <class T, typename... Args>
void warning(T msg, Args... args)
{
#ifndef DISABLE_LOGGING
printLevel(LOG_LEVEL_WARNING, msg, args...);
#endif
}
/**
* Output a debug message. Output message contains
* N: followed by original message
* Debug messages are printed out at
* loglevels >= LOG_LEVEL_DEBUG
*
* @param msg format string to output
* @param ... any number of variables
* @return void
*/
template <class T, typename... Args>
void debug(T msg, Args... args)
{
#ifndef DISABLE_LOGGING
printLevel(LOG_LEVEL_DEBUG, msg, args...);
#endif
}
/**
* Output a trace message. Output message contains
* N: followed by original message
* Trace messages are printed out at
* loglevels >= LOG_LEVEL_TRACE
*
* @param msg format string to output
* @param ... any number of variables
* @return void
*/
template <class T, typename... Args>
void trace(T msg, Args... args)
{
#ifndef DISABLE_LOGGING
printLevel(LOG_LEVEL_TRACE, msg, args...);
#endif
}
/**
* Output a verbose message. Output message contains
* V: followed by original message
* Debug messages are printed out at
* loglevels >= LOG_LEVEL_VERBOSE
*
* @param msg format string to output
* @param ... any number of variables
* @return void
*/
template <class T, typename... Args>
void verbose(T msg, Args... args)
{
#ifndef DISABLE_LOGGING
printLevel(LOG_LEVEL_VERBOSE, msg, args...);
#endif
}
private:
void print(const char *format, va_list args);
void print(const __FlashStringHelper *format, va_list args);
void printFormat(const char format, va_list *args);
printfunction _prefix = NULL;
printfunction _suffix = NULL;
template <class T>
void printLevel(int level, T msg, ...)
{
#ifndef DISABLE_LOGGING
if (level <= _level)
{
if (_prefix != NULL)
_prefix(_logOutput);
if (_showLevel)
{
char levels[] = "FEWDTV";
_logOutput->print(levels[level - 1]);
_logOutput->print(": ");
}
va_list args;
va_start(args, msg);
print(msg, args);
if (_suffix != NULL)
_suffix(_logOutput);
}
#endif
}
};
extern Logging Log;
#endif
|
9b745d85fe8b9f79309211e62e76b12d09e3b7b8 | 539728625607833179a817f0f4f0cd7be977f3b5 | /Essence/Views.h | 7d64bf87df4420a509ff01379447cc3f3470cd2b | [] | no_license | goskatopudel/dx12sandbox | e4ce81476387b39ba4897038e7115589978ba28e | 31e80fb32515575d8db10ff36eaa1e728554706a | refs/heads/master | 2020-05-19T12:16:48.645061 | 2016-02-29T01:16:42 | 2016-02-29T01:16:42 | 42,481,791 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 931 | h | Views.h | #pragma once
#include "Collections.h"
namespace Essence {
template<typename T>
struct array_view {
T* elements;
u32 num;
array_view() = default;
array_view(T* ptr, u32 size) : elements(ptr), num(size) {};
T& operator [](i64 index) {
Check(index >= 0 && index < (i32)num);
return elements[index];
}
T const & operator [](i64 index) const {
Check(index >= 0 && index < (i32)num);
return elements[index];
}
};
template<typename T>
void allocate_array(array_view<T> *a, u32 size, IAllocator* allocator) {
(*a) = array_view<T>((T*)allocator->Allocate(sizeof(T) * size, alignof(T)), size);
}
template<typename T>
void zero_array(array_view<T> *a) {
ZeroMemory(a->elements, sizeof(T) * a->num);
}
template<typename T>
Array<T> wrap_c_array(T* ptr, u32 size) {
Array<T> wrapped;
wrapped.Allocator = nullptr;
wrapped.Capacity = wrapped.Size = size;
wrapped.DataPtr = ptr;
return std::move(wrapped);
}
} |
299c7eae128c2850b6a9ba7d05e2a9342b7316d3 | a5a99f646e371b45974a6fb6ccc06b0a674818f2 | /CalibCalorimetry/EcalLaserAnalyzer/test/MusEcal/src/MEEEDisplay.cc | 1c39e0cfb5d6a9c25635c758649a9b868222f273 | [
"Apache-2.0"
] | permissive | cms-sw/cmssw | 4ecd2c1105d59c66d385551230542c6615b9ab58 | 19c178740257eb48367778593da55dcad08b7a4f | refs/heads/master | 2023-08-23T21:57:42.491143 | 2023-08-22T20:22:40 | 2023-08-22T20:22:40 | 10,969,551 | 1,006 | 3,696 | Apache-2.0 | 2023-09-14T19:14:28 | 2013-06-26T14:09:07 | C++ | UTF-8 | C++ | false | false | 127,318 | cc | MEEEDisplay.cc | #include <assert.h>
#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
#include "MEEEDisplay.hh"
ClassImp(MEEEDisplay);
list< TObject* > MEEEDisplay::_list;
map<int,MEEEGeom::EtaPhiPoint> MEEEDisplay::_pointMap;
map< int, TPolyLine* > MEEEDisplay::_rzXtals;
int MEEEDisplay::bkgColor=38;
int MEEEDisplay::lineColor=2;
int MEEEDisplay::lineWidth=2;
TPolyLine*
MEEEDisplay::getSCPolyLine( int iX, int iY, int iz, float shift )
{
int iSC = MEEEGeom::sc( iX, iY );
if( iSC<0 ) return 0;
vector<int> jx_;
vector<int> jy_;
sc_nodes( MEEEGeom::sc_type( iX, iY ), jx_, jy_ );
assert( jx_.size()==jy_.size() );
int n_ = jx_.size();
if( n_==0 ) return 0;
float eta[n_+1];
float phi[n_+1];
for( int ii=0; ii<n_; ii++ )
{
MEEEGeom::EtaPhiPoint p_ = getNode( iX, iY, iz, jx_[ii], jy_[ii] );
eta[ii] = p_.first;
phi[ii] = p_.second + shift;
}
eta[n_] = eta[0];
phi[n_] = phi[0];
return new TPolyLine( n_+1, eta, phi );
}
TPolyLine*
MEEEDisplay::getXtalPolyLine( int ix, int iy, int iz, float shift )
{
int iX = (ix-1)/5+1;
int iY = (iy-1)/5+1;
int iSC = MEEEGeom::sc( iX, iY );
// cout << "ix/iy/iX/iY/iSC " << ix << "/" << iy << "/" << iX << "/" << iY << "/" << iSC << endl;
if( iSC<0 ) return 0;
int crystal_in_sc = MEEEGeom::crystal_in_sc( ix, iy );
if( crystal_in_sc<0 ) return 0;
int iquad = MEEEGeom::quadrant( iX, iY );
int ix0 = ix;
int iy0 = iy;
int iX0 = iX;
int iY0 = iY;
if( iquad==2 || iquad==3 )
{
iX0 = 21-iX;
ix0 = 101-ix;
}
if( iquad==3 || iquad==4 )
{
iY0 = 21-iY;
iy0 = 101-iy;
}
// cout << "ix0/iy0/iX0/iY0 " << ix0 << "/" << iy0 << "/" << iX0 << "/" << iY0 << endl;
int jx = ix0 - 5*(iX0-1);
int jy = iy0 - 5*(iY0-1);
// cout << "jx/jy " << jx << "/" << jy << endl;
float eta[5];
float phi[5];
int kx[4] = {0,-1,-1, 0};
int ky[4] = {0, 0,-1,-1};
for( int ii=0; ii<4; ii++ )
{
MEEEGeom::EtaPhiPoint p_ = getNode( iX, iY, iz, jx+kx[ii], jy+ky[ii] );
eta[ii] = p_.first;
phi[ii] = p_.second + shift;
}
eta[4] = eta[0];
phi[4] = phi[0];
return new TPolyLine( 5, eta, phi );
}
void
MEEEDisplay::drawEE()
{
refresh();
// int iz=1;
for( int iz=-1; iz<=1; iz+=2 )
{
for( int iX=1; iX<=20; iX++ )
{
for( int iY=1; iY<=20; iY++ )
{
drawSC( iX, iY, iz );
}
}
}
}
void
MEEEDisplay::drawSC( int iX, int iY, int iz, float shift )
{
TPolyLine* pline = getSCPolyLine( iX, iY, iz, shift );
registerTObject( pline );
if( pline==0 ) return;
if( bkgColor>=0 ) pline->SetFillColor( bkgColor );
pline->SetLineColor( lineColor );
pline->SetLineWidth( lineWidth );
if( bkgColor>=0 ) pline->Draw("f");
pline->Draw();
if( shift==0 )
{
if( iY==10 && iX>=11 ) drawSC( iX, iY, iz, -2. );
if( iY==11 && iX>=11 ) drawSC( iX, iY, iz, 2. );
}
}
void
MEEEDisplay::drawXtal( int ix, int iy, int iz, int color, float shift )
{
TPolyLine* pline = getXtalPolyLine( ix, iy, iz, shift );
registerTObject( pline );
if( pline==0 ) return;
pline->SetFillColor( color );
pline->SetLineColor( color );
pline->SetLineWidth( 0 );
pline->Draw("f"); pline->Draw();
if( shift==0 )
{
int iX = (ix-1)/5+1;
int iY = (iy-1)/5+1;
if( iY==10 && iX>=11 ) drawXtal( ix, iy, iz, color, -2. );
if( iY==11 && iX>=11 ) drawXtal( ix, iy, iz, color, 2. );
}
}
void
MEEEDisplay::sc_nodes( int itype, vector< int >& jx_, vector< int >& jy_ )
{
int n_;
if( itype==0 )
{
n_=20;
jx_.resize( n_ ); jy_.resize( n_ );
int ii=0;
jx_[ii]=0; jy_[ii]=0; ii++;
jx_[ii]=0; jy_[ii]=1; ii++;
jx_[ii]=0; jy_[ii]=2; ii++;
jx_[ii]=0; jy_[ii]=3; ii++;
jx_[ii]=0; jy_[ii]=4; ii++;
jx_[ii]=0; jy_[ii]=5; ii++;
jx_[ii]=1; jy_[ii]=5; ii++;
jx_[ii]=2; jy_[ii]=5; ii++;
jx_[ii]=3; jy_[ii]=5; ii++;
jx_[ii]=4; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=4; ii++;
jx_[ii]=5; jy_[ii]=3; ii++;
jx_[ii]=5; jy_[ii]=2; ii++;
jx_[ii]=5; jy_[ii]=1; ii++;
jx_[ii]=5; jy_[ii]=0; ii++;
jx_[ii]=4; jy_[ii]=0; ii++;
jx_[ii]=3; jy_[ii]=0; ii++;
jx_[ii]=2; jy_[ii]=0; ii++;
jx_[ii]=1; jy_[ii]=0; ii++;
assert( ii==n_ );
}
else if( itype==1 )
{
n_=18;
jx_.resize( n_ ); jy_.resize( n_ );
int ii=0;
jx_[ii]=0; jy_[ii]=1; ii++;
jx_[ii]=0; jy_[ii]=2; ii++;
jx_[ii]=0; jy_[ii]=3; ii++;
jx_[ii]=0; jy_[ii]=4; ii++;
jx_[ii]=0; jy_[ii]=5; ii++;
jx_[ii]=1; jy_[ii]=5; ii++;
jx_[ii]=2; jy_[ii]=5; ii++;
jx_[ii]=3; jy_[ii]=5; ii++;
jx_[ii]=4; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=4; ii++;
jx_[ii]=5; jy_[ii]=3; ii++;
jx_[ii]=5; jy_[ii]=2; ii++;
jx_[ii]=5; jy_[ii]=1; ii++;
jx_[ii]=4; jy_[ii]=1; ii++;
jx_[ii]=3; jy_[ii]=1; ii++;
jx_[ii]=2; jy_[ii]=1; ii++;
jx_[ii]=1; jy_[ii]=1; ii++;
assert( ii==n_ );
}
else if( itype==2 )
{
n_=12;
jx_.resize( n_ ); jy_.resize( n_ );
int ii=0;
jx_[ii]=2; jy_[ii]=4; ii++;
jx_[ii]=2; jy_[ii]=5; ii++;
jx_[ii]=3; jy_[ii]=5; ii++;
jx_[ii]=4; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=4; ii++;
jx_[ii]=5; jy_[ii]=3; ii++;
jx_[ii]=5; jy_[ii]=2; ii++;
jx_[ii]=4; jy_[ii]=2; ii++;
jx_[ii]=4; jy_[ii]=3; ii++;
jx_[ii]=3; jy_[ii]=3; ii++;
jx_[ii]=3; jy_[ii]=4; ii++;
assert( ii==n_ );
}
else if( itype==3 )
{
n_=18;
jx_.resize( n_ ); jy_.resize( n_ );
int ii=0;
jx_[ii]=1; jy_[ii]=0; ii++;
jx_[ii]=1; jy_[ii]=1; ii++;
jx_[ii]=1; jy_[ii]=2; ii++;
jx_[ii]=1; jy_[ii]=3; ii++;
jx_[ii]=1; jy_[ii]=4; ii++;
jx_[ii]=1; jy_[ii]=5; ii++;
jx_[ii]=2; jy_[ii]=5; ii++;
jx_[ii]=3; jy_[ii]=5; ii++;
jx_[ii]=4; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=5; ii++;
jx_[ii]=5; jy_[ii]=4; ii++;
jx_[ii]=5; jy_[ii]=3; ii++;
jx_[ii]=5; jy_[ii]=2; ii++;
jx_[ii]=5; jy_[ii]=1; ii++;
jx_[ii]=5; jy_[ii]=0; ii++;
jx_[ii]=4; jy_[ii]=0; ii++;
jx_[ii]=3; jy_[ii]=0; ii++;
jx_[ii]=2; jy_[ii]=0; ii++;
assert( ii==n_ );
}
else if( itype==4 )
{
n_=14;
jx_.resize( n_ ); jy_.resize( n_ );
int ii=0;
jx_[ii]=0; jy_[ii]=0; ii++;
jx_[ii]=0; jy_[ii]=1; ii++;
jx_[ii]=0; jy_[ii]=2; ii++;
jx_[ii]=1; jy_[ii]=2; ii++;
jx_[ii]=2; jy_[ii]=2; ii++;
jx_[ii]=3; jy_[ii]=2; ii++;
jx_[ii]=4; jy_[ii]=2; ii++;
jx_[ii]=5; jy_[ii]=2; ii++;
jx_[ii]=5; jy_[ii]=1; ii++;
jx_[ii]=5; jy_[ii]=0; ii++;
jx_[ii]=4; jy_[ii]=0; ii++;
jx_[ii]=3; jy_[ii]=0; ii++;
jx_[ii]=2; jy_[ii]=0; ii++;
jx_[ii]=1; jy_[ii]=0; ii++;
assert( ii==n_ );
}
else if( itype==5 )
{
n_=0 ;
jx_.resize( n_ ); jy_.resize( n_ );
}
else if( itype==6 )
{
n_=14;
jx_.resize( n_ ); jy_.resize( n_ );
int ii=0;
jx_[ii]=0; jy_[ii]=0; ii++;
jx_[ii]=0; jy_[ii]=1; ii++;
jx_[ii]=0; jy_[ii]=2; ii++;
jx_[ii]=0; jy_[ii]=3; ii++;
jx_[ii]=0; jy_[ii]=4; ii++;
jx_[ii]=0; jy_[ii]=5; ii++;
jx_[ii]=1; jy_[ii]=5; ii++;
jx_[ii]=2; jy_[ii]=5; ii++;
jx_[ii]=2; jy_[ii]=4; ii++;
jx_[ii]=2; jy_[ii]=3; ii++;
jx_[ii]=2; jy_[ii]=2; ii++;
jx_[ii]=2; jy_[ii]=1; ii++;
jx_[ii]=2; jy_[ii]=0; ii++;
jx_[ii]=1; jy_[ii]=0; ii++;
assert( ii==n_ );
}
}
void
MEEEDisplay::set( int iX, int iY, int jx, int jy, float eta, float phioverpi )
{
assert( iX>10 && iY>10 );
assert( jx>=0 && jx<=5 );
assert( jy>=0 && jy<=5 );
assert( eta>0 );
assert( phioverpi>=0 && phioverpi<=0.5 );
int ii = 10000*iX + 100*iY + 10*jx + jy;
MEEEGeom::EtaPhiPoint p_( eta, phioverpi );
_pointMap.insert( pair<int,MEEEGeom::EtaPhiPoint>(ii,p_) );
}
MEEEGeom::EtaPhiPoint
MEEEDisplay::getNode( MEEEGeom::SuperCrysCoord iX,
MEEEGeom::SuperCrysCoord iY,
int iz, int jx, int jy )
{
int iquad = MEEEGeom::quadrant( iX, iY );
int iX0 = iX;
int iY0 = iY;
if( iquad==2 || iquad==3 ) iX0 = 21-iX;
if( iquad==3 || iquad==4 ) iY0 = 21-iY;
int ii = 10000*iX0 + 100*iY0 + 10*jx + jy;
setFirstQuadrant();
if( _pointMap.count(ii)!=1 )
{
cout << "iX/iY/iz/jx/jy " << iX << "/" << iY << "/" << iz << "/" << jx << "/" << jy << endl;
cout << "_pointMap.count(ii)=" << _pointMap.count(ii) << endl;
return MEEEGeom::EtaPhiPoint(0,0);
}
MEEEGeom::EtaPhiPoint p_ = _pointMap[ii];
if( iquad==2 ) return MEEEGeom::EtaPhiPoint( iz*p_.first, 1-p_.second );
if( iquad==3 ) return MEEEGeom::EtaPhiPoint( iz*p_.first, p_.second+1 );
if( iquad==4 ) return MEEEGeom::EtaPhiPoint( iz*p_.first, 2-p_.second );
return MEEEGeom::EtaPhiPoint( iz*p_.first, p_.second );
}
void
MEEEDisplay::setFirstQuadrant()
{
static bool done=false;
if( done ) return;
done = true;
//
// eta/phi for SC nodes in first quadrant, iz=1
//
// iX, iY, jx, jy, eta phi/pi
set( 11, 13, 0, 1, 2.9770, 0.4982);
set( 11, 13, 0, 2, 2.8924, 0.4983);
set( 11, 13, 0, 3, 2.8138, 0.4984);
set( 11, 13, 0, 4, 2.7409, 0.4985);
set( 11, 13, 0, 5, 2.6736, 0.4986);
set( 11, 13, 1, 1, 2.9726, 0.4701);
set( 11, 13, 1, 2, 2.8888, 0.4725);
set( 11, 13, 1, 3, 2.8107, 0.4746);
set( 11, 13, 1, 4, 2.7382, 0.4764);
set( 11, 13, 1, 5, 2.6713, 0.4779);
set( 11, 13, 2, 1, 2.9606, 0.4423);
set( 11, 13, 2, 2, 2.8786, 0.4469);
set( 11, 13, 2, 3, 2.8019, 0.4508);
set( 11, 13, 2, 4, 2.7307, 0.4543);
set( 11, 13, 2, 5, 2.6646, 0.4572);
set( 11, 13, 3, 1, 2.9414, 0.4154);
set( 11, 13, 3, 2, 2.8623, 0.4219);
set( 11, 13, 3, 3, 2.7879, 0.4276);
set( 11, 13, 3, 4, 2.7185, 0.4326);
set( 11, 13, 3, 5, 2.6540, 0.4368);
set( 11, 13, 4, 1, 2.9159, 0.3896);
set( 11, 13, 4, 2, 2.8404, 0.3979);
set( 11, 13, 4, 3, 2.7691, 0.4052);
set( 11, 13, 4, 4, 2.7021, 0.4115);
set( 11, 13, 4, 5, 2.6395, 0.4170);
set( 11, 13, 5, 1, 2.8853, 0.3655);
set( 11, 13, 5, 2, 2.8140, 0.3752);
set( 11, 13, 5, 3, 2.7461, 0.3838);
set( 11, 13, 5, 4, 2.6819, 0.3913);
set( 11, 13, 5, 5, 2.6217, 0.3979);
set( 11, 14, 0, 0, 2.6688, 0.4987);
set( 11, 14, 0, 1, 2.6063, 0.4987);
set( 11, 14, 0, 2, 2.5469, 0.4988);
set( 11, 14, 0, 3, 2.4908, 0.4989);
set( 11, 14, 0, 4, 2.4378, 0.4989);
set( 11, 14, 0, 5, 2.3879, 0.4990);
set( 11, 14, 1, 0, 2.6664, 0.4781);
set( 11, 14, 1, 1, 2.6042, 0.4794);
set( 11, 14, 1, 2, 2.5451, 0.4806);
set( 11, 14, 1, 3, 2.4892, 0.4817);
set( 11, 14, 1, 4, 2.4363, 0.4826);
set( 11, 14, 1, 5, 2.3866, 0.4835);
set( 11, 14, 2, 0, 2.6600, 0.4576);
set( 11, 14, 2, 1, 2.5985, 0.4601);
set( 11, 14, 2, 2, 2.5400, 0.4624);
set( 11, 14, 2, 3, 2.4847, 0.4644);
set( 11, 14, 2, 4, 2.4322, 0.4662);
set( 11, 14, 2, 5, 2.3829, 0.4679);
set( 11, 14, 3, 0, 2.6495, 0.4374);
set( 11, 14, 3, 1, 2.5892, 0.4411);
set( 11, 14, 3, 2, 2.5317, 0.4444);
set( 11, 14, 3, 3, 2.4773, 0.4474);
set( 11, 14, 3, 4, 2.4256, 0.4500);
set( 11, 14, 3, 5, 2.3768, 0.4524);
set( 11, 14, 4, 0, 2.6353, 0.4177);
set( 11, 14, 4, 1, 2.5766, 0.4225);
set( 11, 14, 4, 2, 2.5205, 0.4268);
set( 11, 14, 4, 3, 2.4672, 0.4306);
set( 11, 14, 4, 4, 2.4165, 0.4341);
set( 11, 14, 4, 5, 2.3686, 0.4372);
set( 11, 14, 5, 0, 2.6178, 0.3988);
set( 11, 14, 5, 1, 2.5611, 0.4045);
set( 11, 14, 5, 2, 2.5066, 0.4097);
set( 11, 14, 5, 3, 2.4547, 0.4144);
set( 11, 14, 5, 4, 2.4052, 0.4186);
set( 11, 14, 5, 5, 2.3583, 0.4224);
set( 11, 15, 0, 0, 2.3850, 0.4990);
set( 11, 15, 0, 1, 2.3379, 0.4990);
set( 11, 15, 0, 2, 2.2924, 0.4991);
set( 11, 15, 0, 3, 2.2490, 0.4991);
set( 11, 15, 0, 4, 2.2073, 0.4992);
set( 11, 15, 0, 5, 2.1677, 0.4992);
set( 11, 15, 1, 0, 2.3837, 0.4836);
set( 11, 15, 1, 1, 2.3367, 0.4844);
set( 11, 15, 1, 2, 2.2913, 0.4850);
set( 11, 15, 1, 3, 2.2480, 0.4857);
set( 11, 15, 1, 4, 2.2064, 0.4863);
set( 11, 15, 1, 5, 2.1669, 0.4868);
set( 11, 15, 2, 0, 2.3801, 0.4681);
set( 11, 15, 2, 1, 2.3334, 0.4696);
set( 11, 15, 2, 2, 2.2883, 0.4709);
set( 11, 15, 2, 3, 2.2452, 0.4722);
set( 11, 15, 2, 4, 2.2039, 0.4733);
set( 11, 15, 2, 5, 2.1645, 0.4743);
set( 11, 15, 3, 0, 2.3742, 0.4528);
set( 11, 15, 3, 1, 2.3280, 0.4550);
set( 11, 15, 3, 2, 2.2834, 0.4569);
set( 11, 15, 3, 3, 2.2407, 0.4587);
set( 11, 15, 3, 4, 2.1997, 0.4604);
set( 11, 15, 3, 5, 2.1607, 0.4619);
set( 11, 15, 4, 0, 2.3661, 0.4377);
set( 11, 15, 4, 1, 2.3206, 0.4405);
set( 11, 15, 4, 2, 2.2767, 0.4431);
set( 11, 15, 4, 3, 2.2345, 0.4455);
set( 11, 15, 4, 4, 2.1940, 0.4476);
set( 11, 15, 4, 5, 2.1554, 0.4496);
set( 11, 15, 5, 0, 2.3560, 0.4231);
set( 11, 15, 5, 1, 2.3114, 0.4265);
set( 11, 15, 5, 2, 2.2682, 0.4296);
set( 11, 15, 5, 3, 2.2267, 0.4325);
set( 11, 15, 5, 4, 2.1868, 0.4352);
set( 11, 15, 5, 5, 2.1488, 0.4376);
set( 11, 16, 0, 0, 2.1662, 0.4992);
set( 11, 16, 0, 1, 2.1284, 0.4992);
set( 11, 16, 0, 2, 2.0916, 0.4993);
set( 11, 16, 0, 3, 2.0562, 0.4993);
set( 11, 16, 0, 4, 2.0220, 0.4993);
set( 11, 16, 0, 5, 1.9892, 0.4993);
set( 11, 16, 1, 0, 2.1654, 0.4869);
set( 11, 16, 1, 1, 2.1277, 0.4874);
set( 11, 16, 1, 2, 2.0909, 0.4878);
set( 11, 16, 1, 3, 2.0555, 0.4883);
set( 11, 16, 1, 4, 2.0213, 0.4887);
set( 11, 16, 1, 5, 1.9886, 0.4890);
set( 11, 16, 2, 0, 2.1631, 0.4745);
set( 11, 16, 2, 1, 2.1255, 0.4755);
set( 11, 16, 2, 2, 2.0890, 0.4763);
set( 11, 16, 2, 3, 2.0537, 0.4772);
set( 11, 16, 2, 4, 2.0196, 0.4779);
set( 11, 16, 2, 5, 1.9870, 0.4786);
set( 11, 16, 3, 0, 2.1593, 0.4622);
set( 11, 16, 3, 1, 2.1220, 0.4636);
set( 11, 16, 3, 2, 2.0857, 0.4649);
set( 11, 16, 3, 3, 2.0507, 0.4661);
set( 11, 16, 3, 4, 2.0168, 0.4672);
set( 11, 16, 3, 5, 1.9843, 0.4683);
set( 11, 16, 4, 0, 2.1542, 0.4501);
set( 11, 16, 4, 1, 2.1172, 0.4519);
set( 11, 16, 4, 2, 2.0813, 0.4536);
set( 11, 16, 4, 3, 2.0465, 0.4551);
set( 11, 16, 4, 4, 2.0129, 0.4566);
set( 11, 16, 4, 5, 1.9807, 0.4580);
set( 11, 16, 5, 0, 2.1476, 0.4381);
set( 11, 16, 5, 1, 2.1112, 0.4403);
set( 11, 16, 5, 2, 2.0756, 0.4424);
set( 11, 16, 5, 3, 2.0413, 0.4444);
set( 11, 16, 5, 4, 2.0080, 0.4462);
set( 11, 16, 5, 5, 1.9761, 0.4479);
set( 11, 17, 0, 0, 1.9887, 0.4993);
set( 11, 17, 0, 1, 1.9572, 0.4994);
set( 11, 17, 0, 2, 1.9264, 0.4994);
set( 11, 17, 0, 3, 1.8965, 0.4994);
set( 11, 17, 0, 4, 1.8675, 0.4994);
set( 11, 17, 0, 5, 1.8395, 0.4994);
set( 11, 17, 1, 0, 1.9882, 0.4891);
set( 11, 17, 1, 1, 1.9567, 0.4895);
set( 11, 17, 1, 2, 1.9259, 0.4898);
set( 11, 17, 1, 3, 1.8960, 0.4901);
set( 11, 17, 1, 4, 1.8670, 0.4903);
set( 11, 17, 1, 5, 1.8391, 0.4906);
set( 11, 17, 2, 0, 1.9866, 0.4788);
set( 11, 17, 2, 1, 1.9552, 0.4795);
set( 11, 17, 2, 2, 1.9245, 0.4801);
set( 11, 17, 2, 3, 1.8947, 0.4807);
set( 11, 17, 2, 4, 1.8658, 0.4812);
set( 11, 17, 2, 5, 1.8379, 0.4817);
set( 11, 17, 3, 0, 1.9840, 0.4686);
set( 11, 17, 3, 1, 1.9528, 0.4695);
set( 11, 17, 3, 2, 1.9222, 0.4704);
set( 11, 17, 3, 3, 1.8926, 0.4713);
set( 11, 17, 3, 4, 1.8638, 0.4721);
set( 11, 17, 3, 5, 1.8360, 0.4728);
set( 11, 17, 4, 0, 1.9804, 0.4584);
set( 11, 17, 4, 1, 1.9494, 0.4596);
set( 11, 17, 4, 2, 1.9191, 0.4608);
set( 11, 17, 4, 3, 1.8896, 0.4620);
set( 11, 17, 4, 4, 1.8610, 0.4630);
set( 11, 17, 4, 5, 1.8334, 0.4640);
set( 11, 17, 5, 0, 1.9759, 0.4484);
set( 11, 17, 5, 1, 1.9452, 0.4499);
set( 11, 17, 5, 2, 1.9151, 0.4514);
set( 11, 17, 5, 3, 1.8858, 0.4528);
set( 11, 17, 5, 4, 1.8574, 0.4541);
set( 11, 17, 5, 5, 1.8300, 0.4553);
set( 11, 18, 0, 0, 1.8399, 0.4994);
set( 11, 18, 0, 1, 1.8129, 0.4995);
set( 11, 18, 0, 2, 1.7864, 0.4995);
set( 11, 18, 0, 3, 1.7606, 0.4995);
set( 11, 18, 0, 4, 1.7354, 0.4995);
set( 11, 18, 0, 5, 1.7111, 0.4995);
set( 11, 18, 1, 0, 1.8395, 0.4907);
set( 11, 18, 1, 1, 1.8125, 0.4909);
set( 11, 18, 1, 2, 1.7860, 0.4912);
set( 11, 18, 1, 3, 1.7602, 0.4914);
set( 11, 18, 1, 4, 1.7351, 0.4916);
set( 11, 18, 1, 5, 1.7108, 0.4918);
set( 11, 18, 2, 0, 1.8383, 0.4819);
set( 11, 18, 2, 1, 1.8114, 0.4824);
set( 11, 18, 2, 2, 1.7850, 0.4828);
set( 11, 18, 2, 3, 1.7593, 0.4832);
set( 11, 18, 2, 4, 1.7342, 0.4837);
set( 11, 18, 2, 5, 1.7099, 0.4840);
set( 11, 18, 3, 0, 1.8365, 0.4731);
set( 11, 18, 3, 1, 1.8097, 0.4738);
set( 11, 18, 3, 2, 1.7833, 0.4745);
set( 11, 18, 3, 3, 1.7577, 0.4751);
set( 11, 18, 3, 4, 1.7327, 0.4757);
set( 11, 18, 3, 5, 1.7085, 0.4763);
set( 11, 18, 4, 0, 1.8339, 0.4644);
set( 11, 18, 4, 1, 1.8072, 0.4653);
set( 11, 18, 4, 2, 1.7810, 0.4662);
set( 11, 18, 4, 3, 1.7555, 0.4670);
set( 11, 18, 4, 4, 1.7306, 0.4678);
set( 11, 18, 4, 5, 1.7065, 0.4686);
set( 11, 18, 5, 0, 1.8306, 0.4558);
set( 11, 18, 5, 1, 1.8041, 0.4569);
set( 11, 18, 5, 2, 1.7781, 0.4580);
set( 11, 18, 5, 3, 1.7527, 0.4590);
set( 11, 18, 5, 4, 1.7279, 0.4600);
set( 11, 18, 5, 5, 1.7040, 0.4610);
set( 11, 19, 0, 0, 1.7122, 0.4995);
set( 11, 19, 0, 1, 1.6886, 0.4995);
set( 11, 19, 0, 2, 1.6654, 0.4995);
set( 11, 19, 0, 3, 1.6427, 0.4995);
set( 11, 19, 0, 4, 1.6206, 0.4996);
set( 11, 19, 0, 5, 1.5991, 0.4996);
set( 11, 19, 1, 0, 1.7119, 0.4919);
set( 11, 19, 1, 1, 1.6883, 0.4921);
set( 11, 19, 1, 2, 1.6651, 0.4923);
set( 11, 19, 1, 3, 1.6425, 0.4924);
set( 11, 19, 1, 4, 1.6203, 0.4926);
set( 11, 19, 1, 5, 1.5988, 0.4927);
set( 11, 19, 2, 0, 1.7110, 0.4842);
set( 11, 19, 2, 1, 1.6875, 0.4846);
set( 11, 19, 2, 2, 1.6644, 0.4849);
set( 11, 19, 2, 3, 1.6417, 0.4852);
set( 11, 19, 2, 4, 1.6196, 0.4856);
set( 11, 19, 2, 5, 1.5981, 0.4859);
set( 11, 19, 3, 0, 1.7096, 0.4765);
set( 11, 19, 3, 1, 1.6862, 0.4771);
set( 11, 19, 3, 2, 1.6631, 0.4776);
set( 11, 19, 3, 3, 1.6405, 0.4781);
set( 11, 19, 3, 4, 1.6184, 0.4785);
set( 11, 19, 3, 5, 1.5970, 0.4790);
set( 11, 19, 4, 0, 1.7077, 0.4689);
set( 11, 19, 4, 1, 1.6843, 0.4696);
set( 11, 19, 4, 2, 1.6613, 0.4703);
set( 11, 19, 4, 3, 1.6388, 0.4709);
set( 11, 19, 4, 4, 1.6168, 0.4715);
set( 11, 19, 4, 5, 1.5955, 0.4721);
set( 11, 19, 5, 0, 1.7052, 0.4613);
set( 11, 19, 5, 1, 1.6820, 0.4622);
set( 11, 19, 5, 2, 1.6591, 0.4631);
set( 11, 19, 5, 3, 1.6367, 0.4639);
set( 11, 19, 5, 4, 1.6148, 0.4646);
set( 11, 19, 5, 5, 1.5935, 0.4654);
set( 11, 20, 0, 0, 1.6007, 0.4996);
set( 11, 20, 0, 1, 1.5799, 0.4996);
set( 11, 20, 0, 2, 1.5592, 0.4996);
set( 11, 20, 0, 3, 1.5390, 0.4996);
set( 11, 20, 0, 4, 1.5192, 0.4996);
set( 11, 20, 0, 5, 1.5000, 0.4996);
set( 11, 20, 1, 0, 1.6005, 0.4928);
set( 11, 20, 1, 1, 1.5796, 0.4930);
set( 11, 20, 1, 2, 1.5590, 0.4931);
set( 11, 20, 1, 3, 1.5388, 0.4932);
set( 11, 20, 1, 4, 1.5190, 0.4934);
set( 11, 20, 1, 5, 1.4998, 0.4935);
set( 11, 20, 2, 0, 1.5998, 0.4860);
set( 11, 20, 2, 1, 1.5790, 0.4863);
set( 11, 20, 2, 2, 1.5584, 0.4866);
set( 11, 20, 2, 3, 1.5382, 0.4868);
set( 11, 20, 2, 4, 1.5185, 0.4871);
set( 11, 20, 2, 5, 1.4992, 0.4873);
set( 11, 20, 3, 0, 1.5987, 0.4792);
set( 11, 20, 3, 1, 1.5779, 0.4796);
set( 11, 20, 3, 2, 1.5574, 0.4800);
set( 11, 20, 3, 3, 1.5373, 0.4804);
set( 11, 20, 3, 4, 1.5175, 0.4808);
set( 11, 20, 3, 5, 1.4984, 0.4811);
set( 11, 20, 4, 0, 1.5972, 0.4724);
set( 11, 20, 4, 1, 1.5765, 0.4730);
set( 11, 20, 4, 2, 1.5560, 0.4735);
set( 11, 20, 4, 3, 1.5359, 0.4740);
set( 11, 20, 4, 4, 1.5163, 0.4745);
set( 11, 20, 4, 5, 1.4971, 0.4750);
set( 11, 20, 5, 0, 1.5953, 0.4657);
set( 11, 20, 5, 1, 1.5746, 0.4664);
set( 11, 20, 5, 2, 1.5542, 0.4671);
set( 11, 20, 5, 3, 1.5342, 0.4677);
set( 11, 20, 5, 4, 1.5146, 0.4683);
set( 11, 20, 5, 5, 1.4956, 0.4689);
set( 12, 12, 2, 4, 2.9434, 0.2885);
set( 12, 12, 2, 5, 2.8778, 0.3040);
set( 12, 12, 3, 3, 2.9506, 0.2495);
set( 12, 12, 3, 4, 2.8902, 0.2680);
set( 12, 12, 3, 5, 2.8307, 0.2842);
set( 12, 12, 4, 2, 2.9429, 0.2106);
set( 12, 12, 4, 3, 2.8900, 0.2311);
set( 12, 12, 4, 4, 2.8359, 0.2496);
set( 12, 12, 4, 5, 2.7819, 0.2660);
set( 12, 12, 5, 2, 2.8771, 0.1951);
set( 12, 12, 5, 3, 2.8303, 0.2150);
set( 12, 12, 5, 4, 2.7817, 0.2333);
set( 12, 12, 5, 5, 2.7330, 0.2497);
set( 12, 13, 0, 0, 2.9588, 0.3512);
set( 12, 13, 0, 1, 2.8839, 0.3627);
set( 12, 13, 0, 2, 2.8124, 0.3728);
set( 12, 13, 0, 3, 2.7450, 0.3816);
set( 12, 13, 0, 4, 2.6812, 0.3893);
set( 12, 13, 0, 5, 2.6213, 0.3960);
set( 12, 13, 1, 0, 2.9178, 0.3276);
set( 12, 13, 1, 1, 2.8483, 0.3403);
set( 12, 13, 1, 2, 2.7815, 0.3516);
set( 12, 13, 1, 3, 2.7178, 0.3614);
set( 12, 13, 1, 4, 2.6572, 0.3701);
set( 12, 13, 1, 5, 2.6000, 0.3778);
set( 12, 13, 2, 0, 2.8731, 0.3057);
set( 12, 13, 2, 1, 2.8092, 0.3193);
set( 12, 13, 2, 2, 2.7471, 0.3315);
set( 12, 13, 2, 3, 2.6874, 0.3422);
set( 12, 13, 2, 4, 2.6302, 0.3517);
set( 12, 13, 2, 5, 2.5758, 0.3602);
set( 12, 13, 3, 0, 2.8262, 0.2858);
set( 12, 13, 3, 1, 2.7678, 0.3000);
set( 12, 13, 3, 2, 2.7103, 0.3127);
set( 12, 13, 3, 3, 2.6547, 0.3241);
set( 12, 13, 3, 4, 2.6009, 0.3344);
set( 12, 13, 3, 5, 2.5494, 0.3435);
set( 12, 13, 4, 0, 2.7781, 0.2676);
set( 12, 13, 4, 1, 2.7247, 0.2822);
set( 12, 13, 4, 2, 2.6718, 0.2954);
set( 12, 13, 4, 3, 2.6200, 0.3073);
set( 12, 13, 4, 4, 2.5697, 0.3180);
set( 12, 13, 4, 5, 2.5212, 0.3276);
set( 12, 13, 5, 0, 2.7298, 0.2513);
set( 12, 13, 5, 1, 2.6811, 0.2660);
set( 12, 13, 5, 2, 2.6324, 0.2795);
set( 12, 13, 5, 3, 2.5844, 0.2917);
set( 12, 13, 5, 4, 2.5373, 0.3028);
set( 12, 13, 5, 5, 2.4918, 0.3128);
set( 12, 14, 0, 0, 2.6171, 0.3966);
set( 12, 14, 0, 1, 2.5606, 0.4025);
set( 12, 14, 0, 2, 2.5064, 0.4078);
set( 12, 14, 0, 3, 2.4547, 0.4126);
set( 12, 14, 0, 4, 2.4054, 0.4170);
set( 12, 14, 0, 5, 2.3587, 0.4209);
set( 12, 14, 1, 0, 2.5961, 0.3785);
set( 12, 14, 1, 1, 2.5418, 0.3853);
set( 12, 14, 1, 2, 2.4895, 0.3914);
set( 12, 14, 1, 3, 2.4394, 0.3969);
set( 12, 14, 1, 4, 2.3915, 0.4020);
set( 12, 14, 1, 5, 2.3460, 0.4065);
set( 12, 14, 2, 0, 2.5722, 0.3611);
set( 12, 14, 2, 1, 2.5204, 0.3685);
set( 12, 14, 2, 2, 2.4701, 0.3754);
set( 12, 14, 2, 3, 2.4219, 0.3816);
set( 12, 14, 2, 4, 2.3756, 0.3872);
set( 12, 14, 2, 5, 2.3315, 0.3923);
set( 12, 14, 3, 0, 2.5462, 0.3444);
set( 12, 14, 3, 1, 2.4968, 0.3526);
set( 12, 14, 3, 2, 2.4488, 0.3600);
set( 12, 14, 3, 3, 2.4025, 0.3668);
set( 12, 14, 3, 4, 2.3579, 0.3730);
set( 12, 14, 3, 5, 2.3152, 0.3786);
set( 12, 14, 4, 0, 2.5184, 0.3287);
set( 12, 14, 4, 1, 2.4716, 0.3373);
set( 12, 14, 4, 2, 2.4258, 0.3453);
set( 12, 14, 4, 3, 2.3815, 0.3526);
set( 12, 14, 4, 4, 2.3386, 0.3592);
set( 12, 14, 4, 5, 2.2975, 0.3653);
set( 12, 14, 5, 0, 2.4893, 0.3140);
set( 12, 14, 5, 1, 2.4450, 0.3230);
set( 12, 14, 5, 2, 2.4015, 0.3314);
set( 12, 14, 5, 3, 2.3592, 0.3391);
set( 12, 14, 5, 4, 2.3182, 0.3462);
set( 12, 14, 5, 5, 2.2787, 0.3526);
set( 12, 15, 0, 0, 2.3561, 0.4213);
set( 12, 15, 0, 1, 2.3117, 0.4248);
set( 12, 15, 0, 2, 2.2686, 0.4280);
set( 12, 15, 0, 3, 2.2273, 0.4311);
set( 12, 15, 0, 4, 2.1875, 0.4338);
set( 12, 15, 0, 5, 2.1496, 0.4364);
set( 12, 15, 1, 0, 2.3436, 0.4070);
set( 12, 15, 1, 1, 2.3002, 0.4111);
set( 12, 15, 1, 2, 2.2581, 0.4149);
set( 12, 15, 1, 3, 2.2176, 0.4183);
set( 12, 15, 1, 4, 2.1786, 0.4216);
set( 12, 15, 1, 5, 2.1413, 0.4245);
set( 12, 15, 2, 0, 2.3292, 0.3929);
set( 12, 15, 2, 1, 2.2870, 0.3975);
set( 12, 15, 2, 2, 2.2460, 0.4018);
set( 12, 15, 2, 3, 2.2064, 0.4058);
set( 12, 15, 2, 4, 2.1682, 0.4095);
set( 12, 15, 2, 5, 2.1316, 0.4128);
set( 12, 15, 3, 0, 2.3132, 0.3793);
set( 12, 15, 3, 1, 2.2723, 0.3844);
set( 12, 15, 3, 2, 2.2324, 0.3891);
set( 12, 15, 3, 3, 2.1938, 0.3935);
set( 12, 15, 3, 4, 2.1565, 0.3976);
set( 12, 15, 3, 5, 2.1208, 0.4013);
set( 12, 15, 4, 0, 2.2958, 0.3661);
set( 12, 15, 4, 1, 2.2562, 0.3716);
set( 12, 15, 4, 2, 2.2175, 0.3768);
set( 12, 15, 4, 3, 2.1800, 0.3816);
set( 12, 15, 4, 4, 2.1437, 0.3860);
set( 12, 15, 4, 5, 2.1088, 0.3901);
set( 12, 15, 5, 0, 2.2771, 0.3535);
set( 12, 15, 5, 1, 2.2390, 0.3594);
set( 12, 15, 5, 2, 2.2015, 0.3649);
set( 12, 15, 5, 3, 2.1652, 0.3701);
set( 12, 15, 5, 4, 2.1299, 0.3748);
set( 12, 15, 5, 5, 2.0959, 0.3793);
set( 12, 16, 0, 0, 2.1482, 0.4366);
set( 12, 16, 0, 1, 2.1119, 0.4389);
set( 12, 16, 0, 2, 2.0764, 0.4411);
set( 12, 16, 0, 3, 2.0421, 0.4432);
set( 12, 16, 0, 4, 2.0090, 0.4451);
set( 12, 16, 0, 5, 1.9771, 0.4469);
set( 12, 16, 1, 0, 2.1400, 0.4249);
set( 12, 16, 1, 1, 2.1042, 0.4276);
set( 12, 16, 1, 2, 2.0693, 0.4302);
set( 12, 16, 1, 3, 2.0355, 0.4326);
set( 12, 16, 1, 4, 2.0027, 0.4348);
set( 12, 16, 1, 5, 1.9713, 0.4369);
set( 12, 16, 2, 0, 2.1305, 0.4133);
set( 12, 16, 2, 1, 2.0953, 0.4164);
set( 12, 16, 2, 2, 2.0610, 0.4193);
set( 12, 16, 2, 3, 2.0277, 0.4220);
set( 12, 16, 2, 4, 1.9955, 0.4246);
set( 12, 16, 2, 5, 1.9644, 0.4269);
set( 12, 16, 3, 0, 2.1198, 0.4019);
set( 12, 16, 3, 1, 2.0854, 0.4053);
set( 12, 16, 3, 2, 2.0517, 0.4086);
set( 12, 16, 3, 3, 2.0190, 0.4116);
set( 12, 16, 3, 4, 1.9873, 0.4145);
set( 12, 16, 3, 5, 1.9567, 0.4171);
set( 12, 16, 4, 0, 2.1080, 0.3907);
set( 12, 16, 4, 1, 2.0744, 0.3945);
set( 12, 16, 4, 2, 2.0414, 0.3981);
set( 12, 16, 4, 3, 2.0093, 0.4014);
set( 12, 16, 4, 4, 1.9782, 0.4046);
set( 12, 16, 4, 5, 1.9482, 0.4075);
set( 12, 16, 5, 0, 2.0953, 0.3799);
set( 12, 16, 5, 1, 2.0625, 0.3840);
set( 12, 16, 5, 2, 2.0302, 0.3879);
set( 12, 16, 5, 3, 1.9989, 0.3915);
set( 12, 16, 5, 4, 1.9684, 0.3949);
set( 12, 16, 5, 5, 1.9389, 0.3981);
set( 12, 17, 0, 0, 1.9767, 0.4470);
set( 12, 17, 0, 1, 1.9461, 0.4487);
set( 12, 17, 0, 2, 1.9160, 0.4502);
set( 12, 17, 0, 3, 1.8869, 0.4517);
set( 12, 17, 0, 4, 1.8585, 0.4531);
set( 12, 17, 0, 5, 1.8312, 0.4544);
set( 12, 17, 1, 0, 1.9710, 0.4371);
set( 12, 17, 1, 1, 1.9406, 0.4391);
set( 12, 17, 1, 2, 1.9109, 0.4409);
set( 12, 17, 1, 3, 1.8820, 0.4426);
set( 12, 17, 1, 4, 1.8539, 0.4443);
set( 12, 17, 1, 5, 1.8268, 0.4458);
set( 12, 17, 2, 0, 1.9642, 0.4273);
set( 12, 17, 2, 1, 1.9343, 0.4295);
set( 12, 17, 2, 2, 1.9049, 0.4316);
set( 12, 17, 2, 3, 1.8764, 0.4336);
set( 12, 17, 2, 4, 1.8486, 0.4355);
set( 12, 17, 2, 5, 1.8217, 0.4372);
set( 12, 17, 3, 0, 1.9566, 0.4176);
set( 12, 17, 3, 1, 1.9271, 0.4200);
set( 12, 17, 3, 2, 1.8982, 0.4224);
set( 12, 17, 3, 3, 1.8700, 0.4246);
set( 12, 17, 3, 4, 1.8425, 0.4267);
set( 12, 17, 3, 5, 1.8160, 0.4287);
set( 12, 17, 4, 0, 1.9482, 0.4080);
set( 12, 17, 4, 1, 1.9192, 0.4107);
set( 12, 17, 4, 2, 1.8907, 0.4133);
set( 12, 17, 4, 3, 1.8629, 0.4158);
set( 12, 17, 4, 4, 1.8358, 0.4181);
set( 12, 17, 4, 5, 1.8097, 0.4203);
set( 12, 17, 5, 0, 1.9391, 0.3987);
set( 12, 17, 5, 1, 1.9106, 0.4016);
set( 12, 17, 5, 2, 1.8825, 0.4045);
set( 12, 17, 5, 3, 1.8552, 0.4071);
set( 12, 17, 5, 4, 1.8285, 0.4097);
set( 12, 17, 5, 5, 1.8027, 0.4121);
set( 12, 18, 0, 0, 1.8316, 0.4546);
set( 12, 18, 0, 1, 1.8051, 0.4558);
set( 12, 18, 0, 2, 1.7792, 0.4570);
set( 12, 18, 0, 3, 1.7538, 0.4581);
set( 12, 18, 0, 4, 1.7291, 0.4592);
set( 12, 18, 0, 5, 1.7052, 0.4602);
set( 12, 18, 1, 0, 1.8273, 0.4460);
set( 12, 18, 1, 1, 1.8011, 0.4475);
set( 12, 18, 1, 2, 1.7753, 0.4489);
set( 12, 18, 1, 3, 1.7501, 0.4502);
set( 12, 18, 1, 4, 1.7256, 0.4514);
set( 12, 18, 1, 5, 1.7018, 0.4526);
set( 12, 18, 2, 0, 1.8223, 0.4375);
set( 12, 18, 2, 1, 1.7963, 0.4392);
set( 12, 18, 2, 2, 1.7708, 0.4407);
set( 12, 18, 2, 3, 1.7458, 0.4422);
set( 12, 18, 2, 4, 1.7215, 0.4437);
set( 12, 18, 2, 5, 1.6979, 0.4450);
set( 12, 18, 3, 0, 1.8166, 0.4291);
set( 12, 18, 3, 1, 1.7910, 0.4309);
set( 12, 18, 3, 2, 1.7657, 0.4327);
set( 12, 18, 3, 3, 1.7410, 0.4344);
set( 12, 18, 3, 4, 1.7169, 0.4360);
set( 12, 18, 3, 5, 1.6935, 0.4375);
set( 12, 18, 4, 0, 1.8104, 0.4207);
set( 12, 18, 4, 1, 1.7850, 0.4228);
set( 12, 18, 4, 2, 1.7600, 0.4247);
set( 12, 18, 4, 3, 1.7356, 0.4266);
set( 12, 18, 4, 4, 1.7117, 0.4284);
set( 12, 18, 4, 5, 1.6886, 0.4301);
set( 12, 18, 5, 0, 1.8035, 0.4126);
set( 12, 18, 5, 1, 1.7785, 0.4148);
set( 12, 18, 5, 2, 1.7538, 0.4169);
set( 12, 18, 5, 3, 1.7297, 0.4190);
set( 12, 18, 5, 4, 1.7061, 0.4209);
set( 12, 18, 5, 5, 1.6832, 0.4228);
set( 12, 19, 0, 0, 1.7062, 0.4603);
set( 12, 19, 0, 1, 1.6831, 0.4612);
set( 12, 19, 0, 2, 1.6602, 0.4621);
set( 12, 19, 0, 3, 1.6378, 0.4630);
set( 12, 19, 0, 4, 1.6160, 0.4639);
set( 12, 19, 0, 5, 1.5948, 0.4647);
set( 12, 19, 1, 0, 1.7029, 0.4528);
set( 12, 19, 1, 1, 1.6799, 0.4539);
set( 12, 19, 1, 2, 1.6572, 0.4550);
set( 12, 19, 1, 3, 1.6350, 0.4560);
set( 12, 19, 1, 4, 1.6132, 0.4570);
set( 12, 19, 1, 5, 1.5921, 0.4579);
set( 12, 19, 2, 0, 1.6991, 0.4453);
set( 12, 19, 2, 1, 1.6762, 0.4466);
set( 12, 19, 2, 2, 1.6537, 0.4478);
set( 12, 19, 2, 3, 1.6316, 0.4490);
set( 12, 19, 2, 4, 1.6100, 0.4501);
set( 12, 19, 2, 5, 1.5890, 0.4512);
set( 12, 19, 3, 0, 1.6947, 0.4378);
set( 12, 19, 3, 1, 1.6721, 0.4393);
set( 12, 19, 3, 2, 1.6497, 0.4407);
set( 12, 19, 3, 3, 1.6278, 0.4420);
set( 12, 19, 3, 4, 1.6063, 0.4433);
set( 12, 19, 3, 5, 1.5855, 0.4445);
set( 12, 19, 4, 0, 1.6899, 0.4305);
set( 12, 19, 4, 1, 1.6675, 0.4321);
set( 12, 19, 4, 2, 1.6453, 0.4336);
set( 12, 19, 4, 3, 1.6236, 0.4351);
set( 12, 19, 4, 4, 1.6023, 0.4365);
set( 12, 19, 4, 5, 1.5816, 0.4378);
set( 12, 19, 5, 0, 1.6846, 0.4232);
set( 12, 19, 5, 1, 1.6624, 0.4250);
set( 12, 19, 5, 2, 1.6404, 0.4267);
set( 12, 19, 5, 3, 1.6189, 0.4283);
set( 12, 19, 5, 4, 1.5978, 0.4298);
set( 12, 19, 5, 5, 1.5774, 0.4313);
set( 12, 20, 0, 0, 1.5964, 0.4647);
set( 12, 20, 0, 1, 1.5758, 0.4655);
set( 12, 20, 0, 2, 1.5554, 0.4662);
set( 12, 20, 0, 3, 1.5355, 0.4669);
set( 12, 20, 0, 4, 1.5159, 0.4676);
set( 12, 20, 0, 5, 1.4968, 0.4683);
set( 12, 20, 1, 0, 1.5938, 0.4581);
set( 12, 20, 1, 1, 1.5733, 0.4590);
set( 12, 20, 1, 2, 1.5530, 0.4598);
set( 12, 20, 1, 3, 1.5331, 0.4607);
set( 12, 20, 1, 4, 1.5136, 0.4615);
set( 12, 20, 1, 5, 1.4947, 0.4622);
set( 12, 20, 2, 0, 1.5907, 0.4514);
set( 12, 20, 2, 1, 1.5704, 0.4524);
set( 12, 20, 2, 2, 1.5502, 0.4534);
set( 12, 20, 2, 3, 1.5304, 0.4544);
set( 12, 20, 2, 4, 1.5110, 0.4553);
set( 12, 20, 2, 5, 1.4922, 0.4561);
set( 12, 20, 3, 0, 1.5873, 0.4448);
set( 12, 20, 3, 1, 1.5670, 0.4459);
set( 12, 20, 3, 2, 1.5470, 0.4470);
set( 12, 20, 3, 3, 1.5274, 0.4481);
set( 12, 20, 3, 4, 1.5081, 0.4491);
set( 12, 20, 3, 5, 1.4893, 0.4501);
set( 12, 20, 4, 0, 1.5835, 0.4382);
set( 12, 20, 4, 1, 1.5634, 0.4394);
set( 12, 20, 4, 2, 1.5435, 0.4407);
set( 12, 20, 4, 3, 1.5240, 0.4418);
set( 12, 20, 4, 4, 1.5048, 0.4430);
set( 12, 20, 4, 5, 1.4862, 0.4441);
set( 12, 20, 5, 0, 1.5793, 0.4317);
set( 12, 20, 5, 1, 1.5593, 0.4331);
set( 12, 20, 5, 2, 1.5396, 0.4344);
set( 12, 20, 5, 3, 1.5202, 0.4357);
set( 12, 20, 5, 4, 1.5012, 0.4370);
set( 12, 20, 5, 5, 1.4827, 0.4382);
set( 13, 11, 1, 0, 2.9748, 0.0013);
set( 13, 11, 1, 1, 2.9706, 0.0292);
set( 13, 11, 1, 2, 2.9588, 0.0570);
set( 13, 11, 1, 3, 2.9398, 0.0839);
set( 13, 11, 1, 4, 2.9146, 0.1097);
set( 13, 11, 1, 5, 2.8842, 0.1338);
set( 13, 11, 2, 0, 2.8905, 0.0012);
set( 13, 11, 2, 1, 2.8869, 0.0269);
set( 13, 11, 2, 2, 2.8769, 0.0525);
set( 13, 11, 2, 3, 2.8608, 0.0774);
set( 13, 11, 2, 4, 2.8391, 0.1014);
set( 13, 11, 2, 5, 2.8129, 0.1241);
set( 13, 11, 3, 0, 2.8120, 0.0011);
set( 13, 11, 3, 1, 2.8089, 0.0249);
set( 13, 11, 3, 2, 2.8004, 0.0486);
set( 13, 11, 3, 3, 2.7865, 0.0718);
set( 13, 11, 3, 4, 2.7678, 0.0942);
set( 13, 11, 3, 5, 2.7450, 0.1156);
set( 13, 11, 4, 0, 2.7392, 0.0010);
set( 13, 11, 4, 1, 2.7366, 0.0231);
set( 13, 11, 4, 2, 2.7292, 0.0452);
set( 13, 11, 4, 3, 2.7171, 0.0669);
set( 13, 11, 4, 4, 2.7008, 0.0880);
set( 13, 11, 4, 5, 2.6809, 0.1081);
set( 13, 11, 5, 0, 2.6720, 0.0009);
set( 13, 11, 5, 1, 2.6697, 0.0216);
set( 13, 11, 5, 2, 2.6632, 0.0423);
set( 13, 11, 5, 3, 2.6527, 0.0627);
set( 13, 11, 5, 4, 2.6383, 0.0825);
set( 13, 11, 5, 5, 2.6207, 0.1015);
set( 13, 12, 0, 0, 2.9573, 0.1475);
set( 13, 12, 0, 1, 2.9168, 0.1712);
set( 13, 12, 0, 2, 2.8726, 0.1931);
set( 13, 12, 0, 3, 2.8261, 0.2132);
set( 13, 12, 0, 4, 2.7783, 0.2314);
set( 13, 12, 0, 5, 2.7303, 0.2478);
set( 13, 12, 1, 0, 2.8823, 0.1362);
set( 13, 12, 1, 1, 2.8472, 0.1586);
set( 13, 12, 1, 2, 2.8085, 0.1796);
set( 13, 12, 1, 3, 2.7674, 0.1991);
set( 13, 12, 1, 4, 2.7247, 0.2169);
set( 13, 12, 1, 5, 2.6813, 0.2332);
set( 13, 12, 2, 0, 2.8108, 0.1262);
set( 13, 12, 2, 1, 2.7803, 0.1475);
set( 13, 12, 2, 2, 2.7462, 0.1676);
set( 13, 12, 2, 3, 2.7098, 0.1864);
set( 13, 12, 2, 4, 2.6715, 0.2038);
set( 13, 12, 2, 5, 2.6324, 0.2198);
set( 13, 12, 3, 0, 2.7433, 0.1176);
set( 13, 12, 3, 1, 2.7165, 0.1378);
set( 13, 12, 3, 2, 2.6865, 0.1570);
set( 13, 12, 3, 3, 2.6540, 0.1751);
set( 13, 12, 3, 4, 2.6196, 0.1920);
set( 13, 12, 3, 5, 2.5842, 0.2076);
set( 13, 12, 4, 0, 2.6795, 0.1100);
set( 13, 12, 4, 1, 2.6558, 0.1292);
set( 13, 12, 4, 2, 2.6291, 0.1476);
set( 13, 12, 4, 3, 2.6001, 0.1650);
set( 13, 12, 4, 4, 2.5691, 0.1813);
set( 13, 12, 4, 5, 2.5370, 0.1966);
set( 13, 12, 5, 0, 2.6196, 0.1034);
set( 13, 12, 5, 1, 2.5986, 0.1216);
set( 13, 12, 5, 2, 2.5747, 0.1392);
set( 13, 12, 5, 3, 2.5485, 0.1559);
set( 13, 12, 5, 4, 2.5205, 0.1718);
set( 13, 12, 5, 5, 2.4913, 0.1866);
set( 13, 13, 0, 0, 2.7265, 0.2493);
set( 13, 13, 0, 1, 2.6785, 0.2640);
set( 13, 13, 0, 2, 2.6304, 0.2775);
set( 13, 13, 0, 3, 2.5830, 0.2898);
set( 13, 13, 0, 4, 2.5364, 0.3010);
set( 13, 13, 0, 5, 2.4913, 0.3111);
set( 13, 13, 1, 0, 2.6781, 0.2347);
set( 13, 13, 1, 1, 2.6343, 0.2494);
set( 13, 13, 1, 2, 2.5901, 0.2630);
set( 13, 13, 1, 3, 2.5462, 0.2755);
set( 13, 13, 1, 4, 2.5028, 0.2869);
set( 13, 13, 1, 5, 2.4604, 0.2973);
set( 13, 13, 2, 0, 2.6297, 0.2213);
set( 13, 13, 2, 1, 2.5898, 0.2359);
set( 13, 13, 2, 2, 2.5492, 0.2495);
set( 13, 13, 2, 3, 2.5085, 0.2621);
set( 13, 13, 2, 4, 2.4682, 0.2736);
set( 13, 13, 2, 5, 2.4286, 0.2842);
set( 13, 13, 3, 0, 2.5820, 0.2091);
set( 13, 13, 3, 1, 2.5456, 0.2235);
set( 13, 13, 3, 2, 2.5083, 0.2371);
set( 13, 13, 3, 3, 2.4707, 0.2496);
set( 13, 13, 3, 4, 2.4332, 0.2612);
set( 13, 13, 3, 5, 2.3961, 0.2719);
set( 13, 13, 4, 0, 2.5352, 0.1981);
set( 13, 13, 4, 1, 2.5019, 0.2122);
set( 13, 13, 4, 2, 2.4676, 0.2256);
set( 13, 13, 4, 3, 2.4329, 0.2380);
set( 13, 13, 4, 4, 2.3980, 0.2497);
set( 13, 13, 4, 5, 2.3634, 0.2604);
set( 13, 13, 5, 0, 2.4899, 0.1881);
set( 13, 13, 5, 1, 2.4594, 0.2019);
set( 13, 13, 5, 2, 2.4278, 0.2151);
set( 13, 13, 5, 3, 2.3957, 0.2274);
set( 13, 13, 5, 4, 2.3632, 0.2390);
set( 13, 13, 5, 5, 2.3309, 0.2497);
set( 13, 14, 0, 0, 2.4883, 0.3120);
set( 13, 14, 0, 1, 2.4445, 0.3212);
set( 13, 14, 0, 2, 2.4013, 0.3297);
set( 13, 14, 0, 3, 2.3594, 0.3374);
set( 13, 14, 0, 4, 2.3186, 0.3446);
set( 13, 14, 0, 5, 2.2794, 0.3512);
set( 13, 14, 1, 0, 2.4579, 0.2983);
set( 13, 14, 1, 1, 2.4165, 0.3078);
set( 13, 14, 1, 2, 2.3756, 0.3165);
set( 13, 14, 1, 3, 2.3357, 0.3247);
set( 13, 14, 1, 4, 2.2967, 0.3322);
set( 13, 14, 1, 5, 2.2591, 0.3390);
set( 13, 14, 2, 0, 2.4263, 0.2853);
set( 13, 14, 2, 1, 2.3874, 0.2949);
set( 13, 14, 2, 2, 2.3487, 0.3040);
set( 13, 14, 2, 3, 2.3108, 0.3124);
set( 13, 14, 2, 4, 2.2737, 0.3202);
set( 13, 14, 2, 5, 2.2377, 0.3273);
set( 13, 14, 3, 0, 2.3942, 0.2730);
set( 13, 14, 3, 1, 2.3576, 0.2829);
set( 13, 14, 3, 2, 2.3211, 0.2921);
set( 13, 14, 3, 3, 2.2852, 0.3007);
set( 13, 14, 3, 4, 2.2498, 0.3087);
set( 13, 14, 3, 5, 2.2154, 0.3161);
set( 13, 14, 4, 0, 2.3619, 0.2615);
set( 13, 14, 4, 1, 2.3275, 0.2715);
set( 13, 14, 4, 2, 2.2930, 0.2808);
set( 13, 14, 4, 3, 2.2589, 0.2896);
set( 13, 14, 4, 4, 2.2254, 0.2978);
set( 13, 14, 4, 5, 2.1926, 0.3053);
set( 13, 14, 5, 0, 2.3296, 0.2509);
set( 13, 14, 5, 1, 2.2973, 0.2609);
set( 13, 14, 5, 2, 2.2648, 0.2703);
set( 13, 14, 5, 3, 2.2325, 0.2792);
set( 13, 14, 5, 4, 2.2006, 0.2875);
set( 13, 14, 5, 5, 2.1694, 0.2952);
set( 13, 15, 0, 0, 2.2774, 0.3518);
set( 13, 15, 0, 1, 2.2395, 0.3578);
set( 13, 15, 0, 2, 2.2023, 0.3634);
set( 13, 15, 0, 3, 2.1662, 0.3686);
set( 13, 15, 0, 4, 2.1311, 0.3735);
set( 13, 15, 0, 5, 2.0974, 0.3780);
set( 13, 15, 1, 0, 2.2574, 0.3397);
set( 13, 15, 1, 1, 2.2209, 0.3460);
set( 13, 15, 1, 2, 2.1850, 0.3520);
set( 13, 15, 1, 3, 2.1501, 0.3575);
set( 13, 15, 1, 4, 2.1161, 0.3627);
set( 13, 15, 1, 5, 2.0833, 0.3675);
set( 13, 15, 2, 0, 2.2362, 0.3281);
set( 13, 15, 2, 1, 2.2012, 0.3347);
set( 13, 15, 2, 2, 2.1666, 0.3409);
set( 13, 15, 2, 3, 2.1329, 0.3467);
set( 13, 15, 2, 4, 2.1000, 0.3521);
set( 13, 15, 2, 5, 2.0682, 0.3572);
set( 13, 15, 3, 0, 2.2142, 0.3169);
set( 13, 15, 3, 1, 2.1806, 0.3237);
set( 13, 15, 3, 2, 2.1474, 0.3302);
set( 13, 15, 3, 3, 2.1149, 0.3362);
set( 13, 15, 3, 4, 2.0832, 0.3419);
set( 13, 15, 3, 5, 2.0524, 0.3472);
set( 13, 15, 4, 0, 2.1916, 0.3062);
set( 13, 15, 4, 1, 2.1594, 0.3132);
set( 13, 15, 4, 2, 2.1276, 0.3199);
set( 13, 15, 4, 3, 2.0963, 0.3261);
set( 13, 15, 4, 4, 2.0657, 0.3320);
set( 13, 15, 4, 5, 2.0359, 0.3375);
set( 13, 15, 5, 0, 2.1686, 0.2961);
set( 13, 15, 5, 1, 2.1379, 0.3033);
set( 13, 15, 5, 2, 2.1073, 0.3101);
set( 13, 15, 5, 3, 2.0773, 0.3165);
set( 13, 15, 5, 4, 2.0477, 0.3226);
set( 13, 15, 5, 5, 2.0190, 0.3282);
set( 13, 16, 0, 0, 2.0963, 0.3784);
set( 13, 16, 0, 1, 2.0637, 0.3826);
set( 13, 16, 0, 2, 2.0316, 0.3865);
set( 13, 16, 0, 3, 2.0004, 0.3902);
set( 13, 16, 0, 4, 1.9701, 0.3937);
set( 13, 16, 0, 5, 1.9408, 0.3970);
set( 13, 16, 1, 0, 2.0824, 0.3680);
set( 13, 16, 1, 1, 2.0506, 0.3724);
set( 13, 16, 1, 2, 2.0194, 0.3766);
set( 13, 16, 1, 3, 1.9889, 0.3806);
set( 13, 16, 1, 4, 1.9592, 0.3843);
set( 13, 16, 1, 5, 1.9305, 0.3878);
set( 13, 16, 2, 0, 2.0675, 0.3577);
set( 13, 16, 2, 1, 2.0366, 0.3624);
set( 13, 16, 2, 2, 2.0062, 0.3669);
set( 13, 16, 2, 3, 1.9765, 0.3711);
set( 13, 16, 2, 4, 1.9475, 0.3751);
set( 13, 16, 2, 5, 1.9194, 0.3788);
set( 13, 16, 3, 0, 2.0519, 0.3478);
set( 13, 16, 3, 1, 2.0219, 0.3527);
set( 13, 16, 3, 2, 1.9923, 0.3574);
set( 13, 16, 3, 3, 1.9634, 0.3618);
set( 13, 16, 3, 4, 1.9351, 0.3660);
set( 13, 16, 3, 5, 1.9078, 0.3699);
set( 13, 16, 4, 0, 2.0356, 0.3382);
set( 13, 16, 4, 1, 2.0065, 0.3433);
set( 13, 16, 4, 2, 1.9778, 0.3482);
set( 13, 16, 4, 3, 1.9497, 0.3528);
set( 13, 16, 4, 4, 1.9222, 0.3572);
set( 13, 16, 4, 5, 1.8955, 0.3613);
set( 13, 16, 5, 0, 2.0189, 0.3290);
set( 13, 16, 5, 1, 1.9907, 0.3343);
set( 13, 16, 5, 2, 1.9629, 0.3393);
set( 13, 16, 5, 3, 1.9356, 0.3441);
set( 13, 16, 5, 4, 1.9088, 0.3486);
set( 13, 16, 5, 5, 1.8828, 0.3529);
set( 13, 17, 0, 0, 1.9406, 0.3973);
set( 13, 17, 0, 1, 1.9122, 0.4003);
set( 13, 17, 0, 2, 1.8843, 0.4033);
set( 13, 17, 0, 3, 1.8571, 0.4060);
set( 13, 17, 0, 4, 1.8305, 0.4086);
set( 13, 17, 0, 5, 1.8048, 0.4111);
set( 13, 17, 1, 0, 1.9304, 0.3882);
set( 13, 17, 1, 1, 1.9026, 0.3915);
set( 13, 17, 1, 2, 1.8752, 0.3946);
set( 13, 17, 1, 3, 1.8485, 0.3976);
set( 13, 17, 1, 4, 1.8223, 0.4004);
set( 13, 17, 1, 5, 1.7970, 0.4030);
set( 13, 17, 2, 0, 1.9195, 0.3792);
set( 13, 17, 2, 1, 1.8923, 0.3827);
set( 13, 17, 2, 2, 1.8654, 0.3860);
set( 13, 17, 2, 3, 1.8391, 0.3892);
set( 13, 17, 2, 4, 1.8135, 0.3922);
set( 13, 17, 2, 5, 1.7886, 0.3950);
set( 13, 17, 3, 0, 1.9079, 0.3704);
set( 13, 17, 3, 1, 1.8813, 0.3741);
set( 13, 17, 3, 2, 1.8550, 0.3776);
set( 13, 17, 3, 3, 1.8293, 0.3809);
set( 13, 17, 3, 4, 1.8041, 0.3841);
set( 13, 17, 3, 5, 1.7797, 0.3871);
set( 13, 17, 4, 0, 1.8958, 0.3618);
set( 13, 17, 4, 1, 1.8698, 0.3657);
set( 13, 17, 4, 2, 1.8441, 0.3694);
set( 13, 17, 4, 3, 1.8189, 0.3729);
set( 13, 17, 4, 4, 1.7942, 0.3762);
set( 13, 17, 4, 5, 1.7703, 0.3793);
set( 13, 17, 5, 0, 1.8833, 0.3535);
set( 13, 17, 5, 1, 1.8579, 0.3575);
set( 13, 17, 5, 2, 1.8327, 0.3614);
set( 13, 17, 5, 3, 1.8081, 0.3650);
set( 13, 17, 5, 4, 1.7839, 0.3685);
set( 13, 17, 5, 5, 1.7605, 0.3718);
set( 13, 18, 0, 0, 1.8053, 0.4113);
set( 13, 18, 0, 1, 1.7804, 0.4136);
set( 13, 18, 0, 2, 1.7558, 0.4158);
set( 13, 18, 0, 3, 1.7318, 0.4180);
set( 13, 18, 0, 4, 1.7083, 0.4200);
set( 13, 18, 0, 5, 1.6855, 0.4219);
set( 13, 18, 1, 0, 1.7976, 0.4033);
set( 13, 18, 1, 1, 1.7731, 0.4058);
set( 13, 18, 1, 2, 1.7488, 0.4082);
set( 13, 18, 1, 3, 1.7251, 0.4105);
set( 13, 18, 1, 4, 1.7019, 0.4127);
set( 13, 18, 1, 5, 1.6794, 0.4147);
set( 13, 18, 2, 0, 1.7893, 0.3953);
set( 13, 18, 2, 1, 1.7652, 0.3980);
set( 13, 18, 2, 2, 1.7413, 0.4006);
set( 13, 18, 2, 3, 1.7179, 0.4030);
set( 13, 18, 2, 4, 1.6950, 0.4053);
set( 13, 18, 2, 5, 1.6728, 0.4076);
set( 13, 18, 3, 0, 1.7805, 0.3875);
set( 13, 18, 3, 1, 1.7567, 0.3903);
set( 13, 18, 3, 2, 1.7332, 0.3931);
set( 13, 18, 3, 3, 1.7102, 0.3956);
set( 13, 18, 3, 4, 1.6877, 0.3981);
set( 13, 18, 3, 5, 1.6658, 0.4005);
set( 13, 18, 4, 0, 1.7712, 0.3798);
set( 13, 18, 4, 1, 1.7479, 0.3828);
set( 13, 18, 4, 2, 1.7248, 0.3857);
set( 13, 18, 4, 3, 1.7021, 0.3884);
set( 13, 18, 4, 4, 1.6800, 0.3910);
set( 13, 18, 4, 5, 1.6584, 0.3935);
set( 13, 18, 5, 0, 1.7615, 0.3724);
set( 13, 18, 5, 1, 1.7386, 0.3755);
set( 13, 18, 5, 2, 1.7159, 0.3785);
set( 13, 18, 5, 3, 1.6937, 0.3813);
set( 13, 18, 5, 4, 1.6719, 0.3841);
set( 13, 18, 5, 5, 1.6506, 0.3867);
set( 13, 19, 0, 0, 1.6866, 0.4221);
set( 13, 19, 0, 1, 1.6645, 0.4239);
set( 13, 19, 0, 2, 1.6426, 0.4257);
set( 13, 19, 0, 3, 1.6211, 0.4273);
set( 13, 19, 0, 4, 1.6001, 0.4290);
set( 13, 19, 0, 5, 1.5797, 0.4305);
set( 13, 19, 1, 0, 1.6806, 0.4150);
set( 13, 19, 1, 1, 1.6587, 0.4169);
set( 13, 19, 1, 2, 1.6371, 0.4188);
set( 13, 19, 1, 3, 1.6158, 0.4206);
set( 13, 19, 1, 4, 1.5950, 0.4224);
set( 13, 19, 1, 5, 1.5748, 0.4240);
set( 13, 19, 2, 0, 1.6741, 0.4079);
set( 13, 19, 2, 1, 1.6525, 0.4100);
set( 13, 19, 2, 2, 1.6311, 0.4120);
set( 13, 19, 2, 3, 1.6101, 0.4139);
set( 13, 19, 2, 4, 1.5895, 0.4158);
set( 13, 19, 2, 5, 1.5695, 0.4176);
set( 13, 19, 3, 0, 1.6672, 0.4008);
set( 13, 19, 3, 1, 1.6458, 0.4031);
set( 13, 19, 3, 2, 1.6247, 0.4052);
set( 13, 19, 3, 3, 1.6040, 0.4073);
set( 13, 19, 3, 4, 1.5837, 0.4093);
set( 13, 19, 3, 5, 1.5639, 0.4112);
set( 13, 19, 4, 0, 1.6598, 0.3939);
set( 13, 19, 4, 1, 1.6388, 0.3963);
set( 13, 19, 4, 2, 1.6180, 0.3986);
set( 13, 19, 4, 3, 1.5975, 0.4007);
set( 13, 19, 4, 4, 1.5775, 0.4028);
set( 13, 19, 4, 5, 1.5579, 0.4048);
set( 13, 19, 5, 0, 1.6522, 0.3872);
set( 13, 19, 5, 1, 1.6315, 0.3897);
set( 13, 19, 5, 2, 1.6109, 0.3920);
set( 13, 19, 5, 3, 1.5908, 0.3943);
set( 13, 19, 5, 4, 1.5709, 0.3966);
set( 13, 19, 5, 5, 1.5516, 0.3987);
set( 13, 20, 0, 0, 1.5814, 0.4306);
set( 13, 20, 0, 1, 1.5615, 0.4321);
set( 13, 20, 0, 2, 1.5420, 0.4335);
set( 13, 20, 1, 0, 1.5765, 0.4242);
set( 13, 20, 1, 1, 1.5569, 0.4258);
set( 13, 20, 1, 2, 1.5375, 0.4273);
set( 13, 20, 2, 0, 1.5713, 0.4178);
set( 13, 20, 2, 1, 1.5518, 0.4195);
set( 13, 20, 2, 2, 1.5327, 0.4211);
set( 13, 20, 3, 0, 1.5657, 0.4115);
set( 13, 20, 3, 1, 1.5465, 0.4133);
set( 13, 20, 3, 2, 1.5275, 0.4150);
set( 13, 20, 4, 0, 1.5599, 0.4052);
set( 13, 20, 4, 1, 1.5408, 0.4071);
set( 13, 20, 4, 2, 1.5221, 0.4090);
set( 13, 20, 5, 0, 1.5537, 0.3991);
set( 13, 20, 5, 1, 1.5349, 0.4011);
set( 13, 20, 5, 2, 1.5163, 0.4030);
set( 14, 11, 0, 0, 2.6670, 0.0009);
set( 14, 11, 0, 1, 2.6647, 0.0214);
set( 14, 11, 0, 2, 2.6584, 0.0419);
set( 14, 11, 0, 3, 2.6480, 0.0621);
set( 14, 11, 0, 4, 2.6340, 0.0818);
set( 14, 11, 0, 5, 2.6166, 0.1006);
set( 14, 11, 1, 0, 2.6046, 0.0009);
set( 14, 11, 1, 1, 2.6026, 0.0201);
set( 14, 11, 1, 2, 2.5970, 0.0394);
set( 14, 11, 1, 3, 2.5878, 0.0584);
set( 14, 11, 1, 4, 2.5753, 0.0770);
set( 14, 11, 1, 5, 2.5599, 0.0949);
set( 14, 11, 2, 0, 2.5453, 0.0008);
set( 14, 11, 2, 1, 2.5435, 0.0190);
set( 14, 11, 2, 2, 2.5385, 0.0372);
set( 14, 11, 2, 3, 2.5304, 0.0551);
set( 14, 11, 2, 4, 2.5192, 0.0728);
set( 14, 11, 2, 5, 2.5054, 0.0898);
set( 14, 11, 3, 0, 2.4893, 0.0008);
set( 14, 11, 3, 1, 2.4878, 0.0179);
set( 14, 11, 3, 2, 2.4833, 0.0352);
set( 14, 11, 3, 3, 2.4760, 0.0522);
set( 14, 11, 3, 4, 2.4660, 0.0689);
set( 14, 11, 3, 5, 2.4536, 0.0851);
set( 14, 11, 4, 0, 2.4364, 0.0007);
set( 14, 11, 4, 1, 2.4349, 0.0170);
set( 14, 11, 4, 2, 2.4309, 0.0334);
set( 14, 11, 4, 3, 2.4243, 0.0496);
set( 14, 11, 4, 4, 2.4153, 0.0655);
set( 14, 11, 4, 5, 2.4041, 0.0810);
set( 14, 11, 5, 0, 2.3865, 0.0007);
set( 14, 11, 5, 1, 2.3852, 0.0162);
set( 14, 11, 5, 2, 2.3816, 0.0318);
set( 14, 11, 5, 3, 2.3756, 0.0472);
set( 14, 11, 5, 4, 2.3674, 0.0624);
set( 14, 11, 5, 5, 2.3572, 0.0772);
set( 14, 12, 0, 0, 2.6152, 0.1024);
set( 14, 12, 0, 1, 2.5946, 0.1205);
set( 14, 12, 0, 2, 2.5712, 0.1380);
set( 14, 12, 0, 3, 2.5455, 0.1546);
set( 14, 12, 0, 4, 2.5180, 0.1704);
set( 14, 12, 0, 5, 2.4893, 0.1852);
set( 14, 12, 1, 0, 2.5588, 0.0966);
set( 14, 12, 1, 1, 2.5403, 0.1139);
set( 14, 12, 1, 2, 2.5192, 0.1306);
set( 14, 12, 1, 3, 2.4960, 0.1466);
set( 14, 12, 1, 4, 2.4711, 0.1619);
set( 14, 12, 1, 5, 2.4448, 0.1762);
set( 14, 12, 2, 0, 2.5045, 0.0914);
set( 14, 12, 2, 1, 2.4879, 0.1079);
set( 14, 12, 2, 2, 2.4689, 0.1239);
set( 14, 12, 2, 3, 2.4479, 0.1393);
set( 14, 12, 2, 4, 2.4251, 0.1540);
set( 14, 12, 2, 5, 2.4012, 0.1679);
set( 14, 12, 3, 0, 2.4529, 0.0867);
set( 14, 12, 3, 1, 2.4379, 0.1024);
set( 14, 12, 3, 2, 2.4206, 0.1178);
set( 14, 12, 3, 3, 2.4015, 0.1326);
set( 14, 12, 3, 4, 2.3807, 0.1468);
set( 14, 12, 3, 5, 2.3588, 0.1603);
set( 14, 12, 4, 0, 2.4036, 0.0824);
set( 14, 12, 4, 1, 2.3900, 0.0975);
set( 14, 12, 4, 2, 2.3743, 0.1122);
set( 14, 12, 4, 3, 2.3568, 0.1265);
set( 14, 12, 4, 4, 2.3378, 0.1402);
set( 14, 12, 4, 5, 2.3176, 0.1533);
set( 14, 12, 5, 0, 2.3569, 0.0786);
set( 14, 12, 5, 1, 2.3445, 0.0930);
set( 14, 12, 5, 2, 2.3301, 0.1072);
set( 14, 12, 5, 3, 2.3141, 0.1209);
set( 14, 12, 5, 4, 2.2966, 0.1342);
set( 14, 12, 5, 5, 2.2780, 0.1469);
set( 14, 13, 0, 0, 2.4873, 0.1866);
set( 14, 13, 0, 1, 2.4573, 0.2004);
set( 14, 13, 0, 2, 2.4263, 0.2135);
set( 14, 13, 0, 3, 2.3946, 0.2259);
set( 14, 13, 0, 4, 2.3625, 0.2375);
set( 14, 13, 0, 5, 2.3306, 0.2482);
set( 14, 13, 1, 0, 2.4432, 0.1776);
set( 14, 13, 1, 1, 2.4157, 0.1911);
set( 14, 13, 1, 2, 2.3870, 0.2040);
set( 14, 13, 1, 3, 2.3576, 0.2162);
set( 14, 13, 1, 4, 2.3278, 0.2276);
set( 14, 13, 1, 5, 2.2980, 0.2383);
set( 14, 13, 2, 0, 2.3998, 0.1693);
set( 14, 13, 2, 1, 2.3746, 0.1824);
set( 14, 13, 2, 2, 2.3481, 0.1951);
set( 14, 13, 2, 3, 2.3209, 0.2070);
set( 14, 13, 2, 4, 2.2931, 0.2184);
set( 14, 13, 2, 5, 2.2652, 0.2290);
set( 14, 13, 3, 0, 2.3577, 0.1616);
set( 14, 13, 3, 1, 2.3344, 0.1744);
set( 14, 13, 3, 2, 2.3099, 0.1868);
set( 14, 13, 3, 3, 2.2847, 0.1985);
set( 14, 13, 3, 4, 2.2588, 0.2097);
set( 14, 13, 3, 5, 2.2327, 0.2202);
set( 14, 13, 4, 0, 2.3168, 0.1546);
set( 14, 13, 4, 1, 2.2953, 0.1671);
set( 14, 13, 4, 2, 2.2726, 0.1791);
set( 14, 13, 4, 3, 2.2491, 0.1906);
set( 14, 13, 4, 4, 2.2250, 0.2016);
set( 14, 13, 4, 5, 2.2005, 0.2120);
set( 14, 13, 5, 0, 2.2774, 0.1482);
set( 14, 13, 5, 1, 2.2575, 0.1603);
set( 14, 13, 5, 2, 2.2364, 0.1721);
set( 14, 13, 5, 3, 2.2145, 0.1834);
set( 14, 13, 5, 4, 2.1920, 0.1941);
set( 14, 13, 5, 5, 2.1690, 0.2044);
set( 14, 14, 0, 0, 2.3288, 0.2492);
set( 14, 14, 0, 1, 2.2969, 0.2592);
set( 14, 14, 0, 2, 2.2648, 0.2687);
set( 14, 14, 0, 3, 2.2330, 0.2776);
set( 14, 14, 0, 4, 2.2014, 0.2859);
set( 14, 14, 0, 5, 2.1704, 0.2937);
set( 14, 14, 1, 0, 2.2965, 0.2393);
set( 14, 14, 1, 1, 2.2665, 0.2493);
set( 14, 14, 1, 2, 2.2362, 0.2589);
set( 14, 14, 1, 3, 2.2061, 0.2678);
set( 14, 14, 1, 4, 2.1761, 0.2762);
set( 14, 14, 1, 5, 2.1466, 0.2841);
set( 14, 14, 2, 0, 2.2640, 0.2300);
set( 14, 14, 2, 1, 2.2358, 0.2400);
set( 14, 14, 2, 2, 2.2073, 0.2495);
set( 14, 14, 2, 3, 2.1788, 0.2585);
set( 14, 14, 2, 4, 2.1503, 0.2669);
set( 14, 14, 2, 5, 2.1223, 0.2749);
set( 14, 14, 3, 0, 2.2317, 0.2213);
set( 14, 14, 3, 1, 2.2053, 0.2312);
set( 14, 14, 3, 2, 2.1784, 0.2406);
set( 14, 14, 3, 3, 2.1514, 0.2496);
set( 14, 14, 3, 4, 2.1245, 0.2581);
set( 14, 14, 3, 5, 2.0978, 0.2661);
set( 14, 14, 4, 0, 2.1998, 0.2131);
set( 14, 14, 4, 1, 2.1750, 0.2228);
set( 14, 14, 4, 2, 2.1496, 0.2322);
set( 14, 14, 4, 3, 2.1241, 0.2412);
set( 14, 14, 4, 4, 2.0986, 0.2497);
set( 14, 14, 4, 5, 2.0732, 0.2577);
set( 14, 14, 5, 0, 2.1686, 0.2054);
set( 14, 14, 5, 1, 2.1452, 0.2151);
set( 14, 14, 5, 2, 2.1213, 0.2244);
set( 14, 14, 5, 3, 2.0972, 0.2333);
set( 14, 14, 5, 4, 2.0729, 0.2418);
set( 14, 14, 5, 5, 2.0488, 0.2498);
set( 14, 15, 0, 0, 2.1692, 0.2944);
set( 14, 15, 0, 1, 2.1388, 0.3017);
set( 14, 15, 0, 2, 2.1085, 0.3086);
set( 14, 15, 0, 3, 2.0787, 0.3151);
set( 14, 15, 0, 4, 2.0494, 0.3212);
set( 14, 15, 0, 5, 2.0209, 0.3269);
set( 14, 15, 1, 0, 2.1456, 0.2849);
set( 14, 15, 1, 1, 2.1165, 0.2922);
set( 14, 15, 1, 2, 2.0875, 0.2993);
set( 14, 15, 1, 3, 2.0589, 0.3059);
set( 14, 15, 1, 4, 2.0308, 0.3121);
set( 14, 15, 1, 5, 2.0032, 0.3180);
set( 14, 15, 2, 0, 2.1215, 0.2757);
set( 14, 15, 2, 1, 2.0938, 0.2831);
set( 14, 15, 2, 2, 2.0660, 0.2902);
set( 14, 15, 2, 3, 2.0386, 0.2970);
set( 14, 15, 2, 4, 2.0115, 0.3034);
set( 14, 15, 2, 5, 1.9850, 0.3094);
set( 14, 15, 3, 0, 2.0973, 0.2669);
set( 14, 15, 3, 1, 2.0708, 0.2744);
set( 14, 15, 3, 2, 2.0442, 0.2816);
set( 14, 15, 3, 3, 2.0179, 0.2884);
set( 14, 15, 3, 4, 1.9919, 0.2949);
set( 14, 15, 3, 5, 1.9664, 0.3010);
set( 14, 15, 4, 0, 2.0729, 0.2586);
set( 14, 15, 4, 1, 2.0476, 0.2661);
set( 14, 15, 4, 2, 2.0223, 0.2733);
set( 14, 15, 4, 3, 1.9971, 0.2802);
set( 14, 15, 4, 4, 1.9721, 0.2868);
set( 14, 15, 4, 5, 1.9475, 0.2930);
set( 14, 15, 5, 0, 2.0487, 0.2507);
set( 14, 15, 5, 1, 2.0246, 0.2582);
set( 14, 15, 5, 2, 2.0003, 0.2655);
set( 14, 15, 5, 3, 1.9762, 0.2724);
set( 14, 15, 5, 4, 1.9522, 0.2790);
set( 14, 15, 5, 5, 1.9285, 0.2853);
set( 14, 16, 0, 0, 2.0203, 0.3274);
set( 14, 16, 0, 1, 1.9925, 0.3328);
set( 14, 16, 0, 2, 1.9648, 0.3379);
set( 14, 16, 0, 3, 1.9377, 0.3428);
set( 14, 16, 0, 4, 1.9112, 0.3474);
set( 14, 16, 0, 5, 1.8853, 0.3517);
set( 14, 16, 1, 0, 2.0028, 0.3186);
set( 14, 16, 1, 1, 1.9759, 0.3241);
set( 14, 16, 1, 2, 1.9491, 0.3294);
set( 14, 16, 1, 3, 1.9228, 0.3344);
set( 14, 16, 1, 4, 1.8970, 0.3391);
set( 14, 16, 1, 5, 1.8719, 0.3436);
set( 14, 16, 2, 0, 1.9848, 0.3100);
set( 14, 16, 2, 1, 1.9587, 0.3156);
set( 14, 16, 2, 2, 1.9329, 0.3210);
set( 14, 16, 2, 3, 1.9074, 0.3262);
set( 14, 16, 2, 4, 1.8823, 0.3310);
set( 14, 16, 2, 5, 1.8579, 0.3356);
set( 14, 16, 3, 0, 1.9664, 0.3017);
set( 14, 16, 3, 1, 1.9412, 0.3074);
set( 14, 16, 3, 2, 1.9162, 0.3129);
set( 14, 16, 3, 3, 1.8916, 0.3182);
set( 14, 16, 3, 4, 1.8672, 0.3232);
set( 14, 16, 3, 5, 1.8435, 0.3279);
set( 14, 16, 4, 0, 1.9477, 0.2937);
set( 14, 16, 4, 1, 1.9235, 0.2995);
set( 14, 16, 4, 2, 1.8993, 0.3051);
set( 14, 16, 4, 3, 1.8754, 0.3105);
set( 14, 16, 4, 4, 1.8518, 0.3156);
set( 14, 16, 4, 5, 1.8288, 0.3204);
set( 14, 16, 5, 0, 1.9289, 0.2860);
set( 14, 16, 5, 1, 1.9055, 0.2919);
set( 14, 16, 5, 2, 1.8822, 0.2976);
set( 14, 16, 5, 3, 1.8591, 0.3031);
set( 14, 16, 5, 4, 1.8363, 0.3083);
set( 14, 16, 5, 5, 1.8139, 0.3132);
set( 14, 17, 0, 0, 1.8854, 0.3521);
set( 14, 17, 0, 1, 1.8602, 0.3561);
set( 14, 17, 0, 2, 1.8352, 0.3601);
set( 14, 17, 0, 3, 1.8107, 0.3638);
set( 14, 17, 0, 4, 1.7867, 0.3674);
set( 14, 17, 0, 5, 1.7634, 0.3707);
set( 14, 17, 1, 0, 1.8721, 0.3440);
set( 14, 17, 1, 1, 1.8475, 0.3483);
set( 14, 17, 1, 2, 1.8231, 0.3523);
set( 14, 17, 1, 3, 1.7992, 0.3562);
set( 14, 17, 1, 4, 1.7757, 0.3599);
set( 14, 17, 1, 5, 1.7529, 0.3634);
set( 14, 17, 2, 0, 1.8582, 0.3362);
set( 14, 17, 2, 1, 1.8343, 0.3405);
set( 14, 17, 2, 2, 1.8106, 0.3447);
set( 14, 17, 2, 3, 1.7872, 0.3487);
set( 14, 17, 2, 4, 1.7643, 0.3525);
set( 14, 17, 2, 5, 1.7419, 0.3561);
set( 14, 17, 3, 0, 1.8440, 0.3285);
set( 14, 17, 3, 1, 1.8207, 0.3329);
set( 14, 17, 3, 2, 1.7976, 0.3372);
set( 14, 17, 3, 3, 1.7748, 0.3414);
set( 14, 17, 3, 4, 1.7524, 0.3453);
set( 14, 17, 3, 5, 1.7306, 0.3490);
set( 14, 17, 4, 0, 1.8295, 0.3210);
set( 14, 17, 4, 1, 1.8068, 0.3256);
set( 14, 17, 4, 2, 1.7843, 0.3300);
set( 14, 17, 4, 3, 1.7621, 0.3342);
set( 14, 17, 4, 4, 1.7403, 0.3382);
set( 14, 17, 4, 5, 1.7189, 0.3421);
set( 14, 17, 5, 0, 1.8148, 0.3138);
set( 14, 17, 5, 1, 1.7928, 0.3185);
set( 14, 17, 5, 2, 1.7708, 0.3230);
set( 14, 17, 5, 3, 1.7492, 0.3273);
set( 14, 17, 5, 4, 1.7279, 0.3314);
set( 14, 17, 5, 5, 1.7071, 0.3354);
set( 14, 18, 0, 0, 1.7640, 0.3710);
set( 14, 18, 0, 1, 1.7413, 0.3742);
set( 14, 18, 0, 2, 1.7187, 0.3773);
set( 14, 18, 0, 3, 1.6966, 0.3802);
set( 14, 18, 0, 4, 1.6749, 0.3830);
set( 14, 18, 0, 5, 1.6538, 0.3857);
set( 14, 18, 1, 0, 1.7537, 0.3637);
set( 14, 18, 1, 1, 1.7314, 0.3670);
set( 14, 18, 1, 2, 1.7092, 0.3702);
set( 14, 18, 1, 3, 1.6875, 0.3733);
set( 14, 18, 1, 4, 1.6662, 0.3762);
set( 14, 18, 1, 5, 1.6454, 0.3790);
set( 14, 18, 2, 0, 1.7428, 0.3565);
set( 14, 18, 2, 1, 1.7210, 0.3600);
set( 14, 18, 2, 2, 1.6993, 0.3633);
set( 14, 18, 2, 3, 1.6780, 0.3665);
set( 14, 18, 2, 4, 1.6570, 0.3695);
set( 14, 18, 2, 5, 1.6366, 0.3724);
set( 14, 18, 3, 0, 1.7316, 0.3495);
set( 14, 18, 3, 1, 1.7102, 0.3530);
set( 14, 18, 3, 2, 1.6890, 0.3565);
set( 14, 18, 3, 3, 1.6681, 0.3597);
set( 14, 18, 3, 4, 1.6476, 0.3629);
set( 14, 18, 3, 5, 1.6275, 0.3659);
set( 14, 18, 4, 0, 1.7201, 0.3426);
set( 14, 18, 4, 1, 1.6992, 0.3463);
set( 14, 18, 4, 2, 1.6784, 0.3498);
set( 14, 18, 4, 3, 1.6579, 0.3532);
set( 14, 18, 4, 4, 1.6378, 0.3564);
set( 14, 18, 4, 5, 1.6181, 0.3595);
set( 14, 18, 5, 0, 1.7084, 0.3359);
set( 14, 18, 5, 1, 1.6880, 0.3397);
set( 14, 18, 5, 2, 1.6676, 0.3433);
set( 14, 18, 5, 3, 1.6476, 0.3468);
set( 14, 18, 5, 4, 1.6278, 0.3501);
set( 14, 18, 5, 5, 1.6085, 0.3533);
set( 14, 19, 0, 0, 1.6550, 0.3859);
set( 14, 19, 0, 1, 1.6344, 0.3885);
set( 14, 19, 0, 2, 1.6139, 0.3909);
set( 14, 19, 0, 3, 1.5939, 0.3933);
set( 14, 19, 0, 4, 1.5742, 0.3956);
set( 14, 19, 0, 5, 1.5549, 0.3978);
set( 14, 19, 1, 0, 1.6467, 0.3793);
set( 14, 19, 1, 1, 1.6264, 0.3820);
set( 14, 19, 1, 2, 1.6063, 0.3845);
set( 14, 19, 1, 3, 1.5865, 0.3870);
set( 14, 19, 1, 4, 1.5671, 0.3894);
set( 14, 19, 1, 5, 1.5481, 0.3917);
set( 14, 19, 2, 0, 1.6380, 0.3728);
set( 14, 19, 2, 1, 1.6181, 0.3755);
set( 14, 19, 2, 2, 1.5983, 0.3782);
set( 14, 19, 2, 3, 1.5788, 0.3808);
set( 14, 19, 2, 4, 1.5597, 0.3833);
set( 14, 19, 2, 5, 1.5410, 0.3856);
set( 14, 19, 3, 0, 1.6290, 0.3663);
set( 14, 19, 3, 1, 1.6094, 0.3692);
set( 14, 19, 3, 2, 1.5900, 0.3719);
set( 14, 19, 3, 3, 1.5708, 0.3746);
set( 14, 19, 3, 4, 1.5519, 0.3772);
set( 14, 19, 3, 5, 1.5335, 0.3796);
set( 14, 19, 4, 0, 1.6198, 0.3600);
set( 14, 19, 4, 1, 1.6005, 0.3629);
set( 14, 19, 4, 2, 1.5814, 0.3658);
set( 14, 19, 4, 3, 1.5625, 0.3686);
set( 14, 19, 4, 4, 1.5440, 0.3712);
set( 14, 19, 4, 5, 1.5258, 0.3738);
set( 14, 19, 5, 0, 1.6103, 0.3538);
set( 14, 19, 5, 1, 1.5914, 0.3569);
set( 14, 19, 5, 2, 1.5726, 0.3598);
set( 14, 19, 5, 3, 1.5540, 0.3627);
set( 14, 19, 5, 4, 1.5358, 0.3654);
set( 14, 19, 5, 5, 1.5179, 0.3680);
set( 15, 11, 0, 0, 2.3835, 0.0007);
set( 15, 11, 0, 1, 2.3822, 0.0161);
set( 15, 11, 0, 2, 2.3787, 0.0315);
set( 15, 11, 0, 3, 2.3728, 0.0468);
set( 15, 11, 0, 4, 2.3648, 0.0618);
set( 15, 11, 0, 5, 2.3548, 0.0765);
set( 15, 11, 1, 0, 2.3364, 0.0007);
set( 15, 11, 1, 1, 2.3353, 0.0153);
set( 15, 11, 1, 2, 2.3320, 0.0301);
set( 15, 11, 1, 3, 2.3267, 0.0447);
set( 15, 11, 1, 4, 2.3194, 0.0591);
set( 15, 11, 1, 5, 2.3102, 0.0731);
set( 15, 11, 2, 0, 2.2910, 0.0006);
set( 15, 11, 2, 1, 2.2900, 0.0146);
set( 15, 11, 2, 2, 2.2870, 0.0287);
set( 15, 11, 2, 3, 2.2821, 0.0427);
set( 15, 11, 2, 4, 2.2754, 0.0565);
set( 15, 11, 2, 5, 2.2670, 0.0700);
set( 15, 11, 3, 0, 2.2476, 0.0006);
set( 15, 11, 3, 1, 2.2466, 0.0140);
set( 15, 11, 3, 2, 2.2439, 0.0275);
set( 15, 11, 3, 3, 2.2394, 0.0409);
set( 15, 11, 3, 4, 2.2333, 0.0542);
set( 15, 11, 3, 5, 2.2256, 0.0672);
set( 15, 11, 4, 0, 2.2060, 0.0006);
set( 15, 11, 4, 1, 2.2051, 0.0135);
set( 15, 11, 4, 2, 2.2026, 0.0264);
set( 15, 11, 4, 3, 2.1985, 0.0393);
set( 15, 11, 4, 4, 2.1928, 0.0520);
set( 15, 11, 4, 5, 2.1857, 0.0645);
set( 15, 11, 5, 0, 2.1664, 0.0006);
set( 15, 11, 5, 1, 2.1656, 0.0129);
set( 15, 11, 5, 2, 2.1633, 0.0254);
set( 15, 11, 5, 3, 2.1595, 0.0378);
set( 15, 11, 5, 4, 2.1543, 0.0501);
set( 15, 11, 5, 5, 2.1477, 0.0621);
set( 15, 12, 0, 0, 2.3542, 0.0779);
set( 15, 12, 0, 1, 2.3420, 0.0922);
set( 15, 12, 0, 2, 2.3279, 0.1063);
set( 15, 12, 0, 3, 2.3123, 0.1199);
set( 15, 12, 0, 4, 2.2951, 0.1331);
set( 15, 12, 0, 5, 2.2768, 0.1458);
set( 15, 12, 1, 0, 2.3097, 0.0745);
set( 15, 12, 1, 1, 2.2986, 0.0882);
set( 15, 12, 1, 2, 2.2857, 0.1017);
set( 15, 12, 1, 3, 2.2712, 0.1149);
set( 15, 12, 1, 4, 2.2554, 0.1277);
set( 15, 12, 1, 5, 2.2385, 0.1399);
set( 15, 12, 2, 0, 2.2667, 0.0713);
set( 15, 12, 2, 1, 2.2565, 0.0845);
set( 15, 12, 2, 2, 2.2446, 0.0975);
set( 15, 12, 2, 3, 2.2313, 0.1103);
set( 15, 12, 2, 4, 2.2166, 0.1226);
set( 15, 12, 2, 5, 2.2009, 0.1345);
set( 15, 12, 3, 0, 2.2254, 0.0684);
set( 15, 12, 3, 1, 2.2159, 0.0811);
set( 15, 12, 3, 2, 2.2050, 0.0937);
set( 15, 12, 3, 3, 2.1926, 0.1059);
set( 15, 12, 3, 4, 2.1791, 0.1179);
set( 15, 12, 3, 5, 2.1645, 0.1294);
set( 15, 12, 4, 0, 2.1856, 0.0657);
set( 15, 12, 4, 1, 2.1769, 0.0779);
set( 15, 12, 4, 2, 2.1667, 0.0901);
set( 15, 12, 4, 3, 2.1553, 0.1019);
set( 15, 12, 4, 4, 2.1427, 0.1135);
set( 15, 12, 4, 5, 2.1291, 0.1247);
set( 15, 12, 5, 0, 2.1476, 0.0632);
set( 15, 12, 5, 1, 2.1396, 0.0751);
set( 15, 12, 5, 2, 2.1301, 0.0868);
set( 15, 12, 5, 3, 2.1195, 0.0983);
set( 15, 12, 5, 4, 2.1078, 0.1095);
set( 15, 12, 5, 5, 2.0951, 0.1204);
set( 15, 13, 0, 0, 2.2758, 0.1469);
set( 15, 13, 0, 1, 2.2563, 0.1590);
set( 15, 13, 0, 2, 2.2356, 0.1708);
set( 15, 13, 0, 3, 2.2140, 0.1820);
set( 15, 13, 0, 4, 2.1918, 0.1928);
set( 15, 13, 0, 5, 2.1692, 0.2030);
set( 15, 13, 1, 0, 2.2377, 0.1411);
set( 15, 13, 1, 1, 2.2196, 0.1529);
set( 15, 13, 1, 2, 2.2003, 0.1643);
set( 15, 13, 1, 3, 2.1802, 0.1753);
set( 15, 13, 1, 4, 2.1594, 0.1859);
set( 15, 13, 1, 5, 2.1382, 0.1959);
set( 15, 13, 2, 0, 2.2004, 0.1356);
set( 15, 13, 2, 1, 2.1835, 0.1471);
set( 15, 13, 2, 2, 2.1655, 0.1582);
set( 15, 13, 2, 3, 2.1468, 0.1690);
set( 15, 13, 2, 4, 2.1273, 0.1793);
set( 15, 13, 2, 5, 2.1074, 0.1892);
set( 15, 13, 3, 0, 2.1641, 0.1305);
set( 15, 13, 3, 1, 2.1484, 0.1417);
set( 15, 13, 3, 2, 2.1317, 0.1525);
set( 15, 13, 3, 3, 2.1141, 0.1630);
set( 15, 13, 3, 4, 2.0958, 0.1732);
set( 15, 13, 3, 5, 2.0771, 0.1829);
set( 15, 13, 4, 0, 2.1289, 0.1258);
set( 15, 13, 4, 1, 2.1143, 0.1366);
set( 15, 13, 4, 2, 2.0986, 0.1472);
set( 15, 13, 4, 3, 2.0821, 0.1575);
set( 15, 13, 4, 4, 2.0650, 0.1674);
set( 15, 13, 4, 5, 2.0474, 0.1769);
set( 15, 13, 5, 0, 2.0951, 0.1214);
set( 15, 13, 5, 1, 2.0813, 0.1319);
set( 15, 13, 5, 2, 2.0666, 0.1423);
set( 15, 13, 5, 3, 2.0512, 0.1523);
set( 15, 13, 5, 4, 2.0350, 0.1620);
set( 15, 13, 5, 5, 2.0184, 0.1714);
set( 15, 14, 0, 0, 2.1683, 0.2039);
set( 15, 14, 0, 1, 2.1453, 0.2136);
set( 15, 14, 0, 2, 2.1218, 0.2229);
set( 15, 14, 0, 3, 2.0980, 0.2318);
set( 15, 14, 0, 4, 2.0740, 0.2403);
set( 15, 14, 0, 5, 2.0502, 0.2483);
set( 15, 14, 1, 0, 2.1375, 0.1969);
set( 15, 14, 1, 1, 2.1158, 0.2064);
set( 15, 14, 1, 2, 2.0936, 0.2156);
set( 15, 14, 1, 3, 2.0711, 0.2245);
set( 15, 14, 1, 4, 2.0484, 0.2329);
set( 15, 14, 1, 5, 2.0257, 0.2409);
set( 15, 14, 2, 0, 2.1069, 0.1902);
set( 15, 14, 2, 1, 2.0865, 0.1996);
set( 15, 14, 2, 2, 2.0655, 0.2087);
set( 15, 14, 2, 3, 2.0441, 0.2174);
set( 15, 14, 2, 4, 2.0226, 0.2258);
set( 15, 14, 2, 5, 2.0010, 0.2338);
set( 15, 14, 3, 0, 2.0768, 0.1838);
set( 15, 14, 3, 1, 2.0576, 0.1931);
set( 15, 14, 3, 2, 2.0377, 0.2021);
set( 15, 14, 3, 3, 2.0175, 0.2107);
set( 15, 14, 3, 4, 1.9970, 0.2190);
set( 15, 14, 3, 5, 1.9765, 0.2269);
set( 15, 14, 4, 0, 2.0473, 0.1779);
set( 15, 14, 4, 1, 2.0291, 0.1870);
set( 15, 14, 4, 2, 2.0103, 0.1958);
set( 15, 14, 4, 3, 1.9912, 0.2044);
set( 15, 14, 4, 4, 1.9717, 0.2126);
set( 15, 14, 4, 5, 1.9522, 0.2204);
set( 15, 14, 5, 0, 2.0185, 0.1723);
set( 15, 14, 5, 1, 2.0013, 0.1813);
set( 15, 14, 5, 2, 1.9835, 0.1900);
set( 15, 14, 5, 3, 1.9654, 0.1984);
set( 15, 14, 5, 4, 1.9469, 0.2065);
set( 15, 14, 5, 5, 1.9283, 0.2143);
set( 15, 15, 0, 0, 2.0496, 0.2491);
set( 15, 15, 0, 1, 2.0258, 0.2567);
set( 15, 15, 0, 2, 2.0019, 0.2640);
set( 15, 15, 0, 3, 1.9780, 0.2709);
set( 15, 15, 0, 4, 1.9543, 0.2776);
set( 15, 15, 0, 5, 1.9309, 0.2839);
set( 15, 15, 1, 0, 2.0253, 0.2417);
set( 15, 15, 1, 1, 2.0026, 0.2493);
set( 15, 15, 1, 2, 1.9797, 0.2566);
set( 15, 15, 1, 3, 1.9569, 0.2636);
set( 15, 15, 1, 4, 1.9341, 0.2702);
set( 15, 15, 1, 5, 1.9116, 0.2766);
set( 15, 15, 2, 0, 2.0008, 0.2345);
set( 15, 15, 2, 1, 1.9792, 0.2421);
set( 15, 15, 2, 2, 1.9573, 0.2494);
set( 15, 15, 2, 3, 1.9354, 0.2564);
set( 15, 15, 2, 4, 1.9136, 0.2631);
set( 15, 15, 2, 5, 1.8920, 0.2695);
set( 15, 15, 3, 0, 1.9765, 0.2277);
set( 15, 15, 3, 1, 1.9559, 0.2353);
set( 15, 15, 3, 2, 1.9350, 0.2426);
set( 15, 15, 3, 3, 1.9140, 0.2495);
set( 15, 15, 3, 4, 1.8931, 0.2563);
set( 15, 15, 3, 5, 1.8723, 0.2626);
set( 15, 15, 4, 0, 1.9524, 0.2213);
set( 15, 15, 4, 1, 1.9327, 0.2287);
set( 15, 15, 4, 2, 1.9127, 0.2360);
set( 15, 15, 4, 3, 1.8926, 0.2430);
set( 15, 15, 4, 4, 1.8725, 0.2497);
set( 15, 15, 4, 5, 1.8526, 0.2561);
set( 15, 15, 5, 0, 1.9287, 0.2151);
set( 15, 15, 5, 1, 1.9099, 0.2226);
set( 15, 15, 5, 2, 1.8907, 0.2298);
set( 15, 15, 5, 3, 1.8715, 0.2367);
set( 15, 15, 5, 4, 1.8522, 0.2434);
set( 15, 15, 5, 5, 1.8331, 0.2498);
set( 15, 16, 0, 0, 1.9308, 0.2845);
set( 15, 16, 0, 1, 1.9077, 0.2904);
set( 15, 16, 0, 2, 1.8846, 0.2961);
set( 15, 16, 0, 3, 1.8617, 0.3016);
set( 15, 16, 0, 4, 1.8391, 0.3069);
set( 15, 16, 0, 5, 1.8170, 0.3119);
set( 15, 16, 1, 0, 1.9116, 0.2772);
set( 15, 16, 1, 1, 1.8894, 0.2832);
set( 15, 16, 1, 2, 1.8671, 0.2890);
set( 15, 16, 1, 3, 1.8450, 0.2945);
set( 15, 16, 1, 4, 1.8231, 0.2999);
set( 15, 16, 1, 5, 1.8016, 0.3049);
set( 15, 16, 2, 0, 1.8922, 0.2701);
set( 15, 16, 2, 1, 1.8708, 0.2762);
set( 15, 16, 2, 2, 1.8493, 0.2820);
set( 15, 16, 2, 3, 1.8279, 0.2876);
set( 15, 16, 2, 4, 1.8068, 0.2930);
set( 15, 16, 2, 5, 1.7860, 0.2981);
set( 15, 16, 3, 0, 1.8727, 0.2633);
set( 15, 16, 3, 1, 1.8521, 0.2694);
set( 15, 16, 3, 2, 1.8313, 0.2753);
set( 15, 16, 3, 3, 1.8107, 0.2809);
set( 15, 16, 3, 4, 1.7902, 0.2863);
set( 15, 16, 3, 5, 1.7701, 0.2915);
set( 15, 16, 4, 0, 1.8532, 0.2568);
set( 15, 16, 4, 1, 1.8333, 0.2629);
set( 15, 16, 4, 2, 1.8133, 0.2688);
set( 15, 16, 4, 3, 1.7934, 0.2744);
set( 15, 16, 4, 4, 1.7736, 0.2799);
set( 15, 16, 4, 5, 1.7541, 0.2851);
set( 15, 16, 5, 0, 1.8338, 0.2505);
set( 15, 16, 5, 1, 1.8147, 0.2566);
set( 15, 16, 5, 2, 1.7954, 0.2625);
set( 15, 16, 5, 3, 1.7761, 0.2682);
set( 15, 16, 5, 4, 1.7570, 0.2737);
set( 15, 16, 5, 5, 1.7381, 0.2790);
set( 15, 17, 0, 0, 1.8173, 0.3123);
set( 15, 17, 0, 1, 1.7956, 0.3170);
set( 15, 17, 0, 2, 1.7739, 0.3216);
set( 15, 17, 0, 3, 1.7524, 0.3259);
set( 15, 17, 0, 4, 1.7313, 0.3301);
set( 15, 17, 0, 5, 1.7106, 0.3341);
set( 15, 17, 1, 0, 1.8021, 0.3054);
set( 15, 17, 1, 1, 1.7810, 0.3102);
set( 15, 17, 1, 2, 1.7599, 0.3148);
set( 15, 17, 1, 3, 1.7390, 0.3193);
set( 15, 17, 1, 4, 1.7185, 0.3236);
set( 15, 17, 1, 5, 1.6983, 0.3276);
set( 15, 17, 2, 0, 1.7866, 0.2986);
set( 15, 17, 2, 1, 1.7661, 0.3035);
set( 15, 17, 2, 2, 1.7456, 0.3082);
set( 15, 17, 2, 3, 1.7253, 0.3127);
set( 15, 17, 2, 4, 1.7052, 0.3171);
set( 15, 17, 2, 5, 1.6856, 0.3212);
set( 15, 17, 3, 0, 1.7709, 0.2921);
set( 15, 17, 3, 1, 1.7510, 0.2970);
set( 15, 17, 3, 2, 1.7311, 0.3018);
set( 15, 17, 3, 3, 1.7114, 0.3063);
set( 15, 17, 3, 4, 1.6918, 0.3108);
set( 15, 17, 3, 5, 1.6727, 0.3150);
set( 15, 17, 4, 0, 1.7551, 0.2857);
set( 15, 17, 4, 1, 1.7358, 0.2907);
set( 15, 17, 4, 2, 1.7164, 0.2955);
set( 15, 17, 4, 3, 1.6973, 0.3001);
set( 15, 17, 4, 4, 1.6783, 0.3046);
set( 15, 17, 4, 5, 1.6596, 0.3089);
set( 15, 17, 5, 0, 1.7392, 0.2796);
set( 15, 17, 5, 1, 1.7205, 0.2846);
set( 15, 17, 5, 2, 1.7017, 0.2895);
set( 15, 17, 5, 3, 1.6831, 0.2942);
set( 15, 17, 5, 4, 1.6646, 0.2987);
set( 15, 17, 5, 5, 1.6465, 0.3030);
set( 15, 18, 0, 0, 1.7115, 0.3345);
set( 15, 18, 0, 1, 1.6912, 0.3383);
set( 15, 18, 0, 2, 1.6711, 0.3420);
set( 15, 18, 0, 3, 1.6512, 0.3455);
set( 15, 18, 0, 4, 1.6316, 0.3489);
set( 15, 18, 0, 5, 1.6124, 0.3522);
set( 15, 18, 1, 0, 1.6993, 0.3280);
set( 15, 18, 1, 1, 1.6795, 0.3319);
set( 15, 18, 1, 2, 1.6598, 0.3357);
set( 15, 18, 1, 3, 1.6403, 0.3393);
set( 15, 18, 1, 4, 1.6211, 0.3428);
set( 15, 18, 1, 5, 1.6023, 0.3461);
set( 15, 18, 2, 0, 1.6867, 0.3217);
set( 15, 18, 2, 1, 1.6674, 0.3256);
set( 15, 18, 2, 2, 1.6481, 0.3295);
set( 15, 18, 2, 3, 1.6291, 0.3332);
set( 15, 18, 2, 4, 1.6103, 0.3367);
set( 15, 18, 2, 5, 1.5919, 0.3401);
set( 15, 18, 3, 0, 1.6739, 0.3155);
set( 15, 18, 3, 1, 1.6551, 0.3195);
set( 15, 18, 3, 2, 1.6363, 0.3234);
set( 15, 18, 3, 3, 1.6177, 0.3272);
set( 15, 18, 3, 4, 1.5993, 0.3308);
set( 15, 18, 3, 5, 1.5813, 0.3343);
set( 15, 18, 4, 0, 1.6610, 0.3094);
set( 15, 18, 4, 1, 1.6426, 0.3135);
set( 15, 18, 4, 2, 1.6242, 0.3175);
set( 15, 18, 4, 3, 1.6061, 0.3213);
set( 15, 18, 4, 4, 1.5881, 0.3250);
set( 15, 18, 4, 5, 1.5705, 0.3285);
set( 15, 18, 5, 0, 1.6480, 0.3036);
set( 15, 18, 5, 1, 1.6301, 0.3077);
set( 15, 18, 5, 2, 1.6121, 0.3117);
set( 15, 18, 5, 3, 1.5944, 0.3156);
set( 15, 18, 5, 4, 1.5768, 0.3194);
set( 15, 18, 5, 5, 1.5596, 0.3230);
set( 15, 19, 0, 0, 1.6137, 0.3524);
set( 15, 19, 0, 1, 1.5950, 0.3555);
set( 15, 19, 0, 2, 1.5763, 0.3586);
set( 15, 19, 0, 3, 1.5579, 0.3615);
set( 15, 19, 0, 4, 1.5398, 0.3643);
set( 15, 19, 0, 5, 1.5221, 0.3670);
set( 15, 19, 1, 0, 1.6038, 0.3465);
set( 15, 19, 1, 1, 1.5854, 0.3496);
set( 15, 19, 1, 2, 1.5670, 0.3527);
set( 15, 19, 1, 3, 1.5490, 0.3557);
set( 15, 19, 1, 4, 1.5311, 0.3586);
set( 15, 19, 1, 5, 1.5137, 0.3614);
set( 15, 19, 2, 0, 1.5935, 0.3405);
set( 15, 19, 2, 1, 1.5754, 0.3438);
set( 15, 19, 2, 2, 1.5575, 0.3469);
set( 15, 19, 2, 3, 1.5397, 0.3500);
set( 15, 19, 2, 4, 1.5222, 0.3530);
set( 15, 19, 2, 5, 1.5051, 0.3558);
set( 15, 19, 3, 0, 1.5830, 0.3347);
set( 15, 19, 3, 1, 1.5653, 0.3380);
set( 15, 19, 3, 2, 1.5477, 0.3413);
set( 15, 19, 3, 3, 1.5302, 0.3444);
set( 15, 19, 3, 4, 1.5131, 0.3474);
set( 15, 19, 3, 5, 1.4962, 0.3503);
set( 15, 19, 4, 0, 1.5723, 0.3290);
set( 15, 19, 4, 1, 1.5550, 0.3324);
set( 15, 19, 4, 2, 1.5377, 0.3357);
set( 15, 19, 4, 3, 1.5206, 0.3389);
set( 15, 19, 4, 4, 1.5037, 0.3420);
set( 15, 19, 4, 5, 1.4872, 0.3449);
set( 15, 19, 5, 0, 1.5615, 0.3235);
set( 15, 19, 5, 1, 1.5445, 0.3269);
set( 15, 19, 5, 2, 1.5276, 0.3303);
set( 15, 19, 5, 3, 1.5108, 0.3335);
set( 15, 19, 5, 4, 1.4943, 0.3367);
set( 15, 19, 5, 5, 1.4780, 0.3397);
set( 16, 11, 0, 0, 2.1647, 0.0006);
set( 16, 11, 0, 1, 2.1640, 0.0128);
set( 16, 11, 0, 2, 2.1617, 0.0252);
set( 16, 11, 0, 3, 2.1580, 0.0375);
set( 16, 11, 0, 4, 2.1528, 0.0496);
set( 16, 11, 0, 5, 2.1464, 0.0615);
set( 16, 11, 1, 0, 2.1270, 0.0005);
set( 16, 11, 1, 1, 2.1262, 0.0124);
set( 16, 11, 1, 2, 2.1241, 0.0243);
set( 16, 11, 1, 3, 2.1207, 0.0361);
set( 16, 11, 1, 4, 2.1159, 0.0478);
set( 16, 11, 1, 5, 2.1099, 0.0593);
set( 16, 11, 2, 0, 2.0902, 0.0005);
set( 16, 11, 2, 1, 2.0896, 0.0119);
set( 16, 11, 2, 2, 2.0876, 0.0234);
set( 16, 11, 2, 3, 2.0844, 0.0348);
set( 16, 11, 2, 4, 2.0800, 0.0461);
set( 16, 11, 2, 5, 2.0744, 0.0573);
set( 16, 11, 3, 0, 2.0548, 0.0005);
set( 16, 11, 3, 1, 2.0542, 0.0115);
set( 16, 11, 3, 2, 2.0524, 0.0226);
set( 16, 11, 3, 3, 2.0494, 0.0336);
set( 16, 11, 3, 4, 2.0453, 0.0446);
set( 16, 11, 3, 5, 2.0401, 0.0553);
set( 16, 11, 4, 0, 2.0206, 0.0005);
set( 16, 11, 4, 1, 2.0200, 0.0111);
set( 16, 11, 4, 2, 2.0183, 0.0218);
set( 16, 11, 4, 3, 2.0156, 0.0325);
set( 16, 11, 4, 4, 2.0117, 0.0431);
set( 16, 11, 4, 5, 2.0068, 0.0535);
set( 16, 11, 5, 0, 1.9878, 0.0005);
set( 16, 11, 5, 1, 1.9873, 0.0108);
set( 16, 11, 5, 2, 1.9857, 0.0211);
set( 16, 11, 5, 3, 1.9831, 0.0315);
set( 16, 11, 5, 4, 1.9795, 0.0418);
set( 16, 11, 5, 5, 1.9749, 0.0518);
set( 16, 12, 0, 0, 2.1461, 0.0627);
set( 16, 12, 0, 1, 2.1382, 0.0744);
set( 16, 12, 0, 2, 2.1290, 0.0860);
set( 16, 12, 0, 3, 2.1186, 0.0974);
set( 16, 12, 0, 4, 2.1071, 0.1086);
set( 16, 12, 0, 5, 2.0947, 0.1194);
set( 16, 12, 1, 0, 2.1098, 0.0604);
set( 16, 12, 1, 1, 2.1024, 0.0718);
set( 16, 12, 1, 2, 2.0938, 0.0830);
set( 16, 12, 1, 3, 2.0841, 0.0940);
set( 16, 12, 1, 4, 2.0734, 0.1049);
set( 16, 12, 1, 5, 2.0618, 0.1154);
set( 16, 12, 2, 0, 2.0743, 0.0583);
set( 16, 12, 2, 1, 2.0675, 0.0693);
set( 16, 12, 2, 2, 2.0595, 0.0802);
set( 16, 12, 2, 3, 2.0504, 0.0909);
set( 16, 12, 2, 4, 2.0403, 0.1014);
set( 16, 12, 2, 5, 2.0295, 0.1116);
set( 16, 12, 3, 0, 2.0401, 0.0564);
set( 16, 12, 3, 1, 2.0337, 0.0670);
set( 16, 12, 3, 2, 2.0262, 0.0775);
set( 16, 12, 3, 3, 2.0177, 0.0879);
set( 16, 12, 3, 4, 2.0083, 0.0981);
set( 16, 12, 3, 5, 1.9980, 0.1080);
set( 16, 12, 4, 0, 2.0069, 0.0545);
set( 16, 12, 4, 1, 2.0009, 0.0648);
set( 16, 12, 4, 2, 1.9939, 0.0750);
set( 16, 12, 4, 3, 1.9859, 0.0851);
set( 16, 12, 4, 4, 1.9771, 0.0950);
set( 16, 12, 4, 5, 1.9675, 0.1047);
set( 16, 12, 5, 0, 1.9751, 0.0528);
set( 16, 12, 5, 1, 1.9694, 0.0628);
set( 16, 12, 5, 2, 1.9628, 0.0727);
set( 16, 12, 5, 3, 1.9553, 0.0825);
set( 16, 12, 5, 4, 1.9470, 0.0922);
set( 16, 12, 5, 5, 1.9380, 0.1016);
set( 16, 13, 0, 0, 2.0943, 0.1204);
set( 16, 13, 0, 1, 2.0809, 0.1308);
set( 16, 13, 0, 2, 2.0664, 0.1411);
set( 16, 13, 0, 3, 2.0513, 0.1511);
set( 16, 13, 0, 4, 2.0354, 0.1608);
set( 16, 13, 0, 5, 2.0191, 0.1701);
set( 16, 13, 1, 0, 2.0615, 0.1164);
set( 16, 13, 1, 1, 2.0489, 0.1266);
set( 16, 13, 1, 2, 2.0354, 0.1366);
set( 16, 13, 1, 3, 2.0211, 0.1463);
set( 16, 13, 1, 4, 2.0062, 0.1558);
set( 16, 13, 1, 5, 1.9908, 0.1649);
set( 16, 13, 2, 0, 2.0293, 0.1126);
set( 16, 13, 2, 1, 2.0175, 0.1225);
set( 16, 13, 2, 2, 2.0048, 0.1323);
set( 16, 13, 2, 3, 1.9913, 0.1418);
set( 16, 13, 2, 4, 1.9773, 0.1511);
set( 16, 13, 2, 5, 1.9627, 0.1600);
set( 16, 13, 3, 0, 1.9981, 0.1090);
set( 16, 13, 3, 1, 1.9869, 0.1187);
set( 16, 13, 3, 2, 1.9749, 0.1282);
set( 16, 13, 3, 3, 1.9623, 0.1375);
set( 16, 13, 3, 4, 1.9490, 0.1466);
set( 16, 13, 3, 5, 1.9352, 0.1553);
set( 16, 13, 4, 0, 1.9676, 0.1056);
set( 16, 13, 4, 1, 1.9571, 0.1150);
set( 16, 13, 4, 2, 1.9458, 0.1244);
set( 16, 13, 4, 3, 1.9339, 0.1334);
set( 16, 13, 4, 4, 1.9213, 0.1423);
set( 16, 13, 4, 5, 1.9082, 0.1509);
set( 16, 13, 5, 0, 1.9382, 0.1025);
set( 16, 13, 5, 1, 1.9283, 0.1117);
set( 16, 13, 5, 2, 1.9176, 0.1208);
set( 16, 13, 5, 3, 1.9063, 0.1296);
set( 16, 13, 5, 4, 1.8944, 0.1383);
set( 16, 13, 5, 5, 1.8820, 0.1467);
set( 16, 14, 0, 0, 2.0188, 0.1709);
set( 16, 14, 0, 1, 2.0019, 0.1799);
set( 16, 14, 0, 2, 1.9844, 0.1886);
set( 16, 14, 0, 3, 1.9666, 0.1970);
set( 16, 14, 0, 4, 1.9484, 0.2051);
set( 16, 14, 0, 5, 1.9301, 0.2129);
set( 16, 14, 1, 0, 1.9906, 0.1658);
set( 16, 14, 1, 1, 1.9746, 0.1746);
set( 16, 14, 1, 2, 1.9580, 0.1831);
set( 16, 14, 1, 3, 1.9411, 0.1914);
set( 16, 14, 1, 4, 1.9238, 0.1995);
set( 16, 14, 1, 5, 1.9063, 0.2071);
set( 16, 14, 2, 0, 1.9627, 0.1609);
set( 16, 14, 2, 1, 1.9476, 0.1695);
set( 16, 14, 2, 2, 1.9318, 0.1779);
set( 16, 14, 2, 3, 1.9157, 0.1861);
set( 16, 14, 2, 4, 1.8993, 0.1940);
set( 16, 14, 2, 5, 1.8826, 0.2016);
set( 16, 14, 3, 0, 1.9353, 0.1562);
set( 16, 14, 3, 1, 1.9210, 0.1646);
set( 16, 14, 3, 2, 1.9061, 0.1729);
set( 16, 14, 3, 3, 1.8907, 0.1810);
set( 16, 14, 3, 4, 1.8751, 0.1888);
set( 16, 14, 3, 5, 1.8592, 0.1963);
set( 16, 14, 4, 0, 1.9085, 0.1518);
set( 16, 14, 4, 1, 1.8949, 0.1601);
set( 16, 14, 4, 2, 1.8807, 0.1682);
set( 16, 14, 4, 3, 1.8661, 0.1761);
set( 16, 14, 4, 4, 1.8512, 0.1838);
set( 16, 14, 4, 5, 1.8361, 0.1912);
set( 16, 14, 5, 0, 1.8825, 0.1476);
set( 16, 14, 5, 1, 1.8695, 0.1557);
set( 16, 14, 5, 2, 1.8560, 0.1637);
set( 16, 14, 5, 3, 1.8421, 0.1716);
set( 16, 14, 5, 4, 1.8279, 0.1791);
set( 16, 14, 5, 5, 1.8134, 0.1864);
set( 16, 15, 0, 0, 1.9299, 0.2136);
set( 16, 15, 0, 1, 1.9115, 0.2210);
set( 16, 15, 0, 2, 1.8926, 0.2283);
set( 16, 15, 0, 3, 1.8737, 0.2352);
set( 16, 15, 0, 4, 1.8547, 0.2419);
set( 16, 15, 0, 5, 1.8358, 0.2483);
set( 16, 15, 1, 0, 1.9064, 0.2079);
set( 16, 15, 1, 1, 1.8887, 0.2152);
set( 16, 15, 1, 2, 1.8707, 0.2224);
set( 16, 15, 1, 3, 1.8526, 0.2293);
set( 16, 15, 1, 4, 1.8343, 0.2360);
set( 16, 15, 1, 5, 1.8162, 0.2424);
set( 16, 15, 2, 0, 1.8828, 0.2023);
set( 16, 15, 2, 1, 1.8660, 0.2096);
set( 16, 15, 2, 2, 1.8487, 0.2167);
set( 16, 15, 2, 3, 1.8313, 0.2236);
set( 16, 15, 2, 4, 1.8138, 0.2303);
set( 16, 15, 2, 5, 1.7964, 0.2366);
set( 16, 15, 3, 0, 1.8596, 0.1971);
set( 16, 15, 3, 1, 1.8435, 0.2043);
set( 16, 15, 3, 2, 1.8270, 0.2113);
set( 16, 15, 3, 3, 1.8103, 0.2181);
set( 16, 15, 3, 4, 1.7935, 0.2248);
set( 16, 15, 3, 5, 1.7767, 0.2311);
set( 16, 15, 4, 0, 1.8366, 0.1920);
set( 16, 15, 4, 1, 1.8212, 0.1991);
set( 16, 15, 4, 2, 1.8054, 0.2061);
set( 16, 15, 4, 3, 1.7894, 0.2129);
set( 16, 15, 4, 4, 1.7733, 0.2194);
set( 16, 15, 4, 5, 1.7571, 0.2257);
set( 16, 15, 5, 0, 1.8141, 0.1872);
set( 16, 15, 5, 1, 1.7994, 0.1943);
set( 16, 15, 5, 2, 1.7842, 0.2012);
set( 16, 15, 5, 3, 1.7689, 0.2079);
set( 16, 15, 5, 4, 1.7534, 0.2144);
set( 16, 15, 5, 5, 1.7379, 0.2206);
set( 16, 16, 0, 0, 1.8360, 0.2489);
set( 16, 16, 0, 1, 1.8171, 0.2551);
set( 16, 16, 0, 2, 1.7981, 0.2610);
set( 16, 16, 0, 3, 1.7792, 0.2667);
set( 16, 16, 0, 4, 1.7603, 0.2723);
set( 16, 16, 0, 5, 1.7416, 0.2775);
set( 16, 16, 1, 0, 1.8165, 0.2430);
set( 16, 16, 1, 1, 1.7984, 0.2491);
set( 16, 16, 1, 2, 1.7800, 0.2551);
set( 16, 16, 1, 3, 1.7617, 0.2608);
set( 16, 16, 1, 4, 1.7434, 0.2664);
set( 16, 16, 1, 5, 1.7254, 0.2717);
set( 16, 16, 2, 0, 1.7969, 0.2373);
set( 16, 16, 2, 1, 1.7794, 0.2434);
set( 16, 16, 2, 2, 1.7618, 0.2493);
set( 16, 16, 2, 3, 1.7441, 0.2551);
set( 16, 16, 2, 4, 1.7264, 0.2606);
set( 16, 16, 2, 5, 1.7089, 0.2659);
set( 16, 16, 3, 0, 1.7774, 0.2317);
set( 16, 16, 3, 1, 1.7606, 0.2378);
set( 16, 16, 3, 2, 1.7435, 0.2438);
set( 16, 16, 3, 3, 1.7265, 0.2495);
set( 16, 16, 3, 4, 1.7094, 0.2550);
set( 16, 16, 3, 5, 1.6925, 0.2604);
set( 16, 16, 4, 0, 1.7580, 0.2264);
set( 16, 16, 4, 1, 1.7418, 0.2325);
set( 16, 16, 4, 2, 1.7254, 0.2384);
set( 16, 16, 4, 3, 1.7089, 0.2441);
set( 16, 16, 4, 4, 1.6924, 0.2497);
set( 16, 16, 4, 5, 1.6760, 0.2550);
set( 16, 16, 5, 0, 1.7389, 0.2213);
set( 16, 16, 5, 1, 1.7232, 0.2274);
set( 16, 16, 5, 2, 1.7074, 0.2332);
set( 16, 16, 5, 3, 1.6915, 0.2390);
set( 16, 16, 5, 4, 1.6755, 0.2445);
set( 16, 16, 5, 5, 1.6597, 0.2498);
set( 16, 17, 0, 0, 1.7422, 0.2780);
set( 16, 17, 0, 1, 1.7237, 0.2831);
set( 16, 17, 0, 2, 1.7052, 0.2880);
set( 16, 17, 0, 3, 1.6868, 0.2927);
set( 16, 17, 0, 4, 1.6685, 0.2973);
set( 16, 17, 0, 5, 1.6505, 0.3016);
set( 16, 17, 1, 0, 1.7261, 0.2722);
set( 16, 17, 1, 1, 1.7082, 0.2772);
set( 16, 17, 1, 2, 1.6902, 0.2822);
set( 16, 17, 1, 3, 1.6723, 0.2869);
set( 16, 17, 1, 4, 1.6546, 0.2916);
set( 16, 17, 1, 5, 1.6371, 0.2960);
set( 16, 17, 2, 0, 1.7098, 0.2665);
set( 16, 17, 2, 1, 1.6925, 0.2716);
set( 16, 17, 2, 2, 1.6750, 0.2765);
set( 16, 17, 2, 3, 1.6576, 0.2813);
set( 16, 17, 2, 4, 1.6404, 0.2859);
set( 16, 17, 2, 5, 1.6234, 0.2904);
set( 16, 17, 3, 0, 1.6935, 0.2609);
set( 16, 17, 3, 1, 1.6767, 0.2660);
set( 16, 17, 3, 2, 1.6598, 0.2710);
set( 16, 17, 3, 3, 1.6429, 0.2758);
set( 16, 17, 3, 4, 1.6261, 0.2805);
set( 16, 17, 3, 5, 1.6096, 0.2850);
set( 16, 17, 4, 0, 1.6772, 0.2556);
set( 16, 17, 4, 1, 1.6609, 0.2607);
set( 16, 17, 4, 2, 1.6445, 0.2657);
set( 16, 17, 4, 3, 1.6281, 0.2705);
set( 16, 17, 4, 4, 1.6118, 0.2752);
set( 16, 17, 4, 5, 1.5957, 0.2797);
set( 16, 17, 5, 0, 1.6611, 0.2504);
set( 16, 17, 5, 1, 1.6453, 0.2555);
set( 16, 17, 5, 2, 1.6293, 0.2605);
set( 16, 17, 5, 3, 1.6134, 0.2654);
set( 16, 17, 5, 4, 1.5976, 0.2701);
set( 16, 17, 5, 5, 1.5819, 0.2746);
set( 16, 18, 0, 0, 1.6515, 0.3020);
set( 16, 18, 0, 1, 1.6338, 0.3062);
set( 16, 18, 0, 2, 1.6161, 0.3103);
set( 16, 18, 0, 3, 1.5985, 0.3142);
set( 16, 18, 0, 4, 1.5812, 0.3180);
set( 16, 18, 0, 5, 1.5641, 0.3217);
set( 16, 18, 1, 0, 1.6382, 0.2964);
set( 16, 18, 1, 1, 1.6209, 0.3006);
set( 16, 18, 1, 2, 1.6036, 0.3047);
set( 16, 18, 1, 3, 1.5865, 0.3087);
set( 16, 18, 1, 4, 1.5695, 0.3126);
set( 16, 18, 1, 5, 1.5528, 0.3163);
set( 16, 18, 2, 0, 1.6246, 0.2909);
set( 16, 18, 2, 1, 1.6078, 0.2951);
set( 16, 18, 2, 2, 1.5909, 0.2993);
set( 16, 18, 2, 3, 1.5742, 0.3033);
set( 16, 18, 2, 4, 1.5576, 0.3072);
set( 16, 18, 2, 5, 1.5413, 0.3109);
set( 16, 18, 3, 0, 1.6110, 0.2855);
set( 16, 18, 3, 1, 1.5946, 0.2898);
set( 16, 18, 3, 2, 1.5782, 0.2939);
set( 16, 18, 3, 3, 1.5618, 0.2980);
set( 16, 18, 3, 4, 1.5456, 0.3019);
set( 16, 18, 3, 5, 1.5297, 0.3057);
set( 16, 18, 4, 0, 1.5973, 0.2802);
set( 16, 18, 4, 1, 1.5813, 0.2845);
set( 16, 18, 4, 2, 1.5653, 0.2888);
set( 16, 18, 4, 3, 1.5494, 0.2928);
set( 16, 18, 4, 4, 1.5335, 0.2968);
set( 16, 18, 4, 5, 1.5180, 0.3006);
set( 16, 18, 5, 0, 1.5836, 0.2752);
set( 16, 18, 5, 1, 1.5680, 0.2795);
set( 16, 18, 5, 2, 1.5524, 0.2837);
set( 16, 18, 5, 3, 1.5369, 0.2879);
set( 16, 18, 5, 4, 1.5214, 0.2918);
set( 16, 18, 5, 5, 1.5062, 0.2957);
set( 16, 19, 0, 0, 1.5655, 0.3220);
set( 16, 19, 0, 1, 1.5487, 0.3255);
set( 16, 19, 0, 2, 1.5321, 0.3288);
set( 16, 19, 1, 0, 1.5544, 0.3166);
set( 16, 19, 1, 1, 1.5379, 0.3202);
set( 16, 19, 1, 2, 1.5216, 0.3236);
set( 16, 19, 2, 0, 1.5430, 0.3113);
set( 16, 19, 2, 1, 1.5269, 0.3149);
set( 16, 19, 2, 2, 1.5110, 0.3184);
set( 16, 19, 3, 0, 1.5315, 0.3062);
set( 16, 19, 3, 1, 1.5158, 0.3098);
set( 16, 19, 3, 2, 1.5001, 0.3133);
set( 16, 19, 4, 0, 1.5199, 0.3011);
set( 16, 19, 4, 1, 1.5045, 0.3048);
set( 16, 19, 4, 2, 1.4892, 0.3083);
set( 16, 19, 5, 0, 1.5083, 0.2962);
set( 16, 19, 5, 1, 1.4932, 0.2999);
set( 16, 19, 5, 2, 1.4783, 0.3035);
set( 17, 11, 0, 0, 1.9872, 0.0005);
set( 17, 11, 0, 1, 1.9867, 0.0107);
set( 17, 11, 0, 2, 1.9851, 0.0209);
set( 17, 11, 0, 3, 1.9826, 0.0312);
set( 17, 11, 0, 4, 1.9790, 0.0414);
set( 17, 11, 0, 5, 1.9746, 0.0514);
set( 17, 11, 1, 0, 1.9557, 0.0004);
set( 17, 11, 1, 1, 1.9552, 0.0103);
set( 17, 11, 1, 2, 1.9538, 0.0203);
set( 17, 11, 1, 3, 1.9514, 0.0302);
set( 17, 11, 1, 4, 1.9481, 0.0401);
set( 17, 11, 1, 5, 1.9439, 0.0498);
set( 17, 11, 2, 0, 1.9249, 0.0004);
set( 17, 11, 2, 1, 1.9245, 0.0100);
set( 17, 11, 2, 2, 1.9231, 0.0197);
set( 17, 11, 2, 3, 1.9208, 0.0293);
set( 17, 11, 2, 4, 1.9177, 0.0389);
set( 17, 11, 2, 5, 1.9138, 0.0483);
set( 17, 11, 3, 0, 1.8951, 0.0004);
set( 17, 11, 3, 1, 1.8946, 0.0097);
set( 17, 11, 3, 2, 1.8933, 0.0191);
set( 17, 11, 3, 3, 1.8912, 0.0285);
set( 17, 11, 3, 4, 1.8883, 0.0378);
set( 17, 11, 3, 5, 1.8846, 0.0470);
set( 17, 11, 4, 0, 1.8661, 0.0004);
set( 17, 11, 4, 1, 1.8656, 0.0095);
set( 17, 11, 4, 2, 1.8644, 0.0186);
set( 17, 11, 4, 3, 1.8624, 0.0277);
set( 17, 11, 4, 4, 1.8597, 0.0368);
set( 17, 11, 4, 5, 1.8562, 0.0457);
set( 17, 11, 5, 0, 1.8381, 0.0004);
set( 17, 11, 5, 1, 1.8377, 0.0092);
set( 17, 11, 5, 2, 1.8366, 0.0181);
set( 17, 11, 5, 3, 1.8347, 0.0269);
set( 17, 11, 5, 4, 1.8321, 0.0358);
set( 17, 11, 5, 5, 1.8288, 0.0444);
set( 17, 12, 0, 0, 1.9745, 0.0523);
set( 17, 12, 0, 1, 1.9690, 0.0622);
set( 17, 12, 0, 2, 1.9626, 0.0720);
set( 17, 12, 0, 3, 1.9553, 0.0818);
set( 17, 12, 0, 4, 1.9471, 0.0913);
set( 17, 12, 0, 5, 1.9383, 0.1007);
set( 17, 12, 1, 0, 1.9439, 0.0507);
set( 17, 12, 1, 1, 1.9387, 0.0603);
set( 17, 12, 1, 2, 1.9326, 0.0699);
set( 17, 12, 1, 3, 1.9257, 0.0794);
set( 17, 12, 1, 4, 1.9181, 0.0887);
set( 17, 12, 1, 5, 1.9097, 0.0978);
set( 17, 12, 2, 0, 1.9139, 0.0493);
set( 17, 12, 2, 1, 1.9090, 0.0586);
set( 17, 12, 2, 2, 1.9032, 0.0679);
set( 17, 12, 2, 3, 1.8967, 0.0771);
set( 17, 12, 2, 4, 1.8895, 0.0862);
set( 17, 12, 2, 5, 1.8816, 0.0950);
set( 17, 12, 3, 0, 1.8847, 0.0479);
set( 17, 12, 3, 1, 1.8801, 0.0569);
set( 17, 12, 3, 2, 1.8747, 0.0660);
set( 17, 12, 3, 3, 1.8685, 0.0750);
set( 17, 12, 3, 4, 1.8617, 0.0838);
set( 17, 12, 3, 5, 1.8542, 0.0924);
set( 17, 12, 4, 0, 1.8563, 0.0465);
set( 17, 12, 4, 1, 1.8520, 0.0554);
set( 17, 12, 4, 2, 1.8469, 0.0642);
set( 17, 12, 4, 3, 1.8410, 0.0729);
set( 17, 12, 4, 4, 1.8346, 0.0815);
set( 17, 12, 4, 5, 1.8275, 0.0900);
set( 17, 12, 5, 0, 1.8290, 0.0453);
set( 17, 12, 5, 1, 1.8249, 0.0539);
set( 17, 12, 5, 2, 1.8200, 0.0625);
set( 17, 12, 5, 3, 1.8145, 0.0710);
set( 17, 12, 5, 4, 1.8083, 0.0794);
set( 17, 12, 5, 5, 1.8016, 0.0877);
set( 17, 13, 0, 0, 1.9382, 0.1016);
set( 17, 13, 0, 1, 1.9285, 0.1107);
set( 17, 13, 0, 2, 1.9181, 0.1197);
set( 17, 13, 0, 3, 1.9070, 0.1285);
set( 17, 13, 0, 4, 1.8953, 0.1372);
set( 17, 13, 0, 5, 1.8832, 0.1455);
set( 17, 13, 1, 0, 1.9097, 0.0987);
set( 17, 13, 1, 1, 1.9006, 0.1076);
set( 17, 13, 1, 2, 1.8907, 0.1164);
set( 17, 13, 1, 3, 1.8802, 0.1250);
set( 17, 13, 1, 4, 1.8691, 0.1335);
set( 17, 13, 1, 5, 1.8576, 0.1417);
set( 17, 13, 2, 0, 1.8817, 0.0959);
set( 17, 13, 2, 1, 1.8731, 0.1046);
set( 17, 13, 2, 2, 1.8637, 0.1132);
set( 17, 13, 2, 3, 1.8538, 0.1216);
set( 17, 13, 2, 4, 1.8433, 0.1299);
set( 17, 13, 2, 5, 1.8323, 0.1379);
set( 17, 13, 3, 0, 1.8544, 0.0933);
set( 17, 13, 3, 1, 1.8462, 0.1018);
set( 17, 13, 3, 2, 1.8373, 0.1102);
set( 17, 13, 3, 3, 1.8279, 0.1184);
set( 17, 13, 3, 4, 1.8179, 0.1265);
set( 17, 13, 3, 5, 1.8075, 0.1344);
set( 17, 13, 4, 0, 1.8278, 0.0908);
set( 17, 13, 4, 1, 1.8200, 0.0991);
set( 17, 13, 4, 2, 1.8116, 0.1073);
set( 17, 13, 4, 3, 1.8026, 0.1154);
set( 17, 13, 4, 4, 1.7931, 0.1233);
set( 17, 13, 4, 5, 1.7832, 0.1310);
set( 17, 13, 5, 0, 1.8020, 0.0885);
set( 17, 13, 5, 1, 1.7946, 0.0966);
set( 17, 13, 5, 2, 1.7866, 0.1046);
set( 17, 13, 5, 3, 1.7780, 0.1125);
set( 17, 13, 5, 4, 1.7690, 0.1203);
set( 17, 13, 5, 5, 1.7595, 0.1279);
set( 17, 14, 0, 0, 1.8832, 0.1463);
set( 17, 14, 0, 1, 1.8706, 0.1544);
set( 17, 14, 0, 2, 1.8574, 0.1624);
set( 17, 14, 0, 3, 1.8437, 0.1702);
set( 17, 14, 0, 4, 1.8298, 0.1778);
set( 17, 14, 0, 5, 1.8156, 0.1850);
set( 17, 14, 1, 0, 1.8578, 0.1424);
set( 17, 14, 1, 1, 1.8457, 0.1504);
set( 17, 14, 1, 2, 1.8331, 0.1583);
set( 17, 14, 1, 3, 1.8202, 0.1659);
set( 17, 14, 1, 4, 1.8068, 0.1734);
set( 17, 14, 1, 5, 1.7932, 0.1806);
set( 17, 14, 2, 0, 1.8326, 0.1387);
set( 17, 14, 2, 1, 1.8211, 0.1465);
set( 17, 14, 2, 2, 1.8091, 0.1543);
set( 17, 14, 2, 3, 1.7967, 0.1618);
set( 17, 14, 2, 4, 1.7840, 0.1691);
set( 17, 14, 2, 5, 1.7710, 0.1762);
set( 17, 14, 3, 0, 1.8079, 0.1352);
set( 17, 14, 3, 1, 1.7970, 0.1429);
set( 17, 14, 3, 2, 1.7855, 0.1504);
set( 17, 14, 3, 3, 1.7737, 0.1578);
set( 17, 14, 3, 4, 1.7615, 0.1651);
set( 17, 14, 3, 5, 1.7491, 0.1720);
set( 17, 14, 4, 0, 1.7837, 0.1318);
set( 17, 14, 4, 1, 1.7733, 0.1393);
set( 17, 14, 4, 2, 1.7623, 0.1468);
set( 17, 14, 4, 3, 1.7510, 0.1541);
set( 17, 14, 4, 4, 1.7394, 0.1612);
set( 17, 14, 4, 5, 1.7275, 0.1681);
set( 17, 14, 5, 0, 1.7602, 0.1286);
set( 17, 14, 5, 1, 1.7502, 0.1360);
set( 17, 14, 5, 2, 1.7398, 0.1433);
set( 17, 14, 5, 3, 1.7289, 0.1505);
set( 17, 14, 5, 4, 1.7178, 0.1575);
set( 17, 14, 5, 5, 1.7064, 0.1643);
set( 17, 15, 0, 0, 1.8158, 0.1857);
set( 17, 15, 0, 1, 1.8013, 0.1928);
set( 17, 15, 0, 2, 1.7865, 0.1997);
set( 17, 15, 0, 3, 1.7714, 0.2064);
set( 17, 15, 0, 4, 1.7562, 0.2129);
set( 17, 15, 0, 5, 1.7409, 0.2192);
set( 17, 15, 1, 0, 1.7936, 0.1812);
set( 17, 15, 1, 1, 1.7797, 0.1882);
set( 17, 15, 1, 2, 1.7655, 0.1950);
set( 17, 15, 1, 3, 1.7510, 0.2017);
set( 17, 15, 1, 4, 1.7364, 0.2081);
set( 17, 15, 1, 5, 1.7217, 0.2143);
set( 17, 15, 2, 0, 1.7715, 0.1769);
set( 17, 15, 2, 1, 1.7582, 0.1838);
set( 17, 15, 2, 2, 1.7445, 0.1905);
set( 17, 15, 2, 3, 1.7307, 0.1971);
set( 17, 15, 2, 4, 1.7166, 0.2035);
set( 17, 15, 2, 5, 1.7025, 0.2096);
set( 17, 15, 3, 0, 1.7497, 0.1728);
set( 17, 15, 3, 1, 1.7370, 0.1795);
set( 17, 15, 3, 2, 1.7239, 0.1862);
set( 17, 15, 3, 3, 1.7105, 0.1927);
set( 17, 15, 3, 4, 1.6970, 0.1990);
set( 17, 15, 3, 5, 1.6834, 0.2051);
set( 17, 15, 4, 0, 1.7282, 0.1688);
set( 17, 15, 4, 1, 1.7160, 0.1755);
set( 17, 15, 4, 2, 1.7035, 0.1820);
set( 17, 15, 4, 3, 1.6906, 0.1885);
set( 17, 15, 4, 4, 1.6776, 0.1947);
set( 17, 15, 4, 5, 1.6645, 0.2008);
set( 17, 15, 5, 0, 1.7073, 0.1650);
set( 17, 15, 5, 1, 1.6956, 0.1716);
set( 17, 15, 5, 2, 1.6835, 0.1781);
set( 17, 15, 5, 3, 1.6711, 0.1844);
set( 17, 15, 5, 4, 1.6586, 0.1906);
set( 17, 15, 5, 5, 1.6460, 0.1966);
set( 17, 16, 0, 0, 1.7414, 0.2197);
set( 17, 16, 0, 1, 1.7261, 0.2258);
set( 17, 16, 0, 2, 1.7105, 0.2317);
set( 17, 16, 0, 3, 1.6948, 0.2374);
set( 17, 16, 0, 4, 1.6791, 0.2430);
set( 17, 16, 0, 5, 1.6635, 0.2483);
set( 17, 16, 1, 0, 1.7223, 0.2149);
set( 17, 16, 1, 1, 1.7075, 0.2209);
set( 17, 16, 1, 2, 1.6925, 0.2268);
set( 17, 16, 1, 3, 1.6774, 0.2325);
set( 17, 16, 1, 4, 1.6622, 0.2380);
set( 17, 16, 1, 5, 1.6471, 0.2434);
set( 17, 16, 2, 0, 1.7032, 0.2103);
set( 17, 16, 2, 1, 1.6890, 0.2162);
set( 17, 16, 2, 2, 1.6745, 0.2220);
set( 17, 16, 2, 3, 1.6599, 0.2277);
set( 17, 16, 2, 4, 1.6452, 0.2332);
set( 17, 16, 2, 5, 1.6306, 0.2385);
set( 17, 16, 3, 0, 1.6843, 0.2058);
set( 17, 16, 3, 1, 1.6706, 0.2117);
set( 17, 16, 3, 2, 1.6566, 0.2175);
set( 17, 16, 3, 3, 1.6425, 0.2231);
set( 17, 16, 3, 4, 1.6283, 0.2286);
set( 17, 16, 3, 5, 1.6142, 0.2339);
set( 17, 16, 4, 0, 1.6656, 0.2014);
set( 17, 16, 4, 1, 1.6523, 0.2073);
set( 17, 16, 4, 2, 1.6388, 0.2130);
set( 17, 16, 4, 3, 1.6252, 0.2186);
set( 17, 16, 4, 4, 1.6115, 0.2241);
set( 17, 16, 4, 5, 1.5978, 0.2294);
set( 17, 16, 5, 0, 1.6472, 0.1973);
set( 17, 16, 5, 1, 1.6344, 0.2031);
set( 17, 16, 5, 2, 1.6213, 0.2088);
set( 17, 16, 5, 3, 1.6082, 0.2144);
set( 17, 16, 5, 4, 1.5949, 0.2198);
set( 17, 16, 5, 5, 1.5817, 0.2250);
set( 17, 17, 0, 0, 1.6643, 0.2488);
set( 17, 17, 0, 1, 1.6488, 0.2539);
set( 17, 17, 0, 2, 1.6331, 0.2589);
set( 17, 17, 0, 3, 1.6174, 0.2638);
set( 17, 17, 0, 4, 1.6018, 0.2685);
set( 17, 17, 0, 5, 1.5864, 0.2731);
set( 17, 17, 1, 0, 1.6481, 0.2439);
set( 17, 17, 1, 1, 1.6330, 0.2490);
set( 17, 17, 1, 2, 1.6178, 0.2540);
set( 17, 17, 1, 3, 1.6026, 0.2589);
set( 17, 17, 1, 4, 1.5874, 0.2636);
set( 17, 17, 1, 5, 1.5724, 0.2682);
set( 17, 17, 2, 0, 1.6317, 0.2391);
set( 17, 17, 2, 1, 1.6171, 0.2442);
set( 17, 17, 2, 2, 1.6023, 0.2492);
set( 17, 17, 2, 3, 1.5876, 0.2541);
set( 17, 17, 2, 4, 1.5728, 0.2588);
set( 17, 17, 2, 5, 1.5582, 0.2634);
set( 17, 17, 3, 0, 1.6154, 0.2344);
set( 17, 17, 3, 1, 1.6013, 0.2395);
set( 17, 17, 3, 2, 1.5869, 0.2446);
set( 17, 17, 3, 3, 1.5726, 0.2494);
set( 17, 17, 3, 4, 1.5583, 0.2542);
set( 17, 17, 3, 5, 1.5441, 0.2587);
set( 17, 17, 4, 0, 1.5992, 0.2299);
set( 17, 17, 4, 1, 1.5855, 0.2350);
set( 17, 17, 4, 2, 1.5716, 0.2400);
set( 17, 17, 4, 3, 1.5577, 0.2449);
set( 17, 17, 4, 4, 1.5437, 0.2496);
set( 17, 17, 4, 5, 1.5299, 0.2542);
set( 17, 17, 5, 0, 1.5832, 0.2256);
set( 17, 17, 5, 1, 1.5699, 0.2307);
set( 17, 17, 5, 2, 1.5564, 0.2357);
set( 17, 17, 5, 3, 1.5429, 0.2405);
set( 17, 17, 5, 4, 1.5293, 0.2452);
set( 17, 17, 5, 5, 1.5159, 0.2498);
set( 17, 18, 0, 0, 1.5875, 0.2735);
set( 17, 18, 0, 1, 1.5722, 0.2779);
set( 17, 18, 0, 2, 1.5569, 0.2821);
set( 17, 18, 1, 0, 1.5737, 0.2687);
set( 17, 18, 1, 1, 1.5587, 0.2730);
set( 17, 18, 1, 2, 1.5439, 0.2773);
set( 17, 18, 2, 0, 1.5596, 0.2639);
set( 17, 18, 2, 1, 1.5451, 0.2683);
set( 17, 18, 2, 2, 1.5306, 0.2725);
set( 17, 18, 3, 0, 1.5456, 0.2592);
set( 17, 18, 3, 1, 1.5315, 0.2636);
set( 17, 18, 3, 2, 1.5174, 0.2679);
set( 17, 18, 4, 0, 1.5316, 0.2547);
set( 17, 18, 4, 1, 1.5178, 0.2591);
set( 17, 18, 4, 2, 1.5041, 0.2634);
set( 17, 18, 5, 0, 1.5177, 0.2504);
set( 17, 18, 5, 1, 1.5043, 0.2548);
set( 17, 18, 5, 2, 1.4909, 0.2590);
set( 18, 11, 0, 0, 1.8383, 0.0004);
set( 18, 11, 0, 1, 1.8379, 0.0091);
set( 18, 11, 0, 2, 1.8368, 0.0179);
set( 18, 11, 0, 3, 1.8350, 0.0267);
set( 18, 11, 0, 4, 1.8324, 0.0354);
set( 18, 11, 0, 5, 1.8292, 0.0440);
set( 18, 11, 1, 0, 1.8114, 0.0004);
set( 18, 11, 1, 1, 1.8110, 0.0089);
set( 18, 11, 1, 2, 1.8099, 0.0174);
set( 18, 11, 1, 3, 1.8082, 0.0260);
set( 18, 11, 1, 4, 1.8058, 0.0345);
set( 18, 11, 1, 5, 1.8027, 0.0429);
set( 18, 11, 2, 0, 1.7849, 0.0004);
set( 18, 11, 2, 1, 1.7845, 0.0087);
set( 18, 11, 2, 2, 1.7835, 0.0170);
set( 18, 11, 2, 3, 1.7819, 0.0253);
set( 18, 11, 2, 4, 1.7796, 0.0336);
set( 18, 11, 2, 5, 1.7767, 0.0418);
set( 18, 11, 3, 0, 1.7591, 0.0004);
set( 18, 11, 3, 1, 1.7588, 0.0084);
set( 18, 11, 3, 2, 1.7578, 0.0166);
set( 18, 11, 3, 3, 1.7562, 0.0247);
set( 18, 11, 3, 4, 1.7541, 0.0328);
set( 18, 11, 3, 5, 1.7513, 0.0408);
set( 18, 11, 4, 0, 1.7340, 0.0004);
set( 18, 11, 4, 1, 1.7336, 0.0082);
set( 18, 11, 4, 2, 1.7327, 0.0162);
set( 18, 11, 4, 3, 1.7312, 0.0241);
set( 18, 11, 4, 4, 1.7292, 0.0320);
set( 18, 11, 4, 5, 1.7265, 0.0398);
set( 18, 11, 5, 0, 1.7096, 0.0003);
set( 18, 11, 5, 1, 1.7093, 0.0080);
set( 18, 11, 5, 2, 1.7085, 0.0158);
set( 18, 11, 5, 3, 1.7071, 0.0235);
set( 18, 11, 5, 4, 1.7051, 0.0312);
set( 18, 11, 5, 5, 1.7026, 0.0388);
set( 18, 12, 0, 0, 1.8292, 0.0448);
set( 18, 12, 0, 1, 1.8252, 0.0533);
set( 18, 12, 0, 2, 1.8205, 0.0619);
set( 18, 12, 0, 3, 1.8151, 0.0703);
set( 18, 12, 0, 4, 1.8091, 0.0786);
set( 18, 12, 0, 5, 1.8025, 0.0868);
set( 18, 12, 1, 0, 1.8028, 0.0437);
set( 18, 12, 1, 1, 1.7990, 0.0520);
set( 18, 12, 1, 2, 1.7945, 0.0603);
set( 18, 12, 1, 3, 1.7894, 0.0685);
set( 18, 12, 1, 4, 1.7837, 0.0767);
set( 18, 12, 1, 5, 1.7774, 0.0847);
set( 18, 12, 2, 0, 1.7768, 0.0426);
set( 18, 12, 2, 1, 1.7732, 0.0507);
set( 18, 12, 2, 2, 1.7689, 0.0588);
set( 18, 12, 2, 3, 1.7641, 0.0668);
set( 18, 12, 2, 4, 1.7587, 0.0748);
set( 18, 12, 2, 5, 1.7527, 0.0826);
set( 18, 12, 3, 0, 1.7515, 0.0415);
set( 18, 12, 3, 1, 1.7480, 0.0494);
set( 18, 12, 3, 2, 1.7440, 0.0574);
set( 18, 12, 3, 3, 1.7394, 0.0652);
set( 18, 12, 3, 4, 1.7342, 0.0730);
set( 18, 12, 3, 5, 1.7285, 0.0806);
set( 18, 12, 4, 0, 1.7268, 0.0405);
set( 18, 12, 4, 1, 1.7235, 0.0482);
set( 18, 12, 4, 2, 1.7196, 0.0560);
set( 18, 12, 4, 3, 1.7152, 0.0637);
set( 18, 12, 4, 4, 1.7103, 0.0713);
set( 18, 12, 4, 5, 1.7049, 0.0787);
set( 18, 12, 5, 0, 1.7029, 0.0396);
set( 18, 12, 5, 1, 1.6997, 0.0471);
set( 18, 12, 5, 2, 1.6960, 0.0547);
set( 18, 12, 5, 3, 1.6918, 0.0622);
set( 18, 12, 5, 4, 1.6871, 0.0697);
set( 18, 12, 5, 5, 1.6820, 0.0770);
set( 18, 13, 0, 0, 1.8027, 0.0876);
set( 18, 13, 0, 1, 1.7954, 0.0956);
set( 18, 13, 0, 2, 1.7876, 0.1036);
set( 18, 13, 0, 3, 1.7793, 0.1115);
set( 18, 13, 0, 4, 1.7704, 0.1192);
set( 18, 13, 0, 5, 1.7612, 0.1267);
set( 18, 13, 1, 0, 1.7777, 0.0854);
set( 18, 13, 1, 1, 1.7708, 0.0933);
set( 18, 13, 1, 2, 1.7633, 0.1011);
set( 18, 13, 1, 3, 1.7554, 0.1088);
set( 18, 13, 1, 4, 1.7469, 0.1164);
set( 18, 13, 1, 5, 1.7381, 0.1237);
set( 18, 13, 2, 0, 1.7530, 0.0833);
set( 18, 13, 2, 1, 1.7465, 0.0910);
set( 18, 13, 2, 2, 1.7393, 0.0987);
set( 18, 13, 2, 3, 1.7317, 0.1062);
set( 18, 13, 2, 4, 1.7237, 0.1136);
set( 18, 13, 2, 5, 1.7153, 0.1209);
set( 18, 13, 3, 0, 1.7289, 0.0814);
set( 18, 13, 3, 1, 1.7227, 0.0889);
set( 18, 13, 3, 2, 1.7159, 0.0964);
set( 18, 13, 3, 3, 1.7086, 0.1038);
set( 18, 13, 3, 4, 1.7009, 0.1110);
set( 18, 13, 3, 5, 1.6929, 0.1181);
set( 18, 13, 4, 0, 1.7054, 0.0795);
set( 18, 13, 4, 1, 1.6994, 0.0868);
set( 18, 13, 4, 2, 1.6929, 0.0942);
set( 18, 13, 4, 3, 1.6860, 0.1014);
set( 18, 13, 4, 4, 1.6786, 0.1085);
set( 18, 13, 4, 5, 1.6709, 0.1155);
set( 18, 13, 5, 0, 1.6825, 0.0777);
set( 18, 13, 5, 1, 1.6768, 0.0849);
set( 18, 13, 5, 2, 1.6706, 0.0921);
set( 18, 13, 5, 3, 1.6639, 0.0992);
set( 18, 13, 5, 4, 1.6569, 0.1062);
set( 18, 13, 5, 5, 1.6495, 0.1130);
set( 18, 14, 0, 0, 1.7614, 0.1274);
set( 18, 14, 0, 1, 1.7517, 0.1348);
set( 18, 14, 0, 2, 1.7415, 0.1420);
set( 18, 14, 0, 3, 1.7309, 0.1492);
set( 18, 14, 0, 4, 1.7200, 0.1561);
set( 18, 14, 0, 5, 1.7089, 0.1629);
set( 18, 14, 1, 0, 1.7385, 0.1244);
set( 18, 14, 1, 1, 1.7292, 0.1317);
set( 18, 14, 1, 2, 1.7194, 0.1388);
set( 18, 14, 1, 3, 1.7093, 0.1458);
set( 18, 14, 1, 4, 1.6988, 0.1527);
set( 18, 14, 1, 5, 1.6881, 0.1593);
set( 18, 14, 2, 0, 1.7157, 0.1216);
set( 18, 14, 2, 1, 1.7069, 0.1287);
set( 18, 14, 2, 2, 1.6975, 0.1357);
set( 18, 14, 2, 3, 1.6878, 0.1426);
set( 18, 14, 2, 4, 1.6778, 0.1493);
set( 18, 14, 2, 5, 1.6675, 0.1559);
set( 18, 14, 3, 0, 1.6934, 0.1188);
set( 18, 14, 3, 1, 1.6849, 0.1258);
set( 18, 14, 3, 2, 1.6760, 0.1327);
set( 18, 14, 3, 3, 1.6667, 0.1395);
set( 18, 14, 3, 4, 1.6570, 0.1461);
set( 18, 14, 3, 5, 1.6472, 0.1526);
set( 18, 14, 4, 0, 1.6716, 0.1162);
set( 18, 14, 4, 1, 1.6634, 0.1230);
set( 18, 14, 4, 2, 1.6548, 0.1298);
set( 18, 14, 4, 3, 1.6459, 0.1365);
set( 18, 14, 4, 4, 1.6366, 0.1430);
set( 18, 14, 4, 5, 1.6272, 0.1494);
set( 18, 14, 5, 0, 1.6503, 0.1137);
set( 18, 14, 5, 1, 1.6425, 0.1204);
set( 18, 14, 5, 2, 1.6342, 0.1271);
set( 18, 14, 5, 3, 1.6256, 0.1336);
set( 18, 14, 5, 4, 1.6167, 0.1401);
set( 18, 14, 5, 5, 1.6076, 0.1464);
set( 18, 15, 0, 0, 1.7093, 0.1635);
set( 18, 15, 0, 1, 1.6979, 0.1701);
set( 18, 15, 0, 2, 1.6860, 0.1766);
set( 18, 15, 0, 3, 1.6740, 0.1829);
set( 18, 15, 0, 4, 1.6617, 0.1891);
set( 18, 15, 0, 5, 1.6493, 0.1951);
set( 18, 15, 1, 0, 1.6887, 0.1600);
set( 18, 15, 1, 1, 1.6777, 0.1665);
set( 18, 15, 1, 2, 1.6663, 0.1729);
set( 18, 15, 1, 3, 1.6547, 0.1791);
set( 18, 15, 1, 4, 1.6429, 0.1853);
set( 18, 15, 1, 5, 1.6309, 0.1912);
set( 18, 15, 2, 0, 1.6682, 0.1565);
set( 18, 15, 2, 1, 1.6576, 0.1629);
set( 18, 15, 2, 2, 1.6466, 0.1693);
set( 18, 15, 2, 3, 1.6355, 0.1754);
set( 18, 15, 2, 4, 1.6241, 0.1815);
set( 18, 15, 2, 5, 1.6126, 0.1874);
set( 18, 15, 3, 0, 1.6480, 0.1532);
set( 18, 15, 3, 1, 1.6378, 0.1595);
set( 18, 15, 3, 2, 1.6273, 0.1658);
set( 18, 15, 3, 3, 1.6165, 0.1719);
set( 18, 15, 3, 4, 1.6055, 0.1779);
set( 18, 15, 3, 5, 1.5944, 0.1837);
set( 18, 15, 4, 0, 1.6281, 0.1500);
set( 18, 15, 4, 1, 1.6183, 0.1563);
set( 18, 15, 4, 2, 1.6081, 0.1624);
set( 18, 15, 4, 3, 1.5978, 0.1684);
set( 18, 15, 4, 4, 1.5872, 0.1744);
set( 18, 15, 4, 5, 1.5765, 0.1801);
set( 18, 15, 5, 0, 1.6086, 0.1470);
set( 18, 15, 5, 1, 1.5992, 0.1531);
set( 18, 15, 5, 2, 1.5894, 0.1592);
set( 18, 15, 5, 3, 1.5794, 0.1652);
set( 18, 15, 5, 4, 1.5692, 0.1710);
set( 18, 15, 5, 5, 1.5589, 0.1767);
set( 18, 16, 0, 0, 1.6500, 0.1957);
set( 18, 16, 0, 1, 1.6375, 0.2015);
set( 18, 16, 0, 2, 1.6247, 0.2072);
set( 18, 16, 0, 3, 1.6118, 0.2128);
set( 18, 16, 0, 4, 1.5988, 0.2182);
set( 18, 16, 0, 5, 1.5858, 0.2234);
set( 18, 16, 1, 0, 1.6318, 0.1918);
set( 18, 16, 1, 1, 1.6197, 0.1975);
set( 18, 16, 1, 2, 1.6073, 0.2032);
set( 18, 16, 1, 3, 1.5948, 0.2087);
set( 18, 16, 1, 4, 1.5822, 0.2141);
set( 18, 16, 1, 5, 1.5696, 0.2193);
set( 18, 16, 2, 0, 1.6135, 0.1879);
set( 18, 16, 2, 1, 1.6019, 0.1936);
set( 18, 16, 2, 2, 1.5899, 0.1992);
set( 18, 16, 2, 3, 1.5778, 0.2047);
set( 18, 16, 2, 4, 1.5656, 0.2101);
set( 18, 16, 2, 5, 1.5534, 0.2153);
set( 18, 16, 3, 0, 1.5955, 0.1843);
set( 18, 16, 3, 1, 1.5842, 0.1899);
set( 18, 16, 3, 2, 1.5727, 0.1955);
set( 18, 16, 3, 3, 1.5610, 0.2009);
set( 18, 16, 3, 4, 1.5492, 0.2062);
set( 18, 16, 3, 5, 1.5374, 0.2114);
set( 18, 16, 4, 0, 1.5777, 0.1807);
set( 18, 16, 4, 1, 1.5668, 0.1863);
set( 18, 16, 4, 2, 1.5556, 0.1918);
set( 18, 16, 4, 3, 1.5443, 0.1972);
set( 18, 16, 4, 4, 1.5329, 0.2025);
set( 18, 16, 4, 5, 1.5214, 0.2076);
set( 18, 16, 5, 0, 1.5602, 0.1773);
set( 18, 16, 5, 1, 1.5497, 0.1828);
set( 18, 16, 5, 2, 1.5389, 0.1883);
set( 18, 16, 5, 3, 1.5279, 0.1936);
set( 18, 16, 5, 4, 1.5169, 0.1988);
set( 18, 16, 5, 5, 1.5058, 0.2039);
set( 18, 17, 0, 0, 1.5867, 0.2239);
set( 18, 17, 0, 1, 1.5737, 0.2290);
set( 18, 17, 0, 2, 1.5605, 0.2340);
set( 18, 17, 0, 3, 1.5472, 0.2389);
set( 18, 17, 0, 4, 1.5339, 0.2436);
set( 18, 17, 0, 5, 1.5207, 0.2482);
set( 18, 17, 1, 0, 1.5707, 0.2198);
set( 18, 17, 1, 1, 1.5581, 0.2249);
set( 18, 17, 1, 2, 1.5452, 0.2298);
set( 18, 17, 1, 3, 1.5323, 0.2347);
set( 18, 17, 1, 4, 1.5194, 0.2394);
set( 18, 17, 1, 5, 1.5066, 0.2440);
set( 18, 17, 2, 0, 1.5548, 0.2158);
set( 18, 17, 2, 1, 1.5425, 0.2209);
set( 18, 17, 2, 2, 1.5301, 0.2258);
set( 18, 17, 2, 3, 1.5176, 0.2306);
set( 18, 17, 2, 4, 1.5050, 0.2354);
set( 18, 17, 2, 5, 1.4925, 0.2399);
set( 19, 11, 0, 0, 1.7105, 0.0003);
set( 19, 11, 0, 1, 1.7102, 0.0080);
set( 19, 11, 0, 2, 1.7094, 0.0156);
set( 19, 11, 0, 3, 1.7080, 0.0233);
set( 19, 11, 0, 4, 1.7061, 0.0309);
set( 19, 11, 0, 5, 1.7036, 0.0384);
set( 19, 11, 1, 0, 1.6870, 0.0003);
set( 19, 11, 1, 1, 1.6867, 0.0078);
set( 19, 11, 1, 2, 1.6859, 0.0153);
set( 19, 11, 1, 3, 1.6846, 0.0228);
set( 19, 11, 1, 4, 1.6828, 0.0302);
set( 19, 11, 1, 5, 1.6804, 0.0376);
set( 19, 11, 2, 0, 1.6638, 0.0003);
set( 19, 11, 2, 1, 1.6635, 0.0076);
set( 19, 11, 2, 2, 1.6628, 0.0149);
set( 19, 11, 2, 3, 1.6615, 0.0223);
set( 19, 11, 2, 4, 1.6598, 0.0295);
set( 19, 11, 2, 5, 1.6575, 0.0367);
set( 19, 11, 3, 0, 1.6411, 0.0003);
set( 19, 11, 3, 1, 1.6409, 0.0074);
set( 19, 11, 3, 2, 1.6401, 0.0146);
set( 19, 11, 3, 3, 1.6389, 0.0218);
set( 19, 11, 3, 4, 1.6373, 0.0289);
set( 19, 11, 3, 5, 1.6351, 0.0360);
set( 19, 11, 4, 0, 1.6190, 0.0003);
set( 19, 11, 4, 1, 1.6187, 0.0073);
set( 19, 11, 4, 2, 1.6180, 0.0143);
set( 19, 11, 4, 3, 1.6169, 0.0213);
set( 19, 11, 4, 4, 1.6153, 0.0283);
set( 19, 11, 4, 5, 1.6133, 0.0352);
set( 19, 11, 5, 0, 1.5975, 0.0003);
set( 19, 11, 5, 1, 1.5972, 0.0071);
set( 19, 11, 5, 2, 1.5966, 0.0140);
set( 19, 11, 5, 3, 1.5955, 0.0209);
set( 19, 11, 5, 4, 1.5940, 0.0277);
set( 19, 11, 5, 5, 1.5920, 0.0345);
set( 19, 12, 0, 0, 1.7038, 0.0392);
set( 19, 12, 0, 1, 1.7007, 0.0466);
set( 19, 12, 0, 2, 1.6971, 0.0541);
set( 19, 12, 0, 3, 1.6930, 0.0616);
set( 19, 12, 0, 4, 1.6885, 0.0689);
set( 19, 12, 0, 5, 1.6834, 0.0762);
set( 19, 12, 1, 0, 1.6806, 0.0383);
set( 19, 12, 1, 1, 1.6777, 0.0456);
set( 19, 12, 1, 2, 1.6743, 0.0529);
set( 19, 12, 1, 3, 1.6703, 0.0602);
set( 19, 12, 1, 4, 1.6660, 0.0674);
set( 19, 12, 1, 5, 1.6612, 0.0745);
set( 19, 12, 2, 0, 1.6577, 0.0374);
set( 19, 12, 2, 1, 1.6550, 0.0446);
set( 19, 12, 2, 2, 1.6517, 0.0518);
set( 19, 12, 2, 3, 1.6479, 0.0589);
set( 19, 12, 2, 4, 1.6438, 0.0660);
set( 19, 12, 2, 5, 1.6392, 0.0729);
set( 19, 12, 3, 0, 1.6354, 0.0366);
set( 19, 12, 3, 1, 1.6327, 0.0436);
set( 19, 12, 3, 2, 1.6296, 0.0507);
set( 19, 12, 3, 3, 1.6260, 0.0576);
set( 19, 12, 3, 4, 1.6220, 0.0646);
set( 19, 12, 3, 5, 1.6176, 0.0714);
set( 19, 12, 4, 0, 1.6135, 0.0359);
set( 19, 12, 4, 1, 1.6110, 0.0427);
set( 19, 12, 4, 2, 1.6080, 0.0496);
set( 19, 12, 4, 3, 1.6045, 0.0564);
set( 19, 12, 4, 4, 1.6007, 0.0632);
set( 19, 12, 4, 5, 1.5965, 0.0699);
set( 19, 12, 5, 0, 1.5923, 0.0351);
set( 19, 12, 5, 1, 1.5899, 0.0418);
set( 19, 12, 5, 2, 1.5870, 0.0486);
set( 19, 12, 5, 3, 1.5837, 0.0553);
set( 19, 12, 5, 4, 1.5800, 0.0620);
set( 19, 12, 5, 5, 1.5760, 0.0685);
set( 19, 13, 0, 0, 1.6837, 0.0769);
set( 19, 13, 0, 1, 1.6782, 0.0840);
set( 19, 13, 0, 2, 1.6721, 0.0911);
set( 19, 13, 0, 3, 1.6657, 0.0982);
set( 19, 13, 0, 4, 1.6588, 0.1051);
set( 19, 13, 0, 5, 1.6516, 0.1119);
set( 19, 13, 1, 0, 1.6615, 0.0752);
set( 19, 13, 1, 1, 1.6562, 0.0822);
set( 19, 13, 1, 2, 1.6504, 0.0892);
set( 19, 13, 1, 3, 1.6442, 0.0961);
set( 19, 13, 1, 4, 1.6376, 0.1029);
set( 19, 13, 1, 5, 1.6307, 0.1096);
set( 19, 13, 2, 0, 1.6396, 0.0736);
set( 19, 13, 2, 1, 1.6345, 0.0804);
set( 19, 13, 2, 2, 1.6289, 0.0873);
set( 19, 13, 2, 3, 1.6230, 0.0941);
set( 19, 13, 2, 4, 1.6167, 0.1008);
set( 19, 13, 2, 5, 1.6100, 0.1073);
set( 19, 13, 3, 0, 1.6181, 0.0720);
set( 19, 13, 3, 1, 1.6132, 0.0788);
set( 19, 13, 3, 2, 1.6079, 0.0855);
set( 19, 13, 3, 3, 1.6022, 0.0921);
set( 19, 13, 3, 4, 1.5961, 0.0987);
set( 19, 13, 3, 5, 1.5897, 0.1051);
set( 19, 13, 4, 0, 1.5970, 0.0706);
set( 19, 13, 4, 1, 1.5923, 0.0771);
set( 19, 13, 4, 2, 1.5872, 0.0837);
set( 19, 13, 4, 3, 1.5817, 0.0903);
set( 19, 13, 4, 4, 1.5759, 0.0967);
set( 19, 13, 4, 5, 1.5698, 0.1030);
set( 19, 13, 5, 0, 1.5765, 0.0691);
set( 19, 13, 5, 1, 1.5720, 0.0756);
set( 19, 13, 5, 2, 1.5671, 0.0821);
set( 19, 13, 5, 3, 1.5619, 0.0885);
set( 19, 13, 5, 4, 1.5563, 0.0948);
set( 19, 13, 5, 5, 1.5504, 0.1011);
set( 19, 14, 0, 0, 1.6520, 0.1125);
set( 19, 14, 0, 1, 1.6444, 0.1192);
set( 19, 14, 0, 2, 1.6364, 0.1258);
set( 19, 14, 0, 3, 1.6280, 0.1323);
set( 19, 14, 0, 4, 1.6193, 0.1388);
set( 19, 14, 0, 5, 1.6104, 0.1450);
set( 19, 14, 1, 0, 1.6312, 0.1102);
set( 19, 14, 1, 1, 1.6239, 0.1168);
set( 19, 14, 1, 2, 1.6162, 0.1233);
set( 19, 14, 1, 3, 1.6082, 0.1297);
set( 19, 14, 1, 4, 1.5998, 0.1360);
set( 19, 14, 1, 5, 1.5912, 0.1421);
set( 19, 14, 2, 0, 1.6106, 0.1079);
set( 19, 14, 2, 1, 1.6036, 0.1144);
set( 19, 14, 2, 2, 1.5962, 0.1208);
set( 19, 14, 2, 3, 1.5884, 0.1271);
set( 19, 14, 2, 4, 1.5804, 0.1333);
set( 19, 14, 2, 5, 1.5722, 0.1394);
set( 19, 14, 3, 0, 1.5904, 0.1058);
set( 19, 14, 3, 1, 1.5837, 0.1121);
set( 19, 14, 3, 2, 1.5765, 0.1184);
set( 19, 14, 3, 3, 1.5691, 0.1246);
set( 19, 14, 3, 4, 1.5613, 0.1307);
set( 19, 14, 3, 5, 1.5534, 0.1367);
set( 19, 14, 4, 0, 1.5706, 0.1037);
set( 19, 14, 4, 1, 1.5641, 0.1099);
set( 19, 14, 4, 2, 1.5572, 0.1161);
set( 19, 14, 4, 3, 1.5500, 0.1222);
set( 19, 14, 4, 4, 1.5426, 0.1282);
set( 19, 14, 4, 5, 1.5349, 0.1341);
set( 19, 14, 5, 0, 1.5512, 0.1017);
set( 19, 14, 5, 1, 1.5449, 0.1078);
set( 19, 14, 5, 2, 1.5383, 0.1139);
set( 19, 14, 5, 3, 1.5314, 0.1199);
set( 19, 14, 5, 4, 1.5242, 0.1259);
set( 19, 14, 5, 5, 1.5168, 0.1317);
set( 19, 15, 0, 0, 1.6110, 0.1456);
set( 19, 15, 0, 1, 1.6018, 0.1517);
set( 19, 15, 0, 2, 1.5923, 0.1577);
set( 19, 15, 0, 3, 1.5825, 0.1637);
set( 19, 15, 0, 4, 1.5726, 0.1695);
set( 19, 15, 0, 5, 1.5625, 0.1751);
set( 19, 15, 1, 0, 1.5920, 0.1427);
set( 19, 15, 1, 1, 1.5831, 0.1488);
set( 19, 15, 1, 2, 1.5739, 0.1547);
set( 19, 15, 1, 3, 1.5645, 0.1606);
set( 19, 15, 1, 4, 1.5549, 0.1663);
set( 19, 15, 1, 5, 1.5451, 0.1719);
set( 19, 15, 2, 0, 1.5730, 0.1400);
set( 19, 15, 2, 1, 1.5644, 0.1459);
set( 19, 15, 2, 2, 1.5556, 0.1518);
set( 19, 15, 2, 3, 1.5465, 0.1576);
set( 19, 15, 2, 4, 1.5372, 0.1632);
set( 19, 15, 2, 5, 1.5277, 0.1688);
set( 19, 15, 3, 0, 1.5543, 0.1373);
set( 19, 15, 3, 1, 1.5461, 0.1431);
set( 19, 15, 3, 2, 1.5375, 0.1489);
set( 19, 15, 3, 3, 1.5287, 0.1547);
set( 19, 15, 3, 4, 1.5197, 0.1603);
set( 19, 15, 3, 5, 1.5106, 0.1657);
set( 19, 15, 4, 0, 1.5359, 0.1347);
set( 19, 15, 4, 1, 1.5280, 0.1405);
set( 19, 15, 4, 2, 1.5197, 0.1462);
set( 19, 15, 4, 3, 1.5112, 0.1518);
set( 19, 15, 4, 4, 1.5025, 0.1574);
set( 19, 15, 4, 5, 1.4937, 0.1628);
set( 19, 15, 5, 0, 1.5179, 0.1323);
set( 19, 15, 5, 1, 1.5103, 0.1379);
set( 19, 15, 5, 2, 1.5023, 0.1436);
set( 19, 15, 5, 3, 1.4941, 0.1491);
set( 19, 15, 5, 4, 1.4857, 0.1546);
set( 19, 15, 5, 5, 1.4771, 0.1600);
set( 19, 16, 0, 0, 1.5633, 0.1757);
set( 19, 16, 0, 1, 1.5530, 0.1812);
set( 19, 16, 0, 2, 1.5425, 0.1866);
set( 19, 16, 0, 3, 1.5318, 0.1920);
set( 19, 16, 0, 4, 1.5210, 0.1972);
set( 19, 16, 0, 5, 1.5101, 0.2023);
set( 19, 16, 1, 0, 1.5460, 0.1725);
set( 19, 16, 1, 1, 1.5361, 0.1779);
set( 19, 16, 1, 2, 1.5259, 0.1833);
set( 19, 16, 1, 3, 1.5155, 0.1886);
set( 19, 16, 1, 4, 1.5050, 0.1938);
set( 19, 16, 1, 5, 1.4945, 0.1988);
set( 19, 16, 2, 0, 1.5290, 0.1694);
set( 19, 16, 2, 1, 1.5193, 0.1748);
set( 19, 16, 2, 2, 1.5095, 0.1801);
set( 19, 16, 2, 3, 1.4994, 0.1853);
set( 19, 16, 2, 4, 1.4892, 0.1905);
set( 19, 16, 2, 5, 1.4790, 0.1955);
set( 20, 11, 0, 0, 1.5989, 0.0003);
set( 20, 11, 0, 1, 1.5987, 0.0070);
set( 20, 11, 0, 2, 1.5980, 0.0138);
set( 20, 11, 0, 3, 1.5970, 0.0206);
set( 20, 11, 0, 4, 1.5955, 0.0274);
set( 20, 11, 0, 5, 1.5936, 0.0341);
set( 20, 11, 1, 0, 1.5781, 0.0003);
set( 20, 11, 1, 1, 1.5779, 0.0069);
set( 20, 11, 1, 2, 1.5772, 0.0136);
set( 20, 11, 1, 3, 1.5762, 0.0202);
set( 20, 11, 1, 4, 1.5748, 0.0269);
set( 20, 11, 1, 5, 1.5730, 0.0334);
set( 20, 11, 2, 0, 1.5575, 0.0003);
set( 20, 11, 2, 1, 1.5573, 0.0068);
set( 20, 11, 2, 2, 1.5567, 0.0133);
set( 20, 11, 2, 3, 1.5557, 0.0198);
set( 20, 11, 2, 4, 1.5543, 0.0263);
set( 20, 11, 2, 5, 1.5526, 0.0328);
set( 20, 11, 3, 0, 1.5373, 0.0003);
set( 20, 11, 3, 1, 1.5371, 0.0066);
set( 20, 11, 3, 2, 1.5365, 0.0130);
set( 20, 11, 3, 3, 1.5356, 0.0194);
set( 20, 11, 3, 4, 1.5343, 0.0258);
set( 20, 11, 3, 5, 1.5326, 0.0321);
set( 20, 11, 4, 0, 1.5175, 0.0003);
set( 20, 11, 4, 1, 1.5173, 0.0065);
set( 20, 11, 4, 2, 1.5168, 0.0128);
set( 20, 11, 4, 3, 1.5158, 0.0191);
set( 20, 11, 4, 4, 1.5146, 0.0253);
set( 20, 11, 4, 5, 1.5130, 0.0315);
set( 20, 11, 5, 0, 1.4983, 0.0003);
set( 20, 11, 5, 1, 1.4981, 0.0064);
set( 20, 11, 5, 2, 1.4975, 0.0126);
set( 20, 11, 5, 3, 1.4967, 0.0187);
set( 20, 11, 5, 4, 1.4955, 0.0249);
set( 20, 11, 5, 5, 1.4939, 0.0309);
set( 20, 12, 0, 0, 1.5938, 0.0347);
set( 20, 12, 0, 1, 1.5914, 0.0414);
set( 20, 12, 0, 2, 1.5886, 0.0480);
set( 20, 12, 0, 3, 1.5854, 0.0547);
set( 20, 12, 0, 4, 1.5818, 0.0613);
set( 20, 12, 0, 5, 1.5779, 0.0677);
set( 20, 12, 1, 0, 1.5732, 0.0340);
set( 20, 12, 1, 1, 1.5709, 0.0406);
set( 20, 12, 1, 2, 1.5682, 0.0471);
set( 20, 12, 1, 3, 1.5651, 0.0536);
set( 20, 12, 1, 4, 1.5617, 0.0601);
set( 20, 12, 1, 5, 1.5579, 0.0664);
set( 20, 12, 2, 0, 1.5528, 0.0334);
set( 20, 12, 2, 1, 1.5506, 0.0398);
set( 20, 12, 2, 2, 1.5480, 0.0462);
set( 20, 12, 2, 3, 1.5451, 0.0526);
set( 20, 12, 2, 4, 1.5418, 0.0589);
set( 20, 12, 2, 5, 1.5381, 0.0652);
set( 20, 12, 3, 0, 1.5329, 0.0327);
set( 20, 12, 3, 1, 1.5307, 0.0390);
set( 20, 12, 3, 2, 1.5283, 0.0453);
set( 20, 12, 3, 3, 1.5254, 0.0516);
set( 20, 12, 3, 4, 1.5222, 0.0578);
set( 20, 12, 3, 5, 1.5187, 0.0639);
set( 20, 12, 4, 0, 1.5133, 0.0321);
set( 20, 12, 4, 1, 1.5113, 0.0383);
set( 20, 12, 4, 2, 1.5089, 0.0445);
set( 20, 12, 4, 3, 1.5061, 0.0506);
set( 20, 12, 4, 4, 1.5031, 0.0567);
set( 20, 12, 4, 5, 1.4997, 0.0628);
set( 20, 12, 5, 0, 1.4943, 0.0315);
set( 20, 12, 5, 1, 1.4923, 0.0376);
set( 20, 12, 5, 2, 1.4900, 0.0437);
set( 20, 12, 5, 3, 1.4874, 0.0497);
set( 20, 12, 5, 4, 1.4844, 0.0557);
set( 20, 12, 5, 5, 1.4812, 0.0616);
set( 20, 13, 0, 0, 1.5782, 0.0684);
set( 20, 13, 0, 1, 1.5739, 0.0748);
set( 20, 13, 0, 2, 1.5691, 0.0812);
set( 20, 13, 0, 3, 1.5640, 0.0875);
set( 20, 13, 0, 4, 1.5586, 0.0938);
set( 20, 13, 0, 5, 1.5528, 0.1000);
set( 20, 13, 1, 0, 1.5583, 0.0670);
set( 20, 13, 1, 1, 1.5541, 0.0733);
set( 20, 13, 1, 2, 1.5495, 0.0796);
set( 20, 13, 1, 3, 1.5446, 0.0859);
set( 20, 13, 1, 4, 1.5394, 0.0921);
set( 20, 13, 1, 5, 1.5339, 0.0981);
set( 20, 13, 2, 0, 1.5388, 0.0658);
set( 20, 13, 2, 1, 1.5347, 0.0720);
set( 20, 13, 2, 2, 1.5303, 0.0781);
set( 20, 13, 2, 3, 1.5256, 0.0843);
set( 20, 13, 2, 4, 1.5205, 0.0904);
set( 20, 13, 2, 5, 1.5152, 0.0963);
}
void
MEEEDisplay::drawRz()
{
setRzXtals();
for( int ii=1; ii<=100; ii++ )
{
if( _rzXtals.count(ii)!=1 ) continue;
_rzXtals[ii]->SetLineColor( kGreen+3 );
_rzXtals[ii]->SetLineWidth( 1 );
_rzXtals[ii]->SetFillColor( kGreen-9 );
_rzXtals[ii]->Draw("f");
_rzXtals[ii]->Draw();
TPolyLine* pline_;
for( int jj=1; jj<5; jj++ )
{
pline_ = (TPolyLine*) _rzXtals[ii]->Clone();
for( int kk=0; kk<5; kk++ )
{
pline_->GetX()[kk] *= -1;
}
pline_->Draw("f");
pline_->Draw();
}
for( int jj=1; jj<5; jj++ )
{
pline_ = (TPolyLine*) _rzXtals[ii]->Clone();
for( int kk=0; kk<5; kk++ )
{
pline_->GetX()[kk] *= -1;
pline_->GetY()[kk] *= -1;
}
pline_->Draw("f");
pline_->Draw();
}
for( int jj=1; jj<5; jj++ )
{
pline_ = (TPolyLine*) _rzXtals[ii]->Clone();
for( int kk=0; kk<5; kk++ )
{
pline_->GetY()[kk] *= -1;
}
pline_->Draw("f");
pline_->Draw();
}
}
}
void
MEEEDisplay::setRzXtals()
{
static bool done=false;
if( done ) return;
done = true;
cout << "SetRzXtals " << endl;
// iy=62
double xx_62[5]; double yy_62[5];
xx_62[0]= 319.867; yy_62[0]= 32.748;
xx_62[1]= 319.670; yy_62[1]= 35.592;
xx_62[2]= 341.608; yy_62[2]= 37.252;
xx_62[3]= 341.814; yy_62[3]= 34.270;
xx_62[4]= xx_62[0]; yy_62[4]= yy_62[0];;
_rzXtals[62] = new TPolyLine( 5, xx_62,yy_62);
// iy=63
double xx_63[5]; double yy_63[5];
xx_63[0]= 319.686; yy_63[0]= 35.648;
xx_63[1]= 319.471; yy_63[1]= 38.492;
xx_63[2]= 341.398; yy_63[2]= 40.290;
xx_63[3]= 341.623; yy_63[3]= 37.309;
xx_63[4]= xx_63[0]; yy_63[4]= yy_63[0];;
_rzXtals[63] = new TPolyLine( 5, xx_63,yy_63);
// iy=64
double xx_64[5]; double yy_64[5];
xx_64[0]= 319.506; yy_64[0]= 38.551;
xx_64[1]= 319.272; yy_64[1]= 41.394;
xx_64[2]= 341.188; yy_64[2]= 43.329;
xx_64[3]= 341.432; yy_64[3]= 40.348;
xx_64[4]= xx_64[0]; yy_64[4]= yy_64[0];;
_rzXtals[64] = new TPolyLine( 5, xx_64,yy_64);
// iy=65
double xx_65[5]; double yy_65[5];
xx_65[0]= 319.326; yy_65[0]= 41.454;
xx_65[1]= 319.075; yy_65[1]= 44.296;
xx_65[2]= 340.978; yy_65[2]= 46.369;
xx_65[3]= 341.241; yy_65[3]= 43.389;
xx_65[4]= xx_65[0]; yy_65[4]= yy_65[0];;
_rzXtals[65] = new TPolyLine( 5, xx_65,yy_65);
// iy=66
double xx_66[5]; double yy_66[5];
xx_66[0]= 320.497; yy_66[0]= 44.711;
xx_66[1]= 320.228; yy_66[1]= 47.552;
xx_66[2]= 342.117; yy_66[2]= 49.762;
xx_66[3]= 342.399; yy_66[3]= 46.783;
xx_66[4]= xx_66[0]; yy_66[4]= yy_66[0];;
_rzXtals[66] = new TPolyLine( 5, xx_66,yy_66);
// iy=67
double xx_67[5]; double yy_67[5];
xx_67[0]= 320.223; yy_67[0]= 47.607;
xx_67[1]= 319.937; yy_67[1]= 50.446;
xx_67[2]= 341.812; yy_67[2]= 52.794;
xx_67[3]= 342.112; yy_67[3]= 49.817;
xx_67[4]= xx_67[0]; yy_67[4]= yy_67[0];;
_rzXtals[67] = new TPolyLine( 5, xx_67,yy_67);
// iy=68
double xx_68[5]; double yy_68[5];
xx_68[0]= 319.951; yy_68[0]= 50.503;
xx_68[1]= 319.646; yy_68[1]= 53.341;
xx_68[2]= 341.506; yy_68[2]= 55.826;
xx_68[3]= 341.826; yy_68[3]= 52.851;
xx_68[4]= xx_68[0]; yy_68[4]= yy_68[0];;
_rzXtals[68] = new TPolyLine( 5, xx_68,yy_68);
// iy=69
double xx_69[5]; double yy_69[5];
xx_69[0]= 319.680; yy_69[0]= 53.401;
xx_69[1]= 319.357; yy_69[1]= 56.237;
xx_69[2]= 341.201; yy_69[2]= 58.859;
xx_69[3]= 341.539; yy_69[3]= 55.885;
xx_69[4]= xx_69[0]; yy_69[4]= yy_69[0];;
_rzXtals[69] = new TPolyLine( 5, xx_69,yy_69);
// iy=70
double xx_70[5]; double yy_70[5];
xx_70[0]= 319.409; yy_70[0]= 56.299;
xx_70[1]= 319.069; yy_70[1]= 59.133;
xx_70[2]= 340.896; yy_70[2]= 61.892;
xx_70[3]= 341.252; yy_70[3]= 58.921;
xx_70[4]= xx_70[0]; yy_70[4]= yy_70[0];;
_rzXtals[70] = new TPolyLine( 5, xx_70,yy_70);
// iy=71
double xx_71[5]; double yy_71[5];
xx_71[0]= 320.940; yy_71[0]= 59.652;
xx_71[1]= 320.582; yy_71[1]= 62.484;
xx_71[2]= 342.391; yy_71[2]= 65.380;
xx_71[3]= 342.767; yy_71[3]= 62.410;
xx_71[4]= xx_71[0]; yy_71[4]= yy_71[0];;
_rzXtals[71] = new TPolyLine( 5, xx_71,yy_71);
// iy=72
double xx_72[5]; double yy_72[5];
xx_72[0]= 320.576; yy_72[0]= 62.539;
xx_72[1]= 320.200; yy_72[1]= 65.369;
xx_72[2]= 341.991; yy_72[2]= 68.402;
xx_72[3]= 342.385; yy_72[3]= 65.435;
xx_72[4]= xx_72[0]; yy_72[4]= yy_72[0];;
_rzXtals[72] = new TPolyLine( 5, xx_72,yy_72);
// iy=73
double xx_73[5]; double yy_73[5];
xx_73[0]= 320.213; yy_73[0]= 65.427;
xx_73[1]= 319.819; yy_73[1]= 68.255;
xx_73[2]= 341.590; yy_73[2]= 71.424;
xx_73[3]= 342.003; yy_73[3]= 68.459;
xx_73[4]= xx_73[0]; yy_73[4]= yy_73[0];;
_rzXtals[73] = new TPolyLine( 5, xx_73,yy_73);
// iy=74
double xx_74[5]; double yy_74[5];
xx_74[0]= 319.850; yy_74[0]= 68.315;
xx_74[1]= 319.439; yy_74[1]= 71.141;
xx_74[2]= 341.190; yy_74[2]= 74.447;
xx_74[3]= 341.621; yy_74[3]= 71.485;
xx_74[4]= xx_74[0]; yy_74[4]= yy_74[0];;
_rzXtals[74] = new TPolyLine( 5, xx_74,yy_74);
// iy=75
double xx_75[5]; double yy_75[5];
xx_75[0]= 319.489; yy_75[0]= 71.204;
xx_75[1]= 319.059; yy_75[1]= 74.027;
xx_75[2]= 340.789; yy_75[2]= 77.470;
xx_75[3]= 341.239; yy_75[3]= 74.510;
xx_75[4]= xx_75[0]; yy_75[4]= yy_75[0];;
_rzXtals[75] = new TPolyLine( 5, xx_75,yy_75);
// iy=76
double xx_76[5]; double yy_76[5];
xx_76[0]= 321.379; yy_76[0]= 74.678;
xx_76[1]= 320.932; yy_76[1]= 77.498;
xx_76[2]= 342.640; yy_76[2]= 81.077;
xx_76[3]= 343.108; yy_76[3]= 78.120;
xx_76[4]= xx_76[0]; yy_76[4]= yy_76[0];;
_rzXtals[76] = new TPolyLine( 5, xx_76,yy_76);
// iy=77
double xx_77[5]; double yy_77[5];
xx_77[0]= 320.924; yy_77[0]= 77.553;
xx_77[1]= 320.460; yy_77[1]= 80.370;
xx_77[2]= 342.145; yy_77[2]= 84.086;
xx_77[3]= 342.632; yy_77[3]= 81.132;
xx_77[4]= xx_77[0]; yy_77[4]= yy_77[0];;
_rzXtals[77] = new TPolyLine( 5, xx_77,yy_77);
// iy=78
double xx_78[5]; double yy_78[5];
xx_78[0]= 320.471; yy_78[0]= 80.428;
xx_78[1]= 319.988; yy_78[1]= 83.243;
xx_78[2]= 341.649; yy_78[2]= 87.094;
xx_78[3]= 342.155; yy_78[3]= 84.143;
xx_78[4]= xx_78[0]; yy_78[4]= yy_78[0];;
_rzXtals[78] = new TPolyLine( 5, xx_78,yy_78);
// iy=79
double xx_79[5]; double yy_79[5];
xx_79[0]= 320.018; yy_79[0]= 83.304;
xx_79[1]= 319.518; yy_79[1]= 86.116;
xx_79[2]= 341.154; yy_79[2]= 90.104;
xx_79[3]= 341.678; yy_79[3]= 87.156;
xx_79[4]= xx_79[0]; yy_79[4]= yy_79[0];;
_rzXtals[79] = new TPolyLine( 5, xx_79,yy_79);
// iy=80
double xx_80[5]; double yy_80[5];
xx_80[0]= 319.565; yy_80[0]= 86.181;
xx_80[1]= 319.048; yy_80[1]= 88.990;
xx_80[2]= 340.659; yy_80[2]= 93.113;
xx_80[3]= 341.201; yy_80[3]= 90.169;
xx_80[4]= xx_80[0]; yy_80[4]= yy_80[0];;
_rzXtals[80] = new TPolyLine( 5, xx_80,yy_80);
// iy=81
double xx_81[5]; double yy_81[5];
xx_81[0]= 321.813; yy_81[0]= 89.802;
xx_81[1]= 321.278; yy_81[1]= 92.607;
xx_81[2]= 342.862; yy_81[2]= 96.866;
xx_81[3]= 343.424; yy_81[3]= 93.925;
xx_81[4]= xx_81[0]; yy_81[4]= yy_81[0];;
_rzXtals[81] = new TPolyLine( 5, xx_81,yy_81);
// iy=82
double xx_82[5]; double yy_82[5];
xx_82[0]= 321.268; yy_82[0]= 92.661;
xx_82[1]= 320.716; yy_82[1]= 95.463;
xx_82[2]= 342.273; yy_82[2]= 99.858;
xx_82[3]= 342.853; yy_82[3]= 96.920;
xx_82[4]= xx_82[0]; yy_82[4]= yy_82[0];;
_rzXtals[82] = new TPolyLine( 5, xx_82,yy_82);
// iy=83
double xx_83[5]; double yy_83[5];
xx_83[0]= 320.725; yy_83[0]= 95.522;
xx_83[1]= 320.154; yy_83[1]= 98.320;
xx_83[2]= 341.683; yy_83[2]= 102.850;
xx_83[3]= 342.281; yy_83[3]= 99.916;
xx_83[4]= xx_83[0]; yy_83[4]= yy_83[0];;
_rzXtals[83] = new TPolyLine( 5, xx_83,yy_83);
// iy=84
double xx_84[5]; double yy_84[5];
xx_84[0]= 320.181; yy_84[0]= 98.382;
xx_84[1]= 319.593; yy_84[1]= 101.177;
xx_84[2]= 341.094; yy_84[2]= 105.842;
xx_84[3]= 341.710; yy_84[3]= 102.912;
xx_84[4]= xx_84[0]; yy_84[4]= yy_84[0];;
_rzXtals[84] = new TPolyLine( 5, xx_84,yy_84);
// iy=85
double xx_85[5]; double yy_85[5];
xx_85[0]= 319.639; yy_85[0]= 101.244;
xx_85[1]= 319.033; yy_85[1]= 104.035;
xx_85[2]= 340.504; yy_85[2]= 108.835;
xx_85[3]= 341.139; yy_85[3]= 105.909;
xx_85[4]= xx_85[0]; yy_85[4]= yy_85[0];;
_rzXtals[85] = new TPolyLine( 5, xx_85,yy_85);
// iy=86
double xx_86[5]; double yy_86[5];
xx_86[0]= 322.242; yy_86[0]= 105.039;
xx_86[1]= 321.619; yy_86[1]= 107.826;
xx_86[2]= 343.059; yy_86[2]= 112.761;
xx_86[3]= 343.712; yy_86[3]= 109.838;
xx_86[4]= xx_86[0]; yy_86[4]= yy_86[0];;
_rzXtals[86] = new TPolyLine( 5, xx_86,yy_86);
// iy=87
double xx_87[5]; double yy_87[5];
xx_87[0]= 321.608; yy_87[0]= 107.880;
xx_87[1]= 320.967; yy_87[1]= 110.663;
xx_87[2]= 342.376; yy_87[2]= 115.733;
xx_87[3]= 343.047; yy_87[3]= 112.815;
xx_87[4]= xx_87[0]; yy_87[4]= yy_87[0];;
_rzXtals[87] = new TPolyLine( 5, xx_87,yy_87);
// iy=88
double xx_88[5]; double yy_88[5];
xx_88[0]= 320.974; yy_88[0]= 110.722;
xx_88[1]= 320.316; yy_88[1]= 113.501;
xx_88[2]= 341.692; yy_88[2]= 118.705;
xx_88[3]= 342.382; yy_88[3]= 115.791;
xx_88[4]= xx_88[0]; yy_88[4]= yy_88[0];;
_rzXtals[88] = new TPolyLine( 5, xx_88,yy_88);
// iy=89
double xx_89[5]; double yy_89[5];
xx_89[0]= 320.341; yy_89[0]= 113.564;
xx_89[1]= 319.666; yy_89[1]= 116.340;
xx_89[2]= 341.009; yy_89[2]= 121.677;
xx_89[3]= 341.717; yy_89[3]= 118.768;
xx_89[4]= xx_89[0]; yy_89[4]= yy_89[0];;
_rzXtals[89] = new TPolyLine( 5, xx_89,yy_89);
// iy=90
double xx_90[5]; double yy_90[5];
xx_90[0]= 319.709; yy_90[0]= 116.407;
xx_90[1]= 319.016; yy_90[1]= 119.178;
xx_90[2]= 340.326; yy_90[2]= 124.650;
xx_90[3]= 341.052; yy_90[3]= 121.745;
xx_90[4]= xx_90[0]; yy_90[4]= yy_90[0];;
_rzXtals[90] = new TPolyLine( 5, xx_90,yy_90);
// iy=91
double xx_91[5]; double yy_91[5];
xx_91[0]= 322.665; yy_91[0]= 120.404;
xx_91[1]= 321.955; yy_91[1]= 123.170;
xx_91[2]= 343.229; yy_91[2]= 128.776;
xx_91[3]= 343.974; yy_91[3]= 125.875;
xx_91[4]= xx_91[0]; yy_91[4]= yy_91[0];;
_rzXtals[91] = new TPolyLine( 5, xx_91,yy_91);
// iy=92
double xx_92[5]; double yy_92[5];
xx_92[0]= 321.942; yy_92[0]= 123.224;
xx_92[1]= 321.214; yy_92[1]= 125.986;
xx_92[2]= 342.453; yy_92[2]= 131.725;
xx_92[3]= 343.216; yy_92[3]= 128.829;
xx_92[4]= xx_92[0]; yy_92[4]= yy_92[0];;
_rzXtals[92] = new TPolyLine( 5, xx_92,yy_92);
// iy=93
double xx_93[5]; double yy_93[5];
xx_93[0]= 321.219; yy_93[0]= 126.045;
xx_93[1]= 320.474; yy_93[1]= 128.802;
xx_93[2]= 341.677; yy_93[2]= 134.674;
xx_93[3]= 342.458; yy_93[3]= 131.784;
xx_93[4]= xx_93[0]; yy_93[4]= yy_93[0];;
_rzXtals[93] = new TPolyLine( 5, xx_93,yy_93);
// iy=94
double xx_94[5]; double yy_94[5];
xx_94[0]= 320.498; yy_94[0]= 128.866;
xx_94[1]= 319.735; yy_94[1]= 131.619;
xx_94[2]= 340.900; yy_94[2]= 137.624;
xx_94[3]= 341.700; yy_94[3]= 134.738;
xx_94[4]= xx_94[0]; yy_94[4]= yy_94[0];;
_rzXtals[94] = new TPolyLine( 5, xx_94,yy_94);
// iy=95
double xx_95[5]; double yy_95[5];
xx_95[0]= 319.777; yy_95[0]= 131.688;
xx_95[1]= 318.997; yy_95[1]= 134.436;
xx_95[2]= 340.124; yy_95[2]= 140.574;
xx_95[3]= 340.941; yy_95[3]= 137.693;
xx_95[4]= xx_95[0]; yy_95[4]= yy_95[0];;
_rzXtals[95] = new TPolyLine( 5, xx_95,yy_95);
// iy=96
double xx_96[5]; double yy_96[5];
xx_96[0]= 323.082; yy_96[0]= 135.914;
xx_96[1]= 322.285; yy_96[1]= 138.657;
xx_96[2]= 343.373; yy_96[2]= 144.928;
xx_96[3]= 344.208; yy_96[3]= 142.052;
xx_96[4]= xx_96[0]; yy_96[4]= yy_96[0];;
_rzXtals[96] = new TPolyLine( 5, xx_96,yy_96);
// iy=97
double xx_97[5]; double yy_97[5];
xx_97[0]= 322.270; yy_97[0]= 138.710;
xx_97[1]= 321.456; yy_97[1]= 141.448;
xx_97[2]= 342.504; yy_97[2]= 147.851;
xx_97[3]= 343.358; yy_97[3]= 144.981;
xx_97[4]= xx_97[0]; yy_97[4]= yy_97[0];;
_rzXtals[97] = new TPolyLine( 5, xx_97,yy_97);
// iy=98
double xx_98[5]; double yy_98[5];
xx_98[0]= 321.460; yy_98[0]= 141.507;
xx_98[1]= 320.628; yy_98[1]= 144.239;
xx_98[2]= 341.636; yy_98[2]= 150.775;
xx_98[3]= 342.507; yy_98[3]= 147.910;
xx_98[4]= xx_98[0]; yy_98[4]= yy_98[0];;
_rzXtals[98] = new TPolyLine( 5, xx_98,yy_98);
// iy=99
double xx_99[5]; double yy_99[5];
xx_99[0]= 320.650; yy_99[0]= 144.304;
xx_99[1]= 319.801; yy_99[1]= 147.032;
xx_99[2]= 340.767; yy_99[2]= 153.699;
xx_99[3]= 341.657; yy_99[3]= 150.839;
xx_99[4]= xx_99[0]; yy_99[4]= yy_99[0];;
_rzXtals[99] = new TPolyLine( 5, xx_99,yy_99);
// iy=100
double xx_100[5]; double yy_100[5];
xx_100[0]= 319.840; yy_100[0]= 147.102;
xx_100[1]= 318.975; yy_100[1]= 149.824;
xx_100[2]= 339.899; yy_100[2]= 156.623;
xx_100[3]= 340.806; yy_100[3]= 153.769;
xx_100[4]= xx_100[0]; yy_100[4]= yy_100[0];;
_rzXtals[100] = new TPolyLine( 5, xx_100,yy_100);
}
void
MEEEDisplay::registerTObject( TObject* o )
{
_list.push_back( o );
}
void
MEEEDisplay::refresh()
{
for( list<TObject*>::iterator it=_list.begin();
it!=_list.end(); ++it )
{
delete (*it);
(*it) = 0;
}
_list.clear();
}
void
MEEEDisplay::drawEEGlobal()
{
// for( int ii=73; ii<=92; ii++ )
// {
// int iz=1;
// if( ii>82 ) iz=-1;
// TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMRegion, ii, iz );
// for( int jj=0; jj<g_->GetN(); jj++ )
// {
// double x,y;
// g_->GetPoint( jj, x, y );
// g_->SetPoint( jj, x, iz*y );
// }
// g_->SetLineWidth(1);
// g_->Draw("LSame");
// }
for( int iz=-1; iz<=2; iz+=2 )
{
for( int iside=1; iside<=2; iside++ )
{
for( int ii=1; ii<=19; ii++ )
{
// int iz=1;
// if( ii>9 ) iz=-1;
TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, ii, iz, iside );
for( int jj=0; jj<g_->GetN(); jj++ )
{
double x,y;
g_->GetPoint( jj, x, y );
g_->SetPoint( jj, x, iz*y );
}
g_->SetLineWidth(1);
g_->Draw("LSame");
}
}
for( int ii=1; ii<=9; ii++ )
{
// int iz=1;
// if( ii>9 ) iz=-1;
TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iSector, ii, iz );
for( int jj=0; jj<g_->GetN(); jj++ )
{
double x,y;
g_->GetPoint( jj, x, y );
g_->SetPoint( jj, x, iz*y );
}
g_->SetLineWidth(2);
g_->Draw("LSame");
}
}
}
void
MEEEDisplay::drawEELocal( int isect )
{
if( isect<1 || isect>18 ) return;
// fixme !!!
if( isect>9 ) isect-=9;
int iz=1;
int ii=isect;
TGraph* g1_(0);
if( isect==1 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 1, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 2, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 3, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 4, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==2 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 5, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 6, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 7, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 8, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==3 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 9, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 10, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 11, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 12, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 13, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==4 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 14, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 15, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 16, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 17, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==5 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 18, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 19, iz, 1 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 18, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 19, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==6 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 14, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 15, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 16, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 17, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==7 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 9, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 10, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 11, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 12, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 13, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==8 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 5, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 6, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 7, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 8, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
else if( isect==9 )
{
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 1, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 2, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 3, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
g1_ = MEEEGeom::getGraphBoundary( MEEEGeom::iLMModule, 4, iz, 2 );
g1_->SetLineWidth(1); g1_->Draw("LSame");
}
TGraph* g_ = MEEEGeom::getGraphBoundary( MEEEGeom::iSector, ii, iz );
for( int jj=0; jj<g_->GetN(); jj++ )
{
double x,y;
g_->GetPoint( jj, x, y );
g_->SetPoint( jj, x, iz*y );
}
g_->SetLineWidth(2);
g_->Draw("LSame");
}
|
ec80825d7d1ebb8d40941bee90a64b4c08b8864e | 6f5962b952bd9c5ca6bbe5fb0704b0ae28c812ee | /cmon/src/cmon_climate_sampler.h | 08461e7dc7d4d290eba961428ebe749c12854d7a | [] | no_license | emwhbr/caramon | 75573ff67aa16c1af0868ca6073180f0f84bd1d9 | a2eb782fafc0ada3c1f33ae374d3e3cfa300e57c | refs/heads/master | 2021-01-10T12:35:42.944635 | 2017-03-05T12:29:15 | 2017-03-05T12:29:15 | 49,129,255 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,510 | h | cmon_climate_sampler.h | // ************************************************************************
// * *
// * Copyright (C) 2015 Bonden i Nol (hakanbrolin@hotmail.com) *
// * *
// * 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. *
// * *
// ************************************************************************
#ifndef __CMON_CLIMATE_SAMPLER_H__
#define __CMON_CLIMATE_SAMPLER_H__
#include <stdint.h>
#include <string>
#include "cmon_int_sensor.h"
#include "cmon_ext_sensor.h"
#include "cmon_climate_data_queue.h"
#include "thread.h"
#include "item_stats.h"
using namespace std;
/////////////////////////////////////////////////////////////////////////////
// Definitions of macros
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Class support types
/////////////////////////////////////////////////////////////////////////////
typedef struct {
int sensor_error_cnt;
bool sensor_permanent_fault;
item_stats<float> temperature_stats;
item_stats<float> humidity_stats;
} CMON_INTERNAL_CLIMATE;
typedef struct {
int sensor_error_cnt;
bool sensor_permanent_fault;
item_stats<float> temperature_stats;
} CMON_EXTERNAL_CLIMATE;
/////////////////////////////////////////////////////////////////////////////
// Definition of classes
/////////////////////////////////////////////////////////////////////////////
class cmon_climate_sampler : public thread {
public:
cmon_climate_sampler(string thread_name,
uint32_t cpu_affinity_mask,
int rt_priority,
cmon_climate_data_queue *climate_data_queue,
bool verbose);
~cmon_climate_sampler(void);
void shutdown(void);
protected:
virtual long setup(void); // Implements pure virtual functions from base class
virtual long cleanup(void); // Implements pure virtual functions from base class
virtual long execute(void *arg); // Implements pure virtual functions from base class
private:
bool m_verbose;
// Controlled shutdown
bool m_shutdown_requested;
// QUEUE PRODUCER CONSUMER
// Data queue Internal thread External thread
cmon_climate_data_queue *m_climate_data_queue;
// Internal climate
CMON_INTERNAL_CLIMATE m_internal_climate;
// External climate
CMON_EXTERNAL_CLIMATE m_external_climate[CMON_EXT_MAX_SENSORS];
void initialize_climate_sampler(void);
void finalize_climate_sampler(void);
void handle_climate_sampler(void);
// Support functions for the internal thread
void sample_internal_climate(float &temperature,
float &humidity,
bool &sensor_error);
void sample_external_climate(CMON_EXT_SENSOR sensor,
float &temperature,
bool &sensor_error);
void allocate_climate_data(cmon_climate_data **climate_data);
void create_climate_data(cmon_climate_data *climate_data);
};
#endif // __CMON_CLIMATE_SAMPLER_H__
|
70cfd98a3732ef5a0d50fc952314bcd11c44f235 | 635c344550534c100e0a86ab318905734c95390d | /hal/src/main/native/athena/Accelerometer.cpp | b8cc832afe0c38d0c09dd7e3447ce13cb6fdaa2c | [
"BSD-3-Clause"
] | permissive | wpilibsuite/allwpilib | 2435cd2f5c16fb5431afe158a5b8fd84da62da24 | 8f3d6a1d4b1713693abc888ded06023cab3cab3a | refs/heads/main | 2023-08-23T21:04:26.896972 | 2023-08-23T17:47:32 | 2023-08-23T17:47:32 | 24,655,143 | 986 | 769 | NOASSERTION | 2023-09-14T03:51:22 | 2014-09-30T20:51:33 | C++ | UTF-8 | C++ | false | false | 6,367 | cpp | Accelerometer.cpp | // Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/Accelerometer.h"
#include <stdint.h>
#include <cassert>
#include <cstdio>
#include <memory>
#include "HALInitializer.h"
#include "hal/ChipObject.h"
#include "hal/HAL.h"
using namespace hal;
// The 7-bit I2C address with a 0 "send" bit
static constexpr uint8_t kSendAddress = (0x1c << 1) | 0;
// The 7-bit I2C address with a 1 "receive" bit
static constexpr uint8_t kReceiveAddress = (0x1c << 1) | 1;
static constexpr uint8_t kControlTxRx = 1;
static constexpr uint8_t kControlStart = 2;
static constexpr uint8_t kControlStop = 4;
static std::unique_ptr<tAccel> accel;
static HAL_AccelerometerRange accelerometerRange;
// Register addresses
enum Register {
kReg_Status = 0x00,
kReg_OutXMSB = 0x01,
kReg_OutXLSB = 0x02,
kReg_OutYMSB = 0x03,
kReg_OutYLSB = 0x04,
kReg_OutZMSB = 0x05,
kReg_OutZLSB = 0x06,
kReg_Sysmod = 0x0B,
kReg_IntSource = 0x0C,
kReg_WhoAmI = 0x0D,
kReg_XYZDataCfg = 0x0E,
kReg_HPFilterCutoff = 0x0F,
kReg_PLStatus = 0x10,
kReg_PLCfg = 0x11,
kReg_PLCount = 0x12,
kReg_PLBfZcomp = 0x13,
kReg_PLThsReg = 0x14,
kReg_FFMtCfg = 0x15,
kReg_FFMtSrc = 0x16,
kReg_FFMtThs = 0x17,
kReg_FFMtCount = 0x18,
kReg_TransientCfg = 0x1D,
kReg_TransientSrc = 0x1E,
kReg_TransientThs = 0x1F,
kReg_TransientCount = 0x20,
kReg_PulseCfg = 0x21,
kReg_PulseSrc = 0x22,
kReg_PulseThsx = 0x23,
kReg_PulseThsy = 0x24,
kReg_PulseThsz = 0x25,
kReg_PulseTmlt = 0x26,
kReg_PulseLtcy = 0x27,
kReg_PulseWind = 0x28,
kReg_ASlpCount = 0x29,
kReg_CtrlReg1 = 0x2A,
kReg_CtrlReg2 = 0x2B,
kReg_CtrlReg3 = 0x2C,
kReg_CtrlReg4 = 0x2D,
kReg_CtrlReg5 = 0x2E,
kReg_OffX = 0x2F,
kReg_OffY = 0x30,
kReg_OffZ = 0x31
};
namespace hal::init {
void InitializeAccelerometer() {}
} // namespace hal::init
namespace hal {
static void writeRegister(Register reg, uint8_t data);
static uint8_t readRegister(Register reg);
/**
* Initialize the accelerometer.
*/
static void initializeAccelerometer() {
hal::init::CheckInit();
int32_t status = 0;
if (!accel) {
accel.reset(tAccel::create(&status));
accelerometerRange = HAL_AccelerometerRange::HAL_AccelerometerRange_k2G;
// Enable I2C
accel->writeCNFG(1, &status);
// Set the counter to 100 kbps
accel->writeCNTR(213, &status);
// The device identification number should be 0x2a
assert(readRegister(kReg_WhoAmI) == 0x2a);
}
}
static void writeRegister(Register reg, uint8_t data) {
int32_t status = 0;
uint64_t initialTime;
accel->writeADDR(kSendAddress, &status);
// Send a start transmit/receive message with the register address
accel->writeCNTL(kControlStart | kControlTxRx, &status);
accel->writeDATO(reg, &status);
accel->strobeGO(&status);
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
// Send a stop transmit/receive message with the data
accel->writeCNTL(kControlStop | kControlTxRx, &status);
accel->writeDATO(data, &status);
accel->strobeGO(&status);
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
}
static uint8_t readRegister(Register reg) {
int32_t status = 0;
uint64_t initialTime;
// Send a start transmit/receive message with the register address
accel->writeADDR(kSendAddress, &status);
accel->writeCNTL(kControlStart | kControlTxRx, &status);
accel->writeDATO(reg, &status);
accel->strobeGO(&status);
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
// Receive a message with the data and stop
accel->writeADDR(kReceiveAddress, &status);
accel->writeCNTL(kControlStart | kControlStop | kControlTxRx, &status);
accel->strobeGO(&status);
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
return accel->readDATI(&status);
}
/**
* Convert a 12-bit raw acceleration value into a scaled double in units of
* 1 g-force, taking into account the accelerometer range.
*/
static double unpackAxis(int16_t raw) {
// The raw value is actually 12 bits, not 16, so we need to propagate the
// 2's complement sign bit to the unused 4 bits for this to work with
// negative numbers.
raw <<= 4;
raw >>= 4;
switch (accelerometerRange) {
case HAL_AccelerometerRange_k2G:
return raw / 1024.0;
case HAL_AccelerometerRange_k4G:
return raw / 512.0;
case HAL_AccelerometerRange_k8G:
return raw / 256.0;
default:
return 0.0;
}
}
} // namespace hal
extern "C" {
void HAL_SetAccelerometerActive(HAL_Bool active) {
initializeAccelerometer();
uint8_t ctrlReg1 = readRegister(kReg_CtrlReg1);
ctrlReg1 &= ~1; // Clear the existing active bit
writeRegister(kReg_CtrlReg1, ctrlReg1 | (active ? 1 : 0));
}
void HAL_SetAccelerometerRange(HAL_AccelerometerRange range) {
initializeAccelerometer();
accelerometerRange = range;
uint8_t xyzDataCfg = readRegister(kReg_XYZDataCfg);
xyzDataCfg &= ~3; // Clear the existing two range bits
writeRegister(kReg_XYZDataCfg, xyzDataCfg | range);
}
double HAL_GetAccelerometerX(void) {
initializeAccelerometer();
int32_t raw =
(readRegister(kReg_OutXMSB) << 4) | (readRegister(kReg_OutXLSB) >> 4);
return unpackAxis(raw);
}
double HAL_GetAccelerometerY(void) {
initializeAccelerometer();
int32_t raw =
(readRegister(kReg_OutYMSB) << 4) | (readRegister(kReg_OutYLSB) >> 4);
return unpackAxis(raw);
}
double HAL_GetAccelerometerZ(void) {
initializeAccelerometer();
int32_t raw =
(readRegister(kReg_OutZMSB) << 4) | (readRegister(kReg_OutZLSB) >> 4);
return unpackAxis(raw);
}
} // extern "C"
|
e0ea7a9e5147cbeba575ae8e9e42a251c25700d5 | bbf39c52eb74c195afd2185cfa14699ad5deb25c | /src/sim3.cpp | f7b9ba279099d2243cac712609ea4e04fa0377b2 | [
"BSD-2-Clause"
] | permissive | pangfumin/liegroups | ebd03b4e5663a3a330a13c7d6d4d28cc9a0989ec | 8a72700457e35d083f7de4f9ca9b51f7d23980c0 | refs/heads/master | 2021-01-20T17:49:56.625387 | 2017-05-10T17:40:21 | 2017-05-10T17:40:21 | 90,891,874 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,728 | cpp | sim3.cpp | #include <liegroups/sim3.hpp>
#include <liegroups/scalar.hpp>
#include <liegroups/matrix.hpp>
#include <liegroups/exp_coefs.hpp>
#include <liegroups/exp_helpers.hpp>
#include <cmath>
#include <iostream>
template <> const liegroups::Sim3<float>
liegroups::Sim3<float>::identity = { liegroups::SE3<float>::identity, 1.0f, 1.0f };
template <> const liegroups::Sim3<double>
liegroups::Sim3<double>::identity = { liegroups::SE3<double>::identity, 1.0, 1.0 };
template <class S>
void liegroups::multiply(Sim3<S> &ab, const Sim3<S> &a, const Sim3<S> &b)
{
multiply(ab.rigid, a.rigid, b.rigid);
S tf = b.inv_scale - (S)1;
ab.rigid.t[0] += tf*a.rigid.t[0];
ab.rigid.t[1] += tf*a.rigid.t[1];
ab.rigid.t[2] += tf*a.rigid.t[2];
ab.scale = a.scale * b.scale;
ab.inv_scale = a.inv_scale * b.inv_scale;
}
template void liegroups::multiply<float>(Sim3<float>&, const Sim3<float>&, const Sim3<float> &);
template void liegroups::multiply<double>(Sim3<double>&, const Sim3<double>&, const Sim3<double> &);
template <class S>
void liegroups::multiply_a_binv(Sim3<S> &abinv, const Sim3<S> &a, const Sim3<S> &b)
{
multiply_a_binv(abinv.rigid, a.rigid, b.rigid);
abinv.rigid.t[0] *= b.scale;
abinv.rigid.t[1] *= b.scale;
abinv.rigid.t[2] *= b.scale;
abinv.scale = a.scale * b.inv_scale;
abinv.inv_scale = a.inv_scale * b.scale;
}
template void liegroups::multiply_a_binv<float>(Sim3<float>&, const Sim3<float>&, const Sim3<float> &);
template void liegroups::multiply_a_binv<double>(Sim3<double>&, const Sim3<double>&, const Sim3<double> &);
template <class S>
void liegroups::invert(Sim3<S> &g)
{
invert(g.rigid);
S s = g.scale;
g.rigid.t[0] *= s;
g.rigid.t[1] *= s;
g.rigid.t[2] *= s;
g.scale = g.inv_scale;
g.inv_scale = s;
}
template void liegroups::invert<float>(Sim3<float>&);
template void liegroups::invert<double>(Sim3<double>&);
template <class S>
void liegroups::rectify(Sim3<S> &g)
{
rectify(g.rigid);
g.inv_scale = (S)1 / g.scale;
}
template void liegroups::rectify<float>(Sim3<float>&);
template void liegroups::rectify<double>(Sim3<double>&);
template <class S, class X>
void liegroups::transform_point(X y[3], const Sim3<S> &g, const X x[3])
{
transform_point(y, g.rigid, x);
y[0] *= g.scale;
y[1] *= g.scale;
y[2] *= g.scale;
}
template void liegroups::transform_point<float,float>(float[3], const Sim3<float> &, const float[3]);
template void liegroups::transform_point<double,double>(double[3], const Sim3<double> &, const double[3]);
template void liegroups::transform_point<double,float>(float[3], const Sim3<double> &, const float[3]);
template void liegroups::transform_point<float,double>(double[3], const Sim3<float> &, const double[3]);
template <class S, class X>
void liegroups::transform_point_by_inverse(X y[3], const Sim3<S> &g, const X x[3])
{
y[0] = g.inv_scale * x[0];
y[1] = g.inv_scale * x[1];
y[2] = g.inv_scale * x[2];
transform_point_by_inverse(y, g.rigid, y);
}
template void liegroups::transform_point_by_inverse<float,float>(float[3], const Sim3<float> &, const float[3]);
template void liegroups::transform_point_by_inverse<double,double>(double[3], const Sim3<double> &, const double[3]);
template void liegroups::transform_point_by_inverse<double,float>(float[3], const Sim3<double> &, const float[3]);
template void liegroups::transform_point_by_inverse<float,double>(double[3], const Sim3<float> &, const double[3]);
template <class S>
static void compute_V(S &a, S &b, S theta, S lambda, S ct, S st, S exp_lambda)
{
S theta_sq = theta * theta;
S lambda_sq = lambda * lambda;
S z = theta_sq + lambda_sq;
if (z < liegroups::Constants<S>::sqrt_epsilon()) {
a = (S)1 - (S)0.5*lambda + (lambda_sq - theta_sq)*(S)(1.0/6);
b = theta*((S)0.5 - lambda*(S)(1.0/6));
} else {
S inv_s = (S)1 / exp_lambda;
S inv_z = (S)1 / z;
a = inv_z*(lambda*ct + theta*st - lambda*inv_s);
b = inv_z*(lambda*st - theta*ct + theta*inv_s);
}
}
template <typename S>
static void cross(S axb[3], const S a[3], const S b[3])
{
const S b0 = b[0];
const S b1 = b[1];
const S b2 = b[2];
axb[0] = a[1]*b2 - a[2]*b1;
axb[1] = a[2]*b0 - a[0]*b2;
axb[2] = a[0]*b1 - a[1]*b0;
}
template <typename S>
static void compute_exp_coefs(S &Xc, S &Yc, S &Zc,
S theta_sq, const liegroups::ExpCoefs<S> &coefs,
S lambda, S exp_neg_lambda)
{
using namespace liegroups;
const S lambda_sq = lambda * lambda;
S D, alpha;
if (theta_sq < Constants<S>::sqrt_epsilon()) {
D = (S)(1.0/24) * (1 - theta_sq * (S)(1.0/30) * (1 - theta_sq * (S)(1.0/56)));
if (lambda_sq > theta_sq) {
alpha = lambda_sq / (lambda_sq + theta_sq);
} else {
alpha = 0;
}
} else {
D = ((S)0.5 - coefs.B) / theta_sq;
alpha = lambda_sq / (lambda_sq + theta_sq);
}
S beta, gamma;
if (lambda_sq < Constants<S>::sqrt_epsilon()) {
gamma = (S)(1.0/6) * (1 - lambda * (S)(0.25) * (1 - lambda * (S)(0.2) * (1 - lambda*(S)(1.0/6))));
beta = (S)0.5 - lambda * gamma;
Xc = 1 - lambda * beta;
} else {
const S inv_lambda = (S)1 / lambda;
Xc = ((S)1 - exp_neg_lambda) * inv_lambda;
beta = ((S)1 - Xc) * inv_lambda;
gamma = ((S)0.5 - beta) * inv_lambda;
}
Yc = alpha * beta + (1 - alpha) * (coefs.B - lambda * coefs.C);
Zc = alpha * gamma + (1 - alpha) * (coefs.C - lambda * D);
}
template <class S>
void liegroups::exp(Sim3<S> &X, const S uwl[7])
{
const S *w = &uwl[3];
const S lambda = uwl[6];
const S theta_sq = w[0]*w[0] + w[1]*w[1] + w[2]*w[2];
const ExpCoefs<S> coefs(theta_sq);
compute_exp_matrix3(X.rigid.R.R, coefs.cos_theta, coefs.A, coefs.B, w);
X.scale = liegroups::exp(lambda);
X.inv_scale = (S)1 / X.scale;
S Xc, Yc, Zc;
compute_exp_coefs(Xc, Yc, Zc, theta_sq, coefs, lambda, X.inv_scale);
S wxu[3], wxwxu[3];
cross(wxu, w, uwl);
cross(wxwxu, w, wxu);
for (int i=0; i<3; ++i)
X.rigid.t[i] = Xc * uwl[i] + Yc * wxu[i] + Zc * wxwxu[i];
}
template void liegroups::exp<float>(Sim3<float> &, const float[7]);
template void liegroups::exp<double>(Sim3<double> &, const double[7]);
template <class S>
void liegroups::log(S uwl[7], const Sim3<S> &X)
{
uwl[6] = liegroups::ln(X.scale);
S *w = &uwl[3];
log(w, X.rigid.R);
const S theta_sq = w[0]*w[0] + w[1]*w[1] + w[2]*w[2];
const ExpCoefs<S> coefs(theta_sq);
S Xc, Yc, Zc;
compute_exp_coefs(Xc, Yc, Zc, theta_sq, coefs, uwl[6], X.inv_scale);
S V[3*3];
compute_exp_matrix3(V, Xc - theta_sq*Zc, Yc, Zc, w);
const S *const t = X.rigid.t;
invert<3>(V, V);
for (int i=0; i<3; ++i)
uwl[i] = V[i*3]*t[0] + V[i*3+1]*t[1] + V[i*3+2]*t[2];
}
template void liegroups::log<float>(float[7], const Sim3<float> &);
template void liegroups::log<double>(double[7], const Sim3<double> &);
template <class S>
void liegroups::adjoint(S adj[7*7], const Sim3<S> &g)
{
const S *const R = g.rigid.R.R;
const S s = g.scale;
const S sx = s * g.rigid.t[0];
const S sy = s * g.rigid.t[1];
const S sz = s * g.rigid.t[2];
for (int i=0; i<3; ++i) {
for (int j=0; j<3; ++j) {
adj[i*7 + j] = s * R[i*3 + j];
adj[(i+3)*7 + j] = 0;
adj[(i+3)*7 + j+3] = R[i*3 + j];
}
adj[3 + i] = sy * R[6 + i] - sz * R[3 + i];
adj[10 + i] = sz * R[i] - sx * R[6 + i];
adj[17 + i] = sx * R[3 + i] - sy * R[i];
adj[(i+3)*7 + 6] = 0;
adj[42 + i] = 0;
adj[45 + i] = 0;
}
adj[6] = -sx;
adj[13] = -sy;
adj[20] = -sz;
adj[48] = 1;
}
template void liegroups::adjoint<float>(float[7*7], const Sim3<float> &);
template void liegroups::adjoint<double>(double[7*7], const Sim3<double> &);
template <class S>
void liegroups::adjoint_multiply(S y[7], const Sim3<S> &g, const S x[7])
{
const S *const R = g.rigid.R.R;
const S *const t = g.rigid.t;
const S s = g.scale;
const S x3 = x[3], x4 = x[4], x5 = x[5];
y[3] = R[0]*x3 + R[1]*x4 + R[2]*x5;
y[4] = R[3]*x3 + R[4]*x4 + R[5]*x5;
y[5] = R[6]*x3 + R[7]*x4 + R[8]*x5;
const S x0 = x[0], x1 = x[1], x2 = x[2];
y[0] = s * (R[0]*x0 + R[1]*x1 + R[2]*x2 + t[1]*y[5] - t[2]*y[4] - t[0]*x[6]);
y[1] = s * (R[3]*x0 + R[4]*x1 + R[5]*x2 + t[2]*y[3] - t[0]*y[5] - t[1]*x[6]);
y[2] = s * (R[6]*x0 + R[7]*x1 + R[8]*x2 + t[0]*y[4] - t[1]*y[3] - t[2]*x[6]);
y[6] = x[6];
}
template void liegroups::adjoint_multiply<float>(float[7], const Sim3<float> &, const float[7]);
template void liegroups::adjoint_multiply<double>(double[7], const Sim3<double> &, const double[7]);
template <class S>
void liegroups::adjoint_T_multiply(S y[7], const Sim3<S> &g, const S x[7])
{
const S *const R = g.rigid.R.R;
const S *const t = g.rigid.t;
const S s = g.scale;
const S sx0 = s*x[0], sx1 = s*x[1], sx2 = s*x[2];
y[0] = R[0]*sx0 + R[3]*sx1 + R[6]*sx2;
y[1] = R[1]*sx0 + R[4]*sx1 + R[7]*sx2;
y[2] = R[2]*sx0 + R[5]*sx1 + R[8]*sx2;
const S a = x[3] - (t[1]*sx2 - t[2]*sx1);
const S b = x[4] - (t[2]*sx0 - t[0]*sx2);
const S c = x[5] - (t[0]*sx1 - t[1]*sx0);
y[3] = R[0]*a + R[3]*b + R[6]*c;
y[4] = R[1]*a + R[4]*b + R[7]*c;
y[5] = R[2]*a + R[5]*b + R[8]*c;
y[6] = x[6] - (t[0]*sx0 + t[1]*sx1 + t[2]*sx2);
}
template void liegroups::adjoint_T_multiply<float>(float[7], const Sim3<float> &, const float[7]);
template void liegroups::adjoint_T_multiply<double>(double[7], const Sim3<double> &, const double[7]);
|
29610e19170e3cf9e2f3ff62c83c308d64f3a5d0 | 4e8ea46eb44e93069b53cdfc3c0ffc57a7e226a1 | /nonbPotDetector.cpp | 1c459d4de19ccd63bb2dbd25476a3eaa03c6b2f8 | [] | no_license | srcfind/srcfind | ebe5492e367792201f607e8f1e65f35d7922194b | 81945f63b3ce0f0b6fdad27fa0e2a0f79845a3e6 | refs/heads/master | 2020-08-06T22:29:54.982126 | 2019-10-06T14:49:37 | 2019-10-06T14:49:37 | 213,182,073 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,618 | cpp | nonbPotDetector.cpp | //
// Created by ttbond on 18-12-1.
//
#ifndef SRCFIND_NONBPOTDETECTOR_CPP
#define SRCFIND_NONBPOTDETECTOR_CPP
#include "nonbPotDetector.h"
nonbPotDetector::nonbPotDetector(char *bedFileName,char *agct){
bedF=new bedFile(bedFileName,agct);
maxSep=7;
}
nonbPotDetector::~nonbPotDetector(){
if(bedF!=NULL){
delete bedF;
}
}
void nonbPotDetector::detect() {
bedF->init();
std::vector<std::vector<basicInfo> >tmpRel;
while(!bedF->atRegionEnd()){
basicInfo nowR=bedF->getNowRegion();
detectRegion region(bedF->getChrAgct(nowR),nowR);
tmpRel=region.getPotDirPos();
}
int tsiz=tmpRel.size();
int jishu=0;
for(int i=0;i<tsiz;i++){
std::vector<basicInfo> &tvec=tmpRel[i];
sort(tvec.begin(),tvec.end());
int siz=tvec.size();
for(int j=0;j<siz;j++){
for(int k=j+1;k<siz;k++){
if(tvec[j].ed>=tvec[k].st){
continue;
}
if(tvec[k].st-tvec[j].ed>=maxSep){
break;
}
jishu=jishu+1;
std::vector<basicInfo> toConsNonb;
toConsNonb.push_back(tvec[j]);
toConsNonb.push_back(tvec[k]);
nonB tmpNonb(toConsNonb,bedF->getChrAgct(toConsNonb[0]),DIRREP);
if(tmpNonb.getMisNum()!=1||tmpNonb.isBrinkDiverge()){
continue;
}
detectRel.push_back(tmpNonb);
}
}
}
sort(detectRel.begin(),detectRel.end());
std::vector<nonB>:: iterator it;
it=unique(detectRel.begin(),detectRel.end());
while(detectRel.end()!=it){
detectRel.pop_back();
}
printf("after unique:%d\n",detectRel.size());
puts("finish");
}
void nonbPotDetector::printF(const char *fileName){
int siz=detectRel.size();
FILE *relF=fopen(fileName,"w");
for(int i=0;i<siz;i++){
detectRel[i].printMe(relF);
fprintf(relF,"\n");
}
fclose(relF);
}
void nonbPotDetector::printF_point(const char *fileName){
std::vector<basicInfo> tmp;
int siz=detectRel.size();
for(int i=0;i<siz;i++){
tmp.insert(tmp.end(),detectRel[i].misMachPoint.begin(),detectRel[i].misMachPoint.end());
}
sort(tmp.begin(),tmp.end());
std::vector<basicInfo>::iterator it;
it=unique(tmp.begin(),tmp.end());
while(tmp.end()!=it){
tmp.pop_back();
}
FILE *fp=fopen(fileName,"w");
siz=tmp.size();
for(int i=0;i<siz;i++){
tmp[i].printMe(fp);
fprintf(fp,"\n");
}
fclose(fp);
}
#endif |
f07529a14a12f7567e7041fb0899c1407290b37f | 188fb8ded33ad7a2f52f69975006bb38917437ef | /Fluid/processor2/0.62/U | 7890c8a22921143385e4bc2544d78e71b064452a | [] | no_license | abarcaortega/Tuto_2 | 34a4721f14725c20471ff2dc8d22b52638b8a2b3 | 4a84c22efbb9cd2eaeda92883343b6910e0941e2 | refs/heads/master | 2020-08-05T16:11:57.674940 | 2019-10-04T09:56:09 | 2019-10-04T09:56:09 | 212,573,883 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,035 | U | /*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0.62";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField nonuniform List<vector>
465
(
(5.47895 6.60219e-21 6.78642)
(5.69202 1.35954e-18 6.4421)
(6.48694 -9.36897e-20 6.43807)
(6.76025 -8.54966e-19 6.14789)
(6.99635 -5.85857e-20 5.76425)
(7.19697 6.17557e-19 5.2898)
(7.46194 0 6.03497)
(7.76084 0 5.79456)
(8.03622 -8.48101e-19 5.45708)
(8.28095 -6.02849e-20 5.02591)
(8.49045 0 4.50529)
(8.57447 0 5.6346)
(8.81199 0 5.41622)
(9.06536 1.7437e-18 5.11392)
(9.3113 6.17953e-20 4.72387)
(9.53448 -1.26981e-19 4.24704)
(9.72374 1.34737e-19 3.68761)
(9.86945 -6.88752e-20 3.0535)
(10.1109 -8.81974e-20 5.36377)
(10.1697 1.84545e-19 5.10388)
(10.3007 -1.7232e-18 4.79575)
(10.4682 8.62216e-19 4.4227)
(10.6449 9.26064e-19 3.97723)
(10.8097 -6.4806e-20 3.45878)
(10.946 1.02733e-18 2.87259)
(11.0406 -1.05194e-18 2.22958)
(11.0842 0 1.54645)
(12.1763 0 5.31312)
(12.0295 9.00049e-20 4.95912)
(11.9804 1.5078e-18 4.59373)
(12.0024 -1.04441e-18 4.195)
(12.0686 -6.83106e-19 3.74859)
(12.1551 7.53953e-21 3.24766)
(12.2415 -1.12162e-18 2.69207)
(12.3116 0 2.08764)
(12.355 0 1.44504)
(12.3689 1.08444e-18 0.777025)
(14.4935 6.0932e-20 5.42015)
(14.2456 0 4.97509)
(14.0739 -1.34944e-18 4.53543)
(13.9711 0 4.08354)
(13.924 -1.03972e-19 3.60534)
(13.9168 -7.18494e-19 3.09162)
(13.9337 0 2.53829)
(13.9613 -8.96524e-19 1.94601)
(13.9902 0 1.31888)
(14.0172 -8.65702e-19 0.661758)
(14.0466 -1.19236e-19 -0.0237839)
(14.0893 -1.08053e-18 -0.743274)
(16.6468 1.06541e-20 5.55083)
(16.4317 -1.30938e-19 5.05065)
(16.2525 1.25149e-18 4.55482)
(16.115 -8.63064e-20 4.05258)
(16.0194 8.52001e-20 3.53393)
(15.9608 1.52135e-18 2.99108)
(15.9323 1.03091e-19 2.41918)
(15.9265 7.14993e-20 1.81626)
(15.9375 7.1567e-19 1.18241)
(15.9619 1.08643e-19 0.517879)
(15.9988 -1.07694e-19 -0.178949)
(16.0484 0 -0.911182)
(16.0985 9.86467e-20 -1.67184)
(18.3505 4.99841e-20 5.60558)
(18.2531 -4.99061e-19 5.08913)
(18.1553 -2.18321e-20 4.56699)
(18.0684 7.44853e-20 4.03431)
(17.999 -6.51067e-19 3.48561)
(17.9496 -7.03522e-19 2.91602)
(17.92 0 2.32202)
(17.9079 8.67233e-19 1.70161)
(17.9101 -8.86504e-19 1.05396)
(17.9228 0 0.378724)
(17.9413 0 -0.324306)
(17.9574 0 -1.05311)
(17.9473 0 -1.79449)
(17.8987 8.01122e-20 -2.52949)
(17.7939 -7.13015e-19 -3.23717)
(19.5034 -2.78639e-20 5.54007)
(19.5491 3.81269e-19 5.03821)
(19.5705 -4.47779e-19 4.51815)
(19.5783 0 3.97924)
(19.5802 5.61279e-19 3.41977)
(19.5813 -7.36325e-20 2.83791)
(19.5841 -4.87425e-19 2.23233)
(19.5888 -8.10189e-20 1.60257)
(19.5934 -5.30945e-19 0.949124)
(19.5938 6.21788e-19 0.27349)
(19.5829 5.39115e-19 -0.421067)
(19.5508 8.17676e-20 -1.12788)
(19.4721 6.55824e-19 -1.83293)
(19.3419 -7.39361e-20 -2.52002)
(19.1481 -4.91028e-19 -3.17106)
(18.8811 4.90877e-19 -3.76647)
(20.1373 -9.09167e-20 5.35214)
(20.3108 2.57121e-20 4.88502)
(20.4479 -1.32071e-19 4.38893)
(20.5558 0 3.86571)
(20.6404 0 3.31625)
(20.706 4.19195e-19 2.74119)
(20.7549 5.45883e-19 2.14144)
(20.7875 0 1.51864)
(20.8019 5.24666e-19 0.87542)
(20.794 -9.83681e-19 0.215859)
(20.7566 -1.12473e-18 -0.453669)
(20.6817 -6.93351e-20 -1.12368)
(20.5492 -5.64893e-19 -1.78193)
(20.3566 0 -2.4153)
(20.0978 9.46231e-19 -3.00876)
(19.7678 -5.20673e-20 -3.54589)
(19.3663 -1.90222e-20 -4.01)
(18.8979 -5.59801e-19 -4.38493)
(20.3557 3.51691e-20 5.06542)
(20.6211 0 4.64294)
(20.8472 1.29861e-19 4.1847)
(21.0368 0 3.69346)
(21.1928 2.36047e-19 3.17153)
(21.317 -3.68112e-19 2.62121)
(21.4101 0 2.04522)
(21.4715 0 1.44701)
(21.499 5.75365e-20 0.831143)
(21.4887 4.49746e-19 0.203685)
(21.4347 8.17381e-20 -0.427163)
(21.3316 0 -1.05078)
(21.1674 0 -1.65703)
(20.9392 0 -2.23508)
(20.645 -4.05533e-19 -2.77282)
(20.2837 0 -3.25661)
(19.8578 -2.60352e-19 -3.67278)
(19.3734 0 -4.00834)
(18.8405 -3.65271e-19 -4.25172)
(20.2847 3.61631e-20 4.71458)
(20.6022 4.66591e-21 4.33872)
(20.883 0 3.92465)
(21.1263 0 3.47499)
(21.3316 -2.75049e-19 2.99252)
(21.4983 0 2.48041)
(21.6252 -3.51566e-19 1.94243)
(21.7104 -7.37241e-21 1.38319)
(21.7512 4.05622e-20 0.808386)
(21.744 4.54339e-20 0.225124)
(21.6847 3.70026e-19 -0.357857)
(21.5698 -2.46173e-19 -0.930128)
(21.3944 -4.56667e-20 -1.48292)
(21.1549 -3.09115e-19 -2.00669)
(20.8522 2.4627e-19 -2.49196)
(20.4876 2.87546e-19 -2.92756)
(20.065 2.28553e-19 -3.30216)
(19.5912 -3.2191e-19 -3.60515)
(19.0759 0 -3.82727)
(18.5371 0 -3.9612)
(20.0408 -6.23482e-20 4.33343)
(20.3767 0 4.00147)
(20.6809 0 3.63221)
(20.9501 -3.02968e-21 3.22778)
(21.1815 2.63982e-20 2.79087)
(21.3725 1.56289e-19 2.32479)
(21.5203 3.26526e-19 1.83364)
(21.6219 -5.95998e-20 1.32241)
(21.6744 -7.12822e-20 0.797166)
(21.6745 -3.68588e-21 0.265163)
(21.6192 7.30589e-20 -0.265175)
(21.5063 3.32421e-19 -0.784395)
(21.3349 -3.55866e-20 -1.28385)
(21.1031 5.8658e-19 -1.75652)
(20.8119 -4.95311e-20 -2.19342)
(20.4643 -2.46801e-19 -2.58565)
(20.0647 0 -2.92383)
(19.62 3.41488e-19 -3.19919)
(19.1391 2.20215e-19 -3.40415)
(18.6373 1.3296e-19 -3.53282)
(17.9792 1.7544e-21 -3.58313)
(19.7118 6.14094e-20 3.94744)
(20.0434 2.38119e-20 3.65491)
(20.3483 0 3.32801)
(20.6222 2.03783e-20 2.96837)
(20.861 -4.31393e-20 2.57834)
(21.0609 -7.61228e-20 2.16095)
(21.2182 -1.55217e-19 1.72011)
(21.3293 0 1.26067)
(21.3909 -5.30268e-20 0.78846)
(21.4002 5.22572e-20 0.310268)
(21.3549 1.417e-19 -0.16627)
(21.2535 2.60948e-19 -0.632928)
(21.096 1.74463e-19 -1.08154)
(20.884 -2.16213e-19 -1.50618)
(20.6168 -2.24508e-19 -1.89862)
(20.2984 -2.10939e-20 -2.25162)
(19.9334 2.07552e-20 -2.55734)
(19.5281 0 -2.80838)
(19.0906 -3.78445e-19 -2.99841)
(18.6335 -1.41272e-19 -3.12252)
(18.0344 -1.45254e-21 -3.17883)
(19.3543 0 3.57188)
(19.6695 7.30158e-20 3.31434)
(19.9621 1.20935e-20 3.02622)
(20.2276 -1.26675e-20 2.70874)
(20.4617 -8.51706e-21 2.36383)
(20.66 -1.96995e-20 1.99416)
(20.8186 1.51091e-19 1.60323)
(20.9336 0 1.19541)
(21.0019 0 0.775898)
(21.0206 1.71412e-19 0.350714)
(20.988 -2.36392e-19 -0.0734726)
(20.9031 -2.00442e-19 -0.489577)
(20.766 -9.00441e-20 -0.890434)
(20.5785 -1.06026e-19 -1.27002)
(20.3416 0 -1.62173)
(20.0579 0 -1.93886)
(19.7321 -1.10078e-19 -2.21497)
(19.37 1.81308e-19 -2.44378)
(18.9785 1.70072e-19 -2.61982)
(18.5683 -9.14997e-20 -2.73891)
(18.0299 -1.18662e-21 -2.79906)
(18.9999 4.91263e-20 3.21365)
(19.294 -6.22986e-20 2.98734)
(19.5687 6.04039e-20 2.73433)
(19.8197 -2.41975e-20 2.45557)
(20.0429 0 2.15264)
(20.2339 -2.02279e-20 1.82782)
(20.389 -2.94556e-20 1.48414)
(20.5046 0 1.12533)
(20.5774 8.61281e-20 0.755832)
(20.6049 -4.33662e-20 0.380828)
(20.5855 -1.22048e-19 0.00604242)
(20.5183 -3.1646e-20 -0.362447)
(20.4033 -1.17895e-19 -0.718447)
(20.2416 1.76679e-19 -1.05595)
(20.0363 -1.34821e-19 -1.37012)
(19.7882 0 -1.65413)
(19.5018 1.19042e-19 -1.90273)
(19.1823 -1.18552e-19 -2.11056)
(18.8357 -1.07961e-19 -2.2729)
(18.4709 9.07633e-20 -2.38599)
(17.9907 0 -2.44768)
(18.6641 1.95111e-19 2.87447)
(18.9368 -1.5075e-19 2.67631)
(19.1925 8.96695e-20 2.4551)
(19.4273 0 2.21161)
(19.6375 0 1.94712)
(19.8191 1.02477e-20 1.66355)
(19.9687 -2.18012e-20 1.36343)
(20.0829 7.36247e-21 1.0499)
(20.1587 -6.83332e-20 0.726729)
(20.1938 -1.18936e-19 0.398267)
(20.1865 1.12862e-19 0.0693683)
(20.1361 -1.91468e-20 -0.254786)
(20.0425 0 -0.568875)
(19.9065 -2.22674e-20 -0.867627)
(19.7303 1.98583e-19 -1.14623)
(19.5159 0 -1.39943)
(19.2664 0 -1.62209)
(18.9865 -9.49641e-21 -1.80978)
(18.6815 1.01634e-19 -1.95835)
(18.3587 5.42835e-20 -2.06436)
(17.9323 3.07331e-20 -2.12552)
(18.3546 -6.84347e-20 2.55344)
(18.6074 -1.19995e-19 2.38087)
(18.845 -3.48162e-20 2.18856)
(19.0642 -3.41703e-20 1.97713)
(19.2616 3.34764e-20 1.74763)
(19.4336 0 1.50164)
(19.5771 1.54781e-20 1.24127)
(19.689 2.91447e-21 0.969156)
(19.7668 -3.4635e-22 0.688449)
(19.8081 3.60513e-20 0.402758)
(19.8115 -1.03784e-20 0.116142)
(19.7761 2.3031e-20 -0.16701)
(19.7017 2.87039e-20 -0.442134)
(19.589 0 -0.704653)
(19.4393 -8.00926e-20 -0.950008)
(19.2556 7.23681e-21 -1.17425)
(19.0394 6.03483e-21 -1.37228)
(18.7952 -5.74071e-20 -1.54041)
(18.5276 1.8568e-21 -1.67502)
(18.2426 -5.78902e-20 -1.77296)
(17.8648 -2.94456e-20 -1.83195)
(18.0751 -8.26691e-20 2.24875)
(18.3101 6.95829e-20 2.09957)
(18.5317 0 1.93362)
(18.7368 0 1.7514)
(18.9223 0 1.55375)
(19.0853 0 1.34198)
(19.223 4.83999e-20 1.11782)
(19.3325 -1.10909e-20 0.883478)
(19.4115 1.0881e-20 0.641561)
(19.4579 0 0.395065)
(19.4703 0 0.147347)
(19.4478 5.62474e-21 -0.097918)
(19.3903 -4.61149e-20 -0.336849)
(19.298 -1.4141e-20 -0.565489)
(19.1722 1.85447e-20 -0.779914)
(19.0147 -2.87808e-20 -0.976257)
(18.8283 0 -1.15104)
(18.6157 -2.50541e-20 -1.30016)
(18.3812 -2.06571e-20 -1.42069)
(18.1301 -1.52668e-20 -1.50984)
(17.7957 0 -1.56537)
(17.828 -8.72684e-20 1.95805)
(18.0478 -1.27438e-21 1.83037)
(18.2553 -1.23444e-19 1.68857)
(18.4481 5.62243e-20 1.53303)
(18.6233 9.18699e-20 1.36447)
(18.7783 0 1.18392)
(18.9106 -4.7737e-20 0.992818)
(19.0177 0 0.792966)
(19.0974 0 0.586541)
(19.148 2.46495e-20 0.376006)
(19.168 0 0.164099)
(19.1565 3.45404e-22 -0.0461472)
(19.1133 7.01874e-21 -0.251454)
(19.0387 1.70404e-20 -0.448434)
(18.9334 -2.66678e-20 -0.633723)
(18.7992 1.74764e-20 -0.803989)
(18.6382 -2.51366e-21 -0.956078)
(18.4532 7.72298e-21 -1.08688)
(18.2476 3.52971e-20 -1.19334)
(18.026 1.5569e-20 -1.27314)
(17.7298 -6.33146e-22 -1.32416)
(17.6153 0 1.67928)
(17.8221 0 1.57148)
(18.0178 0 1.45193)
(18.2001 0 1.32094)
(18.3665 -9.06568e-20 1.17909)
(18.5147 3.6813e-20 1.02722)
(18.6423 -6.34678e-21 0.866468)
(18.7472 -8.59698e-20 0.698319)
(18.8275 -1.76897e-20 0.524537)
(18.8814 -6.9253e-21 0.347133)
(18.9076 -2.52383e-20 0.168334)
(18.9054 5.23269e-21 -0.00938206)
(18.8743 -1.03476e-20 -0.183296)
(18.8145 2.94606e-21 -0.350564)
(18.7268 5.18681e-21 -0.508325)
(18.6125 1.2336e-20 -0.653767)
(18.4733 -5.30317e-21 -0.78413)
(18.3118 2.13817e-20 -0.896836)
(18.1312 -1.26139e-20 -0.989411)
(17.9351 0 -1.05948)
(17.6717 -5.28671e-21 -1.10514)
(17.4389 -8.52582e-20 1.40939)
(17.6351 8.34046e-20 1.32008)
(17.821 -6.59063e-20 1.22118)
(17.9946 6.44881e-20 1.11294)
(18.1537 0 0.995791)
(18.2962 4.61844e-20 0.87042)
(18.42 0 0.737733)
(18.523 1.20623e-19 0.598899)
(18.6035 0 0.455329)
(18.66 1.70648e-20 0.308626)
(18.6914 4.08234e-20 0.160546)
(18.6969 0 0.013104)
(18.676 -1.79957e-20 -0.131443)
(18.6287 -1.24726e-20 -0.270743)
(18.5557 -3.63906e-21 -0.402433)
(18.4579 -3.31459e-22 -0.524171)
(18.3371 -3.67633e-22 -0.633668)
(18.1955 -5.83613e-21 -0.728711)
(18.0357 0 -0.807195)
(17.8613 -2.92507e-21 -0.867205)
(17.6257 5.29062e-21 -0.906884)
(17.3006 0 1.14747)
(17.4883 -3.89408e-20 1.07557)
(17.6664 3.74323e-21 0.996046)
(17.8331 9.36191e-20 0.909092)
(17.9864 -1.10612e-19 0.815051)
(18.1243 5.2339e-21 0.714439)
(18.245 -3.74074e-20 0.607959)
(18.3466 -2.70215e-20 0.496518)
(18.4276 0 0.381209)
(18.4866 0 0.263238)
(18.5223 -2.41758e-20 0.143967)
(18.534 -7.83523e-21 0.0250584)
(18.5211 -5.54802e-21 -0.0916494)
(18.4839 -8.31801e-21 -0.204309)
(18.4227 3.1648e-21 -0.311046)
(18.3385 1.37513e-21 -0.409966)
(18.2328 2.97258e-21 -0.499214)
(18.1075 2.8375e-21 -0.576988)
(17.965 -2.35962e-21 -0.641568)
(17.8087 2.89634e-21 -0.691309)
(17.5963 2.56301e-21 -0.72457)
(17.2023 9.52809e-20 0.888329)
(17.3835 0 0.832961)
(17.5557 2.29615e-21 0.771791)
(17.7172 6.56074e-20 0.704957)
(17.8662 2.80838e-20 0.632707)
(18.0007 2.33577e-20 0.555418)
(18.1192 -4.27734e-20 0.473604)
(18.2198 -1.77844e-20 0.387923)
(18.3013 -1.39593e-20 0.299183)
(18.3624 5.11183e-20 0.208353)
(18.4016 -1.11863e-20 0.116566)
(18.4179 9.84953e-21 0.0250268)
(18.4114 3.5529e-20 -0.0650322)
(18.382 1.15017e-20 -0.152234)
(18.3302 3.07967e-21 -0.235055)
(18.2567 -3.01324e-21 -0.311969)
(18.163 -7.95112e-21 -0.381519)
(18.0508 2.0453e-21 -0.442305)
(17.9222 2.59943e-21 -0.492953)
(17.7802 -1.70187e-22 -0.53212)
(17.5862 -2.49964e-21 -0.558472)
(17.1456 -9.34522e-20 0.635391)
(17.3225 0 0.595972)
(17.4907 -7.30534e-20 0.552446)
(17.6487 3.51214e-20 0.504903)
(17.7948 -2.79227e-20 0.45351)
(17.9271 -2.5987e-20 0.398516)
(18.0442 4.32446e-20 0.340269)
(18.1444 5.49738e-20 0.279209)
(18.2263 3.26695e-20 0.215921)
(18.2888 -2.56007e-20 0.151186)
(18.3305 -1.00424e-20 0.0858549)
(18.3509 -6.99813e-21 0.0206339)
(18.3496 -2.114e-20 -0.0437603)
(18.3265 -4.42609e-22 -0.106338)
(18.2818 -4.82168e-21 -0.165939)
(18.2166 2.70157e-21 -0.221428)
(18.1319 4.20885e-21 -0.27174)
(18.0294 -4.0967e-21 -0.31584)
(17.9112 3.52426e-21 -0.352703)
(17.78 2.87596e-22 -0.381299)
(17.5997 0 -0.400542)
(17.1312 -2.3866e-20 0.375908)
(17.3058 4.32547e-20 0.352077)
(17.4719 -1.90237e-20 0.325783)
(17.6281 0 0.297077)
(17.7726 -3.06604e-22 0.266053)
(17.9039 1.18604e-20 0.232855)
(18.0204 -3.27558e-20 0.197684)
(18.1204 -4.71566e-20 0.160804)
(18.2028 -5.64254e-20 0.122565)
(18.2662 7.47235e-21 0.0834236)
(18.3097 0 0.0438658)
(18.3328 0 0.00434541)
(18.3347 1.44901e-20 -0.0346667)
(18.3153 8.71138e-21 -0.0726248)
(18.275 2.61683e-21 -0.108912)
(18.2145 -2.07644e-21 -0.142841)
(18.135 -6.73269e-21 -0.173676)
(18.0378 2.90089e-21 -0.200682)
(17.9251 -3.04976e-21 -0.223132)
(17.7994 -9.29125e-22 -0.24025)
(17.6259 -2.09112e-23 -0.251012)
(16.838 2.32483e-20 0.12712)
(17.0065 -2.09675e-20 0.118842)
(17.1663 9.75815e-21 0.109668)
(17.3157 1.68275e-20 0.0996148)
(17.4531 -2.96235e-20 0.0887152)
(17.5769 7.33105e-22 0.0770204)
(17.6853 6.00829e-21 0.0646043)
(17.7769 1.9259e-20 0.0515661)
(17.8502 2.02386e-20 0.0380317)
(17.904 -5.36651e-22 0.0241457)
(17.9372 -3.15915e-21 0.0100777)
(17.9492 0 -0.00395753)
(17.9395 0 -0.0177561)
(17.908 -1.3841e-21 -0.0311615)
(17.8548 1.35175e-21 -0.0440018)
(17.7806 3.53214e-21 -0.0560269)
(17.6866 5.14952e-21 -0.0669321)
(17.5744 -3.53168e-21 -0.0764152)
(17.4463 0 -0.0841871)
(17.3054 9.31746e-22 -0.0899108)
(17.1144 0 -0.0931165)
)
;
boundaryField
{
inlet
{
type fixedValue;
value nonuniform 0();
}
outlet
{
type zeroGradient;
}
flap
{
type movingWallVelocity;
value nonuniform 0();
}
upperWall
{
type noSlip;
}
lowerWall
{
type noSlip;
}
frontAndBack
{
type empty;
}
procBoundary2to1
{
type processor;
value nonuniform List<vector>
17
(
(20.0483 -9.58105e-21 5.44873)
(19.9319 -4.51635e-20 5.04962)
(19.6767 4.83892e-20 4.62641)
(19.3578 9.1168e-20 4.20461)
(19.0209 -1.04854e-19 3.79823)
(18.6904 0 3.41286)
(18.3781 -8.09826e-20 3.0493)
(18.09 8.00258e-20 2.70608)
(17.8293 9.22372e-20 2.38102)
(17.5986 -1.80305e-19 2.0715)
(17.3997 0 1.77526)
(17.2346 0 1.48904)
(17.1052 -1.04326e-19 1.2117)
(17.0138 4.84044e-20 0.93786)
(16.9616 7.72139e-20 0.670685)
(16.9498 -1.08717e-20 0.397267)
(16.6623 -1.281e-20 0.134502)
)
;
}
procBoundary2to4
{
type processor;
value nonuniform List<vector>
11
(
(5.22107 -6.9633e-19 7.04307)
(6.17559 7.25219e-19 6.62962)
(7.15292 0 6.17621)
(8.38897 -7.18813e-20 5.78155)
(10.1674 0 5.60389)
(12.4428 4.93891e-19 5.68408)
(14.8158 -4.7723e-19 5.88928)
(16.8835 -1.13571e-20 6.06463)
(18.4314 -1.1704e-19 6.11874)
(19.4202 1.55158e-20 6.022)
(19.9196 6.94121e-20 5.78688)
)
;
}
procBoundary2to5
{
type processor;
value nonuniform List<vector>
34
(
(4.4021 -4.26183e-19 7.05604)
(4.5401 4.97714e-19 6.6617)
(5.86605 0 6.01324)
(5.86605 0 6.01324)
(6.00549 -5.40564e-20 5.50086)
(7.36246 1.79484e-18 4.72813)
(7.36246 1.79484e-18 4.72813)
(8.66072 0 3.89979)
(8.66072 0 3.89979)
(8.78654 1.23605e-18 3.21651)
(9.96233 -1.14921e-18 2.35761)
(9.96233 -1.14921e-18 2.35761)
(9.9938 -1.1761e-18 1.61983)
(11.0732 0 0.844074)
(11.0732 0 0.844074)
(12.3609 6.50033e-20 0.0931)
(12.3609 6.50033e-20 0.0931)
(12.3482 -6.31815e-20 -0.609424)
(14.155 1.03483e-18 -1.50144)
(14.155 1.03483e-18 -1.50144)
(16.1285 9.65283e-20 -2.44262)
(16.1285 9.65283e-20 -2.44262)
(16.1167 4.07721e-20 -3.20086)
(17.6172 5.05038e-19 -3.89442)
(17.6172 5.05038e-19 -3.89442)
(18.5362 -2.23003e-20 -4.28578)
(18.5362 -2.23003e-20 -4.28578)
(18.1146 -1.25995e-18 -4.70863)
(18.3713 5.5366e-20 -4.65598)
(18.3713 5.5366e-20 -4.65598)
(18.2791 2.49493e-21 -4.39349)
(18.2791 2.49493e-21 -4.39349)
(17.8273 0 -4.00412)
(17.8273 0 -4.00412)
)
;
}
}
// ************************************************************************* //
| |
51de89b2241f4cc5058a3470829959adf0a3d18f | 1f05b964049c83113b2c7e78187dd23ea518a8dd | /FlagGG/Lua/ILua/StackSet.h | d3eacfe22fa4606baae54f3973cd7ba222c289b2 | [] | no_license | flagflag/FlagGG | 36bf363d141e7e110bc39b5632ce32951520fd7f | 9982129c525358e49eef16e2d10ebd64202b7672 | refs/heads/master | 2023-08-21T04:02:17.133863 | 2023-08-12T15:21:57 | 2023-08-12T15:21:57 | 149,803,838 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,183 | h | StackSet.h | #pragma once
#include "Container/Str.h"
#include <lua.hpp>
namespace FlagGG
{
template < class T, class Ignore = void >
struct Setter {};
template <>
struct Setter<bool>
{
static void Set(lua_State* L, bool value)
{
lua_pushboolean(L, value ? 1 : 0);
}
};
template < class T >
struct Setter<T, typename std::enable_if<std::is_enum<T>::value>::type>
{
static void Set(lua_State* L, T value)
{
lua_pushinteger(L, value);
}
};
template < class T >
struct Setter<T, typename std::enable_if<std::is_integral<T>::value>::type>
{
static void Set(lua_State* L, T value)
{
lua_pushinteger(L, value);
}
};
template < class T >
struct Setter<T, typename std::enable_if<std::is_floating_point<T>::value>::type>
{
static void Set(lua_State* L, T value)
{
lua_pushnumber(L, value);
}
};
template <>
struct Setter<const char*>
{
static void Set(lua_State* L, const char* value)
{
lua_pushstring(L, value);
}
};
template <>
struct Setter<String>
{
static void Set(lua_State* L, const String& value)
{
lua_pushstring(L, value.CString());
}
};
template < class T >
void Set(lua_State* L, T&& value)
{
Setter<typename std::decay<T>::type>::Set(L, value);
}
}
|
2d95ca1993bea86d7963f1f4a75f1db1d99dffdd | 8eb40f2ef0f4b50515a9bc8967c50f6049edbc14 | /omok/omok_dll/FunctionLibrary.cpp | 8d346b639baeb17d582c0a106e6c7057e164b81f | [] | no_license | 3355moijam/inha_programing | 96294a20b7658b484662c5db94ab1ecf66ea7448 | 8735e17cf2a60e4dd31b6ad3455344c205159786 | refs/heads/master | 2023-03-25T23:50:13.234996 | 2020-10-20T00:12:05 | 2020-10-20T00:12:05 | 134,127,980 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 361 | cpp | FunctionLibrary.cpp | #pragma once
#include "omok_framework.h"
#include "FunctionLibrary.h"
POINT& operator-=(POINT& left, const POINT& right)
{
left.x -= right.x;
left.y -= right.y;
return left;
}
POINT& operator-=(POINT& left, int num)
{
left.x -= num;
left.y -= num;
return left;
}
POINT& operator+=(POINT& left, int num)
{
left.x += num;
left.y += num;
return left;
} |
93be324d8e0c19dcefd04feaad275dd7e5968823 | 5f097697270c18323fa3385db6c793995d681552 | /Header Files/chessGame.h | 0c2007434805b6c70680e2001e71e51c7b9391ac | [] | no_license | YarinBazini/boardGames | 9c23f819b9d2fd084d45c0ed6e77e1c251af8acd | a8b89d9086639fabf6301c9afb2289de8cc85cd9 | refs/heads/master | 2023-08-25T00:32:45.102693 | 2021-11-03T19:34:55 | 2021-11-03T19:34:55 | 424,348,416 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,993 | h | chessGame.h | #pragma once
#include "game.h"
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
class ChessGameStone;
class ChessKingStone;
class ChessGame : public Game
{
public:
static const int chess_size = 8;
static const int chess_stones_number = 32;
/* ChessGame constructor */
ChessGame();
/* ChessGame constructor */
ChessGame(const ChessGame& other);
/* ChessGame destructor */
virtual ~ChessGame();
/* ChessGame constructor */
ChessGame(istream& in);
/* ChessGame copy constructor */
ChessGame(ChessGame& other);
/* ChessGame move constructor */
ChessGame(ChessGame&& other):Game(move(other)) { *this = move(other); }
/* assignment operator */
virtual const ChessGame& operator= (const ChessGame& other);
/* move assignment operator */
virtual const ChessGame& operator= (ChessGame&& other);
/* the function make user move on the game and return move status */
virtual void makeMove(GameStone::Position& src, GameStone::Position& dstMove, GameStone::Position* dstArrow);
/* the function return cell board according to the position */
virtual Cell& getCellOnBoard(const GameStone::Position& position);
/* the function return true if the position on board lines and false else */
virtual bool isInBoardLines(const GameStone::Position& position)const {
return position.x > 0 && position.x <= chess_size && position.y > 0 && position.y <= chess_size;
}
/* the function return board size */
virtual int getBoardSize() { return chess_size; }
/* the function return true if game end and false else */
virtual bool isGameEnd();
/* the function return true if the move danger the king and false else */
bool isDangerKing(ChessGameStone * stone, const GameStone:: Position& src, const GameStone::Position& dst);
/* the function save the game to file */
virtual void save(ostream& outFile) const;
private:
Cell _board[chess_size][chess_size];
ChessKingStone* _king1, *_king2;
int _countEatenStones;
/* the function set the board */
void setBoard();
/* the function set dstMove cell on board */
void setCellOnBoard(GameStone::Position & dstMove, GameStone * stone);
/* the function set the first row of the game for all players */
void setFirstRow(int playerNum);
/* the function set the second row of the game for all players */
void setSecondRow(int playerNum);
/* the function set valid move list for all stones */
void setValidMovesToStones();
/* the function set risk list for all stones */
void setRisksToStones();
/* the function return new stone by type */
ChessGameStone* allocNewChessStoneByType(ChessGameStone* stone);
/* the function set board game from file */
void setBoardFromFile(vector<ChessGameStone*> & v);
/* the function delete all vector date */
void deletVectorData(vector<ChessGameStone*>& v);
/* the function delete all the stones on board */
void deleteAllStones();
};
|
f50e31d3a9fa3e80cb74ec0c3660b8221d0c93b0 | 06ec039cb533ba9cf8759b99ea95536c23c52858 | /Core/Memory32.cpp | 1c1246c11c0059312e437747a1ef51ba74a1ba8e | [
"Zlib"
] | permissive | Psycho-micheal/ddmk | ab9c5638adc5459500e856845fd2fadc2c5a0519 | f05e7c8ee2d4c562654ebc711ba99a11dd9f97a2 | refs/heads/master | 2020-07-03T02:04:35.353018 | 2020-04-18T03:37:22 | 2020-04-18T03:37:22 | 201,751,794 | 0 | 0 | null | 2019-08-11T10:44:19 | 2019-08-11T10:44:18 | null | UTF-8 | C++ | false | false | 2,737 | cpp | Memory32.cpp | #include "Memory32.h"
uint32 appProcessId = 0;
BYTE * appBaseAddr = 0;
HANDLE appProcess = 0;
HWND mainWindow = 0;
BYTE * mainChunk = 0;
uint32 mainChunkPos = 0;
SYSTEM_INFO si = {};
uint32 appSize = 0;
void WriteAddress(BYTE * addr, BYTE * dest, uint32 size, BYTE header, uint32 padSize, BYTE padValue)
{
DWORD p = 0;
VirtualProtectEx(appProcess, addr, (size + padSize), PAGE_EXECUTE_READWRITE, &p);
if (header)
{
*(BYTE *)addr = header;
}
if (size == 2)
{
*(int8 *)(addr + (size - 1)) = (int8)(dest - addr - size);
}
else
{
*(int32 *)(addr + (size - 4)) = (int32)(dest - addr - size);
}
if (padSize)
{
memset((addr + size), padValue, padSize);
}
VirtualProtectEx(appProcess, addr, (size + padSize), p, &p);
}
void WriteCall(BYTE * addr, BYTE * dest, uint32 padSize, BYTE padValue)
{
WriteAddress(addr, dest, 5, 0xE8, padSize, padValue);
}
void WriteJump(BYTE * addr, BYTE * dest, uint32 padSize, BYTE padValue)
{
WriteAddress(addr, dest, 5, 0xE9, padSize, padValue);
}
void WriteShortJump(BYTE * addr, BYTE * dest, uint32 padSize, BYTE padValue)
{
WriteAddress(addr, dest, 2, 0xEB, padSize, padValue);
}
void vp_memset(void * addr, BYTE value, uint32 size)
{
DWORD p = 0;
VirtualProtectEx(appProcess, addr, size, PAGE_EXECUTE_READWRITE, &p);
memset(addr, value, size);
VirtualProtectEx(appProcess, addr, size, p, &p);
}
void vp_memcpy(void * dest, void * addr, uint32 size)
{
DWORD p = 0;
VirtualProtectEx(appProcess, dest, size, PAGE_EXECUTE_READWRITE, &p);
memcpy(dest, addr, size);
VirtualProtectEx(appProcess, dest, size, p, &p);
}
bool Memory_Init()
{
LogFunction();
appProcessId = GetCurrentProcessId();
MODULEENTRY32 me32 = {};
me32.dwSize = sizeof(MODULEENTRY32);
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, appProcessId);
Module32First(snapshot, &me32);
appBaseAddr = me32.modBaseAddr;
Log("%u %s %llX", appProcessId, me32.szModule, appBaseAddr);
appProcess = OpenProcess(PROCESS_ALL_ACCESS, false, appProcessId);
if (!appProcess)
{
Log("OpenProcess failed. %X", GetLastError());
return false;
}
if (!mainChunkSize)
{
Log("No chunk desired.");
return true;
}
GetSystemInfo(&si);
//mainChunk = (BYTE *)HighAlloc(mainChunkSize);
// @Todo: Make sure memory is allocated after appBaseAddr
// For now we make do with a random position.
mainChunk = (BYTE *)VirtualAlloc(0, mainChunkSize, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
DWORD error = GetLastError();
if (!mainChunk && error)
{
Log("VirtualAllocEx failed. %X", error);
return false;
}
memset(mainChunk, 0xCC, mainChunkSize);
return true;
}
|
d8bb20fa4c9ffb635b06c42192b8c3e8eb9bcbaf | 30bdd8ab897e056f0fb2f9937dcf2f608c1fd06a | /Graphs/1195.cpp | 06e59df1d6e6538390bdc05c6744f07693f07a75 | [] | no_license | thegamer1907/Code_Analysis | 0a2bb97a9fb5faf01d983c223d9715eb419b7519 | 48079e399321b585efc8a2c6a84c25e2e7a22a61 | refs/heads/master | 2020-05-27T01:20:55.921937 | 2019-11-20T11:15:11 | 2019-11-20T11:15:11 | 188,403,594 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 369 | cpp | 1195.cpp | #include<iostream>
using namespace::std;
int main(){
int n,t;
cin>>n>>t;
t--;
int ar[n];
for(int i=0;i<n-1;i++){
cin>>ar[i];
}
int i=0;
while(i<n&&i<=t){
if(i==t){
cout<<"YES"<<'\n';
return 0;
}
i+=ar[i];
}
cout<<"NO"<<'\n';
}
|
0f9d89b80fd51979eb5eef175716543c6a888d2c | 89a1470c32b102272983eb8f69ad0bd23940a852 | /src/ManagedAlloc.cpp | 01f3d062e4468fefbea151f20c2c02561776d53f | [
"Apache-2.0"
] | permissive | ASkyeye/ExeLoader | 62bb21567a89b87efd5d10f8cbf582988247e284 | 87cf373643f9fd734a7b4a72957dd7aed114a220 | refs/heads/master | 2022-04-09T12:02:37.862889 | 2020-03-20T19:07:28 | 2020-03-20T19:08:00 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,093 | cpp | ManagedAlloc.cpp | // SPinti Software
// 20 Mars 2020
#include <stdlib.h>
#include <stdio.h>
#include "ManagedAlloc.h"
#include "..\..\..\OS2.1\CPinti\include\leakchk.h"
void ManagedAlloc::ManagedAlloc_(int alloc_max, const char* name)
{
// Creer une instance unique pour chaque process
this->managed_alloc_max = alloc_max;
this->name = name;
}
int ManagedAlloc::ManagedAlloc_clean()
{
fprintf(stdout, "[%s] ManagedAlloc_clean()\n", this->name);
// Vider la memoire
for(int index = 0; index < this->managed_alloc_max; index++)
{
if(this->Alloc_Array[index] != 0)
{
// Liberer la memoire
free(this->Alloc_Array[index]);
fprintf(stdout, "%d : [0x%p] freed!\n", index, (void*) this->Alloc_Array[index]);
}
}
}
bool ManagedAlloc::ManagedFree(void* ptr)
{
// Vider un emplacement connu
fprintf(stdout, "[%s] ManagedFree() [0x%p]\n", this->name, (void*) ptr);
if(ptr != 0)
for(int index = 0; index < this->managed_alloc_max; index++)
if(this->Alloc_Array[index] == ptr)
{
free(ptr);
this->Alloc_Array[index] = 0;
return true;
}
return false;
}
void* ManagedAlloc::ManagedMalloc(size_t size__)
{
// Chercher un emplacement vide et malloc dedans!
fprintf(stdout, "[%s] ManagedMalloc() %d ", this->name, (int) size__);
for(int index = 0; index < this->managed_alloc_max; index++)
if(this->Alloc_Array[index] == 0)
{
this->Alloc_Array[index] = malloc(size__);
fprintf(stdout, "Wrote in [0x%p] -> %d\n", this->Alloc_Array[index], index);
return this->Alloc_Array[index];
}
// Plus de places
return malloc(size__);
}
void* ManagedAlloc::ManagedCalloc(size_t size__, size_t sizeElem__)
{
// Chercher un emplacement vide et malloc dedans!
fprintf(stdout, "[%s] ManagedCalloc() %d ", this->name, (int) size__);
for(int index = 0; index < this->managed_alloc_max; index++)
if(this->Alloc_Array[index] == 0)
{
this->Alloc_Array[index] = calloc(size__, sizeElem__);
fprintf(stdout, "Wrote in [0x%p] -> %d\n", this->Alloc_Array[index], index);
return this->Alloc_Array[index];
}
// Plus de places
return malloc(size__);
}
|
6f93ab8a3d4bb629f989c6a95507a7c7c14ea245 | 186ab878c03f6f2ba352216ff8abb408613421a2 | /构造函数.cpp | ca2c179a884b285b9adef8bd058cf73d8406a8f4 | [] | no_license | 123Expecting/Cplusplus-repo | d43394f6b706a614e7cbc5402013bf8d64173daa | 6b60ed59e90f302c6f34a33b5bb7d188418dff2e | refs/heads/master | 2021-05-27T17:38:36.573748 | 2014-01-31T11:19:20 | 2014-01-31T11:19:20 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,153 | cpp | 构造函数.cpp | /*--------------Program Description-----------
程序名称:构造函数.cpp
程序目的:调用类成员以及构造函数
Written By Dong-Hong yan(WANT Studio)
=================================================*/
#include<iostream>
using namespace std;
//Clock的定义
class Clock {
//外部接口
public:
//构造函数里的参数是“私有数据”,不是函数参数,
//如果没有构造函数,编译通不过,嘻嘻
Clock (int newH,int newM,int newS);
void setTime(int newH,int newM,int newS);
void showTime();
//私有数据
private:
int hour,minute,second;
};
//构造函数的实现
Clock::Clock(int newH,int newM,int newS) {
hour=newH;
minute=newM;
second=newS;
}
//成员函数的实现,类型后函数前加上类的名称
void Clock::setTime(int newH,int newM,int newS) {
hour=newH;
minute=newM;
second=newS;
}
//定义为内联函数
inline void Clock::showTime() {
cout<<hour<<":"<<minute<<":"<<second<<endl;
}
//主程序
int main() {
//该语句必须有参数,如果有默认值的话,也写成Clok c;
Clock c(0,0,0);
c.showTime();
c.setTime(8,30,30);
c.showTime();
return 0;
}
|
78fa3c9189fc7b57ce8e80bc0d818c81e5023d76 | 24cbace834b4b40eeaed79fe22240d6fda215aca | /systems/SFMLDisplaySystem.cpp | 109b4c9502e05a9dff1e13b3b495cc59c6c5ab11 | [
"WTFPL"
] | permissive | deb0ch/R-Type | 89ff6707e34618bc9da9e726f376d56b409b043e | 8bb37cd5ec318efb97119afb87d4996f6bb7644e | refs/heads/master | 2021-01-10T11:54:59.140931 | 2019-01-31T12:44:36 | 2019-01-31T12:44:36 | 53,809,601 | 6 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 905 | cpp | SFMLDisplaySystem.cpp | #include "SFMLDisplaySystem.hh"
SFMLDisplaySystem::SFMLDisplaySystem()
: ASystem("SFMLDisplaySystem")
{}
SFMLDisplaySystem::~SFMLDisplaySystem()
{}
//----- ----- Methods ----- ----- //
bool SFMLDisplaySystem::canProcess(Entity *) const
{
return (false);
}
void SFMLDisplaySystem::processEntity(Entity *, const float)
{}
void SFMLDisplaySystem::start()
{
if (!(this->_window = this->_world->getSharedObject<sf::RenderWindow>("sfmlwindow")))
{
this->_window = new sf::RenderWindow(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 32), "EpicGradius");
this->_window->setVerticalSyncEnabled(true);
this->_world->setSharedObject("sfmlwindow", this->_window);
}
}
void SFMLDisplaySystem::beforeProcess(const float)
{
if (this->_window)
this->_window->display();
}
void SFMLDisplaySystem::afterProcess(const float)
{
if (this->_window)
this->_window->clear();
}
|
c77b50577e2595a449483eeac9c17cc09bf1408f | f89c4a2f1cdbfb8f85c25798ab22beb2442c44db | /d03/ex01/main.cpp | 71e538344dc82c917bd1dd57c3f34734bdd0c329 | [] | no_license | InBergman/Piscine_CPP_42 | dbade793beeb5f6d1136956ff620f1c8bdbeaab9 | 672c8846c88ea571c8870e0458597308c016cf60 | refs/heads/master | 2020-03-08T05:23:14.524009 | 2019-08-07T15:26:06 | 2019-08-07T15:26:06 | 127,946,819 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 84 | cpp | main.cpp | #include "FragTrap.hpp"
#include "ScavTrap.hpp"
int main(void) {
return(0);
}
|
da6cbb6ff647d953e4e16ac84611af1d1a079094 | ac176f429c420a8d6290c57df14346d207cff3de | /leetcodecpp/leetcode/crackcodeinterview/ZeroFiveZeroThree.cpp | 09392b40e56aba3d38e4ec69b3bdabd52815f4d9 | [] | no_license | xu20160924/leetcode | 72c6fc02428e568148af4503c63c6f2553982a1c | 43e12a3db5b4087913ec338e652ae7fd59859c23 | refs/heads/master | 2023-08-04T14:41:06.964273 | 2022-11-20T13:39:28 | 2022-11-20T13:39:28 | 252,931,114 | 0 | 0 | null | 2023-07-23T10:52:04 | 2020-04-04T06:57:49 | Java | UTF-8 | C++ | false | false | 817 | cpp | ZeroFiveZeroThree.cpp | //
// Created by John on 2020/3/25.
//
#include <bitstring.h>
#include "iostream"
using namespace std;
class Solution{
public:
int reverseBits(int num) {
int max = 0;
int cnt = 0, cntPre = 0;
while (num) {
// cout << bit_set(num) << endl;
cout << bitset<32>(num) << endl;
if (1 & num) {
cnt++;
} else {
if (cntPre + cnt + 1 > max) {
max = cntPre + cnt + 1;
}
cntPre = cnt;
cnt = 0;
}
num >>= 1;
}
if (cntPre + cnt + 1 > max) {
max = cntPre + cnt + 1;
}
return max;
}
};
//int main() {
// Solution *solution = new Solution();
// solution->reverseBits(1775);
//} |
7a103037207d634eedf84291ae8ca865488dffd8 | e018d8a71360d3a05cba3742b0f21ada405de898 | /Client/MAttackZoneRectEffectGenerator.cpp | ee59a9e4586f88f9ae40b5675987b90a2f53f676 | [] | no_license | opendarkeden/client | 33f2c7e74628a793087a08307e50161ade6f4a51 | 321b680fad81d52baf65ea7eb3beeb91176c15f4 | refs/heads/master | 2022-11-28T08:41:15.782324 | 2022-11-26T13:21:22 | 2022-11-26T13:21:22 | 42,562,963 | 24 | 18 | null | 2022-11-26T13:21:23 | 2015-09-16T03:43:01 | C++ | UHC | C++ | false | false | 2,813 | cpp | MAttackZoneRectEffectGenerator.cpp | //----------------------------------------------------------------------
// MAttackZoneRectEffectGenerator.cpp
//----------------------------------------------------------------------
// 가운데서부터 8방향으로 이동하게 만든다.
//----------------------------------------------------------------------
#include "Client_PCH.h"
#include "MAttackZoneRectEffectGenerator.h"
#include "MLinearEffect.h"
#include "MTopView.h"
#include "MZone.h"
#include "EffectSpriteTypeDef.h"
#include "MEffectSpriteTypeTable.h"
bool
MAttackZoneRectEffectGenerator::Generate( const EFFECTGENERATOR_INFO& egInfo )
{
int est = egInfo.effectSpriteType;
BLT_TYPE bltType = (*g_pEffectSpriteTypeTable)[est].BltType;
TYPE_FRAMEID frameID = (*g_pEffectSpriteTypeTable)[est].FrameID;
int currentPhase = egInfo.pEffectTarget != NULL ?egInfo.pEffectTarget->GetCurrentPhase() : -1;
int maxFrame = g_pTopView->GetMaxEffectFrame(bltType, frameID);
// 시작 좌표
if( currentPhase == 2 )
{
// 첫번째면 8방향을 생성한다.
int sx = egInfo.x1;
int sy = egInfo.y1;
int sz = egInfo.z1;
for(int i=0;i<8;i++)
{
MLinearEffect *pEffect = new MLinearEffect(bltType);
pEffect->SetFrameID( frameID, maxFrame );
pEffect->SetPixelPosition( sx, sy, 0 );
int tx,ty;
tx = g_pTopView->PixelToMapX( sx );
ty = g_pTopView->PixelToMapY( sy );
if( i == 0 || i == 1 || i == 7 )
tx --;
else
if( i == 3 || i == 4 || i == 5 )
tx ++;
if( i == 1 || i == 2 || i == 3 )
ty ++;
else
if( i == 5 || i == 6 || i == 7 )
ty --;
tx = g_pTopView->MapToPixelX( tx );
ty = g_pTopView->MapToPixelY( ty );
pEffect->SetTarget(tx,ty,0, egInfo.step );
pEffect->SetDirection( i );
pEffect->SetCount(egInfo.count, egInfo.linkCount);
pEffect->SetPower(egInfo.power);
if(g_pZone->AddGroundEffect( pEffect ) && i ==0 )
{
pEffect->SetLink( egInfo.nActionInfo, egInfo.pEffectTarget);
} else
{
pEffect->SetLink( egInfo.nActionInfo, NULL);
}
}
} else
{
// 첫번째가 아니면
int sx = egInfo.x0;
int sy = egInfo.y0;
int sz = egInfo.z0;
int tx,ty;
tx = egInfo.x1;
ty = egInfo.y1;
MLinearEffect* pEffect = new MLinearEffect(bltType);
pEffect->SetFrameID( frameID, maxFrame );
pEffect->SetPixelPosition( sx,sy,0 );
pEffect->SetTarget(tx,ty,sz,egInfo.step);
pEffect->SetDirection( egInfo.direction);
pEffect->SetCount( egInfo.count, egInfo.linkCount );
pEffect->SetPower( egInfo.power);
if(g_pZone->AddGroundEffect( pEffect ) )
{
pEffect->SetLink(egInfo.nActionInfo, egInfo.pEffectTarget );
} else
{
pEffect->SetLink( egInfo.nActionInfo, NULL);
}
}
return true;
}
|
2356a5561c376cfeda8ed89a8e8ab88c7f041439 | d9bb656bd11f85e6419ebd786aec6fe3f917cb73 | /modules/variants/phase.cpp | 321bc10d8f1c66e0f66197ab6715b450229d45c1 | [
"BSD-2-Clause"
] | permissive | spiralgenetics/biograph | 55a91703a70429568107209ce20e71f6b96577df | 5f40198e95b0626ae143e021ec97884de634e61d | refs/heads/main | 2023-08-30T18:04:55.636103 | 2021-10-31T00:50:48 | 2021-10-31T00:51:08 | 386,059,959 | 21 | 10 | NOASSERTION | 2021-07-22T23:28:45 | 2021-07-14T19:52:15 | HTML | UTF-8 | C++ | false | false | 21,703 | cpp | phase.cpp | #include "modules/variants/phase.h"
#include "modules/io/ref_count.h"
#include "modules/io/stats.h"
namespace variants {
namespace {
constexpr bool k_dbg = false;
constexpr bool k_show_stats = false;
constexpr int k_show_stats_interval = 30;
static time_t g_next_show_stats = 0;
static time_t g_next_split_show_stats = 0;
} // namespace
const char join_phases::k_join_phases_name[] = "JOIN_PHASES";
bool join_phases::g_check_invariants = false;
join_phases::join_phases(size_t max_phase_len, size_t max_phase_asm_len, pipeline_step_t output)
: sorted_output_pipeline_step(std::move(output)),
m_max_phase_len(max_phase_len),
m_max_phase_asm_len(max_phase_asm_len) {}
join_phases::~join_phases() { flush(); }
void join_phases::show_stats() {
if (!k_show_stats) {
return;
}
time_t now = time(0);
if (g_next_show_stats > now) {
return;
}
g_next_show_stats += k_show_stats_interval;
if (g_next_show_stats < now) {
g_next_show_stats = now + k_show_stats_interval;
if (g_next_split_show_stats < now) {
g_next_split_show_stats = now;
}
}
absl::btree_set<active_t*> distinct_actives;
absl::btree_set<const assembly*> distinct_subs;
absl::btree_set<const assembly*> distinct_refs;
for (const auto& act : m_active) {
distinct_actives.insert(act.second.get());
}
simple_stats<double> dist_to_left;
simple_stats<double> dist_to_right;
simple_stats<double> dist_to_var_right;
simple_stats<double> num_joined;
simple_stats<double> num_ref;
size_t tot_joined = 0;
size_t tot_ref = 0;
for (active_t* act : distinct_actives) {
dist_to_left.add_sample(act->joined_a->left_offset - m_cur_offset);
dist_to_right.add_sample(act->right_offset - m_cur_offset);
dist_to_var_right.add_sample(act->var_right_offset - m_cur_offset);
num_joined.add_sample(act->joined_a->sub_assemblies.size());
tot_joined += act->joined_a->sub_assemblies.size();
num_ref.add_sample(act->reference_after.size());
tot_ref += act->reference_after.size();
for (const auto& sub : act->joined_a->sub_assemblies) {
distinct_subs.insert(sub->get());
}
for (const auto& ref : act->reference_after) {
distinct_refs.insert(ref->get());
}
}
auto statstr = [](simple_stats<double>& stats) -> std::string {
std::stringstream out;
stats.analyze();
if (stats.samples.empty()) {
out << "(none)";
} else {
out << stats.min << "/" << stats.avg << "/" << stats.max;
}
return out.str();
};
std::cerr << "join_phases@" << m_cur_offset << ": " << m_tot_seen << " asms (" << tot_joined
<< " active, " << distinct_subs.size() << " distinct), " << m_tot_seen_phases
<< " phases (" << m_seen_phases.size() << " distinct, " << m_active.size()
<< " active, " << distinct_actives.size() << " distinct active) ref afters=" << tot_ref
<< " (" << distinct_refs.size() << " distinct)"
<< " left=" << statstr(dist_to_left) << " right=" << statstr(dist_to_right)
<< " var_right=" << statstr(dist_to_var_right) << "\n";
}
void join_phases::check_invariants() {
if (!g_check_invariants) {
return;
}
absl::btree_map<active_t*, phase_set> phase_refs;
for (const auto& act : m_active) {
CHECK(phase_refs[act.second.get()].insert(act.first).second);
}
for (const auto& phase_ref : phase_refs) {
active_t* act = phase_ref.first;
CHECK(phase_ref.second == act->joined_a->phase_ids)
<< "phase_ref: " << phase_ref.second << " active: " << act->joined_a->phase_ids;
aoffset_t right_offset = act->joined_a->left_offset;
dna_sequence seq;
for (const auto& sub : act->joined_a->sub_assemblies) {
CHECK_EQ((*sub)->left_offset, right_offset);
right_offset = (*sub)->right_offset;
seq += (*sub)->seq;
}
CHECK_EQ(act->joined_a->right_offset, right_offset);
CHECK_EQ(seq, act->joined_a->seq);
CHECK_EQ(right_offset, act->var_right_offset);
for (const auto& ref_asm : act->reference_after) {
CHECK_EQ((*ref_asm)->left_offset, right_offset);
right_offset = (*ref_asm)->right_offset;
}
CHECK_EQ(right_offset, act->right_offset);
}
}
void join_phases::add_ref_asm(std::shared_ptr<assembly_ptr> shared_a) {
if (k_dbg) {
std::cout << "join_phases::add_ref_asm: " << **shared_a << "\n";
}
CHECK((*shared_a)->matches_reference);
auto& a = *shared_a;
for (auto it = m_active.begin(); it != m_active.end();) {
auto& act = it->second;
if (act->right_offset > a->left_offset) {
if (k_dbg) {
std::cout << "Phase " << it->first << " at " << act->right_offset
<< "; doesn't need reference at " << a->left_offset << "\n";
}
++it;
continue;
}
if (act->right_offset < a->left_offset) {
if (k_dbg) {
std::cout << "Phase " << it->first << " at " << act->right_offset << "; not caught up to "
<< a->left_offset << ". discarding.\n";
}
output_active(std::move(act));
it = m_active.erase(it);
continue;
}
if (k_dbg) {
std::cout << "Phase " << it->first << " at " << act->right_offset << " adding reference from "
<< a->left_offset << " to " << a->right_offset << "\n";
}
CHECK_EQ((*shared_a)->left_offset, act->right_offset);
act->reference_after.push_back(shared_a);
act->right_offset = (*shared_a)->right_offset;
if (k_dbg) {
std::cout << "new active right offset: " << act->right_offset << "\n";
}
++it;
}
output_if_last_ref(std::move(shared_a));
check_invariants();
}
void join_phases::output_active(active_ptr act_shared) {
auto act = act_shared.release();
if (!act) {
// Not the last reference; wait to output it.
return;
}
if (k_dbg) {
std::cout << "Outputting active " << *act->joined_a << "\n";
}
untrack_left_offset(act->joined_a->left_offset);
sort_and_output(std::move(act->joined_a));
for (auto& ref : act->reference_after) {
output_if_last_ref(std::move(ref));
}
}
void join_phases::output_if_last_ref(std::shared_ptr<assembly_ptr> shared_a) {
if (shared_a.use_count() == 1) {
assembly_ptr a = std::move(*shared_a);
if (k_dbg) {
std::cout << "Outputting since it's the last reference: " << *a << "\n";
}
sort_and_output(std::move(a));
} else {
if (k_dbg) {
std::cout << shared_a.use_count() << " refs left on " << **shared_a << "\n";
}
}
}
void join_phases::advance_to(aoffset_t target) {
if (k_dbg) {
std::cout << "Advance target: " << target << "\n";
}
while (m_cur_offset < target) {
advance_towards(target);
flush_sorted_to(m_cur_offset);
show_stats();
}
CHECK_EQ(m_cur_offset, target);
}
void join_phases::advance_towards(aoffset_t target) {
CHECK_GT(target, m_cur_offset);
for (auto& ref_asm : m_cur_ref) {
aoffset_t left_offset = ref_asm->left_offset;
auto shared_a = std::make_shared<assembly_ptr>(std::move(ref_asm));
add_ref_asm(shared_a);
auto new_act = new_active((*shared_a)->left_offset, {});
CHECK_EQ((*shared_a)->left_offset, new_act->right_offset);
new_act->right_offset = (*shared_a)->right_offset;
new_act->joined_a->matches_reference = true;
add_to_active(new_act.get(), std::move(shared_a));
CHECK_EQ(1, new_act.use_count()) << "Reference phase should not be added to any phase group";
output_active(std::move(new_act));
untrack_left_offset(left_offset);
}
m_cur_ref.clear();
for (const auto& act_elem : m_active) {
const auto& act = act_elem.second;
if (act->right_offset > m_cur_offset) {
target = std::min(target, act->right_offset);
}
}
if (!m_abort_at.empty()) {
target = std::min(target, m_abort_at.begin()->first);
}
CHECK_GT(target, m_cur_offset);
if (k_dbg) {
std::cout << "Advancing " << m_cur_offset << " to " << target << "\n";
}
m_cur_offset = target;
for (auto it = m_active.begin(); it != m_active.end();) {
auto& act = it->second;
if (act->right_offset < m_cur_offset ||
act->var_right_offset + aoffset_t(m_max_phase_len) < m_cur_offset) {
if (k_dbg) {
std::cout << act->right_offset << " (var=" << act->var_right_offset
<< ") expired phase: " << *act->joined_a << " ids=" << act->joined_a->phase_ids
<< "\n";
}
output_active(std::move(act));
it = m_active.erase(it);
continue;
}
++it;
}
if (!m_abort_at.empty()) {
auto first_abort = m_abort_at.begin();
CHECK_GE(first_abort->first, m_cur_offset);
if (first_abort->first == m_cur_offset) {
abort_phases(first_abort->second);
m_abort_at.erase(first_abort);
}
}
check_invariants();
}
void join_phases::on_assembly(assembly_ptr a) {
if (k_dbg) {
std::cout << "join_phases got assembly " << *a << " with phases " << a->phase_ids << "\n";
}
if (k_show_stats) {
++m_tot_seen;
m_tot_seen_phases += a->phase_ids.size();
for (const std::string& phase_id : a->phase_ids) {
m_seen_phases.insert(phase_id);
}
}
advance_to(a->left_offset);
if (a->phase_ids.empty() && !a->matches_reference) {
if (k_dbg) {
std::cout << "Unphased assembly passing through: " << *a << "\n";
}
sort_and_output(std::move(a));
return;
}
if (a->matches_reference) {
if (k_dbg) {
std::cout << "Saving ref asm: " << *a << "\n";
}
// Process reference last, after all variants here.
track_left_offset(a->left_offset);
m_cur_ref.emplace_back(std::move(a));
return;
}
add_var_asm(std::make_shared<assembly_ptr>(std::move(a)));
}
void join_phases::add_var_asm(std::shared_ptr<assembly_ptr> shared_a) {
if (k_dbg) {
std::cout << "Adding var asm: " << **shared_a << "\n";
}
auto& a = *shared_a;
CHECK(!a->phase_ids.empty());
bool force_abort = false;
if ((a->right_offset - a->left_offset) > aoffset_t(m_max_phase_asm_len)) {
if (k_dbg) {
std::cout << "Forcing abort due to large variant seq\n";
}
force_abort = true;
} else if (aoffset_t(a->seq.size()) > m_max_phase_asm_len) {
if (k_dbg) {
std::cout << "Forcing abort due to large reference seq\n";
}
force_abort = true;
}
absl::btree_map<active_t*, phase_set /* phase ids */> found_phases;
absl::btree_map<active_t*, std::pair<active_ptr, phase_set /* phase ids */>> discard_phases;
phase_set new_phases;
phase_set abort_phase_ids;
if (force_abort) {
abort_phase_ids = a->phase_ids;
} else {
for (const auto& phase_id : a->phase_ids) {
auto it = m_active.find(phase_id);
if (it == m_active.end()) {
new_phases.insert(phase_id);
continue;
}
auto& act = it->second;
if (act->right_offset != a->left_offset) {
std::stringstream msg;
msg << "Phase conflict with phase id '" << phase_id << "' between " << *act->joined_a
<< " and " << *a << "; consider running resolve_phase_conflicts";
throw(io_exception(msg.str()));
}
found_phases[act.get()].insert(phase_id);
}
}
if (!abort_phase_ids.empty()) {
abort_phases(abort_phase_ids);
// Abort these phase ids again at the other end of this assembly.
if (a->right_offset > m_cur_offset) {
m_abort_at[a->right_offset] += abort_phase_ids;
}
new_phases += abort_phase_ids;
}
for (const auto& found : found_phases) {
auto* act = found.first;
const auto& found_phase_ids = found.second;
if (k_dbg) {
std::cout << "Processing phase subset: " << found_phase_ids << "\n";
}
if (act->joined_a->phase_ids != found_phase_ids) {
// Split necessary.
split_active(act, found_phase_ids);
CHECK(act->joined_a->phase_ids == found_phase_ids)
<< "active=" << act->joined_a->phase_ids << " found=" << found_phase_ids;
}
CHECK_EQ(act->right_offset, a->left_offset);
save_ref_asms(act);
add_to_active(act, shared_a);
CHECK_EQ((*shared_a)->left_offset, act->right_offset);
act->right_offset = (*shared_a)->right_offset;
check_invariants();
}
if (new_phases.empty()) {
CHECK(!found_phases.empty());
} else {
auto new_act = new_active((*shared_a)->left_offset, new_phases);
CHECK_EQ((*shared_a)->left_offset, new_act->right_offset);
new_act->right_offset = (*shared_a)->right_offset;
add_to_active(new_act.get(), std::move(shared_a));
CHECK(!new_act.release()) << "Unable to add new active to any phases";
}
if (!abort_phase_ids.empty()) {
abort_phases(abort_phase_ids);
}
check_invariants();
}
void join_phases::abort_phases(const phase_set& abort_ids) {
if (k_dbg) {
std::cout << "Aborting phases: " << abort_ids << "\n";
}
CHECK(!abort_ids.empty());
absl::btree_map<active_t*, std::pair<active_ptr, phase_set /* phase ids */>> found_phases;
for (const auto& abort_id : abort_ids) {
auto it = m_active.find(abort_id);
if (it == m_active.end()) {
// No need to abort this phase id.
continue;
}
auto& act = it->second;
auto& found = found_phases[act.get()];
auto& found_act = found.first;
auto& found_phase_ids = found.second;
if (found_act) {
CHECK_EQ(found_act.get(), act.get());
CHECK(!found_act.release());
}
found_act = std::move(act);
CHECK(found_phase_ids.insert(abort_id).second);
m_active.erase(it);
}
for (auto& found : found_phases) {
auto& act = found.second.first;
CHECK_EQ(found.first, act.get());
auto& phase_ids = found.second.second;
if (act->joined_a->phase_ids != phase_ids) {
split_active(act.get(), phase_ids);
}
CHECK_EQ(act->joined_a->phase_ids, phase_ids);
output_active(std::move(act));
}
}
void join_phases::split_active(active_t* act, const phase_set& keep_phases) {
CHECK_LT(keep_phases.size(), act->joined_a->phase_ids.size());
if (g_check_invariants) {
phase_set unexpected_phases = keep_phases - act->joined_a->phase_ids;
CHECK(unexpected_phases.empty())
<< "orig=" << act->joined_a->phase_ids << "keep=" << keep_phases
<< "unexpected=" << unexpected_phases;
}
phase_set split_phases = act->joined_a->phase_ids - keep_phases;
CHECK(!split_phases.empty()) << "orig=" << act->joined_a->phase_ids << "keep=" << keep_phases
<< "split=" << split_phases;
if (k_dbg) {
std::cout << "Splitting active " << *act->joined_a << ", keeping " << keep_phases
<< ", splitting " << split_phases << "\n";
}
act->joined_a->phase_ids = keep_phases;
active_ptr new_act(make_unique<active_t>());
new_act->joined_a = make_unique<assembly>(*act->joined_a);
new_act->joined_a->assembly_id = allocate_assembly_id();
new_act->joined_a->phase_ids = std::move(split_phases);
new_act->reference_after = act->reference_after;
new_act->right_offset = act->right_offset;
new_act->var_right_offset = act->var_right_offset;
track_left_offset(new_act->joined_a->left_offset);
for (const auto& phase_id : new_act->joined_a->phase_ids) {
auto it = m_active.find(phase_id);
CHECK(it != m_active.end());
CHECK_EQ(it->second.get(), act);
CHECK(!it->second.release()) << "Split removed last old active?";
it->second = new_act.clone();
}
CHECK(!new_act.release()) << "Unable to assign new active to any phase ids";
check_invariants();
}
void join_phases::save_ref_asms(active_t* act) {
if (k_dbg) {
std::cout << "Saving " << act->reference_after.size() << " ref asms from " << *act->joined_a
<< " init right = " << act->right_offset << "\n";
}
for (auto& ref_asm : act->reference_after) {
add_to_active(act, std::move(ref_asm));
}
act->reference_after.clear();
}
void join_phases::add_to_active(active_t* act, std::shared_ptr<assembly_ptr> shared_a) {
const auto& a = *shared_a;
act->joined_a->seq += a->seq;
CHECK_EQ(act->var_right_offset, a->left_offset);
CHECK_EQ(act->joined_a->right_offset, a->left_offset);
act->joined_a->right_offset = a->right_offset;
act->joined_a->sub_assemblies.push_back(std::move(shared_a));
act->var_right_offset = a->right_offset;
}
join_phases::active_ptr join_phases::new_active(aoffset_t left_offset,
const phase_set& new_phases) {
if (k_dbg) {
std::cout << "New active for " << new_phases << " at " << left_offset << "\n";
}
active_ptr new_act(make_unique<active_t>());
new_act->joined_a = make_unique<assembly>();
new_act->right_offset = left_offset;
new_act->var_right_offset = left_offset;
auto& new_a = new_act->joined_a;
new_a->assembly_id = allocate_assembly_id();
new_a->left_offset = left_offset;
new_a->right_offset = left_offset;
new_a->tags.insert(k_join_phases_name);
new_a->phase_ids = new_phases;
track_left_offset(new_a->left_offset);
for (const auto& phase_id : new_phases) {
auto& act = m_active[phase_id];
CHECK(!act);
act = new_act.clone();
}
return new_act;
}
void join_phases::flush() {
advance_to(std::numeric_limits<aoffset_t>::max());
CHECK(m_active.empty());
CHECK(m_cur_ref.empty());
}
void propagate_subassembly_coverage(assembly* a) {
if (a->sub_assemblies.empty()) {
return;
}
aoffset_t seq_offset = 0;
for (auto& subasm : a->sub_assemblies) {
const auto& suba = *subasm;
size_t subseq_size = (*subasm)->seq.size();
auto propagate_cov = [seq_offset, subseq_size](boost::optional<read_coverage_t>& cov,
boost::optional<read_coverage_t>& subcov) {
if (!cov) {
return;
}
if (subcov) {
// subcov->add_subcoverage(*cov, seq_offset, subseq_size);
read_coverage_t new_subcov = cov->subcoverage(seq_offset, subseq_size);
*subcov = subcov->union_with(new_subcov);
} else {
read_coverage_t new_subcov = cov->subcoverage(seq_offset, subseq_size);
subcov.emplace(std::move(new_subcov));
}
};
propagate_cov(a->read_coverage, suba->read_coverage);
propagate_cov(a->pair_read_coverage, suba->pair_read_coverage);
seq_offset += subseq_size;
}
CHECK_EQ(seq_offset, a->seq.size());
}
split_phases::split_phases(pipeline_step_t output)
: sorted_output_pipeline_step(std::move(output)) {}
split_phases::~split_phases() {
advance_to(std::numeric_limits<aoffset_t>::max());
CHECK(m_active.empty());
}
void split_phases::on_assembly(assembly_ptr a) {
advance_to(a->left_offset);
if (k_show_stats) {
time_t now = time(0);
if (g_next_split_show_stats < now) {
g_next_split_show_stats += k_show_stats_interval;
if (g_next_split_show_stats < now) {
g_next_split_show_stats = now + k_show_stats_interval;
}
std::cerr << "split_phases@" << a->left_offset << " active=" << m_active.size();
if (!m_active.empty()) {
std::cerr << " left=" << m_active.begin()->first << " right=" << m_active.rbegin()->first;
}
std::cerr << "\n";
}
}
if (a->sub_assemblies.empty()) {
sort_and_output(std::move(a));
return;
}
for (auto& suba : a->sub_assemblies) {
aoffset_t left_offset = (*suba)->left_offset;
if (m_active[left_offset].insert(std::move(suba)).second) {
track_left_offset(left_offset);
}
}
}
void split_phases::advance_to(aoffset_t offset) {
while (!m_active.empty() && m_active.begin()->first < offset) {
auto& asms = m_active.begin()->second;
for (const auto& a : asms) {
untrack_left_offset((*a)->left_offset);
sort_and_output(std::move(*a));
}
m_active.erase(m_active.begin());
}
flush_sorted_to(offset);
}
resolve_phase_conflicts::resolve_phase_conflicts(const resolve_conflict_func_t& resolve_conflict,
pipeline_step_t output)
: sorted_output_pipeline_step(std::move(output)), m_resolve_conflict(resolve_conflict) {}
resolve_phase_conflicts::~resolve_phase_conflicts() {
advance_to(std::numeric_limits<aoffset_t>::max());
CHECK(m_active.empty());
}
void resolve_phase_conflicts::on_assembly(assembly_ptr a) {
advance_to(a->left_offset);
bool need_conflict_check = true;
while (need_conflict_check) {
need_conflict_check = false;
for (auto& act : m_active) {
if (check_and_resolve_conflicts(a, act.second)) {
need_conflict_check = true;
break;
}
}
}
track_left_offset(a->left_offset);
aoffset_t right_offset = a->right_offset;
m_active.emplace(right_offset, std::move(a));
}
void resolve_phase_conflicts::advance_to(aoffset_t pos) {
while (!m_active.empty() && m_active.begin()->first < pos) {
auto it = m_active.begin();
assembly_ptr a = std::move(it->second);
m_active.erase(it);
untrack_left_offset(a->left_offset);
sort_and_output(std::move(a));
}
flush_sorted_to(pos);
}
bool resolve_phase_conflicts::check_and_resolve_conflicts(const assembly_ptr& a,
const assembly_ptr& b) {
phase_set in_common = a->phase_ids & b->phase_ids;
if (in_common.empty()) {
return false;
}
m_resolve_conflict(a, b, in_common);
phase_set new_in_common = a->phase_ids & b->phase_ids;
if (!new_in_common.empty()) {
std::stringstream msg;
msg << "Phase conflict resolution failed between " << *a << " and " << *b
<< "; origin conflict phases=" << in_common
<< ", after resolution conflicts=" << new_in_common;
throw(io_exception(msg.str()));
}
return true;
}
} // namespace variants
|
d342c9f553ca22926f19c532814fb2738d83609c | ec97a0b1f6da878fb2bef54c9b8c70306e37b74c | /Project5/Class.cpp | fcff67e26804196be405b098df07673f228161e9 | [] | no_license | mahm99/Cpp | 693f4b19675c350e3defed3e16e49882ffc70714 | d103a9ec23b0819b13a70cd29eb47ff9e647f0db | refs/heads/master | 2022-04-06T02:14:08.021768 | 2020-03-02T16:14:41 | 2020-03-02T16:14:41 | 232,875,145 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,444 | cpp | Class.cpp | /********************************************************************
* File: Class.cpp
* Author: Mahmood Ul Mohasin Aziz
* Description:
* This file contains the program code for the Class class. This class
* controls everything related to the class vector. It adds students
* to the roster and waitlist based on the situation, and prints
* out the requested information about the section. This class finds
* the student the user is trying to look for, and also allows to
* sort the roster and waitlist.
*********************************************************************/
#include "Class.h"
//Name: Class()
//Desc: Default Constructor
//Precondition: None
//Postcondition: Creates Class object
Class::Class() {
m_name = "";
m_section = 0;
}
//Name: Class
//Desc: Overloaded Constructor
//Precondition: Have name and number
//Postcondition: Creates Class object
Class::Class(string name, int section) {
m_name = name;
m_section = section;
}
//Name: ~Class
//Desc: Destructor
//Precondition: None
//Postcondition: Deallocates anything dynamically allocated in a Class
Class::~Class() {
// condition only to make sure roster is not empty.
if (m_roster.Size() > 0) {
for(int i = 0; i < m_roster.Size(); i++) {
delete m_roster[i];
}
}
// condition to avoid looping if waitlist is empty.
if (m_waitlist.Size() > 0) {
for(int i = 0; i < m_waitlist.Size(); i++) {
delete m_waitlist[i];
}
}
}
//Name: DisplayStudents
//Desc: Displays all students in Class. Displays students in the m_roster
// and if there are students in the m_waitlist, displays them
// Additionally shows count of students in m_roster and count in m_waitlist
//Precondition: Class has students enrolled
//Postcondition: Lists all students for a specific Class
void Class::DisplayStudents() {
cout << "Total Enrolled: " << m_roster.Size() << endl;
for(int i = 0; i < m_roster.Size(); i++) {
cout << (i+1) << ". " << *m_roster[i];
}
if (m_waitlist.IsEmpty() == 0) {
cout << "\nTotal Waitlisted: " << m_waitlist.Size() << endl;
for(int i = 0; i < m_waitlist.Size(); i++) {
cout << (i+1) << ". " << *m_waitlist[i];
}
}
}
//Name: AddStudent
//Desc: A student is added to a Class. If there is room in the m_roster, added there.
// If the m_roster is full, attempts to add student to m_waitlist.
// Else new section added, waitlist moved to new section and new student added.
//Precondition: Class exists
//Postcondition: Adds a student to a Class; returns true if added else false
bool Class::AddStudent(Student* newStudent) {
if (!IsRosterFull()) {
m_roster.Enqueue(newStudent);
return true;
}
else if (!IsWaitlistFull()) {
m_waitlist.Enqueue(newStudent);
return true;
}
return false;
}
//Name: Sort
//Desc: Sorts the students alphabetically by last name for both roster and waitlist
//Precondition: None
//Postcondition: m_roster and m_waitlist are sorted
void Class::SortStudents() {
m_roster.Sort();
m_waitlist.Sort();
}
//Name: GetName
//Desc: Returns name of Class
//Precondition: None
//Postcondition: Class name is returned
string Class::GetName() {
return m_name;
}
//Name: SetName
//Desc: Allows Class name to be set
//Precondition: name is a valid string
//Postcondition: Class name is updated
void Class::SetName(string name) {
m_name = name;
}
//Name: GetSection
//Desc: Returns section of Class
//Precondition: None
//Postcondition: Class section is returned
int Class::GetSection() {
return m_section;
}
//Name: SetSection
//Desc: Allows Class section to be set
//Precondition: section is a valid integer
//Postcondition: Class section is updated
void Class::SetSection(int section) {
m_section = section;
}
//Name: TransferWaitToRoster
//Desc: When an m_roster is full and m_waitlist is full, copies all students in
// m_waitlist to a destination Class
//Precondition: m_waitlist is full
//Postcondition: m_waitlist is empty and all students were transferred to new Class
void Class::TransferWaitToRoster(Class& destination) {
// moving waitlisted students into the newly created section.
if (m_waitlist.IsFull() == 1) {
for(int i = 0; i < m_waitlist.Size(); i++) {
destination.AddStudent(m_waitlist[i]);
}
m_waitlist.ClearData();
}
}
//Name: IsRosterFull()
//Desc: Returns bool of if the m_roster is at capacity
//Precondition: None
//Postcondition: Returns bool
bool Class::IsRosterFull() {
// condition to check if the roster is full.
if (m_roster.Size() == ROSTER_MAX) {
return true;
}
return false;
}
//Name: IsWaitlistFull()
//Desc: Returns bool of if the m_waitlist is at capacity
//Precondition: None
//Postcondition: Returns bool
bool Class::IsWaitlistFull() {
// condition to check if the waitlist is full.
if (m_waitlist.Size() == WAIT_MAX) {
return true;
}
return false;
}
//Name: SearchClass
//Desc: Searches m_roster and m_waitlist for a string.
// If string exists in m_roster or m_waitlist, Class information printed
//Precondition: None
//Postcondition: Returns bool
bool Class::SearchClass(string item) {
// Searching for the student in the roster.
for(int i = 0; i < m_roster.Size(); i++) {
if ((m_roster[i]->GetFName() == item) || (m_roster[i]->GetLName() == item)) {
return true;
}
}
// Condition to avoid looping if the waitlist is empty
// for searching.
if (m_waitlist.IsEmpty() == 0) {
for(int i = 0; i < m_waitlist.Size(); i++) {
if ((m_waitlist[i]->GetFName() == item) || (m_waitlist[i]->GetLName() == item)) {
return true;
}
}
}
return false;
}
// Name: Overloaded <<
// Description: Prints the details of a Class (Class name and section)
// Preconditions: all variables are set valid
// Postconditions: returns an ostream with output of the Class
ostream& operator<<(ostream& out, Class& Classy) {
// outputting the class information.
out << "Course: " << Classy.GetName() << " Section: " << Classy.GetSection() << endl;
return out;
}
|
c5831d20378d74a845e9d75f22d2ab9b294fa403 | 74d94cb03b7f8a803363df30019bc4bf51557e46 | /FT_App_Metaball_Arduino/App_Metaballs/cf_ctouch.cpp | 94ccfc55dbc84a55170b8ab9267b3152f2378100 | [] | no_license | crystalfontz/CFA-FTDI-EVE2-ESP32-Examples | 0954cd12639e0773b7be091bee563aaad2fdc290 | 84bac3bda6a8ea0df0996746401eedc8a7edb16b | refs/heads/master | 2020-06-05T09:34:31.917061 | 2020-01-01T17:35:45 | 2020-01-01T17:35:45 | 192,394,189 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,633 | cpp | cf_ctouch.cpp | //============================================================================
//
// Add-on FT9xx library for original FTDI/BridgeTek EVE Arduino examples
//
// This source-code and minor modifications to the original FTDI examples
// is meant for use with the Crystalfontz CFA10100 based LCD modules which
// use a Goodix GT911 cap touch screen controller.
//
// 2019-06-01 Mark Williams / Crystalfontz
// 2018-11-21 Brent A. Crosby / Crystalfontz
//
//---------------------------------------------------------------------------
//
//This is free and unencumbered software released into the public domain.
//
//Anyone is free to copy, modify, publish, use, compile, sell, or
//distribute this software, either in source code form or as a compiled
//binary, for any purpose, commercial or non-commercial, and by any
//means.
//
//In jurisdictions that recognize copyright laws, the author or authors
//of this software dedicate any and all copyright interest in the
//software to the public domain. We make this dedication for the benefit
//of the public at large and to the detriment of our heirs and
//successors. We intend this dedication to be an overt act of
//relinquishment in perpetuity of all present and future rights to this
//software under copyright law.
//
//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 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.
//
//For more information, please refer to <http://unlicense.org/>
//============================================================================
#include "cf_ctouch.h"
#ifdef FT81X_CTOUCH
//============================================================================
//Apparently there is a "pen-up bug" in the FTDI.
//Magic binary data from FTDI supplied PC sample code
#define PEN_UP_BUG_FIX_INIT_DATA_LENGTH (1172)
const uint8_t Pen_Up_Bug_Fix_Init_Data[PEN_UP_BUG_FIX_INIT_DATA_LENGTH] PROGMEM =
{
26,255,255,255,32,32,48,0,4,0,0,0,2,0,0,0,34,255,255,255,0,176,48,0,120,218,237,84,255,107,92,69,16,159,125,155,107,
141,201,121,247,106,130,9,225,244,238,37,246,146,52,63,53,98,172,53,48,243,8,36,166,182,63,136,216,246,7,205,219,75,
122,119,185,139,196,128,34,33,136,123,65,240,7,31,44,105,41,69,72,12,210,166,6,17,12,104,64,165,73,133,134,98,80,74,
43,148,22,20,133,40,20,34,233,15,82,250,131,10,113,246,229,106,197,191,161,111,217,55,179,59,59,59,243,153,47,251,
135,15,58,204,11,109,114,89,149,84,169,242,172,2,109,10,73,53,167,92,158,89,21,6,89,230,236,126,86,89,206,242,169,
178,61,187,115,62,85,190,199,133,129,44,132,249,90,12,243,124,67,49,169,76,81,22,195,60,211,113,40,133,249,253,104,
114,113,148,197,131,105,169,158,3,19,132,65,28,187,240,25,112,3,147,99,235,163,80,98,63,10,123,181,208,73,213,29,24,
246,226,121,112,199,146,74,98,56,22,195,135,245,32,14,194,17,180,182,100,46,169,220,114,244,103,171,114,252,41,222,
143,97,150,53,64,167,202,110,240,86,186,45,16,90,14,191,158,110,196,163,216,130,241,232,159,42,251,88,4,169,90,80,42,
163,226,248,168,206,97,132,136,169,69,113,20,27,245,203,40,131,12,54,87,37,143,253,43,105,97,137,9,172,103,181,26,172,
79,163,102,184,142,57,83,0,61,139,144,159,79,135,193,62,61,0,157,250,5,20,186,67,91,255,133,238,140,104,167,30,192,197,
72,2,85,137,221,89,134,101,140,177,191,238,137,75,105,137,23,97,18,226,31,175,98,31,174,165,141,90,193,21,88,194,117,60,
207,243,115,248,202,254,171,171,37,248,20,87,112,17,59,180,59,246,35,199,177,83,175,35,140,93,224,187,172,45,169,172,
108,29,47,192,59,186,70,159,1,208,155,136,40,71,190,195,101,222,117,131,221,90,142,110,48,221,85,165,177,42,173,169,82,
89,165,78,149,138,136,110,224,13,108,200,0,132,1,50,103,114,55,176,145,254,51,132,208,183,177,137,64,111,128,192,13,104,
162,86,145,165,198,255,141,86,209,68,79,146,84,87,33,163,95,132,39,120,182,242,76,115,78,123,40,142,7,200,227,21,103,50,
103,171,109,123,27,242,115,193,0,197,176,70,63,141,125,212,35,14,8,95,28,20,246,116,155,30,132,152,118,3,40,29,162,62,
60,158,9,131,8,197,120,49,99,115,35,39,228,200,168,48,81,197,2,175,221,224,205,140,173,148,4,87,13,148,94,19,235,216,
205,62,212,179,14,199,221,234,21,223,207,112,254,163,90,169,197,247,50,110,249,16,249,156,113,137,83,98,146,163,23,
215,115,16,146,173,102,142,158,74,160,205,181,28,217,67,93,156,121,40,156,202,76,130,169,184,193,12,9,125,82,132,149,
121,209,65,219,198,12,47,80,7,15,182,163,97,52,171,206,211,20,186,229,195,148,42,15,137,45,116,244,29,188,138,105,177,
76,139,149,18,113,141,160,192,1,218,222,14,131,101,90,224,17,195,239,51,113,156,194,111,245,21,49,137,171,100,61,238,
21,166,50,67,95,83,63,154,202,71,116,141,45,205,208,37,94,133,188,186,201,177,134,82,86,117,84,109,46,137,52,237,214,
102,248,22,253,82,41,137,91,148,37,29,97,147,195,86,126,89,156,165,45,214,188,43,54,43,160,63,36,139,169,142,17,73,175,
31,255,230,232,164,175,244,161,197,38,71,118,121,70,109,226,43,252,14,100,249,142,135,180,156,48,185,45,172,176,247,71,
244,29,104,240,25,3,37,216,78,179,159,101,171,9,63,225,95,166,6,126,71,24,29,156,165,199,253,126,108,119,88,51,146,216,
19,191,137,102,191,107,186,68,109,78,247,244,95,130,99,94,134,49,183,128,158,84,207,58,245,129,9,220,145,78,16,218,85,
102,226,94,102,142,121,247,51,243,146,119,63,51,3,14,71,157,94,245,86,169,151,134,156,99,212,206,189,148,208,9,109,239,
43,242,125,57,135,249,19,111,120,245,182,79,121,218,62,110,231,222,203,57,220,245,52,237,217,126,246,253,183,89,95,59,
59,145,238,165,15,28,91,45,86,239,140,215,231,199,56,34,59,239,154,239,159,244,38,57,63,167,156,41,126,95,14,83,82,189,
203,183,244,51,186,33,39,12,234,244,105,156,79,111,161,100,186,232,37,25,187,195,253,252,137,35,245,2,243,54,207,243,8,
176,143,109,175,225,57,92,131,71,248,220,151,222,113,255,28,26,114,131,139,17,130,111,24,65,63,235,157,198,90,188,238,
213,251,63,120,130,59,151,187,130,95,193,207,252,26,214,221,175,215,240,186,211,85,217,197,107,67,123,113,15,217,42,252,
201,155,245,133,94,131,122,255,87,207,80,143,215,238,91,47,126,247,106,248,204,159,153,187,116,219,49,116,45,115,147,
182,48,242,4,190,240,127,118,224,193,247,224,3,89,247,15,148,99,211,103,26,255,255,255,20,33,48,0,4,0,0,0,15,0,0,0,26,
255,255,255,32,32,48,0,4,0,0,0,0,0,0,0
};
//----------------------------------------------------------------------------
void FT81x_Init_CTouch(Gpu_Hal_Context_t *phost)
{
//Sets up address, writes the data blob, and executes
Gpu_Hal_WrCmdBufFromFlash(phost, Pen_Up_Bug_Fix_Init_Data, PEN_UP_BUG_FIX_INIT_DATA_LENGTH);
/*
//"Straight AN_336"
//"Hold the touch engine in reset (write REG_CPURESET=2)"
Gpu_Hal_Wr8(phost, REG_CPURESET, 0x02);
//"Write REG_TOUCH_CONFIG=0x05D0"
Gpu_Hal_Wr16(phost, REG_TOUCH_CONFIG, 0x05D0);
//"Set GPIO0 output LOW"
// The CFA10100 FT813 uses GPIO3 to reset GT911
// Reset-Value is 0x8000 adding 0x0008 sets GPIO3 to output
// Default-value for REG_GPIOX is 0x8000 -> Low output on GPIO3
Gpu_Hal_Wr16(phost,REG_GPIOX_DIR,0x8008);
// "Wait more than 100us"
delay(1);
// "Write REG_CPURESET=0"
Gpu_Hal_Wr8(phost,REG_CPURESET, 0x00);
// "Wait more than 55ms"
delay(56);
// "Set GPIO0 to input (floating)"
// The CFA10100 FT813 uses GPIO3 to reset GT911
Gpu_Hal_Wr16(phost,REG_GPIOX_DIR,0x8000);
*/
//done
}
#endif
|
2a16dd8106f3e92cc3142de9e6910edf91c96feb | bc2820d426df282aa6f58362e4ec9a36c107b65b | /Luogu/P4777/4777.cpp | f284ddc2da4f9230f05c38effd81549bec4bc3e4 | [] | no_license | LuoshuiTianyi/Code | 22b2357aabe7ae203e63a3d371055c9654623d5f | 6df97d5b5a2be626f4c3456a40206e781fa545e2 | refs/heads/master | 2020-07-22T16:56:39.451380 | 2020-06-19T02:20:01 | 2020-06-19T02:20:01 | 207,263,820 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,412 | cpp | 4777.cpp | #include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
#define LL long long
#define go(G, x, i, v) \
for (int i = G.hd[x], v = G.to[i]; i; v = G.to[i = G.nx[i]])
#define inline __inline__ __attribute__((always_inline))
inline LL read() {
LL x = 0, w = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-') w = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar();
}
return x * w;
}
const int Max_n = 1e5 + 5;
int n;
LL x, M;
namespace Input {
void main() { n = read(); }
} // namespace Input
namespace Solve {
void exgcd(LL a, LL b, LL &x, LL &y) {
if (!b) {
x = 1, y = 0;
return;
}
exgcd(b, a % b, y, x), y = y - (a / b) * x;
}
void Mod(LL &x, LL mod) { x = x >= mod ? x - mod : x; }
LL Mul(LL a, LL b, LL mod) {
LL res = 0;
((a %= mod) += mod) %= mod;
for (; b; b >>= 1, Mod(a <<= 1, mod))
if (b & 1) Mod(res += a, mod);
return res;
}
void main() {
M = 1, x = 0;
while (n--) {
LL b = read(), a = read(), c = (a - x % b + b) % b, x1, x2;
LL gcd = __gcd(M, b);
exgcd(M, b, x1, x2);
x += Mul(x1, c / gcd, b / gcd) * M;
M = M * (b / gcd);
x = (x % M + M) % M;
}
cout << x;
}
} // namespace Solve
int main() {
#ifndef ONLINE_JUDGE
freopen("4777.in", "r", stdin);
freopen("4777.out", "w", stdout);
#endif
Input::main();
Solve::main();
}
|
721897cdc1c905030a390df2c0ff0865496e53f5 | e12b5e5ed708714040e484001519b4aaedae1c9f | /Codes/ActorsSpawns.cpp | de0b6b9ea57f5b7713dd7fe4f399d09d3d5b2b39 | [] | no_license | yahxemo/UE4 | 7a4e24fc5fa1588a06a302a054ba957dcf6727a6 | ed9fe88e51dace93d24e4d6ff6e1e2803f4e3c5b | refs/heads/master | 2022-12-09T04:27:48.007021 | 2020-09-17T08:36:37 | 2020-09-17T08:36:37 | 296,214,751 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 53 | cpp | ActorsSpawns.cpp | //#include "pch.h"
#include "ActorsSpawns.h"
|
4ff5107fced053b4b50c50fba2c7c413ea83c51a | 98edcfa08de8963387fa87f5ffb940460fd7b996 | /ScreenRecorderLib/internal_recorder.cpp | 51ebf8267420dde13af467d6aa035a68ed322b3c | [
"MIT"
] | permissive | wuharvey/windows-recorder | d2047376b6ba3c4ca6dbb38fbe032e2ffa3bbe35 | 2fe6339090e3e1f78c34fa653e14053d54b98e4b | refs/heads/master | 2023-02-02T03:01:43.800975 | 2020-12-11T17:04:45 | 2020-12-11T17:04:45 | 305,498,538 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 54,888 | cpp | internal_recorder.cpp | #include <ppltasks.h>
#include <ctime> // localtime
#include <sstream> // stringstream
#include <iomanip> // put_time
#include <string>
#include <comdef.h>
#include <Mferror.h>
#include <wrl.h>
#include <ScreenGrab.h>
#include <concrt.h>
#include <mfidl.h>
#include <VersionHelpers.h>
#include <Wmcodecdsp.h>
#include <filesystem>
#include "loopback_capture.h"
#include "internal_recorder.h"
#include "audio_prefs.h"
#include "log.h"
#include "utilities.h"
#include "cleanup.h"
#include "string_format.h"
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "D3D11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "Mfuuid.lib")
#pragma comment(lib, "Mfplat.lib")
#pragma comment(lib, "evr.lib")
#pragma comment(lib, "mfreadwrite.lib")
#pragma comment(lib, "Mf.lib")
#pragma comment(lib, "wmcodecdspuuid.lib")
using namespace std;
using namespace std::chrono;
using namespace concurrency;
using namespace DirectX;
INT64 g_LastMouseClickDurationRemaining;
INT g_MouseClickDetectionDurationMillis = 50;
UINT g_LastMouseClickButton;
// Driver types supported
D3D_DRIVER_TYPE gDriverTypes[] =
{
D3D_DRIVER_TYPE_HARDWARE,
D3D_DRIVER_TYPE_WARP,
D3D_DRIVER_TYPE_REFERENCE,
};
// Feature levels supported
D3D_FEATURE_LEVEL m_FeatureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_1
};
struct internal_recorder::TaskWrapper {
Concurrency::task<void> m_RecordTask;
Concurrency::cancellation_token_source m_RecordTaskCts;
};
internal_recorder::internal_recorder() :m_TaskWrapperImpl(make_unique<TaskWrapper>())
{
}
internal_recorder::~internal_recorder()
{
UnhookWindowsHookEx(m_Mousehook);
if (m_IsRecording) {
LOG("Recording is in progress while destructing, cancelling recording task and waiting for completion.");
m_TaskWrapperImpl->m_RecordTaskCts.cancel();
m_TaskWrapperImpl->m_RecordTask.wait();
}
}
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// MB1 click
if (wParam == WM_LBUTTONDOWN)
{
g_LastMouseClickButton = VK_LBUTTON;
g_LastMouseClickDurationRemaining = g_MouseClickDetectionDurationMillis;
}
else if (wParam == WM_RBUTTONDOWN)
{
g_LastMouseClickButton = VK_RBUTTON;
g_LastMouseClickDurationRemaining = g_MouseClickDetectionDurationMillis;
}
return CallNextHookEx(0, nCode, wParam, lParam);
}
void internal_recorder::SetVideoFps(UINT32 fps)
{
m_VideoFps = fps;
}
void internal_recorder::SetVideoBitrate(UINT32 bitrate)
{
m_VideoBitrate = bitrate;
}
void internal_recorder::SetVideoQuality(UINT32 quality)
{
m_VideoQuality = quality;
}
void internal_recorder::SetVideoBitrateMode(UINT32 mode) {
m_VideoBitrateControlMode = mode;
}
void internal_recorder::SetAudioBitrate(UINT32 bitrate)
{
m_AudioBitrate = bitrate;
}
void internal_recorder::SetAudioChannels(UINT32 channels)
{
m_AudioChannels = channels;
}
void internal_recorder::SetOutputDevice(std::wstring& string)
{
m_AudioOutputDevice = string;
}
void internal_recorder::SetInputDevice(std::wstring& string)
{
m_AudioInputDevice = string;
}
void internal_recorder::SetAudioEnabled(bool enabled)
{
m_IsAudioEnabled = enabled;
}
void internal_recorder::SetOutputDeviceEnabled(bool enabled)
{
m_IsOutputDeviceEnabled = enabled;
}
void internal_recorder::SetInputDeviceEnabled(bool enabled)
{
m_IsInputDeviceEnabled = enabled;
}
void internal_recorder::SetMousePointerEnabled(bool enabled)
{
m_IsMousePointerEnabled = enabled;
}
void internal_recorder::SetIsFastStartEnabled(bool enabled) {
m_IsMp4FastStartEnabled = enabled;
}
void internal_recorder::SetIsFragmentedMp4Enabled(bool enabled) {
m_IsFragmentedMp4Enabled = enabled;
}
void internal_recorder::SetIsHardwareEncodingEnabled(bool enabled) {
m_IsHardwareEncodingEnabled = enabled;
}
void internal_recorder::SetIsLowLatencyModeEnabled(bool enabled) {
m_IsLowLatencyModeEnabled = enabled;
}
void internal_recorder::SetDestRectangle(RECT rect)
{
if (rect.left % 2 != 0)
rect.left += 1;
if (rect.top % 2 != 0)
rect.top += 1;
if (rect.right % 2 != 0)
rect.right += 1;
if (rect.bottom % 2 != 0)
rect.bottom += 1;
m_DestRect = rect;
}
void internal_recorder::SetDisplayOutput(UINT32 output)
{
m_DisplayOutput = output;
}
void internal_recorder::SetDisplayOutput(std::wstring output)
{
m_DisplayOutputName = output;
}
void internal_recorder::SetRecorderMode(UINT32 mode)
{
m_RecorderMode = mode;
}
void internal_recorder::SetFixedFramerate(bool value)
{
m_IsFixedFramerate = value;
}
void internal_recorder::SetIsThrottlingDisabled(bool value) {
m_IsThrottlingDisabled = value;
}
void internal_recorder::SetH264EncoderProfile(UINT32 value) {
m_H264Profile = value;
}
void internal_recorder::SetDetectMouseClicks(bool value) {
m_IsMouseClicksDetected = value;
}
void internal_recorder::SetMouseClickDetectionLMBColor(std::string value) {
m_MouseClickDetectionLMBColor = value;
}
void internal_recorder::SetMouseClickDetectionRMBColor(std::string value) {
m_MouseClickDetectionRMBColor = value;
}
void internal_recorder::SetMouseClickDetectionRadius(int value) {
m_MouseClickDetectionRadius = value;
}
void internal_recorder::SetMouseClickDetectionDuration(int value) {
g_MouseClickDetectionDurationMillis = value;
}
void internal_recorder::SetMouseClickDetectionMode(UINT32 value) {
m_MouseClickDetectionMode = value;
}
void internal_recorder::SetSnapshotSaveFormat(GUID value) {
m_ImageEncoderFormat = value;
}
std::vector<BYTE> internal_recorder::MixAudio(std::vector<BYTE> &first, std::vector<BYTE> &second)
{
std::vector<BYTE> newvector;
size_t smaller;
if (first.size() >= second.size())
{
newvector.insert(newvector.end(), first.begin(), first.end());
smaller = second.size();
}
else
{
newvector.insert(newvector.end(), second.begin(), second.end());
smaller = first.size();
}
for (int i = 0; i < smaller; i += 2) {
short buf1A = first[i + 1];
short buf2A = first[i];
buf1A = (short)((buf1A & 0xff) << 8);
buf2A = (short)(buf2A & 0xff);
short buf1B = second[i + 1];
short buf2B = second[i];
buf1B = (short)((buf1B & 0xff) << 8);
buf2B = (short)(buf2B & 0xff);
short buf1C = (short)(buf1A + buf1B);
short buf2C = (short)(buf2A + buf2B);
short res = (short)(buf1C + buf2C);
newvector[i] = (BYTE)res;
newvector[i + 1] = (BYTE)(res >> 8);
}
return newvector;
}
std::wstring internal_recorder::GetImageExtension() {
if (m_ImageEncoderFormat == GUID_ContainerFormatPng) {
return L".png";
}
else if (m_ImageEncoderFormat == GUID_ContainerFormatJpeg) {
return L".jpg";
}
else if (m_ImageEncoderFormat == GUID_ContainerFormatBmp) {
return L".bmp";
}
else if (m_ImageEncoderFormat == GUID_ContainerFormatTiff) {
return L".tiff";
}
else {
ERR("Image encoder format not recognized, defaulting to .jpg extension");
return L".jpg";
}
}
std::wstring internal_recorder::GetVideoExtension() {
return L".mp4";
}
HRESULT internal_recorder::ConfigureOutputDir(std::wstring path) {
m_OutputFullPath = path;
wstring dir = path;
if (m_RecorderMode == MODE_SLIDESHOW) {
if (!dir.empty() && dir.back() != '\\')
dir += '\\';
}
LPWSTR directory = (LPWSTR)dir.c_str();
PathRemoveFileSpecW(directory);
std::error_code ec;
if (std::filesystem::exists(directory) || std::filesystem::create_directories(directory, ec))
{
LOG(L"output folder is ready");
m_OutputFolder = directory;
}
else
{
// Failed to create directory.
ERR(L"failed to create output folder");
if (RecordingFailedCallback != nullptr)
RecordingFailedCallback(L"Failed to create output folder: " + s2ws(ec.message()));
return E_FAIL;
}
if (m_RecorderMode == MODE_VIDEO || m_RecorderMode == MODE_SNAPSHOT) {
wstring ext = m_RecorderMode == MODE_VIDEO ? GetVideoExtension() : GetImageExtension();
LPWSTR pStrExtension = PathFindExtension(path.c_str());
if (pStrExtension == nullptr || pStrExtension[0] == 0)
{
m_OutputFullPath = m_OutputFolder + L"\\" + s2ws(CurrentTimeToFormattedString()) + ext;
}
}
return S_OK;
}
HRESULT internal_recorder::BeginRecording(IStream *stream) {
return BeginRecording(L"", stream);
}
HRESULT internal_recorder::BeginRecording(std::wstring path) {
return BeginRecording(path, nullptr);
}
HRESULT internal_recorder::BeginRecording(std::wstring path, IStream *stream) {
if (!IsWindows8OrGreater()) {
wstring errorText = L"Windows 8 or higher is required";
ERR(L"%ls", errorText);
RecordingFailedCallback(errorText);
return E_FAIL;
}
if (m_IsRecording) {
if (m_IsPaused) {
m_IsPaused = false;
if (RecordingStatusChangedCallback != nullptr)
RecordingStatusChangedCallback(STATUS_RECORDING);
}
return S_FALSE;
}
m_EncoderResult = S_FALSE;
m_LastFrameHadAudio = false;
m_FrameDelays.clear();
if (!path.empty()) {
RETURN_ON_BAD_HR(ConfigureOutputDir(path));
}
m_TaskWrapperImpl->m_RecordTaskCts = cancellation_token_source();
cancellation_token token = m_TaskWrapperImpl->m_RecordTaskCts.get_token();
if (m_IsMouseClicksDetected) {
switch (m_MouseClickDetectionMode)
{
default:
case MOUSE_DETECTION_MODE_POLLING: {
concurrency::create_task([this, token]() {
while (true) {
if (GetKeyState(VK_LBUTTON) < 0)
{
//If left mouse button is held, reset the duration of click duration
g_LastMouseClickButton = VK_LBUTTON;
g_LastMouseClickDurationRemaining = g_MouseClickDetectionDurationMillis;
}
else if (GetKeyState(VK_RBUTTON) < 0)
{
//If right mouse button is held, reset the duration of click duration
g_LastMouseClickButton = VK_RBUTTON;
g_LastMouseClickDurationRemaining = g_MouseClickDetectionDurationMillis;
}
if (token.is_canceled()) {
break;
}
wait(1);
}
LOG("Exiting mouse click polling task");
});
break;
}
case MOUSE_DETECTION_MODE_HOOK: {
m_Mousehook = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, nullptr, 0);
break;
}
}
}
m_TaskWrapperImpl->m_RecordTask = concurrency::create_task([this, token, stream]() {
HRESULT hr = CoInitializeEx(nullptr, COINITBASE_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
RETURN_ON_BAD_HR(hr = MFStartup(MF_VERSION, MFSTARTUP_LITE));
{
DXGI_OUTDUPL_DESC outputDuplDesc;
RtlZeroMemory(&outputDuplDesc, sizeof(outputDuplDesc));
CComPtr<IDXGIOutputDuplication> pDeskDupl = nullptr;
std::unique_ptr<mouse_pointer> pMousePointer = make_unique<mouse_pointer>();
std::unique_ptr<loopback_capture> pLoopbackCaptureOutputDevice = make_unique<loopback_capture>();
std::unique_ptr<loopback_capture> pLoopbackCaptureInputDevice = make_unique<loopback_capture>();
CComPtr<IDXGIOutput> pSelectedOutput = nullptr;
hr = GetOutputForDeviceName(m_DisplayOutputName, &pSelectedOutput);
RETURN_ON_BAD_HR(hr = InitializeDx(pSelectedOutput, &m_ImmediateContext, &m_Device, &pDeskDupl, &outputDuplDesc));
DXGI_MODE_ROTATION screenRotation = outputDuplDesc.Rotation;
D3D11_TEXTURE2D_DESC sourceFrameDesc;
D3D11_TEXTURE2D_DESC destFrameDesc;
RECT sourceRect, destRect;
RtlZeroMemory(&destFrameDesc, sizeof(destFrameDesc));
RtlZeroMemory(&sourceFrameDesc, sizeof(sourceFrameDesc));
RtlZeroMemory(&sourceRect, sizeof(sourceRect));
RtlZeroMemory(&destRect, sizeof(destRect));
RETURN_ON_BAD_HR(hr = initializeDesc(outputDuplDesc, &sourceFrameDesc, &destFrameDesc, &sourceRect, &destRect));
bool isDestRectEqualToSourceRect = EqualRect(&sourceRect, &destRect);
// create "loopback audio capture has started" events
HANDLE hOutputCaptureStartedEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (nullptr == hOutputCaptureStartedEvent) {
ERR(L"CreateEvent failed: last error is %u", GetLastError());
return E_FAIL;
}
HANDLE hInputCaptureStartedEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (nullptr == hInputCaptureStartedEvent) {
ERR(L"CreateEvent failed: last error is %u", GetLastError());
return E_FAIL;
}
CloseHandleOnExit closeOutputCaptureStartedEvent(hOutputCaptureStartedEvent);
CloseHandleOnExit closeInputCaptureStartedEvent(hInputCaptureStartedEvent);
// create "stop capturing audio now" events
HANDLE hOutputCaptureStopEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (nullptr == hOutputCaptureStopEvent) {
ERR(L"CreateEvent failed: last error is %u", GetLastError());
return E_FAIL;
}
HANDLE hInputCaptureStopEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (nullptr == hInputCaptureStopEvent) {
ERR(L"CreateEvent failed: last error is %u", GetLastError());
return E_FAIL;
}
CloseHandleOnExit closeOutputCaptureStopEvent(hOutputCaptureStopEvent);
CloseHandleOnExit closeInputCaptureStopEvent(hInputCaptureStopEvent);
bool recordAudio = m_RecorderMode == MODE_VIDEO && m_IsAudioEnabled;
if (recordAudio && m_IsOutputDeviceEnabled)
{
bool isDeviceEmpty = m_AudioOutputDevice.empty();
LPCWSTR argv[3] = { L"", L"--device", m_AudioOutputDevice.c_str() };
int argc = isDeviceEmpty ? 1 : SIZEOF_ARRAY(argv);
CPrefs prefs(argc, isDeviceEmpty ? nullptr : argv, hr, eRender);
if (SUCCEEDED(hr)) {
prefs.m_bInt16 = true;
// create arguments for loopback capture thread
LoopbackCaptureThreadFunctionArguments threadArgs;
threadArgs.hr = E_UNEXPECTED; // thread will overwrite this
threadArgs.pMMDevice = prefs.m_pMMDevice;
threadArgs.pCaptureInstance = pLoopbackCaptureOutputDevice.get();
threadArgs.bInt16 = prefs.m_bInt16;
threadArgs.hFile = prefs.m_hFile;
threadArgs.hStartedEvent = hOutputCaptureStartedEvent;
threadArgs.hStopEvent = hOutputCaptureStopEvent;
threadArgs.nFrames = 0;
threadArgs.flow = eRender;
threadArgs.samplerate = 0;
threadArgs.channels = m_AudioChannels;
threadArgs.tag = L"AudioOutputDevice";
HANDLE hThread = CreateThread(
nullptr, 0,
LoopbackCaptureThreadFunction, &threadArgs, 0, nullptr
);
if (nullptr == hThread) {
ERR(L"CreateThread failed: last error is %u", GetLastError());
return E_FAIL;
}
WaitForSingleObjectEx(hOutputCaptureStartedEvent, 1000, false);
m_InputAudioSamplesPerSecond = pLoopbackCaptureOutputDevice->GetInputSampleRate();
CloseHandle(hThread);
}
}
if (recordAudio && m_IsInputDeviceEnabled)
{
bool isDeviceEmpty = m_AudioInputDevice.empty();
LPCWSTR argv[3] = { L"", L"--device", m_AudioInputDevice.c_str() };
int argc = isDeviceEmpty ? 1 : SIZEOF_ARRAY(argv);
CPrefs prefs(argc, isDeviceEmpty ? nullptr : argv, hr, eCapture);
if (SUCCEEDED(hr)) {
prefs.m_bInt16 = true;
// create arguments for loopback capture thread
LoopbackCaptureThreadFunctionArguments threadArgs;
threadArgs.hr = E_UNEXPECTED; // thread will overwrite this
threadArgs.pMMDevice = prefs.m_pMMDevice;
threadArgs.pCaptureInstance = pLoopbackCaptureInputDevice.get();
threadArgs.bInt16 = prefs.m_bInt16;
threadArgs.hFile = prefs.m_hFile;
threadArgs.hStartedEvent = hInputCaptureStartedEvent;
threadArgs.hStopEvent = hInputCaptureStopEvent;
threadArgs.nFrames = 0;
threadArgs.flow = eCapture;
threadArgs.samplerate = 0;
threadArgs.channels = m_AudioChannels;
threadArgs.tag = L"AudioInputDevice";
if (m_IsOutputDeviceEnabled)
{
threadArgs.samplerate = m_InputAudioSamplesPerSecond;
}
HANDLE hThread = CreateThread(
nullptr, 0,
LoopbackCaptureThreadFunction, &threadArgs, 0, nullptr
);
if (nullptr == hThread) {
ERR(L"CreateThread failed: last error is %u", GetLastError());
return E_FAIL;
}
WaitForSingleObjectEx(hInputCaptureStartedEvent, 1000, false);
m_InputAudioSamplesPerSecond = pLoopbackCaptureInputDevice->GetInputSampleRate();
CloseHandle(hThread);
}
}
if (recordAudio && m_IsOutputDeviceEnabled && m_IsInputDeviceEnabled)
{
m_InputAudioSamplesPerSecond = pLoopbackCaptureOutputDevice->GetInputSampleRate();
}
// moved this section after sound initialization to get right m_InputAudioSamplesPerSecond from pLoopbackCapture before InitializeVideoSinkWriter
if (m_RecorderMode == MODE_VIDEO) {
CComPtr<IMFByteStream> outputStream = nullptr;
if (stream != nullptr) {
RETURN_ON_BAD_HR(hr = MFCreateMFByteStreamOnStream(stream, &outputStream));
}
RETURN_ON_BAD_HR(hr = InitializeVideoSinkWriter(m_OutputFullPath, outputStream, m_Device, sourceRect, destRect, outputDuplDesc.Rotation, &m_SinkWriter, &m_VideoStreamIndex, &m_AudioStreamIndex));
}
m_IsRecording = true;
if (RecordingStatusChangedCallback != nullptr)
RecordingStatusChangedCallback(STATUS_RECORDING);
RETURN_ON_BAD_HR(hr = pMousePointer->Initialize(m_ImmediateContext, m_Device));
SetViewPort(m_ImmediateContext, sourceRect.right - sourceRect.left, sourceRect.bottom - sourceRect.top);
g_LastMouseClickDurationRemaining = 0;
INT64 lastFrameStartPos = 0;
pLoopbackCaptureOutputDevice->ClearRecordedBytes();
pLoopbackCaptureInputDevice->ClearRecordedBytes();
bool gotMousePointer = false;
INT64 videoFrameDurationMillis = 1000 / m_VideoFps;
INT64 videoFrameDuration100Nanos = MillisToHundredNanos(videoFrameDurationMillis);
INT frameTimeout = 0;
INT frameNr = 0;
CComPtr<ID3D11Texture2D> pPreviousFrameCopy = nullptr;
std::chrono::high_resolution_clock::time_point lastFrame = std::chrono::high_resolution_clock::now();
mouse_pointer::PTR_INFO PtrInfo;
RtlZeroMemory(&PtrInfo, sizeof(PtrInfo));
while (true)
{
CComPtr<IDXGIResource> pDesktopResource = nullptr;
DXGI_OUTDUPL_FRAME_INFO FrameInfo;
RtlZeroMemory(&FrameInfo, sizeof(FrameInfo));
if (token.is_canceled()) {
hr = S_OK;
break;
}
if (m_IsPaused) {
wait(10);
lastFrame = high_resolution_clock::now();
pLoopbackCaptureOutputDevice->ClearRecordedBytes();
pLoopbackCaptureInputDevice->ClearRecordedBytes();
continue;
}
if (pDeskDupl) {
pDeskDupl->ReleaseFrame();
// Get new frame
hr = pDeskDupl->AcquireNextFrame(
frameTimeout,
&FrameInfo,
&pDesktopResource);
// Get mouse info
gotMousePointer = SUCCEEDED(pMousePointer->GetMouse(&PtrInfo, &(FrameInfo), sourceRect, pDeskDupl));
}
if (pDeskDupl == nullptr
|| hr == DXGI_ERROR_ACCESS_LOST
|| hr == DXGI_ERROR_INVALID_CALL) {
if (pDeskDupl) {
pDeskDupl->ReleaseFrame();
pDeskDupl.Release();
}
_com_error err(hr);
ERR(L"Error getting next frame, reinitializing: %s\n", err.ErrorMessage());
hr = InitializeDesktopDupl(m_Device, pSelectedOutput, &pDeskDupl, &outputDuplDesc);
if (FAILED(hr))
{
_com_error err(hr);
ERR(L"Error reinitializing desktop duplication: %s\n", err.ErrorMessage());
if (hr == E_ACCESSDENIED) {
//Access to video output is denied, probably due to DRM, screen saver, fullscreen application or similar.
//We continue the recording, and instead of desktop texture just add a blank texture instead.
hr = S_OK;
}
}
RETURN_ON_BAD_HR(hr);
}
if (hr == DXGI_ERROR_DEVICE_REMOVED) {
return m_Device->GetDeviceRemovedReason();
}
if (m_RecorderMode == MODE_SLIDESHOW
|| m_RecorderMode == MODE_SNAPSHOT) {
if (frameNr == 0 && FrameInfo.AccumulatedFrames == 0) {
continue;
}
}
INT64 durationSinceLastFrame100Nanos = max(duration_cast<nanoseconds>(chrono::high_resolution_clock::now() - lastFrame).count() / 100, 0);
if (frameNr > 0 //always draw first frame
&& !m_IsFixedFramerate
&& (!m_IsMousePointerEnabled || FrameInfo.PointerShapeBufferSize == 0)//always redraw when pointer changes if we draw pointer
&& ((hr == DXGI_ERROR_WAIT_TIMEOUT && durationSinceLastFrame100Nanos < m_MaxFrameLength100Nanos) //don't wait on timeout if the frame duration is > m_MaxFrameLength100Nanos
|| durationSinceLastFrame100Nanos < videoFrameDuration100Nanos)) //wait if frame timeouted or duration is under our chosen framerate
{
bool delay = false;
if (SUCCEEDED(hr) && durationSinceLastFrame100Nanos < videoFrameDuration100Nanos) {
if (pDesktopResource != nullptr) {
//we got a frame, but it's too soon, so we cache it and see if there are more changes.
if (pPreviousFrameCopy == nullptr) {
RETURN_ON_BAD_HR(hr = m_Device->CreateTexture2D(&sourceFrameDesc, nullptr, &pPreviousFrameCopy));
}
CComPtr<ID3D11Texture2D> pAcquiredDesktopImage = nullptr;
RETURN_ON_BAD_HR(hr = pDesktopResource->QueryInterface(IID_PPV_ARGS(&pAcquiredDesktopImage)));
m_ImmediateContext->CopyResource(pPreviousFrameCopy, pAcquiredDesktopImage);
pAcquiredDesktopImage.Release();
}
delay = true;
}
else if (hr == DXGI_ERROR_WAIT_TIMEOUT) {
if (durationSinceLastFrame100Nanos < m_MaxFrameLength100Nanos) {
delay = true;
}
}
if (delay) {
UINT64 delay = 1;
if (durationSinceLastFrame100Nanos < videoFrameDuration100Nanos) {
delay = HundredNanosToMillis((videoFrameDuration100Nanos - durationSinceLastFrame100Nanos));
}
wait(delay);
continue;
}
}
if (pPreviousFrameCopy && hr != DXGI_ERROR_WAIT_TIMEOUT) {
pPreviousFrameCopy.Release();
}
lastFrame = high_resolution_clock::now();
{
CComPtr<ID3D11Texture2D> pFrameCopy = nullptr;
RETURN_ON_BAD_HR(hr = m_Device->CreateTexture2D(&sourceFrameDesc, nullptr, &pFrameCopy));
if (pPreviousFrameCopy) {
m_ImmediateContext->CopyResource(pFrameCopy, pPreviousFrameCopy);
}
else if (pDesktopResource != nullptr) {
CComPtr<ID3D11Texture2D> pAcquiredDesktopImage = nullptr;
RETURN_ON_BAD_HR(hr = pDesktopResource->QueryInterface(IID_PPV_ARGS(&pAcquiredDesktopImage)));
m_ImmediateContext->CopyResource(pFrameCopy, pAcquiredDesktopImage);
}
SetDebugName(pFrameCopy, "FrameCopy");
if (pPreviousFrameCopy == nullptr
&& m_RecorderMode == MODE_VIDEO || m_RecorderMode == MODE_SLIDESHOW) {
RETURN_ON_BAD_HR(hr = m_Device->CreateTexture2D(&sourceFrameDesc, nullptr, &pPreviousFrameCopy));
m_ImmediateContext->CopyResource(pPreviousFrameCopy, pFrameCopy);
SetDebugName(pPreviousFrameCopy, "PreviousFrameCopy");
}
if (gotMousePointer) {
hr = DrawMousePointer(pFrameCopy, pMousePointer.get(), PtrInfo, screenRotation, durationSinceLastFrame100Nanos);
if (hr == DXGI_ERROR_ACCESS_LOST
|| hr == DXGI_ERROR_INVALID_CALL) {
if (pDeskDupl) {
pDeskDupl->ReleaseFrame();
pDeskDupl.Release();
}
_com_error err(hr);
ERR(L"Error drawing mouse pointer, reinitializing desktop duplication: %s\n", err.ErrorMessage());
hr = InitializeDesktopDupl(m_Device, pSelectedOutput, &pDeskDupl, &outputDuplDesc);
if (FAILED(hr))
{
_com_error err(hr);
ERR(L"Reinitialize desktop duplication error: %s\n", err.ErrorMessage());
}
if (hr != E_ACCESSDENIED) {
RETURN_ON_BAD_HR(hr);
}
wait(1);
continue;
}
}
if (token.is_canceled()) {
hr = S_OK;
break;
}
if ((m_RecorderMode == MODE_SLIDESHOW || m_RecorderMode == MODE_SNAPSHOT) && !isDestRectEqualToSourceRect) {
pFrameCopy = CropFrame(pFrameCopy, destFrameDesc, destRect);
}
FrameWriteModel model;
RtlZeroMemory(&model, sizeof(model));
model.Frame = pFrameCopy;
model.Duration = durationSinceLastFrame100Nanos;
model.StartPos = lastFrameStartPos;
model.Audio = recordAudio ? GrabAudioFrame(pLoopbackCaptureOutputDevice, pLoopbackCaptureInputDevice) : std::vector<BYTE>();
model.FrameNumber = frameNr;
hr = m_EncoderResult = RenderFrame(model);
if (FAILED(hr)) {
break;
}
if (m_RecorderMode == MODE_SNAPSHOT) {
break;
}
frameNr++;
lastFrameStartPos += durationSinceLastFrame100Nanos;
if (m_IsFixedFramerate)
{
wait(static_cast<UINT32>(videoFrameDurationMillis));
}
}
}
//Push the last frame waiting to be recorded to the sink writer.
if (pPreviousFrameCopy != nullptr) {
INT64 duration = duration_cast<nanoseconds>(chrono::high_resolution_clock::now() - lastFrame).count() / 100;
if (gotMousePointer) {
DrawMousePointer(pPreviousFrameCopy, pMousePointer.get(), PtrInfo, screenRotation, duration);
}
if ((m_RecorderMode == MODE_SLIDESHOW || m_RecorderMode == MODE_SNAPSHOT) && !isDestRectEqualToSourceRect) {
pPreviousFrameCopy = CropFrame(pPreviousFrameCopy, destFrameDesc, destRect);
}
FrameWriteModel model;
RtlZeroMemory(&model, sizeof(model));
model.Frame = pPreviousFrameCopy;
model.Duration = duration;
model.StartPos = lastFrameStartPos;
model.Audio = recordAudio ? GrabAudioFrame(pLoopbackCaptureOutputDevice, pLoopbackCaptureInputDevice) : std::vector<BYTE>();
model.FrameNumber = frameNr;
hr = m_EncoderResult = RenderFrame(model);
}
SetEvent(hOutputCaptureStopEvent);
SetEvent(hInputCaptureStopEvent);
if (RecordingStatusChangedCallback != nullptr)
RecordingStatusChangedCallback(STATUS_FINALIZING);
pDeskDupl->ReleaseFrame();
if (pPreviousFrameCopy)
pPreviousFrameCopy.Release();
if (pMousePointer) {
pMousePointer->CleanupResources();
}
if (PtrInfo.PtrShapeBuffer)
delete PtrInfo.PtrShapeBuffer;
PtrInfo.PtrShapeBuffer = nullptr;
}
LOG("Exiting recording task");
return hr;
})
.then([this, token](HRESULT hr) {
m_IsRecording = false;
if (m_SinkWriter) {
hr = m_SinkWriter->Finalize();
if (FAILED(hr)) {
ERR("Failed to finalize sink writer");
}
//Dispose of MPEG4MediaSink
IMFMediaSink *pSink;
if (SUCCEEDED(m_SinkWriter->GetServiceForStream(MF_SINK_WRITER_MEDIASINK, GUID_NULL, IID_PPV_ARGS(&pSink)))) {
hr = pSink->Shutdown();
if (FAILED(hr)) {
ERR("Failed to shut down IMFMediaSink");
}
};
SafeRelease(&m_SinkWriter);
}
SafeRelease(&m_ImmediateContext);
SafeRelease(&m_Device);
#if _DEBUG
if (m_Debug) {
m_Debug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
SafeRelease(&m_Debug);
}
#endif
return hr;
})
.then([this](concurrency::task<HRESULT> t)
{
LOG(L"Finalized!");
MFShutdown();
CoUninitialize();
LOG(L"MF shut down!");
std::wstring errMsg = L"";
bool success = false;
try {
HRESULT hr = t.get();
// .get() didn't throw, so we succeeded.
success = SUCCEEDED(hr);
if (!success) {
_com_error err(hr);
errMsg = err.ErrorMessage();
}
}
catch (const exception & e) {
// handle error
ERR(L"Exception in RecordTask: %s", e.what());
}
catch (...) {
ERR(L"Exception in RecordTask");
}
if (RecordingStatusChangedCallback)
RecordingStatusChangedCallback(STATUS_IDLE);
if (success) {
if (RecordingCompleteCallback)
RecordingCompleteCallback(m_OutputFullPath, m_FrameDelays);
}
else {
if (RecordingFailedCallback) {
if (FAILED(m_EncoderResult)) {
_com_error encoderFailure(m_EncoderResult);
errMsg = string_format(L"Write error (0x%lx) in video encoder: %s", m_EncoderResult, encoderFailure.ErrorMessage());
if (m_IsHardwareEncodingEnabled) {
errMsg += L" If the problem persists, disabling hardware encoding may improve stability.";
}
}
else {
if (errMsg.empty()) {
errMsg = GetLastErrorStdWstr();
}
}
RecordingFailedCallback(errMsg);
}
}
UnhookWindowsHookEx(m_Mousehook);
});
return S_OK;
}
void internal_recorder::EndRecording() {
if (m_IsRecording) {
m_IsPaused = false;
m_TaskWrapperImpl->m_RecordTaskCts.cancel();
}
}
void internal_recorder::PauseRecording() {
if (m_IsRecording) {
m_IsPaused = true;
if (RecordingStatusChangedCallback != nullptr)
RecordingStatusChangedCallback(STATUS_PAUSED);
}
}
void internal_recorder::ResumeRecording() {
if (m_IsRecording) {
if (m_IsPaused) {
m_IsPaused = false;
if (RecordingStatusChangedCallback != nullptr)
RecordingStatusChangedCallback(STATUS_RECORDING);
}
}
}
std::vector<BYTE> internal_recorder::GrabAudioFrame(std::unique_ptr<loopback_capture> & pLoopbackCaptureOutputDevice,
std::unique_ptr<loopback_capture> & pLoopbackCaptureInputDevice)
{
if (m_IsOutputDeviceEnabled && m_IsInputDeviceEnabled && pLoopbackCaptureOutputDevice && pLoopbackCaptureInputDevice) {
// mix our audio buffers from output device and input device to get one audio buffer since VideoSinkWriter works only with one Audio sink
if (pLoopbackCaptureOutputDevice->PeakRecordedBytes().size() > 0) {
std::vector<BYTE> outputDeviceData = pLoopbackCaptureOutputDevice->GetRecordedBytes(0);
std::vector<BYTE> inputDeviceData = pLoopbackCaptureInputDevice->GetRecordedBytes(outputDeviceData.size());
return std::move(MixAudio(outputDeviceData, inputDeviceData));
}
else {
std::vector<BYTE> inputDeviceData = pLoopbackCaptureInputDevice->GetRecordedBytes();
std::vector<BYTE> outputDeviceData = pLoopbackCaptureOutputDevice->GetRecordedBytes(inputDeviceData.size());
return std::move(MixAudio(outputDeviceData, inputDeviceData));
}
}
else if (m_IsOutputDeviceEnabled && pLoopbackCaptureOutputDevice)
return std::move(pLoopbackCaptureOutputDevice->GetRecordedBytes());
else if (m_IsInputDeviceEnabled && pLoopbackCaptureInputDevice)
return std::move(pLoopbackCaptureInputDevice->GetRecordedBytes());
else
return std::vector<BYTE>();
}
HRESULT internal_recorder::initializeDesc(DXGI_OUTDUPL_DESC outputDuplDesc, _Out_ D3D11_TEXTURE2D_DESC * pSourceFrameDesc, _Out_ D3D11_TEXTURE2D_DESC * pDestFrameDesc, _Out_ RECT * pSourceRect, _Out_ RECT * pDestRect) {
UINT monitorWidth = (outputDuplDesc.Rotation == DXGI_MODE_ROTATION_ROTATE90 || outputDuplDesc.Rotation == DXGI_MODE_ROTATION_ROTATE270)
? outputDuplDesc.ModeDesc.Height : outputDuplDesc.ModeDesc.Width;
UINT monitorHeight = (outputDuplDesc.Rotation == DXGI_MODE_ROTATION_ROTATE90 || outputDuplDesc.Rotation == DXGI_MODE_ROTATION_ROTATE270)
? outputDuplDesc.ModeDesc.Width : outputDuplDesc.ModeDesc.Height;
RECT sourceRect;
sourceRect.left = 0;
sourceRect.right = monitorWidth;
sourceRect.top = 0;
sourceRect.bottom = monitorHeight;
RECT destRect = sourceRect;
if (m_DestRect.right != 0
|| m_DestRect.top != 0
|| m_DestRect.bottom != 0
|| m_DestRect.left != 0)
{
destRect = m_DestRect;
}
D3D11_TEXTURE2D_DESC sourceFrameDesc;
sourceFrameDesc.Width = monitorWidth;
sourceFrameDesc.Height = monitorHeight;
sourceFrameDesc.Format = outputDuplDesc.ModeDesc.Format;
sourceFrameDesc.ArraySize = 1;
sourceFrameDesc.BindFlags = D3D11_BIND_FLAG::D3D11_BIND_RENDER_TARGET;
sourceFrameDesc.MiscFlags = 0;
sourceFrameDesc.SampleDesc.Count = 1;
sourceFrameDesc.SampleDesc.Quality = 0;
sourceFrameDesc.MipLevels = 1;
sourceFrameDesc.CPUAccessFlags = 0;
sourceFrameDesc.Usage = D3D11_USAGE_DEFAULT;
D3D11_TEXTURE2D_DESC destFrameDesc;
destFrameDesc.Width = destRect.right - destRect.left;
destFrameDesc.Height = destRect.bottom - destRect.top;
destFrameDesc.Format = outputDuplDesc.ModeDesc.Format;
destFrameDesc.ArraySize = 1;
destFrameDesc.BindFlags = D3D11_BIND_FLAG::D3D11_BIND_RENDER_TARGET;
destFrameDesc.MiscFlags = 0;
destFrameDesc.SampleDesc.Count = 1;
destFrameDesc.SampleDesc.Quality = 0;
destFrameDesc.MipLevels = 1;
destFrameDesc.CPUAccessFlags = 0;
destFrameDesc.Usage = D3D11_USAGE_DEFAULT;
*pSourceRect = sourceRect;
*pDestRect = destRect;
*pSourceFrameDesc = sourceFrameDesc;
*pDestFrameDesc = destFrameDesc;
return S_OK;
}
HRESULT internal_recorder::InitializeDx(_In_opt_ IDXGIOutput * pDxgiOutput, _Outptr_ ID3D11DeviceContext * *ppContext, _Outptr_ ID3D11Device * *ppDevice, _Outptr_ IDXGIOutputDuplication * *ppDesktopDupl, _Out_ DXGI_OUTDUPL_DESC * pOutputDuplDesc) {
*ppContext = nullptr;
*ppDevice = nullptr;
*ppDesktopDupl = nullptr;
HRESULT hr(S_OK);
DXGI_OUTDUPL_DESC OutputDuplDesc;
RtlZeroMemory(&OutputDuplDesc, sizeof(OutputDuplDesc));
CComPtr<ID3D11DeviceContext> m_ImmediateContext = nullptr;
CComPtr<ID3D11Device> pDevice = nullptr;
CComPtr<IDXGIOutputDuplication> pDeskDupl = nullptr;
int lresult(-1);
D3D_FEATURE_LEVEL featureLevel;
CComPtr<IDXGIAdapter> pDxgiAdapter = nullptr;
if (pDxgiOutput) {
// Get DXGI adapter
hr = pDxgiOutput->GetParent(
__uuidof(IDXGIAdapter),
reinterpret_cast<void**>(&pDxgiAdapter));
}
std::vector<D3D_DRIVER_TYPE> driverTypes;
if (pDxgiAdapter) {
driverTypes.push_back(D3D_DRIVER_TYPE_UNKNOWN);
}
else
{
for each (D3D_DRIVER_TYPE type in gDriverTypes)
{
driverTypes.push_back(type);
}
}
UINT numDriverTypes = driverTypes.size();
UINT creationFlagsDebug = D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_DEBUG;
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
// Create devices
for (UINT DriverTypeIndex = 0; DriverTypeIndex < numDriverTypes; ++DriverTypeIndex)
{
hr = D3D11CreateDevice(
pDxgiAdapter,
driverTypes[DriverTypeIndex],
nullptr,
#if _DEBUG
creationFlagsDebug,
#else
creationFlags,
#endif
m_FeatureLevels,
ARRAYSIZE(m_FeatureLevels),
D3D11_SDK_VERSION,
&pDevice,
&featureLevel,
&m_ImmediateContext);
if (SUCCEEDED(hr))
{
#if _DEBUG
HRESULT hr = pDevice->QueryInterface(IID_PPV_ARGS(&m_Debug));
#endif
// Device creation success, no need to loop anymore
break;
}
}
RETURN_ON_BAD_HR(hr);
CComPtr<ID3D10Multithread> pMulti = nullptr;
hr = m_ImmediateContext->QueryInterface(IID_PPV_ARGS(&pMulti));
RETURN_ON_BAD_HR(hr);
pMulti->SetMultithreadProtected(TRUE);
pMulti.Release();
if (pDevice == nullptr)
return E_FAIL;
hr = InitializeDesktopDupl(pDevice, pDxgiOutput, &pDeskDupl, &OutputDuplDesc);
RETURN_ON_BAD_HR(hr);
// Return the pointer to the caller.
*ppContext = m_ImmediateContext;
(*ppContext)->AddRef();
*ppDevice = pDevice;
(*ppDevice)->AddRef();
*ppDesktopDupl = pDeskDupl;
(*ppDesktopDupl)->AddRef();
*pOutputDuplDesc = OutputDuplDesc;
return hr;
}
HRESULT internal_recorder::InitializeDesktopDupl(_In_ ID3D11Device * pDevice, _In_opt_ IDXGIOutput * pDxgiOutput, _Outptr_ IDXGIOutputDuplication * *ppDesktopDupl, _Out_ DXGI_OUTDUPL_DESC * pOutputDuplDesc) {
*ppDesktopDupl = nullptr;
// Get DXGI device
CComPtr<IDXGIDevice> pDxgiDevice = nullptr;
CComPtr<IDXGIOutputDuplication> pDeskDupl = nullptr;
DXGI_OUTDUPL_DESC OutputDuplDesc;
RtlZeroMemory(&OutputDuplDesc, sizeof(OutputDuplDesc));
HRESULT hr = S_OK;
if (!pDxgiOutput) {
hr = pDevice->QueryInterface(IID_PPV_ARGS(&pDxgiDevice));
RETURN_ON_BAD_HR(hr);
// Get DXGI adapter
CComPtr<IDXGIAdapter> pDxgiAdapter = nullptr;
hr = pDxgiDevice->GetParent(
__uuidof(IDXGIAdapter),
reinterpret_cast<void**>(&pDxgiAdapter));
pDxgiDevice.Release();
RETURN_ON_BAD_HR(hr);
// Get pDxgiOutput
hr = pDxgiAdapter->EnumOutputs(
m_DisplayOutput,
&pDxgiOutput);
RETURN_ON_BAD_HR(hr);
pDxgiAdapter.Release();
}
RETURN_ON_BAD_HR(hr);
CComPtr<IDXGIOutput1> pDxgiOutput1 = nullptr;
hr = pDxgiOutput->QueryInterface(IID_PPV_ARGS(&pDxgiOutput1));
RETURN_ON_BAD_HR(hr);
// Create desktop duplication
hr = pDxgiOutput1->DuplicateOutput(
pDevice,
&pDeskDupl);
RETURN_ON_BAD_HR(hr);
pDxgiOutput1.Release();
// Create GUI drawing texture
pDeskDupl->GetDesc(&OutputDuplDesc);
*ppDesktopDupl = pDeskDupl;
(*ppDesktopDupl)->AddRef();
*pOutputDuplDesc = OutputDuplDesc;
return hr;
}
//
// Set new viewport
//
void internal_recorder::SetViewPort(ID3D11DeviceContext * deviceContext, UINT Width, UINT Height)
{
D3D11_VIEWPORT VP;
VP.Width = static_cast<FLOAT>(Width);
VP.Height = static_cast<FLOAT>(Height);
VP.MinDepth = 0.0f;
VP.MaxDepth = 1.0f;
VP.TopLeftX = 0;
VP.TopLeftY = 0;
deviceContext->RSSetViewports(1, &VP);
}
HRESULT internal_recorder::GetOutputForDeviceName(std::wstring deviceName, _Outptr_opt_result_maybenull_ IDXGIOutput * *ppOutput) {
HRESULT hr = S_OK;
*ppOutput = nullptr;
if (deviceName != L"") {
std::vector<CComPtr<IDXGIAdapter>> adapters = EnumDisplayAdapters();
for each (CComPtr<IDXGIAdapter> adapter in adapters)
{
IDXGIOutput *pOutput;
int i = 0;
while (adapter->EnumOutputs(i, &pOutput) != DXGI_ERROR_NOT_FOUND)
{
DXGI_OUTPUT_DESC desc;
RETURN_ON_BAD_HR(pOutput->GetDesc(&desc));
if (desc.DeviceName == deviceName) {
// Return the pointer to the caller.
*ppOutput = pOutput;
(*ppOutput)->AddRef();
break;
}
SafeRelease(&pOutput);
i++;
}
if (*ppOutput) {
break;
}
}
}
return hr;
}
std::vector<CComPtr<IDXGIAdapter>> internal_recorder::EnumDisplayAdapters()
{
std::vector<CComPtr<IDXGIAdapter>> vAdapters;
IDXGIFactory1 * pFactory;
HRESULT hr = CreateDXGIFactory1(__uuidof(IDXGIFactory), (void**)(&pFactory));
if (SUCCEEDED(hr)) {
UINT i = 0;
IDXGIAdapter *pAdapter;
while (pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND)
{
vAdapters.push_back(CComPtr<IDXGIAdapter>(pAdapter));
SafeRelease(&pAdapter);
++i;
}
}
SafeRelease(&pFactory);
return vAdapters;
}
HRESULT internal_recorder::InitializeVideoSinkWriter(std::wstring path, _In_opt_ IMFByteStream * pOutStream, _In_ ID3D11Device * pDevice, RECT sourceRect, RECT destRect, DXGI_MODE_ROTATION rotation, _Outptr_ IMFSinkWriter * *ppWriter, _Out_ DWORD * pVideoStreamIndex, _Out_ DWORD * pAudioStreamIndex)
{
*ppWriter = nullptr;
*pVideoStreamIndex = 0;
*pAudioStreamIndex = 0;
UINT pResetToken;
CComPtr<IMFDXGIDeviceManager> pDeviceManager = nullptr;
CComPtr<IMFSinkWriter> pSinkWriter = nullptr;
CComPtr<IMFMediaType> pVideoMediaTypeOut = nullptr;
CComPtr<IMFMediaType> pAudioMediaTypeOut = nullptr;
CComPtr<IMFMediaType> pVideoMediaTypeIn = nullptr;
CComPtr<IMFMediaType> pAudioMediaTypeIn = nullptr;
CComPtr<IMFAttributes> pAttributes = nullptr;
MFVideoRotationFormat rotationFormat = MFVideoRotationFormat_0;
if (rotation == DXGI_MODE_ROTATION_ROTATE90) {
rotationFormat = MFVideoRotationFormat_90;
}
else if (rotation == DXGI_MODE_ROTATION_ROTATE180) {
rotationFormat = MFVideoRotationFormat_180;
}
else if (rotation == DXGI_MODE_ROTATION_ROTATE270) {
rotationFormat = MFVideoRotationFormat_270;
}
DWORD audioStreamIndex;
DWORD videoStreamIndex;
RETURN_ON_BAD_HR(MFCreateDXGIDeviceManager(&pResetToken, &pDeviceManager));
RETURN_ON_BAD_HR(pDeviceManager->ResetDevice(pDevice, pResetToken));
const wchar_t *pathString = nullptr;
if (!path.empty()) {
pathString = path.c_str();
}
if (pOutStream == nullptr)
{
RETURN_ON_BAD_HR(MFCreateFile(MF_ACCESSMODE_READWRITE, MF_OPENMODE_FAIL_IF_EXIST, MF_FILEFLAGS_NONE, pathString, &pOutStream));
};
// Passing 6 as the argument to save re-allocations
RETURN_ON_BAD_HR(MFCreateAttributes(&pAttributes, 6));
RETURN_ON_BAD_HR(pAttributes->SetGUID(MF_TRANSCODE_CONTAINERTYPE, MFTranscodeContainerType_MPEG4));
RETURN_ON_BAD_HR(pAttributes->SetUINT32(MF_READWRITE_ENABLE_HARDWARE_TRANSFORMS, m_IsHardwareEncodingEnabled));
RETURN_ON_BAD_HR(pAttributes->SetUINT32(MF_MPEG4SINK_MOOV_BEFORE_MDAT, m_IsMp4FastStartEnabled));
RETURN_ON_BAD_HR(pAttributes->SetUINT32(MF_LOW_LATENCY, m_IsLowLatencyModeEnabled));
RETURN_ON_BAD_HR(pAttributes->SetUINT32(MF_SINK_WRITER_DISABLE_THROTTLING, m_IsThrottlingDisabled));
// Add device manager to attributes. This enables hardware encoding.
RETURN_ON_BAD_HR(pAttributes->SetUnknown(MF_SINK_WRITER_D3D_MANAGER, pDeviceManager));
UINT sourceWidth = max(0, sourceRect.right - sourceRect.left);
UINT sourceHeight = max(0, sourceRect.bottom - sourceRect.top);
UINT destWidth = max(0, destRect.right - destRect.left);
UINT destHeight = max(0, destRect.bottom - destRect.top);
// Set the output video type.
RETURN_ON_BAD_HR(MFCreateMediaType(&pVideoMediaTypeOut));
RETURN_ON_BAD_HR(pVideoMediaTypeOut->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video));
RETURN_ON_BAD_HR(pVideoMediaTypeOut->SetGUID(MF_MT_SUBTYPE, VIDEO_ENCODING_FORMAT));
RETURN_ON_BAD_HR(pVideoMediaTypeOut->SetUINT32(MF_MT_AVG_BITRATE, m_VideoBitrate));
RETURN_ON_BAD_HR(pVideoMediaTypeOut->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive));
RETURN_ON_BAD_HR(pVideoMediaTypeOut->SetUINT32(MF_MT_MPEG2_PROFILE, m_H264Profile));
RETURN_ON_BAD_HR(pVideoMediaTypeOut->SetUINT32(MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601));
RETURN_ON_BAD_HR(MFSetAttributeSize(pVideoMediaTypeOut, MF_MT_FRAME_SIZE, destWidth, destHeight));
RETURN_ON_BAD_HR(MFSetAttributeRatio(pVideoMediaTypeOut, MF_MT_FRAME_RATE, m_VideoFps, 1));
RETURN_ON_BAD_HR(MFSetAttributeRatio(pVideoMediaTypeOut, MF_MT_PIXEL_ASPECT_RATIO, 1, 1));
// Set the input video type.
CreateInputMediaTypeFromOutput(pVideoMediaTypeOut, VIDEO_INPUT_FORMAT, &pVideoMediaTypeIn);
RETURN_ON_BAD_HR(MFSetAttributeSize(pVideoMediaTypeIn, MF_MT_FRAME_SIZE, sourceWidth, sourceHeight));
pVideoMediaTypeIn->SetUINT32(MF_MT_VIDEO_ROTATION, rotationFormat);
bool isAudioEnabled = m_IsAudioEnabled
&& (m_IsOutputDeviceEnabled || m_IsInputDeviceEnabled);
if (isAudioEnabled) {
// Set the output audio type.
RETURN_ON_BAD_HR(MFCreateMediaType(&pAudioMediaTypeOut));
RETURN_ON_BAD_HR(pAudioMediaTypeOut->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio));
RETURN_ON_BAD_HR(pAudioMediaTypeOut->SetGUID(MF_MT_SUBTYPE, AUDIO_ENCODING_FORMAT));
RETURN_ON_BAD_HR(pAudioMediaTypeOut->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, m_AudioChannels));
RETURN_ON_BAD_HR(pAudioMediaTypeOut->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, AUDIO_BITS_PER_SAMPLE));
RETURN_ON_BAD_HR(pAudioMediaTypeOut->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, m_InputAudioSamplesPerSecond));
RETURN_ON_BAD_HR(pAudioMediaTypeOut->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, m_AudioBitrate));
// Set the input audio type.
RETURN_ON_BAD_HR(MFCreateMediaType(&pAudioMediaTypeIn));
RETURN_ON_BAD_HR(pAudioMediaTypeIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio));
RETURN_ON_BAD_HR(pAudioMediaTypeIn->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_PCM));
RETURN_ON_BAD_HR(pAudioMediaTypeIn->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, AUDIO_BITS_PER_SAMPLE));
RETURN_ON_BAD_HR(pAudioMediaTypeIn->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, m_InputAudioSamplesPerSecond));
RETURN_ON_BAD_HR(pAudioMediaTypeIn->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, m_AudioChannels));
}
//Creates a streaming writer
CComPtr<IMFMediaSink> pMp4StreamSink = nullptr;
if (m_IsFragmentedMp4Enabled) {
RETURN_ON_BAD_HR(MFCreateFMPEG4MediaSink(pOutStream, pVideoMediaTypeOut, pAudioMediaTypeOut, &pMp4StreamSink));
}
else {
RETURN_ON_BAD_HR(MFCreateMPEG4MediaSink(pOutStream, pVideoMediaTypeOut, pAudioMediaTypeOut, &pMp4StreamSink));
}
pAudioMediaTypeOut.Release();
pVideoMediaTypeOut.Release();
RETURN_ON_BAD_HR(MFCreateSinkWriterFromMediaSink(pMp4StreamSink, pAttributes, &pSinkWriter));
pMp4StreamSink.Release();
videoStreamIndex = 0;
audioStreamIndex = 1;
RETURN_ON_BAD_HR(pSinkWriter->SetInputMediaType(videoStreamIndex, pVideoMediaTypeIn, nullptr));
pVideoMediaTypeIn.Release();
if (isAudioEnabled) {
RETURN_ON_BAD_HR(pSinkWriter->SetInputMediaType(audioStreamIndex, pAudioMediaTypeIn, nullptr));
pAudioMediaTypeIn.Release();
}
CComPtr<ICodecAPI> encoder = nullptr;
pSinkWriter->GetServiceForStream(videoStreamIndex, GUID_NULL, IID_PPV_ARGS(&encoder));
if (encoder) {
RETURN_ON_BAD_HR(SetAttributeU32(encoder, CODECAPI_AVEncCommonRateControlMode, m_VideoBitrateControlMode));
switch (m_VideoBitrateControlMode) {
case eAVEncCommonRateControlMode_Quality:
RETURN_ON_BAD_HR(SetAttributeU32(encoder, CODECAPI_AVEncCommonQuality, m_VideoQuality));
break;
default:
break;
}
}
if (destWidth != sourceWidth || destHeight != sourceHeight) {
GUID transformType;
DWORD transformIndex = 0;
CComPtr<IMFVideoProcessorControl> videoProcessor = nullptr;
CComPtr<IMFSinkWriterEx> pSinkWriterEx = nullptr;
RETURN_ON_BAD_HR(pSinkWriter->QueryInterface(&pSinkWriterEx));
while (true) {
CComPtr<IMFTransform> transform = nullptr;
RETURN_ON_BAD_HR(pSinkWriterEx->GetTransformForStream(videoStreamIndex, transformIndex, &transformType, &transform));
if (transformType == MFT_CATEGORY_VIDEO_PROCESSOR) {
RETURN_ON_BAD_HR(transform->QueryInterface(&videoProcessor));
break;
}
transformIndex++;
}
if (videoProcessor) {
videoProcessor->SetSourceRectangle(&destRect);
videoProcessor->SetRotation(ROTATION_NORMAL);
}
}
// Tell the sink writer to start accepting data.
RETURN_ON_BAD_HR(pSinkWriter->BeginWriting());
// Return the pointer to the caller.
*ppWriter = pSinkWriter;
(*ppWriter)->AddRef();
*pVideoStreamIndex = videoStreamIndex;
*pAudioStreamIndex = audioStreamIndex;
return S_OK;
}
HRESULT internal_recorder::CreateInputMediaTypeFromOutput(
_In_ IMFMediaType * pType, // Pointer to an encoded video type.
const GUID & subtype, // Uncompressed subtype (eg, RGB-32, AYUV)
_Outptr_ IMFMediaType * *ppType // Receives a matching uncompressed video type.
)
{
CComPtr<IMFMediaType> pTypeUncomp = nullptr;
HRESULT hr = S_OK;
GUID majortype = { 0 };
MFRatio par = { 0 };
hr = pType->GetMajorType(&majortype);
if (majortype != MFMediaType_Video)
{
return MF_E_INVALIDMEDIATYPE;
}
// Create a new media type and copy over all of the items.
// This ensures that extended color information is retained.
RETURN_ON_BAD_HR(hr = MFCreateMediaType(&pTypeUncomp));
RETURN_ON_BAD_HR(hr = pType->CopyAllItems(pTypeUncomp));
// Set the subtype.
RETURN_ON_BAD_HR(hr = pTypeUncomp->SetGUID(MF_MT_SUBTYPE, subtype));
// Uncompressed means all samples are independent.
RETURN_ON_BAD_HR(hr = pTypeUncomp->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE));
// Fix up PAR if not set on the original type.
if (SUCCEEDED(hr))
{
hr = MFGetAttributeRatio(
pTypeUncomp,
MF_MT_PIXEL_ASPECT_RATIO,
(UINT32*)&par.Numerator,
(UINT32*)&par.Denominator
);
// Default to square pixels.
if (FAILED(hr))
{
hr = MFSetAttributeRatio(
pTypeUncomp,
MF_MT_PIXEL_ASPECT_RATIO,
1, 1
);
}
}
if (SUCCEEDED(hr))
{
*ppType = pTypeUncomp;
(*ppType)->AddRef();
}
return hr;
}
HRESULT internal_recorder::DrawMousePointer(ID3D11Texture2D * frame, mouse_pointer * pMousePointer, mouse_pointer::PTR_INFO ptrInfo, DXGI_MODE_ROTATION screenRotation, INT64 durationSinceLastFrame100Nanos)
{
HRESULT hr = S_FALSE;
if (g_LastMouseClickDurationRemaining > 0
&& m_IsMouseClicksDetected)
{
if (g_LastMouseClickButton == VK_LBUTTON)
{
hr = pMousePointer->DrawMouseClick(&ptrInfo, frame, m_MouseClickDetectionLMBColor, m_MouseClickDetectionRadius, screenRotation);
}
if (g_LastMouseClickButton == VK_RBUTTON)
{
hr = pMousePointer->DrawMouseClick(&ptrInfo, frame, m_MouseClickDetectionRMBColor, m_MouseClickDetectionRadius, screenRotation);
}
INT64 millis = max(HundredNanosToMillis(durationSinceLastFrame100Nanos), 0);
g_LastMouseClickDurationRemaining = max(g_LastMouseClickDurationRemaining - millis, 0);
LOG("Drawing mouse click, duration remaining on click is %u ms", g_LastMouseClickDurationRemaining);
}
if (m_IsMousePointerEnabled) {
hr = pMousePointer->DrawMousePointer(&ptrInfo, m_ImmediateContext, m_Device, frame, screenRotation);
}
return hr;
}
ID3D11Texture2D * internal_recorder::CropFrame(ID3D11Texture2D * frame, D3D11_TEXTURE2D_DESC frameDesc, RECT destRect)
{
CComPtr<ID3D11Texture2D> pCroppedFrameCopy = nullptr;
HRESULT hr = m_Device->CreateTexture2D(&frameDesc, nullptr, &pCroppedFrameCopy);
D3D11_BOX sourceRegion;
RtlZeroMemory(&sourceRegion, sizeof(sourceRegion));
sourceRegion.left = destRect.left;
sourceRegion.right = destRect.right;
sourceRegion.top = destRect.top;
sourceRegion.bottom = destRect.bottom;
sourceRegion.front = 0;
sourceRegion.back = 1;
m_ImmediateContext->CopySubresourceRegion(pCroppedFrameCopy, 0, 0, 0, 0, frame, 0, &sourceRegion);
return pCroppedFrameCopy;
}
HRESULT internal_recorder::SetAttributeU32(_Inout_ CComPtr<ICodecAPI> & codec, const GUID & guid, UINT32 value)
{
VARIANT val;
val.vt = VT_UI4;
val.uintVal = value;
return codec->SetValue(&guid, &val);
}
HRESULT internal_recorder::RenderFrame(FrameWriteModel & model) {
HRESULT hr(S_OK);
if (m_RecorderMode == MODE_VIDEO) {
hr = WriteFrameToVideo(model.StartPos, model.Duration, m_VideoStreamIndex, model.Frame);
bool wroteAudioSample;
if (FAILED(hr)) {
_com_error err(hr);
ERR(L"Writing of video frame with start pos %lld ms failed: %s\n", (HundredNanosToMillis(model.StartPos)), err.ErrorMessage());
return hr;//Stop recording if we fail
}
bool isAudioEnabled = m_IsAudioEnabled
&& (m_IsOutputDeviceEnabled || m_IsInputDeviceEnabled);
/* If the audio pCaptureInstance returns no data, i.e. the source is silent, we need to pad the PCM stream with zeros to give the media sink silence as input.
* If we don't, the sink writer will begin throttling video frames because it expects audio samples to be delivered, and think they are delayed.
* We ignore every instance where the last frame had audio, due to sometimes very short frame durations due to mouse cursor changes have zero audio length,
* and inserting silence between two frames that has audio leads to glitching. */
if (isAudioEnabled && model.Audio.size() == 0 && model.Duration > 0) {
if (!m_LastFrameHadAudio) {
int frameCount = int(ceil(m_InputAudioSamplesPerSecond * HundredNanosToMillis(model.Duration) / 1000));
int byteCount = frameCount * (AUDIO_BITS_PER_SAMPLE / 8) * m_AudioChannels;
model.Audio.insert(model.Audio.end(), byteCount, 0);
LOG(L"Inserted %zd bytes of silence", model.Audio.size());
}
m_LastFrameHadAudio = false;
}
else {
m_LastFrameHadAudio = true;
}
if (model.Audio.size() > 0) {
hr = WriteAudioSamplesToVideo(model.StartPos, model.Duration, m_AudioStreamIndex, &(model.Audio)[0], model.Audio.size());
if (FAILED(hr)) {
_com_error err(hr);
ERR(L"Writing of audio sample with start pos %lld ms failed: %s\n", (HundredNanosToMillis(model.StartPos)), err.ErrorMessage());
return hr;//Stop recording if we fail
}
else {
wroteAudioSample = true;
}
}
LOG(L"Wrote %s with start pos %lld ms and with duration %lld ms", wroteAudioSample ? L"video and audio sample" : L"video sample", HundredNanosToMillis(model.StartPos), HundredNanosToMillis(model.Duration));
}
else if (m_RecorderMode == MODE_SLIDESHOW) {
wstring path = m_OutputFolder + L"\\" + to_wstring(model.FrameNumber) + GetImageExtension();
hr = WriteFrameToImage(model.Frame, path.c_str());
INT64 startposMs = HundredNanosToMillis(model.StartPos);
INT64 durationMs = HundredNanosToMillis(model.Duration);
if (FAILED(hr)) {
_com_error err(hr);
ERR(L"Writing of video slideshow frame with start pos %lld ms failed: %s\n", startposMs, err.ErrorMessage());
return hr; //Stop recording if we fail
}
else {
m_FrameDelays.insert(std::pair<wstring, int>(path, model.FrameNumber == 0 ? 0 : (int)durationMs));
LOG(L"Wrote video slideshow frame with start pos %lld ms and with duration %lld ms\n", startposMs, durationMs);
}
}
else if (m_RecorderMode == MODE_SNAPSHOT) {
hr = WriteFrameToImage(model.Frame, m_OutputFullPath.c_str());
LOG(L"Wrote snapshot to %s\n", m_OutputFullPath.c_str());
}
model.Frame.Release();
return hr;
}
std::string internal_recorder::CurrentTimeToFormattedString()
{
chrono::system_clock::time_point p = chrono::system_clock::now();
time_t t = chrono::system_clock::to_time_t(p);
struct tm newTime;
auto err = localtime_s(&newTime, &t);
std::stringstream ss;
if (err)
ss << "NEW";
else
ss << std::put_time(&newTime, "%Y-%m-%d %X");
string time = ss.str();
std::replace(time.begin(), time.end(), ':', '-');
return time;
}
HRESULT internal_recorder::WriteFrameToImage(_In_ ID3D11Texture2D * pAcquiredDesktopImage, LPCWSTR filePath)
{
HRESULT hr = SaveWICTextureToFile(m_ImmediateContext, pAcquiredDesktopImage,
m_ImageEncoderFormat, filePath, nullptr);
return hr;
}
HRESULT internal_recorder::WriteFrameToVideo(INT64 frameStartPos, INT64 frameDuration, DWORD streamIndex, _In_ ID3D11Texture2D * pAcquiredDesktopImage)
{
IMFMediaBuffer *pMediaBuffer;
HRESULT hr = MFCreateDXGISurfaceBuffer(__uuidof(ID3D11Texture2D), pAcquiredDesktopImage, 0, FALSE, &pMediaBuffer);
IMF2DBuffer *p2DBuffer;
if (SUCCEEDED(hr))
{
hr = pMediaBuffer->QueryInterface(__uuidof(IMF2DBuffer), reinterpret_cast<void **>(&p2DBuffer));
}
DWORD length;
if (SUCCEEDED(hr))
{
hr = p2DBuffer->GetContiguousLength(&length);
}
if (SUCCEEDED(hr))
{
hr = pMediaBuffer->SetCurrentLength(length);
}
IMFSample *pSample;
if (SUCCEEDED(hr))
{
hr = MFCreateSample(&pSample);
}
if (SUCCEEDED(hr))
{
hr = pSample->AddBuffer(pMediaBuffer);
}
if (SUCCEEDED(hr))
{
hr = pSample->SetSampleTime(frameStartPos);
}
if (SUCCEEDED(hr))
{
hr = pSample->SetSampleDuration(frameDuration);
}
if (SUCCEEDED(hr))
{
// Send the sample to the Sink Writer.
hr = m_SinkWriter->WriteSample(streamIndex, pSample);
}
SafeRelease(&pSample);
SafeRelease(&p2DBuffer);
SafeRelease(&pMediaBuffer);
return hr;
}
HRESULT internal_recorder::WriteAudioSamplesToVideo(INT64 frameStartPos, INT64 frameDuration, DWORD streamIndex, _In_ BYTE * pSrc, DWORD cbData)
{
IMFMediaBuffer *pBuffer = nullptr;
BYTE *pData = nullptr;
// Create the media buffer.
HRESULT hr = MFCreateMemoryBuffer(
cbData, // Amount of memory to allocate, in bytes.
&pBuffer
);
//once in awhile, things get behind and we get an out of memory error when trying to create the buffer
//so, just check, wait and try again if necessary
int counter = 0;
while (!SUCCEEDED(hr) && counter++ < 100) {
Sleep(100);
hr = MFCreateMemoryBuffer(cbData, &pBuffer);
}
// Lock the buffer to get a pointer to the memory.
if (SUCCEEDED(hr))
{
hr = pBuffer->Lock(&pData, nullptr, nullptr);
}
if (SUCCEEDED(hr))
{
memcpy_s(pData, cbData, pSrc, cbData);
}
// Update the current length.
if (SUCCEEDED(hr))
{
hr = pBuffer->SetCurrentLength(cbData);
}
// Unlock the buffer.
if (pData)
{
hr = pBuffer->Unlock();
}
IMFSample *pSample;
if (SUCCEEDED(hr))
{
hr = MFCreateSample(&pSample);
}
if (SUCCEEDED(hr))
{
hr = pSample->AddBuffer(pBuffer);
}
if (SUCCEEDED(hr))
{
INT64 start = frameStartPos;
hr = pSample->SetSampleTime(start);
}
if (SUCCEEDED(hr))
{
INT64 duration = frameDuration;
hr = pSample->SetSampleDuration(duration);
}
if (SUCCEEDED(hr))
{
// Send the sample to the Sink Writer.
hr = m_SinkWriter->WriteSample(streamIndex, pSample);
}
SafeRelease(&pSample);
SafeRelease(&pBuffer);
return hr;
}
void internal_recorder::SetDebugName(ID3D11DeviceChild * child, const std::string & name)
{
#if _DEBUG
if (child != nullptr)
child->SetPrivateData(WKPDID_D3DDebugObjectName, name.size(), name.c_str());
#endif
} |
ca24cd8ab675a9a4e18a726e7a16965c3baeed8e | b5e388f02d79ca7e82c2295f06948abb5788db75 | /Solved/Sources/1967/Source.cpp | 5df0688d865a5412a09622aaf1c232b8f29a5f61 | [
"MIT"
] | permissive | Sylvia3259/baekjoon-online-judge | 1330c02c110e48a31d0806763026d6fe56f393d7 | 08539af22a252352daaa06464df22678d1310a6f | refs/heads/master | 2023-07-04T15:43:25.886394 | 2021-08-07T13:11:18 | 2021-08-07T13:11:18 | 389,019,488 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 838 | cpp | Source.cpp | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
vector<pair<int, int>> adj[100001];
bool checked[2][100001];
int max_distance[2], max_node[2];
void dfs(int node, int sum, int index) {
if (checked[index][node])
return;
checked[index][node] = true;
if (sum > max_distance[index]) {
max_distance[index] = sum;
max_node[index] = node;
}
for (auto adj_node : adj[node])
dfs(adj_node.first, sum + adj_node.second, index);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
int from, to, weight;
cin >> from >> to >> weight;
adj[from].push_back({ to, weight });
adj[to].push_back({ from, weight });
}
dfs(1, 0, 0);
dfs(max_node[0], 0, 1);
cout << max_distance[1] << endl;
return 0;
} |
cbe302a30c6c0b8ba27bfb57a037f0568c3e37f6 | 0b2b45d6f98f51f5e098e464cd2005363d39a419 | /hdoj/2112_HDU_Today_scanf.cpp | 56227a91c74e662e96d146583891eabb026324e2 | [] | no_license | helloliuc/ACM | 6a83e1ad578e6238c7c13246abf899bf791d3dc6 | 5807bc24541b10b9ca97ae4f14707ff1559071f5 | refs/heads/master | 2021-01-23T20:45:44.829304 | 2013-09-29T16:02:11 | 2013-09-29T16:02:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,025 | cpp | 2112_HDU_Today_scanf.cpp | //9226199 2013-09-25 16:49:09 Accepted 2112 1953MS 644K 2049 B C++ nkhelloworld
//9228102 2013-09-25 21:23:49 Accepted 2112 1984MS 648K 2996 B C++ nkhelloworld --priority
//9230062 2013-09-26 10:33:50 Accepted 2112 1625MS 728K 3715 B G++ nkhelloworld 用cin,cout,开启sync_with_studio(false)优化
//9230079 2013-09-26 10:39:12 Accepted 2112 1406MS 712K 3942 B G++ nkhelloworld scanf
//9230078 2013-09-26 10:39:00 Accepted 2112 1500MS 616K 3942 B C++ nkhelloworld scanf
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0f);
const int MAXN = 210;
const int MAXEDGE = 21000;
int idx[MAXN];
int dis[MAXN];
struct EDGE {
int u,v,d,nxt;
}edge[MAXEDGE];//注意无向图里边数可能需要加倍
int pedge = 0;
void initEdge() {
memset(idx,-1,sizeof(idx));
pedge = 0;
}
void addEdge(int u, int v, int d) {
edge[pedge].u = u; edge[pedge].v = v; edge[pedge].d = d;
edge[pedge].nxt = idx[u]; idx[u] = pedge++;
}
void dijkstra(int n,int s,int e)
{
memset(dis,-1,sizeof(dis));
bool flag[MAXN];
memset(flag,false,sizeof(flag));
dis[s] = 0;
for(int i=1;i<=n;i++) {
int mindis = INF, minpos = s;
for(int j=1;j<=n;j++) {
if(!flag[j] && dis[j] < mindis && dis[j] != -1) {
minpos = j; mindis = dis[j];
}
}
flag[minpos] = true;
if(minpos == e) return ;
for(int j=idx[minpos]; j!=-1; j=edge[j].nxt) {
int u=edge[j].u, v=edge[j].v, d=edge[j].d;
if(!flag[v] && (dis[v] - d > dis[u] || dis[v] == -1)) {
dis[v] = d + dis[u];
}
}
}
}
typedef pair<int, int> pii;
void dijkstra_priority(int n, int st, int ed) {
bool flag[MAXN];
memset(flag, false, sizeof(flag));
memset(dis, -1, sizeof(dis));
priority_queue<pii, vector<pii>, greater<pii> > q;
dis[st] = 0;
q.push(make_pair(dis[st], st));
while(!q.empty()) {
pii tmp = q.top(); q.pop();
if(flag[tmp.second]) continue;
if(tmp.second == ed) return ;
flag[tmp.second] = true;
for(int j=idx[tmp.second]; j!=-1; j=edge[j].nxt) {
if(!flag[edge[j].v] && dis[edge[j].u] + edge[j].d < dis[edge[j].v] || dis[edge[j].v] == -1) {
dis[edge[j].v] = dis[edge[j].u] + edge[j].d;
q.push(make_pair(dis[edge[j].v], edge[j].v));
}
}
}
}
/*
int map_find(const string &s) {
if(m.count(s)) return m[s];
m[s] = cnt_map++;
return cnt_map-1;
}
*/
map<string, int> m;
int main()
{
char tmp1[100], tmp2[100];
int n;
while(scanf("%d",&n), n!=-1) {
m.clear();
scanf("%s%s",tmp1,tmp2);
string s,e;
s=tmp1; e=tmp2;
initEdge();
int cnt_map = 1;
string a,b;
int d;
for(int i=0;i<n;i++) {
scanf("%s%s%d",tmp1,tmp2,&d);
a=tmp1; b=tmp2;
//if(m.insert(make_pair(a, cnt_map)).second == true) cnt_map++;
//if(m.insert(make_pair(b, cnt_map)).second == true) cnt_map++;
if(m[a] == 0) m[a] = cnt_map++;
if(m[b] == 0) m[b] = cnt_map++;
//if(!m.count(a)) m[a] = cnt_map++;
//if(!m.count(b)) m[b] = cnt_map++;
addEdge(m[a], m[b], d);
addEdge(m[b], m[a], d);
/*
int t1 = map_find(a);
int t2 = map_find(b);
addEdge(t1,t2,d);
addEdge(t2,t1,d);
*/
}
if(m[s] == 0) m[s] = cnt_map++;
if(m[e] == 0) m[e] = cnt_map++;
//dijkstra(cnt_map-1, m[s], m[e]);
dijkstra_priority(cnt_map-1, m[s], m[e]);
printf("%d\n",dis[m[e]]);
//cout<<dis[m[e]]<<endl;
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.