blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2 values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905 values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 10.4M | extension stringclasses 115 values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8d71f4fb702bb445173269818431c0980a86e5cf | c51febc209233a9160f41913d895415704d2391f | /library/ATF/_remain_potion_buf_use_time_inform_zocl.hpp | 7604979814bf26f35b703e2d8ecc561e29361aaf | [
"MIT"
] | permissive | roussukke/Yorozuya | 81f81e5e759ecae02c793e65d6c3acc504091bc3 | d9a44592b0714da1aebf492b64fdcb3fa072afe5 | refs/heads/master | 2023-07-08T03:23:00.584855 | 2023-06-29T08:20:25 | 2023-06-29T08:20:25 | 463,330,454 | 0 | 0 | MIT | 2022-02-24T23:15:01 | 2022-02-24T23:15:00 | null | UTF-8 | C++ | false | false | 334 | hpp | // This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually
#pragma once
#include <common/common.h>
START_ATF_NAMESPACE
struct _remain_potion_buf_use_time_inform_zocl
{
bool bUse;
char byDay;
char byHour;
char byMin;
};
END_ATF_NAMESPACE
| [
"b1ll.cipher@yandex.ru"
] | b1ll.cipher@yandex.ru |
0fa5740501a496feee3388504193d0d9d258cdd2 | eb8dce3750f055dd87fcd635ff7cb34e53010a7c | /src/qt/teshubstrings.cpp | 475f125e0e28ad7e4f8e38fd9c83aef81ba7e5cb | [
"MIT"
] | permissive | Teshubcoin/wallet | 3c83f09d271ac3e627626e6ddc81978bfe0c5010 | 04c2182d922d1fa28136721de4306c174f0c62fd | refs/heads/master | 2020-03-21T18:45:24.285600 | 2018-06-29T04:06:50 | 2018-06-29T04:06:50 | 138,909,777 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 28,726 | cpp |
#include <QtGlobal>
// Automatically generated by extract_strings.py
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif
static const char UNUSED *teshub_strings[] = {
QT_TRANSLATE_NOOP("teshub-core", ""
"(1 = keep tx meta data e.g. account owner and payment request information, 2 "
"= drop tx meta data)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Allow JSON-RPC connections from specified source. Valid for <ip> are a "
"single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or "
"a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times"),
QT_TRANSLATE_NOOP("teshub-core", ""
"An error occurred while setting up the RPC address %s port %u for listening: "
"%s"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Bind to given address and always listen on it. Use [host]:port notation for "
"IPv6"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Bind to given address and whitelist peers connecting to it. Use [host]:port "
"notation for IPv6"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Bind to given address to listen for JSON-RPC connections. Use [host]:port "
"notation for IPv6. This option can be specified multiple times (default: "
"bind to all interfaces)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Cannot obtain a lock on data directory %s. TesHub Core is probably already "
"running."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Change automatic finalized budget voting behavior. mode=auto: Vote for only "
"exact finalized budget match to my generated budget. (string, default: auto)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Continuously rate-limit free transactions to <n>*1000 bytes per minute "
"(default:%u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Create new files with system default permissions, instead of umask 077 (only "
"effective with disabled wallet functionality)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Delete all wallet transactions and only recover those parts of the "
"blockchain through -rescan on startup"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Disable all TesHub specific functionality (Masternodes, SwiftTX, "
"Budgeting) (0-1, default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Distributed under the MIT software license, see the accompanying file "
"COPYING or <http://www.opensource.org/licenses/mit-license.php>."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Enable SwiftTX, show confirmations for locked transactions (bool, default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Enable spork administration functionality with the appropriate private key."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Enter regression test mode, which uses a special chain in which blocks can "
"be solved instantly."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Error: Listening for incoming connections failed (listen returned error %s)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Error: 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("teshub-core", ""
"Error: This transaction requires a transaction fee of at least %s because of "
"its amount, complexity, or use of recently received funds!"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Error: Unsupported argument -checklevel found. Checklevel must be level 4."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Error: Unsupported argument -socks found. Setting SOCKS version isn't "
"possible anymore, only SOCKS5 proxies are supported."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Execute command when a relevant alert is received or we see a really long "
"fork (%s in cmd is replaced by message)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Execute command when a wallet transaction changes (%s in cmd is replaced by "
"TxID)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Execute command when the best block changes (%s in cmd is replaced by block "
"hash)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Fees (in TESB/Kb) smaller than this are considered zero fee for relaying "
"(default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Fees (in TESB/Kb) smaller than this are considered zero fee for transaction "
"creation (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Flush database activity from memory pool to disk log every <n> megabytes "
"(default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"If paytxfee is not set, include enough fee so transactions begin "
"confirmation on average within n blocks (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"In this mode -genproclimit controls how many blocks are generated "
"immediately."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Insufficient or insufficient confirmed funds, you might need to wait a few "
"minutes and try again."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Invalid amount for -maxtxfee=<amount>: '%s' (must be at least the minrelay "
"fee of %s to prevent stuck transactions)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Keep the specified amount available for spending at all times (default: 0)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Log transaction priority and fee per kB when mining blocks (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Maintain a full transaction index, used by the getrawtransaction rpc call "
"(default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Maximum size of data in data carrier transactions we relay and mine "
"(default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Maximum total fees to use in a single wallet transaction, setting too low "
"may abort large transactions (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Number of seconds to keep misbehaving peers from reconnecting (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Output debugging information (default: %u, supplying <category> is optional)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Query for peer addresses via DNS lookup, if low on addresses (default: 1 "
"unless -connect)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Randomize credentials for every proxy connection. This enables Tor stream "
"isolation (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Require high priority for relaying free or low-fee transactions (default:%u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Send trace/debug info to console instead of debug.log file (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Set maximum size of high-priority/low-fee transactions in bytes (default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Set the number of script verification threads (%u to %d, 0 = auto, <0 = "
"leave that many cores free, default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Set the number of threads for coin generation if enabled (-1 = all cores, "
"default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Show N confirmations for a successfully locked transaction (0-9999, default: "
"%u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Support filtering of blocks and transaction with bloom filters (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"SwiftTX requires inputs with at least 6 confirmations, you might need to wait "
"a few minutes and try again."),
QT_TRANSLATE_NOOP("teshub-core", ""
"This is a pre-release test build - use at your own risk - do not use for "
"staking or merchant applications!"),
QT_TRANSLATE_NOOP("teshub-core", ""
"This product includes software developed by the OpenSSL Project for use in "
"the OpenSSL Toolkit <https://www.openssl.org/> and cryptographic software "
"written by Eric Young and UPnP software written by Thomas Bernard."),
QT_TRANSLATE_NOOP("teshub-core", ""
"To use teshubd, or the -server option to teshub-qt, you must set an rpcpassword "
"in the configuration file:\n"
"%s\n"
"It is recommended you use the following random password:\n"
"rpcuser=teshubrpc\n"
"rpcpassword=%s\n"
"(you do not need to remember this password)\n"
"The username and password MUST NOT be the same.\n"
"If the file does not exist, create it with owner-readable-only file "
"permissions.\n"
"It is also recommended to set alertnotify so you are notified of problems;\n"
"for example: alertnotify=echo %%s | mail -s \"TesHub Alert\" admin@foo.com\n"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Unable to bind to %s on this computer. TesHub Core is probably already running."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Unable to locate enough funds for this transaction that are not equal 1000 "
"TESB."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: "
"%s)"),
QT_TRANSLATE_NOOP("teshub-core", ""
"Warning: -maxtxfee is set very high! Fees this large could be paid on a "
"single transaction."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Warning: -paytxfee is set very high! This is the transaction fee you will "
"pay if you send a transaction."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Warning: Please check that your computer's date and time are correct! If "
"your clock is wrong TesHub Core will not work properly."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Warning: The network does not appear to fully agree! Some miners appear to "
"be experiencing issues."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Warning: We do not appear to fully agree with our peers! You may need to "
"upgrade, or other nodes may need to upgrade."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Warning: error reading wallet.dat! All keys read correctly, but transaction "
"data or address book entries might be missing or incorrect."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Warning: wallet.dat corrupt, data salvaged! Original wallet.dat saved as "
"wallet.{timestamp}.bak in %s; if your balance or transactions are incorrect "
"you should restore from a backup."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Whitelist peers connecting from the given netmask or IP address. Can be "
"specified multiple times."),
QT_TRANSLATE_NOOP("teshub-core", ""
"Whitelisted peers cannot be DoS banned and their transactions are always "
"relayed, even if they are already in the mempool, useful e.g. for a gateway"),
QT_TRANSLATE_NOOP("teshub-core", ""
"You must specify a masternodeprivkey in the configuration. Please see "
"documentation for help."),
QT_TRANSLATE_NOOP("teshub-core", "(23500 could be used only on mainnet)"),
QT_TRANSLATE_NOOP("teshub-core", "(default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "(default: 1)"),
QT_TRANSLATE_NOOP("teshub-core", "(must be 23500 for mainnet)"),
QT_TRANSLATE_NOOP("teshub-core", "<category> can be:"),
QT_TRANSLATE_NOOP("teshub-core", "Accept command line and JSON-RPC commands"),
QT_TRANSLATE_NOOP("teshub-core", "Accept connections from outside (default: 1 if no -proxy or -connect)"),
QT_TRANSLATE_NOOP("teshub-core", "Accept public REST requests (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Acceptable ciphers (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Add a node to connect to and attempt to keep the connection open"),
QT_TRANSLATE_NOOP("teshub-core", "Allow DNS lookups for -addnode, -seednode and -connect"),
QT_TRANSLATE_NOOP("teshub-core", "Already have that input."),
QT_TRANSLATE_NOOP("teshub-core", "Always query for peer addresses via DNS lookup (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Attempt to force blockchain corruption recovery"),
QT_TRANSLATE_NOOP("teshub-core", "Attempt to recover private keys from a corrupt wallet.dat"),
QT_TRANSLATE_NOOP("teshub-core", "Automatically create Tor hidden service (default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", "Block creation options:"),
QT_TRANSLATE_NOOP("teshub-core", "Can't find random Masternode."),
QT_TRANSLATE_NOOP("teshub-core", "Cannot downgrade wallet"),
QT_TRANSLATE_NOOP("teshub-core", "Cannot resolve -bind address: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Cannot resolve -externalip address: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Cannot resolve -whitebind address: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Cannot write default address"),
QT_TRANSLATE_NOOP("teshub-core", "Collateral not valid."),
QT_TRANSLATE_NOOP("teshub-core", "Connect only to the specified node(s)"),
QT_TRANSLATE_NOOP("teshub-core", "Connect through SOCKS5 proxy"),
QT_TRANSLATE_NOOP("teshub-core", "Connect to a node to retrieve peer addresses, and disconnect"),
QT_TRANSLATE_NOOP("teshub-core", "Connection options:"),
QT_TRANSLATE_NOOP("teshub-core", "Copyright (C) 2009-%i The Bitcoin Core Developers"),
QT_TRANSLATE_NOOP("teshub-core", "Copyright (C) 2014-%i The Dash Core Developers"),
QT_TRANSLATE_NOOP("teshub-core", "Copyright (C) 2015-%i The PIVX Core Developers"),
QT_TRANSLATE_NOOP("teshub-core", "Copyright (C) 2017-%i The TesHub Core Developers"),
QT_TRANSLATE_NOOP("teshub-core", "Corrupted block database detected"),
QT_TRANSLATE_NOOP("teshub-core", "Could not parse -rpcbind value %s as network address"),
QT_TRANSLATE_NOOP("teshub-core", "Could not parse masternode.conf"),
QT_TRANSLATE_NOOP("teshub-core", "Debugging/Testing options:"),
QT_TRANSLATE_NOOP("teshub-core", "Delete blockchain folders and resync from scratch"),
QT_TRANSLATE_NOOP("teshub-core", "Disable OS notifications for incoming transactions (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Disable safemode, override a real safe mode event (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Discover own IP address (default: 1 when listening and no -externalip)"),
QT_TRANSLATE_NOOP("teshub-core", "Display the stake modifier calculations in the debug.log file."),
QT_TRANSLATE_NOOP("teshub-core", "Display verbose coin stake messages in the debug.log file."),
QT_TRANSLATE_NOOP("teshub-core", "Do not load the wallet and disable wallet RPC calls"),
QT_TRANSLATE_NOOP("teshub-core", "Do you want to rebuild the block database now?"),
QT_TRANSLATE_NOOP("teshub-core", "Done loading"),
QT_TRANSLATE_NOOP("teshub-core", "Enable publish hash block in <address>"),
QT_TRANSLATE_NOOP("teshub-core", "Enable publish hash transaction (locked via SwiftTX) in <address>"),
QT_TRANSLATE_NOOP("teshub-core", "Enable publish hash transaction in <address>"),
QT_TRANSLATE_NOOP("teshub-core", "Enable publish raw block in <address>"),
QT_TRANSLATE_NOOP("teshub-core", "Enable publish raw transaction (locked via SwiftTX) in <address>"),
QT_TRANSLATE_NOOP("teshub-core", "Enable publish raw transaction in <address>"),
QT_TRANSLATE_NOOP("teshub-core", "Enable staking functionality (0-1, default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Enable the client to act as a masternode (0-1, default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Entries are full."),
QT_TRANSLATE_NOOP("teshub-core", "Error connecting to Masternode."),
QT_TRANSLATE_NOOP("teshub-core", "Error initializing block database"),
QT_TRANSLATE_NOOP("teshub-core", "Error initializing wallet database environment %s!"),
QT_TRANSLATE_NOOP("teshub-core", "Error loading block database"),
QT_TRANSLATE_NOOP("teshub-core", "Error loading wallet.dat"),
QT_TRANSLATE_NOOP("teshub-core", "Error loading wallet.dat: Wallet corrupted"),
QT_TRANSLATE_NOOP("teshub-core", "Error loading wallet.dat: Wallet requires newer version of TesHub Core"),
QT_TRANSLATE_NOOP("teshub-core", "Error opening block database"),
QT_TRANSLATE_NOOP("teshub-core", "Error reading from database, shutting down."),
QT_TRANSLATE_NOOP("teshub-core", "Error recovering public key."),
QT_TRANSLATE_NOOP("teshub-core", "Error"),
QT_TRANSLATE_NOOP("teshub-core", "Error: A fatal internal error occured, see debug.log for details"),
QT_TRANSLATE_NOOP("teshub-core", "Error: Disk space is low!"),
QT_TRANSLATE_NOOP("teshub-core", "Error: Unsupported argument -tor found, use -onion."),
QT_TRANSLATE_NOOP("teshub-core", "Error: Wallet locked, unable to create transaction!"),
QT_TRANSLATE_NOOP("teshub-core", "Failed to listen on any port. Use -listen=0 if you want this."),
QT_TRANSLATE_NOOP("teshub-core", "Failed to read block index"),
QT_TRANSLATE_NOOP("teshub-core", "Failed to read block"),
QT_TRANSLATE_NOOP("teshub-core", "Failed to write block index"),
QT_TRANSLATE_NOOP("teshub-core", "Fee (in TESB/kB) to add to transactions you send (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Finalizing transaction."),
QT_TRANSLATE_NOOP("teshub-core", "Force safe mode (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Found enough users, signing ( waiting %s )"),
QT_TRANSLATE_NOOP("teshub-core", "Found enough users, signing ..."),
QT_TRANSLATE_NOOP("teshub-core", "Generate coins (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "How many blocks to check at startup (default: %u, 0 = all)"),
QT_TRANSLATE_NOOP("teshub-core", "If <category> is not supplied, output all debugging information."),
QT_TRANSLATE_NOOP("teshub-core", "Importing..."),
QT_TRANSLATE_NOOP("teshub-core", "Imports blocks from external blk000??.dat file"),
QT_TRANSLATE_NOOP("teshub-core", "Include IP addresses in debug output (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Incompatible mode."),
QT_TRANSLATE_NOOP("teshub-core", "Incompatible version."),
QT_TRANSLATE_NOOP("teshub-core", "Incorrect or no genesis block found. Wrong datadir for network?"),
QT_TRANSLATE_NOOP("teshub-core", "Information"),
QT_TRANSLATE_NOOP("teshub-core", "Initialization sanity check failed. TesHub Core is shutting down."),
QT_TRANSLATE_NOOP("teshub-core", "Input is not valid."),
QT_TRANSLATE_NOOP("teshub-core", "Insufficient funds"),
QT_TRANSLATE_NOOP("teshub-core", "Insufficient funds."),
QT_TRANSLATE_NOOP("teshub-core", "Invalid -onion address or hostname: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid -proxy address or hostname: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid amount for -maxtxfee=<amount>: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid amount for -minrelaytxfee=<amount>: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid amount for -mintxfee=<amount>: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid amount for -paytxfee=<amount>: '%s' (must be at least %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid amount for -paytxfee=<amount>: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid amount for -reservebalance=<amount>"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid amount"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid masternodeprivkey. Please see documenation."),
QT_TRANSLATE_NOOP("teshub-core", "Invalid netmask specified in -whitelist: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid port detected in masternode.conf"),
QT_TRANSLATE_NOOP("teshub-core", "Invalid private key."),
QT_TRANSLATE_NOOP("teshub-core", "Invalid script detected."),
QT_TRANSLATE_NOOP("teshub-core", "Keep at most <n> unconnectable transactions in memory (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Limit size of signature cache to <n> entries (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Line: %d"),
QT_TRANSLATE_NOOP("teshub-core", "Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Listen for connections on <port> (default: %u or testnet: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Loading addresses..."),
QT_TRANSLATE_NOOP("teshub-core", "Loading block index..."),
QT_TRANSLATE_NOOP("teshub-core", "Loading budget cache..."),
QT_TRANSLATE_NOOP("teshub-core", "Loading masternode cache..."),
QT_TRANSLATE_NOOP("teshub-core", "Loading masternode payment cache..."),
QT_TRANSLATE_NOOP("teshub-core", "Loading sporks..."),
QT_TRANSLATE_NOOP("teshub-core", "Loading wallet... (%3.2f %%)"),
QT_TRANSLATE_NOOP("teshub-core", "Loading wallet..."),
QT_TRANSLATE_NOOP("teshub-core", "Lock is already in place."),
QT_TRANSLATE_NOOP("teshub-core", "Lock masternodes from masternode configuration file (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Maintain at most <n> connections to peers (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Masternode options:"),
QT_TRANSLATE_NOOP("teshub-core", "Masternode queue is full."),
QT_TRANSLATE_NOOP("teshub-core", "Masternode:"),
QT_TRANSLATE_NOOP("teshub-core", "Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Missing input transaction information."),
QT_TRANSLATE_NOOP("teshub-core", "Need to specify a port with -whitebind: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "No Masternodes detected."),
QT_TRANSLATE_NOOP("teshub-core", "No compatible Masternode found."),
QT_TRANSLATE_NOOP("teshub-core", "Node relay options:"),
QT_TRANSLATE_NOOP("teshub-core", "Non-standard public key detected."),
QT_TRANSLATE_NOOP("teshub-core", "Not compatible with existing transactions."),
QT_TRANSLATE_NOOP("teshub-core", "Not enough file descriptors available."),
QT_TRANSLATE_NOOP("teshub-core", "Not in the Masternode list."),
QT_TRANSLATE_NOOP("teshub-core", "Number of automatic wallet backups (default: 10)"),
QT_TRANSLATE_NOOP("teshub-core", "Only accept block chain matching built-in checkpoints (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Only connect to nodes in network <net> (ipv4, ipv6 or onion)"),
QT_TRANSLATE_NOOP("teshub-core", "Options:"),
QT_TRANSLATE_NOOP("teshub-core", "Password for JSON-RPC connections"),
QT_TRANSLATE_NOOP("teshub-core", "Preparing for resync..."),
QT_TRANSLATE_NOOP("teshub-core", "Prepend debug output with timestamp (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Print version and exit"),
QT_TRANSLATE_NOOP("teshub-core", "RPC SSL options: (see the Bitcoin Wiki for SSL setup instructions)"),
QT_TRANSLATE_NOOP("teshub-core", "RPC server options:"),
QT_TRANSLATE_NOOP("teshub-core", "RPC support for HTTP persistent connections (default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", "Randomly drop 1 of every <n> network messages"),
QT_TRANSLATE_NOOP("teshub-core", "Randomly fuzz 1 of every <n> network messages"),
QT_TRANSLATE_NOOP("teshub-core", "Rebuild block chain index from current blk000??.dat files"),
QT_TRANSLATE_NOOP("teshub-core", "Receive and display P2P network alerts (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Relay and mine data carrier transactions (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Relay non-P2SH multisig (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Rescan the block chain for missing wallet transactions"),
QT_TRANSLATE_NOOP("teshub-core", "Rescanning..."),
QT_TRANSLATE_NOOP("teshub-core", "Run a thread to flush wallet periodically (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Run in the background as a daemon and accept commands"),
QT_TRANSLATE_NOOP("teshub-core", "Send transactions as zero-fee transactions if possible (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Server certificate file (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Server private key (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Session not complete!"),
QT_TRANSLATE_NOOP("teshub-core", "Session timed out."),
QT_TRANSLATE_NOOP("teshub-core", "Set database cache size in megabytes (%d to %d, default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", "Set external address:port to get to this masternode (example: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Set key pool size to <n> (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Set maximum block size in bytes (default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", "Set minimum block size in bytes (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Set the Maximum reorg depth (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Set the masternode private key"),
QT_TRANSLATE_NOOP("teshub-core", "Set the number of threads to service RPC calls (default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", "Sets the DB_PRIVATE flag in the wallet db environment (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Show all debugging options (usage: --help -help-debug)"),
QT_TRANSLATE_NOOP("teshub-core", "Shrink debug.log file on client startup (default: 1 when no -debug)"),
QT_TRANSLATE_NOOP("teshub-core", "Signing failed."),
QT_TRANSLATE_NOOP("teshub-core", "Signing timed out."),
QT_TRANSLATE_NOOP("teshub-core", "Signing transaction failed"),
QT_TRANSLATE_NOOP("teshub-core", "Specify configuration file (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Specify connection timeout in milliseconds (minimum: 1, default: %d)"),
QT_TRANSLATE_NOOP("teshub-core", "Specify data directory"),
QT_TRANSLATE_NOOP("teshub-core", "Specify masternode configuration file (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Specify pid file (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Specify wallet file (within data directory)"),
QT_TRANSLATE_NOOP("teshub-core", "Specify your own public address"),
QT_TRANSLATE_NOOP("teshub-core", "Spend unconfirmed change when sending transactions (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Staking options:"),
QT_TRANSLATE_NOOP("teshub-core", "Stop running after importing blocks from disk (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Submitted following entries to masternode: %u / %d"),
QT_TRANSLATE_NOOP("teshub-core", "Submitted to masternode, waiting for more entries ( %u / %d ) %s"),
QT_TRANSLATE_NOOP("teshub-core", "Submitted to masternode, waiting in queue %s"),
QT_TRANSLATE_NOOP("teshub-core", "SwiftTX options:"),
QT_TRANSLATE_NOOP("teshub-core", "Synchronization failed"),
QT_TRANSLATE_NOOP("teshub-core", "Synchronization finished"),
QT_TRANSLATE_NOOP("teshub-core", "Synchronization pending..."),
QT_TRANSLATE_NOOP("teshub-core", "Synchronizing budgets..."),
QT_TRANSLATE_NOOP("teshub-core", "Synchronizing masternode winners..."),
QT_TRANSLATE_NOOP("teshub-core", "Synchronizing masternodes..."),
QT_TRANSLATE_NOOP("teshub-core", "Synchronizing sporks..."),
QT_TRANSLATE_NOOP("teshub-core", "This help message"),
QT_TRANSLATE_NOOP("teshub-core", "This is experimental software."),
QT_TRANSLATE_NOOP("teshub-core", "This is intended for regression testing tools and app development."),
QT_TRANSLATE_NOOP("teshub-core", "This is not a Masternode."),
QT_TRANSLATE_NOOP("teshub-core", "Threshold for disconnecting misbehaving peers (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Tor control port password (default: empty)"),
QT_TRANSLATE_NOOP("teshub-core", "Tor control port to use if onion listening enabled (default: %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Transaction amount too small"),
QT_TRANSLATE_NOOP("teshub-core", "Transaction amounts must be positive"),
QT_TRANSLATE_NOOP("teshub-core", "Transaction created successfully."),
QT_TRANSLATE_NOOP("teshub-core", "Transaction fees are too high."),
QT_TRANSLATE_NOOP("teshub-core", "Transaction not valid."),
QT_TRANSLATE_NOOP("teshub-core", "Transaction too large for fee policy"),
QT_TRANSLATE_NOOP("teshub-core", "Transaction too large"),
QT_TRANSLATE_NOOP("teshub-core", "Transmitting final transaction."),
QT_TRANSLATE_NOOP("teshub-core", "Unable to bind to %s on this computer (bind returned error %s)"),
QT_TRANSLATE_NOOP("teshub-core", "Unable to sign spork message, wrong key?"),
QT_TRANSLATE_NOOP("teshub-core", "Unknown network specified in -onlynet: '%s'"),
QT_TRANSLATE_NOOP("teshub-core", "Unknown state: id = %u"),
QT_TRANSLATE_NOOP("teshub-core", "Upgrade wallet to latest format"),
QT_TRANSLATE_NOOP("teshub-core", "Use OpenSSL (https) for JSON-RPC connections"),
QT_TRANSLATE_NOOP("teshub-core", "Use UPnP to map the listening port (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Use UPnP to map the listening port (default: 1 when listening)"),
QT_TRANSLATE_NOOP("teshub-core", "Use a custom max chain reorganization depth (default: %u)"),
QT_TRANSLATE_NOOP("teshub-core", "Use the test network"),
QT_TRANSLATE_NOOP("teshub-core", "Username for JSON-RPC connections"),
QT_TRANSLATE_NOOP("teshub-core", "Verifying blocks..."),
QT_TRANSLATE_NOOP("teshub-core", "Verifying wallet..."),
QT_TRANSLATE_NOOP("teshub-core", "Wallet %s resides outside data directory %s"),
QT_TRANSLATE_NOOP("teshub-core", "Wallet is locked."),
QT_TRANSLATE_NOOP("teshub-core", "Wallet needed to be rewritten: restart TesHub Core to complete"),
QT_TRANSLATE_NOOP("teshub-core", "Wallet options:"),
QT_TRANSLATE_NOOP("teshub-core", "Wallet window title"),
QT_TRANSLATE_NOOP("teshub-core", "Warning"),
QT_TRANSLATE_NOOP("teshub-core", "Warning: This version is obsolete, upgrade required!"),
QT_TRANSLATE_NOOP("teshub-core", "Warning: Unsupported argument -benchmark ignored, use -debug=bench."),
QT_TRANSLATE_NOOP("teshub-core", "Warning: Unsupported argument -debugnet ignored, use -debug=net."),
QT_TRANSLATE_NOOP("teshub-core", "Will retry..."),
QT_TRANSLATE_NOOP("teshub-core", "You need to rebuild the database using -reindex to change -txindex"),
QT_TRANSLATE_NOOP("teshub-core", "Your entries added successfully."),
QT_TRANSLATE_NOOP("teshub-core", "Your transaction was accepted into the pool!"),
QT_TRANSLATE_NOOP("teshub-core", "Zapping all transactions from wallet..."),
QT_TRANSLATE_NOOP("teshub-core", "ZeroMQ notification options:"),
QT_TRANSLATE_NOOP("teshub-core", "on startup"),
QT_TRANSLATE_NOOP("teshub-core", "wallet.dat corrupt, salvage failed"),
};
| [
"OhCreativeYT@gmail.com"
] | OhCreativeYT@gmail.com |
05915e30cb2caf2b6cdef41034513c940ce959a1 | 0bc263b0eeeba9398c7ce950a1e571bb29c1653f | /HTWK_SD_FILTER/SD_SimpleDrive/IParkGap.h | 2ea67d76e634aa374c1d3060bc84c322824a53d2 | [
"BSD-2-Clause"
] | permissive | neophack/HTWK_SmartDriving_2015 | b9de57b72137e71130d33634f28e88b66ed17d71 | 95ee77aa0f9ebbb541bbb1e3b99d3f044347d103 | refs/heads/master | 2020-06-22T14:32:07.322632 | 2015-11-02T10:55:31 | 2015-11-02T10:55:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,862 | h | /**
* Copyright (c) 2014-2015, HTWK SmartDriving
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* AUTHORS: Silvio Feig, Denny Hecht, Andreas Kluge, Lars Kollmann, Eike Florian Petersen, Artem Pokas
*
*/
#ifndef _I_PARK_GAP_H_
#define _I_PARK_GAP_H_
class IParkGap
{
protected:
bool isDebugActive;
public:
//virtual bool isParkingGapFound() const = 0;
virtual bool searchParkingGap(const tInt &irValue,const tInt &distance) = 0;
virtual void setIsDebugActive(const bool &isDebugActive) = 0;
virtual void setDecision(const Decision ¤tDecision) = 0;
};
#endif | [
"gjenschmischek@gmail.com"
] | gjenschmischek@gmail.com |
00b732b715054a7e54911ac2a9399895ac5b74fc | 902ea50f2af62e54977baffcf11f73f18519cd9e | /jx_top100/166. 分数到小数.cpp | 4bd8b38e9b2e8cb18582b6d16c5319f384e25841 | [] | no_license | dh434/leetcode | 80f1436106edd83d38d50d7e21005eaaa4096ac1 | 28ea3e3d5215b23120b9477e31c5727252e19e33 | refs/heads/master | 2020-06-05T16:49:17.023493 | 2019-11-17T12:55:58 | 2019-11-17T12:55:58 | 192,487,558 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,241 | cpp | /*
给定两个整数,分别表示分数的分子 numerator 和分母 denominator,以字符串形式返回小数。
如果小数部分为循环小数,则将循环的部分括在括号内。
示例 1:
输入: numerator = 1, denominator = 2
输出: "0.5"
示例 2:
输入: numerator = 2, denominator = 1
输出: "2"
示例 3:
输入: numerator = 2, denominator = 3
输出: "0.(6)"
*/
/*
这道题细节很多
测试样例 解释
\frac{0}{1}
1
0
被除数为 0。
\frac{1}{0}
0
1
除数为 0,应当抛出异常,这里为了简单起见不考虑。
\frac{20}{4}
4
20
答案是整数,不包括小数部分。
\frac{1}{2}
2
1
答案是 0.5,是有限小数。
\frac{-1}{4}
4
−1
或 \frac{1}{-4}
−4
1
除数被除数有一个为负数,结果为负数。
\frac{-1}{-4}
−4
−1
除数和被除数都是负数,结果为正数。
\frac{-2147483648}{-1}
−1
−2147483648
转成整数时注意可能溢出。
https://leetcode-cn.com/problems/fraction-to-recurring-decimal/solution/fen-shu-dao-xiao-shu-by-leetcode/
*/
//可以直接先求整数部分的,然后再单独求小数部分
class Solution {
public:
string fractionToDecimal(int numerator, int denominator) {
if(numerator == 0)
return "0";
string res = "";
if(numerator <0 ^ denominator <0 )
res += "-";
long dividend = numerator;
long divisor = denominator;
dividend = abs(dividend);
divisor = abs(divisor);
res += to_string(dividend/divisor);
long remainder = dividend%divisor;
if(remainder == 0)
return res;
res += ".";
map<int,int> mp;
while(remainder!=0){
// cout<<remainder<<endl;
if(mp.find(remainder) != mp.end()){
res.insert(mp[remainder], "(");
res += ")";
break;
}
mp[remainder] = res.size();
remainder *= 10;
res += to_string(remainder/divisor);
remainder = remainder%divisor;
}
return res;
}
};
| [
"denghao@bupt.edu.cn"
] | denghao@bupt.edu.cn |
1e9b66f6ae84747992707636dd18dfd113f25a0a | f433402f2a3c5846d25c59c3358174e4a7ead5a3 | /automatic_sensor/src/position_search.h | c9efd94e348f151fc87cb975c13409530ee17d31 | [] | no_license | fire0ice1leaf1484/mbedST | 8167f45d5ea0feb1be30778073eadcac503ac260 | b99354d328d98af41512e3249e66c465543f5f0d | refs/heads/master | 2020-11-28T09:20:17.265457 | 2020-08-30T10:53:31 | 2020-08-30T10:53:31 | 229,756,787 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,071 | h | #ifndef POSITION___H
#define POSITION___H
#include "mbed.h"
#include "MPU6050.h"
#include "MadgwickAHRS.h"
#include "CRotaryEncoder.h"
#include "pinOutYamaShoEdition.h"
#include "functionYamaShoEdition.h"
class Point{
public:
Point(float _x, float _y, float _r, int _p);
float distanceV(float robotX, float robotY, float robotR);
float distance(float robotX, float robotY);
float x, y, r;
int p;
};
extern float aG[3]; //傾き
extern float bG[3];
extern float angle[3];
extern float gx,gy,gz;
extern float theta;
extern Thread positionThread; //座標を推定したり追従したりするスレ
extern CRotaryEncoder encY;
extern CRotaryEncoder encX;
extern double cosR;
extern double sinR;
extern double dx, dy; //ロボットのXY軸でdt間でどれだけすすんだか
extern double realX, realY, realR; //推定される座標
extern float yaw, yaw_radian; //Yaw角
extern float dt; //時間差
void position(void); //座標を推定したり追従したりするスレ
#endif | [
"agohigethirteen@gmail.com"
] | agohigethirteen@gmail.com |
703a32610e53005b8ae4bd6020c975201645e195 | b4f3934c4a10c455adebc3cdac49e13a2745a2ba | /scintilla/lexlib/CharacterCategory.cxx | ab9107b6fab8fb56e14045293ba99ba73263e35a | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"MIT",
"LicenseRef-scancode-scintilla",
"BSD-2-Clause"
] | permissive | weiling103/notepad2 | 40b11bc592bd23a306659a5efb728d9d6f9895a7 | 7842371bbbb645918f3defdc1c5a9b7959b62ada | refs/heads/master | 2023-05-25T07:17:35.100852 | 2021-06-03T14:08:46 | 2021-06-03T14:08:46 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 117,652 | cxx | // Scintilla source code edit control
/** @file CharacterCategory.cxx
** Returns the Unicode general category of a character.
** Table automatically regenerated by scripts/GenerateCharacterCategory.py
** Should only be rarely regenerated for new versions of Unicode.
**/
// Copyright 2013 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <vector>
#include <algorithm>
#include <iterator>
#include "CharacterCategory.h"
namespace Lexilla {
namespace {
// Use an unnamed namespace to protect the declarations from name conflicts
//++Autogenerated -- start of section automatically generated
// Created with Python 3.9.0, Unicode 13.0.0
#if CHARACTERCATEGORY_OPTIMIZE_LATIN1
const unsigned char catLatin[] = {
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
22, 17, 17, 17, 19, 17, 17, 17, 13, 14, 17, 18, 17, 12, 17, 17,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 17, 17, 18, 18, 18, 17,
17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 17, 14, 20, 11,
20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 18, 14, 18, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
22, 17, 19, 19, 19, 19, 21, 17, 20, 21, 4, 15, 18, 26, 21, 20,
21, 18, 10, 10, 20, 1, 17, 17, 20, 10, 4, 16, 10, 10, 10, 17,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 18, 1, 1, 1, 1, 1, 1, 1, 1,
};
#endif
#if CHARACTERCATEGORY_USE_BINARY_SEARCH
const int catRanges[] = {
25,
1046,
1073,
1171,
1201,
1293,
1326,
1361,
1394,
1425,
1452,
1489,
1544,
1873,
1938,
2033,
2080,
2925,
2961,
2990,
3028,
3051,
3092,
3105,
3949,
3986,
4014,
4050,
4089,
5142,
5169,
5203,
5333,
5361,
5396,
5429,
5444,
5487,
5522,
5562,
5589,
5620,
5653,
5682,
5706,
5780,
5793,
5841,
5908,
5930,
5956,
6000,
6026,
6129,
6144,
6898,
6912,
7137,
7922,
7937,
8192,
8225,
8256,
8289,
8320,
8353,
8384,
8417,
8448,
8481,
8512,
8545,
8576,
8609,
8640,
8673,
8704,
8737,
8768,
8801,
8832,
8865,
8896,
8929,
8960,
8993,
9024,
9057,
9088,
9121,
9152,
9185,
9216,
9249,
9280,
9313,
9344,
9377,
9408,
9441,
9472,
9505,
9536,
9569,
9600,
9633,
9664,
9697,
9728,
9761,
9792,
9825,
9856,
9889,
9920,
9953,
10016,
10049,
10080,
10113,
10144,
10177,
10208,
10241,
10272,
10305,
10336,
10369,
10400,
10433,
10464,
10497,
10560,
10593,
10624,
10657,
10688,
10721,
10752,
10785,
10816,
10849,
10880,
10913,
10944,
10977,
11008,
11041,
11072,
11105,
11136,
11169,
11200,
11233,
11264,
11297,
11328,
11361,
11392,
11425,
11456,
11489,
11520,
11553,
11584,
11617,
11648,
11681,
11712,
11745,
11776,
11809,
11840,
11873,
11904,
11937,
11968,
12001,
12032,
12097,
12128,
12161,
12192,
12225,
12320,
12385,
12416,
12449,
12480,
12545,
12576,
12673,
12736,
12865,
12896,
12961,
12992,
13089,
13184,
13249,
13280,
13345,
13376,
13409,
13440,
13473,
13504,
13569,
13600,
13633,
13696,
13729,
13760,
13825,
13856,
13953,
13984,
14017,
14048,
14113,
14180,
14208,
14241,
14340,
14464,
14498,
14529,
14560,
14594,
14625,
14656,
14690,
14721,
14752,
14785,
14816,
14849,
14880,
14913,
14944,
14977,
15008,
15041,
15072,
15105,
15136,
15169,
15200,
15233,
15296,
15329,
15360,
15393,
15424,
15457,
15488,
15521,
15552,
15585,
15616,
15649,
15680,
15713,
15744,
15777,
15808,
15841,
15904,
15938,
15969,
16000,
16033,
16064,
16161,
16192,
16225,
16256,
16289,
16320,
16353,
16384,
16417,
16448,
16481,
16512,
16545,
16576,
16609,
16640,
16673,
16704,
16737,
16768,
16801,
16832,
16865,
16896,
16929,
16960,
16993,
17024,
17057,
17088,
17121,
17152,
17185,
17216,
17249,
17280,
17313,
17344,
17377,
17408,
17441,
17472,
17505,
17536,
17569,
17600,
17633,
17664,
17697,
17728,
17761,
17792,
17825,
17856,
17889,
17920,
17953,
17984,
18017,
18240,
18305,
18336,
18401,
18464,
18497,
18528,
18657,
18688,
18721,
18752,
18785,
18816,
18849,
18880,
18913,
21124,
21153,
22019,
22612,
22723,
23124,
23555,
23732,
23939,
23988,
24003,
24052,
24581,
28160,
28193,
28224,
28257,
28291,
28340,
28352,
28385,
28445,
28483,
28513,
28625,
28640,
28701,
28820,
28864,
28913,
28928,
29053,
29056,
29117,
29120,
29185,
29216,
29789,
29792,
30081,
31200,
31233,
31296,
31393,
31488,
31521,
31552,
31585,
31616,
31649,
31680,
31713,
31744,
31777,
31808,
31841,
31872,
31905,
31936,
31969,
32000,
32033,
32064,
32097,
32128,
32161,
32192,
32225,
32384,
32417,
32466,
32480,
32513,
32544,
32609,
32672,
34305,
35840,
35873,
35904,
35937,
35968,
36001,
36032,
36065,
36096,
36129,
36160,
36193,
36224,
36257,
36288,
36321,
36352,
36385,
36416,
36449,
36480,
36513,
36544,
36577,
36608,
36641,
36672,
36705,
36736,
36769,
36800,
36833,
36864,
36897,
36949,
36965,
37127,
37184,
37217,
37248,
37281,
37312,
37345,
37376,
37409,
37440,
37473,
37504,
37537,
37568,
37601,
37632,
37665,
37696,
37729,
37760,
37793,
37824,
37857,
37888,
37921,
37952,
37985,
38016,
38049,
38080,
38113,
38144,
38177,
38208,
38241,
38272,
38305,
38336,
38369,
38400,
38433,
38464,
38497,
38528,
38561,
38592,
38625,
38656,
38689,
38720,
38753,
38784,
38817,
38848,
38881,
38912,
38977,
39008,
39041,
39072,
39105,
39136,
39169,
39200,
39233,
39264,
39297,
39328,
39361,
39424,
39457,
39488,
39521,
39552,
39585,
39616,
39649,
39680,
39713,
39744,
39777,
39808,
39841,
39872,
39905,
39936,
39969,
40000,
40033,
40064,
40097,
40128,
40161,
40192,
40225,
40256,
40289,
40320,
40353,
40384,
40417,
40448,
40481,
40512,
40545,
40576,
40609,
40640,
40673,
40704,
40737,
40768,
40801,
40832,
40865,
40896,
40929,
40960,
40993,
41024,
41057,
41088,
41121,
41152,
41185,
41216,
41249,
41280,
41313,
41344,
41377,
41408,
41441,
41472,
41505,
41536,
41569,
41600,
41633,
41664,
41697,
41728,
41761,
41792,
41825,
41856,
41889,
41920,
41953,
41984,
42017,
42048,
42081,
42112,
42145,
42176,
42209,
42240,
42273,
42304,
42337,
42368,
42401,
42432,
42465,
42525,
42528,
43773,
43811,
43857,
44033,
45361,
45388,
45437,
45493,
45555,
45597,
45605,
47052,
47077,
47121,
47141,
47217,
47237,
47313,
47333,
47389,
47620,
48509,
48612,
48753,
48829,
49178,
49362,
49457,
49523,
49553,
49621,
49669,
50033,
50074,
50109,
50129,
50180,
51203,
51236,
51557,
52232,
52561,
52676,
52741,
52772,
55953,
55972,
56005,
56250,
56277,
56293,
56483,
56549,
56629,
56645,
56772,
56840,
57156,
57269,
57316,
57361,
57821,
57850,
57860,
57893,
57924,
58885,
59773,
59812,
62661,
63012,
63069,
63496,
63812,
64869,
65155,
65237,
65265,
65347,
65405,
65445,
65491,
65540,
66245,
66371,
66405,
66691,
66725,
66819,
66853,
67037,
67089,
67581,
67588,
68389,
68509,
68561,
68605,
68612,
68989,
70660,
71357,
71364,
71965,
72293,
72794,
72805,
73830,
73860,
75589,
75622,
75653,
75684,
75718,
75813,
76070,
76197,
76230,
76292,
76325,
76548,
76869,
76945,
77000,
77329,
77347,
77380,
77861,
77894,
77981,
77988,
78269,
78308,
78397,
78436,
79165,
79172,
79421,
79428,
79485,
79556,
79709,
79749,
79780,
79814,
79909,
80061,
80102,
80189,
80230,
80293,
80324,
80381,
80614,
80669,
80772,
80861,
80868,
80965,
81053,
81096,
81412,
81491,
81546,
81749,
81779,
81796,
81841,
81861,
81917,
81957,
82022,
82077,
82084,
82301,
82404,
82493,
82532,
83261,
83268,
83517,
83524,
83613,
83620,
83709,
83716,
83805,
83845,
83901,
83910,
84005,
84093,
84197,
84285,
84325,
84445,
84517,
84573,
84772,
84925,
84932,
84989,
85192,
85509,
85572,
85669,
85713,
85757,
86053,
86118,
86173,
86180,
86493,
86500,
86621,
86628,
87357,
87364,
87613,
87620,
87709,
87716,
87901,
87941,
87972,
88006,
88101,
88285,
88293,
88358,
88413,
88422,
88485,
88541,
88580,
88637,
89092,
89157,
89245,
89288,
89617,
89651,
89693,
89892,
89925,
90141,
90149,
90182,
90269,
90276,
90557,
90596,
90685,
90724,
91453,
91460,
91709,
91716,
91805,
91812,
91997,
92037,
92068,
92102,
92133,
92166,
92197,
92349,
92390,
92477,
92518,
92581,
92637,
92837,
92902,
92957,
93060,
93149,
93156,
93253,
93341,
93384,
93717,
93732,
93770,
93981,
94277,
94308,
94365,
94372,
94589,
94660,
94781,
94788,
94941,
95012,
95101,
95108,
95165,
95172,
95261,
95332,
95421,
95492,
95613,
95684,
96093,
96198,
96261,
96294,
96381,
96454,
96573,
96582,
96677,
96733,
96772,
96829,
96998,
97053,
97480,
97802,
97909,
98099,
98133,
98173,
98309,
98342,
98437,
98468,
98749,
98756,
98877,
98884,
99645,
99652,
100189,
100260,
100293,
100390,
100541,
100549,
100669,
100677,
100829,
101029,
101117,
101124,
101245,
101380,
101445,
101533,
101576,
101917,
102129,
102154,
102389,
102404,
102437,
102470,
102545,
102564,
102845,
102852,
102973,
102980,
103741,
103748,
104093,
104100,
104285,
104325,
104356,
104390,
104421,
104454,
104637,
104645,
104678,
104765,
104774,
104837,
104925,
105126,
105213,
105412,
105469,
105476,
105541,
105629,
105672,
106013,
106020,
106109,
106501,
106566,
106628,
106941,
106948,
107069,
107076,
108389,
108452,
108486,
108581,
108733,
108742,
108861,
108870,
108965,
108996,
109045,
109085,
109188,
109286,
109322,
109540,
109637,
109725,
109768,
110090,
110389,
110404,
110621,
110629,
110662,
110749,
110756,
111357,
111428,
112221,
112228,
112541,
112548,
112605,
112644,
112893,
112965,
113021,
113126,
113221,
113341,
113349,
113405,
113414,
113693,
113864,
114205,
114246,
114321,
114365,
114724,
116261,
116292,
116357,
116605,
116723,
116740,
116931,
116965,
117233,
117256,
117585,
117661,
118820,
118909,
118916,
118973,
118980,
119165,
119172,
119965,
119972,
120029,
120036,
120357,
120388,
120453,
120740,
120797,
120836,
121021,
121027,
121085,
121093,
121309,
121352,
121693,
121732,
121885,
122884,
122933,
123025,
123509,
123537,
123573,
123653,
123733,
123912,
124234,
124565,
124581,
124629,
124645,
124693,
124709,
124749,
124782,
124813,
124846,
124870,
124932,
125213,
125220,
126397,
126501,
126950,
126981,
127153,
127173,
127236,
127397,
127773,
127781,
128957,
128981,
129221,
129269,
129469,
129493,
129553,
129717,
129841,
129917,
131076,
132454,
132517,
132646,
132677,
132870,
132901,
132966,
133029,
133092,
133128,
133457,
133636,
133830,
133893,
133956,
134085,
134180,
134214,
134308,
134374,
134596,
134693,
134820,
135237,
135270,
135333,
135398,
135589,
135620,
135654,
135688,
136006,
136101,
136149,
136192,
137437,
137440,
137501,
137632,
137693,
137729,
139121,
139139,
139169,
139268,
149821,
149828,
149981,
150020,
150269,
150276,
150333,
150340,
150493,
150532,
151869,
151876,
152029,
152068,
153149,
153156,
153309,
153348,
153597,
153604,
153661,
153668,
153821,
153860,
154365,
154372,
156221,
156228,
156381,
156420,
158589,
158629,
158737,
159018,
159677,
159748,
160277,
160605,
160768,
163549,
163585,
163805,
163852,
163876,
183733,
183761,
183780,
184342,
184356,
185197,
185230,
185277,
185348,
187761,
187849,
187940,
188221,
188420,
188861,
188868,
188997,
189117,
189444,
190021,
190129,
190205,
190468,
191045,
191133,
191492,
191933,
191940,
192061,
192069,
192157,
192516,
194181,
194246,
194277,
194502,
194757,
194790,
194853,
195217,
195299,
195345,
195443,
195460,
195493,
195549,
195592,
195933,
196106,
196445,
196625,
196812,
196849,
196965,
197082,
197117,
197128,
197469,
197636,
198755,
198788,
200509,
200708,
200869,
200932,
202021,
202052,
202109,
202244,
204509,
204804,
205821,
205829,
205926,
206053,
206118,
206237,
206342,
206405,
206438,
206629,
206749,
206869,
206909,
206993,
207048,
207364,
208349,
208388,
208573,
208900,
210333,
210436,
211293,
211464,
211786,
211837,
211925,
212996,
213733,
213798,
213861,
213917,
213969,
214020,
215718,
215749,
215782,
215813,
216061,
216069,
216102,
216133,
216166,
216229,
216486,
216677,
217021,
217061,
217096,
217437,
217608,
217949,
218129,
218339,
218385,
218589,
218629,
219079,
219109,
219197,
221189,
221318,
221348,
222853,
222886,
222917,
223078,
223109,
223142,
223301,
223334,
223396,
223645,
223752,
224081,
224309,
224613,
224917,
225213,
225285,
225350,
225380,
226342,
226373,
226502,
226565,
226630,
226661,
226756,
226824,
227140,
228549,
228582,
228613,
228678,
228773,
228806,
228837,
228934,
229021,
229265,
229380,
230534,
230789,
231046,
231109,
231197,
231281,
231432,
231773,
231844,
231944,
232260,
233219,
233425,
233473,
233789,
233984,
235389,
235424,
235537,
235805,
236037,
236145,
236165,
236582,
236613,
236836,
236965,
236996,
237189,
237220,
237286,
237317,
237380,
237437,
237569,
238979,
240993,
241411,
241441,
242531,
243717,
245597,
245605,
245760,
245793,
245824,
245857,
245888,
245921,
245952,
245985,
246016,
246049,
246080,
246113,
246144,
246177,
246208,
246241,
246272,
246305,
246336,
246369,
246400,
246433,
246464,
246497,
246528,
246561,
246592,
246625,
246656,
246689,
246720,
246753,
246784,
246817,
246848,
246881,
246912,
246945,
246976,
247009,
247040,
247073,
247104,
247137,
247168,
247201,
247232,
247265,
247296,
247329,
247360,
247393,
247424,
247457,
247488,
247521,
247552,
247585,
247616,
247649,
247680,
247713,
247744,
247777,
247808,
247841,
247872,
247905,
247936,
247969,
248000,
248033,
248064,
248097,
248128,
248161,
248192,
248225,
248256,
248289,
248320,
248353,
248384,
248417,
248448,
248481,
248512,
248545,
248576,
248609,
248640,
248673,
248704,
248737,
248768,
248801,
248832,
248865,
248896,
248929,
248960,
248993,
249024,
249057,
249088,
249121,
249152,
249185,
249216,
249249,
249280,
249313,
249344,
249377,
249408,
249441,
249472,
249505,
249536,
249569,
249600,
249633,
249664,
249697,
249728,
249761,
249792,
249825,
249856,
249889,
249920,
249953,
249984,
250017,
250048,
250081,
250112,
250145,
250176,
250209,
250240,
250273,
250304,
250337,
250368,
250401,
250432,
250465,
250496,
250529,
250816,
250849,
250880,
250913,
250944,
250977,
251008,
251041,
251072,
251105,
251136,
251169,
251200,
251233,
251264,
251297,
251328,
251361,
251392,
251425,
251456,
251489,
251520,
251553,
251584,
251617,
251648,
251681,
251712,
251745,
251776,
251809,
251840,
251873,
251904,
251937,
251968,
252001,
252032,
252065,
252096,
252129,
252160,
252193,
252224,
252257,
252288,
252321,
252352,
252385,
252416,
252449,
252480,
252513,
252544,
252577,
252608,
252641,
252672,
252705,
252736,
252769,
252800,
252833,
252864,
252897,
252928,
252961,
252992,
253025,
253056,
253089,
253120,
253153,
253184,
253217,
253248,
253281,
253312,
253345,
253376,
253409,
253440,
253473,
253504,
253537,
253568,
253601,
253632,
253665,
253696,
253729,
253760,
253793,
253824,
253857,
253888,
253921,
254208,
254465,
254685,
254720,
254941,
254977,
255232,
255489,
255744,
256001,
256221,
256256,
256477,
256513,
256797,
256800,
256861,
256864,
256925,
256928,
256989,
256992,
257025,
257280,
257537,
258013,
258049,
258306,
258561,
258818,
259073,
259330,
259585,
259773,
259777,
259840,
259970,
260020,
260033,
260084,
260161,
260285,
260289,
260352,
260482,
260532,
260609,
260765,
260801,
260864,
261021,
261044,
261121,
261376,
261556,
261661,
261697,
261821,
261825,
261888,
262018,
262068,
262141,
262166,
262522,
262668,
262865,
262927,
262960,
262989,
263023,
263088,
263117,
263151,
263185,
263447,
263480,
263514,
263670,
263697,
263983,
264016,
264049,
264171,
264241,
264338,
264365,
264398,
264433,
264786,
264817,
264843,
264881,
265206,
265242,
265405,
265434,
265738,
265763,
265821,
265866,
266066,
266157,
266190,
266211,
266250,
266578,
266669,
266702,
266749,
266755,
267197,
267283,
268317,
268805,
269223,
269349,
269383,
269477,
269885,
270357,
270400,
270453,
270560,
270613,
270657,
270688,
270785,
270848,
270945,
270997,
271008,
271061,
271122,
271136,
271317,
271488,
271541,
271552,
271605,
271616,
271669,
271680,
271829,
271841,
271872,
272001,
272036,
272161,
272213,
272257,
272320,
272402,
272544,
272577,
272725,
272754,
272789,
272833,
272885,
272906,
273417,
274528,
274561,
274601,
274730,
274773,
274845,
274962,
275125,
275282,
275349,
275474,
275509,
275570,
275605,
275666,
275701,
275922,
275957,
276946,
277013,
277074,
277109,
277138,
277173,
278162,
286741,
286989,
287022,
287053,
287086,
287125,
287762,
287829,
288045,
288078,
288117,
290706,
290741,
291698,
292501,
293778,
293973,
296189,
296981,
297341,
297994,
299925,
302410,
303125,
308978,
309013,
309298,
309333,
311058,
311317,
314866,
314901,
322829,
322862,
322893,
322926,
322957,
322990,
323021,
323054,
323085,
323118,
323149,
323182,
323213,
323246,
323274,
324245,
325650,
325805,
325838,
325874,
326861,
326894,
326925,
326958,
326989,
327022,
327053,
327086,
327117,
327150,
327186,
327701,
335890,
340077,
340110,
340141,
340174,
340205,
340238,
340269,
340302,
340333,
340366,
340397,
340430,
340461,
340494,
340525,
340558,
340589,
340622,
340653,
340686,
340717,
340750,
340786,
342797,
342830,
342861,
342894,
342930,
343949,
343982,
344018,
352277,
353810,
354485,
354546,
354741,
355997,
356053,
357085,
357109,
360448,
361981,
361985,
363517,
363520,
363553,
363584,
363681,
363744,
363777,
363808,
363841,
363872,
363905,
363936,
364065,
364096,
364129,
364192,
364225,
364419,
364480,
364577,
364608,
364641,
364672,
364705,
364736,
364769,
364800,
364833,
364864,
364897,
364928,
364961,
364992,
365025,
365056,
365089,
365120,
365153,
365184,
365217,
365248,
365281,
365312,
365345,
365376,
365409,
365440,
365473,
365504,
365537,
365568,
365601,
365632,
365665,
365696,
365729,
365760,
365793,
365824,
365857,
365888,
365921,
365952,
365985,
366016,
366049,
366080,
366113,
366144,
366177,
366208,
366241,
366272,
366305,
366336,
366369,
366400,
366433,
366464,
366497,
366528,
366561,
366592,
366625,
366656,
366689,
366720,
366753,
366784,
366817,
366848,
366881,
366912,
366945,
366976,
367009,
367040,
367073,
367104,
367137,
367168,
367201,
367232,
367265,
367296,
367329,
367360,
367393,
367424,
367457,
367488,
367521,
367552,
367585,
367616,
367649,
367680,
367713,
367797,
367968,
368001,
368032,
368065,
368101,
368192,
368225,
368285,
368433,
368554,
368593,
368641,
369885,
369889,
369949,
370081,
370141,
370180,
371997,
372195,
372241,
372285,
372709,
372740,
373501,
373764,
374013,
374020,
374269,
374276,
374525,
374532,
374781,
374788,
375037,
375044,
375293,
375300,
375549,
375556,
375805,
375813,
376849,
376911,
376944,
376975,
377008,
377041,
377135,
377168,
377201,
377231,
377264,
377297,
377580,
377617,
377676,
377713,
377743,
377776,
377809,
377871,
377904,
377933,
377966,
377997,
378030,
378061,
378094,
378125,
378158,
378193,
378339,
378385,
378700,
378769,
378892,
378929,
378957,
378993,
379413,
379473,
379517,
380949,
381789,
381813,
384669,
385045,
391901,
392725,
393117,
393238,
393265,
393365,
393379,
393412,
393449,
393485,
393518,
393549,
393582,
393613,
393646,
393677,
393710,
393741,
393774,
393813,
393869,
393902,
393933,
393966,
393997,
394030,
394061,
394094,
394124,
394157,
394190,
394261,
394281,
394565,
394694,
394764,
394787,
394965,
395017,
395107,
395140,
395185,
395221,
395293,
395300,
398077,
398117,
398196,
398243,
398308,
398348,
398372,
401265,
401283,
401380,
401437,
401572,
402973,
402980,
406013,
406037,
406090,
406229,
406532,
407573,
408733,
409092,
409621,
410621,
410634,
410965,
411914,
412181,
412202,
412693,
413706,
414037,
415274,
415765,
425988,
636949,
638980,
1310653,
1310724,
1311395,
1311428,
1348029,
1348117,
1349885,
1350148,
1351427,
1351633,
1351684,
1360259,
1360305,
1360388,
1360904,
1361220,
1361309,
1361920,
1361953,
1361984,
1362017,
1362048,
1362081,
1362112,
1362145,
1362176,
1362209,
1362240,
1362273,
1362304,
1362337,
1362368,
1362401,
1362432,
1362465,
1362496,
1362529,
1362560,
1362593,
1362624,
1362657,
1362688,
1362721,
1362752,
1362785,
1362816,
1362849,
1362880,
1362913,
1362944,
1362977,
1363008,
1363041,
1363072,
1363105,
1363136,
1363169,
1363200,
1363233,
1363264,
1363297,
1363328,
1363361,
1363396,
1363429,
1363463,
1363569,
1363589,
1363921,
1363939,
1363968,
1364001,
1364032,
1364065,
1364096,
1364129,
1364160,
1364193,
1364224,
1364257,
1364288,
1364321,
1364352,
1364385,
1364416,
1364449,
1364480,
1364513,
1364544,
1364577,
1364608,
1364641,
1364672,
1364705,
1364736,
1364769,
1364800,
1364833,
1364867,
1364933,
1364996,
1367241,
1367557,
1367633,
1367837,
1368084,
1368803,
1369108,
1369152,
1369185,
1369216,
1369249,
1369280,
1369313,
1369344,
1369377,
1369408,
1369441,
1369472,
1369505,
1369536,
1369569,
1369664,
1369697,
1369728,
1369761,
1369792,
1369825,
1369856,
1369889,
1369920,
1369953,
1369984,
1370017,
1370048,
1370081,
1370112,
1370145,
1370176,
1370209,
1370240,
1370273,
1370304,
1370337,
1370368,
1370401,
1370432,
1370465,
1370496,
1370529,
1370560,
1370593,
1370624,
1370657,
1370688,
1370721,
1370752,
1370785,
1370816,
1370849,
1370880,
1370913,
1370944,
1370977,
1371008,
1371041,
1371072,
1371105,
1371136,
1371169,
1371200,
1371233,
1371264,
1371297,
1371328,
1371361,
1371392,
1371425,
1371456,
1371489,
1371520,
1371553,
1371584,
1371617,
1371651,
1371681,
1371936,
1371969,
1372000,
1372033,
1372064,
1372129,
1372160,
1372193,
1372224,
1372257,
1372288,
1372321,
1372352,
1372385,
1372419,
1372468,
1372512,
1372545,
1372576,
1372609,
1372644,
1372672,
1372705,
1372736,
1372769,
1372864,
1372897,
1372928,
1372961,
1372992,
1373025,
1373056,
1373089,
1373120,
1373153,
1373184,
1373217,
1373248,
1373281,
1373312,
1373345,
1373376,
1373409,
1373440,
1373473,
1373504,
1373665,
1373696,
1373857,
1373888,
1373921,
1373952,
1373985,
1374016,
1374049,
1374080,
1374113,
1374144,
1374177,
1374237,
1374272,
1374305,
1374336,
1374465,
1374496,
1374529,
1374589,
1375904,
1375937,
1375972,
1376003,
1376065,
1376100,
1376325,
1376356,
1376453,
1376484,
1376613,
1376644,
1377382,
1377445,
1377510,
1377557,
1377669,
1377725,
1377802,
1378005,
1378067,
1378101,
1378141,
1378308,
1379985,
1380125,
1380358,
1380420,
1382022,
1382533,
1382621,
1382865,
1382920,
1383261,
1383429,
1384004,
1384209,
1384292,
1384337,
1384356,
1384421,
1384456,
1384772,
1385669,
1385937,
1385988,
1386725,
1387078,
1387165,
1387505,
1387524,
1388477,
1388549,
1388646,
1388676,
1390181,
1390214,
1390277,
1390406,
1390469,
1390534,
1390641,
1391069,
1391075,
1391112,
1391453,
1391569,
1391620,
1391781,
1391811,
1391844,
1392136,
1392452,
1392637,
1392644,
1393957,
1394150,
1394213,
1394278,
1394341,
1394429,
1394692,
1394789,
1394820,
1395077,
1395110,
1395165,
1395208,
1395549,
1395601,
1395716,
1396227,
1396260,
1396469,
1396548,
1396582,
1396613,
1396646,
1396676,
1398277,
1398308,
1398341,
1398436,
1398501,
1398564,
1398725,
1398788,
1398821,
1398852,
1398909,
1399652,
1399715,
1399761,
1399812,
1400166,
1400197,
1400262,
1400337,
1400388,
1400419,
1400486,
1400517,
1400573,
1400868,
1401085,
1401124,
1401341,
1401380,
1401597,
1401860,
1402109,
1402116,
1402365,
1402369,
1403764,
1403779,
1403905,
1404195,
1404244,
1404317,
1404417,
1406980,
1408102,
1408165,
1408198,
1408261,
1408294,
1408369,
1408390,
1408421,
1408477,
1408520,
1408861,
1409028,
1766557,
1766916,
1767677,
1767780,
1769373,
1769499,
1835036,
2039812,
2051549,
2051588,
2055005,
2056193,
2056445,
2056801,
2056989,
2057124,
2057157,
2057188,
2057522,
2057540,
2057981,
2057988,
2058173,
2058180,
2058237,
2058244,
2058333,
2058340,
2058429,
2058436,
2061908,
2062429,
2062948,
2074574,
2074605,
2074653,
2075140,
2077213,
2077252,
2079005,
2080260,
2080659,
2080693,
2080733,
2080773,
2081297,
2081517,
2081550,
2081585,
2081629,
2081797,
2082321,
2082348,
2082411,
2082477,
2082510,
2082541,
2082574,
2082605,
2082638,
2082669,
2082702,
2082733,
2082766,
2082797,
2082830,
2082861,
2082894,
2082925,
2082958,
2082993,
2083053,
2083086,
2083121,
2083243,
2083345,
2083453,
2083473,
2083596,
2083629,
2083662,
2083693,
2083726,
2083757,
2083790,
2083825,
2083922,
2083948,
2083986,
2084093,
2084113,
2084147,
2084177,
2084253,
2084356,
2084541,
2084548,
2088893,
2088954,
2088989,
2089009,
2089107,
2089137,
2089229,
2089262,
2089297,
2089330,
2089361,
2089388,
2089425,
2089480,
2089809,
2089874,
2089969,
2090016,
2090861,
2090897,
2090926,
2090964,
2090987,
2091028,
2091041,
2091885,
2091922,
2091950,
2091986,
2092013,
2092046,
2092081,
2092109,
2092142,
2092177,
2092228,
2092547,
2092580,
2094019,
2094084,
2095101,
2095172,
2095389,
2095428,
2095645,
2095684,
2095901,
2095940,
2096061,
2096147,
2096210,
2096244,
2096277,
2096307,
2096381,
2096405,
2096434,
2096565,
2096637,
2096954,
2097045,
2097117,
2097156,
2097565,
2097572,
2098429,
2098436,
2099069,
2099076,
2099165,
2099172,
2099677,
2099716,
2100189,
2101252,
2105213,
2105361,
2105469,
2105578,
2107037,
2107125,
2107401,
2109098,
2109237,
2109770,
2109845,
2109949,
2109973,
2110397,
2110485,
2110525,
2112021,
2113445,
2113501,
2117636,
2118589,
2118660,
2120253,
2120709,
2120746,
2121629,
2121732,
2122762,
2122909,
2123172,
2123817,
2123844,
2124105,
2124157,
2124292,
2125509,
2125693,
2125828,
2126813,
2126833,
2126852,
2128029,
2128132,
2128401,
2128425,
2128605,
2129920,
2131201,
2132484,
2135005,
2135048,
2135389,
2135552,
2136733,
2136833,
2138013,
2138116,
2139421,
2139652,
2141341,
2141681,
2141725,
2146308,
2156285,
2156548,
2157277,
2157572,
2157853,
2162692,
2162909,
2162948,
2163005,
2163012,
2164445,
2164452,
2164541,
2164612,
2164669,
2164708,
2165469,
2165489,
2165514,
2165764,
2166517,
2166570,
2166788,
2167805,
2168042,
2168349,
2169860,
2170493,
2170500,
2170589,
2170730,
2170884,
2171594,
2171805,
2171889,
2171908,
2172765,
2172913,
2172957,
2174980,
2176797,
2176906,
2176964,
2177034,
2177565,
2177610,
2179076,
2179109,
2179229,
2179237,
2179325,
2179461,
2179588,
2179741,
2179748,
2179869,
2179876,
2180829,
2180869,
2180989,
2181093,
2181130,
2181437,
2181649,
2181949,
2182148,
2183082,
2183153,
2183172,
2184106,
2184221,
2185220,
2185493,
2185508,
2186405,
2186493,
2186602,
2186769,
2187005,
2187268,
2189021,
2189105,
2189316,
2190045,
2190090,
2190340,
2190973,
2191114,
2191364,
2191965,
2192177,
2192317,
2192682,
2192925,
2195460,
2197821,
2199552,
2201213,
2201601,
2203261,
2203466,
2203652,
2204805,
2204957,
2205192,
2205533,
2214922,
2215933,
2215940,
2217309,
2217317,
2217388,
2217437,
2217476,
2217565,
2220036,
2220970,
2221284,
2221341,
2221572,
2222277,
2222634,
2222769,
2222941,
2225668,
2226346,
2226589,
2227204,
2227965,
2228230,
2228261,
2228294,
2228324,
2230021,
2230513,
2230749,
2230858,
2231496,
2231837,
2232293,
2232390,
2232420,
2233862,
2233957,
2234086,
2234149,
2234225,
2234298,
2234321,
2234461,
2234810,
2234845,
2234884,
2235709,
2235912,
2236253,
2236421,
2236516,
2237669,
2237830,
2237861,
2238141,
2238152,
2238481,
2238596,
2238630,
2238692,
2238749,
2238980,
2240101,
2240145,
2240196,
2240253,
2240517,
2240582,
2240612,
2242150,
2242245,
2242534,
2242596,
2242737,
2242853,
2242993,
2243014,
2243045,
2243080,
2243396,
2243441,
2243460,
2243505,
2243613,
2243626,
2244285,
2244612,
2245213,
2245220,
2246022,
2246117,
2246214,
2246277,
2246310,
2246341,
2246417,
2246597,
2246653,
2248708,
2248957,
2248964,
2249021,
2249028,
2249181,
2249188,
2249693,
2249700,
2250033,
2250077,
2250244,
2251749,
2251782,
2251877,
2252157,
2252296,
2252637,
2252805,
2252870,
2252957,
2252964,
2253245,
2253284,
2253373,
2253412,
2254141,
2254148,
2254397,
2254404,
2254493,
2254500,
2254685,
2254693,
2254756,
2254790,
2254853,
2254886,
2255037,
2255078,
2255165,
2255206,
2255325,
2255364,
2255421,
2255590,
2255645,
2255780,
2255942,
2256029,
2256069,
2256317,
2256389,
2256573,
2260996,
2262694,
2262789,
2263046,
2263109,
2263206,
2263237,
2263268,
2263409,
2263560,
2263889,
2263965,
2263985,
2264005,
2264036,
2264157,
2265092,
2266630,
2266725,
2266918,
2266949,
2266982,
2267109,
2267174,
2267205,
2267268,
2267345,
2267364,
2267421,
2267656,
2267997,
2273284,
2274790,
2274885,
2275037,
2275078,
2275205,
2275270,
2275301,
2275377,
2276100,
2276229,
2276317,
2277380,
2278918,
2279013,
2279270,
2279333,
2279366,
2279397,
2279473,
2279556,
2279613,
2279944,
2280285,
2280465,
2280893,
2281476,
2282853,
2282886,
2282917,
2282950,
2283013,
2283206,
2283237,
2283268,
2283325,
2283528,
2283869,
2285572,
2286461,
2286501,
2286598,
2286661,
2286790,
2286821,
2287005,
2287112,
2287434,
2287505,
2287605,
2287645,
2293764,
2295174,
2295269,
2295558,
2295589,
2295665,
2295709,
2298880,
2299905,
2300936,
2301258,
2301565,
2301924,
2302205,
2302244,
2302301,
2302340,
2302621,
2302628,
2302717,
2302724,
2303494,
2303709,
2303718,
2303805,
2303845,
2303910,
2303941,
2303972,
2304006,
2304036,
2304070,
2304101,
2304145,
2304253,
2304520,
2304861,
2307076,
2307357,
2307396,
2308646,
2308741,
2308893,
2308933,
2308998,
2309125,
2309156,
2309201,
2309220,
2309254,
2309309,
2310148,
2310181,
2310500,
2311781,
2311974,
2312004,
2312037,
2312177,
2312421,
2312477,
2312708,
2312741,
2312934,
2312997,
2313092,
2314565,
2314982,
2315013,
2315089,
2315172,
2315217,
2315389,
2316292,
2318141,
2326532,
2326845,
2326852,
2328038,
2328069,
2328317,
2328325,
2328518,
2328549,
2328580,
2328625,
2328797,
2329096,
2329418,
2330045,
2330129,
2330180,
2331165,
2331205,
2331933,
2331942,
2331973,
2332198,
2332229,
2332294,
2332325,
2332413,
2334724,
2334973,
2334980,
2335069,
2335076,
2336293,
2336509,
2336581,
2336637,
2336645,
2336733,
2336741,
2336964,
2336997,
2337053,
2337288,
2337629,
2337796,
2338013,
2338020,
2338109,
2338116,
2339142,
2339325,
2339333,
2339421,
2339430,
2339493,
2339526,
2339557,
2339588,
2339645,
2339848,
2340189,
2350084,
2350693,
2350758,
2350833,
2350909,
2356740,
2356797,
2357258,
2357941,
2358195,
2358325,
2358877,
2359281,
2359300,
2388829,
2392073,
2395645,
2395665,
2395837,
2396164,
2402461,
2490372,
2524669,
2524698,
2524989,
2654212,
2672893,
2949124,
2967357,
2967556,
2968573,
2968584,
2968925,
2969041,
2969117,
2972164,
2973149,
2973189,
2973361,
2973405,
2973700,
2975237,
2975473,
2975637,
2975747,
2975889,
2975925,
2975965,
2976264,
2976605,
2976618,
2976861,
2976868,
2977565,
2977700,
2978333,
3000320,
3001345,
3002378,
3003121,
3003261,
3006468,
3008893,
3008997,
3009028,
3009062,
3010845,
3011045,
3011171,
3011613,
3013635,
3013713,
3013731,
3013765,
3013821,
3014150,
3014237,
3014660,
3211037,
3211268,
3250909,
3252228,
3252541,
3538948,
3548157,
3549700,
3549821,
3550340,
3550493,
3550724,
3563421,
3637252,
3640701,
3640836,
3641277,
3641348,
3641661,
3641860,
3642205,
3642261,
3642277,
3642353,
3642394,
3642525,
3801109,
3808989,
3809301,
3810557,
3810613,
3812518,
3812581,
3812693,
3812774,
3812986,
3813221,
3813493,
3813541,
3813781,
3814725,
3814869,
3816765,
3817493,
3819589,
3819701,
3819741,
3824650,
3825309,
3825685,
3828477,
3828746,
3829565,
3833856,
3834689,
3835520,
3836353,
3836605,
3836609,
3837184,
3838017,
3838848,
3838909,
3838912,
3839005,
3839040,
3839101,
3839136,
3839229,
3839264,
3839421,
3839424,
3839681,
3839837,
3839841,
3839901,
3839905,
3840157,
3840161,
3840512,
3841345,
3842176,
3842269,
3842272,
3842429,
3842464,
3842749,
3842752,
3843005,
3843009,
3843840,
3843933,
3843936,
3844093,
3844096,
3844285,
3844288,
3844349,
3844416,
3844669,
3844673,
3845504,
3846337,
3847168,
3848001,
3848832,
3849665,
3850496,
3851329,
3852160,
3852993,
3853824,
3854657,
3855581,
3855616,
3856434,
3856449,
3857266,
3857281,
3857472,
3858290,
3858305,
3859122,
3859137,
3859328,
3860146,
3860161,
3860978,
3860993,
3861184,
3862002,
3862017,
3862834,
3862849,
3863040,
3863858,
3863873,
3864690,
3864705,
3864896,
3864929,
3864989,
3865032,
3866645,
3883013,
3884789,
3884901,
3886517,
3886757,
3886805,
3887237,
3887285,
3887345,
3887517,
3887973,
3888157,
3888165,
3888669,
3932165,
3932413,
3932421,
3932989,
3933029,
3933277,
3933285,
3933373,
3933381,
3933565,
3940356,
3941821,
3941893,
3942115,
3942365,
3942408,
3942749,
3942852,
3942901,
3942941,
3954692,
3956101,
3956232,
3956573,
3956723,
3956765,
3997700,
4004029,
4004074,
4004357,
4004605,
4005888,
4006977,
4008069,
4008291,
4008349,
4008456,
4008797,
4008913,
4008989,
4034090,
4035989,
4036010,
4036115,
4036138,
4036285,
4038698,
4040149,
4040170,
4040669,
4046852,
4047005,
4047012,
4047901,
4047908,
4047997,
4048004,
4048061,
4048100,
4048157,
4048164,
4048509,
4048516,
4048669,
4048676,
4048733,
4048740,
4048797,
4048964,
4049021,
4049124,
4049181,
4049188,
4049245,
4049252,
4049309,
4049316,
4049437,
4049444,
4049533,
4049540,
4049597,
4049636,
4049693,
4049700,
4049757,
4049764,
4049821,
4049828,
4049885,
4049892,
4049949,
4049956,
4050045,
4050052,
4050109,
4050148,
4050301,
4050308,
4050557,
4050564,
4050717,
4050724,
4050877,
4050884,
4050941,
4050948,
4051293,
4051300,
4051869,
4052004,
4052125,
4052132,
4052317,
4052324,
4052893,
4054546,
4054621,
4063253,
4064669,
4064789,
4067997,
4068373,
4068861,
4068917,
4069405,
4069429,
4069917,
4069941,
4071133,
4071434,
4071861,
4077021,
4078805,
4079741,
4080149,
4081565,
4081685,
4081981,
4082197,
4082269,
4082709,
4082909,
4087829,
4095860,
4096021,
4119325,
4119573,
4119997,
4120085,
4120509,
4120597,
4124317,
4124693,
4127549,
4127765,
4128157,
4128789,
4129181,
4129301,
4131101,
4131349,
4131677,
4131861,
4133149,
4133397,
4134365,
4134421,
4134493,
4136981,
4140861,
4140885,
4143517,
4143541,
4147869,
4148245,
4148701,
4148757,
4148925,
4149013,
4149117,
4149269,
4149501,
4149781,
4150589,
4150805,
4151037,
4151317,
4151421,
4151829,
4152061,
4153365,
4158077,
4158101,
4159869,
4161032,
4161373,
4194308,
5561309,
5562372,
5695165,
5695492,
5702621,
5702660,
5887069,
5887492,
6126653,
6225924,
6243293,
6291460,
6449533,
29360186,
29360221,
29361178,
29364253,
29368325,
29376029,
31457308,
33554397,
33554460,
35651549,
35651613,
};
#else
const unsigned char catTable1[] = {
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38,
40, 42, 44, 46, 48, 50, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 54, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 56,
58, 52, 60, 62, 64, 66, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 68, 70, 70, 70, 70, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104,
106, 108, 110, 112, 52, 114, 116, 118, 118, 118, 118, 118, 52, 52, 120, 118, 118, 118, 118, 118,
118, 118, 52, 122, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
52, 124, 118, 126, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 128, 52, 52, 130, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 132, 134, 118, 118,
118, 118, 136, 118, 118, 118, 118, 118, 118, 118, 118, 118, 138, 140, 142, 144, 146, 148, 118, 118,
150, 152, 118, 118, 154, 118, 156, 158, 160, 162, 146, 164, 166, 168, 118, 118, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 170,
52, 52, 52, 52, 52, 52, 52, 172, 174, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 176,
52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 178, 118, 118, 118, 118, 118, 118,
52, 180, 118, 118, 52, 52, 52, 52, 52, 52, 52, 52, 52, 182, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 184, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 186, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, 186,
};
const unsigned short catTable2[] = {
0, 0, 16, 32, 48, 64, 80, 96, 0, 0, 112, 128, 144, 160, 176, 192, 208, 208, 208, 224,
240, 208, 208, 256, 272, 288, 304, 320, 336, 352, 208, 368, 208, 208, 208, 384, 400, 176, 176, 176,
176, 416, 176, 432, 448, 464, 480, 496, 512, 512, 512, 512, 512, 512, 512, 528, 544, 560, 576, 176,
592, 608, 208, 624, 144, 144, 144, 176, 176, 176, 208, 208, 640, 208, 208, 208, 656, 208, 208, 208,
208, 208, 208, 672, 144, 688, 176, 176, 704, 720, 512, 736, 752, 768, 784, 800, 816, 832, 768, 768,
848, 512, 864, 880, 768, 768, 768, 768, 768, 896, 912, 928, 944, 960, 768, 512, 976, 768, 768, 768,
768, 768, 992, 1008, 1024, 768, 1040, 1056, 768, 1072, 1088, 1104, 768, 1120, 1136, 1152, 1152, 1152, 768, 1168,
1184, 1200, 1216, 512, 1232, 768, 768, 1248, 1264, 1280, 1296, 1312, 1328, 1344, 1360, 1376, 1392, 1408, 1424, 1440,
1456, 1344, 1360, 1472, 1488, 1504, 1520, 1536, 1552, 1568, 1360, 1584, 1600, 1616, 1424, 1632, 1648, 1344, 1360, 1664,
1680, 1696, 1424, 1712, 1728, 1744, 1760, 1776, 1792, 1808, 1520, 1824, 1840, 1856, 1360, 1872, 1888, 1904, 1424, 1920,
1936, 1856, 1360, 1952, 1968, 1984, 1424, 2000, 2016, 1856, 768, 2032, 2048, 2064, 1424, 2080, 2096, 2112, 768, 2128,
2144, 2160, 1520, 2176, 2192, 768, 768, 2208, 2224, 2240, 1152, 1152, 2256, 768, 2272, 2288, 2304, 2320, 1152, 1152,
2336, 2352, 2368, 2384, 2400, 768, 2416, 2432, 2448, 2464, 512, 2480, 2496, 2512, 1152, 1152, 768, 768, 2528, 2544,
2560, 2576, 2592, 2608, 2624, 2640, 144, 144, 2656, 176, 176, 2672, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 2688, 2704, 768, 768, 2688, 768, 768, 2720,
2736, 2752, 768, 768, 768, 2736, 768, 768, 768, 2768, 2784, 2800, 768, 2816, 144, 144, 144, 144, 144, 2832,
2848, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 2864, 768,
2880, 2896, 768, 768, 768, 768, 2912, 2928, 2944, 2960, 768, 2976, 768, 2992, 2944, 3008, 768, 768, 768, 3024,
3040, 3056, 3072, 3088, 3104, 3072, 768, 768, 3120, 768, 768, 3136, 3152, 768, 3168, 768, 768, 768, 768, 3184,
768, 3200, 3216, 3232, 3248, 768, 3264, 3280, 768, 768, 3296, 768, 3312, 3328, 3344, 3344, 768, 3360, 768, 768,
768, 3376, 3392, 3408, 3072, 3072, 3424, 3440, 3456, 1152, 1152, 1152, 3472, 768, 768, 3488, 3504, 2560, 3520, 3536,
3552, 768, 3568, 1024, 768, 768, 3584, 3600, 768, 768, 3616, 3632, 3648, 1024, 768, 3664, 3680, 144, 144, 3696,
3712, 3728, 3744, 3760, 176, 176, 3776, 432, 432, 432, 3792, 3808, 176, 3824, 432, 432, 512, 512, 512, 3840,
208, 208, 208, 208, 208, 208, 208, 208, 208, 3856, 208, 208, 208, 208, 208, 208, 3872, 3888, 3872, 3872,
3888, 3904, 3872, 3920, 3936, 3936, 3936, 3952, 3968, 3984, 4000, 4016, 4032, 4048, 4064, 4080, 4096, 4112, 4128, 4144,
4160, 4176, 4192, 4192, 1152, 4208, 4224, 3456, 4240, 4256, 4272, 4288, 4304, 4320, 4336, 4336, 4352, 4368, 4384, 3344,
4400, 4416, 3344, 4432, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448,
4464, 3344, 4480, 3344, 3344, 3344, 3344, 4496, 3344, 4512, 4448, 4528, 3344, 4544, 4560, 3344, 3344, 3344, 4576, 1152,
4592, 1152, 4320, 4320, 4320, 4608, 3344, 3344, 3344, 3344, 4624, 4320, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 4640, 4656, 3344, 3344, 4672, 3344, 3344, 3344, 3344, 3344, 3344, 4688, 3344, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 4704, 4720, 4320, 4736, 3344, 3344, 4752, 4448, 4768, 4448,
3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 4448, 4448, 4448, 4448,
4448, 4448, 4448, 4448, 4784, 4800, 4448, 4448, 4448, 4816, 4448, 4832, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448,
4448, 4448, 4448, 4448, 4448, 4448, 4448, 4448, 3344, 3344, 3344, 4448, 4848, 3344, 3344, 4864, 3344, 4880, 3344, 3344,
3344, 3344, 3344, 3344, 144, 144, 4896, 176, 176, 4912, 4928, 4944, 208, 208, 208, 208, 208, 208, 4960, 4976,
176, 176, 4992, 768, 768, 768, 5008, 5024, 768, 5040, 5056, 5056, 5056, 5056, 512, 512, 5072, 5088, 5104, 5120,
5136, 5152, 1152, 1152, 3344, 5168, 3344, 3344, 3344, 3344, 3344, 5184, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 3344, 3344, 5200, 1152, 5216, 5232, 5248, 5264, 5280, 2192, 768, 768, 768, 768, 5296, 2848, 768,
768, 768, 768, 5312, 5328, 768, 768, 2192, 768, 768, 768, 768, 3200, 5344, 768, 768, 3344, 3344, 5184, 768,
3344, 5360, 5376, 3344, 5392, 5408, 3344, 3344, 5376, 3344, 3344, 5408, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 3344, 3344, 3344, 3344, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 2416, 768, 5424, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 2416, 3344, 3344, 3344, 4576, 768, 768, 3664, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 5440, 768, 5456, 1152, 208, 208, 5472, 5488,
208, 5504, 768, 768, 768, 768, 5520, 5536, 496, 5552, 5568, 5584, 208, 208, 208, 5600, 5616, 5632, 5648, 5664,
5680, 1152, 1152, 5696, 5712, 768, 5728, 5744, 768, 768, 768, 5760, 5776, 768, 768, 5792, 5808, 3072, 512, 5824,
1024, 768, 5840, 768, 5856, 5872, 768, 2416, 1232, 768, 768, 5888, 5904, 5920, 5936, 5952, 768, 768, 5968, 5984,
6000, 6016, 768, 6032, 768, 768, 768, 6048, 6064, 6080, 6096, 6112, 6128, 6144, 5056, 176, 176, 6160, 6176, 176,
176, 176, 176, 176, 768, 768, 6192, 3072, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 6208, 768, 6224, 768, 768, 3296,
6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240,
6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6240, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256,
6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256,
6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 3264, 768, 768, 768, 768, 768, 768, 3312, 1152, 1152, 6272, 6288, 6304, 6320, 6336, 768, 768, 768,
768, 768, 768, 6352, 6368, 6384, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 6400, 1152, 768, 768, 768, 768, 6416, 768, 768, 1184, 1152, 1152, 6432,
512, 6448, 512, 6464, 6480, 6496, 6512, 1168, 768, 768, 768, 768, 768, 768, 768, 6528, 6544, 32, 48, 64,
80, 6560, 6576, 6592, 768, 6608, 768, 3200, 6624, 6640, 6656, 6672, 6688, 768, 2752, 6704, 3264, 3264, 1152, 1152,
768, 768, 768, 768, 768, 768, 768, 1136, 6720, 4320, 4320, 6736, 4336, 4336, 4336, 6752, 6768, 6784, 6800, 1152,
1152, 3344, 3344, 6816, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 2416, 768, 768, 768, 1616, 6832, 6848,
768, 768, 6864, 768, 6880, 768, 768, 6896, 768, 6912, 768, 768, 6928, 6944, 1152, 1152, 144, 144, 6960, 176,
176, 768, 768, 768, 768, 3264, 3072, 144, 144, 6976, 176, 6992, 768, 768, 1184, 768, 768, 768, 7008, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 5040, 768, 3184, 1184, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
7024, 768, 768, 7040, 768, 7056, 768, 7072, 768, 3200, 7088, 1152, 1152, 1152, 768, 7104, 768, 7120, 768, 7136,
1152, 1152, 1152, 1152, 768, 768, 768, 7152, 4320, 7168, 4320, 4320, 7184, 7200, 768, 7216, 7232, 7248, 768, 7264,
768, 7280, 1152, 1152, 7296, 768, 7312, 7328, 768, 768, 768, 7344, 768, 7360, 768, 7376, 768, 7392, 7408, 1152,
1152, 1152, 1152, 1152, 768, 768, 768, 768, 3136, 1152, 1152, 1152, 144, 144, 144, 7424, 176, 176, 176, 7440,
768, 768, 7456, 3072, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 4320, 7472, 768, 768, 7488, 7504, 1152, 1152, 1152, 1152, 768, 7280, 7520, 768, 992, 7536, 1152, 1152,
1152, 1152, 1152, 768, 7552, 1152, 768, 5040, 7568, 768, 768, 7584, 7600, 7168, 7616, 7632, 3552, 768, 768, 7648,
7664, 768, 3136, 3072, 7680, 768, 7696, 7712, 7728, 768, 768, 7744, 3552, 768, 768, 7760, 7776, 7792, 7808, 7824,
768, 1568, 7840, 7856, 1152, 1152, 1152, 1152, 7872, 7888, 7904, 768, 768, 7920, 7936, 3072, 7952, 1344, 1360, 7968,
7984, 8000, 8016, 8032, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 768, 8048, 8064, 8080, 7504, 1152,
768, 768, 768, 8096, 8112, 3072, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 8128, 8144,
8160, 8176, 1152, 1152, 768, 768, 768, 8192, 8208, 3072, 8224, 1152, 768, 768, 8240, 8256, 3072, 1152, 1152, 1152,
768, 2768, 8272, 8288, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 7840, 8304,
1152, 1152, 1152, 1152, 1152, 1152, 144, 144, 176, 176, 2368, 8320, 8336, 8352, 768, 8368, 8384, 3072, 1152, 1152,
1152, 1152, 8400, 768, 768, 8416, 8432, 1152, 8448, 768, 768, 8464, 8480, 8496, 768, 768, 8512, 8528, 8544, 1152,
768, 768, 768, 3136, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1360, 768, 8128, 8560, 8576, 2368, 2800, 8592, 768, 8608, 8624, 8640, 1152, 1152, 1152, 1152, 8656, 768, 768, 8672,
8688, 3072, 8704, 768, 8720, 8736, 3072, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 768, 8752, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1616,
4320, 8768, 8784, 8800, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 3312, 1152, 1152, 1152, 1152, 1152, 1152, 4336, 4336, 4336, 4336,
4336, 4336, 8816, 8832, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 6208, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
768, 768, 3200, 8848, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 768, 768, 5040, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 768, 768, 768, 3136, 768, 3200, 5920, 1152, 1152, 1152, 1152, 1152, 1152, 768, 3264, 8864,
768, 768, 768, 8880, 8896, 8912, 8928, 8944, 768, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
144, 144, 176, 176, 4320, 8960, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 768, 768, 8976, 8992, 9008, 9008,
9024, 9040, 1152, 1152, 1152, 1152, 9056, 9072, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 1184,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 3184, 1152, 1152, 3136, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 3200, 1152, 1152, 1152, 9088, 9104, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 3296,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 768, 768,
768, 768, 1136, 2416, 3136, 9120, 9136, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 5200, 3344, 3344, 9152, 3344, 3344, 3344, 9168, 9184, 9200, 3344, 9216, 3344, 3344, 3344, 9232, 1152,
3344, 3344, 3344, 3344, 9248, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 4320, 9264, 3344, 3344, 3344, 3344,
3344, 4576, 4320, 7232, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 144, 9280, 176, 9296, 9312, 9328, 3872, 144,
9344, 9360, 9376, 9392, 9408, 144, 9280, 176, 9424, 9440, 176, 9456, 9472, 9488, 9504, 144, 9520, 176, 144, 9280,
176, 9296, 9312, 176, 3872, 144, 9344, 9504, 144, 9520, 176, 144, 9280, 176, 9536, 144, 9552, 9568, 9584, 9600,
176, 9616, 144, 9632, 9648, 9664, 9680, 176, 9696, 144, 9712, 176, 9728, 9744, 9744, 9744, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 512, 512, 512, 9760, 512, 512, 9776, 9792, 9808, 9824, 720, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
9840, 9856, 9872, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 2416, 9888,
9904, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 768, 768, 9920, 9936, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 9952, 9968, 1152, 1152,
144, 144, 9344, 176, 9984, 5920, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 7808, 4320, 4320, 10000, 10016, 1152, 1152, 1152, 1152, 7808, 4320, 10032, 10048, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 10064, 768, 10080, 10096, 10112, 10128, 10144, 10160, 10176, 3296, 10192, 3296,
1152, 1152, 1152, 10208, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
3344, 3344, 5216, 3344, 3344, 3344, 3344, 3344, 3344, 5184, 5360, 10224, 10224, 10224, 3344, 5200, 10240, 3344, 3344, 3344,
3344, 3344, 3344, 3344, 3344, 3344, 10256, 1152, 1152, 1152, 10272, 3344, 10288, 3344, 3344, 5216, 9232, 10304, 5200, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344,
3344, 3344, 3344, 10320, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 10336, 6784, 6784,
3344, 3344, 3344, 3344, 3344, 3344, 3344, 5184, 3344, 3344, 3344, 3344, 3344, 9232, 5216, 1152, 5216, 3344, 3344, 3344,
10336, 2816, 3344, 3344, 10336, 3344, 10256, 10304, 1152, 1152, 1152, 1152, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 10352,
3344, 3344, 3344, 3344, 10368, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 5184, 10256, 10384, 4576, 3344, 9232, 4576,
10288, 4576, 1152, 1152, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 3344, 10400, 3344, 3344, 4592, 1152, 1152, 3072,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 3264, 1152, 1152, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 3280, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 3264, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 7504, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 1616, 1152,
768, 3264, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 768, 768, 768, 768, 768, 768, 768, 768,
768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 768, 1136, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
1152, 1152, 1152, 1152, 10416, 1152, 10432, 10432, 10432, 10432, 10432, 10432, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 1152, 6256, 6256, 6256, 6256,
6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256, 6256,
6256, 6256, 6256, 6256, 6256, 6256, 6256, 10448,
};
const unsigned char catTable[] = {
25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 22, 17, 17, 17,
19, 17, 17, 17, 13, 14, 17, 18, 17, 12, 17, 17, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 17, 17, 18, 18, 18, 17, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 17, 14, 20, 11,
20, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 13, 18, 14, 18, 25, 22, 17, 19, 19, 19, 19, 21, 17,
20, 21, 4, 15, 18, 26, 21, 20, 21, 18, 10, 10, 20, 1, 17, 17, 20, 10, 4, 16,
10, 10, 10, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 18,
1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0,
1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1,
0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0,
1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 4, 0, 1, 1, 1, 4, 4, 4, 4,
0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 2, 1, 0, 1, 0, 0, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1,
1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1,
4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 20, 20, 20, 20, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
3, 3, 3, 3, 3, 20, 20, 20, 20, 20, 20, 20, 3, 20, 3, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 0, 1, 0, 1, 3, 20, 0, 1, 29, 29, 3, 1,
1, 1, 17, 0, 29, 29, 29, 29, 20, 20, 0, 17, 0, 0, 0, 29, 0, 29, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1,
0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 18, 0, 1, 0, 0, 1, 1, 0, 0, 0,
0, 1, 21, 5, 5, 5, 5, 5, 7, 7, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 29, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 29, 3, 17, 17,
17, 17, 17, 17, 1, 1, 1, 1, 1, 1, 1, 1, 1, 17, 12, 29, 29, 21, 21, 19,
29, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 12, 5, 17, 5, 5, 17, 5, 5, 17, 5,
29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 4,
4, 4, 4, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 26, 26, 26, 26,
26, 26, 18, 18, 18, 17, 17, 19, 17, 17, 21, 21, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 17, 26, 29, 17, 17, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
5, 5, 5, 5, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 17, 17, 17, 17, 4, 4,
5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
17, 4, 5, 5, 5, 5, 5, 5, 5, 26, 21, 5, 5, 5, 5, 5, 5, 3, 3, 5,
5, 21, 5, 5, 5, 5, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4,
4, 21, 21, 4, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 29, 26,
4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5,
3, 3, 21, 17, 17, 17, 3, 29, 29, 5, 19, 19, 4, 4, 4, 4, 4, 4, 5, 5,
5, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 3, 5, 5, 5,
5, 5, 29, 29, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 29,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 29, 29, 17, 29, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 26, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6,
5, 4, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 5, 6, 6,
4, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5,
17, 17, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 17, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 6, 29, 4, 4, 4, 4, 4, 4, 4,
4, 29, 29, 4, 4, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 29, 4, 29,
29, 29, 4, 4, 4, 4, 29, 29, 5, 4, 6, 6, 6, 5, 5, 5, 5, 29, 29, 6,
6, 29, 29, 6, 6, 5, 4, 29, 29, 29, 29, 29, 29, 29, 29, 6, 29, 29, 29, 29,
4, 4, 29, 4, 4, 4, 5, 5, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
4, 4, 19, 19, 10, 10, 10, 10, 10, 10, 21, 19, 4, 17, 5, 29, 29, 5, 5, 6,
29, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 4, 4, 29, 4, 4, 29, 4, 4, 29,
4, 4, 29, 29, 5, 29, 6, 6, 6, 5, 5, 29, 29, 29, 29, 5, 5, 29, 29, 5,
5, 5, 29, 29, 29, 5, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 29, 4, 29,
29, 29, 29, 29, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 5, 5, 4, 4,
4, 5, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 5, 5, 6, 29, 4, 4, 4,
4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 29, 4, 4, 29, 4, 4, 4, 4, 4, 29, 29, 5, 4, 6, 6,
6, 5, 5, 5, 5, 5, 29, 5, 5, 6, 29, 6, 6, 5, 29, 29, 4, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 17, 19, 29, 29, 29, 29, 29, 29,
29, 4, 5, 5, 5, 5, 5, 5, 29, 5, 6, 6, 29, 4, 4, 4, 4, 4, 4, 4,
4, 29, 29, 4, 4, 29, 4, 4, 29, 4, 4, 4, 4, 4, 29, 29, 5, 4, 6, 5,
6, 5, 5, 5, 5, 29, 29, 6, 6, 29, 29, 6, 6, 5, 29, 29, 29, 29, 29, 29,
29, 5, 5, 6, 29, 29, 29, 29, 4, 4, 29, 4, 21, 4, 10, 10, 10, 10, 10, 10,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 5, 4, 29, 4, 4, 4, 4, 4, 4, 29,
29, 29, 4, 4, 4, 29, 4, 4, 4, 4, 29, 29, 29, 4, 4, 29, 4, 29, 4, 4,
29, 29, 29, 4, 4, 29, 29, 29, 4, 4, 4, 29, 29, 29, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 6, 6, 5, 6, 6, 29, 29, 29, 6, 6,
6, 29, 6, 6, 6, 5, 29, 29, 4, 29, 29, 29, 29, 29, 29, 6, 29, 29, 29, 29,
29, 29, 29, 29, 10, 10, 10, 21, 21, 21, 21, 21, 21, 19, 21, 29, 29, 29, 29, 29,
5, 6, 6, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 29, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 29, 29, 29, 4, 5, 5, 5, 6, 6, 6, 6, 29, 5, 5, 5, 29, 5, 5,
5, 5, 29, 29, 29, 29, 29, 29, 29, 5, 5, 29, 4, 4, 4, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 17, 10, 10, 10, 10, 10, 10, 10, 21, 4, 5, 6, 6,
17, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4,
4, 4, 29, 29, 5, 4, 6, 5, 6, 6, 6, 6, 6, 29, 5, 6, 6, 29, 6, 6,
5, 5, 29, 29, 29, 29, 29, 29, 29, 6, 6, 29, 29, 29, 29, 29, 29, 29, 4, 29,
29, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 5, 5, 6, 6,
4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 5, 5, 4, 6, 6, 6, 5, 5, 5, 5, 29, 6, 6, 6, 29, 6, 6,
6, 5, 4, 21, 29, 29, 29, 29, 4, 4, 4, 6, 10, 10, 10, 10, 10, 10, 10, 4,
10, 10, 10, 10, 10, 10, 10, 10, 10, 21, 4, 4, 4, 4, 4, 4, 29, 5, 6, 6,
29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29,
29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4,
29, 4, 29, 29, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 5, 29, 29, 29, 29, 6,
6, 6, 5, 5, 5, 29, 5, 29, 6, 6, 6, 6, 6, 6, 6, 6, 29, 29, 6, 6,
17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 5, 5, 5, 5, 5, 5, 29,
29, 29, 29, 19, 4, 4, 4, 4, 4, 4, 3, 5, 5, 5, 5, 5, 5, 5, 5, 17,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 17, 17, 29, 29, 29, 29, 29, 4, 4, 29,
4, 29, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 29, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
5, 4, 29, 29, 4, 4, 4, 4, 4, 29, 3, 29, 5, 5, 5, 5, 5, 5, 29, 29,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 29, 29, 4, 4, 4, 4, 4, 21, 21, 21,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 21, 17, 21, 21, 21,
5, 5, 21, 21, 21, 21, 21, 21, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 21, 5, 21, 5, 21, 5, 13, 14, 13, 14, 6, 6,
4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 17, 5, 5, 4, 4, 4, 4,
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 29, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 29, 21, 21, 21, 21, 21, 21,
21, 21, 5, 21, 21, 21, 21, 21, 21, 29, 21, 21, 17, 17, 17, 17, 17, 21, 21, 21,
21, 17, 17, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6,
6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 6, 5, 5, 6, 6, 5, 5, 4,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 17, 17, 17, 17, 17, 17, 4, 4, 4, 4,
4, 4, 6, 6, 5, 5, 4, 4, 4, 4, 5, 5, 5, 4, 6, 6, 6, 4, 4, 6,
6, 6, 6, 6, 6, 6, 4, 4, 4, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 5, 6, 6, 5, 5, 6, 6, 6, 6, 6, 6, 5, 4, 6,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 5, 21, 21, 0, 0, 0, 0,
0, 0, 29, 0, 29, 29, 29, 29, 29, 0, 29, 29, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 17, 3, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4,
4, 4, 29, 29, 4, 4, 4, 4, 4, 4, 4, 29, 4, 29, 4, 4, 4, 4, 29, 29,
4, 29, 4, 4, 4, 4, 29, 29, 4, 4, 4, 4, 4, 4, 4, 29, 4, 29, 4, 4,
4, 4, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29,
29, 5, 5, 5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 29, 29, 29, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 29, 29, 29, 29, 29, 29, 0, 0, 0, 0, 0, 0, 29, 29,
1, 1, 1, 1, 1, 1, 29, 29, 12, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 21, 17, 4,
22, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 13, 14, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 17, 17, 17, 9, 9, 9, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29,
29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4,
4, 4, 5, 5, 5, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 5, 5,
5, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 5, 5, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 4, 29, 5, 5, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 4, 4, 4, 4, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6,
6, 6, 6, 6, 6, 6, 5, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
17, 17, 17, 3, 17, 17, 17, 19, 4, 5, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 29, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 29, 29,
29, 29, 29, 29, 17, 17, 17, 17, 17, 17, 12, 17, 17, 17, 17, 5, 5, 5, 26, 29,
4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 5, 5, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 4, 29,
29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 5, 5, 5, 6,
6, 6, 6, 5, 5, 6, 6, 6, 29, 29, 29, 29, 6, 6, 5, 6, 6, 6, 6, 6,
6, 5, 5, 5, 29, 29, 29, 29, 21, 29, 29, 29, 17, 17, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29,
4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 29, 29, 29, 29, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 29,
29, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
4, 4, 4, 4, 4, 4, 4, 5, 5, 6, 6, 5, 29, 29, 17, 17, 4, 4, 4, 4,
4, 6, 5, 6, 5, 5, 5, 5, 5, 5, 5, 29, 5, 6, 5, 6, 6, 5, 5, 5,
5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 29, 29, 5, 17, 17, 17, 17, 17, 17, 17, 3, 17, 17, 17, 17, 17, 17, 29, 29,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 5, 5, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 5, 5, 5, 5, 6, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 5, 5, 5, 5, 5, 6,
5, 6, 6, 6, 6, 6, 5, 6, 6, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29,
17, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 5, 5, 5, 5, 5, 5, 5, 5, 5,
21, 21, 21, 21, 21, 21, 21, 21, 21, 29, 29, 29, 5, 5, 6, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 5, 5, 5, 5, 6, 6, 5, 5, 6, 5,
5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 5, 5, 6, 6, 6, 5, 6, 5,
5, 5, 6, 6, 29, 29, 29, 29, 29, 29, 29, 29, 17, 17, 17, 17, 4, 4, 4, 4,
6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 5,
29, 29, 29, 17, 17, 17, 17, 17, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 29, 29,
29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 17, 17,
1, 1, 1, 1, 1, 1, 1, 1, 1, 29, 29, 29, 29, 29, 29, 29, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 29, 29, 0, 0, 0, 17, 17, 17, 17, 17, 17, 17, 17,
29, 29, 29, 29, 29, 29, 29, 29, 5, 5, 5, 17, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 5, 4, 4,
4, 4, 4, 4, 5, 4, 4, 6, 5, 5, 4, 29, 29, 29, 29, 29, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 29, 5, 5, 5, 5, 5, 0, 1, 0, 1,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 29, 29, 0, 0, 0, 0,
0, 0, 29, 29, 1, 1, 1, 1, 1, 1, 1, 1, 29, 0, 29, 0, 29, 0, 29, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 29, 29, 1, 1, 1, 1,
1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 29, 1, 1,
0, 0, 0, 0, 2, 20, 1, 20, 20, 20, 1, 1, 1, 29, 1, 1, 0, 0, 0, 0,
2, 20, 20, 20, 1, 1, 1, 1, 29, 29, 1, 1, 0, 0, 0, 0, 29, 20, 20, 20,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 20, 20, 20, 29, 29, 1, 1,
1, 29, 1, 1, 0, 0, 0, 0, 2, 20, 20, 29, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 26, 26, 26, 26, 26, 12, 12, 12, 12, 12, 12, 17, 17, 15, 16, 13, 15,
15, 16, 13, 15, 17, 17, 17, 17, 17, 17, 17, 17, 23, 24, 26, 26, 26, 26, 26, 22,
17, 17, 17, 17, 17, 17, 17, 17, 17, 15, 16, 17, 17, 17, 17, 11, 11, 17, 17, 17,
18, 13, 14, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 17, 11, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 22, 26, 26, 26, 26, 26, 29, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 10, 3, 29, 29, 10, 10, 10, 10, 10, 10, 18, 18, 18, 13, 14, 3,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 18, 18, 18, 13, 14, 29, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 29, 29, 29, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 19, 19, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 7, 7, 7, 7, 5, 7, 7, 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
21, 21, 0, 21, 21, 21, 21, 0, 21, 21, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1,
21, 0, 21, 21, 18, 0, 0, 0, 0, 0, 21, 21, 21, 21, 21, 21, 0, 21, 0, 21,
0, 21, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 1, 4, 4, 4, 4, 1, 21, 21,
1, 1, 0, 0, 18, 18, 18, 18, 18, 0, 1, 1, 1, 1, 21, 18, 21, 21, 1, 21,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 1, 9, 9, 9,
9, 10, 21, 21, 29, 29, 29, 29, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 18, 18,
21, 21, 21, 21, 18, 21, 21, 18, 21, 21, 18, 21, 21, 21, 21, 21, 21, 21, 18, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 21, 21, 18, 21,
18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 13, 14, 13, 14, 21, 21, 21, 21,
18, 18, 21, 21, 21, 21, 21, 21, 21, 13, 14, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 18, 18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18,
18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 10, 10, 10, 10, 10, 10,
21, 21, 21, 21, 21, 21, 21, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
18, 18, 18, 18, 18, 18, 18, 18, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 18, 21, 21, 21, 21, 21, 21, 21, 21, 13, 14, 13, 14, 13, 14, 13, 14,
13, 14, 13, 14, 13, 14, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 18, 18, 18, 18, 18, 13, 14, 18,
18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 13, 14, 13, 14, 13, 14,
13, 14, 13, 14, 18, 18, 18, 13, 14, 13, 14, 13, 14, 13, 14, 13, 14, 13, 14, 13,
14, 13, 14, 13, 14, 13, 14, 13, 14, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 13, 14, 13, 14, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
18, 18, 18, 18, 13, 14, 18, 18, 18, 18, 18, 18, 18, 21, 21, 18, 18, 18, 18, 18,
18, 21, 21, 21, 21, 21, 21, 21, 29, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 29, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 29, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0,
1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 3, 3, 0, 0,
0, 1, 0, 1, 1, 21, 21, 21, 21, 21, 21, 0, 1, 0, 1, 5, 5, 5, 0, 1,
29, 29, 29, 29, 29, 17, 17, 17, 17, 10, 17, 17, 1, 1, 1, 1, 1, 1, 29, 1,
29, 29, 29, 29, 29, 1, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29,
29, 29, 29, 3, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 5,
4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4,
4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 29, 17, 17, 15, 16, 15, 16, 17, 17,
17, 15, 16, 17, 15, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 12, 17, 17, 12, 17,
15, 16, 17, 17, 15, 16, 13, 14, 13, 14, 13, 14, 13, 14, 17, 17, 17, 17, 17, 3,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 12, 12, 17, 17, 17, 17, 12, 17, 13, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 21, 21, 17, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 29, 21,
21, 21, 21, 21, 21, 21, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
21, 21, 21, 21, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 29, 29, 29, 29, 22, 17, 17, 17, 21, 3, 4, 9,
13, 14, 13, 14, 13, 14, 13, 14, 13, 14, 21, 21, 13, 14, 13, 14, 13, 14, 13, 14,
12, 13, 14, 14, 21, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 5, 5, 6, 6,
12, 3, 3, 3, 3, 3, 21, 21, 9, 9, 9, 3, 4, 17, 21, 21, 4, 4, 4, 4,
4, 4, 4, 29, 29, 5, 5, 20, 20, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 17, 3, 3, 3, 4, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 21, 21, 10, 10, 10, 10, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 29, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
10, 10, 10, 10, 10, 10, 10, 10, 21, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 17, 17, 17, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 4, 4, 29, 29, 29, 29, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 0, 1, 4, 5, 7, 7, 7, 17, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 17, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 3, 3, 5, 5,
4, 4, 4, 4, 4, 4, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 5, 5, 17, 17,
17, 17, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 20, 20, 20, 20, 20, 20, 20, 3,
3, 3, 3, 3, 3, 3, 3, 3, 20, 20, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1,
0, 1, 0, 1, 3, 20, 20, 0, 1, 0, 1, 4, 0, 1, 0, 1, 1, 1, 0, 1,
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
29, 29, 0, 1, 0, 0, 0, 0, 1, 0, 1, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 0, 1, 4, 3, 3, 1, 4, 4, 4, 4, 4, 4, 4, 5, 4, 4, 4, 5, 4,
4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 6, 6, 5, 5, 6, 21, 21, 21, 21,
5, 29, 29, 29, 10, 10, 10, 10, 10, 10, 21, 21, 19, 21, 29, 29, 29, 29, 29, 29,
4, 4, 4, 4, 17, 17, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 6, 6, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 29, 29, 29, 29, 29, 29,
29, 29, 17, 17, 5, 5, 4, 4, 4, 4, 4, 4, 17, 17, 17, 4, 17, 4, 4, 5,
4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 4, 4, 4, 4,
4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 17, 4, 4, 4, 5, 6, 6, 5, 5, 5, 5, 6, 6,
5, 5, 6, 6, 6, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 29, 3,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 29, 29, 29, 29, 17, 17, 4, 4, 4, 4,
4, 5, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5,
5, 5, 5, 6, 6, 5, 5, 6, 6, 5, 5, 29, 29, 29, 29, 29, 29, 29, 29, 29,
4, 4, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 29, 29, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 29, 29, 17, 17, 17, 17, 3, 4, 4, 4, 4, 4, 4, 21,
21, 21, 4, 6, 5, 6, 4, 4, 5, 4, 5, 5, 5, 4, 4, 5, 5, 4, 4, 4,
4, 4, 5, 5, 4, 5, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 3, 17, 17, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 6, 5, 5, 6, 6, 17, 17, 4, 3, 3, 6, 5, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 29, 29, 4, 4, 4,
4, 4, 4, 29, 29, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20, 3, 3, 3, 3, 1, 1, 1, 1,
1, 1, 1, 1, 1, 3, 20, 20, 29, 29, 29, 29, 4, 4, 4, 6, 6, 5, 6, 6,
5, 6, 6, 17, 6, 5, 29, 29, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 4, 4, 4, 4, 4,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 1, 1, 1, 1, 1, 1, 1, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 1, 1, 1, 1, 1, 29, 29, 29, 29,
29, 4, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 18, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 29, 4, 29, 4, 4, 29, 4,
4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 14, 13, 29, 29, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 19, 21, 29, 29, 17, 17, 17, 17, 17, 17, 17, 13, 14, 17, 29, 29,
29, 29, 29, 29, 17, 12, 12, 11, 11, 13, 14, 13, 14, 13, 14, 13, 14, 13, 14, 13,
14, 13, 14, 13, 14, 17, 17, 13, 14, 17, 17, 17, 17, 11, 11, 11, 17, 17, 17, 29,
17, 17, 17, 17, 12, 13, 14, 13, 14, 13, 14, 17, 17, 17, 18, 12, 18, 18, 18, 29,
17, 19, 17, 17, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 29, 29, 26, 29, 17, 17, 17, 19, 17, 17, 17, 13, 14, 17, 18, 17, 12, 17, 17,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 13, 18, 14, 18, 13, 14, 17, 13, 14,
17, 17, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 3, 3, 29, 29, 4, 4, 4, 4, 4, 4, 29, 29, 4, 4, 4, 4, 4, 4,
29, 29, 4, 4, 4, 4, 4, 4, 29, 29, 4, 4, 4, 29, 29, 29, 19, 19, 18, 20,
21, 19, 19, 29, 21, 18, 18, 18, 18, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 26, 26, 26, 21, 21, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 29, 4,
17, 17, 17, 29, 29, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
29, 29, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 9, 9, 9, 9, 9, 10, 10, 10,
10, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 10, 10,
21, 21, 21, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 29, 29, 29,
21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 5, 29, 29, 5, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
29, 29, 29, 29, 10, 10, 10, 10, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4,
4, 9, 4, 4, 4, 4, 4, 4, 4, 4, 9, 29, 29, 29, 29, 29, 4, 4, 4, 4,
4, 4, 5, 5, 5, 5, 5, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 29, 17, 4, 4, 4, 4, 29, 29, 29, 29, 4, 4, 4, 4,
4, 4, 4, 4, 17, 9, 9, 9, 9, 9, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
29, 29, 29, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 29, 29, 29, 29, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 17, 4, 4, 4, 4, 4, 4, 29, 29, 4, 29, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 29, 4, 4, 29, 29, 29, 4, 29, 29, 4, 4, 4, 4, 4,
4, 4, 29, 17, 10, 10, 10, 10, 10, 10, 10, 10, 4, 4, 4, 4, 4, 4, 4, 21,
21, 10, 10, 10, 10, 10, 10, 10, 29, 29, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10,
10, 10, 10, 10, 4, 4, 4, 29, 4, 4, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10,
4, 4, 4, 4, 4, 4, 10, 10, 10, 10, 10, 10, 29, 29, 29, 17, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 17, 4, 4, 4, 4, 4, 4, 4, 4,
29, 29, 29, 29, 10, 10, 4, 4, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 4, 5, 5, 5, 29, 5, 5, 29, 29, 29, 29, 29, 5, 5, 5, 5,
4, 4, 4, 4, 29, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 29, 29, 5, 5, 5, 29, 29, 29, 29, 5, 10, 10, 10, 10, 10, 10, 10, 10,
10, 29, 29, 29, 29, 29, 29, 29, 17, 17, 17, 17, 17, 17, 17, 17, 17, 29, 29, 29,
29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 10, 10, 17,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 10, 10, 10, 4, 4, 4, 4,
4, 4, 4, 4, 21, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 29,
29, 29, 29, 10, 10, 10, 10, 10, 17, 17, 17, 17, 17, 17, 17, 29, 29, 29, 29, 29,
29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 29, 29, 29, 17, 17, 17, 17, 17, 17, 17,
4, 4, 4, 4, 4, 4, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10, 4, 4, 4, 29,
29, 29, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10, 4, 4, 29, 29, 29, 29, 29, 29,
29, 17, 17, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 10, 10, 10,
10, 10, 10, 10, 0, 0, 0, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
1, 1, 1, 29, 29, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10, 10, 4, 4, 4, 4,
5, 5, 5, 5, 29, 29, 29, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 5,
5, 12, 29, 29, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
10, 10, 10, 10, 10, 10, 10, 4, 29, 29, 29, 29, 29, 29, 29, 29, 5, 10, 10, 10,
10, 17, 17, 17, 17, 17, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 10, 10, 10,
10, 10, 10, 10, 29, 29, 29, 29, 6, 5, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 17, 17, 17, 29, 29, 10, 10, 10, 10,
10, 10, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 5, 6, 6, 6, 5, 5, 5, 5, 6, 6, 5, 5, 17,
17, 26, 17, 17, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 26, 29, 29,
5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 29, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 17, 17, 17, 17, 4, 6, 6, 4, 29, 29, 29, 29,
29, 29, 29, 29, 4, 4, 4, 5, 17, 17, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29,
4, 4, 4, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 4, 4, 4,
4, 17, 17, 17, 17, 5, 5, 5, 5, 17, 6, 5, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 4, 17, 4, 17, 17, 17, 29, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 5, 5, 5, 6, 6,
5, 6, 5, 5, 17, 17, 17, 17, 17, 17, 5, 29, 4, 4, 4, 4, 4, 4, 4, 29,
4, 29, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 17, 29, 29, 29, 29, 29, 29,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 6, 6, 5,
5, 5, 5, 5, 5, 5, 5, 29, 29, 29, 29, 29, 5, 5, 6, 6, 29, 4, 4, 4,
4, 4, 4, 4, 4, 29, 29, 4, 4, 29, 4, 4, 29, 4, 4, 4, 4, 4, 29, 5,
5, 4, 6, 6, 5, 6, 6, 6, 6, 29, 29, 6, 6, 29, 29, 6, 6, 6, 29, 29,
4, 29, 29, 29, 29, 29, 29, 6, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 6, 6,
29, 29, 5, 5, 5, 5, 5, 5, 5, 29, 29, 29, 5, 5, 5, 5, 5, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 6, 6, 6, 5, 5, 5, 5,
5, 5, 5, 5, 6, 6, 5, 5, 5, 6, 5, 4, 4, 4, 4, 17, 17, 17, 17, 17,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 17, 17, 29, 17, 5, 4, 6, 6, 6, 5,
5, 5, 5, 5, 5, 6, 5, 6, 6, 6, 6, 5, 5, 6, 5, 5, 4, 4, 17, 4,
29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 6, 6, 6, 5, 5, 5, 5, 29, 29, 6, 6, 6, 6, 5, 5, 6, 5,
5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 4, 4, 4, 4, 5, 5, 29, 29, 6, 6, 6, 5, 5, 5, 5, 5,
5, 5, 5, 6, 6, 5, 6, 5, 5, 17, 17, 17, 4, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 29, 29, 29,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 5, 6, 6, 5, 5, 5, 5,
5, 5, 6, 5, 4, 29, 29, 29, 29, 29, 29, 29, 6, 6, 5, 5, 5, 5, 6, 5,
5, 5, 5, 5, 29, 29, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10,
17, 17, 17, 21, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 17, 29, 29, 29, 29,
10, 10, 10, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 4,
4, 4, 4, 29, 29, 4, 29, 29, 4, 4, 4, 4, 4, 4, 4, 4, 29, 4, 4, 29,
4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 29, 6, 6, 29, 29, 5,
5, 6, 5, 4, 6, 4, 6, 5, 17, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29,
4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6,
5, 5, 5, 5, 29, 29, 5, 5, 6, 6, 6, 6, 5, 4, 17, 4, 6, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4,
4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 4, 5, 5, 5, 5, 17,
17, 17, 17, 17, 17, 17, 17, 5, 29, 29, 29, 29, 29, 29, 29, 29, 4, 5, 5, 5,
5, 5, 5, 6, 6, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 17, 17,
17, 4, 17, 17, 17, 17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
5, 5, 5, 5, 5, 5, 5, 29, 5, 5, 5, 5, 5, 5, 6, 5, 4, 17, 17, 17,
17, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 17, 17, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 29, 6, 5, 5, 5, 5, 5, 5,
5, 6, 5, 5, 6, 5, 5, 29, 29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4,
4, 4, 4, 29, 4, 4, 29, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 29,
29, 29, 5, 29, 5, 5, 29, 5, 5, 5, 5, 5, 5, 5, 4, 5, 29, 29, 29, 29,
29, 29, 29, 29, 4, 4, 4, 4, 4, 4, 29, 4, 4, 29, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 29, 5, 5, 29, 6,
6, 5, 6, 5, 4, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 5, 5, 6, 6, 17,
17, 29, 29, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10, 21, 21, 21, 21, 21, 21, 21,
21, 19, 19, 19, 19, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 17, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 29, 17, 17, 17, 17, 17, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 26, 26, 26, 26, 26, 26, 26, 26, 26, 29, 29, 29,
29, 29, 29, 29, 5, 5, 5, 5, 5, 17, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 17, 21, 21, 21, 21, 3, 3, 3, 3,
17, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 29, 10, 10, 10, 10, 10, 10, 10, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 29, 4, 4, 4,
10, 10, 10, 10, 10, 10, 10, 17, 17, 17, 17, 29, 29, 29, 29, 29, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 29, 29, 29, 29, 5, 4, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 29, 29, 29, 29, 29, 29, 29, 5,
5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 17, 3,
5, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 6, 6, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 4, 4, 4, 4, 29, 29, 29, 29, 29, 29, 29, 29,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29, 29, 21, 5, 5, 17, 26, 26, 26, 26,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 21, 21, 21, 21, 21, 21, 21, 29,
29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 6, 6, 5, 5, 5, 21, 21,
21, 6, 6, 6, 6, 6, 6, 26, 26, 26, 26, 26, 26, 26, 26, 5, 5, 5, 5, 5,
5, 5, 5, 21, 21, 5, 5, 5, 5, 5, 5, 5, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 5, 5, 5, 5, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 29, 29, 29, 29, 29, 29, 29, 21, 21, 5, 5, 5, 21, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 10, 10, 10, 10, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 29, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 29, 0, 0, 29, 29, 0, 29,
29, 0, 0, 29, 29, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 29, 1, 29, 1, 1, 1, 1, 1, 1, 1, 29, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 29, 0, 0, 0, 0, 29, 29, 0, 0, 0,
0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 0, 29, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 0, 29, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 29, 0, 29,
29, 29, 0, 0, 0, 0, 0, 0, 0, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 29, 29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 18,
1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 1, 1, 1, 1, 1, 1, 1, 1,
1, 18, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 18, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 1, 1, 1, 1,
1, 1, 1, 1, 1, 18, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 18, 1, 1, 1, 1, 1, 1, 1, 1, 1, 18, 1, 1, 1, 1, 1, 1, 0, 1,
29, 29, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
5, 5, 5, 5, 5, 5, 5, 21, 21, 21, 21, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 21, 21, 21, 21, 21, 21, 21, 21, 5, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 5, 21, 21, 17, 17, 17, 17, 17,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 29, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 29, 29, 5, 5, 5, 5, 5, 5, 5, 29, 5, 5, 29, 5, 5,
5, 5, 5, 29, 29, 29, 29, 29, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3,
3, 3, 29, 29, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 29, 29, 29, 29, 4, 21,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 29, 29, 29, 29, 29, 19, 4, 4, 4, 4, 4, 29, 29, 10,
10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 29, 29, 29, 29, 29,
29, 29, 29, 29, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 3, 29, 29, 29, 29,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 21, 10, 10, 10, 19, 10, 10, 10,
10, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 21, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 29, 29, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
29, 4, 4, 29, 4, 29, 29, 4, 29, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 29,
4, 4, 4, 4, 29, 4, 29, 4, 29, 29, 29, 29, 29, 29, 4, 29, 29, 29, 29, 4,
29, 4, 29, 4, 29, 4, 4, 4, 29, 4, 4, 29, 4, 29, 29, 4, 29, 4, 29, 4,
29, 4, 29, 4, 29, 4, 4, 29, 4, 29, 29, 4, 4, 4, 4, 29, 4, 4, 4, 4,
4, 4, 4, 29, 4, 4, 4, 4, 29, 4, 4, 4, 4, 29, 4, 29, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 29, 4, 4, 4, 4, 4, 29, 4, 4, 4, 29, 4, 4, 4,
4, 4, 29, 4, 4, 4, 4, 4, 18, 18, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29,
29, 29, 29, 29, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 20, 20, 20, 20, 20, 21, 21, 21, 21,
21, 21, 21, 21, 29, 29, 29, 29, 29, 29, 29, 29, 21, 21, 21, 21, 21, 21, 21, 21,
21, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
29, 21, 21, 21, 21, 21, 21, 21, 21, 29, 29, 29, 21, 21, 21, 29, 29, 29, 29, 29,
21, 21, 21, 29, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 29, 26, 29, 29,
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 26, 26, 26, 26, 26, 26, 26, 26,
26, 26, 26, 26, 26, 26, 26, 26, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 29, 29,
};
constexpr int catTableShift11 = 9;
constexpr int catTableShift12 = 8;
constexpr int catTableMask1 = 511;
constexpr int catTableShift21 = 4;
constexpr int catTableShift22 = 0;
constexpr int catTableMask2 = 15;
const unsigned short CatTableRLE_BMP[] = {
1049, 54, 113, 51, 113, 45, 46, 49, 50, 49, 44, 81, 328, 81, 114, 81, 832, 45, 49, 46,
52, 43, 52, 833, 45, 50, 46, 50, 1081, 54, 49, 147, 53, 49, 52, 53, 36, 47, 50, 58,
53, 52, 53, 50, 74, 52, 33, 81, 52, 42, 36, 48, 106, 49, 736, 50, 224, 769, 50, 257,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 65, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 65, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 64, 33,
32, 33, 32, 97, 64, 33, 32, 33, 64, 33, 96, 65, 128, 33, 64, 33, 96, 97, 64, 33,
64, 33, 32, 33, 32, 33, 64, 33, 32, 65, 32, 33, 64, 33, 96, 33, 32, 33, 64, 65,
36, 32, 97, 132, 32, 34, 33, 32, 34, 33, 32, 34, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 65, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 65, 32, 34, 33, 32, 33, 96, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 225, 64, 33, 64, 65, 32, 33, 128, 33,
32, 33, 32, 33, 32, 33, 32, 2209, 36, 865, 579, 148, 387, 468, 163, 244, 35, 52, 35, 564,
3589, 32, 33, 32, 33, 35, 52, 32, 33, 93, 35, 97, 49, 32, 157, 84, 32, 49, 96, 61,
32, 61, 64, 33, 544, 61, 288, 1121, 32, 65, 96, 97, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 161, 32, 33, 50, 32,
33, 64, 65, 1632, 1537, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 53,
165, 71, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 64, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 65, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 61, 1216, 93, 35, 209, 1313, 49, 44, 93, 85, 51, 61, 1445, 44,
37, 49, 69, 49, 69, 49, 37, 285, 868, 157, 132, 81, 381, 218, 114, 81, 51, 81, 85, 357,
49, 58, 61, 81, 1028, 35, 324, 677, 328, 145, 68, 37, 3172, 49, 36, 229, 58, 53, 197, 67,
69, 53, 133, 68, 328, 100, 85, 36, 465, 61, 58, 36, 37, 964, 869, 93, 2852, 357, 36, 477,
328, 1060, 293, 67, 53, 113, 35, 93, 37, 83, 708, 133, 35, 293, 35, 101, 35, 165, 93, 497,
61, 804, 101, 93, 49, 61, 356, 1725, 676, 61, 580, 381, 485, 58, 1029, 38, 1732, 37, 38, 37,
36, 102, 261, 134, 37, 70, 36, 229, 324, 69, 81, 328, 49, 35, 484, 37, 70, 61, 260, 93,
68, 93, 708, 61, 228, 61, 36, 125, 132, 93, 37, 36, 102, 133, 93, 70, 93, 70, 37, 36,
285, 38, 157, 68, 61, 100, 69, 93, 328, 68, 83, 202, 53, 51, 36, 49, 37, 93, 69, 38,
61, 196, 157, 68, 93, 708, 61, 228, 61, 68, 61, 68, 61, 68, 93, 37, 61, 102, 69, 157,
69, 93, 101, 125, 37, 253, 132, 61, 36, 253, 328, 69, 100, 37, 49, 349, 69, 38, 61, 292,
61, 100, 61, 708, 61, 228, 61, 68, 61, 164, 93, 37, 36, 102, 165, 61, 69, 38, 61, 70,
37, 93, 36, 509, 68, 69, 93, 328, 49, 51, 253, 36, 197, 61, 37, 70, 61, 260, 93, 68,
93, 708, 61, 228, 61, 68, 61, 164, 93, 37, 36, 38, 37, 38, 133, 93, 70, 93, 70, 37,
253, 69, 38, 157, 68, 61, 100, 69, 93, 328, 53, 36, 202, 349, 37, 36, 61, 196, 125, 100,
61, 132, 125, 68, 61, 36, 61, 68, 125, 68, 125, 100, 125, 388, 157, 70, 37, 70, 125, 102,
61, 102, 37, 93, 36, 221, 38, 477, 328, 106, 213, 51, 53, 189, 37, 102, 37, 260, 61, 100,
61, 740, 61, 516, 125, 36, 101, 134, 61, 101, 61, 133, 253, 69, 61, 100, 189, 68, 69, 93,
328, 253, 49, 234, 53, 36, 37, 70, 49, 260, 61, 100, 61, 740, 61, 324, 61, 164, 93, 37,
36, 38, 37, 166, 61, 37, 70, 61, 70, 69, 253, 70, 253, 36, 61, 68, 69, 93, 328, 61,
68, 445, 69, 70, 292, 61, 100, 61, 1316, 69, 36, 102, 133, 61, 102, 61, 102, 37, 36, 53,
157, 100, 38, 234, 100, 69, 93, 328, 298, 53, 196, 61, 37, 70, 61, 580, 125, 772, 61, 292,
61, 36, 93, 228, 125, 37, 157, 102, 101, 61, 37, 61, 262, 221, 328, 93, 70, 49, 413, 1540,
37, 68, 229, 157, 51, 196, 35, 261, 49, 328, 81, 1213, 68, 61, 36, 61, 164, 61, 772, 61,
36, 61, 324, 37, 68, 293, 36, 93, 164, 61, 35, 61, 197, 93, 328, 93, 132, 1053, 36, 117,
497, 53, 49, 117, 69, 213, 328, 330, 53, 37, 53, 37, 53, 37, 45, 46, 45, 46, 70, 260,
61, 1156, 157, 453, 38, 165, 49, 69, 164, 357, 61, 1157, 61, 277, 37, 213, 61, 85, 177, 149,
81, 1213, 1380, 70, 133, 38, 197, 38, 69, 70, 69, 36, 328, 209, 196, 70, 69, 132, 101, 36,
102, 68, 230, 100, 133, 420, 37, 70, 69, 198, 37, 36, 38, 328, 102, 37, 85, 1216, 61, 32,
189, 32, 93, 1377, 49, 35, 97, 10532, 61, 132, 93, 228, 61, 36, 61, 132, 93, 1316, 61, 132,
93, 1060, 61, 132, 93, 228, 61, 36, 61, 132, 93, 484, 61, 1828, 61, 132, 93, 2148, 93, 101,
305, 650, 125, 516, 341, 221, 2752, 93, 193, 93, 44, 19844, 53, 49, 548, 54, 836, 45, 46, 125,
2404, 113, 105, 260, 253, 420, 61, 132, 101, 381, 580, 101, 81, 317, 580, 69, 413, 420, 61, 100,
61, 69, 413, 1668, 69, 38, 229, 262, 37, 70, 357, 113, 35, 113, 51, 36, 37, 93, 328, 221,
330, 221, 209, 44, 145, 101, 58, 61, 328, 221, 1124, 35, 1700, 253, 164, 69, 1092, 37, 36, 189,
2244, 349, 996, 61, 101, 134, 69, 102, 157, 70, 37, 198, 101, 157, 53, 125, 81, 328, 964, 93,
164, 381, 1412, 157, 836, 221, 328, 42, 125, 1109, 740, 69, 70, 37, 93, 81, 1700, 38, 37, 38,
229, 61, 37, 38, 37, 70, 261, 198, 325, 93, 37, 328, 221, 328, 221, 241, 35, 209, 93, 453,
39, 69, 2045, 133, 38, 1508, 37, 38, 165, 38, 37, 166, 37, 70, 228, 157, 328, 241, 341, 293,
309, 125, 69, 38, 964, 38, 133, 70, 69, 38, 101, 68, 328, 1412, 37, 38, 69, 102, 37, 38,
101, 70, 285, 145, 1156, 262, 261, 70, 69, 125, 177, 328, 125, 100, 328, 964, 195, 81, 289, 253,
1376, 93, 96, 273, 285, 101, 49, 421, 38, 229, 132, 37, 196, 37, 68, 38, 69, 36, 189, 1409,
2019, 417, 35, 1089, 1187, 1861, 61, 165, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 289, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 289, 256, 193, 93, 192,
93, 257, 256, 257, 256, 193, 93, 192, 93, 257, 61, 32, 61, 32, 61, 32, 61, 32, 257, 256,
449, 93, 257, 258, 257, 258, 257, 258, 161, 61, 65, 128, 34, 52, 33, 116, 97, 61, 65, 128,
34, 116, 129, 93, 65, 128, 61, 116, 257, 160, 116, 93, 97, 61, 65, 128, 34, 84, 61, 374,
186, 204, 81, 47, 48, 45, 79, 48, 45, 47, 273, 55, 56, 186, 54, 305, 47, 48, 145, 75,
113, 50, 45, 46, 369, 50, 49, 43, 337, 54, 186, 61, 346, 42, 35, 93, 202, 114, 45, 46,
35, 330, 114, 45, 46, 61, 419, 125, 1043, 541, 421, 135, 37, 103, 389, 509, 85, 32, 149, 32,
85, 33, 96, 65, 96, 33, 53, 32, 85, 50, 160, 213, 32, 53, 32, 53, 32, 53, 128, 53,
33, 128, 33, 132, 33, 85, 65, 64, 178, 32, 129, 53, 50, 85, 33, 53, 522, 1129, 32, 33,
137, 42, 85, 157, 178, 181, 82, 149, 50, 85, 50, 85, 50, 245, 50, 1013, 82, 85, 50, 53,
50, 1013, 8594, 277, 45, 46, 45, 46, 661, 82, 245, 45, 46, 2613, 50, 981, 818, 1301, 210, 2229,
829, 373, 701, 1930, 2517, 714, 5877, 50, 309, 50, 1749, 274, 3573, 50, 7957, 45, 46, 45, 46, 45,
46, 45, 46, 45, 46, 45, 46, 45, 46, 970, 1429, 178, 45, 46, 1010, 45, 46, 45, 46, 45,
46, 45, 46, 45, 46, 530, 8213, 4210, 45, 46, 45, 46, 45, 46, 45, 46, 45, 46, 45, 46,
45, 46, 45, 46, 45, 46, 45, 46, 45, 46, 2034, 45, 46, 45, 46, 1042, 45, 46, 8274, 1557,
690, 85, 210, 1269, 93, 1045, 61, 3381, 1504, 61, 1505, 61, 32, 33, 96, 65, 32, 33, 32, 33,
32, 33, 128, 33, 32, 65, 32, 193, 67, 96, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 65, 213, 32, 33, 32, 33, 101, 32, 33, 189, 145, 42,
81, 1217, 61, 33, 189, 33, 93, 1796, 253, 35, 49, 477, 37, 740, 317, 228, 61, 228, 61, 228,
61, 228, 61, 228, 61, 228, 61, 228, 61, 228, 61, 1029, 81, 47, 48, 47, 48, 113, 47, 48,
49, 47, 48, 305, 44, 81, 44, 49, 47, 48, 81, 47, 48, 45, 46, 45, 46, 45, 46, 45,
46, 177, 35, 337, 76, 145, 44, 49, 45, 433, 85, 49, 1469, 853, 61, 2869, 413, 6869, 861, 405,
157, 54, 113, 53, 35, 36, 41, 45, 46, 45, 46, 45, 46, 45, 46, 45, 46, 85, 45, 46,
45, 46, 45, 46, 45, 46, 44, 45, 78, 53, 297, 133, 70, 44, 163, 85, 105, 35, 36, 49,
85, 61, 2756, 93, 69, 84, 67, 36, 44, 2884, 49, 99, 36, 189, 1380, 61, 3012, 61, 85, 138,
341, 1028, 1173, 413, 516, 1013, 61, 330, 981, 266, 53, 490, 1045, 330, 1269, 490, 10261, 65508, 65508, 65508,
14436, 2069, 65508, 65508, 65508, 65508, 65508, 65508, 65508, 65508, 65508, 65508, 16612, 125, 676, 35, 36580, 125, 1781, 317,
1284, 195, 81, 8580, 35, 113, 516, 328, 68, 669, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 36, 37, 103, 49,
325, 49, 35, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 67, 69, 2244, 329, 69, 209, 285, 756, 291,
84, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 97, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32,
33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 35, 257, 32,
33, 32, 33, 64, 33, 32, 33, 32, 33, 32, 33, 32, 33, 35, 84, 32, 33, 32, 33, 36,
32, 33, 32, 97, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33,
32, 33, 32, 33, 160, 33, 160, 33, 32, 33, 32, 33, 32, 33, 32, 33, 32, 33, 93, 32,
33, 128, 33, 32, 33, 1373, 32, 33, 36, 67, 33, 228, 37, 100, 37, 132, 37, 740, 70, 69,
38, 149, 37, 125, 202, 85, 51, 53, 221, 1668, 145, 285, 70, 1604, 518, 69, 285, 81, 328, 221,
581, 196, 113, 36, 49, 68, 37, 328, 900, 261, 81, 740, 357, 70, 381, 49, 932, 125, 101, 38,
1508, 37, 70, 133, 70, 69, 102, 433, 61, 35, 328, 157, 81, 164, 37, 35, 292, 328, 164, 61,
1316, 197, 70, 69, 70, 69, 317, 100, 37, 260, 37, 38, 93, 328, 93, 145, 516, 35, 196, 117,
36, 38, 37, 38, 1604, 37, 36, 101, 68, 69, 164, 69, 36, 37, 36, 797, 68, 35, 81, 356,
38, 69, 70, 81, 36, 67, 38, 37, 349, 196, 93, 196, 93, 196, 317, 228, 61, 228, 61, 1377,
52, 131, 289, 35, 84, 157, 2561, 1124, 70, 37, 70, 37, 70, 49, 38, 37, 93, 328, 221, 65508,
65508, 65508, 65508, 65508, 29988, 413, 740, 157, 1572, 157, 65531, 59, 65532, 65532, 65532, 8316, 11716, 93, 3396, 1245,
225, 413, 161, 189, 36, 37, 324, 50, 420, 61, 164, 61, 36, 61, 68, 61, 68, 61, 3460, 532,
573, 11620, 46, 45, 541, 2052, 93, 1732, 1309, 388, 51, 53, 93, 517, 241, 45, 46, 49, 221, 517,
49, 76, 75, 45, 46, 45, 46, 45, 46, 45, 46, 45, 46, 45, 46, 45, 46, 45, 46, 81,
45, 46, 145, 107, 113, 61, 145, 44, 45, 46, 45, 46, 45, 46, 113, 50, 44, 114, 61, 49,
51, 81, 157, 164, 61, 4324, 93, 58, 61, 113, 51, 113, 45, 46, 49, 50, 49, 44, 81, 328,
81, 114, 81, 832, 45, 49, 46, 52, 43, 52, 833, 45, 50, 46, 50, 45, 46, 49, 45, 46,
81, 324, 35, 1444, 67, 996, 125, 196, 93, 196, 93, 196, 93, 100, 125, 83, 50, 52, 53, 83,
61, 53, 146, 85, 349, 122, 85, 93,
};
#endif
//--Autogenerated -- end of section automatically generated
constexpr int maxUnicode = 0x10ffff;
constexpr int maskCategory = 0x1F;
}
// Each element in catRanges is the start of a range of Unicode characters in
// one general category.
// The value is comprised of a 21-bit character value shifted 5 bits and a 5 bit
// category matching the CharacterCategory enumeration.
// Initial version has 3249 entries and adds about 13K to the executable.
// The array is in ascending order so can be searched using binary search.
// Therefore the average call takes log2(3249) = 12 comparisons.
// For speed, it may be useful to make a linear table for the common values,
// possibly for 0..0xff for most Western European text or 0..0xfff for most
// alphabetic languages.
CharacterCategory CategoriseCharacter(int character) noexcept {
if (character < 0 || character > maxUnicode) {
return ccCn;
}
#if CHARACTERCATEGORY_OPTIMIZE_LATIN1
if (static_cast<size_t>(character) < std::size(catLatin)) {
return static_cast<CharacterCategory>(catLatin[character]);
}
#endif
#if CHARACTERCATEGORY_USE_BINARY_SEARCH
const int baseValue = character * (maskCategory+1) + maskCategory;
const int *placeAfter = std::lower_bound(catRanges, std::end(catRanges), baseValue);
return static_cast<CharacterCategory>(*(placeAfter-1) & maskCategory);
#else
unsigned int index = (catTable1[character >> catTableShift11] << catTableShift12) | (character & catTableMask1);
index = (catTable2[index >> catTableShift21] << catTableShift22) | (index & catTableMask2);
return static_cast<CharacterCategory>(catTable[index]);
#endif
}
// Implementation of character sets recommended for identifiers in Unicode Standard Annex #31.
// https://unicode.org/reports/tr31/
namespace {
enum class OtherID { oidNone, oidStart, oidContinue };
// Some characters are treated as valid for identifiers even
// though most characters from their category are not.
// Values copied from https://www.unicode.org/Public/12.1.0/ucd/PropList.txt
OtherID OtherIDOfCharacter(int character) noexcept {
if (
(character == 0x1885) || // MONGOLIAN LETTER ALI GALI BALUDA
(character == 0x1886) || // MONGOLIAN LETTER ALI GALI THREE BALUDA
(character == 0x2118) || // SCRIPT CAPITAL P
(character == 0x212E) || // ESTIMATED SYMBOL
(character == 0x309B) || // KATAKANA-HIRAGANA VOICED SOUND MARK
(character == 0x309C)) { // KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
return OtherID::oidStart;
}
if (
(character == 0x00B7) || // MIDDLE DOT
(character == 0x0387) || // GREEK ANO TELEIA
((character >= 0x1369) && (character <= 0x1371)) || // ETHIOPIC DIGIT ONE..ETHIOPIC DIGIT NINE
(character == 0x19DA)) { // NEW TAI LUE THAM DIGIT ONE
return OtherID::oidContinue;
}
return OtherID::oidNone;
}
// Determine if a character is in Ll|Lu|Lt|Lm|Lo|Nl|Mn|Mc|Nd|Pc and has
// Pattern_Syntax|Pattern_White_Space.
// As of Unicode 12, only VERTICAL TILDE which is in Lm and has Pattern_Syntax matches.
// Should really generate from PropList.txt a list of Pattern_Syntax and Pattern_White_Space.
constexpr bool IsIdPattern(int character) noexcept {
return character == 0x2E2F;
}
bool OmitXidStart(int character) noexcept {
switch (character) {
case 0x037A: // GREEK YPOGEGRAMMENI
case 0x0E33: // THAI CHARACTER SARA AM
case 0x0EB3: // LAO VOWEL SIGN AM
case 0x309B: // KATAKANA-HIRAGANA VOICED SOUND MARK
case 0x309C: // KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
case 0xFC5E: // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM
case 0xFC5F: // ARABIC LIGATURE SHADDA WITH KASRATAN ISOLATED FORM
case 0xFC60: // ARABIC LIGATURE SHADDA WITH FATHA ISOLATED FORM
case 0xFC61: // ARABIC LIGATURE SHADDA WITH DAMMA ISOLATED FORM
case 0xFC62: // ARABIC LIGATURE SHADDA WITH KASRA ISOLATED FORM
case 0xFC63: // ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATED FORM
case 0xFDFA: // ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM
case 0xFDFB: // ARABIC LIGATURE JALLAJALALOUHOU
case 0xFE70: // ARABIC FATHATAN ISOLATED FORM
case 0xFE72: // ARABIC DAMMATAN ISOLATED FORM
case 0xFE74: // ARABIC KASRATAN ISOLATED FORM
case 0xFE76: // ARABIC FATHA ISOLATED FORM
case 0xFE78: // ARABIC DAMMA ISOLATED FORM
case 0xFE7A: // ARABIC KASRA ISOLATED FORM
case 0xFE7C: // ARABIC SHADDA ISOLATED FORM
case 0xFE7E: // ARABIC SUKUN ISOLATED FORM
case 0xFF9E: // HALFWIDTH KATAKANA VOICED SOUND MARK
case 0xFF9F: // HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK
return true;
default:
return false;
}
}
bool OmitXidContinue(int character) noexcept {
switch (character) {
case 0x037A: // GREEK YPOGEGRAMMENI
case 0x309B: // KATAKANA-HIRAGANA VOICED SOUND MARK
case 0x309C: // KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK
case 0xFC5E: // ARABIC LIGATURE SHADDA WITH DAMMATAN ISOLATED FORM
case 0xFC5F: // ARABIC LIGATURE SHADDA WITH KASRATAN ISOLATED FORM
case 0xFC60: // ARABIC LIGATURE SHADDA WITH FATHA ISOLATED FORM
case 0xFC61: // ARABIC LIGATURE SHADDA WITH DAMMA ISOLATED FORM
case 0xFC62: // ARABIC LIGATURE SHADDA WITH KASRA ISOLATED FORM
case 0xFC63: // ARABIC LIGATURE SHADDA WITH SUPERSCRIPT ALEF ISOLATED FORM
case 0xFDFA: // ARABIC LIGATURE SALLALLAHOU ALAYHE WASALLAM
case 0xFDFB: // ARABIC LIGATURE JALLAJALALOUHOU
case 0xFE70: // ARABIC FATHATAN ISOLATED FORM
case 0xFE72: // ARABIC DAMMATAN ISOLATED FORM
case 0xFE74: // ARABIC KASRATAN ISOLATED FORM
case 0xFE76: // ARABIC FATHA ISOLATED FORM
case 0xFE78: // ARABIC DAMMA ISOLATED FORM
case 0xFE7A: // ARABIC KASRA ISOLATED FORM
case 0xFE7C: // ARABIC SHADDA ISOLATED FORM
case 0xFE7E: // ARABIC SUKUN ISOLATED FORM
return true;
default:
return false;
}
}
}
// UAX #31 defines ID_Start as
// [[:L:][:Nl:][:Other_ID_Start:]--[:Pattern_Syntax:]--[:Pattern_White_Space:]]
bool IsIdStart(int character) noexcept {
if (IsIdPattern(character)) {
return false;
}
const OtherID oid = OtherIDOfCharacter(character);
if (oid == OtherID::oidStart) {
return true;
}
const CharacterCategory c = CategoriseCharacter(character);
return (c == ccLl || c == ccLu || c == ccLt || c == ccLm || c == ccLo
|| c == ccNl);
}
// UAX #31 defines ID_Continue as
// [[:ID_Start:][:Mn:][:Mc:][:Nd:][:Pc:][:Other_ID_Continue:]--[:Pattern_Syntax:]--[:Pattern_White_Space:]]
bool IsIdContinue(int character) noexcept {
if (IsIdPattern(character)) {
return false;
}
const OtherID oid = OtherIDOfCharacter(character);
if (oid != OtherID::oidNone) {
return true;
}
const CharacterCategory c = CategoriseCharacter(character);
return (c == ccLl || c == ccLu || c == ccLt || c == ccLm || c == ccLo
|| c == ccNl || c == ccMn || c == ccMc || c == ccNd || c == ccPc);
}
// XID_Start is ID_Start modified for Normalization Form KC in UAX #31
bool IsXidStart(int character) noexcept {
if (OmitXidStart(character)) {
return false;
}
return IsIdStart(character);
}
// XID_Continue is ID_Continue modified for Normalization Form KC in UAX #31
bool IsXidContinue(int character) noexcept {
if (OmitXidContinue(character)) {
return false;
}
return IsIdContinue(character);
}
CharacterCategoryMap::CharacterCategoryMap() {
Optimize(256);
}
int CharacterCategoryMap::Size() const noexcept {
return static_cast<int>(dense.size());
}
void CharacterCategoryMap::Optimize(int countCharacters) {
#if CHARACTERCATEGORY_USE_BINARY_SEARCH
const int characters = std::clamp(countCharacters, 256, maxUnicode + 1);
dense.resize(characters);
int end = 0;
int index = 0;
int current = catRanges[index];
++index;
do {
const int next = catRanges[index];
const unsigned char category = current & maskCategory;
current >>= 5;
end = std::min(characters, next >> 5);
while (current < end) {
dense[current++] = category;
}
current = next;
++index;
} while (characters > end);
#else
// only support BMP, see ExpandRLE() in CharClassify.cxx
const int characters = std::clamp(countCharacters, 256, 0xffff + 1);
dense.resize(characters);
int end = 0;
int index = 0;
do {
int current = CatTableRLE_BMP[index++];
const unsigned char category = current & maskCategory;
current >>= 5;
int count = std::min(current, characters - end);
while (count--) {
dense[end++] = category;
}
} while (characters > end);
#endif
}
}
| [
"zufuliu@gmail.com"
] | zufuliu@gmail.com |
7a4c5941d9fc471320e4d77bb8ccb656175b8a24 | 4cba6096a61c0ccda0adfa0e3de6b9402c93a005 | /gimp/data/blueprints/back/usr/include/c++/7/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp | e47decc55b446c430989d342d66379f11059228d | [] | no_license | StanfordSNR/gg-results | da3de3ce52235c187c6178b0ceab32df2526abf5 | 16ac020603e4b1ef96b2d8c27d1683724cbb30b8 | refs/heads/master | 2021-08-06T16:11:06.747488 | 2019-01-05T21:41:24 | 2019-01-05T21:41:24 | 103,858,663 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 63 | hpp | // GGHASH:VT8mLu0g9D9fi1SzA_fqEM08_peLMWYAnCtWS3tnmNgw000009b5
| [
"sfouladi@gmail.com"
] | sfouladi@gmail.com |
c2effe2951f4f5cb98180ed3440e701100b9d241 | 9836a073c4f9c4f371fdfe971045835a0736c73c | /Genetic_Algorithm/MainCycle.cpp | c7fe0f397405d21b058de39a66181b0279622c60 | [] | no_license | Volodimirich/LargeSystems | 962efce5be55d077f32b9d4b959d0cdba305f693 | dfaa70312cd48cfcb6c37cb9f777b29d381f85e8 | refs/heads/master | 2023-02-05T04:42:32.461806 | 2020-12-17T23:11:39 | 2020-12-17T23:11:39 | 295,217,829 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,310 | cpp | //
// Created by voland on 15.12.2020.
//
#include "MainCycle.h"
#include "vector"
#include <unistd.h>
#include <fstream>
#include "string"
void MainCycle::Clear() {
printf("\033[2J");
printf("\033[%d;%dH", 0, 0);
}
void MainCycle::WriteInFile(space &best, bool last) {
std::cout<<exp_numb;
std::cout<<launch_numb << std::endl;
std::string filename = !last ? "series_" + std::to_string(exp_numb) + "_run_" + std::to_string(launch_numb) + ".txt" :
"series_" + std::to_string(exp_numb) + "_run_" + std::to_string(launch_numb) + "_sol_after100.txt";
std::ofstream file(filename.c_str());
for (size_t i = 0; i < best.size(); i++) {
for (size_t j = 0; j < best[i].size(); j++) {
auto symb = best[i][j] == 1 ? "#" : ".";
file << symb;
}
file << std::endl;
}
file.close();
}
void MainCycle::PrintResult(space &best) {
WriteInFile(best, false);
for (size_t it = 0; it<101; it++) {
// for (size_t i = 0; i < best.size(); i++) {
// for (size_t j = 0; j < best[i].size(); j++) {
// auto symb = best[i][j] == 1 ? "#" : ".";
// std::cout << symb;
// }
// std::cout << std::endl;
// }
estim->LifeStart(best, 1);
// usleep(500000);
// Clear();
}
WriteInFile(best, true);
}
MainCycle::MainCycle() {
space gen;
std::vector<int> line;
estim = std::make_unique<Estimation> ();
select = std::make_unique<Selection>();
cross = std::make_unique<Crossing>();
mutate = std::make_unique<Mutation>();
srand(static_cast<unsigned int>(time(nullptr)));
for (size_t pop = 0; pop<POPULATION_SIZE; pop++){
for (size_t i=0; i<FIELD; i++) {
for (size_t j = 0; j < FIELD; j++) {
line.emplace_back(rand() % 2);
}
gen.emplace_back(line);
line.clear();
}
population.emplace_back(gen);
gen.clear();
}
}
void MainCycle::Start(float mut, int numb, int launch) {
std::pair <space, int> best = {{}, 0};
int pos;
size_t best_itt = 0;
mut_probability = mut;
exp_numb = numb;
launch_numb = launch;
while (best_itt < 20) {
pos = -1;
std::vector<std::pair<space, int>> population_estimition = estim->GetEstimation(population);
for (size_t i = 0; i < population_estimition.size(); i++) {
if (population_estimition[i].second > best.second) {
best.second = population_estimition[i].second;
pos = i;
}
}
if (pos != -1) {
best.first = population_estimition[pos].first;
best_itt = 0;
} else {
best_itt++;
}
std::vector<space> new_gen = select->GetSelect(population_estimition, 8, POPULATION_SIZE / 2);
cross->GetCrossing(new_gen);
mutate->GetMutation(new_gen, mut_probability);
population = new_gen;
}
std::cout << "BEST" << best.second << std::endl;
PrintResult(best.first);
std::string filename = "series_" + std::to_string(exp_numb) + "_best_result_" + std::to_string(launch_numb) + ".txt";
std::ofstream file(filename.c_str());
file << best.second;
file.close();
}
| [
"volodimirich@arccn.ru"
] | volodimirich@arccn.ru |
90921248a8b9633a8ba7c4877d60aaec5e1a9595 | 4469634a5205a9b6e3cca8788b78ffd4d69a50f6 | /aws-cpp-sdk-sms-voice/source/PinpointSMSVoiceClient.cpp | 56c0e13869189c2d233b745e006e3c90068fe6a4 | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | tnthornton/aws-sdk-cpp | 7070108f778ce9c39211d7041a537a5598f2a351 | e30ee8c5b40091a11f1019d9230bbfac1e6c5edd | refs/heads/master | 2020-04-11T04:53:19.482117 | 2018-12-12T01:33:22 | 2018-12-12T01:33:22 | 161,530,181 | 0 | 0 | Apache-2.0 | 2018-12-12T18:41:56 | 2018-12-12T18:41:55 | null | UTF-8 | C++ | false | false | 17,800 | cpp | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <aws/core/utils/Outcome.h>
#include <aws/core/auth/AWSAuthSigner.h>
#include <aws/core/client/CoreErrors.h>
#include <aws/core/client/RetryStrategy.h>
#include <aws/core/http/HttpClient.h>
#include <aws/core/http/HttpResponse.h>
#include <aws/core/http/HttpClientFactory.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/threading/Executor.h>
#include <aws/core/utils/DNS.h>
#include <aws/core/utils/logging/LogMacros.h>
#include <aws/sms-voice/PinpointSMSVoiceClient.h>
#include <aws/sms-voice/PinpointSMSVoiceEndpoint.h>
#include <aws/sms-voice/PinpointSMSVoiceErrorMarshaller.h>
#include <aws/sms-voice/model/CreateConfigurationSetRequest.h>
#include <aws/sms-voice/model/CreateConfigurationSetEventDestinationRequest.h>
#include <aws/sms-voice/model/DeleteConfigurationSetRequest.h>
#include <aws/sms-voice/model/DeleteConfigurationSetEventDestinationRequest.h>
#include <aws/sms-voice/model/GetConfigurationSetEventDestinationsRequest.h>
#include <aws/sms-voice/model/SendVoiceMessageRequest.h>
#include <aws/sms-voice/model/UpdateConfigurationSetEventDestinationRequest.h>
using namespace Aws;
using namespace Aws::Auth;
using namespace Aws::Client;
using namespace Aws::PinpointSMSVoice;
using namespace Aws::PinpointSMSVoice::Model;
using namespace Aws::Http;
using namespace Aws::Utils::Json;
static const char* SERVICE_NAME = "sms-voice";
static const char* ALLOCATION_TAG = "PinpointSMSVoiceClient";
PinpointSMSVoiceClient::PinpointSMSVoiceClient(const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<DefaultAWSCredentialsProviderChain>(ALLOCATION_TAG),
SERVICE_NAME, clientConfiguration.region),
Aws::MakeShared<PinpointSMSVoiceErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
PinpointSMSVoiceClient::PinpointSMSVoiceClient(const AWSCredentials& credentials, const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, Aws::MakeShared<SimpleAWSCredentialsProvider>(ALLOCATION_TAG, credentials),
SERVICE_NAME, clientConfiguration.region),
Aws::MakeShared<PinpointSMSVoiceErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
PinpointSMSVoiceClient::PinpointSMSVoiceClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
const Client::ClientConfiguration& clientConfiguration) :
BASECLASS(clientConfiguration,
Aws::MakeShared<AWSAuthV4Signer>(ALLOCATION_TAG, credentialsProvider,
SERVICE_NAME, clientConfiguration.region),
Aws::MakeShared<PinpointSMSVoiceErrorMarshaller>(ALLOCATION_TAG)),
m_executor(clientConfiguration.executor)
{
init(clientConfiguration);
}
PinpointSMSVoiceClient::~PinpointSMSVoiceClient()
{
}
void PinpointSMSVoiceClient::init(const ClientConfiguration& config)
{
m_configScheme = SchemeMapper::ToString(config.scheme);
if (config.endpointOverride.empty())
{
m_uri = m_configScheme + "://" + PinpointSMSVoiceEndpoint::ForRegion(config.region, config.useDualStack);
}
else
{
OverrideEndpoint(config.endpointOverride);
}
}
void PinpointSMSVoiceClient::OverrideEndpoint(const Aws::String& endpoint)
{
if (endpoint.compare(0, 7, "http://") == 0 || endpoint.compare(0, 8, "https://") == 0)
{
m_uri = endpoint;
}
else
{
m_uri = m_configScheme + "://" + endpoint;
}
}
CreateConfigurationSetOutcome PinpointSMSVoiceClient::CreateConfigurationSet(const CreateConfigurationSetRequest& request) const
{
Aws::StringStream ss;
Aws::Http::URI uri = m_uri;
ss << "/v1/sms-voice/configuration-sets";
uri.SetPath(uri.GetPath() + ss.str());
JsonOutcome outcome = MakeRequest(uri, request, HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER);
if(outcome.IsSuccess())
{
return CreateConfigurationSetOutcome(CreateConfigurationSetResult(outcome.GetResult()));
}
else
{
return CreateConfigurationSetOutcome(outcome.GetError());
}
}
CreateConfigurationSetOutcomeCallable PinpointSMSVoiceClient::CreateConfigurationSetCallable(const CreateConfigurationSetRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< CreateConfigurationSetOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->CreateConfigurationSet(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void PinpointSMSVoiceClient::CreateConfigurationSetAsync(const CreateConfigurationSetRequest& request, const CreateConfigurationSetResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->CreateConfigurationSetAsyncHelper( request, handler, context ); } );
}
void PinpointSMSVoiceClient::CreateConfigurationSetAsyncHelper(const CreateConfigurationSetRequest& request, const CreateConfigurationSetResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, CreateConfigurationSet(request), context);
}
CreateConfigurationSetEventDestinationOutcome PinpointSMSVoiceClient::CreateConfigurationSetEventDestination(const CreateConfigurationSetEventDestinationRequest& request) const
{
Aws::StringStream ss;
Aws::Http::URI uri = m_uri;
ss << "/v1/sms-voice/configuration-sets/";
ss << request.GetConfigurationSetName();
ss << "/event-destinations";
uri.SetPath(uri.GetPath() + ss.str());
JsonOutcome outcome = MakeRequest(uri, request, HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER);
if(outcome.IsSuccess())
{
return CreateConfigurationSetEventDestinationOutcome(CreateConfigurationSetEventDestinationResult(outcome.GetResult()));
}
else
{
return CreateConfigurationSetEventDestinationOutcome(outcome.GetError());
}
}
CreateConfigurationSetEventDestinationOutcomeCallable PinpointSMSVoiceClient::CreateConfigurationSetEventDestinationCallable(const CreateConfigurationSetEventDestinationRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< CreateConfigurationSetEventDestinationOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->CreateConfigurationSetEventDestination(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void PinpointSMSVoiceClient::CreateConfigurationSetEventDestinationAsync(const CreateConfigurationSetEventDestinationRequest& request, const CreateConfigurationSetEventDestinationResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->CreateConfigurationSetEventDestinationAsyncHelper( request, handler, context ); } );
}
void PinpointSMSVoiceClient::CreateConfigurationSetEventDestinationAsyncHelper(const CreateConfigurationSetEventDestinationRequest& request, const CreateConfigurationSetEventDestinationResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, CreateConfigurationSetEventDestination(request), context);
}
DeleteConfigurationSetOutcome PinpointSMSVoiceClient::DeleteConfigurationSet(const DeleteConfigurationSetRequest& request) const
{
Aws::StringStream ss;
Aws::Http::URI uri = m_uri;
ss << "/v1/sms-voice/configuration-sets/";
ss << request.GetConfigurationSetName();
uri.SetPath(uri.GetPath() + ss.str());
JsonOutcome outcome = MakeRequest(uri, request, HttpMethod::HTTP_DELETE, Aws::Auth::SIGV4_SIGNER);
if(outcome.IsSuccess())
{
return DeleteConfigurationSetOutcome(DeleteConfigurationSetResult(outcome.GetResult()));
}
else
{
return DeleteConfigurationSetOutcome(outcome.GetError());
}
}
DeleteConfigurationSetOutcomeCallable PinpointSMSVoiceClient::DeleteConfigurationSetCallable(const DeleteConfigurationSetRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< DeleteConfigurationSetOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->DeleteConfigurationSet(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void PinpointSMSVoiceClient::DeleteConfigurationSetAsync(const DeleteConfigurationSetRequest& request, const DeleteConfigurationSetResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->DeleteConfigurationSetAsyncHelper( request, handler, context ); } );
}
void PinpointSMSVoiceClient::DeleteConfigurationSetAsyncHelper(const DeleteConfigurationSetRequest& request, const DeleteConfigurationSetResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, DeleteConfigurationSet(request), context);
}
DeleteConfigurationSetEventDestinationOutcome PinpointSMSVoiceClient::DeleteConfigurationSetEventDestination(const DeleteConfigurationSetEventDestinationRequest& request) const
{
Aws::StringStream ss;
Aws::Http::URI uri = m_uri;
ss << "/v1/sms-voice/configuration-sets/";
ss << request.GetConfigurationSetName();
ss << "/event-destinations/";
ss << request.GetEventDestinationName();
uri.SetPath(uri.GetPath() + ss.str());
JsonOutcome outcome = MakeRequest(uri, request, HttpMethod::HTTP_DELETE, Aws::Auth::SIGV4_SIGNER);
if(outcome.IsSuccess())
{
return DeleteConfigurationSetEventDestinationOutcome(DeleteConfigurationSetEventDestinationResult(outcome.GetResult()));
}
else
{
return DeleteConfigurationSetEventDestinationOutcome(outcome.GetError());
}
}
DeleteConfigurationSetEventDestinationOutcomeCallable PinpointSMSVoiceClient::DeleteConfigurationSetEventDestinationCallable(const DeleteConfigurationSetEventDestinationRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< DeleteConfigurationSetEventDestinationOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->DeleteConfigurationSetEventDestination(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void PinpointSMSVoiceClient::DeleteConfigurationSetEventDestinationAsync(const DeleteConfigurationSetEventDestinationRequest& request, const DeleteConfigurationSetEventDestinationResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->DeleteConfigurationSetEventDestinationAsyncHelper( request, handler, context ); } );
}
void PinpointSMSVoiceClient::DeleteConfigurationSetEventDestinationAsyncHelper(const DeleteConfigurationSetEventDestinationRequest& request, const DeleteConfigurationSetEventDestinationResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, DeleteConfigurationSetEventDestination(request), context);
}
GetConfigurationSetEventDestinationsOutcome PinpointSMSVoiceClient::GetConfigurationSetEventDestinations(const GetConfigurationSetEventDestinationsRequest& request) const
{
Aws::StringStream ss;
Aws::Http::URI uri = m_uri;
ss << "/v1/sms-voice/configuration-sets/";
ss << request.GetConfigurationSetName();
ss << "/event-destinations";
uri.SetPath(uri.GetPath() + ss.str());
JsonOutcome outcome = MakeRequest(uri, request, HttpMethod::HTTP_GET, Aws::Auth::SIGV4_SIGNER);
if(outcome.IsSuccess())
{
return GetConfigurationSetEventDestinationsOutcome(GetConfigurationSetEventDestinationsResult(outcome.GetResult()));
}
else
{
return GetConfigurationSetEventDestinationsOutcome(outcome.GetError());
}
}
GetConfigurationSetEventDestinationsOutcomeCallable PinpointSMSVoiceClient::GetConfigurationSetEventDestinationsCallable(const GetConfigurationSetEventDestinationsRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< GetConfigurationSetEventDestinationsOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->GetConfigurationSetEventDestinations(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void PinpointSMSVoiceClient::GetConfigurationSetEventDestinationsAsync(const GetConfigurationSetEventDestinationsRequest& request, const GetConfigurationSetEventDestinationsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->GetConfigurationSetEventDestinationsAsyncHelper( request, handler, context ); } );
}
void PinpointSMSVoiceClient::GetConfigurationSetEventDestinationsAsyncHelper(const GetConfigurationSetEventDestinationsRequest& request, const GetConfigurationSetEventDestinationsResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, GetConfigurationSetEventDestinations(request), context);
}
SendVoiceMessageOutcome PinpointSMSVoiceClient::SendVoiceMessage(const SendVoiceMessageRequest& request) const
{
Aws::StringStream ss;
Aws::Http::URI uri = m_uri;
ss << "/v1/sms-voice/voice/message";
uri.SetPath(uri.GetPath() + ss.str());
JsonOutcome outcome = MakeRequest(uri, request, HttpMethod::HTTP_POST, Aws::Auth::SIGV4_SIGNER);
if(outcome.IsSuccess())
{
return SendVoiceMessageOutcome(SendVoiceMessageResult(outcome.GetResult()));
}
else
{
return SendVoiceMessageOutcome(outcome.GetError());
}
}
SendVoiceMessageOutcomeCallable PinpointSMSVoiceClient::SendVoiceMessageCallable(const SendVoiceMessageRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< SendVoiceMessageOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->SendVoiceMessage(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void PinpointSMSVoiceClient::SendVoiceMessageAsync(const SendVoiceMessageRequest& request, const SendVoiceMessageResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->SendVoiceMessageAsyncHelper( request, handler, context ); } );
}
void PinpointSMSVoiceClient::SendVoiceMessageAsyncHelper(const SendVoiceMessageRequest& request, const SendVoiceMessageResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, SendVoiceMessage(request), context);
}
UpdateConfigurationSetEventDestinationOutcome PinpointSMSVoiceClient::UpdateConfigurationSetEventDestination(const UpdateConfigurationSetEventDestinationRequest& request) const
{
Aws::StringStream ss;
Aws::Http::URI uri = m_uri;
ss << "/v1/sms-voice/configuration-sets/";
ss << request.GetConfigurationSetName();
ss << "/event-destinations/";
ss << request.GetEventDestinationName();
uri.SetPath(uri.GetPath() + ss.str());
JsonOutcome outcome = MakeRequest(uri, request, HttpMethod::HTTP_PUT, Aws::Auth::SIGV4_SIGNER);
if(outcome.IsSuccess())
{
return UpdateConfigurationSetEventDestinationOutcome(UpdateConfigurationSetEventDestinationResult(outcome.GetResult()));
}
else
{
return UpdateConfigurationSetEventDestinationOutcome(outcome.GetError());
}
}
UpdateConfigurationSetEventDestinationOutcomeCallable PinpointSMSVoiceClient::UpdateConfigurationSetEventDestinationCallable(const UpdateConfigurationSetEventDestinationRequest& request) const
{
auto task = Aws::MakeShared< std::packaged_task< UpdateConfigurationSetEventDestinationOutcome() > >(ALLOCATION_TAG, [this, request](){ return this->UpdateConfigurationSetEventDestination(request); } );
auto packagedFunction = [task]() { (*task)(); };
m_executor->Submit(packagedFunction);
return task->get_future();
}
void PinpointSMSVoiceClient::UpdateConfigurationSetEventDestinationAsync(const UpdateConfigurationSetEventDestinationRequest& request, const UpdateConfigurationSetEventDestinationResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
m_executor->Submit( [this, request, handler, context](){ this->UpdateConfigurationSetEventDestinationAsyncHelper( request, handler, context ); } );
}
void PinpointSMSVoiceClient::UpdateConfigurationSetEventDestinationAsyncHelper(const UpdateConfigurationSetEventDestinationRequest& request, const UpdateConfigurationSetEventDestinationResponseReceivedHandler& handler, const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) const
{
handler(this, request, UpdateConfigurationSetEventDestination(request), context);
}
| [
"aws-sdk-cpp-automation@github.com"
] | aws-sdk-cpp-automation@github.com |
eae05a8e271dfc203b1c56419ec36a7992f168e2 | 78b337c794b02372620ffbb6674073c6f0d1fd3d | /assimp-5.0.1/test/unit/utXImporterExporter.cpp | 39cda4e35c8c0c3dbb339789023f8eab5c71197f | [
"MIT",
"LGPL-2.0-or-later",
"BSD-3-Clause"
] | permissive | eglowacki/yaget_dependencies | 1fb0298f5af210fcc0f8e2c7052a97be5134f0fc | 7bbaaef4d968b9f1cd54963331017ac499777a1f | refs/heads/master | 2023-06-27T18:10:29.104169 | 2021-07-17T19:38:16 | 2021-07-17T19:38:16 | 261,091,491 | 0 | 0 | MIT | 2021-02-27T21:20:16 | 2020-05-04T05:51:17 | C++ | UTF-8 | C++ | false | false | 4,842 | cpp | /*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2020, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "AbstractImportExportBase.h"
#include "UnitTestPCH.h"
#include <assimp/postprocess.h>
#include <assimp/Importer.hpp>
using namespace Assimp;
class utXImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
};
TEST_F(utXImporterExporter, importXFromFileTest) {
EXPECT_TRUE(importerTest());
}
TEST_F(utXImporterExporter, heap_overflow_in_tokenizer) {
Assimp::Importer importer;
EXPECT_NO_THROW(importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/OV_GetNextToken", 0));
}
TEST(utXImporter, importAnimTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/anim_test.x", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, importBCNEpileptic) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/BCN_Epileptic.X", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, importFromTrueSpaceBin32) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/fromtruespace_bin32.x", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, import_kwxport_test_cubewithvcolors) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/kwxport_test_cubewithvcolors.x", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, importTestCubeBinary) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_binary.x", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, importTestCubeCompressed) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_compressed.x", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, importTestCubeText) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test_cube_text.x", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, importTestWuson) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/Testwuson.X", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, TestFormatDetection) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/X/TestFormatDetection", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
TEST(utXImporter, importDwarf) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_NONBSD_DIR "/X/dwarf.x", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
}
| [
"edgar_glowacki@yahoo.com"
] | edgar_glowacki@yahoo.com |
b0be7dc6ec42364728cff3b0d0b16b60287366f8 | eafc5ac599f2e96c3ca61612abb109eba2abe655 | /customSolvers/edcSimpleFoam/lib/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H | cad873ab725423ad055a576793f9c4149a356dc6 | [] | no_license | kohyun/OpenFOAM_MSc_Thesis_Project | b651eb129611d41dbb4d3b08a2dec0d4db7663b3 | 11f6b69c23082b3b47b04963c5fc87b8ab4dd08d | refs/heads/master | 2023-03-17T22:34:57.127580 | 2019-01-12T07:41:07 | 2019-01-12T07:41:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,337 | h | /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::greyDiffusiveRadiationMixedFvPatchScalarField
Description
Radiation temperature specified
SourceFiles
greyDiffusiveRadiationMixedFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef greyDiffusiveRadiationMixedFvPatchScalarField_H
#define greyDiffusiveRadiationMixedFvPatchScalarField_H
#include "mixedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class greyDiffusiveRadiationMixedFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class greyDiffusiveRadiationMixedFvPatchScalarField
:
public mixedFvPatchScalarField
{
// Private data
//- Name of temperature field
word TName_;
//- Emissivity
scalar emissivity_;
public:
//- Runtime type information
TypeName("greyDiffusiveRadiation");
// Constructors
//- Construct from patch and internal field
greyDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
greyDiffusiveRadiationMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given a
// greyDiffusiveRadiationMixedFvPatchScalarField onto a new patch
greyDiffusiveRadiationMixedFvPatchScalarField
(
const greyDiffusiveRadiationMixedFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
greyDiffusiveRadiationMixedFvPatchScalarField
(
const greyDiffusiveRadiationMixedFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new greyDiffusiveRadiationMixedFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
greyDiffusiveRadiationMixedFvPatchScalarField
(
const greyDiffusiveRadiationMixedFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new greyDiffusiveRadiationMixedFvPatchScalarField(*this, iF)
);
}
// Member functions
// Access
//- Return the temperature field name
const word& TName() const
{
return TName_;
}
//- Return reference to the temperature field name to allow
// adjustment
word& TName()
{
return TName_;
}
//- Return the emissivity
const scalar& emissivity() const
{
return emissivity_;
}
//- Return reference to the emissivity to allow adjustment
scalar& emissivity()
{
return emissivity_;
}
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
// I-O
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
| [
"ali@ali-Inspiron-1525.(none)"
] | ali@ali-Inspiron-1525.(none) |
77a7283969dcf92757a2a9b9be70bc0c37d06e4f | 3e0564518184224152071b318fd280e0c6c30b62 | /matGroup/matGroupRealised.h | cdaa75ee4ef01d1ec8d8aaef47d7b81482be625c | [] | no_license | yfszzx/MatX | 5f70c112a8a0720572cfd134ad81439b3a53ab29 | 81a9d1b0744569d437eb860c370b66707747b1b4 | refs/heads/master | 2020-04-06T06:57:02.566352 | 2016-06-20T13:20:55 | 2016-06-20T13:20:55 | 50,677,779 | 3 | 1 | null | null | null | null | GB18030 | C++ | false | false | 8,961 | h | template <typename TYPE, bool CUDA >
int MatGroup<TYPE, CUDA>::size() const{
int ret = 0;
for(int i = 0; i< matsNum; i++){
ret += mats[i]->size();
}
return ret;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA>::MatGroup(){
matsNum = 0;
mats = NULL;
selfSpace = false;
fixMat = false;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA>::~MatGroup(){
memFree();
}
template <typename TYPE, bool CUDA >
void MatGroup<TYPE, CUDA>::memFree(){
if(mats != NULL){
if(selfSpace){
for(int i = 0; i< matsNum; i++){
delete mats[i];
}
}
delete [] mats;
}
}
template <typename TYPE, bool CUDA >
void MatGroup<TYPE, CUDA>::copy(const MatGroup<TYPE, CUDA> & m){
matsNum = m.matsNum;
mats = new MatriX<TYPE, CUDA> *[matsNum];
for(int i = 0; i< matsNum; i++){
mats[i] = new MatriX<TYPE, CUDA>(*m.mats[i]);
}
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA>::MatGroup<TYPE, CUDA>(const MatGroup<TYPE, !CUDA> & m){
selfSpace = true;
matsNum = m.matsNum;
fixMat = false;
mats = new MatriX<TYPE, CUDA> *[matsNum];
for(int i = 0; i< matsNum; i++){
mats[i] = new MatriX<TYPE, CUDA>(*m.mats[i]);
}
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA>::MatGroup<TYPE, CUDA>(const MatGroup<TYPE, CUDA> & m){
fixMat = false;
selfSpace = true;
copy(m);
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA>::MatGroup<TYPE, CUDA>(MatriX<TYPE, CUDA> * m, int num){
matsNum = num;
fixMat = false;
selfSpace = false;
mats = new MatriX<TYPE, CUDA> *[matsNum];
for(int i = 0; i< matsNum; i++){
mats[i] = m + i;
}
};
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA>::MatGroup<TYPE, CUDA>(MatriX<TYPE, !CUDA> * m, int num){
matsNum = mum;
fixMat = false;
selfSpace = true;
mats = new MatriX<TYPE, CUDA> *[matsNum];
for(int i = 0; i< matsNum; i++){
mats[i] = new MatriX<TYPE, CUDA>(m[i]);
}
};
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator <<(MatriX<TYPE, CUDA> & mat){
if(fixMat){
Assert("无法在固定矩阵组中加入新矩阵");
}
MatriX<TYPE, CUDA> ** temp = new MatriX<TYPE, CUDA> *[matsNum + 1];
if(matsNum > 0){
memcpy(temp, mats, sizeof(MatriX<TYPE, CUDA> *) * matsNum);
}
temp[matsNum] = &mat;
matsNum ++;
if(mats != NULL){
delete [] mats;
}
mats = temp;
return *this;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator += (const MatGroup<TYPE, CUDA> & m){
if(fixMat && m.fixMat){
fixMemMat += m.fixMemMat;
}else{
for(int i = 0; i< matsNum; i++){
*mats[i] += *m.mats[i];
}
}
return *this;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator -= (const MatGroup<TYPE, CUDA> & m){
if(fixMat && m.fixMat){
fixMemMat -= m.fixMemMat;
}else{
for(int i = 0; i< matsNum; i++){
*mats[i] -= *m.mats[i];
}
}
return *this;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> MatGroup<TYPE, CUDA>::operator + (const MatGroup<TYPE, CUDA> & m) const{
MatGroup<TYPE, CUDA> ret(*this);
if(fixMat && m.fixMat){
ret.fixMemMat += m.fixMemMat;
}else{
for(int i = 0; i< matsNum; i++){
*ret.mats[i] += *m.mats[i];
}
}
return ret;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> MatGroup<TYPE, CUDA>::operator - (const MatGroup<TYPE, CUDA> & m) const{
MatGroup<TYPE, CUDA> ret(*this);
if(fixMat && m.fixMat){
ret.fixMemMat -= m.fixMemMat;
}else{
for(int i = 0; i< matsNum; i++){
*ret.mats[i] -= *m.mats[i];
}
}
return ret;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator = (const MatGroup<TYPE, CUDA> & m){
if(matsNum == 0){
selfSpace = true;
copy(m);
return *this;
}
if(fixMat && m.fixMat ){
if(fixMemMat.size() != m.fixMemMat.size() || matsNum != m.matsNum){
Assert("\n【错误】MatGroup大小不一致,无法赋值");
}else{
cuWrap::memD2D(fixMemMat.dataPrt(), m.fixMemMat.dataPrt(), sizeof(TYPE) * fixMemMat.size());
}
}else{
if(matsNum != m.matsNum){
Assert("\n【错误】MatGroup元素个数不一致,无法赋值");
}
for(int i = 0; i< matsNum; i++){
*mats[i] = m[i];
}
}
return *this;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator /= ( TYPE scl){
if(fixMat){
cuWrap::scale(fixMemMat.dataPrt(),(TYPE)1.0f/scl, fixMemMat.size());
}else{
for(int i = 0; i< matsNum; i++){
*mats[i] /= scl;
}
}
return *this;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator *= ( TYPE scl){
if(fixMat){
cuWrap::scale(fixMemMat.dataPrt(), scl, fixMemMat.size());
}else{
for(int i = 0; i< matsNum; i++){
*mats[i] *= scl;
}
}
return *this;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator = ( TYPE val){
if(fixMat){
cuWrap::fill(fixMemMat.dataPrt(), val, fixMemMat.size());
}else{
for(int i = 0; i< matsNum; i++){
*mats[i] = val;
}
}
return *this;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> MatGroup<TYPE, CUDA>::operator * ( TYPE scl) const{
MatGroup<TYPE, CUDA> ret(*this);
ret *= scl;
return ret;
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> MatGroup<TYPE, CUDA>::operator / ( TYPE scl) const{
MatGroup<TYPE, CUDA> ret(*this);
ret /= scl;
return ret;
}
template <typename TYPE, bool CUDA >
MatriX<TYPE, CUDA> & MatGroup<TYPE, CUDA>::operator [] (int i) const{
return *mats[i];
}
template <typename TYPE, bool CUDA >
TYPE MatGroup<TYPE, CUDA>::squaredNorm() const{
double ret = 0;
if(fixMat){
ret = fixMemMat.squaredNorm();
}else{
for(int i = 0; i< matsNum; i++){
ret += mats[i]->squaredNorm();
}
}
return ret;
}
template <typename TYPE, bool CUDA >
TYPE MatGroup<TYPE, CUDA>::norm() const{
return sqrt(squaredNorm());
}
template <typename TYPE, bool CUDA >
TYPE MatGroup<TYPE, CUDA>::dot(const MatGroup<TYPE, CUDA> & m) const{
double ret=0;
if(fixMat && m.fixMat){
ret = fixMemMat.dot(m.fixMemMat);
}else{
for(int i = 0; i< matsNum; i++){
ret += mats[i]->dot(m[i]);
}
}
return ret;
}
template <typename TYPE, bool CUDA >
TYPE MatGroup<TYPE, CUDA>::sum() const{
double ret=0;
if(fixMat){
ret = fixMemMat.allSum();
}else{
for(int i = 0; i< matsNum; i++){
ret += mats[i]->allSum();
}
}
return ret;
}
template <typename TYPE, bool CUDA >
TYPE MatGroup<TYPE, CUDA>::correl(const MatGroup<TYPE, CUDA> & m) const{
double ysum = 0;
double tsum = 0;
double _dot = 0;
double ysn = 0;
double tsn = 0;
int n = 0;
for(int i = 0 ; i < matsNum; i++){
ysum += mats[i]->allSum();
tsum += m.mats[i]->allSum();
_dot += mats[i]->dot(*m.mats[i]);
ysn += mats[i]->squaredNorm();
tsn += m.mats[i]->squaredNorm();
n += mats[i]->size();
}
return (n * _dot - ysum * tsum)/sqrt(( n * ysn - ysum * ysum) *( n * tsn - tsum * tsum));
}
template <typename TYPE, bool CUDA >
TYPE MatGroup<TYPE, CUDA>::MSE() const{
double avg = 0;
int n = 0;
for(int i = 0 ; i < matsNum; i++){
avg += mats[i]->allSum();
n += mats[i]->size();
}
avg /= n;
double mse = 0;
for(int i = 0 ; i < matsNum; i++){
mse += (*mats[i] - (TYPE)avg).squaredNorm();
}
return mse/n;
}
template <typename TYPE, bool CUDA >
void MatGroup<TYPE, CUDA>::show() const{
cout<<"\nnum:"<<matsNum<<"\n";
for(int i = 0; i< matsNum; i++){
cout<<"["<<i<<"]"<<mats[i]->str();
}
}
template <typename TYPE,bool CUDA >
MatGroup<TYPE, CUDA> operator * (const TYPE scl, const MatGroup<TYPE, CUDA> & m){
MatGroup<TYPE, CUDA> ret(m);
ret *= scl;
return ret;
}
template <typename TYPE,bool CUDA >
MatGroup<TYPE, CUDA> operator - (const MatGroup<TYPE, CUDA> & m){
MatGroup<TYPE, CUDA> ret(m);
ret *= -1;
return ret;
}
template <typename TYPE, bool CUDA >
void MatGroup<TYPE, CUDA>::save(ofstream & fl) const{
fl.write((char *)&matsNum, sizeof(int));
fl.write((char *)&fixMat, sizeof(bool));
for(int i = 0; i< matsNum; i++){
mats[i]->save(fl);
}
}
template <typename TYPE, bool CUDA >
void MatGroup<TYPE, CUDA>::read(ifstream & fl){
fl.read((char *)&matsNum, sizeof(int));
bool tmp;
fl.read((char *)&tmp, sizeof(bool));
for(int i = 0; i< matsNum; i++){
mats[i]->read(fl);
}
if(tmp){
setFix();
}
}
template <typename TYPE, bool CUDA >
void MatGroup<TYPE, CUDA>::setFix(){
if(CUDA && !fixMat){
fixMemMat = MatriX<TYPE, CUDA>::Zero(size(),1);
int pos = 0;
for(int i = 0; i< matsNum; i++){
pos += mats[i]->size();
}
fixMat = true;
}
}
template <typename TYPE, bool CUDA >
void MatGroup<TYPE, CUDA>::fixFree(){
if(fixMat){
for(int i = 0; i< matsNum; i++){
}
fixMemMat = MatriX<TYPE, CUDA>::Zero(0,0);
fixMat = false;
}
}
template <typename TYPE, bool CUDA >
MatGroup<TYPE, CUDA> & MatGroup<TYPE, CUDA>::clear(){
memFree();
matsNum = 0;
mats = NULL;
selfSpace = false;
fixMat = false;
return *this;
}
template <typename TYPE, bool CUDA >
int MatGroup<TYPE, CUDA>::num() const{
return matsNum;
} | [
"yfszzx@gmail.com"
] | yfszzx@gmail.com |
efa199d4162d6bd81ab0154404d330b119e6f003 | fb7efe44f4d9f30d623f880d0eb620f3a81f0fbd | /chrome/common/profiling/profiling_client.cc | 1cc5d300c8c64768d80fbfb9e5f0bfb05eaba3cb | [
"BSD-3-Clause"
] | permissive | wzyy2/chromium-browser | 2644b0daf58f8b3caee8a6c09a2b448b2dfe059c | eb905f00a0f7e141e8d6c89be8fb26192a88c4b7 | refs/heads/master | 2022-11-23T20:25:08.120045 | 2018-01-16T06:41:26 | 2018-01-16T06:41:26 | 117,618,467 | 3 | 2 | BSD-3-Clause | 2022-11-20T22:03:57 | 2018-01-16T02:09:10 | null | UTF-8 | C++ | false | false | 2,392 | cc | // Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/profiling/profiling_client.h"
#include "base/files/platform_file.h"
#include "chrome/common/profiling/memlog_allocator_shim.h"
#include "chrome/common/profiling/memlog_sender_pipe.h"
#include "chrome/common/profiling/memlog_stream.h"
#include "content/public/common/service_manager_connection.h"
#include "content/public/common/simple_connection_filter.h"
#include "mojo/public/cpp/system/platform_handle.h"
#include "services/service_manager/public/cpp/binder_registry.h"
namespace profiling {
ProfilingClient::ProfilingClient() : binding_(this) {}
ProfilingClient::~ProfilingClient() {
StopAllocatorShimDangerous();
// The allocator shim cannot be synchronously, consistently stopped. We leak
// the memlog_sender_pipe_, with the idea that very few future messages will
// be sent to it. This happens at shutdown, so resources will be reclaimed by
// the OS after the process is terminated.
memlog_sender_pipe_.release();
}
void ProfilingClient::OnServiceManagerConnected(
content::ServiceManagerConnection* connection) {
std::unique_ptr<service_manager::BinderRegistry> registry(
new service_manager::BinderRegistry);
registry->AddInterface(base::Bind(
&profiling::ProfilingClient::BindToInterface, base::Unretained(this)));
connection->AddConnectionFilter(
base::MakeUnique<content::SimpleConnectionFilter>(std::move(registry)));
}
void ProfilingClient::BindToInterface(mojom::ProfilingClientRequest request) {
binding_.Bind(std::move(request));
}
void ProfilingClient::StartProfiling(mojo::ScopedHandle memlog_sender_pipe) {
base::PlatformFile platform_file;
CHECK_EQ(MOJO_RESULT_OK, mojo::UnwrapPlatformFile(
std::move(memlog_sender_pipe), &platform_file));
base::ScopedPlatformFile scoped_platform_file(platform_file);
memlog_sender_pipe_.reset(
new MemlogSenderPipe(std::move(scoped_platform_file)));
StreamHeader header;
header.signature = kStreamSignature;
memlog_sender_pipe_->Send(&header, sizeof(header));
InitAllocatorShim(memlog_sender_pipe_.get());
}
void ProfilingClient::FlushMemlogPipe(uint32_t barrier_id) {
AllocatorShimFlushPipe(barrier_id);
}
} // namespace profiling
| [
"jacob-chen@iotwrt.com"
] | jacob-chen@iotwrt.com |
01c5aa92003497e989be99a71a67939c9fe04d3f | 7bb34b9837b6304ceac6ab45ce482b570526ed3c | /external/webkit/Source/WebCore/html/HTMLImageElement.cpp | 836388f5a988765b6255f88fa9b1dc4ddc1b935f | [
"Apache-2.0",
"LGPL-2.0-only",
"BSD-2-Clause",
"LGPL-2.1-only",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LicenseRef-scancode-other-copyleft"
] | permissive | ghsecuritylab/android_platform_sony_nicki | 7533bca5c13d32a8d2a42696344cc10249bd2fd8 | 526381be7808e5202d7865aa10303cb5d249388a | refs/heads/master | 2021-02-28T20:27:31.390188 | 2013-10-15T07:57:51 | 2013-10-15T07:57:51 | 245,730,217 | 0 | 0 | Apache-2.0 | 2020-03-08T00:59:27 | 2020-03-08T00:59:26 | null | UTF-8 | C++ | false | false | 13,046 | cpp | /*
* Copyright (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "HTMLImageElement.h"
#include "Attribute.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "EventNames.h"
#include "FrameView.h"
#include "HTMLDocument.h"
#include "HTMLFormElement.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "RenderImage.h"
#include "ScriptEventListener.h"
using namespace std;
namespace WebCore {
using namespace HTMLNames;
HTMLImageElement::HTMLImageElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
: HTMLElement(tagName, document)
, m_imageLoader(this)
, ismap(false)
, m_form(form)
, m_compositeOperator(CompositeSourceOver)
{
ASSERT(hasTagName(imgTag));
if (form)
form->registerImgElement(this);
setIeForbidsInsertHTML();
}
PassRefPtr<HTMLImageElement> HTMLImageElement::create(Document* document)
{
return adoptRef(new HTMLImageElement(imgTag, document));
}
PassRefPtr<HTMLImageElement> HTMLImageElement::create(const QualifiedName& tagName, Document* document, HTMLFormElement* form)
{
return adoptRef(new HTMLImageElement(tagName, document, form));
}
HTMLImageElement::~HTMLImageElement()
{
if (m_form)
m_form->removeImgElement(this);
}
PassRefPtr<HTMLImageElement> HTMLImageElement::createForJSConstructor(Document* document, const int* optionalWidth, const int* optionalHeight)
{
RefPtr<HTMLImageElement> image = adoptRef(new HTMLImageElement(imgTag, document));
if (optionalWidth)
image->setWidth(*optionalWidth);
if (optionalHeight > 0)
image->setHeight(*optionalHeight);
return image.release();
}
bool HTMLImageElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
{
if (attrName == widthAttr ||
attrName == heightAttr ||
attrName == vspaceAttr ||
attrName == hspaceAttr ||
attrName == valignAttr) {
result = eUniversal;
return false;
}
if (attrName == borderAttr || attrName == alignAttr) {
result = eReplaced; // Shared with embed and iframe elements.
return false;
}
return HTMLElement::mapToEntry(attrName, result);
}
void HTMLImageElement::parseMappedAttribute(Attribute* attr)
{
const QualifiedName& attrName = attr->name();
if (attrName == altAttr) {
if (renderer() && renderer()->isImage())
toRenderImage(renderer())->updateAltText();
} else if (attrName == srcAttr)
m_imageLoader.updateFromElementIgnoringPreviousError();
else if (attrName == widthAttr)
addCSSLength(attr, CSSPropertyWidth, attr->value());
else if (attrName == heightAttr)
addCSSLength(attr, CSSPropertyHeight, attr->value());
else if (attrName == borderAttr) {
// border="noborder" -> border="0"
addCSSLength(attr, CSSPropertyBorderWidth, attr->value().toInt() ? attr->value() : "0");
addCSSProperty(attr, CSSPropertyBorderTopStyle, CSSValueSolid);
addCSSProperty(attr, CSSPropertyBorderRightStyle, CSSValueSolid);
addCSSProperty(attr, CSSPropertyBorderBottomStyle, CSSValueSolid);
addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
} else if (attrName == vspaceAttr) {
addCSSLength(attr, CSSPropertyMarginTop, attr->value());
addCSSLength(attr, CSSPropertyMarginBottom, attr->value());
} else if (attrName == hspaceAttr) {
addCSSLength(attr, CSSPropertyMarginLeft, attr->value());
addCSSLength(attr, CSSPropertyMarginRight, attr->value());
} else if (attrName == alignAttr)
addHTMLAlignment(attr);
else if (attrName == valignAttr)
addCSSProperty(attr, CSSPropertyVerticalAlign, attr->value());
else if (attrName == usemapAttr) {
if (attr->value().string()[0] == '#')
usemap = attr->value();
else
usemap = document()->completeURL(stripLeadingAndTrailingHTMLSpaces(attr->value())).string();
setIsLink(!attr->isNull());
} else if (attrName == ismapAttr)
ismap = true;
else if (attrName == onabortAttr)
setAttributeEventListener(eventNames().abortEvent, createAttributeEventListener(this, attr));
else if (attrName == onloadAttr)
setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
else if (attrName == onbeforeloadAttr)
setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
else if (attrName == compositeAttr) {
if (!parseCompositeOperator(attr->value(), m_compositeOperator))
m_compositeOperator = CompositeSourceOver;
} else if (attrName == nameAttr) {
const AtomicString& newName = attr->value();
if (inDocument() && document()->isHTMLDocument()) {
HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
document->removeNamedItem(m_name);
document->addNamedItem(newName);
}
m_name = newName;
} else if (isIdAttributeName(attr->name())) {
const AtomicString& newId = attr->value();
if (inDocument() && document()->isHTMLDocument()) {
HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
document->removeExtraNamedItem(m_id);
document->addExtraNamedItem(newId);
}
m_id = newId;
// also call superclass
HTMLElement::parseMappedAttribute(attr);
} else
HTMLElement::parseMappedAttribute(attr);
}
String HTMLImageElement::altText() const
{
// lets figure out the alt text.. magic stuff
// http://www.w3.org/TR/1998/REC-html40-19980424/appendix/notes.html#altgen
// also heavily discussed by Hixie on bugzilla
String alt = getAttribute(altAttr);
// fall back to title attribute
if (alt.isNull())
alt = getAttribute(titleAttr);
return alt;
}
RenderObject* HTMLImageElement::createRenderer(RenderArena* arena, RenderStyle* style)
{
if (style->contentData())
return RenderObject::createObject(this, style);
RenderImage* image = new (arena) RenderImage(this);
image->setImageResource(RenderImageResource::create());
return image;
}
void HTMLImageElement::attach()
{
HTMLElement::attach();
if (renderer() && renderer()->isImage() && m_imageLoader.haveFiredBeforeLoadEvent()) {
RenderImage* renderImage = toRenderImage(renderer());
RenderImageResource* renderImageResource = renderImage->imageResource();
if (renderImageResource->hasImage())
return;
renderImageResource->setCachedImage(m_imageLoader.image());
// If we have no image at all because we have no src attribute, set
// image height and width for the alt text instead.
if (!m_imageLoader.image() && !renderImageResource->cachedImage())
renderImage->setImageSizeForAltText();
}
}
void HTMLImageElement::insertedIntoDocument()
{
if (document()->isHTMLDocument()) {
HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
document->addNamedItem(m_name);
document->addExtraNamedItem(m_id);
}
// If we have been inserted from a renderer-less document,
// our loader may have not fetched the image, so do it now.
if (!m_imageLoader.image())
m_imageLoader.updateFromElement();
HTMLElement::insertedIntoDocument();
}
void HTMLImageElement::removedFromDocument()
{
if (document()->isHTMLDocument()) {
HTMLDocument* document = static_cast<HTMLDocument*>(this->document());
document->removeNamedItem(m_name);
document->removeExtraNamedItem(m_id);
}
HTMLElement::removedFromDocument();
}
void HTMLImageElement::insertedIntoTree(bool deep)
{
if (!m_form) {
// m_form can be non-null if it was set in constructor.
for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) {
if (ancestor->hasTagName(formTag)) {
m_form = static_cast<HTMLFormElement*>(ancestor);
m_form->registerImgElement(this);
break;
}
}
}
HTMLElement::insertedIntoTree(deep);
}
void HTMLImageElement::removedFromTree(bool deep)
{
if (m_form)
m_form->removeImgElement(this);
m_form = 0;
HTMLElement::removedFromTree(deep);
}
int HTMLImageElement::width(bool ignorePendingStylesheets) const
{
if (!renderer()) {
// check the attribute first for an explicit pixel value
bool ok;
int width = getAttribute(widthAttr).toInt(&ok);
if (ok)
return width;
// if the image is available, use its width
if (m_imageLoader.image())
return m_imageLoader.image()->imageSize(1.0f).width();
}
if (ignorePendingStylesheets)
document()->updateLayoutIgnorePendingStylesheets();
else
document()->updateLayout();
RenderBox* box = renderBox();
return box ? adjustForAbsoluteZoom(box->contentWidth(), box) : 0;
}
int HTMLImageElement::height(bool ignorePendingStylesheets) const
{
if (!renderer()) {
// check the attribute first for an explicit pixel value
bool ok;
int height = getAttribute(heightAttr).toInt(&ok);
if (ok)
return height;
// if the image is available, use its height
if (m_imageLoader.image())
return m_imageLoader.image()->imageSize(1.0f).height();
}
if (ignorePendingStylesheets)
document()->updateLayoutIgnorePendingStylesheets();
else
document()->updateLayout();
RenderBox* box = renderBox();
return box ? adjustForAbsoluteZoom(box->contentHeight(), box) : 0;
}
int HTMLImageElement::naturalWidth() const
{
if (!m_imageLoader.image())
return 0;
return m_imageLoader.image()->imageSize(1.0f).width();
}
int HTMLImageElement::naturalHeight() const
{
if (!m_imageLoader.image())
return 0;
return m_imageLoader.image()->imageSize(1.0f).height();
}
bool HTMLImageElement::isURLAttribute(Attribute* attr) const
{
return attr->name() == srcAttr
|| attr->name() == lowsrcAttr
|| attr->name() == longdescAttr
|| (attr->name() == usemapAttr && attr->value().string()[0] != '#');
}
const AtomicString& HTMLImageElement::alt() const
{
return getAttribute(altAttr);
}
bool HTMLImageElement::draggable() const
{
// Image elements are draggable by default.
return !equalIgnoringCase(getAttribute(draggableAttr), "false");
}
void HTMLImageElement::setHeight(int value)
{
setAttribute(heightAttr, String::number(value));
}
KURL HTMLImageElement::src() const
{
return document()->completeURL(getAttribute(srcAttr));
}
void HTMLImageElement::setSrc(const String& value)
{
setAttribute(srcAttr, value);
}
void HTMLImageElement::setWidth(int value)
{
setAttribute(widthAttr, String::number(value));
}
int HTMLImageElement::x() const
{
RenderObject* r = renderer();
if (!r)
return 0;
// FIXME: This doesn't work correctly with transforms.
FloatPoint absPos = r->localToAbsolute();
return absPos.x();
}
int HTMLImageElement::y() const
{
RenderObject* r = renderer();
if (!r)
return 0;
// FIXME: This doesn't work correctly with transforms.
FloatPoint absPos = r->localToAbsolute();
return absPos.y();
}
bool HTMLImageElement::complete() const
{
return m_imageLoader.imageComplete();
}
void HTMLImageElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
{
HTMLElement::addSubresourceAttributeURLs(urls);
addSubresourceURL(urls, src());
// FIXME: What about when the usemap attribute begins with "#"?
addSubresourceURL(urls, document()->completeURL(getAttribute(usemapAttr)));
}
void HTMLImageElement::willMoveToNewOwnerDocument()
{
m_imageLoader.elementWillMoveToNewOwnerDocument();
HTMLElement::willMoveToNewOwnerDocument();
}
}
| [
"gahlotpercy@gmail.com"
] | gahlotpercy@gmail.com |
4890ed6671e588fb3904874497e2b60f8ab637e7 | 04a8d1f59a7be8a7f4b155929e286621b01341d8 | /gclTimer.h | d228efc319cdd26b608c44b57a24ff5f83f1bd1e | [] | no_license | soheean/interraster | 611b8c19652845787b3728b8fe2ef15f97e2ef4e | a165d769936701221f04f3610f81e08063f6fd97 | refs/heads/master | 2021-01-17T17:24:37.271248 | 2016-06-24T07:47:16 | 2016-06-24T07:47:16 | 61,866,682 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 336 | h | #pragma once
typedef __int64 i64;
class gclTimer
{
public:
gclTimer(void);
~gclTimer(void);
private:
double _freq;
double _clocks;
double _start;
public:
void Start(void);//启动计时器
void Stop(void); //停止计时器
void Reset(void);//复位计时器
double GetElapsedTime(void);//计算流逝的时间
};
| [
"soheean@hotmail.com"
] | soheean@hotmail.com |
d65c94c8e06457fb5087de5c8694292feae3a1e3 | 0c3be775906632abcc91ab4e0b48678413997a9f | /src/extract_sequences.cpp | 9bf8a1afe81cb8db7b434e42e8d6b74d77a73e7d | [
"MIT"
] | permissive | induraj2020/clickstream-hmm | 45fc9d9999b418135e2f0be124474a9f8dbe00e3 | 2565183a7aa95984dba0a5759ea40ad81fc4a419 | refs/heads/master | 2023-03-16T06:54:23.335972 | 2018-06-02T20:30:20 | 2018-06-02T20:30:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,379 | cpp | /**
* @file extract_sequences.cpp
* Extracts each browsing session for each user given a Coursera
* clickstream dump.
*/
#include <iostream>
#include <regex>
#include <string>
#include "json.hpp"
#include "meta/hashing/probe_map.h"
#include "meta/io/filesystem.h"
#include "meta/io/packed.h"
#include "meta/logging/logger.h"
#include "meta/parallel/algorithm.h"
#include "meta/util/identifiers.h"
#include "meta/util/multiway_merge.h"
#include "meta/util/optional.h"
#include "meta/util/progress.h"
using namespace nlohmann;
using namespace meta;
MAKE_NUMERIC_IDENTIFIER_UDL(action_id, uint64_t, _aid)
namespace meta
{
namespace util
{
template <class Tag, class T>
void to_json(json& j, const identifier<Tag, T>& i)
{
j = static_cast<T>(i);
}
template <class Tag, class T>
void from_json(const json& j, identifier<Tag, T>& i)
{
i = j.get<T>();
}
} // namespace sequence
} // namespace meta
using action_sequence = std::vector<action_id>;
struct student_record
{
std::string username;
std::vector<action_sequence> sequences;
};
struct memory_student_record
{
uint64_t last_action_time = 0;
std::vector<action_sequence> sequences;
};
util::optional<action_id> get_action(const std::string& str)
{
static std::regex regexes[] = {
std::regex{R"(\/forum\/list$)", std::regex_constants::ECMAScript},
std::regex{R"(\/forum\/list\?forum_id=)",
std::regex_constants::ECMAScript},
std::regex{R"(\/forum\/thread\?thread_id=)",
std::regex_constants::ECMAScript},
std::regex{R"(\/forum\/search\?q=)", std::regex_constants::ECMAScript},
std::regex{R"(\/forum\/posted_thread)",
std::regex_constants::ECMAScript},
std::regex{R"(\/forum\/posted_reply)",
std::regex_constants::ECMAScript},
// either: downloading the video or viewing it in the streaming player
std::regex{R"(\/lecture(\/download|\?lecture_id=|\/view\?lecture_id=))",
std::regex_constants::ECMAScript},
std::regex{R"(\/quiz\/start\?quiz_id=)",
std::regex_constants::ECMAScript},
std::regex{R"(\/quiz\/submit)", std::regex_constants::ECMAScript},
std::regex{R"(\/wiki)", std::regex_constants::ECMAScript}};
action_id aid{0};
for (const auto& regex : regexes)
{
if (std::regex_search(str, regex))
return {aid};
++aid;
}
return util::nullopt;
}
using student_record_map
= hashing::probe_map<std::string, memory_student_record>;
void insert_new_action(student_record_map& store, const std::string& username,
action_id aid, uint64_t timestamp)
{
auto it = store.find(username);
if (it == store.end())
it = store.insert(username, memory_student_record{});
// if the last action was more than 10 hours ago, this is the start
// of a new sequence
if (timestamp > it->value().last_action_time + 10 * 60 * 60 * 1000)
{
it->value().sequences.emplace_back(1, aid);
}
// otherwise, this is just another action of the current sequence
else
{
it->value().sequences.back().push_back(aid);
}
it->value().last_action_time = timestamp;
}
int main()
{
logging::set_cerr_logging();
student_record_map store;
std::string line;
while (std::getline(std::cin, line))
{
auto obj = json::parse(line);
if (obj["key"].get<std::string>() != util::string_view{"pageview"})
continue;
auto username = obj["username"].get<std::string>();
auto timestamp = obj["timestamp"].get<uint64_t>();
// new dumps appear to set some cleaned url in "value"; use that if
// we can
if (auto action = get_action(obj["value"].get<std::string>()))
{
insert_new_action(store, username, *action, timestamp);
}
// otherwise use the value in page_url, which always exists
else if (auto action = get_action(obj["page_url"].get<std::string>()))
{
insert_new_action(store, username, *action, timestamp);
}
}
for (const auto& pr : store)
{
auto obj = json::object();
obj["username"] = pr.key();
obj["sequences"] = pr.value().sequences;
std::cout << obj << '\n';
}
return 0;
}
| [
"geigle1@illinois.edu"
] | geigle1@illinois.edu |
347565ff667583cda80a590f386a9f77d85133a3 | 98877e9ccb49848791945db2853c459c687e1bb7 | /MonitorSYS/MonitorSYSDlg.h | 7cc856a8431308f4d306b8f96b1d56cc6d4954a3 | [] | no_license | Spritutu/MonitorSYS | 6b962e454a0afd74075f186290158d40a66b3042 | ce26e517fa0fde8ce6e3405cddcc1bfb6c5805ba | refs/heads/master | 2021-01-16T18:15:56.764459 | 2015-05-25T22:48:04 | 2015-05-25T22:48:04 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,849 | h |
// MonitorSYSDlg.h : 头文件
//
#pragma once
#include "LoginDlg.h"
#include "BtnST.h"
#include "afxwin.h"
#include "AntimonyDlg.h"
#include "ConditionDlg.h"
#include "LoginDlg.h"
#include "OptimizeCtrDlg.h"
#include "GoldDlg.h"
#include "ProcessDiagram.h"
// CMonitorSYSDlg 对话框
class CMonitorSYSDlg : public CDialogEx
{
// 构造
public:
CMonitorSYSDlg(CWnd* pParent = NULL); // 标准构造函数
CLoginDlg loginDlg;
CProcessDiagram processDlg;
CGoldDlg goldDlg;
CAntimonyDlg antimonyDlg;
COptimizeCtrDlg optimizeCtrDlg;
CConditionDlg conditionDlg;
CBrush m_brush;
CFont m_font;
CFont m_font1;
CFont m_font2;
// 对话框数据
enum { IDD = IDD_MONITORSYS_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 实现
protected:
HICON m_hIcon;
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
CButtonST m_btmin;
CButtonST m_btcalcel;
CButtonST m_btprocess;
CButtonST m_btgold;
CButtonST m_btantimony;
CButtonST m_btcontrol;
CButtonST m_btcondition;
afx_msg LRESULT OnNcHitTest(CPoint point);
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
void setbtColor(CButtonST *btst, COLORREF crColor, COLORREF textColor = RGB(255, 255, 255));
afx_msg void OnBnClickedMinzoom();
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedBtgold();
afx_msg void OnBnClickedBtprocess();
afx_msg void OnBnClickedBtantimony();
afx_msg void OnBnClickedBtcontrol();
afx_msg void OnBnClickedBtcondition();
CButtonST m_usedtime;
CButtonST m_workcondition;
CButtonST m_time;
CButtonST m_label;
afx_msg void OnTimer(UINT_PTR nIDEvent);
CButtonST m_home;
CButtonST m_history;
CButtonST m_expertsys;
};
| [
"905524057@qq.com"
] | 905524057@qq.com |
8dde379fd73c9bb8410265ac6535e6b44f48fe65 | cf8ddfc720bf6451c4ef4fa01684327431db1919 | /SDK/ARKSurvivalEvolved_EngramEntry_HazardSuit_Chest_parameters.hpp | cbbb329ca4d9ba5f26cc4a0facc4296947631ade | [
"MIT"
] | permissive | git-Charlie/ARK-SDK | 75337684b11e7b9f668da1f15e8054052a3b600f | c38ca9925309516b2093ad8c3a70ed9489e1d573 | refs/heads/master | 2023-06-20T06:30:33.550123 | 2021-07-11T13:41:45 | 2021-07-11T13:41:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 770 | hpp | #pragma once
// ARKSurvivalEvolved (329.9) SDK
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
#include "ARKSurvivalEvolved_EngramEntry_HazardSuit_Chest_classes.hpp"
namespace sdk
{
//---------------------------------------------------------------------------
//Parameters
//---------------------------------------------------------------------------
// Function EngramEntry_HazardSuit_Chest.EngramEntry_HazardSuit_Chest_C.ExecuteUbergraph_EngramEntry_HazardSuit_Chest
struct UEngramEntry_HazardSuit_Chest_C_ExecuteUbergraph_EngramEntry_HazardSuit_Chest_Params
{
int EntryPoint; // (Parm, ZeroConstructor, IsPlainOldData)
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"sergey.2bite@gmail.com"
] | sergey.2bite@gmail.com |
6a0cbd4a6f7a9a05fd90ca76e6b6e7f853b2d12f | ea8ca702551a1dfd09039a56ccb04692508829f6 | /src/shadowcoind.cpp | 651c809ce2db4722ba8bcf90fdd028bce4820b4a | [
"MIT"
] | permissive | freecreators/freecreateors | 04c589ec24272feb372c37c5da6cfb28db60db66 | ef29609c99d4dddba761c964374cfa0e21939f23 | refs/heads/master | 2021-01-22T11:28:19.012441 | 2017-05-29T02:19:07 | 2017-05-29T02:19:07 | 92,698,667 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,537 | cpp | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "rpcserver.h"
#include "rpcclient.h"
#include "init.h"
#include <boost/algorithm/string/predicate.hpp>
#include "protocol.h"
void ThreadCli()
{
// - Simple persistent cli
// TODO:
// unbuffered terminal input on linux
// format help text
char buffer[4096];
size_t n;
fd_set rfds;
struct timeval tv;
printf("Shadow CLI ready:\n> ");
fflush(stdout);
for (;;)
{
boost::this_thread::interruption_point();
// - must be set every iteration
FD_ZERO(&rfds);
FD_SET(STDIN_FILENO, &rfds);
tv.tv_sec = 0;
tv.tv_usec = 200000;
if (select(1, &rfds, NULL, NULL, &tv) < 1) // read blocks thread from interrupt
continue;
if ((n = read(STDIN_FILENO, buffer, sizeof(buffer))) < 1)
continue;
buffer[n] = '\0';
for ( ; n > 0 && (buffer[n-1] == '\n' || buffer[n-1] == '\r'); --n)
buffer[n-1] = '\0';
if (strcmp(buffer, "stop") == 0
|| strcmp(buffer, "exit") == 0
|| strcmp(buffer, "quit") == 0
|| strcmp(buffer, "q") == 0)
{
puts("Exiting...");
break;
};
std::string strMethod;
std::vector<std::string> strParams;
char *p;
if ((p = strchr(buffer, ' ')))
{
strMethod = std::string(buffer, p);
char *pPS = p+1;
char *pPE = p+1;
while (*pPS
&& ((pPE = strchr(pPS, ' '))
|| (pPE = strchr(pPS, '\0'))))
{
strParams.push_back(std::string(pPS, pPE));
pPS = pPE+1;
};
} else
{
strMethod = std::string(buffer);
};
std::string strReply;
JSONRequest jreq;
try
{
json_spirit::Array params = RPCConvertValues(strMethod, strParams);
json_spirit::Value result = tableRPC.execute(strMethod, params);
strReply = json_spirit::write_string(result, true);
ReplaceStrInPlace(strReply, "\\n", "\n"); // format help msg
if (write(STDOUT_FILENO, strReply.data(), strReply.length()) != (uint32_t) strReply.length())
throw std::runtime_error("write failed.");
printf("\n> ");
fflush(stdout);
} catch (json_spirit::Object& objError)
{
std::string strReply = JSONRPCReply(json_spirit::Value::null, objError, 0);
printf("Error: %s\n> ", strReply.c_str());
fflush(stdout);
} catch (std::exception& e)
{
printf("Error: %s\n> ", e.what());
fflush(stdout);
};
fflush(stdout);
};
StartShutdown();
};
void WaitForShutdown(boost::thread_group* threadGroup)
{
bool fShutdown = ShutdownRequested();
if (!fDaemon && GetBoolArg("-cli", false))
{
threadGroup->create_thread(boost::bind(&TraceThread<void (*)()>, "cli", &ThreadCli));
};
// Tell the main threads to shutdown.
while (!fShutdown)
{
MilliSleep(200);
fShutdown = ShutdownRequested();
};
LogPrintf("ShadowCoin shutdown.\n\n");
if (threadGroup)
{
threadGroup->interrupt_all();
threadGroup->join_all();
};
}
//////////////////////////////////////////////////////////////////////////////
//
// Start
//
bool AppInit(int argc, char* argv[])
{
boost::thread_group threadGroup;
bool fRet = false;
try
{
//
// Parameters
//
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
ParseParameters(argc, argv);
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
fprintf(stderr, "Error: Specified directory does not exist\n");
Shutdown();
};
ReadConfigFile(mapArgs, mapMultiArgs);
if (mapArgs.count("-?") || mapArgs.count("--help"))
{
// First part of help message is specific to bitcoind / RPC client
std::string strUsage = _("ShadowCoin version") + " " + FormatFullVersion() + "\n\n" +
_("Usage:") + "\n" +
" shadowcoind [options] " + "\n" +
" shadowcoind [options] <command> [params] " + _("Send command to -server or shadowcoind") + "\n" +
" shadowcoind [options] help " + _("List commands") + "\n" +
" shadowcoind [options] help <command> " + _("Get help for a command") + "\n";
strUsage += "\n" + HelpMessage();
fprintf(stdout, "%s", strUsage.c_str());
return false;
};
// Command-line RPC
for (int i = 1; i < argc; i++)
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "shadowcoin:"))
fCommandLine = true;
if (fCommandLine)
{
if (!SelectParamsFromCommandLine())
{
fprintf(stderr, "Error: invalid combination of -regtest and -testnet.\n");
return false;
};
int ret = CommandLineRPC(argc, argv);
exit(ret);
};
#if !defined(WIN32)
fDaemon = GetBoolArg("-daemon", false);
if (fDaemon)
{
// Daemonize
pid_t pid = fork();
if (pid < 0)
{
fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno);
return false;
};
if (pid > 0) // Parent process, pid is child process id
{
CreatePidFile(GetPidFile(), pid);
return true;
};
// Child process falls through to rest of initialization
pid_t sid = setsid();
if (sid < 0)
fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
};
#endif
if (GetBoolArg("-cli", false))
printf("Starting...\n");
fRet = AppInit2(threadGroup);
} catch (std::exception& e)
{
PrintException(&e, "AppInit()");
} catch (...)
{
PrintException(NULL, "AppInit()");
};
if (!fRet)
{
threadGroup.interrupt_all();
// threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of
// the startup-failure cases to make sure they don't result in a hang due to some
// thread-blocking-waiting-for-another-thread-during-startup case
} else
{
WaitForShutdown(&threadGroup);
};
Shutdown();
return fRet;
}
extern void noui_connect();
int main(int argc, char* argv[])
{
bool fRet = false;
fHaveGUI = false;
// Connect shadowcoind signal handlers
noui_connect();
fRet = AppInit(argc, argv);
if (fRet && fDaemon)
return 0;
return (fRet ? 0 : 1);
};
| [
"lenovo@LAPTOP-D9O5PPS6"
] | lenovo@LAPTOP-D9O5PPS6 |
97c421933ed4fb2853e23d1781a45ca6d0529f17 | e8ce2a3ffb573832a8a836bbae490f762961703f | /MegascansPlugin/Source/MegascansPlugin/Private/Utilities/AssetsDatabase.cpp | 0657dcdd4f5a9c9f7c280a1c44676cc1e09a411a | [] | no_license | JuHwan0123/ThreeDPose_UnrealRND | d4c5ca5cc86e6d51ad51f5bb40ab174389b923c5 | 043415ed551eff8829eb18670b4b98d98a91f19c | refs/heads/main | 2023-08-28T13:26:24.314773 | 2021-10-13T08:28:58 | 2021-10-13T08:28:58 | 416,651,907 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,139 | cpp | // Copyright Epic Games, Inc. All Rights Reserved.
#include "AssetsDatabase.h"
#include "Misc/Paths.h"
//#include "SQLiteDatabase.h"
#include "SQLitePreparedStatement.h"
#include "SQLiteDatabaseConnection.h"
#include "SQLiteResultSet.h"
TSharedPtr<FAssetsDatabase> FAssetsDatabase::DBInst;
TSharedPtr<FAssetsDatabase> FAssetsDatabase::Get()
{
if (!DBInst.IsValid())
{
DBInst = MakeShareable(new FAssetsDatabase);
}
return DBInst;
}
FAssetsDatabase::FAssetsDatabase()
{
SQLiteDatabase = MakeShareable(new FSQLiteDatabaseConnection);
FString DatabasePath = FPaths::Combine(FPaths::ConvertRelativePathToFull(FPaths::ProjectContentDir()), TEXT("MSPresets"), TEXT("MSAssets.db"));
CreateAssetsDatabase(DatabasePath);
}
FAssetsDatabase::~FAssetsDatabase()
{
SQLiteDatabase->Close();
}
void FAssetsDatabase::CreateAssetsDatabase(const FString& DatabasePath)
{
SQLiteDatabase->Open(*DatabasePath, nullptr, nullptr);
FString CreateStatement = TEXT("CREATE TABLE IF NOT EXISTS MegascansAssets("
"ID TEXT PRIMARY KEY NOT NULL,"
"NAME TEXT NOT NULL,"
"PATH TEXT NOT NULL,"
"TYPE TEXT NOT NULL"
");");
SQLiteDatabase->Execute(*CreateStatement);
FString MatCreateStatement = TEXT("CREATE TABLE IF NOT EXISTS MSPresets("
"ID TEXT PRIMARY KEY NOT NULL,"
"VERSION FLOAT NOT NULL"
");");
SQLiteDatabase->Execute(*MatCreateStatement);
}
void FAssetsDatabase::AddRecord(const AssetRecord& Record)
{
FString InsertStatement = FString::Printf(TEXT("INSERT OR REPLACE INTO MegascansAssets VALUES('%s', '%s', '%s', '%s');"), *Record.ID, *Record.Name, *Record.Path, *Record.Type);
SQLiteDatabase->Execute(*InsertStatement);
}
void FAssetsDatabase::AddMaterialRecord(const FString& MaterialName, float MaterialVersion)
{
FString InsertStatement = FString::Printf(TEXT("INSERT OR REPLACE INTO MSPresets VALUES('%s', %f);"), *MaterialName, MaterialVersion);
SQLiteDatabase->Execute(*InsertStatement);
}
bool FAssetsDatabase::RecordExists(const FString& AssetID, AssetRecord& Record)
{
FString SelectStatement = FString::Printf(TEXT("SELECT * FROM MegascansAssets WHERE ID = '%s'"), *AssetID);
FSQLiteResultSet* QueryResult = NULL;
if (SQLiteDatabase->Execute(*SelectStatement, QueryResult))
{
for (FSQLiteResultSet::TIterator ResultIterator(QueryResult); ResultIterator; ++ResultIterator)
{
Record.ID = ResultIterator->GetString(TEXT("ID"));
Record.Name = ResultIterator->GetString(TEXT("NAME"));
Record.Path = ResultIterator->GetString(TEXT("PATH"));
Record.Type = ResultIterator->GetString(TEXT("TYPE"));
return true;
}
}
return false;
}
float FAssetsDatabase::GetMaterialVersion(const FString& MaterialName)
{
FString SelectStatement = FString::Printf(TEXT("SELECT * FROM MSPresets WHERE ID = '%s'"), *MaterialName);
FSQLiteResultSet* QueryResult = NULL;
if (SQLiteDatabase->Execute(*SelectStatement, QueryResult))
{
for (FSQLiteResultSet::TIterator ResultIterator(QueryResult); ResultIterator; ++ResultIterator)
{
return ResultIterator->GetFloat(TEXT("VERSION"));
}
}
return 0.0f;
}
| [
"83950058+JuHwan0123@users.noreply.github.com"
] | 83950058+JuHwan0123@users.noreply.github.com |
0640a12cd5a928fbf2850dcbba3ed4ac8775381d | 468067fbc1cba8379bbf1a11dee3ae5e527d122e | /FinalProduct/archive/PUimage/Motion.h | 0df233acd7f4316b6aa160f2825b9e048822e51d | [] | no_license | noticeable/MscProject | b675c87b04892af574082bfceea87027030e1cc3 | 0aca2d34c9736fc02f0f5a330a63d8653c84490e | refs/heads/master | 2020-04-16T22:47:57.775032 | 2016-10-23T07:46:16 | 2016-10-23T07:46:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,581 | h | /************************* Includes *******************************/
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <list>
#include "opencv/cv.h" // Computer Vision Lib Header
#include "opencv/highgui.h" // HighGUI Vision Lib Header
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/opencv.hpp"
/********************************************************************/
using namespace cv;
using namespace std;
Mat LaplacianPyr(Mat img);
bool buildLaplacianPyramid(const Mat &img, const int levels, vector<Mat> &pyramid);//motion
void temporalIIRFilter(const Mat &src, Mat &dst);
void amplify(const Mat &src, Mat &dst);
void reconImgFromLaplacianPyramid2(const vector<Mat> &pyramid, const int levels, Mat &dst);
void attenuate(Mat &src, Mat &dst);
void motion();
void color();
bool buildGaussianPyramid(const cv::Mat &img, const int levels, std::vector<cv::Mat> &pyramid);
void temporalIdealFilter(const cv::Mat &src, cv::Mat &dst);
void upsamplingFromGaussianPyramid(const cv::Mat &src, const int levels, cv::Mat &dst);
void amplify2(const Mat &src, Mat &dst);
void createIdealBandpassFilter(cv::Mat &filter, double fl, double fh, double rate);
bool buildGaussianPyramid(const cv::Mat &img,
const int levels,
std::vector<cv::Mat> &pyramid);
void concat(const std::vector<cv::Mat> &frames,
cv::Mat &dst);
void temporalIdealFilter(const cv::Mat &src,
cv::Mat &dst);
void deConcat(const cv::Mat &src,
const cv::Size &frameSize,
std::vector<cv::Mat> &frames);
| [
"shanshan.fu15@imperial.ac.uk"
] | shanshan.fu15@imperial.ac.uk |
856b8e43f7d19e3ed3d11f8452fbdd37f866ab57 | 588c53fbe0f2edce97477481374f1155ce5d99e1 | /07_2.cpp | 48021060934ba581ea06341f93b8371bd77e1bad | [] | no_license | Zcholm/Codility | 8ff4c5b20e697dbdab6e6fc969d9afad82aed6b5 | 2618640f4491159dab395fdbfa74ebacf20f872f | refs/heads/master | 2020-09-13T18:07:04.193802 | 2019-11-22T13:20:52 | 2019-11-22T13:20:52 | 222,863,802 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 519 | cpp | #include<vector>
int solution(vector<int> &A, vector<int> &B) {
int N = A.size();
vector<int> queue;
int alive = N;
for (int i = 0; i < N; i++) {
if (B[i] == 0) {
while (queue.size() > 0 && queue.back() < A[i]) {
queue.pop_back();
alive--;
}
if (queue.size() > 0) {
alive--;
}
} else {
// add to queue
queue.push_back(A[i]);
}
}
return alive;
}
| [
"simon.holm@afconsult.com"
] | simon.holm@afconsult.com |
e5828a328b499cde56d965edd419a15b913dcf91 | 38118fa82847f484ee3fb4eb71a59f530e385a47 | /examples/26-occlusion/occlusion.cpp | d0149838d36edc6a26128261a11b056c27253483 | [
"BSD-2-Clause",
"LicenseRef-scancode-free-unknown",
"MIT"
] | permissive | wayveai/bgfx | f0a089bf138d95015b06417f388a60ee7c9df2d0 | 4c61c4b825060ac1750a125f44ff0765da7f6f5c | refs/heads/master | 2023-08-30T13:58:16.839209 | 2023-08-22T15:08:39 | 2023-08-22T15:08:39 | 166,040,894 | 3 | 0 | BSD-2-Clause | 2019-05-28T13:09:43 | 2019-01-16T13:00:35 | C++ | UTF-8 | C++ | false | false | 7,945 | cpp | /*
* Copyright 2011-2022 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
#include "common.h"
#include "bgfx_utils.h"
#include "camera.h"
#include "imgui/imgui.h"
namespace
{
#define CUBES_DIM 10
struct PosColorVertex
{
float m_x;
float m_y;
float m_z;
uint32_t m_abgr;
static void init()
{
ms_layout
.begin()
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
.end();
};
static bgfx::VertexLayout ms_layout;
};
bgfx::VertexLayout PosColorVertex::ms_layout;
static PosColorVertex s_cubeVertices[8] =
{
{-1.0f, 1.0f, 1.0f, 0xff000000 },
{ 1.0f, 1.0f, 1.0f, 0xff0000ff },
{-1.0f, -1.0f, 1.0f, 0xff00ff00 },
{ 1.0f, -1.0f, 1.0f, 0xff00ffff },
{-1.0f, 1.0f, -1.0f, 0xffff0000 },
{ 1.0f, 1.0f, -1.0f, 0xffff00ff },
{-1.0f, -1.0f, -1.0f, 0xffffff00 },
{ 1.0f, -1.0f, -1.0f, 0xffffffff },
};
static const uint16_t s_cubeIndices[36] =
{
0, 1, 2, // 0
1, 3, 2,
4, 6, 5, // 2
5, 6, 7,
0, 2, 4, // 4
4, 2, 6,
1, 5, 3, // 6
5, 7, 3,
0, 4, 1, // 8
4, 5, 1,
2, 3, 6, // 10
6, 3, 7,
};
class ExampleOcclusion : public entry::AppI
{
public:
ExampleOcclusion(const char* _name, const char* _description, const char* _url)
: entry::AppI(_name, _description, _url)
{
}
void init(int32_t _argc, const char* const* _argv, uint32_t _width, uint32_t _height) override
{
Args args(_argc, _argv);
m_width = _width;
m_height = _height;
m_debug = BGFX_DEBUG_TEXT;
m_reset = BGFX_RESET_VSYNC;
bgfx::Init init;
init.type = args.m_type;
init.vendorId = args.m_pciId;
init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle);
init.platformData.ndt = entry::getNativeDisplayHandle();
init.resolution.width = m_width;
init.resolution.height = m_height;
init.resolution.reset = m_reset;
bgfx::init(init);
// Enable debug text.
bgfx::setDebug(m_debug);
// Set view 0 clear state.
bgfx::setViewClear(0
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0x303030ff
, 1.0f
, 0
);
bgfx::setViewClear(2
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0x202020ff
, 1.0f
, 0
);
// Create vertex stream declaration.
PosColorVertex::init();
// Create static vertex buffer.
m_vbh = bgfx::createVertexBuffer(
// Static data can be passed with bgfx::makeRef
bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) )
, PosColorVertex::ms_layout
);
// Create static index buffer.
m_ibh = bgfx::createIndexBuffer(
// Static data can be passed with bgfx::makeRef
bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) )
);
// Create program from shaders.
m_program = loadProgram("vs_cubes", "fs_cubes");
const bgfx::Caps* caps = bgfx::getCaps();
m_occlusionQuerySupported = !!(caps->supported & BGFX_CAPS_OCCLUSION_QUERY);
if (m_occlusionQuerySupported)
{
for (uint32_t ii = 0; ii < BX_COUNTOF(m_occlusionQueries); ++ii)
{
m_occlusionQueries[ii] = bgfx::createOcclusionQuery();
}
}
cameraCreate();
cameraSetPosition({ 15.5f, 0.0f, -15.5f });
cameraSetHorizontalAngle(bx::toRad(-45.0f) );
m_timeOffset = bx::getHPCounter();
imguiCreate();
}
virtual int shutdown() override
{
imguiDestroy();
// Cleanup.
cameraDestroy();
if (m_occlusionQuerySupported)
{
for (uint32_t ii = 0; ii < BX_COUNTOF(m_occlusionQueries); ++ii)
{
bgfx::destroy(m_occlusionQueries[ii]);
}
}
bgfx::destroy(m_ibh);
bgfx::destroy(m_vbh);
bgfx::destroy(m_program);
// Shutdown bgfx.
bgfx::shutdown();
return 0;
}
bool update() override
{
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
imguiBeginFrame(m_mouseState.m_mx
, m_mouseState.m_my
, (m_mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (m_mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
| (m_mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
, m_mouseState.m_mz
, uint16_t(m_width)
, uint16_t(m_height)
);
showExampleDialog(this
, !m_occlusionQuerySupported
? "Occlusion query is not supported."
: NULL
);
imguiEndFrame();
if (m_occlusionQuerySupported)
{
int64_t now = bx::getHPCounter();
static int64_t last = now;
const int64_t frameTime = now - last;
last = now;
const double freq = double(bx::getHPFrequency() );
const float time = (float)( (now-m_timeOffset)/double(bx::getHPFrequency() ) );
const float deltaTime = float(frameTime/freq);
// Update camera.
cameraUpdate(deltaTime, m_state.m_mouse, ImGui::MouseOverArea() );
float view[16];
cameraGetViewMtx(view);
// Set view and projection matrix for view 0.
{
float proj[16];
bx::mtxProj(proj, 90.0f, float(m_width)/float(m_height), 0.1f, 10000.0f, bgfx::getCaps()->homogeneousDepth);
bgfx::setViewTransform(0, view, proj);
bgfx::setViewRect(0, 0, 0, uint16_t(m_width), uint16_t(m_height) );
bgfx::setViewTransform(1, view, proj);
bgfx::setViewRect(1, 0, 0, uint16_t(m_width), uint16_t(m_height) );
const bx::Vec3 at = { 0.0f, 0.0f, 0.0f };
const bx::Vec3 eye = { 17.5f, 10.0f, -17.5f };
bx::mtxLookAt(view, eye, at);
bgfx::setViewTransform(2, view, proj);
bgfx::setViewRect(2, 10, uint16_t(m_height - m_height/4 - 10), uint16_t(m_width/4), uint16_t(m_height/4) );
}
bgfx::touch(0);
bgfx::touch(2);
uint8_t img[CUBES_DIM*CUBES_DIM*2];
for (uint32_t yy = 0; yy < CUBES_DIM; ++yy)
{
for (uint32_t xx = 0; xx < CUBES_DIM; ++xx)
{
float mtx[16];
bx::mtxRotateXY(mtx, time + xx*0.21f, time + yy*0.37f);
mtx[12] = -(CUBES_DIM-1) * 3.0f / 2.0f + float(xx)*3.0f;
mtx[13] = 0.0f;
mtx[14] = -(CUBES_DIM-1) * 3.0f / 2.0f + float(yy)*3.0f;
bgfx::OcclusionQueryHandle occlusionQuery = m_occlusionQueries[yy*CUBES_DIM+xx];
bgfx::setTransform(mtx);
bgfx::setVertexBuffer(0, m_vbh);
bgfx::setIndexBuffer(m_ibh);
bgfx::setCondition(occlusionQuery, true);
bgfx::setState(BGFX_STATE_DEFAULT);
bgfx::submit(0, m_program);
bgfx::setTransform(mtx);
bgfx::setVertexBuffer(0, m_vbh);
bgfx::setIndexBuffer(m_ibh);
bgfx::setState(0
| BGFX_STATE_DEPTH_TEST_LEQUAL
| BGFX_STATE_CULL_CW
);
bgfx::submit(1, m_program, occlusionQuery);
bgfx::setTransform(mtx);
bgfx::setVertexBuffer(0, m_vbh);
bgfx::setIndexBuffer(m_ibh);
bgfx::setCondition(occlusionQuery, true);
bgfx::setState(BGFX_STATE_DEFAULT);
bgfx::submit(2, m_program);
img[(yy*CUBES_DIM+xx)*2+0] = " \xfex"[bgfx::getResult(occlusionQuery)];
img[(yy*CUBES_DIM+xx)*2+1] = 0xf;
}
}
for (uint16_t xx = 0; xx < CUBES_DIM; ++xx)
{
bgfx::dbgTextImage(5 + xx*2, 20, 1, CUBES_DIM, img + xx*2, CUBES_DIM*2);
}
int32_t numPixels = 0;
bgfx::getResult(m_occlusionQueries[0], &numPixels);
bgfx::dbgTextPrintf(5, 20 + CUBES_DIM + 1, 0xf, "Passing pixels count: %d", numPixels);
}
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
return true;
}
return false;
}
entry::MouseState m_mouseState;
uint32_t m_width;
uint32_t m_height;
uint32_t m_debug;
uint32_t m_reset;
bgfx::VertexBufferHandle m_vbh;
bgfx::IndexBufferHandle m_ibh;
bgfx::ProgramHandle m_program;
int64_t m_timeOffset;
bool m_occlusionQuerySupported;
bgfx::OcclusionQueryHandle m_occlusionQueries[CUBES_DIM*CUBES_DIM];
entry::WindowState m_state;
};
} // namespace
ENTRY_IMPLEMENT_MAIN(
ExampleOcclusion
, "26-occlusion"
, "Using occlusion query for conditional rendering."
, "https://bkaradzic.github.io/bgfx/examples.html#occlusion"
);
| [
"branimirkaradzic@gmail.com"
] | branimirkaradzic@gmail.com |
eeccbb766fda1f600830ec95e1910553d6a44b54 | 6a55fc908497a0d4ada6eae74d64a057b609c261 | /inference-engine/thirdparty/clDNN/src/gpu/device_info.cpp | 1402e05d5513c1ceae6bb9599db76362448277c7 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | anton-potapov/openvino | 9f24be70026a27ea55dafa6e7e2b6b18c6c18e88 | 84119afe9a8c965e0a0cd920fff53aee67b05108 | refs/heads/master | 2023-04-27T16:34:50.724901 | 2020-06-10T11:13:08 | 2020-06-10T11:13:08 | 271,256,329 | 1 | 0 | Apache-2.0 | 2021-04-23T08:22:48 | 2020-06-10T11:16:29 | null | UTF-8 | C++ | false | false | 2,946 | cpp | // Copyright (c) 2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "device_info.h"
#include "include/to_string_utils.h"
#include <unordered_map>
#include <string>
#include <cassert>
#include <time.h>
#include <limits>
#include <chrono>
#include "ocl_builder.h"
#include <fstream>
#include <iostream>
#include <utility>
namespace cldnn {
namespace gpu {
device_info_internal::device_info_internal(const cl::Device& device) {
dev_name = device.getInfo<CL_DEVICE_NAME>();
driver_version = device.getInfo<CL_DRIVER_VERSION>();
compute_units_count = device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>();
cores_count = static_cast<uint32_t>(device.getInfo<CL_DEVICE_MAX_COMPUTE_UNITS>());
core_frequency = static_cast<uint32_t>(device.getInfo<CL_DEVICE_MAX_CLOCK_FREQUENCY>());
max_work_group_size = static_cast<uint64_t>(device.getInfo<CL_DEVICE_MAX_WORK_GROUP_SIZE>());
if (max_work_group_size > 256)
max_work_group_size = 256;
max_local_mem_size = static_cast<uint64_t>(device.getInfo<CL_DEVICE_LOCAL_MEM_SIZE>());
max_global_mem_size = static_cast<uint64_t>(device.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>());
max_alloc_mem_size = static_cast<uint64_t>(device.getInfo<CL_DEVICE_MAX_MEM_ALLOC_SIZE>());
supports_image = static_cast<uint8_t>(device.getInfo<CL_DEVICE_IMAGE_SUPPORT>());
max_image2d_width = static_cast<uint64_t>(device.getInfo<CL_DEVICE_IMAGE2D_MAX_WIDTH>());
max_image2d_height = static_cast<uint64_t>(device.getInfo<CL_DEVICE_IMAGE2D_MAX_HEIGHT>());
// Check for supported features.
auto extensions = device.getInfo<CL_DEVICE_EXTENSIONS>();
extensions.push_back(' '); // Add trailing space to ease searching (search with keyword with trailing space).
supports_fp16 = extensions.find("cl_khr_fp16 ") != std::string::npos;
supports_fp16_denorms = supports_fp16 && (device.getInfo<CL_DEVICE_HALF_FP_CONFIG>() & CL_FP_DENORM) != 0;
supports_subgroups_short = extensions.find("cl_intel_subgroups_short") != std::string::npos;
supports_imad = dev_name.find("Gen12") != std::string::npos;
supports_immad = false;
dev_type = static_cast<uint32_t>(device.getInfo<CL_DEVICE_TYPE>());
vendor_id = static_cast<uint32_t>(device.getInfo<CL_DEVICE_VENDOR_ID>());
supports_usm = extensions.find("cl_intel_unified_shared_memory") != std::string::npos;
}
} // namespace gpu
} // namespace cldnn
| [
"alexey.suhov@intel.com"
] | alexey.suhov@intel.com |
1f2ecc14e836d1e6cb1898d18859ad92f756e188 | 4352b5c9e6719d762e6a80e7a7799630d819bca3 | /tutorials/oldd/box/4.3e-05/p | 1da96f856a5203ed615452d5bb9ce27fb06d8a53 | [] | no_license | dashqua/epicProject | d6214b57c545110d08ad053e68bc095f1d4dc725 | 54afca50a61c20c541ef43e3d96408ef72f0bcbc | refs/heads/master | 2022-02-28T17:20:20.291864 | 2019-10-28T13:33:16 | 2019-10-28T13:33:16 | 184,294,390 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 21,957 | /*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 6
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "4.3e-05";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField nonuniform List<scalar>
2370
(
1.18816
2.64298
3.6377
-0.0204223
0.765348
0.771182
0.962726
1.03366
0.759172
0.727217
-0.655159
0.624531
-1.66787
0.822124
-1.17948
-0.891976
-3.00846
-1.80415
0.497188
0.600904
0.682057
-0.856649
1.56148
-2.01913
-0.716554
-0.353369
1.23364
0.33271
-4.75234
-1.27226
-2.45705
1.79455
1.15685
0.0689388
0.655928
0.820711
0.133571
0.27582
-0.423985
0.0919768
0.364615
-0.451464
-0.140437
-0.476894
0.963835
0.134216
0.99327
0.150851
-0.419394
1.9913
0.344049
0.652429
1.67882
-0.44866
-0.100963
1.22514
0.687254
0.721418
0.304447
-0.27993
-0.339693
0.950399
0.280991
0.693182
1.46389
0.868746
1.07786
0.0744149
1.13233
0.078511
1.14909
0.942008
1.32306
1.66883
1.06217
0.360779
0.511397
0.448188
0.289058
1.60983
1.59343
0.860894
1.14788
2.15914
0.227648
0.619597
0.22129
1.25723
0.586353
0.60905
0.723989
1.32622
0.828006
1.2614
0.604011
-0.170393
0.612926
0.799587
1.01516
0.537577
1.78078
0.663517
0.696171
0.957344
1.69309
0.948741
-0.512332
0.928748
1.06236
0.961907
0.385398
0.324724
0.861924
0.474756
1.27882
0.263902
0.424576
0.729802
0.259074
1.08433
0.567553
0.380593
0.302833
0.924884
0.450844
-0.937302
0.33274
0.317138
0.478283
0.293845
0.358704
1.47484
0.474483
0.492894
1.30811
1.85883
0.314123
0.737475
1.44143
0.550712
-0.00450904
0.398786
-0.805751
0.427905
0.649985
0.23602
0.1277
0.513005
0.423371
0.365773
0.420782
0.734988
0.730016
0.602054
0.976053
0.907518
-7.44383
1.80331
1.2287
-5.50438
0.775148
-2.24149
-0.417796
0.168512
0.492888
0.341873
-0.154735
-0.0863435
-0.100518
0.175624
-0.218248
-0.173554
-0.173919
-0.142324
-0.262789
0.236985
1.71763
-1.24107
-1.56131
1.00081
0.875394
-0.818276
0.7676
-0.999346
0.533239
-1.64172
-2.15447
0.674827
0.107426
0.264394
-0.987131
-1.06119
0.297245
-1.25667
-0.765118
0.532899
0.76696
-0.866886
-1.21994
2.40174
0.276665
1.18788
-1.74687
-1.58563
0.758046
-3.36477
-2.16057
-2.26646
-1.35589
0.118
0.961016
3.06258
0.0610938
-1.58152
-1.45682
2.5791
2.23308
3.00947
-0.864466
4.79253
2.04137
3.84354
4.56419
2.09917
10.8206
3.91006
3.73214
3.43226
2.77246
3.75569
7.96612
10.6671
4.49722
10.4498
6.09666
3.66572
8.63432
8.23891
7.13476
5.7586
8.10328
3.63272
6.14725
7.83249
4.55557
6.10652
20.5538
1.61818
5.42256
2.17127
4.87798
5.30566
2.72097
8.37806
3.34655
3.01232
5.86741
5.97432
3.95409
7.60041
4.44198
4.22644
3.43304
10.3403
3.01521
5.74701
4.77395
6.47704
5.15659
4.32776
4.75371
4.19186
3.20288
4.97528
6.41504
3.80173
10.2158
8.00586
6.59828
12.6243
12.3955
13.5767
7.74302
2.76284
4.31998
8.14857
19.4928
8.33789
8.39765
19.9134
14.6859
7.52264
11.6902
20.8551
7.02646
7.33858
5.99922
6.15004
22.1234
12.6395
9.08334
15.2282
13.0493
9.03223
8.9686
4.18456
15.2116
4.56352
12.8697
2.34462
6.58308
6.51474
9.04486
10.9154
11.2791
9.3498
0.298178
12.1137
3.9584
4.17886
4.8872
5.20733
2.07698
4.10323
4.65735
5.81638
12.8197
4.95567
3.2941
2.09658
8.68478
6.71255
9.13818
4.51515
4.4222
10.8916
8.20011
8.03999
0.454738
3.65613
2.25384
7.91132
4.65016
6.34925
6.47879
4.4329
8.20549
3.44289
8.36881
5.31206
-0.949909
8.83933
10.6147
6.24014
0.0185486
0.549643
0.397882
4.07666
0.298706
6.34243
3.44531
5.09544
0.148546
9.41869
3.19925
10.6533
4.32579
2.6539
0.414863
6.27509
8.12974
0.0109691
8.44127
3.78932
5.98863
2.61746
2.74965
0.16047
8.56483
7.76363
8.45228
0.206455
5.33747
4.20747
6.12456
10.2478
5.65221
6.05417
3.13165
0.211276
-0.0889764
2.97676
4.21488
4.39478
4.93344
3.90945
8.05666
3.20223
0.272632
5.54273
-0.463116
0.229588
14.0503
-0.260915
5.26062
11.8654
7.96655
5.06185
5.85879
10.2168
6.14726
5.0447
3.5484
4.32862
10.4142
4.21968
0.166191
0.0170338
0.329946
3.81601
0.0849049
8.14956
7.6935
1.69916
0.218213
6.61806
0.323775
2.81358
4.59443
0.131807
7.31994
2.72196
2.82977
5.81446
0.259663
4.55641
4.01804
-0.602503
6.95492
3.8099
0.0104452
5.9518
6.88948
-0.327857
6.71477
3.81656
7.89881
3.45536
0.57654
2.12287
0.355766
4.24322
-0.192301
3.64654
9.73616
5.05868
8.64858
4.4455
7.11446
-0.382203
0.268205
-0.0306432
14.7431
2.80106
0.102927
5.04563
2.66012
3.38661
5.16091
2.26952
3.4636
-1.73081
3.16854
7.85387
4.54665
1.29761
0.683174
0.476488
8.3319
1.90999
0.0161316
4.23352
4.95044
-0.501086
4.20278
6.9174
3.30505
0.677146
4.54251
5.06577
5.95623
0.52621
0.861233
3.69051
5.11945
7.56067
2.52833
6.53913
0.316912
0.191935
3.75218
5.53249
5.12625
9.0263
8.27495
8.58245
4.33972
5.51352
5.76043
5.5213
4.47076
4.0657
4.23674
0.413963
2.65816
7.74667
7.73792
2.4571
-0.0695768
-0.187973
0.129373
-0.807182
0.535002
4.60979
0.379934
3.97841
6.20138
5.73069
4.01357
5.74316
1.77132
5.45173
6.00114
5.22006
0.302013
2.13002
5.56337
2.43817
1.91272
0.820094
3.47553
3.4132
0.34857
0.513244
6.8706
7.77571
0.0330553
-0.0256156
0.0419344
2.96793
0.428956
5.08552
4.78878
4.50346
0.704797
5.78983
-0.225484
0.250653
2.95916
4.95641
0.0977418
0.213857
0.703496
0.177283
3.06756
5.57123
5.08686
4.92549
7.02626
2.95602
0.382616
1.97406
4.18154
2.00428
5.99962
0.0192604
7.28696
5.65502
2.55898
3.05529
0.258868
6.43152
3.30031
2.63649
4.2213
4.03795
3.26911
3.60351
0.395794
0.257893
0.401403
4.646
4.28777
5.69186
5.24168
2.06435
2.28051
3.38695
3.53091
0.330428
0.306461
3.90454
2.92989
-0.983122
2.06774
0.199123
3.71687
0.262938
2.75839
3.08139
4.33839
4.17546
0.609934
1.79182
2.3705
0.241188
7.41652
6.93073
8.31826
4.51018
3.8371
2.62713
9.69943
-0.0691234
4.42702
0.550303
4.04431
4.0101
4.22717
3.89873
0.479056
3.49464
0.140591
-0.448359
3.66934
0.449686
10.4846
15.9083
5.95411
0.115734
0.179996
1.83705
10.5588
9.14874
5.71895
5.72715
6.51368
4.28805
8.56516
6.9522
4.39042
6.04691
3.59492
4.7697
7.8567
2.37527
3.52601
3.36808
4.67113
4.15321
7.10944
3.65625
10.8927
-0.81119
15.3203
6.24407
6.53491
4.60035
3.13098
0.204454
0.55922
3.34438
5.33208
0.121135
6.41943
3.12167
7.36241
1.88425
2.35221
3.29171
5.55053
4.24204
5.779
2.62367
0.242149
3.63637
5.46963
4.39433
3.49845
0.208428
3.46474
2.56848
4.34666
4.97572
5.502
6.50984
-0.0276188
0.468066
8.76794
8.89357
4.04019
5.87254
3.80613
8.90461
-0.116879
0.00883244
5.55168
5.43282
0.678842
6.13139
0.531736
3.69255
1.04015
3.58445
4.18628
5.46633
5.71846
2.95515
9.07365
2.65076
6.36007
5.97574
-0.0904284
4.18693
2.86618
0.256297
5.52314
4.66834
6.58666
0.377112
8.57922
4.91438
0.0720666
0.493774
3.91695
6.40975
-0.571487
7.08248
4.69622
6.57344
4.93463
1.88108
2.74717
2.26809
1.72151
3.26532
2.17978
3.3161
4.31654
6.9284
6.92425
4.0218
-0.0207617
4.87772
0.518209
6.86747
3.39766
3.11553
5.88132
2.861
2.9361
5.91319
2.6846
5.72599
3.6119
3.20189
0.277464
4.35694
5.14374
4.87541
11.7814
5.13162
0.62471
5.52299
0.494124
0.157493
6.6089
5.55923
5.59956
5.85569
0.276214
4.35136
3.1354
3.15214
0.537849
5.85626
0.269099
4.76531
4.85515
6.33905
2.30508
0.897919
3.43024
5.52912
2.30295
5.06717
4.58922
2.79519
0.906124
1.07759
8.39372
3.05548
5.82631
2.77275
3.50201
3.2144
5.60815
4.89586
4.1463
4.95972
3.95795
4.55933
4.63072
3.66015
0.746082
6.41572
9.9917
3.63119
4.18529
3.46932
5.16081
3.64955
-0.19082
3.07533
5.56424
6.34555
4.49786
2.87898
4.54463
3.95096
2.60255
0.329684
3.46382
1.46753
2.4335
5.72931
6.29525
3.65534
0.0734629
0.17777
6.79736
5.04336
4.30976
1.15879
2.61012
3.7335
5.66338
5.69378
0.652886
5.34974
4.10412
5.99216
-0.640474
6.76892
2.567
5.66402
3.07505
4.83062
0.458844
4.22268
0.0617529
7.5807
0.831718
3.44297
8.69667
4.17653
3.95344
8.72837
6.84346
7.06183
0.218446
0.963691
-0.123246
7.63306
2.07377
0.360092
3.80806
4.24112
6.29343
9.33067
4.23682
9.0054
4.93031
0.236915
5.00641
2.47312
7.4192
5.70464
7.92778
2.21846
3.26543
8.88352
4.40186
4.1996
5.44611
7.80055
3.70756
5.37059
5.34209
4.09931
5.38445
-0.0615585
3.63472
5.89117
4.132
7.91307
6.49264
6.10167
4.23873
3.12142
1.79557
8.81969
4.36142
11.5047
13.1176
8.14998
5.15911
4.89978
1.18305
2.52355
3.57936
6.0642
7.77268
4.16453
3.01745
0.119475
7.83824
8.70934
3.66693
0.206705
7.6444
2.51548
1.42385
-0.0245323
5.69155
3.32869
6.43105
0.279506
2.59096
3.28159
5.00547
5.37756
0.518978
5.13998
6.79729
5.2445
6.1678
7.42017
5.36422
10.0766
5.26524
3.58981
3.00549
2.74769
5.80269
2.44322
6.80702
7.22122
3.36753
4.02957
3.57212
4.59115
5.46443
9.35091
2.53145
2.39303
4.76883
6.34352
4.44606
4.21626
5.27888
3.52463
2.56603
0.429662
3.64415
2.53296
0.455731
0.223711
0.306527
7.08053
0.262169
6.46909
6.80869
5.62406
4.71046
7.80644
5.79625
6.19498
4.41386
4.76452
4.04139
2.66537
-0.0704025
8.49283
3.32919
0.256815
0.823478
10.8746
5.46605
-0.784143
0.630679
3.07525
2.11365
3.91959
2.59291
6.46351
6.45046
0.0485169
9.87665
5.18328
4.24121
6.33802
2.29792
4.61067
0.293874
4.8253
3.923
4.1661
6.83512
2.44458
5.82236
6.28884
3.35798
1.79282
5.30124
2.28936
2.48202
0.738866
2.4793
10.3245
9.42815
3.92039
6.11331
3.41099
2.0482
5.53817
8.396
3.47619
0.442821
-0.734154
7.22234
5.42403
3.51766
3.84541
4.75706
3.55163
3.3369
8.53855
12.7835
11.9938
0.488595
-1.06765
5.25817
0.306586
4.66127
-0.0625705
10.9659
0.816079
0.848408
0.812987
9.78551
5.8773
2.74148
9.13243
4.66801
3.55386
2.56727
2.3523
2.7503
2.69067
6.35837
3.90503
11.6764
15.0183
2.54635
2.57517
3.45461
7.10587
2.25432
2.27685
0.457857
6.45958
5.39051
6.64543
5.80856
4.54172
0.517212
0.377541
2.3068
2.31951
1.87381
0.752167
5.3719
5.01275
6.35837
6.36847
0.808938
14.754
2.39831
4.91092
2.13983
6.10396
16.3793
4.24494
5.02209
4.50985
8.80348
6.58783
4.36513
2.90777
4.42675
10.0751
0.569802
9.67664
3.65995
4.38795
2.28494
6.35732
6.81556
4.72746
3.47732
10.2838
12.7039
3.19831
6.93259
3.54874
2.49093
9.69668
5.64859
1.31423
7.37732
7.15015
3.54899
1.60917
1.85821
2.97766
5.15422
4.61104
0.785169
2.90306
1.38451
3.50544
3.14986
3.87704
3.44556
3.81709
5.0401
5.93911
6.76191
5.07141
4.48437
3.04004
6.17412
0.347973
4.24464
3.21977
9.47379
9.19208
3.62587
6.75972
5.60524
0.576489
0.0314504
7.75794
2.43301
5.52823
3.55444
4.55493
5.20391
7.89686
10.0788
4.74522
5.72295
4.55789
6.00119
6.35729
2.39391
3.51257
6.23304
4.93667
8.98569
2.28577
8.05226
5.09538
0.369937
0.225861
4.66417
5.22724
6.10267
12.7517
1.66306
4.16192
8.65756
7.8506
3.85177
5.34741
0.0912424
3.64184
-0.521309
4.16969
3.11697
3.46656
5.49013
7.6701
2.51089
3.992
2.4063
0.888563
5.03895
6.24013
3.72364
3.79865
6.51446
3.70429
-0.472398
3.13182
4.67022
0.591582
4.60534
10.7646
7.81643
5.11903
8.61206
5.25886
5.14342
6.3063
8.08476
3.07036
3.26297
4.36718
4.79934
6.81803
2.94806
4.87786
9.57956
-0.0257527
9.64565
3.24963
4.99502
3.74996
5.36714
5.7034
2.5551
6.91791
12.5944
3.11992
0.0571028
7.63135
3.87809
6.44852
5.81902
5.60811
3.74577
3.24077
5.7455
0.448786
3.49422
5.21758
4.22753
3.38767
4.72981
11.0143
3.41499
8.05758
1.96635
3.98936
1.7004
3.60653
9.85759
8.39343
5.17554
7.47842
2.77233
4.03894
2.46521
4.63186
2.09156
0.745967
6.84714
4.4371
2.24679
9.81795
0.726079
7.86163
3.61094
4.89984
18.5652
6.65117
8.20969
3.73111
4.3532
0.842564
0.849169
9.25083
6.02935
3.63366
3.52984
1.97591
4.52753
3.72023
8.20068
20.4045
20.834
18.4331
17.7061
8.08125
7.81823
10.678
16.5972
3.58847
3.01208
4.21938
4.31424
4.52231
3.65334
4.81454
10.8031
23.6266
3.48981
2.30888
4.21622
10.8469
4.84386
20.053
16.4686
4.9539
12.6256
3.25537
0.12556
3.01005
1.92775
4.10873
0.179499
3.37751
24.0853
3.83942
8.48387
4.15139
7.67975
7.37267
6.86523
9.87021
6.27411
8.35136
9.97539
2.005
10.1859
5.85787
8.51637
5.10644
4.31238
7.60383
9.30425
3.86631
7.76436
0.197171
3.49959
2.79202
2.43684
1.62019
6.74624
13.2017
3.27594
5.92389
7.36858
5.62455
6.78486
10.615
10.511
8.99208
6.00296
5.79263
0.924703
6.71256
1.9042
5.67965
7.97783
1.87536
2.87518
6.56127
8.76395
17.6487
0.379406
6.19077
7.98239
4.57283
18.0959
3.52346
4.37862
5.80377
4.23495
2.03957
2.31303
2.16273
3.23935
1.60296
12.4145
8.59341
3.0327
4.65314
1.79159
4.01596
8.86813
8.39187
3.13788
7.31466
4.52097
2.15811
5.03982
2.19954
1.7475
0.437149
6.34195
7.08728
0.292905
8.36105
0.294059
4.27722
5.03633
2.97504
4.4146
3.28675
4.10706
6.1111
4.8334
5.26145
2.74407
7.55156
5.76565
3.34729
11.2759
4.08526
3.72069
1.66396
8.0676
4.04617
5.68
8.40259
7.71397
3.65004
3.44996
9.25649
13.1447
1.9515
2.76817
3.81657
3.97861
5.23272
10.3662
4.77066
10.1835
4.19077
7.85303
8.8401
8.70223
19.3908
16.9843
17.0133
-0.023272
0.420945
-4.24633
-3.08392
-1.40553
-0.692181
0.746242
-0.412683
0.273132
0.816151
-2.19475
-1.53137
-0.492639
-0.973411
-1.69488
0.977018
-0.305454
-1.06468
0.0286508
0.440376
-0.295561
0.0690316
0.49496
-0.19403
1.25943
-0.922431
-1.56806
-0.0850962
0.404412
0.322776
-0.545888
-1.07027
0.651724
-1.04755
0.636954
-1.71783
-0.19769
4.34503
1.96895
1.53791
3.17709
2.59474
-4.57754
2.25132
3.12974
3.85338
2.16029
6.25465
4.00933
2.66479
2.25997
4.6068
3.06118
1.98058
10.0098
2.72512
4.53491
6.22044
2.22041
2.81159
4.95927
5.16156
7.28957
4.82354
3.68526
5.37159
5.14375
5.527
2.08802
4.19137
3.94939
6.06144
5.57813
2.99416
3.68491
3.89293
2.75565
2.44473
5.55215
5.38597
3.11802
4.47568
3.31431
3.08153
4.59033
4.08946
3.67686
6.38282
2.41163
6.4935
1.6676
2.62552
5.33691
3.80913
11.6385
2.56412
3.24849
4.73107
2.38679
7.09395
3.29844
3.1227
3.12454
4.38937
4.22829
3.32741
4.94563
4.06292
6.89898
8.15627
10.7826
6.75407
4.85093
5.73248
4.97672
8.07398
7.33705
7.98965
1.93598
1.96542
2.11438
5.16596
3.60015
1.51673
3.36972
3.52931
3.34441
2.39018
2.1754
4.34322
4.69377
3.28369
1.79547
6.05264
2.95494
5.37964
3.70872
11.7436
11.1737
13.0937
2.96188
4.13623
4.25704
3.74401
3.58764
2.93235
3.14657
1.60873
3.09946
3.97977
3.41432
4.13305
2.63959
2.23216
4.77741
6.07283
2.65707
5.14663
1.88323
4.99493
3.56494
2.29095
3.75683
4.15066
5.57603
7.07287
2.54762
3.8972
2.56555
5.04007
3.5327
5.39465
2.59499
3.52035
4.87228
4.02643
4.99355
3.61799
6.83157
8.84077
4.65224
4.3945
4.42126
8.11969
8.88744
3.89699
2.46407
5.98728
6.59117
4.95804
6.21454
3.73594
6.29901
6.59208
3.1423
2.54972
5.37585
3.29427
4.03536
3.13134
4.07247
6.50771
5.26855
5.89323
3.46009
8.42459
6.49626
4.10875
1.88966
11.2105
3.12351
3.60453
2.95412
5.99804
5.20915
5.82297
6.89427
7.63931
4.71051
5.98867
6.74408
2.57363
7.5337
4.7747
3.43326
3.32171
3.5445
1.72886
-1.00161
3.43674
2.10889
3.94296
5.25315
3.34341
3.20116
7.98885
4.54438
8.46864
15.046
4.15798
13.8985
7.25306
4.60179
8.59439
6.13965
3.15306
4.15604
2.57222
4.16179
6.11024
4.00844
6.21816
6.81017
7.46544
4.41636
4.60929
2.82746
2.44676
9.85718
6.85822
4.44328
4.98714
6.96932
2.41851
6.36042
4.85734
2.25784
4.26983
11.3043
3.9405
3.81785
5.13771
5.36674
3.67411
2.57216
7.60376
2.66415
2.17147
1.50402
2.92499
5.08166
4.30024
3.34553
2.30561
20.1426
1.37235
6.76508
3.304
17.54
4.08949
2.57331
5.31904
3.97798
2.06755
3.40151
3.18135
3.77343
3.16579
7.32604
5.08199
2.72896
3.9727
5.05154
1.58502
2.58356
4.43372
5.30089
2.69306
4.57824
1.65924
2.32345
2.9837
3.54678
6.93939
5.63792
7.48272
2.93108
2.54457
1.89895
2.79736
3.88683
6.44782
4.81079
5.52639
1.91496
4.91654
5.30557
2.25243
6.71215
2.7921
3.79104
3.85198
7.22404
6.98023
3.70622
2.44236
4.28416
3.25155
3.29464
2.8678
6.89758
2.99155
4.21611
3.58747
6.21635
2.85954
6.62665
2.17635
3.78065
3.78965
2.11079
2.272
6.36075
5.78477
1.75372
3.48304
4.35303
3.63661
5.45159
2.87398
2.34895
2.79437
3.10818
4.43419
1.52032
4.39349
5.60546
3.49627
2.27432
2.10819
5.12435
5.21104
8.85576
4.22109
4.30309
3.52993
8.8573
3.9113
4.35021
3.0635
3.72211
4.81337
4.73938
6.39486
1.85728
2.59417
5.1542
3.46965
5.65204
2.50334
3.14582
2.67029
2.88193
3.22564
2.14242
3.96705
1.82476
1.78091
3.16935
5.42254
3.76326
5.39579
3.59455
4.5871
3.95134
2.39085
1.41189
5.94737
6.97235
4.77586
6.64916
3.67287
6.46562
3.97925
0.288482
6.53089
1.02907
3.56875
4.30282
6.16373
4.32255
3.54195
4.91742
2.32974
3.04558
4.01107
1.90237
8.33416
2.97761
7.55649
3.34346
2.70236
2.95891
0.389026
18.8929
21.2453
6.13426
22.6093
6.44952
9.26252
8.2533
2.40676
6.58984
5.47669
1.73969
5.72915
3.11606
4.39444
3.89735
1.09754
3.15648
2.75387
2.72085
0.794896
3.88262
3.61466
1.23531
3.42717
3.6432
4.49769
4.76146
1.29741
5.416
5.28232
1.7255
5.04801
6.33553
7.80122
7.88221
2.74557
8.44759
8.69482
2.84499
8.03291
9.42755
9.89436
10.2022
1.93547
6.84342
4.76985
1.67851
5.6416
5.61653
6.51582
7.55547
2.05101
11.6803
13.373
3.49023
11.3484
1.55318
5.29644
9.11173
9.13204
16.8894
3.52503
6.37342
3.15453
4.4102
5.04736
8.35617
6.06576
9.91646
4.00722
5.2471
0.208079
3.22038
4.30548
5.89652
-0.0360863
3.41216
5.18996
8.14442
0.171601
4.87071
2.27891
3.10141
-0.131291
1.84103
0.278526
5.09883
6.05567
7.80423
0.36605
3.42155
4.01795
5.1702
-0.229935
-1.34531
1.50165
3.32025
-0.682055
1.13392
-0.108121
12.9241
13.1825
21.2527
5.12229
6.16685
0.600094
4.21339
-0.344123
2.50008
2.65384
4.30776
-0.527315
2.1106
4.40946
6.03633
2.95814
6.11175
3.622
3.69989
0.652581
2.87266
-1.06807
3.23006
3.78557
3.38301
0.833339
3.40589
0.903609
0.301522
2.0248
0.313189
2.34735
2.87436
2.69108
2.95032
1.76967
4.5676
1.7592
3.83399
4.71538
7.34141
1.63627
7.08058
1.66895
5.93989
7.56851
1.35286
4.11259
3.57243
2.85674
-0.492469
1.7379
0.378384
3.27102
4.42132
4.41543
6.1491
1.60639
6.31413
1.60464
6.77484
6.96704
2.85799
1.15126
4.60653
0.464898
4.01683
2.55071
2.34698
2.34057
2.57798
-0.187989
1.85253
-3.72157
5.06933
6.31177
4.51734
1.77385
1.56743
8.4574
1.54844
9.89432
7.29794
5.68539
4.49448
3.89157
0.58006
3.29553
0.560881
2.8216
3.25569
2.87308
2.39477
0.411634
2.02503
-0.458321
1.61214
0.0347336
1.76815
-0.0823641
2.89141
2.43041
6.87071
6.13828
5.68805
1.11511
3.66523
-1.28722
3.40182
0.615831
3.31565
0.564258
4.58325
4.63282
5.66062
6.27482
4.36385
0.885797
4.72624
1.08891
6.87868
9.17863
6.27446
1.06426
6.533
1.50019
4.21918
1.65055
4.64277
6.18158
3.44072
2.51883
0.265737
2.91301
0.333833
2.48293
1.4398
5.2838
1.04646
4.0048
4.37763
3.36068
2.23691
0.65039
2.16208
0.236992
2.20933
1.48649
3.40902
0.995418
3.61078
0.799542
2.62398
4.26577
6.31489
5.82327
1.49024
6.10923
1.47513
5.36277
3.17223
3.98429
2.8528
0.456106
2.99587
0.611343
3.3228
1.20952
3.97974
4.94224
3.50139
0.668585
2.98167
0.654938
4.01919
3.5233
4.63317
4.40011
0.41978
2.99721
0.522744
3.01184
3.3172
0.599654
3.03642
0.473829
2.46911
2.89786
1.04848
4.05371
0.918827
5.22866
5.68513
4.23745
4.3267
1.18023
4.76672
1.17182
4.04732
5.92207
3.41427
3.69041
1.04387
3.79398
-0.549664
2.59214
1.9605
0.291787
2.25113
0.200675
1.88602
2.77114
3.30386
0.807983
3.96123
0.70056
3.01068
3.54382
7.3275
2.29205
4.85117
6.87357
5.24774
1.40098
6.33299
1.5873
5.2174
6.48108
2.30902
3.05239
0.262629
2.12601
-0.7496
1.4258
4.12635
0.969141
5.7812
1.19697
6.18846
6.37147
7.93298
7.83023
1.51644
6.0409
1.85034
6.55585
3.07908
0.755504
2.54058
0.528782
3.61093
3.91559
3.81035
4.72866
3.67883
1.36877
1.96187
6.02744
1.58457
6.13788
8.31023
5.19501
6.07984
6.9859
3.90105
0.267355
4.28462
0.940581
4.88107
0.854074
3.96774
5.71136
6.12039
5.59462
6.89439
1.43805
4.18771
-1.50251
3.11308
3.5698
0.838818
2.97452
-0.292198
1.88723
2.48189
0.36364
2.26539
0.30277
3.10228
3.23841
4.71406
1.21748
4.81012
1.12062
3.50416
5.33402
4.41752
0.91501
4.38608
0.835296
3.26529
4.2435
2.37982
2.66612
0.493938
2.33595
-0.604942
1.69656
0.295307
3.18698
0.398314
2.70129
3.31851
3.66424
5.7894
6.50405
6.13335
1.27121
4.30832
-1.3658
1.51397
0.247059
1.61569
0.305835
2.38266
1.88897
1.49189
6.83008
1.90901
8.52099
9.28752
7.2458
7.31005
2.11147
7.02115
1.52578
5.18485
6.39652
3.49589
3.9563
0.494209
2.95642
-0.80538
1.62733
4.61316
4.42173
3.09207
0.527512
3.63555
0.691621
7.97933
6.01263
5.37551
1.23288
5.64334
1.27664
4.63092
4.20576
0.747883
3.55316
0.777931
3.03131
5.06196
5.49741
3.91817
0.554689
5.2627
0.759196
6.30271
6.35323
1.58845
5.86083
1.7716
8.72037
9.787
8.37975
1.77827
6.78763
)
;
boundaryField
{
emptyPatches_empt
{
type empty;
}
top_cyc
{
type freestreamPressure;
freestreamValue uniform 3;
supersonic false;
value nonuniform List<scalar>
40
(
4.90653
4.51688
6.36879
3.5444
3.07502
2.00876
4.70375
1.79105
2.06928
2.93021
4.77998
3.2414
1.98409
4.09356
3.13225
3.82925
3.95858
3.45717
3.77788
3.68826
3.15969
3.89418
5.80401
1.95818
3.30806
3.25375
4.87256
2.70507
3.49622
3.63218
3.04448
3.15896
3.39976
2.84753
3.87732
3.3233
3.05807
3.67403
3.02857
3.04231
)
;
}
bottom_cyc
{
type freestreamPressure;
freestreamValue uniform 3;
supersonic false;
value nonuniform List<scalar>
40
(
8.14741
10.0624
10.3625
11.8515
6.38848
7.85639
1.05531
3.84167
1.19827
0.831232
5.40222
0.841967
0.805178
7.48897
11.6477
8.43027
5.35315
4.85454
8.92739
5.08755
0.758042
6.02875
6.65557
7.99291
0.629609
7.55556
6.76051
7.15932
12.4628
12.2733
5.1604
5.44757
11.3152
11.4568
5.6787
5.9108
14.2533
14.9761
6.27254
5.72816
)
;
}
inlet_cyc
{
type cyclicAMI;
value nonuniform List<scalar>
30
(
14.2598
11.3428
6.5138
7.78263
5.41595
10.5499
3.58492
2.29402
2.80729
3.81051
4.7471
8.21407
6.49917
2.49185
4.59833
5.48484
5.7897
7.3178
5.52324
6.79291
12.5061
2.48393
7.17126
4.85783
14.6574
15.0017
7.20582
5.16467
5.89565
5.42732
)
;
}
outlet_cyc
{
type cyclicAMI;
value nonuniform List<scalar>
30
(
6.56204
7.73438
5.89565
6.48317
8.23008
3.59065
4.66869
5.35381
5.8589
6.53557
7.84152
2.32436
4.2266
4.7471
7.3178
5.42732
4.88621
3.71079
14.2598
5.48484
11.3428
11.0312
6.79291
4.58324
15.5525
14.1066
3.30454
12.0339
3.81051
2.49185
)
;
}
}
// ************************************************************************* //
| [
"thomasdigiusto@me.com"
] | thomasdigiusto@me.com | |
b95cf815bae821a5418ddde09c837f67b67aedcc | ecbe5ac6da0ab1da00c7f615353b739ef9a6ff03 | /492A.cpp | 4f63d4ec84704be93e05944c55bac13ffb05255e | [] | no_license | ngthvan1612/Codeforces | 2d1b10f155ba2f0efc6e0fdda7d78bcbd6aad496 | b86c3d3d11df92f9744f75f495ad458ace9418ae | refs/heads/master | 2022-04-01T20:34:48.115083 | 2020-02-01T06:14:13 | 2020-02-01T06:14:13 | 237,571,708 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 209 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, t = 0, s = 0, i, res;
cin >> n;
for (i = 1;;++i) {
t += i;
s += t;
if (s <= n) res = i;
else break;
}
cout << res;
return 0;
}
| [
"ngthvan1612@gmail.com"
] | ngthvan1612@gmail.com |
a8d0962ee7dcaf281eb3578bcac05d3707983283 | 641fa8341d8c436ad24945bcbf8e7d7d1dd7dbb2 | /third_party/WebKit/Source/core/input/ScrollManager.h | db2bd298c3068c70d193d22800141527229eb0fb | [
"BSD-2-Clause",
"LGPL-2.0-only",
"LGPL-2.1-only",
"LGPL-2.0-or-later",
"GPL-1.0-or-later",
"MIT",
"Apache-2.0",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"GPL-2.0-only",
"LicenseRef-scancode-other-copyleft"
] | permissive | massnetwork/mass-browser | 7de0dfc541cbac00ffa7308541394bac1e945b76 | 67526da9358734698c067b7775be491423884339 | refs/heads/master | 2022-12-07T09:01:31.027715 | 2017-01-19T14:29:18 | 2017-01-19T14:29:18 | 73,799,690 | 4 | 4 | BSD-3-Clause | 2022-11-26T11:53:23 | 2016-11-15T09:49:29 | null | UTF-8 | C++ | false | false | 5,361 | h | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ScrollManager_h
#define ScrollManager_h
#include "core/CoreExport.h"
#include "core/page/EventWithHitTestResults.h"
#include "platform/PlatformEvent.h"
#include "platform/geometry/LayoutSize.h"
#include "platform/heap/Handle.h"
#include "platform/heap/Visitor.h"
#include "platform/scroll/ScrollTypes.h"
#include "public/platform/WebInputEventResult.h"
#include "wtf/Allocator.h"
#include <deque>
namespace blink {
class AutoscrollController;
class FrameHost;
class LayoutBox;
class LayoutObject;
class LocalFrame;
class PaintLayer;
class PaintLayerScrollableArea;
class PlatformGestureEvent;
class Scrollbar;
class ScrollState;
// This class takes care of scrolling and resizing and the related states. The
// user action that causes scrolling or resizing is determined in other *Manager
// classes and they call into this class for doing the work.
class CORE_EXPORT ScrollManager
: public GarbageCollectedFinalized<ScrollManager> {
WTF_MAKE_NONCOPYABLE(ScrollManager);
public:
explicit ScrollManager(LocalFrame*);
DECLARE_TRACE();
void clear();
bool middleClickAutoscrollInProgress() const;
AutoscrollController* autoscrollController() const;
void stopAutoscroll();
// Performs a chaining logical scroll, within a *single* frame, starting
// from either a provided starting node or a default based on the focused or
// most recently clicked node, falling back to the frame.
// Returns true if the scroll was consumed.
// direction - The logical direction to scroll in. This will be converted to
// a physical direction for each LayoutBox we try to scroll
// based on that box's writing mode.
// granularity - The units that the scroll delta parameter is in.
// startNode - Optional. If provided, start chaining from the given node.
// If not, use the current focus or last clicked node.
bool logicalScroll(ScrollDirection,
ScrollGranularity,
Node* startNode,
Node* mousePressNode);
// Performs a logical scroll that chains, crossing frames, starting from
// the given node or a reasonable default (focus/last clicked).
bool bubblingScroll(ScrollDirection,
ScrollGranularity,
Node* startingNode,
Node* mousePressNode);
void setFrameWasScrolledByUser();
// TODO(crbug.com/616491): Consider moving all gesture related functions to
// another class.
// Handle the provided scroll gesture event, propagating down to child frames
// as necessary.
WebInputEventResult handleGestureScrollEvent(const PlatformGestureEvent&);
WebInputEventResult handleGestureScrollEnd(const PlatformGestureEvent&);
bool isScrollbarHandlingGestures() const;
// Returns true if the gesture event should be handled in ScrollManager.
bool canHandleGestureEvent(const GestureEventWithHitTestResults&);
// These functions are related to |m_resizeScrollableArea|.
bool inResizeMode() const;
void resize(const PlatformEvent&);
// Clears |m_resizeScrollableArea|. if |shouldNotBeNull| is true this
// function DCHECKs to make sure that variable is indeed not null.
void clearResizeScrollableArea(bool shouldNotBeNull);
void setResizeScrollableArea(PaintLayer*, IntPoint);
private:
WebInputEventResult handleGestureScrollUpdate(const PlatformGestureEvent&);
WebInputEventResult handleGestureScrollBegin(const PlatformGestureEvent&);
WebInputEventResult passScrollGestureEventToWidget(
const PlatformGestureEvent&,
LayoutObject*);
void clearGestureScrollState();
void customizedScroll(const Node& startNode, ScrollState&);
FrameHost* frameHost() const;
bool isEffectiveRootScroller(const Node&) const;
bool handleScrollGestureOnResizer(Node*, const PlatformGestureEvent&);
void recomputeScrollChain(const Node& startNode,
std::deque<int>& scrollChain);
// NOTE: If adding a new field to this class please ensure that it is
// cleared in |ScrollManager::clear()|.
const Member<LocalFrame> m_frame;
// Only used with the ScrollCustomization runtime enabled feature.
std::deque<int> m_currentScrollChain;
Member<Node> m_scrollGestureHandlingNode;
bool m_lastGestureScrollOverWidget;
// The most recent element to scroll natively during this scroll
// sequence. Null if no native element has scrolled this scroll
// sequence, or if the most recent element to scroll used scroll
// customization.
Member<Node> m_previousGestureScrolledNode;
// True iff some of the delta has been consumed for the current
// scroll sequence in this frame, or any child frames. Only used
// with ScrollCustomization. If some delta has been consumed, a
// scroll which shouldn't propagate can't cause any element to
// scroll other than the |m_previousGestureScrolledNode|.
bool m_deltaConsumedForScrollSequence;
Member<Scrollbar> m_scrollbarHandlingScrollGesture;
Member<PaintLayerScrollableArea> m_resizeScrollableArea;
LayoutSize
m_offsetFromResizeCorner; // In the coords of m_resizeScrollableArea.
};
} // namespace blink
#endif // ScrollManager_h
| [
"xElvis89x@gmail.com"
] | xElvis89x@gmail.com |
c421b62fd6ea0d001c05e9fb29e9208d7aba95d4 | b6ffa82d277f8e2635556fa4302d7596203237f9 | /jni/boost/libs/wave/test/testwave/testfiles/t_6_053.cpp | f78b030c3d0d6e6890765b8bfa09b1dd2cf7913e | [
"BSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | LeifAndersen/Android-Supertux | 2e66ae3c6a0ffba2f82b35c27130175151bbb1e6 | e188c9d365420bd21eee45da82d6f74215e27516 | refs/heads/master | 2020-04-11T09:57:11.000668 | 2010-09-20T03:34:55 | 2010-09-20T03:34:55 | 867,072 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,288 | cpp | /*=============================================================================
Boost.Wave: A Standard compliant C++ preprocessor library
http://www.boost.org/
Copyright (c) 2001-2005 Hartmut Kaiser. Distributed under the Boost
Software License, Version 1.0. (See accompanying file
LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
The tests included in this file were initially taken from the mcpp V2.5
preprocessor validation suite and were modified to fit into the Boost.Wave
unit test requirements.
The original files of the mcpp preprocessor are distributed under the
license reproduced at the end of this file.
=============================================================================*/
// Tests error reporting: #undef errors.
// 29.4: Excessive token sequence.
//E t_6_053.cpp(20): error: ill formed preprocessor directive: #undef
#undef MACRO_0 Junk
/*-
* Copyright (c) 1998, 2002-2005 Kiyoshi Matsui <kmatsui@t3.rim.or.jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
| [
"onaips@gmail.com"
] | onaips@gmail.com |
3eea429fa6d4974c3e9abfd83f704b7740b08746 | 5c3f6bdd0aa5446a78372c967d5a642c429b8eda | /src/rpc/net.cpp | abab252d89a846850955b89552ca96a746a12064 | [
"MIT"
] | permissive | GlobalBoost/GlobalBoost-Y | defeb2f930222d8b78447a9440d03cce9d8d602c | b4c8f1bb88ebbfa5016376fee9a00ae98902133f | refs/heads/master | 2023-08-11T12:04:12.578240 | 2023-07-11T03:56:18 | 2023-07-11T03:56:18 | 23,804,954 | 20 | 22 | MIT | 2023-07-11T03:56:19 | 2014-09-08T19:26:43 | C++ | UTF-8 | C++ | false | false | 29,985 | cpp | // Copyright (c) 2009-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <rpc/server.h>
#include <chainparams.h>
#include <clientversion.h>
#include <core_io.h>
#include <validation.h>
#include <net.h>
#include <net_processing.h>
#include <netbase.h>
#include <policy/policy.h>
#include <rpc/protocol.h>
#include <sync.h>
#include <timedata.h>
#include <ui_interface.h>
#include <util.h>
#include <utilstrencodings.h>
#include <version.h>
#include <warnings.h>
#include <univalue.h>
static UniValue getconnectioncount(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"getconnectioncount\n"
"\nReturns the number of connections to other nodes.\n"
"\nResult:\n"
"n (numeric) The connection count\n"
"\nExamples:\n"
+ HelpExampleCli("getconnectioncount", "")
+ HelpExampleRpc("getconnectioncount", "")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
return (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL);
}
static UniValue ping(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"ping\n"
"\nRequests that a ping be sent to all other nodes, to measure ping time.\n"
"Results provided in getpeerinfo, pingtime and pingwait fields are decimal seconds.\n"
"Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.\n"
"\nExamples:\n"
+ HelpExampleCli("ping", "")
+ HelpExampleRpc("ping", "")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
// Request that each node send a ping during next message processing pass
g_connman->ForEachNode([](CNode* pnode) {
pnode->fPingQueued = true;
});
return NullUniValue;
}
static UniValue getpeerinfo(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"getpeerinfo\n"
"\nReturns data about each connected network node as a json array of objects.\n"
"\nResult:\n"
"[\n"
" {\n"
" \"id\": n, (numeric) Peer index\n"
" \"addr\":\"host:port\", (string) The IP address and port of the peer\n"
" \"addrbind\":\"ip:port\", (string) Bind address of the connection to the peer\n"
" \"addrlocal\":\"ip:port\", (string) Local address as reported by the peer\n"
" \"services\":\"xxxxxxxxxxxxxxxx\", (string) The services offered\n"
" \"relaytxes\":true|false, (boolean) Whether peer has asked us to relay transactions to it\n"
" \"lastsend\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last send\n"
" \"lastrecv\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last receive\n"
" \"bytessent\": n, (numeric) The total bytes sent\n"
" \"bytesrecv\": n, (numeric) The total bytes received\n"
" \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n"
" \"timeoffset\": ttt, (numeric) The time offset in seconds\n"
" \"pingtime\": n, (numeric) ping time (if available)\n"
" \"minping\": n, (numeric) minimum observed ping time (if any at all)\n"
" \"pingwait\": n, (numeric) ping wait (if non-zero)\n"
" \"version\": v, (numeric) The peer version, such as 70001\n"
" \"subver\": \"/Satoshi:0.8.5/\", (string) The string version\n"
" \"inbound\": true|false, (boolean) Inbound (true) or Outbound (false)\n"
" \"addnode\": true|false, (boolean) Whether connection was due to addnode/-connect or if it was an automatic/inbound connection\n"
" \"startingheight\": n, (numeric) The starting height (block) of the peer\n"
" \"banscore\": n, (numeric) The ban score\n"
" \"synced_headers\": n, (numeric) The last header we have in common with this peer\n"
" \"synced_blocks\": n, (numeric) The last block we have in common with this peer\n"
" \"inflight\": [\n"
" n, (numeric) The heights of blocks we're currently asking from this peer\n"
" ...\n"
" ],\n"
" \"whitelisted\": true|false, (boolean) Whether the peer is whitelisted\n"
" \"bytessent_per_msg\": {\n"
" \"addr\": n, (numeric) The total bytes sent aggregated by message type\n"
" ...\n"
" },\n"
" \"bytesrecv_per_msg\": {\n"
" \"addr\": n, (numeric) The total bytes received aggregated by message type\n"
" ...\n"
" }\n"
" }\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getpeerinfo", "")
+ HelpExampleRpc("getpeerinfo", "")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
std::vector<CNodeStats> vstats;
g_connman->GetNodeStats(vstats);
UniValue ret(UniValue::VARR);
for (const CNodeStats& stats : vstats) {
UniValue obj(UniValue::VOBJ);
CNodeStateStats statestats;
bool fStateStats = GetNodeStateStats(stats.nodeid, statestats);
obj.pushKV("id", stats.nodeid);
obj.pushKV("addr", stats.addrName);
if (!(stats.addrLocal.empty()))
obj.pushKV("addrlocal", stats.addrLocal);
if (stats.addrBind.IsValid())
obj.pushKV("addrbind", stats.addrBind.ToString());
obj.pushKV("services", strprintf("%016x", stats.nServices));
obj.pushKV("relaytxes", stats.fRelayTxes);
obj.pushKV("lastsend", stats.nLastSend);
obj.pushKV("lastrecv", stats.nLastRecv);
obj.pushKV("bytessent", stats.nSendBytes);
obj.pushKV("bytesrecv", stats.nRecvBytes);
obj.pushKV("conntime", stats.nTimeConnected);
obj.pushKV("timeoffset", stats.nTimeOffset);
if (stats.dPingTime > 0.0)
obj.pushKV("pingtime", stats.dPingTime);
if (stats.dMinPing < static_cast<double>(std::numeric_limits<int64_t>::max())/1e6)
obj.pushKV("minping", stats.dMinPing);
if (stats.dPingWait > 0.0)
obj.pushKV("pingwait", stats.dPingWait);
obj.pushKV("version", stats.nVersion);
// Use the sanitized form of subver here, to avoid tricksy remote peers from
// corrupting or modifying the JSON output by putting special characters in
// their ver message.
obj.pushKV("subver", stats.cleanSubVer);
obj.pushKV("inbound", stats.fInbound);
obj.pushKV("addnode", stats.m_manual_connection);
obj.pushKV("startingheight", stats.nStartingHeight);
if (fStateStats) {
obj.pushKV("banscore", statestats.nMisbehavior);
obj.pushKV("synced_headers", statestats.nSyncHeight);
obj.pushKV("synced_blocks", statestats.nCommonHeight);
UniValue heights(UniValue::VARR);
for (int height : statestats.vHeightInFlight) {
heights.push_back(height);
}
obj.pushKV("inflight", heights);
}
obj.pushKV("whitelisted", stats.fWhitelisted);
UniValue sendPerMsgCmd(UniValue::VOBJ);
for (const mapMsgCmdSize::value_type &i : stats.mapSendBytesPerMsgCmd) {
if (i.second > 0)
sendPerMsgCmd.pushKV(i.first, i.second);
}
obj.pushKV("bytessent_per_msg", sendPerMsgCmd);
UniValue recvPerMsgCmd(UniValue::VOBJ);
for (const mapMsgCmdSize::value_type &i : stats.mapRecvBytesPerMsgCmd) {
if (i.second > 0)
recvPerMsgCmd.pushKV(i.first, i.second);
}
obj.pushKV("bytesrecv_per_msg", recvPerMsgCmd);
ret.push_back(obj);
}
return ret;
}
static UniValue addnode(const JSONRPCRequest& request)
{
std::string strCommand;
if (!request.params[1].isNull())
strCommand = request.params[1].get_str();
if (request.fHelp || request.params.size() != 2 ||
(strCommand != "onetry" && strCommand != "add" && strCommand != "remove"))
throw std::runtime_error(
"addnode \"node\" \"add|remove|onetry\"\n"
"\nAttempts to add or remove a node from the addnode list.\n"
"Or try a connection to a node once.\n"
"Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be\n"
"full nodes/support SegWit as other outbound peers are (though such peers will not be synced from).\n"
"\nArguments:\n"
"1. \"node\" (string, required) The node (see getpeerinfo for nodes)\n"
"2. \"command\" (string, required) 'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once\n"
"\nExamples:\n"
+ HelpExampleCli("addnode", "\"192.168.0.6:8333\" \"onetry\"")
+ HelpExampleRpc("addnode", "\"192.168.0.6:8333\", \"onetry\"")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
std::string strNode = request.params[0].get_str();
if (strCommand == "onetry")
{
CAddress addr;
g_connman->OpenNetworkConnection(addr, false, nullptr, strNode.c_str(), false, false, true);
return NullUniValue;
}
if (strCommand == "add")
{
if(!g_connman->AddNode(strNode))
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: Node already added");
}
else if(strCommand == "remove")
{
if(!g_connman->RemoveAddedNode(strNode))
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
}
return NullUniValue;
}
static UniValue disconnectnode(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() == 0 || request.params.size() >= 3)
throw std::runtime_error(
"disconnectnode \"[address]\" [nodeid]\n"
"\nImmediately disconnects from the specified peer node.\n"
"\nStrictly one out of 'address' and 'nodeid' can be provided to identify the node.\n"
"\nTo disconnect by nodeid, either set 'address' to the empty string, or call using the named 'nodeid' argument only.\n"
"\nArguments:\n"
"1. \"address\" (string, optional) The IP address/port of the node\n"
"2. \"nodeid\" (number, optional) The node ID (see getpeerinfo for node IDs)\n"
"\nExamples:\n"
+ HelpExampleCli("disconnectnode", "\"192.168.0.6:8333\"")
+ HelpExampleCli("disconnectnode", "\"\" 1")
+ HelpExampleRpc("disconnectnode", "\"192.168.0.6:8333\"")
+ HelpExampleRpc("disconnectnode", "\"\", 1")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
bool success;
const UniValue &address_arg = request.params[0];
const UniValue &id_arg = request.params[1];
if (!address_arg.isNull() && id_arg.isNull()) {
/* handle disconnect-by-address */
success = g_connman->DisconnectNode(address_arg.get_str());
} else if (!id_arg.isNull() && (address_arg.isNull() || (address_arg.isStr() && address_arg.get_str().empty()))) {
/* handle disconnect-by-id */
NodeId nodeid = (NodeId) id_arg.get_int64();
success = g_connman->DisconnectNode(nodeid);
} else {
throw JSONRPCError(RPC_INVALID_PARAMS, "Only one of address and nodeid should be provided.");
}
if (!success) {
throw JSONRPCError(RPC_CLIENT_NODE_NOT_CONNECTED, "Node not found in connected nodes");
}
return NullUniValue;
}
static UniValue getaddednodeinfo(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() > 1)
throw std::runtime_error(
"getaddednodeinfo ( \"node\" )\n"
"\nReturns information about the given added node, or all added nodes\n"
"(note that onetry addnodes are not listed here)\n"
"\nArguments:\n"
"1. \"node\" (string, optional) If provided, return information about this specific node, otherwise all nodes are returned.\n"
"\nResult:\n"
"[\n"
" {\n"
" \"addednode\" : \"192.168.0.201\", (string) The node IP address or name (as provided to addnode)\n"
" \"connected\" : true|false, (boolean) If connected\n"
" \"addresses\" : [ (list of objects) Only when connected = true\n"
" {\n"
" \"address\" : \"192.168.0.201:8333\", (string) The globalboost server IP and port we're connected to\n"
" \"connected\" : \"outbound\" (string) connection, inbound or outbound\n"
" }\n"
" ]\n"
" }\n"
" ,...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getaddednodeinfo", "\"192.168.0.201\"")
+ HelpExampleRpc("getaddednodeinfo", "\"192.168.0.201\"")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
std::vector<AddedNodeInfo> vInfo = g_connman->GetAddedNodeInfo();
if (!request.params[0].isNull()) {
bool found = false;
for (const AddedNodeInfo& info : vInfo) {
if (info.strAddedNode == request.params[0].get_str()) {
vInfo.assign(1, info);
found = true;
break;
}
}
if (!found) {
throw JSONRPCError(RPC_CLIENT_NODE_NOT_ADDED, "Error: Node has not been added.");
}
}
UniValue ret(UniValue::VARR);
for (const AddedNodeInfo& info : vInfo) {
UniValue obj(UniValue::VOBJ);
obj.pushKV("addednode", info.strAddedNode);
obj.pushKV("connected", info.fConnected);
UniValue addresses(UniValue::VARR);
if (info.fConnected) {
UniValue address(UniValue::VOBJ);
address.pushKV("address", info.resolvedAddress.ToString());
address.pushKV("connected", info.fInbound ? "inbound" : "outbound");
addresses.push_back(address);
}
obj.pushKV("addresses", addresses);
ret.push_back(obj);
}
return ret;
}
static UniValue getnettotals(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() > 0)
throw std::runtime_error(
"getnettotals\n"
"\nReturns information about network traffic, including bytes in, bytes out,\n"
"and current time.\n"
"\nResult:\n"
"{\n"
" \"totalbytesrecv\": n, (numeric) Total bytes received\n"
" \"totalbytessent\": n, (numeric) Total bytes sent\n"
" \"timemillis\": t, (numeric) Current UNIX time in milliseconds\n"
" \"uploadtarget\":\n"
" {\n"
" \"timeframe\": n, (numeric) Length of the measuring timeframe in seconds\n"
" \"target\": n, (numeric) Target in bytes\n"
" \"target_reached\": true|false, (boolean) True if target is reached\n"
" \"serve_historical_blocks\": true|false, (boolean) True if serving historical blocks\n"
" \"bytes_left_in_cycle\": t, (numeric) Bytes left in current time cycle\n"
" \"time_left_in_cycle\": t (numeric) Seconds left in current time cycle\n"
" }\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getnettotals", "")
+ HelpExampleRpc("getnettotals", "")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
UniValue obj(UniValue::VOBJ);
obj.pushKV("totalbytesrecv", g_connman->GetTotalBytesRecv());
obj.pushKV("totalbytessent", g_connman->GetTotalBytesSent());
obj.pushKV("timemillis", GetTimeMillis());
UniValue outboundLimit(UniValue::VOBJ);
outboundLimit.pushKV("timeframe", g_connman->GetMaxOutboundTimeframe());
outboundLimit.pushKV("target", g_connman->GetMaxOutboundTarget());
outboundLimit.pushKV("target_reached", g_connman->OutboundTargetReached(false));
outboundLimit.pushKV("serve_historical_blocks", !g_connman->OutboundTargetReached(true));
outboundLimit.pushKV("bytes_left_in_cycle", g_connman->GetOutboundTargetBytesLeft());
outboundLimit.pushKV("time_left_in_cycle", g_connman->GetMaxOutboundTimeLeftInCycle());
obj.pushKV("uploadtarget", outboundLimit);
return obj;
}
static UniValue GetNetworksInfo()
{
UniValue networks(UniValue::VARR);
for(int n=0; n<NET_MAX; ++n)
{
enum Network network = static_cast<enum Network>(n);
if(network == NET_UNROUTABLE || network == NET_INTERNAL)
continue;
proxyType proxy;
UniValue obj(UniValue::VOBJ);
GetProxy(network, proxy);
obj.pushKV("name", GetNetworkName(network));
obj.pushKV("limited", IsLimited(network));
obj.pushKV("reachable", IsReachable(network));
obj.pushKV("proxy", proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string());
obj.pushKV("proxy_randomize_credentials", proxy.randomize_credentials);
networks.push_back(obj);
}
return networks;
}
static UniValue getnetworkinfo(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"getnetworkinfo\n"
"Returns an object containing various state info regarding P2P networking.\n"
"\nResult:\n"
"{\n"
" \"version\": xxxxx, (numeric) the server version\n"
" \"subversion\": \"/Satoshi:x.x.x/\", (string) the server subversion string\n"
" \"protocolversion\": xxxxx, (numeric) the protocol version\n"
" \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n"
" \"localrelay\": true|false, (bool) true if transaction relay is requested from peers\n"
" \"timeoffset\": xxxxx, (numeric) the time offset\n"
" \"connections\": xxxxx, (numeric) the number of connections\n"
" \"networkactive\": true|false, (bool) whether p2p networking is enabled\n"
" \"networks\": [ (array) information per network\n"
" {\n"
" \"name\": \"xxx\", (string) network (ipv4, ipv6 or onion)\n"
" \"limited\": true|false, (boolean) is the network limited using -onlynet?\n"
" \"reachable\": true|false, (boolean) is the network reachable?\n"
" \"proxy\": \"host:port\" (string) the proxy that is used for this network, or empty if none\n"
" \"proxy_randomize_credentials\": true|false, (string) Whether randomized credentials are used\n"
" }\n"
" ,...\n"
" ],\n"
" \"relayfee\": x.xxxxxxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n"
" \"incrementalfee\": x.xxxxxxxx, (numeric) minimum fee increment for mempool limiting or BIP 125 replacement in " + CURRENCY_UNIT + "/kB\n"
" \"localaddresses\": [ (array) list of local addresses\n"
" {\n"
" \"address\": \"xxxx\", (string) network address\n"
" \"port\": xxx, (numeric) network port\n"
" \"score\": xxx (numeric) relative score\n"
" }\n"
" ,...\n"
" ]\n"
" \"warnings\": \"...\" (string) any network and blockchain warnings\n"
"}\n"
"\nExamples:\n"
+ HelpExampleCli("getnetworkinfo", "")
+ HelpExampleRpc("getnetworkinfo", "")
);
LOCK(cs_main);
UniValue obj(UniValue::VOBJ);
obj.pushKV("version", CLIENT_VERSION);
obj.pushKV("subversion", strSubVersion);
obj.pushKV("protocolversion",PROTOCOL_VERSION);
if(g_connman)
obj.pushKV("localservices", strprintf("%016x", g_connman->GetLocalServices()));
obj.pushKV("localrelay", fRelayTxes);
obj.pushKV("timeoffset", GetTimeOffset());
if (g_connman) {
obj.pushKV("networkactive", g_connman->GetNetworkActive());
obj.pushKV("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL));
}
obj.pushKV("networks", GetNetworksInfo());
obj.pushKV("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()));
obj.pushKV("incrementalfee", ValueFromAmount(::incrementalRelayFee.GetFeePerK()));
UniValue localAddresses(UniValue::VARR);
{
LOCK(cs_mapLocalHost);
for (const std::pair<const CNetAddr, LocalServiceInfo> &item : mapLocalHost)
{
UniValue rec(UniValue::VOBJ);
rec.pushKV("address", item.first.ToString());
rec.pushKV("port", item.second.nPort);
rec.pushKV("score", item.second.nScore);
localAddresses.push_back(rec);
}
}
obj.pushKV("localaddresses", localAddresses);
obj.pushKV("warnings", GetWarnings("statusbar"));
return obj;
}
static UniValue setban(const JSONRPCRequest& request)
{
std::string strCommand;
if (!request.params[1].isNull())
strCommand = request.params[1].get_str();
if (request.fHelp || request.params.size() < 2 ||
(strCommand != "add" && strCommand != "remove"))
throw std::runtime_error(
"setban \"subnet\" \"add|remove\" (bantime) (absolute)\n"
"\nAttempts to add or remove an IP/Subnet from the banned list.\n"
"\nArguments:\n"
"1. \"subnet\" (string, required) The IP/Subnet (see getpeerinfo for nodes IP) with an optional netmask (default is /32 = single IP)\n"
"2. \"command\" (string, required) 'add' to add an IP/Subnet to the list, 'remove' to remove an IP/Subnet from the list\n"
"3. \"bantime\" (numeric, optional) time in seconds how long (or until when if [absolute] is set) the IP is banned (0 or empty means using the default time of 24h which can also be overwritten by the -bantime startup argument)\n"
"4. \"absolute\" (boolean, optional) If set, the bantime must be an absolute timestamp in seconds since epoch (Jan 1 1970 GMT)\n"
"\nExamples:\n"
+ HelpExampleCli("setban", "\"192.168.0.6\" \"add\" 86400")
+ HelpExampleCli("setban", "\"192.168.0.0/24\" \"add\"")
+ HelpExampleRpc("setban", "\"192.168.0.6\", \"add\", 86400")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
CSubNet subNet;
CNetAddr netAddr;
bool isSubnet = false;
if (request.params[0].get_str().find('/') != std::string::npos)
isSubnet = true;
if (!isSubnet) {
CNetAddr resolved;
LookupHost(request.params[0].get_str().c_str(), resolved, false);
netAddr = resolved;
}
else
LookupSubNet(request.params[0].get_str().c_str(), subNet);
if (! (isSubnet ? subNet.IsValid() : netAddr.IsValid()) )
throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Invalid IP/Subnet");
if (strCommand == "add")
{
if (isSubnet ? g_connman->IsBanned(subNet) : g_connman->IsBanned(netAddr))
throw JSONRPCError(RPC_CLIENT_NODE_ALREADY_ADDED, "Error: IP/Subnet already banned");
int64_t banTime = 0; //use standard bantime if not specified
if (!request.params[2].isNull())
banTime = request.params[2].get_int64();
bool absolute = false;
if (request.params[3].isTrue())
absolute = true;
isSubnet ? g_connman->Ban(subNet, BanReasonManuallyAdded, banTime, absolute) : g_connman->Ban(netAddr, BanReasonManuallyAdded, banTime, absolute);
}
else if(strCommand == "remove")
{
if (!( isSubnet ? g_connman->Unban(subNet) : g_connman->Unban(netAddr) ))
throw JSONRPCError(RPC_CLIENT_INVALID_IP_OR_SUBNET, "Error: Unban failed. Requested address/subnet was not previously banned.");
}
return NullUniValue;
}
static UniValue listbanned(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"listbanned\n"
"\nList all banned IPs/Subnets.\n"
"\nExamples:\n"
+ HelpExampleCli("listbanned", "")
+ HelpExampleRpc("listbanned", "")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
banmap_t banMap;
g_connman->GetBanned(banMap);
UniValue bannedAddresses(UniValue::VARR);
for (const auto& entry : banMap)
{
const CBanEntry& banEntry = entry.second;
UniValue rec(UniValue::VOBJ);
rec.pushKV("address", entry.first.ToString());
rec.pushKV("banned_until", banEntry.nBanUntil);
rec.pushKV("ban_created", banEntry.nCreateTime);
rec.pushKV("ban_reason", banEntry.banReasonToString());
bannedAddresses.push_back(rec);
}
return bannedAddresses;
}
static UniValue clearbanned(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 0)
throw std::runtime_error(
"clearbanned\n"
"\nClear all banned IPs.\n"
"\nExamples:\n"
+ HelpExampleCli("clearbanned", "")
+ HelpExampleRpc("clearbanned", "")
);
if(!g_connman)
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
g_connman->ClearBanned();
return NullUniValue;
}
static UniValue setnetworkactive(const JSONRPCRequest& request)
{
if (request.fHelp || request.params.size() != 1) {
throw std::runtime_error(
"setnetworkactive true|false\n"
"\nDisable/enable all p2p network activity.\n"
"\nArguments:\n"
"1. \"state\" (boolean, required) true to enable networking, false to disable\n"
);
}
if (!g_connman) {
throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled");
}
g_connman->SetNetworkActive(request.params[0].get_bool());
return g_connman->GetNetworkActive();
}
static const CRPCCommand commands[] =
{ // category name actor (function) argNames
// --------------------- ------------------------ ----------------------- ----------
{ "network", "getconnectioncount", &getconnectioncount, {} },
{ "network", "ping", &ping, {} },
{ "network", "getpeerinfo", &getpeerinfo, {} },
{ "network", "addnode", &addnode, {"node","command"} },
{ "network", "disconnectnode", &disconnectnode, {"address", "nodeid"} },
{ "network", "getaddednodeinfo", &getaddednodeinfo, {"node"} },
{ "network", "getnettotals", &getnettotals, {} },
{ "network", "getnetworkinfo", &getnetworkinfo, {} },
{ "network", "setban", &setban, {"subnet", "command", "bantime", "absolute"} },
{ "network", "listbanned", &listbanned, {} },
{ "network", "clearbanned", &clearbanned, {} },
{ "network", "setnetworkactive", &setnetworkactive, {"state"} },
};
void RegisterNetRPCCommands(CRPCTable &t)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
t.appendCommand(commands[vcidx].name, &commands[vcidx]);
}
| [
"null"
] | null |
d67ab1335cbf5ca8d7c184ee0c862adcaf3b7f0e | aa0083936eff7afc66fdf62cb7f632e5b3f26d20 | /String processing/Boj 12780.cpp | 2fed5a93cf7f0211248c87d4f4d2548c3edb6a26 | [] | no_license | b8goal/Boj | ab31a8e1a414125bb4a0eb243db7dce2dda1ed4a | b7e395191eda01427a6db8a886a5ce3c49b03abf | refs/heads/master | 2022-02-03T13:15:26.904488 | 2021-12-30T11:58:07 | 2021-12-30T11:58:07 | 161,286,778 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 811 | cpp | #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
typedef long long ll;
using namespace std;
const int MOD = 9901;
const int INF = 0x7fffffff;
const int MAXN = 300;
int p[1000001], dp[250001];
ll cache[61][61];
int find(int x) { return p[x] ^ x ? find(p[x]) : x; }
void merge(int x, int y) { p[find(y)] = find(x); }
int abs(int x, int y) { return x - y > 0 ? x - y : y - x; }
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
int main(void) {
int cnt = 0;
string s1, s2;
cin >> s1 >> s2;
while (1) {
if (s1.find(s2) == string::npos)
break;
else {
s1.erase(s1.find(s2), s2.size());
cnt++;
}
}
cout << cnt << '\n';
return 0;
} | [
"b8goal@naver.com"
] | b8goal@naver.com |
82eada3a6b51ca7aa0ae6abdf19ec240563da625 | defaedbe4fa7d8d8a5df5062e14fe259aaabe6d5 | /include/boost_helpers/make_submodules.hpp | d8af42296bf87aae9894c3e0a2c8dd9cd2cfb49f | [] | no_license | alexleach/bp_helpers | 5cfa858066577eacd8d2f58de172678e16e7ca6f | 1e945706fc39905e8b9f6941a486175800a60c75 | refs/heads/master | 2021-01-02T08:47:01.169546 | 2013-05-24T13:49:30 | 2013-05-24T13:49:30 | 9,748,028 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,381 | hpp | /// make_submodules.hpp
//
// Preprocessor macros for defining sub-package namespaces. These are used to
// organise the Blast+ wrapper classes into a better arranged package namespace.
#include <boost/python/borrowed.hpp>
#include <boost/python/object.hpp>
// The only difference between the macros is the number of registry
// functions they can call from the same macro. If more Boost.Python
// registration functions need to be added to a single namespace, then
// create another macro supporting that number of arguments.
//! BLAST_PYTHON_SUBMODULE
// @param NAME.
// The name of submodule to create within the module-level namespace
// @param INIT
// Function to call, which contains Boost.Python definitions
#define BLAST_PYTHON_SUBMODULE(NAME, INIT) \
{ \
std::string NAME ## _name = module_name + "." #NAME ; \
boost::python::object NAME(boost::python::borrowed( \
PyImport_AddModule(NAME ## _name.c_str() )) ); \
module.attr(#NAME) = NAME; \
{ \
boost::python::scope NAME ## _scope = NAME ; \
INIT(); \
} \
}
//! BLAST_PYTHON_SUBMODULE2
// Same as above, but calls two Boost.Python registry functions.
#define BLAST_PYTHON_SUBMODULE2(NAME, INIT, INIT2) \
{ \
std::string NAME ## _name = module_name + "." #NAME ; \
boost::python::object NAME(boost::python::borrowed( \
PyImport_AddModule(NAME ## _name.c_str() )) ); \
module.attr(#NAME) = NAME; \
{ \
boost::python::scope NAME ## _scope = NAME ; \
INIT(); \
INIT2(); \
} \
}
//! BLAST_PYTHON_SUBMODULE3
// Same as above, but calls three Boost.Python registry functions.
#define BLAST_PYTHON_SUBMODULE3(NAME, INIT, INIT2, INIT3) \
{ \
std::string NAME ## _name = module_name + "." #NAME ; \
boost::python::object NAME(boost::python::borrowed( \
PyImport_AddModule(NAME ## _name.c_str() )) ); \
module.attr(#NAME) = NAME; \
{ \
boost::python::scope NAME ## _scope = NAME ; \
INIT(); \
INIT2(); \
INIT3(); \
} \
}
//! BLAST_PYTHON_SUBMODULE4
// Same as above, but calls four Boost.Python registry functions.
#define BLAST_PYTHON_SUBMODULE4(NAME, INIT, INIT2, INIT3, INIT4) \
{ \
std::string NAME ## _name = module_name + "." #NAME ; \
boost::python::object NAME(boost::python::borrowed( \
PyImport_AddModule(NAME ## _name.c_str() )) ); \
module.attr(#NAME) = NAME; \
{ \
boost::python::scope NAME ## _scope = NAME ; \
INIT(); \
INIT2(); \
INIT3(); \
INIT4(); \
} \
}
//! BLAST_PYTHON_SUBMODULE5
// Same as above, but calls five Boost.Python registry functions.
#define BLAST_PYTHON_SUBMODULE5(NAME, INIT, INIT2, INIT3, INIT4, \
INIT5) \
{ \
std::string NAME ## _name = module_name + "." #NAME ; \
boost::python::object NAME(boost::python::borrowed( \
PyImport_AddModule(NAME ## _name.c_str() )) ); \
module.attr(#NAME) = NAME; \
{ \
boost::python::scope NAME ## _scope = NAME ; \
INIT(); \
INIT2(); \
INIT3(); \
INIT4(); \
INIT5(); \
} \
}
| [
"beamesleach@gmail.com"
] | beamesleach@gmail.com |
d8c158fa663afb5f6f53c95012c6b2157157ae51 | f564812d6af97ad53cf3ad3d0c483caecc0042b6 | /ColliderComponent.h | f440145de0c89f003f889b2693e77689b3c922e3 | [] | no_license | quatros96/pjc_projekt_gra | ea711a4c8112213c55cc88568ff5b7a925562bd2 | 11f320d64d624a605376ce2c585cfc9d7f3403b1 | refs/heads/master | 2022-12-04T07:09:32.985595 | 2020-09-01T21:51:32 | 2020-09-01T21:51:32 | 287,938,061 | 0 | 0 | null | 2020-09-01T21:51:33 | 2020-08-16T12:19:44 | C++ | UTF-8 | C++ | false | false | 552 | h | #pragma once
#include "Component.h"
#include <iostream>
class ColliderComponent : public Component
{
private:
std::string m_Type = "collider";
bool m_Enabled {false};
public:
std::string getType() override
{
return m_Type;
}
void disableComponent() override
{
m_Enabled = false;
}
void enableComponent() override
{
m_Enabled = true;
}
bool enabled() override
{
return m_Enabled;
}
void start(GameObjectSharer* gos, GameObject* self) override
{
}
};
| [
"01129810@pw.edu.pl"
] | 01129810@pw.edu.pl |
866845d9580b971df2bca86bc03d9253b80d4a4f | 8f9b24cb78943c2fa139e9d02cd670e326e6cd39 | /Problems/160. Intersection of Two Linked Lists/Test.cpp | 727a3b839646f2a193a6065615d3dec9f59b797a | [
"MIT"
] | permissive | DanielDFY/LeetCode | a6e340936684abca4d22f1d02a49c4f2cf1cf920 | 5e39e3168db368617ac2f4509886f32cde5bd000 | refs/heads/master | 2021-07-16T16:04:11.759973 | 2020-09-20T15:03:14 | 2020-09-20T15:03:14 | 213,352,385 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 759 | cpp | #define CATCH_CONFIG_MAIN
#include "../../Utils/Cacth/single_include/catch2/catch.hpp"
#include "solution.h"
TEST_CASE("Intersection of Two Linked Lists")
{
Solution s;
SECTION("has intersection") {
ListNode a1(4);
ListNode a2(1);
ListNode b1(5);
ListNode b2(6);
ListNode b3(1);
ListNode c1(8);
ListNode c2(4);
ListNode c3(5);
a1.next = &a2;
a2.next = &c1;
b1.next = &b2;
b2.next = &b3;
b3.next = &c1;
c1.next = &c2;
c2.next = &c3;
CHECK(s.getIntersectionNode(&a1, &b1) == &c1);
}
SECTION("no intersection") {
ListNode a1(2);
ListNode a2(4);
ListNode a3(6);
ListNode b1(1);
ListNode b2(5);
a1.next = &a2;
a2.next = &a3;
b1.next = &b2;
CHECK(s.getIntersectionNode(&a1, &b1) == nullptr);
}
} | [
"daniel_dfy98@163.com"
] | daniel_dfy98@163.com |
7f8098a970f613d14f7781257bb0dae388c9ddd6 | 80816eb7fd304d652eab656d004a59246eda260d | /cpp-holy/exceptionEx.h | edb93d6ee55e6307e8e95db8651d1fae96a0e8d2 | [] | no_license | holy1017-cpp/cpp-holy | b264ac39787ed0759a84030607f4bcb031670197 | 223a69b5c52b8d1b7a3def04d677eda872587848 | refs/heads/master | 2022-12-10T16:34:06.161294 | 2020-09-19T08:30:55 | 2020-09-19T08:30:55 | 290,492,713 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 233 | h | #pragma once
#ifndef exceptionEx_H
#define exceptionEx_H
#include <exception>
using namespace std;
namespace exceptionEx {
class myException : public exception
{
virtual char const* what() const;
} ;
void test();
}
#endif | [
"holy1017@naver.com"
] | holy1017@naver.com |
6be5b79da7cd417da076d345dd333c31d2186ad1 | d9954b283b3fd750b6950a7de8840baa962142cc | /DS/LinklistNode.h | 5d3a042e2ee92085b295f639889b7e603a09f143 | [] | no_license | yiquedexianshi/CP-template | 4a56fca71eb4ab8e593c9ce6931e5a50b7440bc6 | 143832d182b49e609c930298b804dd0ee40a01fc | refs/heads/main | 2023-06-11T18:22:19.916844 | 2021-07-02T10:59:27 | 2021-07-02T10:59:27 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 459 | h | #pragma once
#include <iostream>
using namespace std;
#define OLDYAN_LINKLISTNODE
template<class T>
struct LinklistNode{
T val;
LinklistNode*prev,*next;
LinklistNode():prev(nullptr),next(nullptr){}
LinklistNode(T _val):val(_val),prev(nullptr),next(nullptr){}
LinklistNode(T _val,LinklistNode*_next):val(_val),prev(nullptr),next(_next){}
LinklistNode(T _val,LinklistNode*_prev,LinklistNode*_next):val(_val),prev(_prev),next(_next){}
}; | [
"oldyan_zh@163.com"
] | oldyan_zh@163.com |
ada8e9fca5e8aa1b203d46b9f45d9c1a0a1611de | 8f6569bfb705009b4bead5a9c79730e63d48867e | /src/folly/IPAddress.cpp | c776bc1c76da29c795f1bca2d4f3b80a68cd9015 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | HungMingWu/futures_cpp | ff13e965011f86faa31d42657d0a4671f4b00dd6 | 0e24378c1b989cb7c6115169010577f70aae3c64 | refs/heads/master | 2021-05-12T14:45:10.630137 | 2018-01-11T09:03:17 | 2018-01-11T09:03:17 | 116,111,766 | 0 | 0 | null | 2018-01-03T08:26:30 | 2018-01-03T08:26:29 | null | UTF-8 | C++ | false | false | 12,543 | cpp | /*
* Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <futures/core/IPAddress.h>
#include <limits>
#include <ostream>
#include <string>
#include <vector>
#include "GlogDummy.h"
using std::ostream;
using std::string;
using std::vector;
namespace folly {
// free functions
size_t hash_value(const IPAddress& addr) {
return addr.hash();
}
ostream& operator<<(ostream& os, const IPAddress& addr) {
os << addr.str();
return os;
}
void toAppend(IPAddress addr, string* result) {
result->append(addr.str());
}
#if 0
void toAppend(IPAddress addr, fbstring* result) {
result->append(addr.str());
}
#endif
bool IPAddress::validate(StringPiece ip) {
return IPAddressV4::validate(ip) || IPAddressV6::validate(ip);
}
// public static
IPAddressV4 IPAddress::createIPv4(const IPAddress& addr) {
if (addr.isV4()) {
return addr.asV4();
} else {
return addr.asV6().createIPv4();
}
}
// public static
IPAddressV6 IPAddress::createIPv6(const IPAddress& addr) {
if (addr.isV6()) {
return addr.asV6();
} else {
return addr.asV4().createIPv6();
}
}
void split(const string &delim, StringPiece str, vector<StringPiece> &v)
{
size_t prev = 0, pos = 0;
do
{
pos = str.find(delim, prev);
if (pos == string::npos) pos = str.size();
auto token = str.subpiece(prev, pos-prev);
if (!token.empty()) v.push_back(token);
prev = pos + delim.length();
}
while (pos < str.size() && prev < str.size());
}
// public static
CIDRNetwork IPAddress::createNetwork(StringPiece ipSlashCidr,
int defaultCidr, /* = -1 */
bool applyMask /* = true */) {
if (defaultCidr > std::numeric_limits<uint8_t>::max()) {
throw std::range_error("defaultCidr must be <= UINT8_MAX");
}
vector<StringPiece> vec;
split("/", ipSlashCidr, vec);
vector<string>::size_type elemCount = vec.size();
if (elemCount == 0 || // weird invalid string
elemCount > 2) { // invalid string (IP/CIDR/extras)
throw IPAddressFormatException("Invalid ipSlashCidr specified. "
"Expected IP/CIDR format, got "
"'" + ipSlashCidr.str() + "'");
}
IPAddress subnet(vec.at(0));
uint8_t cidr = (defaultCidr > -1) ? defaultCidr : (subnet.isV4() ? 32 : 128);
if (elemCount == 2) {
try {
cidr = std::atoi(vec.at(1).str().c_str());
} catch (...) {
throw IPAddressFormatException("Mask value "
"'" + vec.at(1).str() + "' not a valid mask");
}
}
if (cidr > subnet.bitCount()) {
throw IPAddressFormatException("CIDR value '" + std::to_string(cidr) + "' "
"is > network bit count "
"'" + std::to_string(subnet.bitCount()) + "'");
}
return std::make_pair(applyMask ? subnet.mask(cidr) : subnet, cidr);
}
// public static
IPAddress IPAddress::fromBinary(ByteRange bytes) {
if (bytes.size() == 4) {
return IPAddress(IPAddressV4::fromBinary(bytes));
} else if (bytes.size() == 16) {
return IPAddress(IPAddressV6::fromBinary(bytes));
} else {
string hexval = detail::Bytes::toHex(bytes.data(), bytes.size());
throw IPAddressFormatException("Invalid address with hex value '" +
hexval + "'");
}
}
// public static
IPAddress IPAddress::fromLong(uint32_t src) {
return IPAddress(IPAddressV4::fromLong(src));
}
IPAddress IPAddress::fromLongHBO(uint32_t src) {
return IPAddress(IPAddressV4::fromLongHBO(src));
}
// default constructor
IPAddress::IPAddress()
: addr_()
, family_(AF_UNSPEC)
{
}
// public string constructor
IPAddress::IPAddress(StringPiece addr)
: addr_()
, family_(AF_UNSPEC)
{
string ip = addr.str(); // inet_pton() needs NUL-terminated string
auto throwFormatException = [&](const string& msg) {
throw IPAddressFormatException("Invalid IP '" + ip+ "': " + msg);
};
if (ip.size() < 2) {
throwFormatException("address too short");
}
if (ip.front() == '[' && ip.back() == ']') {
ip = ip.substr(1, ip.size() - 2);
}
// need to check for V4 address second, since IPv4-mapped IPv6 addresses may
// contain a period
if (ip.find(':') != string::npos) {
struct addrinfo* result;
struct addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET6;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICHOST;
if (!getaddrinfo(ip.c_str(), nullptr, &hints, &result)) {
struct sockaddr_in6* ipAddr = (struct sockaddr_in6*)result->ai_addr;
addr_ = IPAddressV46(IPAddressV6(*ipAddr));
family_ = AF_INET6;
freeaddrinfo(result);
} else {
throwFormatException("getsockaddr failed for V6 address");
}
} else if (ip.find('.') != string::npos) {
in_addr ipAddr;
if (inet_pton(AF_INET, ip.c_str(), &ipAddr) != 1) {
throwFormatException("inet_pton failed for V4 address");
}
addr_ = IPAddressV46(IPAddressV4(ipAddr));
family_ = AF_INET;
} else {
throwFormatException("invalid address format");
}
}
// public sockaddr constructor
IPAddress::IPAddress(const sockaddr* addr)
: addr_()
, family_(AF_UNSPEC)
{
if (addr == nullptr) {
throw IPAddressFormatException("sockaddr == nullptr");
}
family_ = addr->sa_family;
switch (addr->sa_family) {
case AF_INET: {
const sockaddr_in *v4addr = reinterpret_cast<const sockaddr_in*>(addr);
addr_.ipV4Addr = IPAddressV4(v4addr->sin_addr);
break;
}
case AF_INET6: {
const sockaddr_in6 *v6addr = reinterpret_cast<const sockaddr_in6*>(addr);
addr_.ipV6Addr = IPAddressV6(*v6addr);
break;
}
default:
throw InvalidAddressFamilyException(addr->sa_family);
}
}
// public ipv4 constructor
IPAddress::IPAddress(const IPAddressV4 ipV4Addr)
: addr_(ipV4Addr)
, family_(AF_INET)
{
}
// public ipv4 constructor
IPAddress::IPAddress(const in_addr ipV4Addr)
: addr_(IPAddressV4(ipV4Addr))
, family_(AF_INET)
{
}
// public ipv6 constructor
IPAddress::IPAddress(const IPAddressV6& ipV6Addr)
: addr_(ipV6Addr)
, family_(AF_INET6)
{
}
// public ipv6 constructor
IPAddress::IPAddress(const in6_addr& ipV6Addr)
: addr_(IPAddressV6(ipV6Addr))
, family_(AF_INET6)
{
}
// Assign from V4 address
IPAddress& IPAddress::operator=(const IPAddressV4& ipv4_addr) {
addr_ = IPAddressV46(ipv4_addr);
family_ = AF_INET;
return *this;
}
// Assign from V6 address
IPAddress& IPAddress::operator=(const IPAddressV6& ipv6_addr) {
addr_ = IPAddressV46(ipv6_addr);
family_ = AF_INET6;
return *this;
}
// public
bool IPAddress::inSubnet(StringPiece cidrNetwork) const {
auto subnetInfo = IPAddress::createNetwork(cidrNetwork);
return inSubnet(subnetInfo.first, subnetInfo.second);
}
// public
bool IPAddress::inSubnet(const IPAddress& subnet, uint8_t cidr) const {
if (bitCount() == subnet.bitCount()) {
if (isV4()) {
return asV4().inSubnet(subnet.asV4(), cidr);
} else {
return asV6().inSubnet(subnet.asV6(), cidr);
}
}
// an IPv4 address can never belong in a IPv6 subnet unless the IPv6 is a 6to4
// address and vice-versa
if (isV6()) {
const IPAddressV6& v6addr = asV6();
const IPAddressV4& v4subnet = subnet.asV4();
if (v6addr.is6To4()) {
return v6addr.getIPv4For6To4().inSubnet(v4subnet, cidr);
}
} else if (subnet.isV6()) {
const IPAddressV6& v6subnet = subnet.asV6();
const IPAddressV4& v4addr = asV4();
if (v6subnet.is6To4()) {
return v4addr.inSubnet(v6subnet.getIPv4For6To4(), cidr);
}
}
return false;
}
// public
bool IPAddress::inSubnetWithMask(const IPAddress& subnet,
ByteRange mask) const {
auto mkByteArray4 = [&]() -> ByteArray4 {
ByteArray4 ba{{0}};
std::memcpy(ba.data(), mask.begin(), std::min<size_t>(mask.size(), 4));
return ba;
};
if (bitCount() == subnet.bitCount()) {
if (isV4()) {
return asV4().inSubnetWithMask(subnet.asV4(), mkByteArray4());
} else {
ByteArray16 ba{{0}};
std::memcpy(ba.data(), mask.begin(), std::min<size_t>(mask.size(), 16));
return asV6().inSubnetWithMask(subnet.asV6(), ba);
}
}
// an IPv4 address can never belong in a IPv6 subnet unless the IPv6 is a 6to4
// address and vice-versa
if (isV6()) {
const IPAddressV6& v6addr = asV6();
const IPAddressV4& v4subnet = subnet.asV4();
if (v6addr.is6To4()) {
return v6addr.getIPv4For6To4().inSubnetWithMask(v4subnet, mkByteArray4());
}
} else if (subnet.isV6()) {
const IPAddressV6& v6subnet = subnet.asV6();
const IPAddressV4& v4addr = asV4();
if (v6subnet.is6To4()) {
return v4addr.inSubnetWithMask(v6subnet.getIPv4For6To4(), mkByteArray4());
}
}
return false;
}
uint8_t IPAddress::getNthMSByte(size_t byteIndex) const {
const auto highestIndex = byteCount() - 1;
if (byteIndex > highestIndex) {
throw std::invalid_argument("Byte index must be <= " +
std::to_string(highestIndex) + " for addresses of type :" +
detail::familyNameStr(family()));
}
if (isV4()) {
return asV4().bytes()[byteIndex];
}
return asV6().bytes()[byteIndex];
}
// public
bool operator==(const IPAddress& addr1, const IPAddress& addr2) {
if (addr1.family() == addr2.family()) {
if (addr1.isV6()) {
return (addr1.asV6() == addr2.asV6());
} else if (addr1.isV4()) {
return (addr1.asV4() == addr2.asV4());
} else {
CHECK_EQ(addr1.family(), AF_UNSPEC);
// Two default initialized AF_UNSPEC addresses should be considered equal.
// AF_UNSPEC is the only other value for which an IPAddress can be
// created, in the default constructor case.
return true;
}
}
// addr1 is v4 mapped v6 address, addr2 is v4
if (addr1.isIPv4Mapped() && addr2.isV4()) {
if (IPAddress::createIPv4(addr1) == addr2.asV4()) {
return true;
}
}
// addr2 is v4 mapped v6 address, addr1 is v4
if (addr2.isIPv4Mapped() && addr1.isV4()) {
if (IPAddress::createIPv4(addr2) == addr1.asV4()) {
return true;
}
}
// we only compare IPv4 and IPv6 addresses
return false;
}
bool operator<(const IPAddress& addr1, const IPAddress& addr2) {
if (addr1.family() == addr2.family()) {
if (addr1.isV6()) {
return (addr1.asV6() < addr2.asV6());
} else if (addr1.isV4()) {
return (addr1.asV4() < addr2.asV4());
} else {
CHECK_EQ(addr1.family(), AF_UNSPEC);
// Two default initialized AF_UNSPEC addresses can not be less than each
// other. AF_UNSPEC is the only other value for which an IPAddress can be
// created, in the default constructor case.
return false;
}
}
if (addr1.isV6()) {
// means addr2 is v4, convert it to a mapped v6 address and compare
return addr1.asV6() < addr2.asV4().createIPv6();
}
if (addr2.isV6()) {
// means addr2 is v6, convert addr1 to v4 mapped and compare
return addr1.asV4().createIPv6() < addr2.asV6();
}
return false;
}
CIDRNetwork
IPAddress::longestCommonPrefix(const CIDRNetwork& one, const CIDRNetwork& two) {
if (one.first.family() != two.first.family()) {
throw std::invalid_argument("Can't compute longest common prefix between addresses of different families. Passed: " + detail::familyNameStr(one.first.family()) + " and " +
detail::familyNameStr(two.first.family()));
}
if (one.first.isV4()) {
auto prefix = IPAddressV4::longestCommonPrefix(
{one.first.asV4(), one.second},
{two.first.asV4(), two.second});
return {IPAddress(prefix.first), prefix.second};
} else if (one.first.isV6()) {
auto prefix = IPAddressV6::longestCommonPrefix(
{one.first.asV6(), one.second},
{two.first.asV6(), two.second});
return {IPAddress(prefix.first), prefix.second};
} else {
throw std::invalid_argument("Unknown address family");
}
return {IPAddress(0), 0};
}
} // folly
| [
"yuhengchen@sensetime.com"
] | yuhengchen@sensetime.com |
6d4ec4fc980953f0abfd89b029c56e770866544b | 86dae49990a297d199ea2c8e47cb61336b1ca81e | /数据结构/平衡树/splay/P4036.cpp | 11823b2a545cd02fdcc5421177bda89272f37c30 | [] | no_license | yingziyu-llt/OI | 7cc88f6537df0675b60718da73b8407bdaeb5f90 | c8030807fe46b27e431687d5ff050f2f74616bc0 | refs/heads/main | 2023-04-04T03:59:22.255818 | 2021-04-11T10:15:03 | 2021-04-11T10:15:03 | 354,771,118 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,550 | cpp | #include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
const int MAXN = 150010,MOD = 1e9+7;
struct node
{
int c[2],fa,val,siz,hash;
}a[MAXN];
int n,m,root,tot,power26[MAXN];
char s[MAXN];
int push_up(int x)
{
a[x].siz = a[a[x].c[0]].siz + 1 + a[a[x].c[1]].siz;
a[x].hash=(((long long)a[a[x].c[0]].hash*power26[a[a[x].c[1]].siz+1]%MOD+(long long)a[x].val*power26[a[a[x].c[1]].siz]%MOD)%MOD+a[a[x].c[1]].hash)%MOD;
}
void rotate(int &o,int x)
{
int y = a[x].fa,z = a[y].fa,dy = a[y].c[1] == x,dz = a[z].c[1] == y;
if(o == y) o = x;
else a[z].c[dz] = x;
a[x].fa = z;
a[y].c[dy] = a[x].c[dy ^ 1];
a[a[y].c[dy]].fa = y;
a[x].c[dy ^ 1] = y;
a[y].fa = x;
push_up(y);
}
void splay(int &o,int x)
{
while(o != x)
{
int y = a[x].fa,z = a[y].fa;
if(y != o)
{
if((a[y].c[1] == x) ^ (a[z].c[1] == y))
rotate(o,x);
else rotate(o,y);
}
rotate(o,x);
}
push_up(x);
return ;
}
int find(int o,int v)
{
if(v <= a[a[o].c[0]].siz) return find(a[o].c[0],v);
if(v <= a[a[o].c[0]].siz + 1) return o;
return find(a[o].c[1],v - a[a[o].c[0]].siz - 1);
}
int main()
{
scanf("%s",s + 1);
scanf("%d",&m);
n = strlen(s + 1);
power26[0] = 1;
for(int i = 1;i <= MAXN;i++) power26[i] = power26[i - 1] * 26 % MOD;
a[1].siz = n + 2,a[1].c[1] = 2;
a[n + 2].siz = 1;a[n + 2].fa = n + 1;
for(int i = 1;i <= n;i++)
a[i + 1] = (node){{0,i + 2},i,s[i] - 'a',n - i + 2,0},push_up(i + 1);
tot = n + 2,root = 1;
while(m--)
{
char ques[100];
scanf("%s",ques);
if(ques[0] == 'Q')
{
int x,y;
scanf("%d %d",&x,&y);
if(x > y) swap(x,y);
int l = 0,r = n - y + 2;
while(l < r - 1)
{
int mid = (l + r) >> 1;
splay(root,find(root,x));
splay(a[root].c[1],find(root,x + mid + 1));
int tmp = a[a[a[root].c[1]].c[0]].hash;
splay(root,find(root,y));
splay(a[root].c[1],find(root,y + mid + 1));
tmp -= a[a[a[root].c[1]].c[0]].hash;
if(tmp != 0) r = mid;
else l = mid;
}
printf("%d\n",l);
}
else if(ques[0] == 'R')
{
int x;
char c[10];
scanf("%d%s",&x,c);
splay(root,find(root,x + 1));
a[root].val = c[0] - 'a';
push_up(x);
}
else
{
int x;char c[10];
scanf("%d%s",&x,c);
splay(root,find(root,x + 1));
splay(a[root].c[1],find(root,x + 2));
a[a[root].c[1]].c[0] = ++tot;
a[tot] = (node){{0,0},a[root].c[1],c[0] - 'a',1,c[0] - 'a'};
push_up(a[root].c[1]);
push_up(root);
}
}
return 0;
} | [
"linletian1@sina.com"
] | linletian1@sina.com |
95bff8225731de23176cada601933db1dff96bc0 | 7ee32501835c5d0cfe29529ee6edc3b4bef6910e | /OPCODE 1.3.2/OPC_SphereCollider.cpp | 24c9cf05dbcb8ce4104f079618aa46c348e09dab | [] | no_license | moscowlights/OPCODE | 88c87adb4e64b5b194a3e64b37a22fb3e77e8f88 | cf8a6a0192375e05bce14719076199766b9f9984 | refs/heads/master | 2021-05-08T19:49:39.695228 | 2018-02-13T18:30:06 | 2018-02-13T18:30:06 | 119,583,664 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 29,332 | cpp | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
* OPCODE - Optimized Collision Detection
* Copyright (C) 2001 Pierre Terdiman
* Homepage: http://www.codercorner.com/Opcode.htm
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Contains code for a sphere collider.
* \file OPC_SphereCollider.cpp
* \author Pierre Terdiman
* \date June, 2, 2001
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Contains a sphere-vs-tree collider.
* This class performs a collision test between a sphere and an AABB tree. You can use this to do a standard player vs world collision,
* in a Nettle/Telemachos way. It doesn't suffer from all reported bugs in those two classic codes - the "new" one by Paul Nettle is a
* debuggued version I think. Collision response can be driven by reported collision data - it works extremely well for me. In sake of
* efficiency, all meshes (that is, all AABB trees) should of course also be kept in an extra hierarchical structure (octree, whatever).
*
* \class SphereCollider
* \author Pierre Terdiman
* \version 1.3
* \date June, 2, 2001
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Precompiled Header
#include "Stdafx.h"
using namespace Opcode;
using namespace IceMaths;
#include "OPC_SphereAABBOverlap.h"
#include "OPC_SphereTriOverlap.h"
#define SET_CONTACT(prim_index, flag) \
/* Set contact status */ \
mFlags |= flag; \
mTouchedPrimitives->Add(udword(prim_index));
//! Sphere-triangle overlap test
#define SPHERE_PRIM(prim_index, flag) \
/* Request vertices from the app */ \
VertexPointers VP; mIMesh->GetTriangle(VP, prim_index); \
\
/* Perform sphere-tri overlap test */ \
if(SphereTriOverlap(*VP.Vertex[0], *VP.Vertex[1], *VP.Vertex[2])) \
{ \
SET_CONTACT(prim_index, flag) \
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Constructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SphereCollider::SphereCollider()
{
mCenter.Zero();
mRadius2 = 0.0f;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Destructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SphereCollider::~SphereCollider()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Generic collision query for generic OPCODE models. After the call, access the results:
* - with GetContactStatus()
* - with GetNbTouchedPrimitives()
* - with GetTouchedPrimitives()
*
* \param cache [in/out] a sphere cache
* \param sphere [in] collision sphere in local space
* \param model [in] Opcode model to collide with
* \param worlds [in] sphere's world matrix, or null
* \param worldm [in] model's world matrix, or null
* \return true if success
* \warning SCALE NOT SUPPORTED IN SPHERE WORLD MATRIX. The matrix must contain rotation & translation parts only.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SphereCollider::Collide(SphereCache& cache, const IceMaths::Sphere& sphere, const Model& model, const IceMaths::Matrix4x4* worlds, const IceMaths::Matrix4x4* worldm)
{
// Checkings
if(!Setup(&model)) return false;
// Init collision query
if(InitQuery(cache, sphere, worlds, worldm)) return true;
// Special case for 1-leaf trees
if(mCurrentModel && mCurrentModel->HasSingleNode())
{
// Here we're supposed to perform a normal query, except our tree has a single node, i.e. just a few triangles
udword Nb = mIMesh->GetNbTriangles();
// Loop through all triangles
for(udword i=0;i<Nb;i++)
{
SPHERE_PRIM(i, OPC_CONTACT)
}
return true;
}
if(!model.HasLeafNodes())
{
if(model.IsQuantized())
{
const AABBQuantizedNoLeafTree* Tree = static_cast<const AABBQuantizedNoLeafTree *>(model.GetTree());
// Setup dequantization coeffs
mCenterCoeff = Tree->mCenterCoeff;
mExtentsCoeff = Tree->mExtentsCoeff;
// Perform collision query
if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
else _Collide(Tree->GetNodes());
}
else
{
const AABBNoLeafTree* Tree = static_cast<const AABBNoLeafTree *>(model.GetTree());
// Perform collision query
if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
else _Collide(Tree->GetNodes());
}
}
else
{
if(model.IsQuantized())
{
const AABBQuantizedTree* Tree = static_cast<const AABBQuantizedTree *>(model.GetTree());
// Setup dequantization coeffs
mCenterCoeff = Tree->mCenterCoeff;
mExtentsCoeff = Tree->mExtentsCoeff;
// Perform collision query
if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
else _Collide(Tree->GetNodes());
}
else
{
const AABBCollisionTree* Tree = static_cast<const AABBCollisionTree *>(model.GetTree());
// Perform collision query
if(SkipPrimitiveTests()) _CollideNoPrimitiveTest(Tree->GetNodes());
else _Collide(Tree->GetNodes());
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Initializes a collision query :
* - reset stats & contact status
* - setup matrices
* - check temporal coherence
*
* \param cache [in/out] a sphere cache
* \param sphere [in] sphere in local space
* \param worlds [in] sphere's world matrix, or null
* \param worldm [in] model's world matrix, or null
* \return TRUE if we can return immediately
* \warning SCALE NOT SUPPORTED IN SPHERE WORLD MATRIX. The matrix must contain rotation & translation parts only.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL SphereCollider::InitQuery(SphereCache& cache, const IceMaths::Sphere& sphere, const IceMaths::Matrix4x4* worlds, const IceMaths::Matrix4x4* worldm)
{
// 1) Call the base method
VolumeCollider::InitQuery();
// 2) Compute sphere in model space:
// - Precompute R^2
mRadius2 = sphere.mRadius * sphere.mRadius;
// - Compute center position
mCenter = sphere.mCenter;
// -> to world space
if(worlds) mCenter *= *worlds;
// -> to model space
if(worldm)
{
// Matrix normalization & scaling stripping
IceMaths::Matrix4x4 normWorldm;
NormalizePRSMatrix( normWorldm, mLocalScale, *worldm );
// Invert model matrix
IceMaths::Matrix4x4 InvWorldM;
InvertPRMatrix(InvWorldM, normWorldm); // OLD: //InvertPRMatrix(InvWorldM, *worldm);
mCenter *= InvWorldM;
}else
{
mLocalScale.Set(1.0,1.0,1.0);
}
// 3) Setup destination pointer
mTouchedPrimitives = &cache.TouchedPrimitives;
// 4) Special case: 1-triangle meshes [Opcode 1.3]
if(mCurrentModel && mCurrentModel->HasSingleNode())
{
if(!SkipPrimitiveTests())
{
// We simply perform the BV-Prim overlap test each time. We assume single triangle has index 0.
mTouchedPrimitives->Reset();
// Perform overlap test between the unique triangle and the sphere (and set contact status if needed)
SPHERE_PRIM(udword(0), OPC_CONTACT)
// Return immediately regardless of status
return TRUE;
}
}
// 5) Check temporal coherence :
if(TemporalCoherenceEnabled())
{
// Here we use temporal coherence
// => check results from previous frame before performing the collision query
if(FirstContactEnabled())
{
// We're only interested in the first contact found => test the unique previously touched face
if(mTouchedPrimitives->GetNbEntries())
{
// Get index of previously touched face = the first entry in the array
udword PreviouslyTouchedFace = mTouchedPrimitives->GetEntry(0);
// Then reset the array:
// - if the overlap test below is successful, the index we'll get added back anyway
// - if it isn't, then the array should be reset anyway for the normal query
mTouchedPrimitives->Reset();
// Perform overlap test between the cached triangle and the sphere (and set contact status if needed)
SPHERE_PRIM(PreviouslyTouchedFace, OPC_TEMPORAL_CONTACT)
// Return immediately if possible
if(GetContactStatus()) return TRUE;
}
// else no face has been touched during previous query
// => we'll have to perform a normal query
}
else
{
// We're interested in all contacts =>test the new real sphere N(ew) against the previous fat sphere P(revious):
float r = sqrtf(cache.FatRadius2) - sphere.mRadius;
if(IsCacheValid(cache) && cache.Center.SquareDistance(mCenter) < r*r)
{
// - if N is included in P, return previous list
// => we simply leave the list (mTouchedFaces) unchanged
// Set contact status if needed
if(mTouchedPrimitives->GetNbEntries()) mFlags |= OPC_TEMPORAL_CONTACT;
// In any case we don't need to do a query
return TRUE;
}
else
{
// - else do the query using a fat N
// Reset cache since we'll about to perform a real query
mTouchedPrimitives->Reset();
// Make a fat sphere so that coherence will work for subsequent frames
mRadius2 *= cache.FatCoeff;
// mRadius2 = (sphere.mRadius * cache.FatCoeff)*(sphere.mRadius * cache.FatCoeff);
// Update cache with query data (signature for cached faces)
cache.Center = mCenter;
cache.FatRadius2 = mRadius2;
}
}
}
else
{
// Here we don't use temporal coherence => do a normal query
mTouchedPrimitives->Reset();
}
return FALSE;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Collision query for vanilla AABB trees.
* \param cache [in/out] a sphere cache
* \param sphere [in] collision sphere in world space
* \param tree [in] AABB tree
* \return true if success
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SphereCollider::Collide(SphereCache& cache, const IceMaths::Sphere& sphere, const AABBTree* tree)
{
// This is typically called for a scene tree, full of -AABBs-, not full of triangles.
// So we don't really have "primitives" to deal with. Hence it doesn't work with
// "FirstContact" + "TemporalCoherence".
ASSERT( !(FirstContactEnabled() && TemporalCoherenceEnabled()) );
// Checkings
if(!tree) return false;
// Init collision query
if(InitQuery(cache, sphere)) return true;
// Perform collision query
_Collide(tree);
return true;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Checks the sphere completely contains the box. In which case we can end the query sooner.
* \param bc_ [in] box center
* \param be_ [in] box extents
* \return true if the sphere contains the whole box
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ BOOL SphereCollider::SphereContainsBox(const IceMaths::Point& bc_, const IceMaths::Point& be_)
{
// I assume if all 8 box vertices are inside the sphere, so does the whole box.
// Sounds ok but maybe there's a better way?
IceMaths::Point p;
// scaling freak
IceMaths::Point bc = bc_*mLocalScale;
IceMaths::Point be = be_*mLocalScale;
p.x=bc.x+be.x; p.y=bc.y+be.y; p.z=bc.z+be.z; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
p.x=bc.x+be.x; p.y=bc.y-be.y; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
p.x=bc.x+be.x; p.y=bc.y+be.y; p.z=bc.z-be.z; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
p.x=bc.x+be.x; p.y=bc.y-be.y; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE;
return TRUE;
}
#define TEST_BOX_IN_SPHERE(center, extents) \
if(SphereContainsBox(center, extents)) \
{ \
/* Set contact status */ \
mFlags |= OPC_CONTACT; \
_Dump(node); \
return; \
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for normal AABB trees.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_Collide(const AABBCollisionNode* node)
{
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(node->mAABB.mCenter, node->mAABB.mExtents)) return;
TEST_BOX_IN_SPHERE(node->mAABB.mCenter, node->mAABB.mExtents)
if(node->IsLeaf())
{
SPHERE_PRIM(node->GetPrimitive(), OPC_CONTACT)
}
else
{
_Collide(node->GetPos());
if(ContactFound()) return;
_Collide(node->GetNeg());
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for normal AABB trees, without primitive tests.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_CollideNoPrimitiveTest(const AABBCollisionNode* node)
{
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(node->mAABB.mCenter, node->mAABB.mExtents)) return;
TEST_BOX_IN_SPHERE(node->mAABB.mCenter, node->mAABB.mExtents)
if(node->IsLeaf())
{
SET_CONTACT(node->GetPrimitive(), OPC_CONTACT)
}
else
{
_CollideNoPrimitiveTest(node->GetPos());
if(ContactFound()) return;
_CollideNoPrimitiveTest(node->GetNeg());
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for quantized AABB trees.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_Collide(const AABBQuantizedNode* node)
{
// Dequantize box
const QuantizedAABB& Box = node->mAABB;
const IceMaths::Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z);
const IceMaths::Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z);
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(Center, Extents)) return;
TEST_BOX_IN_SPHERE(Center, Extents)
if(node->IsLeaf())
{
SPHERE_PRIM(node->GetPrimitive(), OPC_CONTACT)
}
else
{
_Collide(node->GetPos());
if(ContactFound()) return;
_Collide(node->GetNeg());
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for quantized AABB trees, without primitive tests.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_CollideNoPrimitiveTest(const AABBQuantizedNode* node)
{
// Dequantize box
const QuantizedAABB& Box = node->mAABB;
const IceMaths::Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z);
const IceMaths::Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z);
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(Center, Extents)) return;
TEST_BOX_IN_SPHERE(Center, Extents)
if(node->IsLeaf())
{
SET_CONTACT(node->GetPrimitive(), OPC_CONTACT)
}
else
{
_CollideNoPrimitiveTest(node->GetPos());
if(ContactFound()) return;
_CollideNoPrimitiveTest(node->GetNeg());
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for no-leaf AABB trees.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_Collide(const AABBNoLeafNode* node)
{
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(node->mAABB.mCenter, node->mAABB.mExtents)) return;
TEST_BOX_IN_SPHERE(node->mAABB.mCenter, node->mAABB.mExtents)
if(node->HasPosLeaf()) { SPHERE_PRIM(node->GetPosPrimitive(), OPC_CONTACT) }
else _Collide(node->GetPos());
if(ContactFound()) return;
if(node->HasNegLeaf()) { SPHERE_PRIM(node->GetNegPrimitive(), OPC_CONTACT) }
else _Collide(node->GetNeg());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for no-leaf AABB trees, without primitive tests.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_CollideNoPrimitiveTest(const AABBNoLeafNode* node)
{
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(node->mAABB.mCenter, node->mAABB.mExtents)) return;
TEST_BOX_IN_SPHERE(node->mAABB.mCenter, node->mAABB.mExtents)
if(node->HasPosLeaf()) { SET_CONTACT(node->GetPosPrimitive(), OPC_CONTACT) }
else _CollideNoPrimitiveTest(node->GetPos());
if(ContactFound()) return;
if(node->HasNegLeaf()) { SET_CONTACT(node->GetNegPrimitive(), OPC_CONTACT) }
else _CollideNoPrimitiveTest(node->GetNeg());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for quantized no-leaf AABB trees.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_Collide(const AABBQuantizedNoLeafNode* node)
{
// Dequantize box
const QuantizedAABB& Box = node->mAABB;
const IceMaths::Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z);
const IceMaths::Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z);
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(Center, Extents)) return;
TEST_BOX_IN_SPHERE(Center, Extents)
if(node->HasPosLeaf()) { SPHERE_PRIM(node->GetPosPrimitive(), OPC_CONTACT) }
else _Collide(node->GetPos());
if(ContactFound()) return;
if(node->HasNegLeaf()) { SPHERE_PRIM(node->GetNegPrimitive(), OPC_CONTACT) }
else _Collide(node->GetNeg());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for quantized no-leaf AABB trees, without primitive tests.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node)
{
// Dequantize box
const QuantizedAABB& Box = node->mAABB;
const IceMaths::Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z);
const IceMaths::Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z);
// Perform Sphere-AABB overlap test
if(!SphereAABBOverlap(Center, Extents)) return;
TEST_BOX_IN_SPHERE(Center, Extents)
if(node->HasPosLeaf()) { SET_CONTACT(node->GetPosPrimitive(), OPC_CONTACT) }
else _CollideNoPrimitiveTest(node->GetPos());
if(ContactFound()) return;
if(node->HasNegLeaf()) { SET_CONTACT(node->GetNegPrimitive(), OPC_CONTACT) }
else _CollideNoPrimitiveTest(node->GetNeg());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Recursive collision query for vanilla AABB trees.
* \param node [in] current collision node
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void SphereCollider::_Collide(const AABBTreeNode* node)
{
// Perform Sphere-AABB overlap test
IceMaths::Point Center, Extents;
node->GetAABB()->GetCenter(Center);
node->GetAABB()->GetExtents(Extents);
if(!SphereAABBOverlap(Center, Extents)) return;
if(node->IsLeaf() || SphereContainsBox(Center, Extents))
{
mFlags |= OPC_CONTACT;
mTouchedPrimitives->Add(node->GetPrimitives(), node->GetNbPrimitives());
}
else
{
_Collide(node->GetPos());
_Collide(node->GetNeg());
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Constructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
HybridSphereCollider::HybridSphereCollider()
{
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Destructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
HybridSphereCollider::~HybridSphereCollider()
{
}
bool HybridSphereCollider::Collide(SphereCache& cache, const IceMaths::Sphere& sphere, const HybridModel& model, const IceMaths::Matrix4x4* worlds, const IceMaths::Matrix4x4* worldm)
{
// We don't want primitive tests here!
mFlags |= OPC_NO_PRIMITIVE_TESTS;
// Checkings
if(!Setup(&model)) return false;
// Init collision query
if(InitQuery(cache, sphere, worlds, worldm)) return true;
// Special case for 1-leaf trees
if(mCurrentModel && mCurrentModel->HasSingleNode())
{
// Here we're supposed to perform a normal query, except our tree has a single node, i.e. just a few triangles
udword Nb = mIMesh->GetNbTriangles();
// Loop through all triangles
for(udword i=0;i<Nb;i++)
{
SPHERE_PRIM(i, OPC_CONTACT)
}
return true;
}
// Override destination array since we're only going to get leaf boxes here
mTouchedBoxes.Reset();
mTouchedPrimitives = &mTouchedBoxes;
// Now, do the actual query against leaf boxes
if(!model.HasLeafNodes())
{
if(model.IsQuantized())
{
const AABBQuantizedNoLeafTree* Tree = static_cast<const AABBQuantizedNoLeafTree *>(model.GetTree());
// Setup dequantization coeffs
mCenterCoeff = Tree->mCenterCoeff;
mExtentsCoeff = Tree->mExtentsCoeff;
// Perform collision query - we don't want primitive tests here!
_CollideNoPrimitiveTest(Tree->GetNodes());
}
else
{
const AABBNoLeafTree* Tree = static_cast<const AABBNoLeafTree *>(model.GetTree());
// Perform collision query - we don't want primitive tests here!
_CollideNoPrimitiveTest(Tree->GetNodes());
}
}
else
{
if(model.IsQuantized())
{
const AABBQuantizedTree* Tree = static_cast<const AABBQuantizedTree *>(model.GetTree());
// Setup dequantization coeffs
mCenterCoeff = Tree->mCenterCoeff;
mExtentsCoeff = Tree->mExtentsCoeff;
// Perform collision query - we don't want primitive tests here!
_CollideNoPrimitiveTest(Tree->GetNodes());
}
else
{
const AABBCollisionTree* Tree = static_cast<const AABBCollisionTree *>(model.GetTree());
// Perform collision query - we don't want primitive tests here!
_CollideNoPrimitiveTest(Tree->GetNodes());
}
}
// We only have a list of boxes so far
if(GetContactStatus())
{
// Reset contact status, since it currently only reflects collisions with leaf boxes
Collider::InitQuery();
// Change dest container so that we can use built-in overlap tests and get collided primitives
cache.TouchedPrimitives.Reset();
mTouchedPrimitives = &cache.TouchedPrimitives;
// Read touched leaf boxes
udword Nb = mTouchedBoxes.GetNbEntries();
const udword* Touched = mTouchedBoxes.GetEntries();
const LeafTriangles* LT = model.GetLeafTriangles();
const udword* Indices = model.GetIndices();
// Loop through touched leaves
while(Nb--)
{
const LeafTriangles& CurrentLeaf = LT[*Touched++];
// Each leaf box has a set of triangles
udword NbTris = CurrentLeaf.GetNbTriangles();
if(Indices)
{
const udword* T = &Indices[CurrentLeaf.GetTriangleIndex()];
// Loop through triangles and test each of them
while(NbTris--)
{
udword TriangleIndex = *T++;
SPHERE_PRIM(TriangleIndex, OPC_CONTACT)
}
}
else
{
udword BaseIndex = CurrentLeaf.GetTriangleIndex();
// Loop through triangles and test each of them
while(NbTris--)
{
udword TriangleIndex = BaseIndex++;
SPHERE_PRIM(TriangleIndex, OPC_CONTACT)
}
}
}
}
return true;
}
| [
"a@a.a"
] | a@a.a |
27649f14042d8655cc0b6ad72ee1cd69507eddb2 | f95683864c1ee1028eb4a43bb97fb7ccd4d2d881 | /001_hello_world/hello_world.cc | 7fc1a0ef04c23e8b271e8699912166929fa8e201 | [] | no_license | shoichi0599/cpp_tutorial | 10adfa7fc4b089902b650bb1c02c1193ec9594af | c3fc64a28969167e89a8b26449c2744ec4122aa6 | refs/heads/master | 2020-04-07T01:42:40.381589 | 2018-12-01T07:31:20 | 2018-12-01T07:31:20 | 157,949,087 | 0 | 0 | null | 2018-12-01T07:29:43 | 2018-11-17T04:01:29 | C++ | UTF-8 | C++ | false | false | 144 | cc | // Hellow World
// A basic program
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}
| [
"shoichi.programming@gmail.com"
] | shoichi.programming@gmail.com |
669bb0ba08a117edec5266276f26c34e79cd1fb6 | 28831c88364813222cc2746c7feac5761b709f8d | /Project_2/Project1/CandidateType.h | d0aa20bf1cdb445dc690d481ab0f99ae1ebe24dc | [] | no_license | williamblood/kingdoms | 85fd648498fbe9b5a7726e8412603da3ceff49e6 | e6a86f6fdb88301a0f8b3c53399b5a18aa36cde9 | refs/heads/master | 2022-07-24T18:31:37.266402 | 2020-05-22T04:35:30 | 2020-05-22T04:35:30 | 264,338,581 | 0 | 3 | null | 2020-05-16T08:31:33 | 2020-05-16T01:57:33 | C++ | UTF-8 | C++ | false | false | 1,153 | h | /*
KaibaCorp
Bearden, Reese (TTh 6:30)
Blood, William (TTh 6:30)
Diep, Vincent (TTh 2:20)
Huynh, Andy (TTh 6:30)
Nguyen, Andrew (MW 11:10)
May 12, 2020
CS A250
Project 2
*/
#ifndef CANDIDATETYPE_H
#define CANDIDATETYPE_H
#include "CharacterType.h"
const int NUM_OF_KINGDOMS = 7; // this is the capacity of the array
const std::string KINGDOMS[] = {
"The North",
"The Vale",
"The Stormlands",
"The Reach",
"The Westerlands",
"The Iron Islands",
"Dorne"
};
class CandidateType : public CharacterType
{
public:
// Default constructor
CandidateType();
// Copy constructor
CandidateType(const CandidateType& other);
// Copy assignment operator
CandidateType& operator=(const CandidateType& other);
// updateVotesByKingdom
void updateVotesByKingdom(int index, int numOfVotes);
// getTotalVotes
int getTotalVotes() const;
// getVotesByKingdom
int getVotesByKingdom(int index) const;
// printCandidateInfo
void printCandidateInfo() const;
// printCandidateTotalVotes
void printCandidateTotalVotes() const;
// Destructor
~CandidateType();
private:
int totalVotes;
int numOfKingdoms;
int* kingdomVotes;
};
#endif | [
"w.blood@icloud.com"
] | w.blood@icloud.com |
dbab915473a26b97ad6949e34a372b27c57c95e8 | d4e7817e821c48b77f38eaad09e4f6c0e353e4af | /include/elemental/matrices/DiscreteFourier.hpp | 8d5db35cb10251678328ed47a1906a315aa4cc78 | [] | no_license | ahmadia/Elemental-1 | 711cea2a6fbcb1d2f5e3beca091ca7c9688afd2f | f9a82c76a06728e9e04a4316e41803efbadb5a19 | refs/heads/master | 2021-01-18T08:19:41.737484 | 2013-05-12T06:07:32 | 2013-05-12T06:07:32 | 10,011,794 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,652 | hpp | /*
Copyright (c) 2009-2013, Jack Poulson
All rights reserved.
This file is part of Elemental and is under the BSD 2-Clause License,
which can be found in the LICENSE file in the root directory, or at
http://opensource.org/licenses/BSD-2-Clause
*/
#pragma once
#ifndef MATRICES_DISCRETEFOURIER_HPP
#define MATRICES_DISCRETEFOURIER_HPP
namespace elem {
template<typename R>
inline void
DiscreteFourier( Matrix<Complex<R> >& A, int n )
{
#ifndef RELEASE
CallStackEntry entry("DiscreteFourier");
#endif
A.ResizeTo( n, n );
MakeDiscreteFourier( A );
}
template<typename R,Distribution U,Distribution V>
inline void
DiscreteFourier( DistMatrix<Complex<R>,U,V>& A, int n )
{
#ifndef RELEASE
CallStackEntry entry("DiscreteFourier");
#endif
A.ResizeTo( n, n );
MakeDiscreteFourier( A );
}
template<typename R>
inline void
MakeDiscreteFourier( Matrix<Complex<R> >& A )
{
#ifndef RELEASE
CallStackEntry entry("MakeDiscreteFourier");
#endif
typedef Complex<R> F;
const int m = A.Height();
const int n = A.Width();
if( m != n )
throw std::logic_error("Cannot make a non-square DFT matrix");
const R pi = 4*Atan( R(1) );
const F nSqrt = Sqrt( R(n) );
for( int j=0; j<n; ++j )
{
for( int i=0; i<m; ++i )
{
const R theta = -2*pi*i*j/n;
A.Set( i, j, Complex<R>(Cos(theta),Sin(theta))/nSqrt );
}
}
}
template<typename R,Distribution U,Distribution V>
inline void
MakeDiscreteFourier( DistMatrix<Complex<R>,U,V>& A )
{
#ifndef RELEASE
CallStackEntry entry("MakeDiscreteFourier");
#endif
typedef Complex<R> F;
const int m = A.Height();
const int n = A.Width();
if( m != n )
throw std::logic_error("Cannot make a non-square DFT matrix");
const R pi = 4*Atan( R(1) );
const F nSqrt = Sqrt( R(n) );
const int localHeight = A.LocalHeight();
const int localWidth = A.LocalWidth();
const int colShift = A.ColShift();
const int rowShift = A.RowShift();
const int colStride = A.ColStride();
const int rowStride = A.RowStride();
for( int jLocal=0; jLocal<localWidth; ++jLocal )
{
const int j = rowShift + jLocal*rowStride;
for( int iLocal=0; iLocal<localHeight; ++iLocal )
{
const int i = colShift + iLocal*colStride;
A.SetLocal( iLocal, jLocal, Exp(-2*pi*i*j/n)/nSqrt );
const R theta = -2*pi*i*j/n;
const Complex<R> alpha( Cos(theta), Sin(theta) );
A.SetLocal( iLocal, jLocal, alpha/nSqrt );
}
}
}
} // namespace elem
#endif // ifndef MATRICES_DISCRETEFOURIER_HPP
| [
"jack.poulson@gmail.com"
] | jack.poulson@gmail.com |
f779e9720c608a9ccf49a88cdb55c0eb02ca6bf8 | 83d52ae5413fc0613d2d9f1efbb1c1937f69264a | /src/memory.cpp | 44a0e9c72abc5c00411a62314a7d6a8da0fb9d09 | [
"MIT"
] | permissive | ixy-languages/ixy.cpp | 5a153a4a436c01e489972e1222124e794ae996c4 | c927c418b7ec350c4cc41f3795a1e8d346d1ea16 | refs/heads/master | 2023-04-25T09:15:25.643351 | 2021-05-14T10:38:24 | 2021-05-14T10:38:24 | 227,373,671 | 10 | 1 | MIT | 2020-08-24T13:53:10 | 2019-12-11T13:35:15 | C++ | UTF-8 | C++ | false | false | 1,883 | cpp | #include "memory.hpp"
#include "fs.hpp"
#include <sys/mman.h>
namespace ixy {
static uint32_t huge_pg_id;
auto memory_allocate_dma(size_t size, bool require_contiguous) -> dma_memory {
debug("allocating dma memory via huge page");
// round up to multiples of 2 MB if necessary, this is the wasteful part
// this could be fixed by co-locating allocations on the same page until a request would be too large
// when fixing this: make sure to align on 128 byte boundaries (82599 dma requirement)
if (size % HUGE_PAGE_SIZE) {
size = ((size >> HUGE_PAGE_BITS) + 1) << HUGE_PAGE_BITS;
}
if (require_contiguous && size > HUGE_PAGE_SIZE) {
// this is the place to implement larger contiguous physical mappings if that's ever needed
error("could not map physically contiguous memory");
}
// unique filename, C11 stdatomic.h requires a too recent gcc, we want to support gcc 4.8
uint32_t id = __sync_fetch_and_add(&huge_pg_id, 1);
fs::path path{"/mnt/huge/ixy-" + std::to_string(getpid()) + "-" + std::to_string(id)};
int fd = open(path.c_str(), O_CREAT | O_RDWR, S_IRWXU);
if (fd == -1) {
error("failed to open hugetlbfs file, check that /mnt/huge is mounted");
}
if (ftruncate(fd, static_cast<off_t>(size)) == -1) {
error("failed to allocate huge page memory, check hugetlbfs configuration");
}
void *virt_addr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_HUGETLB, fd, 0);
if (virt_addr == MAP_FAILED) {
error("failed to mmap huge page");
}
// never swap out DMA memory
if (mlock(virt_addr, size) == -1) {
error("disable swap for DMA memory");
}
// don't keep it around in the hugetlbfs
close(fd);
unlink(path.c_str());
return (dma_memory{virt_addr, virt_to_phys(virt_addr)});
}
} // namespace ixy
| [
"simon.ellmann@tum.de"
] | simon.ellmann@tum.de |
4ed108c83eac8383ff15b07b3ac693dff6f262ab | e34dce6dee9f4c969bfdbe7e33285e875d128342 | /Src/AsyncDB/ADBError.h | 04dbc12203ec04e30ce1087bccf7443d7beb5c17 | [] | no_license | Rogni/AsyncDB | 4ba393c2790f7e2fe945be821c30ba9604c8f018 | c5f546d73b7845dd9316ab05c36c46ee8870d526 | refs/heads/master | 2020-08-01T20:47:36.468780 | 2019-10-17T12:36:59 | 2019-10-17T12:36:59 | 211,112,461 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 561 | h | #ifndef ADBERROR_H
#define ADBERROR_H
#include <QString>
#include <memory>
class ADBError
{
QString m_title;
QString m_description;
private:
ADBError() = default;
ADBError(QString title, QString description);
public:
typedef std::shared_ptr<ADBError> Ptr;
typedef std::weak_ptr<ADBError> WPtr;
static Ptr make(QString title, QString description);
QString title() const;
void setTitle(const QString &title);
QString description() const;
void setDescription(const QString &description);
};
#endif // ADBERROR_H
| [
"maktrefa@gmail.com"
] | maktrefa@gmail.com |
7f41662dfd07a667f4b04ca1e744f2081b8dfdab | 85299b50c36911427c47f49e84993ca0350be173 | /Cplus/Acwing/Dp/miniToll.cc | 962b637e50d3831b2e4b46fcf1921968a814d7a3 | [] | no_license | cogitates/Code | 15f4f5907478d4bd21ab3c7cc74f9afc3d6ae632 | d33d9bd99611a58b1192a23bc90d6f79253b5936 | refs/heads/master | 2021-05-18T07:28:33.140308 | 2020-06-27T12:16:34 | 2020-06-27T12:16:34 | 251,179,703 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 953 | cc | // 最低通行费用
// https://www.acwing.com/solution/acwing/content/5011/
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int N = 110; // 有限集数据规模
// 动态规划算法解决的是 **有限集中在给定约束条件下的最优化问题** 。
int cost[N][N]; // 给定约束
int f[N][N]; // 状态表示
int main(){
int n ;
cin >> n;
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
cin >> cost[i][j];
}
}
for(int i = 1;i <= n;i++){
for(int j = 1;j <= n;j++){
if(i == 1 && j == 1) f[i][j] = cost[i][j]; // 特判左上角
else{
f[i][j] = INF;
if(i > 1) f[i][j] = min(f[i][j],f[i-1][j] + cost[i][j]); // 不在第一行
if(j > 1) f[i][j] = min(f[i][j],f[i][j-1] + cost[i][j]); // 不在第一列
}
}
}
cout<< f[n][n] << endl;
return 0;
} | [
"weifengzxq@gmail.com"
] | weifengzxq@gmail.com |
18faaf1a153a054b6d0f95d8154eec0ec890020e | 84f620e4414e1e88f2cd7c0d1c79448d344cc7c4 | /src/s390/interface-descriptors-s390.cc | 83c08782d60725fee3abdcb0159fb9bf63b3e363 | [
"BSD-3-Clause",
"SunPro",
"bzip2-1.0.6"
] | permissive | raymond-cai/v8 | 0775b6d2a8297bdd928558e6af1bc200ca19c776 | b496a8b3de4148af06ff7fbe259f4e7bb6d61f36 | refs/heads/master | 2020-12-31T00:12:19.036155 | 2017-03-29T03:00:34 | 2017-03-29T03:24:07 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,864 | cc | // Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#if V8_TARGET_ARCH_S390
#include "src/interface-descriptors.h"
namespace v8 {
namespace internal {
const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
void CallInterfaceDescriptor::DefaultInitializePlatformSpecific(
CallInterfaceDescriptorData* data, int register_parameter_count) {
const Register default_stub_registers[] = {r2, r3, r4, r5, r6};
CHECK_LE(static_cast<size_t>(register_parameter_count),
arraysize(default_stub_registers));
data->InitializePlatformSpecific(register_parameter_count,
default_stub_registers);
}
const Register FastNewFunctionContextDescriptor::FunctionRegister() {
return r3;
}
const Register FastNewFunctionContextDescriptor::SlotsRegister() { return r2; }
const Register LoadDescriptor::ReceiverRegister() { return r3; }
const Register LoadDescriptor::NameRegister() { return r4; }
const Register LoadDescriptor::SlotRegister() { return r2; }
const Register LoadWithVectorDescriptor::VectorRegister() { return r5; }
const Register LoadICProtoArrayDescriptor::HandlerRegister() { return r6; }
const Register StoreDescriptor::ReceiverRegister() { return r3; }
const Register StoreDescriptor::NameRegister() { return r4; }
const Register StoreDescriptor::ValueRegister() { return r2; }
const Register StoreDescriptor::SlotRegister() { return r6; }
const Register StoreWithVectorDescriptor::VectorRegister() { return r5; }
const Register StoreTransitionDescriptor::SlotRegister() { return r6; }
const Register StoreTransitionDescriptor::VectorRegister() { return r5; }
const Register StoreTransitionDescriptor::MapRegister() { return r7; }
const Register StringCompareDescriptor::LeftRegister() { return r3; }
const Register StringCompareDescriptor::RightRegister() { return r2; }
const Register ApiGetterDescriptor::HolderRegister() { return r2; }
const Register ApiGetterDescriptor::CallbackRegister() { return r5; }
const Register MathPowTaggedDescriptor::exponent() { return r4; }
const Register MathPowIntegerDescriptor::exponent() {
return MathPowTaggedDescriptor::exponent();
}
const Register RegExpExecDescriptor::StringRegister() { return r2; }
const Register RegExpExecDescriptor::LastIndexRegister() { return r3; }
const Register RegExpExecDescriptor::StringStartRegister() { return r4; }
const Register RegExpExecDescriptor::StringEndRegister() { return r5; }
const Register RegExpExecDescriptor::CodeRegister() { return r9; }
const Register GrowArrayElementsDescriptor::ObjectRegister() { return r2; }
const Register GrowArrayElementsDescriptor::KeyRegister() { return r5; }
void FastNewClosureDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r4, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
// static
const Register TypeConversionDescriptor::ArgumentRegister() { return r2; }
void TypeofDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneRegExpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r5, r4, r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r5, r4, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r5, r4, r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r4, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CreateWeakCellDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r4, r5, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallICTrampolineDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r2, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallICDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r2, r5, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallConstructDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r2 : number of arguments
// r3 : the function to call
// r4 : feedback vector
// r5 : slot in feedback vector (Smi, for RecordCallTarget)
// r6 : new target (for IsSuperConstructorCall)
// TODO(turbofan): So far we don't gather type feedback and hence skip the
// slot parameter, but ArrayConstructStub needs the vector to be undefined.
Register registers[] = {r2, r3, r6, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallTrampolineDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r2 : number of arguments
// r3 : the target to call
Register registers[] = {r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallForwardVarargsDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r4 : start index (to support rest parameters)
// r3 : the target to call
Register registers[] = {r3, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructStubDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r2 : number of arguments
// r3 : the target to call
// r5 : the new target
// r4 : allocation site or undefined
Register registers[] = {r3, r5, r2, r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ConstructTrampolineDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// r2 : number of arguments
// r3 : the target to call
// r5 : the new target
Register registers[] = {r3, r5, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void TransitionElementsKindDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r2, r3};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
data->InitializePlatformSpecific(0, nullptr, nullptr);
}
void ArrayConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// kTarget, kNewTarget, kActualArgumentsCount, kAllocationSite
Register registers[] = {r3, r5, r2, r4};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ArrayNoArgumentConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
// r2 -- number of arguments
// r3 -- function
// r4 -- allocation site with elements kind
Register registers[] = {r3, r4, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArraySingleArgumentConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
// r2 -- number of arguments
// r3 -- function
// r4 -- allocation site with elements kind
Register registers[] = {r3, r4, r2};
data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
}
void ArrayNArgumentsConstructorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (constructor pointer, and single argument)
Register registers[] = {r3, r4, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void VarArgFunctionDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// stack param count needs (arg count)
Register registers[] = {r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CompareDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r4, r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void BinaryOpWithVectorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
// register state
// r3 -- lhs
// r2 -- rhs
// r6 -- slot id
// r5 -- vector
Register registers[] = {r3, r2, r6, r5};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CountOpDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r4};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void StringAddDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {r3, r2};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void KeyedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r4, // key
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void NamedDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r4, // name
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void CallHandlerDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r2, // receiver
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r3, // JSFunction
r5, // the new target
r2, // actual number of arguments
r4, // expected number of arguments
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ApiCallbackDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r2, // callee
r6, // call_data
r4, // holder
r3, // api_function_address
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InterpreterDispatchDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
kInterpreterAccumulatorRegister, kInterpreterBytecodeOffsetRegister,
kInterpreterBytecodeArrayRegister, kInterpreterDispatchTableRegister};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InterpreterPushArgsAndCallDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r2, // argument count (not including receiver)
r4, // address of first argument
r3 // the target callable to be call
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InterpreterPushArgsAndConstructDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r2, // argument count (not including receiver)
r5, // new target
r3, // constructor to call
r4, // allocation site feedback if available, undefined otherwise
r6 // address of the first argument
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InterpreterPushArgsAndConstructArrayDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r2, // argument count (not including receiver)
r3, // target to call checked to be Array function
r4, // allocation site feedback if available, undefined otherwise
r5 // address of the first argument
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void InterpreterCEntryDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r2, // argument count (argc)
r4, // address of first argument (argv)
r3 // the runtime function to call
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void ResumeGeneratorDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r2, // the value to pass to the generator
r3, // the JSGeneratorObject to resume
r4 // the resume mode (tagged)
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
void FrameDropperTrampolineDescriptor::InitializePlatformSpecific(
CallInterfaceDescriptorData* data) {
Register registers[] = {
r3, // loaded new FP
};
data->InitializePlatformSpecific(arraysize(registers), registers);
}
} // namespace internal
} // namespace v8
#endif // V8_TARGET_ARCH_S390
| [
"commit-bot@chromium.org"
] | commit-bot@chromium.org |
15a8019bcaad59529c6331de94621b0d27bf6b13 | fd87fbf08aaa8006a5655c19a20051901f5a032b | /LeetCode/49. 字母异位词分组.cpp | 889417649400aee52fc8f23320075d42ff721246 | [] | no_license | Smartuil/LeetCode | c43ad3a32e7ab55e97f9e30183c9dd760ada4015 | c4f31ab91d7073aa2eda8bce58e92e974d5eded8 | refs/heads/master | 2023-06-22T18:54:05.552298 | 2023-06-14T03:10:51 | 2023-06-14T03:10:51 | 243,493,761 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,961 | cpp | #include "iostream"
#include "string"
#include "vector"
#include "map"
#include <algorithm>
#include <unordered_map>
using namespace std;
//class Solution {
//public:
// vector<vector<string>> groupAnagrams(vector<string>& strs) {
// if (strs.empty()) {
// return {};
// }
// map<char, int> index;
// vector<vector<int>> tmp;
// vector<int> tmp2;
// vector<vector<string>> ret;
// vector<string> ret2;
// int len = strs.size();
// index.insert(make_pair('a', 1));
// index.insert(make_pair('b', 2));
// index.insert(make_pair('c', 3));
// index.insert(make_pair('d', 4));
// index.insert(make_pair('e', 5));
// index.insert(make_pair('f', 6));
// index.insert(make_pair('g', 7));
// index.insert(make_pair('h', 8));
// index.insert(make_pair('i', 9));
// index.insert(make_pair('j', 10));
// index.insert(make_pair('k', 11));
// index.insert(make_pair('l', 12));
// index.insert(make_pair('m', 13));
// index.insert(make_pair('n', 14));
// index.insert(make_pair('o', 15));
// index.insert(make_pair('p', 16));
// index.insert(make_pair('q', 17));
// index.insert(make_pair('r', 18));
// index.insert(make_pair('s', 19));
// index.insert(make_pair('t', 20));
// index.insert(make_pair('u', 21));
// index.insert(make_pair('v', 22));
// index.insert(make_pair('w', 23));
// index.insert(make_pair('x', 24));
// index.insert(make_pair('y', 25));
// index.insert(make_pair('z', 26));
// for (int i = 0; i < len; i++) {
// tmp2.clear();
// for (int j = 0; j < strs[i].size(); j++) {
// auto iter = index.find(strs[i][j]);
// tmp2.push_back(iter->second);
// sort(tmp2.begin(), tmp2.end());
// }
// tmp.push_back(tmp2);
// }
//
// int len = tmp.size();
// vector<bool> isUse(len, false);
// int i = 0, j = 1;
// while(i < len) {
// if (isUse[i] == true) {
// i++;
// continue;
// }
// j = i + 1;
// ret2.clear();
// ret2.push_back(strs[i]);
// while (j < len) {
// if (isUse[j] == true) {
// j++;
// continue;
// }
// if (tmp[i] == tmp[j]) {
// isUse[j] = true;
// ret2.push_back(strs[j]);
// }
// j++;
// }
// ret.push_back(ret2);
// i++;
// }
// return ret;
// }
//};
class Solution {
public:
vector<vector<string>> groupAnagrams(vector<string>& strs) {
vector<vector<string>> res;
int sub = 0;
string tmp;
unordered_map<string, int> work;
for (auto str : strs)
{
tmp = str;
sort(tmp.begin(), tmp.end());
if (work.count(tmp))
{
res[work[tmp]].push_back(str);
}
else
{
vector<string> vec(1, str);
res.push_back(vec);
work[tmp] = sub++;
}
}
return res;
}
};
int main() {
Solution *solution = new Solution;
vector<string> strs = { "eat", "tea", "tan", "ate", "nat", "bat" };
vector<vector<string>> ret = solution->groupAnagrams(strs);
cout << "[" << endl;
for (auto i : ret) {
cout << "[";
for (auto j : i) {
cout << j;
}
cout << "]" << endl;
}
cout << "]";
return 0;
} | [
"563412673@qq.com"
] | 563412673@qq.com |
3202b28555502ca72873b810693ee8f3c152b20a | 777fc408df508a66f8ba82e662153b17938a8a11 | /Max/include/maxscript/kernel/value.h | a149ab0b42885b92d8171876b3c5937d18b2634f | [] | no_license | bingeun/BG_DX | 4b89a891ea2aadaf7ea8eab6b18baa5f76185766 | e3182934ed276de58c1ac136c42ec6a8b8f6861c | refs/heads/master | 2020-05-22T08:07:51.033127 | 2016-10-21T14:04:18 | 2016-10-21T14:04:18 | 61,520,947 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,513 | h | /* Value.h - metaclass system MAXScript values
*
* All MAXScript-specific C++ objects are subclasses of a single root class, Value,
* and allocated & automatically freed in a specially maintained heap. There is also
* a metaclass system to provide a runtime type calculus for the scripter. Value subclasses
* are divided into those that are scripter-visible, (ie, may wind up as objects that the
* scripter may pass around or store in variables, etc.), and those that are entirely
* internal to the scripter operation (such as thunks, etc.). The scripter-visible
* classes (the majority) are represented in the metasystem by instances of separate
* metaclasses. The metaclasses are all subclasses of ValueMetaClass, the metaclass of
* a class X is named XClass and its sole instance is X_class. The class instances are
* made visible in globals (usually) named X.
*
* Each Value instance has a tag word that either contains a pointer to the instance's
* class instance (in the case of scripter-visible classes) or the reserved value INTERNAL_CLASS_TAG.
* This value is used in performing runtimne type tests and for yielding results to classOf
* methods.
*
* The metaclass, its instance and some of the class calculus methods are usually defined via
* a bunch of macros defined here (see visible_class, visible_class_instance, etc.)
*
* Some of the classes are can be instanced directly as literals in a script, such as strings,
* Point3s, arrays, etc. Some others are instantiable directly by applying the class value
* to a set of initializing parameters, ie, using the class as a function in a function call,
* for example, ray, quat, interval, etc. These are defined via a variant macro: applyable_class().
* A special case of this is provided in the MAXWrapper subsytem for creatable MAX objects, such as
* boxes, lights, camera, etc.. These are represnted by instances of the class MAXClass, and again, thses
* instances are exposed in globals to be applied to creation paramters. These instances
* contain a lot of property metadata and are defined in MAX_classes.cpp. See MAXObject.h for more
* info.
*
* Copyright (c) John Wainwright, 1996
*
*/
#pragma once
#include "../ScripterExport.h"
#include "collectable.h"
#include "interupts.h"
#include "MAXScript_TLS.h"
#include "../macros/value_locals.h"
#include "MaxscriptTypedefs.h"
#include "../../matrix3.h"
#include "../../box2.h"
#include "../../acolor.h"
#include "../../interval.h"
#include "../../quat.h"
#include "../../ifnpub.h"
// forward declarations
class BitArray;
class CharStream;
class Name;
class PathName;
class Undefined;
class UserProp;
class UserGeneric;
class CallContext;
class ValueMetaClass;
struct node_map;
class Mtl;
class Texmap;
class MtlBase;
class Modifier;
class Control;
class Atmospheric;
class Effect;
class IMultiPassCameraEffect;
class ShadowType;
class FPInterfaceDesc;
class FilterKernel;
class ITrackViewNode;
class NURBSIndependentPoint;
class NURBSPoint;
class NURBSObject;
class NURBSControlVertex;
class NURBSCurve;
class NURBSCVCurve;
class NURBSSurface;
class NURBSTexturePoint;
class NURBSSet;
class ReferenceTarget;
class Mesh;
class Thunk;
class Renderer;
class NURBSTextureSurface;
class NURBSDisplay;
class TessApprox;
class SelectionIterator;
#include "../macros/define_external_functions.h"
# include "../protocols/corenames.inl"
// forward declarations...
extern ScripterExport Undefined undefined;
extern ScripterExport bool dontThrowAccessorError;
// the root MAXScript class
class Value : public Collectable
{
private:
ScripterExport static Matrix3 s_error_matrix;
ScripterExport static Box2 s_error_box2;
public:
#pragma warning(push)
#pragma warning(disable:4100)
ValueMetaClass* tag; // runtime type tag; filled in by subclasses
ScripterExport virtual BOOL is_kind_of(ValueMetaClass* c);
ScripterExport virtual ValueMetaClass* local_base_class(); // local base class in this class's plug-in
virtual Value* eval() { check_interrupts(); return this; }
virtual Value* eval_no_wrapper() { check_interrupts(); return this; }
ScripterExport virtual Value* apply(Value** arglist, int count, CallContext* cc=NULL);
ScripterExport virtual Value* apply_no_alloc_frame(Value** arglist, int count, CallContext* cc=NULL);
virtual void export_to_scripter() { }
virtual Value* map(node_map& m) { unimplemented(_M("map"), this) ; return this; }
virtual Value* map_path(PathName* path, node_map& m) { unimplemented(_M("map_path"), this) ; return this; }
virtual Value* find_first(BOOL (*test_fn)(INode* node, int level, const void* arg), const void* test_arg) { unimplemented(_M("find_first"), this) ; return this; }
virtual Value* get_path(PathName* path) { unimplemented(_M("get"), this) ; return this; }
ScripterExport virtual void sprin1(CharStream* stream);
ScripterExport virtual void sprint(CharStream* stream);
virtual void prin1() { sprin1(thread_local(current_stdout)); }
virtual void print() { sprint(thread_local(current_stdout)); }
/* include all the protocol declarations */
#include "../macros/define_abstract_functions.h"
# include "../protocols/math.inl"
# include "../protocols/vector.inl"
# include "../protocols/matrix.inl"
# include "../protocols/quat.inl"
# include "../protocols/arrays.inl"
# include "../protocols/streams.inl"
# include "../protocols/strings.inl"
# include "../protocols/time.inl"
# include "../protocols/color.inl"
# include "../protocols/node.inl"
# include "../protocols/controller.inl"
# include "../protocols/primitives.inl"
# include "../protocols/generics.inl"
# include "../protocols/bitmaps.inl"
# include "../protocols/textures.inl"
# include "../protocols/atmospherics.inl"
# // Moved to ../maxwrapper/mxsnurbs.h into class NURBSObjectValue
# include "../protocols/cameratracker.inl"
# include "../protocols/bigmatrix.inl"
# include "../protocols/box.inl"
# include "../protocols/physiqueblend.inl"
# include "../protocols/physiquemod.inl"
# include "../protocols/biped.inl"
# include "../protocols/notekey.inl"
# include "../protocols/xrefs.inl"
ScripterExport virtual Class_ID get_max_class_id() { return Class_ID(0, 0); }
ScripterExport virtual Value* delete_vf(Value** arglist, int arg_count) { ABSTRACT_FUNCTION(_M("delete"), this, Value*); }
ScripterExport virtual Value* clearSelection_vf(Value** arglist, int arg_count) { ABSTRACT_FUNCTION(_M("clearSelection"), this, Value*); }
#undef def_generic
#define def_generic(fn, name) ScripterExport virtual Value* fn##_vf(Value** arglist, int arg_count);
# include "../protocols/kernel.inl"
virtual float to_float() { ABSTRACT_CONVERTER(float, Float); }
virtual double to_double() { ABSTRACT_CONVERTER(double, Double); }
virtual const MCHAR* to_string() { ABSTRACT_CONVERTER(const MCHAR*, String); }
virtual MSTR to_mstr() { return MSTR(to_string()); }
virtual MSTR to_filename() { ABSTRACT_CONVERTER(const MCHAR*, FileName); }
virtual int to_int() { ABSTRACT_CONVERTER(int, Integer); }
virtual INT64 to_int64() { ABSTRACT_CONVERTER(INT64, Integer64); }
virtual INT_PTR to_intptr() { ABSTRACT_CONVERTER(INT_PTR, IntegerPtr); }
virtual BOOL to_bool() { ABSTRACT_CONVERTER(BOOL, Boolean); }
virtual BitArray& to_bitarray() { throw ConversionError (this, _M("BitArray")); return *(BitArray*)NULL; }
virtual Point4 to_point4() { ABSTRACT_CONVERTER(Point4, Point4); }
virtual Point3 to_point3() { ABSTRACT_CONVERTER(Point3, Point3); }
virtual Point2 to_point2() { ABSTRACT_CONVERTER(Point2, Point2); }
virtual AColor to_acolor() { throw ConversionError (this, _M("Color")); return AColor(0,0,0); }
virtual COLORREF to_colorref() { throw ConversionError (this, _M("Color")); return RGB(0,0,0); }
virtual INode* to_node() { ABSTRACT_CONVERTER(INode*, <node>); }
virtual Ray to_ray() { throw ConversionError (this, _M("Ray")); return Ray(); }
virtual Interval to_interval() { throw ConversionError (this, _M("Interval")); return Interval(); }
virtual Quat to_quat() { throw ConversionError (this, _M("Quaternion")); return Quat(); }
virtual AngAxis to_angaxis() { throw ConversionError (this, _M("AngleAxis")); return AngAxis(); }
virtual Matrix3& to_matrix3() { throw ConversionError (this, _M("Matrix")); return s_error_matrix; }
virtual float* to_eulerangles() { ABSTRACT_CONVERTER(float*, Float); }
virtual Mtl* to_mtl() { ABSTRACT_CONVERTER(Mtl*, Material); }
virtual Texmap* to_texmap() { ABSTRACT_CONVERTER(Texmap*, TextureMap); }
virtual MtlBase* to_mtlbase() { ABSTRACT_CONVERTER(MtlBase*, MtlBase); }
virtual Modifier* to_modifier() { ABSTRACT_CONVERTER(Modifier*, Modifier); }
virtual TimeValue to_timevalue() { ABSTRACT_CONVERTER(TimeValue, Time); }
virtual Control* to_controller() { ABSTRACT_CONVERTER(Control*, Controller); }
virtual Atmospheric* to_atmospheric() { ABSTRACT_CONVERTER(Atmospheric*, Atmospheric); }
virtual Effect* to_effect() { ABSTRACT_CONVERTER(Effect*, Effect); } // RK: Added this
virtual IMultiPassCameraEffect* to_mpassCamEffect() { ABSTRACT_CONVERTER(IMultiPassCameraEffect*, Effect); } // LAM: Added this
virtual ShadowType* to_shadowtype() { ABSTRACT_CONVERTER(ShadowType*, ShadowType); } // RK: Added this
virtual FilterKernel* to_filter() { ABSTRACT_CONVERTER(FilterKernel*, FilterKernel); } // RK: Added this
virtual INode* to_rootnode() { ABSTRACT_CONVERTER(INode*, <root>); } // RK: Added this
virtual ITrackViewNode* to_trackviewnode() { ABSTRACT_CONVERTER(ITrackViewNode*, TrackViewNode); }
virtual NURBSIndependentPoint* to_nurbsindependentpoint() { throw ConversionError (this, _M("NURBSIndependentPoint")); return (NURBSIndependentPoint*)0; }
virtual NURBSPoint* to_nurbspoint() { throw ConversionError (this, _M("NURBSPoint")); return (NURBSPoint*)0; }
virtual NURBSObject* to_nurbsobject() { throw ConversionError (this, _M("NURBSObject")); return (NURBSObject*)0; }
virtual NURBSControlVertex* to_nurbscontrolvertex() { throw ConversionError (this, _M("NURBSControlVertex")); return (NURBSControlVertex*)0; }
virtual NURBSCurve* to_nurbscurve() { throw ConversionError (this, _M("NURBSCurve")); return (NURBSCurve*)0; }
virtual NURBSCVCurve* to_nurbscvcurve() { throw ConversionError (this, _M("NURBSCVCurve")); return (NURBSCVCurve*)0; }
virtual NURBSSurface* to_nurbssurface() { throw ConversionError (this, _M("NURBSSurface")); return (NURBSSurface*)0; }
virtual NURBSTexturePoint* to_nurbstexturepoint() { throw ConversionError (this, _M("NURBSTexturePoint")); return (NURBSTexturePoint*)0; }
virtual NURBSSet* to_nurbsset() { throw ConversionError (this, _M("NURBSSet")); return (NURBSSet*)0; }
virtual ReferenceTarget* to_reftarg() { ABSTRACT_CONVERTER(ReferenceTarget*, MaxObject); }
virtual Mesh* to_mesh() { ABSTRACT_CONVERTER(Mesh*, Mesh); }
virtual Thunk* to_thunk() { ABSTRACT_CONVERTER(Thunk*, &-reference); }
virtual void to_fpvalue(FPValue& v) { throw ConversionError (this, _M("FPValue")); }
virtual Renderer* to_renderer() { ABSTRACT_CONVERTER(Renderer*, Renderer); } // LAM: Added this 9/15/01
virtual Box2& to_box2() { throw ConversionError (this, _M("Box2")); return s_error_box2; }
virtual NURBSTextureSurface* to_nurbstexturesurface() { throw ConversionError (this, _M("NURBSTextureSurface")); return (NURBSTextureSurface*)0; }
virtual NURBSDisplay* to_nurbsdisplay() { throw ConversionError (this, _M("NURBSDisplay")); return (NURBSDisplay*)0; }
virtual TessApprox* to_tessapprox() { throw ConversionError (this, _M("TessApprox")); return (TessApprox*)0; }
virtual Value* widen_to(Value* arg, Value** arg_list) { ABSTRACT_WIDENER(arg); }
virtual BOOL comparable(Value* arg) { return (tag == arg->tag); }
virtual BOOL is_const() { return FALSE; }
// LAM - 7/8/03 - defect 504956 - following identifies classes that derive from MAXWrapper. Only other implementation is in MAXWrapper
// used by garbage collector to prevent collection of MAXWrapper-derived values while doing light collection
virtual BOOL derives_from_MAXWrapper() { return FALSE; }
ScripterExport virtual Value* get_property(Value** arg_list, int count);
ScripterExport virtual Value* set_property(Value** arg_list, int count);
ScripterExport Value* _get_property(Value* prop);
ScripterExport virtual Value* _set_property(Value* prop, Value* val);
virtual Value* get_container_property(Value* prop, Value* cur_prop) { if (!dontThrowAccessorError) throw AccessorError (cur_prop, prop); return NULL; }
virtual Value* set_container_property(Value* prop, Value* val, Value* cur_prop) { throw AccessorError (cur_prop, prop); return NULL;}
// polymorphic default type predicates - abstracted over by is_x(v) macros as needed
virtual BOOL _is_collection() { return FALSE; }
virtual BOOL _is_charstream() { return FALSE; }
virtual BOOL _is_rolloutcontrol() { return FALSE; }
virtual BOOL _is_rolloutthunk() { return FALSE; }
virtual BOOL _is_function() { return FALSE; }
virtual BOOL _is_selection() { return FALSE; }
virtual BOOL _is_thunk() { return FALSE; }
virtual BOOL _is_indirect_thunk() { return FALSE; }
// yield selection set iterator if you can
virtual SelectionIterator* selection_iterator() { throw RuntimeError (_M("Operation requires a selection (Array or BitArray)")); return NULL; }
// scene persistence functions
ScripterExport virtual IOResult Save(ISave* isave);
// the Load fn is a static method on loadbale classes, see SceneIO.cpp & .h and each loadable class
// called during MAX exit to have all MAXScript-side refs dropped (main implementation in MAXWrapper)
virtual void drop_MAX_refs() { }
// access ID'd FPInterface if supported
virtual BaseInterface* GetInterface(Interface_ID id) { return NULL; }
// stack allocation routines
ScripterExport Value* make_heap_permanent();
ScripterExport Value* make_heap_static() { Value* v = make_heap_permanent(); v->flags |= GC_STATIC; return v; }
ScripterExport Value* get_heap_ptr() { if (!has_heap_copy()) return migrate_to_heap(); return is_on_stack() ? get_stack_heap_ptr() : this; }
ScripterExport Value* get_stack_heap_ptr() { return (Value*)next; }
ScripterExport Value* migrate_to_heap();
ScripterExport Value* get_live_ptr() { return is_on_stack() && has_heap_copy() ? get_stack_heap_ptr() : this; }
#pragma warning(pop)
};
inline Value* heap_ptr(Value* v) { return v ? v->get_heap_ptr() : NULL; } // ensure v is in heap, migrate if not, return heap pointer
inline Value* live_ptr(Value* v) { return v->get_live_ptr(); } // get live pointer, if on stack & migrated, heap copy is live
/* ---------- the base class for all metaclasses ---------- */
class MetaClassClass;
extern MetaClassClass value_metaclass; // the metaclass class
class ValueMetaClass : public Value
{
// Whether the generic functions and property setters of class instances can be called from debugger thread stored
// in Collectable::flags3 - bit 0. Default is false.
public:
const MCHAR* name;
UserProp* user_props; // additional, user defined property accessors
short uprop_count;
UserGeneric* user_gens; // " " " generic fns
short ugen_count;
Tab<FPInterfaceDesc*> prop_interfaces; // static interfaces who methods appear as properties on instances of the class
ValueMetaClass() { }
ScripterExport ValueMetaClass(const MCHAR* iname);
ScripterExport ~ValueMetaClass();
ScripterExport BOOL is_kind_of(ValueMetaClass* c);
# define is_valueclass(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == (ValueMetaClass*)&value_metaclass)
ScripterExport void sprin1(CharStream* s);
ScripterExport void export_to_scripter();
ScripterExport void add_user_prop(const MCHAR* prop, value_cf getter, value_cf setter);
ScripterExport void add_user_generic(const MCHAR* name, value_cf fn);
ScripterExport UserGeneric* find_user_gen(Value* name);
ScripterExport UserProp* find_user_prop(Value* prop);
// static property interfaces
ScripterExport void add_prop_interface(FPInterfaceDesc* fpd) { prop_interfaces.Append(1, &fpd); }
ScripterExport int num_prop_interfaces() { return prop_interfaces.Count(); }
ScripterExport FPInterfaceDesc* get_prop_interface(int i) { return prop_interfaces[i]; }
};
#define CHECK_ARG_COUNT(fn, w, g) if ((w) != (g)) throw ArgCountError (_M(#fn), w, g)
#define classof_methods(_cls, _super) \
Value* classOf_vf(Value** arg_list, int count) \
{ \
UNUSED_PARAM(arg_list); \
CHECK_ARG_COUNT(classOf, 1, count + 1); \
return &_cls##_class; \
} \
Value* superClassOf_vf(Value** arg_list, int count) \
{ \
UNUSED_PARAM(arg_list); \
CHECK_ARG_COUNT(superClassOf, 1, count + 1); \
return &_super##_class; \
} \
Value* isKindOf_vf(Value** arg_list, int count) \
{ \
CHECK_ARG_COUNT(isKindOf, 2, count + 1); \
return (arg_list[0] == &_cls##_class) ? \
&true_value : \
_super::isKindOf_vf(arg_list, count); \
} \
BOOL is_kind_of(ValueMetaClass* c) \
{ \
return (c == &_cls##_class) ? 1 \
: _super::is_kind_of(c); \
}
#define visible_class(_cls) \
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name) : ValueMetaClass (name) { } \
void collect() { delete this; } \
}; \
extern ScripterExport _cls##Class _cls##_class;
#define visible_class_debug_ok(_cls) \
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name) : ValueMetaClass (name) { flags3 |= VALUE_FLAGBIT_0; } \
void collect() { delete this; } \
}; \
extern ScripterExport _cls##Class _cls##_class;
#define visible_class_s(_cls, _super) \
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name) : ValueMetaClass (name) { } \
void collect() { delete this; } \
Value* classOf_vf(Value** arg_list, int count) \
{ \
UNUSED_PARAM(arg_list); \
CHECK_ARG_COUNT(classOf, 1, count + 1); \
return &_super##_class; \
} \
Value* superClassOf_vf(Value** arg_list, int count) \
{ \
UNUSED_PARAM(arg_list); \
UNUSED_PARAM(count); \
return _super##_class.classOf_vf(NULL, 0); \
} \
}; \
extern ScripterExport _cls##Class _cls##_class;
#define applyable_class(_cls) \
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name) : ValueMetaClass (name) { }\
void collect() { delete this; } \
ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL); \
}; \
extern ScripterExport _cls##Class _cls##_class;
#define applyable_class_debug_ok(_cls) \
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name) : ValueMetaClass (name) { flags3 |= VALUE_FLAGBIT_0; }\
void collect() { delete this; } \
ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL); \
}; \
extern ScripterExport _cls##Class _cls##_class;
#define applyable_class_s(_cls, _super) \
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name) : ValueMetaClass (name) { }\
Value* classOf_vf(Value** arg_list, int count) \
{ \
UNUSED_PARAM(arg_list); \
CHECK_ARG_COUNT(classOf, 1, count + 1); \
return &_super##_class; \
} \
Value* superClassOf_vf(Value** arg_list, int count) \
{ \
UNUSED_PARAM(arg_list); \
UNUSED_PARAM(count); \
return _super##_class.classOf_vf(NULL, 0); \
} \
void collect() { delete this; } \
ScripterExport Value* apply(Value** arglist, int count, CallContext* cc=NULL); \
}; \
extern ScripterExport _cls##Class _cls##_class;
#define visible_class_instance(_cls, _name) \
ScripterExport _cls##Class _cls##_class (_M(_name));
#define invisible_class(_cls) \
class _cls##Class : public ValueMetaClass \
{ \
public: \
_cls##Class(const MCHAR* name) : ValueMetaClass (name) { } \
void collect() { delete this; } \
void export_to_scripter() { } \
}; \
extern ScripterExport _cls##Class _cls##_class;
#define invisible_class_instance(_cls, _name) \
ScripterExport _cls##Class _cls##_class (_M(_name));
#define class_tag(_cls) &_cls##_class
#define INTERNAL_CLASS_TAG ((ValueMetaClass*)0L)
#define INTERNAL_INDEX_THUNK_TAG ((ValueMetaClass*)1L)
#define INTERNAL_PROP_THUNK_TAG ((ValueMetaClass*)2L)
#define INTERNAL_LOCAL_THUNK_TAG ((ValueMetaClass*)3L)
#define INTERNAL_FREE_THUNK_TAG ((ValueMetaClass*)4L)
#define INTERNAL_RO_LOCAL_THUNK_TAG ((ValueMetaClass*)5L)
#define INTERNAL_CODE_TAG ((ValueMetaClass*)6L)
#define INTERNAL_SOURCEFILEWRAPPER_TAG ((ValueMetaClass*)7L)
#define INTERNAL_PIPE_TAG ((ValueMetaClass*)8L)
#define INTERNAL_TOOL_LOCAL_THUNK_TAG ((ValueMetaClass*)9L)
#define INTERNAL_GLOBAL_THUNK_TAG ((ValueMetaClass*)10L)
#define INTERNAL_CONST_GLOBAL_THUNK_TAG ((ValueMetaClass*)11L)
#define INTERNAL_SYS_GLOBAL_THUNK_TAG ((ValueMetaClass*)12L)
#define INTERNAL_PLUGIN_LOCAL_THUNK_TAG ((ValueMetaClass*)13L)
#define INTERNAL_PLUGIN_PARAM_THUNK_TAG ((ValueMetaClass*)14L)
#define INTERNAL_RCMENU_LOCAL_THUNK_TAG ((ValueMetaClass*)15L)
#define INTERNAL_STRUCT_MEM_THUNK_TAG ((ValueMetaClass*)16L)
#define INTERNAL_MSPLUGIN_TAG ((ValueMetaClass*)17L)
#define INTERNAL_STRUCT_TAG ((ValueMetaClass*)18L)
#define INTERNAL_MAKER_TAG ((ValueMetaClass*)19L)
#define INTERNAL_CODEBLOCK_LOCAL_TAG ((ValueMetaClass*)20L)
#define INTERNAL_CODEBLOCK_TAG ((ValueMetaClass*)21L)
#define INTERNAL_THUNK_REF_TAG ((ValueMetaClass*)22L)
#define INTERNAL_THUNK_DEREF_TAG ((ValueMetaClass*)23L)
#define INTERNAL_STRUCT_METHOD_TAG ((ValueMetaClass*)24L) // LAM - defect 307069
#define INTERNAL_MSPLUGIN_METHOD_TAG ((ValueMetaClass*)25L) // LAM - 9/6/02 - defect 291499
#define INTERNAL_CONTEXT_THUNK_TAG ((ValueMetaClass*)26L) // LAM - 2/8/05
#define INTERNAL_OWNER_THUNK_TAG ((ValueMetaClass*)27L) // LAM - 2/28/05
#define INTERNAL_RCMENU_ITEM_THUNK_TAG ((ValueMetaClass*)28L) // LAM - 3/21/05
#define INTERNAL_STANDINMSPLUGINCLASS_TAG ((ValueMetaClass*)29L) // LAM - 8/29/06
#define INTERNAL_SOURCEPOSWRAPPER_TAG ((ValueMetaClass*)30L) // LAM - 9/4/08
#define INTERNAL_TAGS ((ValueMetaClass*)100L) // must be higher than all internal tags
#ifndef DOXYGEN
visible_class_debug_ok (Value)
#endif
#define is_sourcepositionwrapper(v) ((v)->tag == INTERNAL_SOURCEPOSWRAPPER_TAG)
/* ---------- the distinguished value subclasses ---------- */
#ifndef DOXYGEN
visible_class_debug_ok (Boolean)
#endif
class Boolean;
class ValueLoader;
extern ScripterExport Boolean true_value;
extern ScripterExport Boolean false_value;
#pragma warning(push)
#pragma warning(disable:4100)
class Boolean : public Value
{
public:
Boolean() { tag = &Boolean_class; }
classof_methods (Boolean, Value);
void collect();
void sprin1(CharStream* s);
# define is_bool(v) ((DbgVerify(!is_sourcepositionwrapper(v)), (v))->tag == &Boolean_class)
Value* not_vf(Value**arg_list, int count);
Value* copy_vf(Value** arg_list, int count) { return this; }
BOOL to_bool() { return this == &true_value; }
void to_fpvalue(FPValue& v) { v.i = (this == &true_value) ? 1 : 0; v.type = (ParamType2)TYPE_BOOL; }
// scene I/O
IOResult Save(ISave* isave);
static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
};
/* ----- */
#ifndef DOXYGEN
visible_class_debug_ok (Undefined)
#endif
class Undefined : public Value
{
public:
Undefined() { tag = &Undefined_class; }
classof_methods (Undefined, Value);
void collect();
ScripterExport void sprin1(CharStream* s);
Value* copy_vf(Value** arg_list, int count) { return this; }
// scene I/O
IOResult Save(ISave* isave);
static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
Mtl* to_mtl() { return NULL; } // undefined is a NULL material
void to_fpvalue(FPValue& v);
};
extern ScripterExport Undefined undefined;
extern ScripterExport Undefined dontCollect;
extern ScripterExport Undefined loopExit;
/* ----- */
#ifndef DOXYGEN
visible_class_debug_ok (Ok)
#endif
class Ok : public Value
{
public:
Ok() { tag = &Ok_class; }
classof_methods (Ok, Value);
void collect();
ScripterExport void sprin1(CharStream* s);
Value* copy_vf(Value** arg_list, int count) { return this; }
// scene I/O
IOResult Save(ISave* isave);
static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
void to_fpvalue(FPValue& v);
};
extern ScripterExport Ok ok;
/* ----- */
#ifndef DOXYGEN
visible_class_debug_ok (Empty)
#endif
class Empty : public Value
{
public:
Empty() { tag = &Empty_class; }
classof_methods (Empty, Value);
void collect();
ScripterExport void sprin1(CharStream* s);
Value* copy_vf(Value** arg_list, int count) { return this; }
// scene I/O
IOResult Save(ISave* isave);
static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
void to_fpvalue(FPValue& v);
};
extern ScripterExport Empty empty;
/* ----- */
#ifndef DOXYGEN
visible_class_debug_ok (Unsupplied)
#endif
class Unsupplied : public Value
{
public:
Unsupplied() { tag = &Unsupplied_class; }
classof_methods (Unsupplied, Value);
void collect();
ScripterExport void sprin1(CharStream* s);
Value* copy_vf(Value** arg_list, int count) { return this; }
// scene I/O
IOResult Save(ISave* isave);
static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
void to_fpvalue(FPValue& v);
};
extern ScripterExport Unsupplied unsupplied;
/* ----- */
#ifndef DOXYGEN
visible_class_debug_ok (NoValue)
#endif
/*
The Class NoValue is for the Max Script function returning silent value, no output and printing log,
even without printing "OK" and "\n".
*/
class NoValue : public Value
{
public:
NoValue() { tag = &NoValue_class; }
classof_methods (NoValue, Value);
void collect();
ScripterExport void sprin1(CharStream* s);
Value* copy_vf(Value** arg_list, int count) { return this; }
// scene I/O
IOResult Save(ISave* isave);
static Value* Load(ILoad* iload, USHORT chunkID, ValueLoader* vload);
void to_fpvalue(FPValue& v);
ScripterExport virtual void sprint(CharStream* stream);
};
#pragma warning(pop)
extern ScripterExport NoValue noValue; | [
"bingeun@dreamwiz.com"
] | bingeun@dreamwiz.com |
834d7d053f4089ecd3b4402e7e74bbfd535c5d73 | 484cb345f43b38425279e42dd3cd320c779d1ea4 | /State_Machine/State_Machine/Automaton.cpp | afc104ac3a07984e79b086e0e2797e24bd1a3243 | [
"MIT"
] | permissive | DavidPetr/Internship_Tasks | 0e231bef90e4c93f2a2c19599f30395f25b49832 | 6c22cf2af667325553df99ebe79c3f5ebd741689 | refs/heads/master | 2020-05-06T20:32:43.091355 | 2019-06-27T11:20:48 | 2019-06-27T11:20:48 | 180,243,173 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,111 | cpp | #include "Automaton.h"
template<typename stateTemplate>
Automaton<stateTemplate>::Automaton(const Alphabet & inputAlphabet
, const Alphabet & outputAlphabet
, const TransmissionOperator<stateTemplate> & transOperator
, const stateTemplate & initialState
, const stateTemplate & finalState
, const System & SysType
, const std::string & input)
:
m_inputAlphabet(inputAlphabet),
m_outputAlphabet(outputAlphabet),
m_transmissionOperator(transOperator),
m_initialState(initialState),
m_SysType(SysType),
m_finalState(finalState)
{
for (auto i : input)
{
m_inputLine.push_back(i);
}
for (auto& key_value : m_transmissionOperator)
{
if (key_value.second == m_finalState)
{
m_minSecondFinalState = key_value.first.first;
break;
}
}
}
template<typename stateTemplate>
Automaton<stateTemplate>::~Automaton()
{
std::cout << std::endl << "Destructor Automaton!!!" << std::endl;
}
template<typename stateTemplate>
void Automaton<stateTemplate>::handler(const stateTemplate& errorState, const char& item)
{
auto search = std::find(m_inputAlphabet.begin(), m_inputAlphabet.end(), item);
if (errorState != stateTemplate::Q || search == m_inputAlphabet.end())
{
std::cout << "Automaton doesn't reach to final state, and stops in " <<
static_cast<std::underlying_type<stateTemplate>::type>(errorState) << " state." <<
std::endl << "Accordingly result is invalid.!!!" << std::endl;
}
else
{
std::cout << "Automaton reach to final state, result is valid !!!" << std::endl;
}
}
template<typename stateTemplate>
void Automaton<stateTemplate>::setinputLine(const std::string & input)
{
m_inputLine.clear();
for (auto i : input)
{
m_inputLine.push_back(i);
}
}
template<typename stateTemplate>
void Automaton<stateTemplate>::work()
{
int value_m_SysType = static_cast<std::underlying_type<stateTemplate>::type>(m_SysType);
int count = m_inputLine.size() % value_m_SysType; /// count of bits that less than SysType
if (count != 0)
{
m_inputLine.insert(m_inputLine.begin(), value_m_SysType - count, '0'); /// push '0' as many as Systype requires to become m_inputAlphabet complete
}
stateTemplate nextState = m_initialState;
char item;
for (int i = 0; i < m_inputLine.size();++i)
{
item = m_inputLine[i];
auto search = m_transmissionOperator.find(std::make_pair(nextState, item));
if (search == m_transmissionOperator.end())
{
break;
}
nextState = search->second;
std::cout << "State " << static_cast<std::underlying_type<stateTemplate>::type>(nextState) << std::endl;
if (nextState >= m_minSecondFinalState)
{
int index1 = static_cast<std::underlying_type<stateTemplate>::type>(nextState);
int index2 = static_cast<std::underlying_type<stateTemplate>::type>(m_minSecondFinalState);
int index = index1 - index2;
m_outputLine.push_back(m_outputAlphabet[index]);
--i;
}
}
handler(nextState,item);
}
template<typename stateTemplate>
void Automaton<stateTemplate>::print()
{
std::cout << "Result is ";
for (auto i : m_outputLine)
{
std::cout << i;
}
std::cout << std::endl;
}
| [
"davitp@cqg.com"
] | davitp@cqg.com |
f45863ef978eb5102a273c8742de5616b6e120b4 | c0376f9eb4eb1adf2db5aff3d25abc3576d0241b | /src/plugins/azoth/interfaces/azoth/imessage.h | 62d339df6ef206a807c72dc4737e04abfb197efe | [
"BSL-1.0"
] | permissive | ROOAARR/leechcraft | 0179e6f1e7c0b7afbfcce60cb810d61bd558b163 | 14bc859ca750598b77abdc8b2d5b9647c281d9b3 | refs/heads/master | 2021-01-17T22:08:16.273024 | 2013-08-05T12:28:45 | 2013-08-05T12:28:45 | 2,217,574 | 1 | 0 | null | 2013-01-19T15:32:47 | 2011-08-16T18:55:44 | C++ | UTF-8 | C++ | false | false | 9,140 | h | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2013 Georg Rudoy
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#ifndef PLUGINS_AZOTH_INTERFACES_IMESSAGE_H
#define PLUGINS_AZOTH_INTERFACES_IMESSAGE_H
#include <QString>
#include <QDateTime>
#include <QtPlugin>
class QObject;
namespace LeechCraft
{
namespace Azoth
{
class ICLEntry;
/** @brief This interface is used to represent a message.
*
* Refer to the MessageType enum for the list of possible message
* types that are covered by this interface.
*
* The message should not be sent upon creation, only call to Send()
* should trigger the sending.
*
* This interface provides only more or less basic functionality.
* Advanced features like delivery receipts and such, are in
* IAdvancedMessage.
*
* Messages implementing this interface are expected to contain only
* plain text bodies. If a message may also contain rich text, it
* should implement the IRichTextMessage interface.
*
* @sa IAdvancedMessage, IRichTextMessage.
*/
class IMessage
{
public:
virtual ~IMessage () {};
/** @brief Represents the direction of the message.
*/
enum Direction
{
/** @brief The message is from the remote party to us.
*/
DIn,
/** @brief The message is from us to the remote party.
*/
DOut
};
/** @brief Represents possible message types.
*/
enum MessageType
{
/** @brief Standard one-to-one message.
*/
MTChatMessage,
/** @brief Message in a multiuser conference.
*
* This kind of message is only for messages that originate
* from participants and are human-generated. Thus, status
* changes, topic changes and such should have a different
* type.
*/
MTMUCMessage,
/** @brief Status changes in a chat.
*
* This type of message contains information about
* participant's status/presence changes.
*/
MTStatusMessage,
/** @brief Various events in a chat.
*
* Messages of this type are for notifying about, for
* example, topic changes, kicks, bans, etc. Generally,
* there is no other part in such messages, so the message
* of this type can return NULL from OtherPart().
*/
MTEventMessage,
/** @brief Other.
*/
MTServiceMessage
};
/** @brief This enum is used for more precise classification of
* chat types messages.
*
* The messages of some particular types may have additional
* required properties used by the Azoth Core and other plugins
* to establish proper context for the events.
*/
enum MessageSubType
{
/** This message is of subtype that doesn't correspond to
* any other subtype of message.
*/
MSTOther,
/** This message notifies about someone being just kicked.
*/
MSTKickNotification,
/** This message notifies about someone being just banned.
*/
MSTBanNotification,
/** @brief Represents status change of a participant in a
* chat or MUC room.
*
* The corresponding MessageType is MTStatusMessage.
*
* Messages of this type should have the following dynamic
* properties:
* - Azoth/Nick, with a QString representing nick of the
* participant that has changed its status.
* - Azoth/TargetState, with a QString representing the
* target state. The string is better obtained from the
* State enum by the means of IProxyObject::StateToString
* method.
* - Azoth/StatusText, with a QString representing the new
* status text of the participant. May be empty.
*/
MSTParticipantStatusChange,
/** @brief Represents permission changes of a participant in
* a chat or MUC room.
*/
MSTParticipantRoleAffiliationChange,
/** @brief Notifies about participant joining to a MUC room.
*/
MSTParticipantJoin,
/** @brief Notifies about participant leaving a MUC room.
*/
MSTParticipantLeave,
/** @brief Notifies about participant in a MUC changing the
* nick.
*/
MSTParticipantNickChange,
/** @brief The participant has ended the conversation.
*/
MSTParticipantEndedConversation,
/** @brief Notifies about changing subject in a MUC room.
*/
MSTRoomSubjectChange
};
/** @brief Returns this message as a QObject.
*/
virtual QObject* GetQObject () = 0;
/** @brief Sends the message.
*
* A message should never be sent except as the result of this
* method.
*
* Please note that if the other part is a MUC, it should send
* back this message with the "IN" direction set.
*/
virtual void Send () = 0;
/** @brief Stores the message.
*
* After calling this function this message should be present in
* the messages list returned by ICLEntry::GetAllMessages(), but
* the message shouldn't be sent.
*
* @sa ICLEntry::GetAllMessages()
*/
virtual void Store () = 0;
/** @brief Returns the direction of this message.
*
* @return The direction of this message.
*/
virtual Direction GetDirection () const = 0;
/** @brief Returns the type of this message.
*
* @return The type of this message.
*/
virtual MessageType GetMessageType () const = 0;
/** @brief Returns the subtype of this message.
*
* The subtype is used for more precise classification of
* messages.
*
* @return The subtype of this message
*/
virtual MessageSubType GetMessageSubType () const = 0;
/** @brief Returns the CL entry from which this message is.
*
* For normal, single user chats, this should always be equal to
* the ICLEntry that was (and will be) used to send the message
* back.
*
* For multiuser chats this should be equal to the contact list
* representation of the participant that sent the message.
*
* The returned object must implement ICLEntry.
*
* @return The CL entry from which this message originates,
* implementing ICLEntry.
*/
virtual QObject* OtherPart () const = 0;
/** @brief Returns the parent CL entry of this message.
*
* This is the same that OtherPart() for single user chats. For
* multiuser chats it should be the contact list entry
* representing the MUC room.
*
* By default this function calls OtherPart() and returns its
* result.
*
* The returned object must implement ICLEntry.
*
* @return The parent CL entry of this message, implementing
* ICLEntry.
*/
virtual QObject* ParentCLEntry () const
{
return OtherPart ();
}
/** @brief The variant of the other part.
*
* If not applicable, a null string should be returned.
*
* @return The variant of the other part.
*/
virtual QString GetOtherVariant () const = 0;
/** @brief Returns the body of the message.
*
* The body is expected to be a plain text string. All '<' and
* '&' will be escaped.
*
* @return The body of the message.
*/
virtual QString GetBody () const = 0;
/** @brief Updates the body of the message.
*
* The passed string is the plain text contents of the message.
*
* @param[in] body The new body of the message.
*/
virtual void SetBody (const QString& body) = 0;
/** @brief Returns the timestamp of the message.
*
* @return The timestamp of the message.
*/
virtual QDateTime GetDateTime () const = 0;
/** @brief Updates the timestamp of the message.
*
* @param[in] timestamp The new timestamp of the message.
*/
virtual void SetDateTime (const QDateTime& timestamp) = 0;
};
}
}
Q_DECLARE_INTERFACE (LeechCraft::Azoth::IMessage,
"org.Deviant.LeechCraft.Azoth.IMessage/1.0");
#endif
| [
"0xd34df00d@gmail.com"
] | 0xd34df00d@gmail.com |
492ce9ba8def3f6a8e22e92bf4081af0ed9ac0b0 | b4c2427ece02bc1bc1f5e6279539ac884efcb323 | /Codeforces/492B/18652748_AC_31ms_36kB.cpp | e64d9a63f8d1ce1217b59402cebc4d5de6b9c420 | [] | no_license | sohag16030/ACM-Programming | eb7210be3685c3f7e5ea855c1598f5e7f3044463 | 39943162ed7b08d34b2b07b1a866b039c6ec2cc7 | refs/heads/master | 2023-01-31T11:08:46.389769 | 2020-12-14T08:57:24 | 2020-12-14T08:57:24 | 218,221,513 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,655 | cpp | /**************************************************
* BISMILLAHIR RAHMANIR RAHIM
* Author Name : SHOHAG (ICT'13)
* University : ICT, MBSTU
***************************************************/
#include<bits/stdc++.h>
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define MAX 1000
#define MIN -1
#define INF 1000
#define dbg cout<<"Executed"<<endl;
#define SET(array_name,value) memset(array_name,value,sizeof(array_name))
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define sfi(n) scanf("%lld",&n)
#define sfii(n,m) scanf("%lld%lld",&n,&m)
#define pfi(n) printf("%lld",n)
#define pfii(n,m) scanf("%lld%lld",n,m)
#define pfn printf("\n")
#define pfs printf(" ")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,i,j,L,m,k,t,sum,cnt,d,rem,mod,v,r,l,row,extra,mn=1000000009, a[MAX];
double mx=-1.0,differ,hmm,extra1,extra2;
string str,str2;
map<ll,ll>maap;
map<ll,ll>::iterator it;
vector<ll>vec,v2,v3;
vector<ll>v4[51];
/************************************ Code Start Here ******************************************************/
int main()
{
sfii(n,l);
for(i=0; i<n; i++)
{
cin>>t;
vec.pb(t);
}
sort(all(vec));
for(i=0; i<vec.size()-1; i++)
{
differ=(double)(vec[i+1]-vec[i])/2;
//printf("%f\n",differ);
differ=max(differ,mx);
mx=differ;
}
extra1=(l-vec[n-1]);
extra2=(vec[0]);
hmm=max(extra1,extra2);
//cout<<hmm;
printf("%.10f",max(hmm,differ));
return 0;
}
| [
"shohag.mbstu.it16030@gmail.com"
] | shohag.mbstu.it16030@gmail.com |
1e31d4e372b97c989b994770a7325545f9ae9b6d | ac16a937f32602cf16114463f8e875a972f64c27 | /docs/dolfin/2016.2.0/cpp/source/demo/undocumented/multimesh-poisson/cpp/MultiMeshPoisson.h | 5e1f215f688133eca1de1d5f3b95e3c9129ff8df | [] | no_license | mparno/fenics-web | 2073248da6f9918ffedbe9be8a3433bc1cbb7ffb | 7202752da876b1f9ab02c1d5a5f28ff5da526528 | refs/heads/master | 2021-05-05T04:45:46.436236 | 2016-12-06T20:25:44 | 2016-12-06T20:25:44 | 118,628,385 | 2 | 0 | null | 2018-01-23T15:21:47 | 2018-01-23T15:21:46 | null | UTF-8 | C++ | false | false | 132,702 | h | // This code conforms with the UFC specification version 2016.2.0
// and was automatically generated by FFC version 2016.2.0.
//
// This code was generated with the option '-l dolfin' and
// contains DOLFIN-specific wrappers that depend on DOLFIN.
//
// This code was generated with the following parameters:
//
// convert_exceptions_to_warnings: False
// cpp_optimize: True
// cpp_optimize_flags: '-O2'
// epsilon: 1e-14
// error_control: False
// form_postfix: True
// format: 'dolfin'
// max_signature_length: 0
// optimize: True
// precision: 15
// quadrature_degree: -1
// quadrature_rule: 'auto'
// representation: 'auto'
// split: False
#ifndef __MULTIMESHPOISSON_H
#define __MULTIMESHPOISSON_H
#include <stdexcept>
#include <ufc.h>
class multimeshpoisson_finite_element_0: public ufc::finite_element
{
public:
multimeshpoisson_finite_element_0() : ufc::finite_element()
{
// Do nothing
}
~multimeshpoisson_finite_element_0() override
{
// Do nothing
}
const char * signature() const final override
{
return "FiniteElement('Lagrange', triangle, 1)";
}
ufc::shape cell_shape() const final override
{
return ufc::shape::triangle;
}
std::size_t topological_dimension() const final override
{
return 2;
}
std::size_t geometric_dimension() const final override
{
return 2;
}
std::size_t space_dimension() const final override
{
return 3;
}
std::size_t value_rank() const final override
{
return 0;
}
std::size_t value_dimension(std::size_t i) const final override
{
return 1;
}
std::size_t value_size() const final override
{
return 1;
}
std::size_t reference_value_rank() const final override
{
return 0;
}
std::size_t reference_value_dimension(std::size_t i) const final override
{
return 1;
}
std::size_t reference_value_size() const final override
{
return 1;
}
std::size_t degree() const final override
{
return 1;
}
const char * family() const final override
{
return "Lagrange";
}
static void _evaluate_basis(std::size_t i,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Compute constants
const double C0 = coordinate_dofs[2] + coordinate_dofs[4];
const double C1 = coordinate_dofs[3] + coordinate_dofs[5];
// Get coordinates and map to the reference (FIAT) element
double X = (J[1]*(C1 - 2.0*x[1]) + J[3]*(2.0*x[0] - C0)) / detJ;
double Y = (J[0]*(2.0*x[1] - C1) + J[2]*(C0 - 2.0*x[0])) / detJ;
// Reset values
*values = 0.0;
switch (i)
{
case 0:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, -0.288675134594813, -0.166666666666667};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
*values += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
case 1:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.288675134594813, -0.166666666666667};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
*values += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
case 2:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.0, 0.333333333333333};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
*values += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
}
}
void evaluate_basis(std::size_t i,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis(i, values, x, coordinate_dofs, cell_orientation);
}
static void _evaluate_basis_all(double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Helper variable to hold values of a single dof.
double dof_values = 0.0;
// Loop dofs and call evaluate_basis
for (unsigned int r = 0; r < 3; r++)
{
_evaluate_basis(r, &dof_values, x, coordinate_dofs, cell_orientation);
values[r] = dof_values;
} // end loop over 'r'
}
void evaluate_basis_all(double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis_all(values, x, coordinate_dofs, cell_orientation);
}
static void _evaluate_basis_derivatives(std::size_t i,
std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Compute number of derivatives.
unsigned int num_derivatives = 1;
for (unsigned int r = 0; r < n; r++)
{
num_derivatives *= 2;
} // end loop over 'r'
// Reset values. Assuming that values is always an array.
for (unsigned int r = 0; r < num_derivatives; r++)
{
values[r] = 0.0;
} // end loop over 'r'
// Call evaluate_basis if order of derivatives is equal to zero.
if (n == 0)
{
_evaluate_basis(i, values, x, coordinate_dofs, cell_orientation);
return ;
}
// If order of derivatives is greater than the maximum polynomial degree, return zeros.
if (n > 1)
{
return ;
}
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Compute constants
const double C0 = coordinate_dofs[2] + coordinate_dofs[4];
const double C1 = coordinate_dofs[3] + coordinate_dofs[5];
// Get coordinates and map to the reference (FIAT) element
double X = (J[1]*(C1 - 2.0*x[1]) + J[3]*(2.0*x[0] - C0)) / detJ;
double Y = (J[0]*(2.0*x[1] - C1) + J[2]*(C0 - 2.0*x[0])) / detJ;
// Declare two dimensional array that holds combinations of derivatives and initialise
unsigned int combinations[2][1];
for (unsigned int row = 0; row < 2; row++)
{
for (unsigned int col = 0; col < 1; col++)
combinations[row][col] = 0;
}
// Generate combinations of derivatives
for (unsigned int row = 1; row < num_derivatives; row++)
{
for (unsigned int num = 0; num < row; num++)
{
for (unsigned int col = n-1; col+1 > 0; col--)
{
if (combinations[row][col] + 1 > 1)
combinations[row][col] = 0;
else
{
combinations[row][col] += 1;
break;
}
}
}
}
// Compute inverse of Jacobian
const double Jinv[2][2] = {{K[0], K[1]}, {K[2], K[3]}};
// Declare transformation matrix
// Declare pointer to two dimensional array and initialise
double transform[2][2];
for (unsigned int j = 0; j < num_derivatives; j++)
{
for (unsigned int k = 0; k < num_derivatives; k++)
transform[j][k] = 1;
}
// Construct transformation matrix
for (unsigned int row = 0; row < num_derivatives; row++)
{
for (unsigned int col = 0; col < num_derivatives; col++)
{
for (unsigned int k = 0; k < n; k++)
transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
}
}
switch (i)
{
case 0:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, -0.288675134594813, -0.166666666666667};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
case 1:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.288675134594813, -0.166666666666667};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
case 2:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.0, 0.333333333333333};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
}
}
void evaluate_basis_derivatives(std::size_t i,
std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation);
}
static void _evaluate_basis_derivatives_all(std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Call evaluate_basis_all if order of derivatives is equal to zero.
if (n == 0)
{
_evaluate_basis_all(values, x, coordinate_dofs, cell_orientation);
return ;
}
// Compute number of derivatives.
unsigned int num_derivatives = 1;
for (unsigned int r = 0; r < n; r++)
{
num_derivatives *= 2;
} // end loop over 'r'
// Set values equal to zero.
for (unsigned int r = 0; r < 3; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r*num_derivatives + s] = 0.0;
} // end loop over 's'
} // end loop over 'r'
// If order of derivatives is greater than the maximum polynomial degree, return zeros.
if (n > 1)
{
return ;
}
// Helper variable to hold values of a single dof.
double dof_values[2];
for (unsigned int r = 0; r < 2; r++)
{
dof_values[r] = 0.0;
} // end loop over 'r'
// Loop dofs and call evaluate_basis_derivatives.
for (unsigned int r = 0; r < 3; r++)
{
_evaluate_basis_derivatives(r, n, dof_values, x, coordinate_dofs, cell_orientation);
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r*num_derivatives + s] = dof_values[s];
} // end loop over 's'
} // end loop over 'r'
}
void evaluate_basis_derivatives_all(std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation);
}
double evaluate_dof(std::size_t i,
const ufc::function& f,
const double * coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const final override
{
// Declare variables for result of evaluation
double vals[1];
// Declare variable for physical coordinates
double y[2];
switch (i)
{
case 0:
{
y[0] = coordinate_dofs[0];
y[1] = coordinate_dofs[1];
f.evaluate(vals, y, c);
return vals[0];
break;
}
case 1:
{
y[0] = coordinate_dofs[2];
y[1] = coordinate_dofs[3];
f.evaluate(vals, y, c);
return vals[0];
break;
}
case 2:
{
y[0] = coordinate_dofs[4];
y[1] = coordinate_dofs[5];
f.evaluate(vals, y, c);
return vals[0];
break;
}
}
return 0.0;
}
void evaluate_dofs(double * values,
const ufc::function& f,
const double * coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const final override
{
// Declare variables for result of evaluation
double vals[1];
// Declare variable for physical coordinates
double y[2];
y[0] = coordinate_dofs[0];
y[1] = coordinate_dofs[1];
f.evaluate(vals, y, c);
values[0] = vals[0];
y[0] = coordinate_dofs[2];
y[1] = coordinate_dofs[3];
f.evaluate(vals, y, c);
values[1] = vals[0];
y[0] = coordinate_dofs[4];
y[1] = coordinate_dofs[5];
f.evaluate(vals, y, c);
values[2] = vals[0];
}
void interpolate_vertex_values(double * vertex_values,
const double * dof_values,
const double * coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const final override
{
// Evaluate function and change variables
vertex_values[0] = dof_values[0];
vertex_values[1] = dof_values[1];
vertex_values[2] = dof_values[2];
}
void tabulate_dof_coordinates(double * dof_coordinates,
const double * coordinate_dofs) const final override
{
dof_coordinates[0] = coordinate_dofs[0];
dof_coordinates[1] = coordinate_dofs[1];
dof_coordinates[2] = coordinate_dofs[2];
dof_coordinates[3] = coordinate_dofs[3];
dof_coordinates[4] = coordinate_dofs[4];
dof_coordinates[5] = coordinate_dofs[5];
}
std::size_t num_sub_elements() const final override
{
return 0;
}
ufc::finite_element * create_sub_element(std::size_t i) const final override
{
return 0;
}
ufc::finite_element * create() const final override
{
return new multimeshpoisson_finite_element_0();
}
};
class multimeshpoisson_finite_element_1: public ufc::finite_element
{
public:
multimeshpoisson_finite_element_1() : ufc::finite_element()
{
// Do nothing
}
~multimeshpoisson_finite_element_1() override
{
// Do nothing
}
const char * signature() const final override
{
return "VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2)";
}
ufc::shape cell_shape() const final override
{
return ufc::shape::triangle;
}
std::size_t topological_dimension() const final override
{
return 2;
}
std::size_t geometric_dimension() const final override
{
return 2;
}
std::size_t space_dimension() const final override
{
return 6;
}
std::size_t value_rank() const final override
{
return 1;
}
std::size_t value_dimension(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return 2;
break;
}
}
return 0;
}
std::size_t value_size() const final override
{
return 2;
}
std::size_t reference_value_rank() const final override
{
return 1;
}
std::size_t reference_value_dimension(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return 2;
break;
}
}
return 0;
}
std::size_t reference_value_size() const final override
{
return 2;
}
std::size_t degree() const final override
{
return 1;
}
const char * family() const final override
{
return "Lagrange";
}
static void _evaluate_basis(std::size_t i,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Compute constants
const double C0 = coordinate_dofs[2] + coordinate_dofs[4];
const double C1 = coordinate_dofs[3] + coordinate_dofs[5];
// Get coordinates and map to the reference (FIAT) element
double X = (J[1]*(C1 - 2.0*x[1]) + J[3]*(2.0*x[0] - C0)) / detJ;
double Y = (J[0]*(2.0*x[1] - C1) + J[2]*(C0 - 2.0*x[0])) / detJ;
// Reset values
values[0] = 0.0;
values[1] = 0.0;
switch (i)
{
case 0:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, -0.288675134594813, -0.166666666666667};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
values[0] += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
case 1:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.288675134594813, -0.166666666666667};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
values[0] += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
case 2:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.0, 0.333333333333333};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
values[0] += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
case 3:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, -0.288675134594813, -0.166666666666667};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
values[1] += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
case 4:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.288675134594813, -0.166666666666667};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
values[1] += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
case 5:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.0, 0.333333333333333};
// Compute value(s)
for (unsigned int r = 0; r < 3; r++)
{
values[1] += coefficients0[r]*basisvalues[r];
} // end loop over 'r'
break;
}
}
}
void evaluate_basis(std::size_t i,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis(i, values, x, coordinate_dofs, cell_orientation);
}
static void _evaluate_basis_all(double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Helper variable to hold values of a single dof.
double dof_values[2] = {0.0, 0.0};
// Loop dofs and call evaluate_basis
for (unsigned int r = 0; r < 6; r++)
{
_evaluate_basis(r, dof_values, x, coordinate_dofs, cell_orientation);
for (unsigned int s = 0; s < 2; s++)
{
values[r*2 + s] = dof_values[s];
} // end loop over 's'
} // end loop over 'r'
}
void evaluate_basis_all(double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis_all(values, x, coordinate_dofs, cell_orientation);
}
static void _evaluate_basis_derivatives(std::size_t i,
std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Compute number of derivatives.
unsigned int num_derivatives = 1;
for (unsigned int r = 0; r < n; r++)
{
num_derivatives *= 2;
} // end loop over 'r'
// Reset values. Assuming that values is always an array.
for (unsigned int r = 0; r < 2*num_derivatives; r++)
{
values[r] = 0.0;
} // end loop over 'r'
// Call evaluate_basis if order of derivatives is equal to zero.
if (n == 0)
{
_evaluate_basis(i, values, x, coordinate_dofs, cell_orientation);
return ;
}
// If order of derivatives is greater than the maximum polynomial degree, return zeros.
if (n > 1)
{
return ;
}
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Compute constants
const double C0 = coordinate_dofs[2] + coordinate_dofs[4];
const double C1 = coordinate_dofs[3] + coordinate_dofs[5];
// Get coordinates and map to the reference (FIAT) element
double X = (J[1]*(C1 - 2.0*x[1]) + J[3]*(2.0*x[0] - C0)) / detJ;
double Y = (J[0]*(2.0*x[1] - C1) + J[2]*(C0 - 2.0*x[0])) / detJ;
// Declare two dimensional array that holds combinations of derivatives and initialise
unsigned int combinations[2][1];
for (unsigned int row = 0; row < 2; row++)
{
for (unsigned int col = 0; col < 1; col++)
combinations[row][col] = 0;
}
// Generate combinations of derivatives
for (unsigned int row = 1; row < num_derivatives; row++)
{
for (unsigned int num = 0; num < row; num++)
{
for (unsigned int col = n-1; col+1 > 0; col--)
{
if (combinations[row][col] + 1 > 1)
combinations[row][col] = 0;
else
{
combinations[row][col] += 1;
break;
}
}
}
}
// Compute inverse of Jacobian
const double Jinv[2][2] = {{K[0], K[1]}, {K[2], K[3]}};
// Declare transformation matrix
// Declare pointer to two dimensional array and initialise
double transform[2][2];
for (unsigned int j = 0; j < num_derivatives; j++)
{
for (unsigned int k = 0; k < num_derivatives; k++)
transform[j][k] = 1;
}
// Construct transformation matrix
for (unsigned int row = 0; row < num_derivatives; row++)
{
for (unsigned int col = 0; col < num_derivatives; col++)
{
for (unsigned int k = 0; k < n; k++)
transform[row][col] *= Jinv[combinations[col][k]][combinations[row][k]];
}
}
switch (i)
{
case 0:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, -0.288675134594813, -0.166666666666667};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
case 1:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.288675134594813, -0.166666666666667};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
case 2:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.0, 0.333333333333333};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
case 3:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, -0.288675134594813, -0.166666666666667};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[num_derivatives + r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
case 4:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.288675134594813, -0.166666666666667};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[num_derivatives + r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
case 5:
{
// Array of basisvalues
double basisvalues[3] = {0.0, 0.0, 0.0};
// Declare helper variables
double tmp0 = (1.0 + Y + 2.0*X)/2.0;
// Compute basisvalues
basisvalues[0] = 1.0;
basisvalues[1] = tmp0;
basisvalues[2] = basisvalues[0]*(0.5 + 1.5*Y);
basisvalues[0] *= std::sqrt(0.5);
basisvalues[2] *= std::sqrt(1.0);
basisvalues[1] *= std::sqrt(3.0);
// Table(s) of coefficients
static const double coefficients0[3] = \
{0.471404520791032, 0.0, 0.333333333333333};
// Tables of derivatives of the polynomial base (transpose).
static const double dmats0[3][3] = \
{{0.0, 0.0, 0.0},
{4.89897948556635, 0.0, 0.0},
{0.0, 0.0, 0.0}};
static const double dmats1[3][3] = \
{{0.0, 0.0, 0.0},
{2.44948974278318, 0.0, 0.0},
{4.24264068711928, 0.0, 0.0}};
// Compute reference derivatives.
// Declare array of derivatives on FIAT element.
double derivatives[2];
for (unsigned int r = 0; r < 2; r++)
{
derivatives[r] = 0.0;
} // end loop over 'r'
// Declare derivative matrix (of polynomial basis).
double dmats[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Declare (auxiliary) derivative matrix (of polynomial basis).
double dmats_old[3][3] = \
{{1.0, 0.0, 0.0},
{0.0, 1.0, 0.0},
{0.0, 0.0, 1.0}};
// Loop possible derivatives.
for (unsigned int r = 0; r < num_derivatives; r++)
{
// Resetting dmats values to compute next derivative.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats[t][u] = 0.0;
if (t == u)
{
dmats[t][u] = 1.0;
}
} // end loop over 'u'
} // end loop over 't'
// Looping derivative order to generate dmats.
for (unsigned int s = 0; s < n; s++)
{
// Updating dmats_old with new values and resetting dmats.
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
dmats_old[t][u] = dmats[t][u];
dmats[t][u] = 0.0;
} // end loop over 'u'
} // end loop over 't'
// Update dmats using an inner product.
if (combinations[r][s] == 0)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats0[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
if (combinations[r][s] == 1)
{
for (unsigned int t = 0; t < 3; t++)
{
for (unsigned int u = 0; u < 3; u++)
{
for (unsigned int tu = 0; tu < 3; tu++)
{
dmats[t][u] += dmats1[t][tu]*dmats_old[tu][u];
} // end loop over 'tu'
} // end loop over 'u'
} // end loop over 't'
}
} // end loop over 's'
for (unsigned int s = 0; s < 3; s++)
{
for (unsigned int t = 0; t < 3; t++)
{
derivatives[r] += coefficients0[s]*dmats[s][t]*basisvalues[t];
} // end loop over 't'
} // end loop over 's'
} // end loop over 'r'
// Transform derivatives back to physical element
for (unsigned int r = 0; r < num_derivatives; r++)
{
for (unsigned int s = 0; s < num_derivatives; s++)
{
values[num_derivatives + r] += transform[r][s]*derivatives[s];
} // end loop over 's'
} // end loop over 'r'
break;
}
}
}
void evaluate_basis_derivatives(std::size_t i,
std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis_derivatives(i, n, values, x, coordinate_dofs, cell_orientation);
}
static void _evaluate_basis_derivatives_all(std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation)
{
// Call evaluate_basis_all if order of derivatives is equal to zero.
if (n == 0)
{
_evaluate_basis_all(values, x, coordinate_dofs, cell_orientation);
return ;
}
// Compute number of derivatives.
unsigned int num_derivatives = 1;
for (unsigned int r = 0; r < n; r++)
{
num_derivatives *= 2;
} // end loop over 'r'
// Set values equal to zero.
for (unsigned int r = 0; r < 6; r++)
{
for (unsigned int s = 0; s < 2*num_derivatives; s++)
{
values[r*2*num_derivatives + s] = 0.0;
} // end loop over 's'
} // end loop over 'r'
// If order of derivatives is greater than the maximum polynomial degree, return zeros.
if (n > 1)
{
return ;
}
// Helper variable to hold values of a single dof.
double dof_values[4];
for (unsigned int r = 0; r < 4; r++)
{
dof_values[r] = 0.0;
} // end loop over 'r'
// Loop dofs and call evaluate_basis_derivatives.
for (unsigned int r = 0; r < 6; r++)
{
_evaluate_basis_derivatives(r, n, dof_values, x, coordinate_dofs, cell_orientation);
for (unsigned int s = 0; s < 2*num_derivatives; s++)
{
values[r*2*num_derivatives + s] = dof_values[s];
} // end loop over 's'
} // end loop over 'r'
}
void evaluate_basis_derivatives_all(std::size_t n,
double * values,
const double * x,
const double * coordinate_dofs,
int cell_orientation) const final override
{
_evaluate_basis_derivatives_all(n, values, x, coordinate_dofs, cell_orientation);
}
double evaluate_dof(std::size_t i,
const ufc::function& f,
const double * coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const final override
{
// Declare variables for result of evaluation
double vals[2];
// Declare variable for physical coordinates
double y[2];
switch (i)
{
case 0:
{
y[0] = coordinate_dofs[0];
y[1] = coordinate_dofs[1];
f.evaluate(vals, y, c);
return vals[0];
break;
}
case 1:
{
y[0] = coordinate_dofs[2];
y[1] = coordinate_dofs[3];
f.evaluate(vals, y, c);
return vals[0];
break;
}
case 2:
{
y[0] = coordinate_dofs[4];
y[1] = coordinate_dofs[5];
f.evaluate(vals, y, c);
return vals[0];
break;
}
case 3:
{
y[0] = coordinate_dofs[0];
y[1] = coordinate_dofs[1];
f.evaluate(vals, y, c);
return vals[1];
break;
}
case 4:
{
y[0] = coordinate_dofs[2];
y[1] = coordinate_dofs[3];
f.evaluate(vals, y, c);
return vals[1];
break;
}
case 5:
{
y[0] = coordinate_dofs[4];
y[1] = coordinate_dofs[5];
f.evaluate(vals, y, c);
return vals[1];
break;
}
}
return 0.0;
}
void evaluate_dofs(double * values,
const ufc::function& f,
const double * coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const final override
{
// Declare variables for result of evaluation
double vals[2];
// Declare variable for physical coordinates
double y[2];
y[0] = coordinate_dofs[0];
y[1] = coordinate_dofs[1];
f.evaluate(vals, y, c);
values[0] = vals[0];
values[3] = vals[1];
y[0] = coordinate_dofs[2];
y[1] = coordinate_dofs[3];
f.evaluate(vals, y, c);
values[1] = vals[0];
values[4] = vals[1];
y[0] = coordinate_dofs[4];
y[1] = coordinate_dofs[5];
f.evaluate(vals, y, c);
values[2] = vals[0];
values[5] = vals[1];
}
void interpolate_vertex_values(double * vertex_values,
const double * dof_values,
const double * coordinate_dofs,
int cell_orientation,
const ufc::cell& c) const final override
{
// Evaluate function and change variables
vertex_values[0] = dof_values[0];
vertex_values[2] = dof_values[1];
vertex_values[4] = dof_values[2];
// Evaluate function and change variables
vertex_values[1] = dof_values[3];
vertex_values[3] = dof_values[4];
vertex_values[5] = dof_values[5];
}
void tabulate_dof_coordinates(double * dof_coordinates,
const double * coordinate_dofs) const final override
{
dof_coordinates[0] = coordinate_dofs[0];
dof_coordinates[1] = coordinate_dofs[1];
dof_coordinates[2] = coordinate_dofs[2];
dof_coordinates[3] = coordinate_dofs[3];
dof_coordinates[4] = coordinate_dofs[4];
dof_coordinates[5] = coordinate_dofs[5];
dof_coordinates[6] = coordinate_dofs[0];
dof_coordinates[7] = coordinate_dofs[1];
dof_coordinates[8] = coordinate_dofs[2];
dof_coordinates[9] = coordinate_dofs[3];
dof_coordinates[10] = coordinate_dofs[4];
dof_coordinates[11] = coordinate_dofs[5];
}
std::size_t num_sub_elements() const final override
{
return 2;
}
ufc::finite_element * create_sub_element(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return new multimeshpoisson_finite_element_0();
break;
}
case 1:
{
return new multimeshpoisson_finite_element_0();
break;
}
}
return 0;
}
ufc::finite_element * create() const final override
{
return new multimeshpoisson_finite_element_1();
}
};
class multimeshpoisson_dofmap_0: public ufc::dofmap
{
public:
multimeshpoisson_dofmap_0() : ufc::dofmap()
{
// Do nothing
}
~multimeshpoisson_dofmap_0() override
{
// Do nothing
}
const char * signature() const final override
{
return "FFC dofmap for FiniteElement('Lagrange', triangle, 1)";
}
bool needs_mesh_entities(std::size_t d) const final override
{
switch (d)
{
case 0:
{
return true;
break;
}
case 1:
{
return false;
break;
}
case 2:
{
return false;
break;
}
}
return false;
}
std::size_t topological_dimension() const final override
{
return 2;
}
std::size_t global_dimension(const std::vector<std::size_t>&
num_global_entities) const final override
{
return num_global_entities[0];
}
std::size_t num_element_dofs() const final override
{
return 3;
}
std::size_t num_facet_dofs() const final override
{
return 2;
}
std::size_t num_entity_dofs(std::size_t d) const final override
{
switch (d)
{
case 0:
{
return 1;
break;
}
case 1:
{
return 0;
break;
}
case 2:
{
return 0;
break;
}
}
return 0;
}
std::size_t num_entity_closure_dofs(std::size_t d) const final override
{
switch (d)
{
case 0:
{
return 1;
break;
}
case 1:
{
return 2;
break;
}
case 2:
{
return 3;
break;
}
}
return 0;
}
void tabulate_dofs(std::size_t * dofs,
const std::vector<std::size_t>& num_global_entities,
const std::vector<std::vector<std::size_t>>& entity_indices) const final override
{
dofs[0] = entity_indices[0][0];
dofs[1] = entity_indices[0][1];
dofs[2] = entity_indices[0][2];
}
void tabulate_facet_dofs(std::size_t * dofs,
std::size_t facet) const final override
{
switch (facet)
{
case 0:
{
dofs[0] = 1;
dofs[1] = 2;
break;
}
case 1:
{
dofs[0] = 0;
dofs[1] = 2;
break;
}
case 2:
{
dofs[0] = 0;
dofs[1] = 1;
break;
}
}
}
void tabulate_entity_dofs(std::size_t * dofs,
std::size_t d, std::size_t i) const final override
{
if (d > 2)
{
throw std::runtime_error("d is larger than dimension (2)");
}
switch (d)
{
case 0:
{
if (i > 2)
{
throw std::runtime_error("i is larger than number of entities (2)");
}
switch (i)
{
case 0:
{
dofs[0] = 0;
break;
}
case 1:
{
dofs[0] = 1;
break;
}
case 2:
{
dofs[0] = 2;
break;
}
}
break;
}
case 1:
{
break;
}
case 2:
{
break;
}
}
}
void tabulate_entity_closure_dofs(std::size_t * dofs,
std::size_t d, std::size_t i) const final override
{
if (d > 2)
{
throw std::runtime_error("d is larger than dimension (2)");
}
switch (d)
{
case 0:
{
if (i > 2)
{
throw std::runtime_error("i is larger than number of entities (2)");
}
switch (i)
{
case 0:
{
dofs[0] = 0;
break;
}
case 1:
{
dofs[0] = 1;
break;
}
case 2:
{
dofs[0] = 2;
break;
}
}
break;
}
case 1:
{
if (i > 2)
{
throw std::runtime_error("i is larger than number of entities (2)");
}
switch (i)
{
case 0:
{
dofs[0] = 1;
dofs[1] = 2;
break;
}
case 1:
{
dofs[0] = 0;
dofs[1] = 2;
break;
}
case 2:
{
dofs[0] = 0;
dofs[1] = 1;
break;
}
}
break;
}
case 2:
{
if (i > 0)
{
throw std::runtime_error("i is larger than number of entities (0)");
}
dofs[0] = 0;
dofs[1] = 1;
dofs[2] = 2;
break;
}
}
}
std::size_t num_sub_dofmaps() const final override
{
return 0;
}
ufc::dofmap * create_sub_dofmap(std::size_t i) const final override
{
return 0;
}
ufc::dofmap * create() const final override
{
return new multimeshpoisson_dofmap_0();
}
};
class multimeshpoisson_dofmap_1: public ufc::dofmap
{
public:
multimeshpoisson_dofmap_1() : ufc::dofmap()
{
// Do nothing
}
~multimeshpoisson_dofmap_1() override
{
// Do nothing
}
const char * signature() const final override
{
return "FFC dofmap for VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2)";
}
bool needs_mesh_entities(std::size_t d) const final override
{
switch (d)
{
case 0:
{
return true;
break;
}
case 1:
{
return false;
break;
}
case 2:
{
return false;
break;
}
}
return false;
}
std::size_t topological_dimension() const final override
{
return 2;
}
std::size_t global_dimension(const std::vector<std::size_t>&
num_global_entities) const final override
{
return 2*num_global_entities[0];
}
std::size_t num_element_dofs() const final override
{
return 6;
}
std::size_t num_facet_dofs() const final override
{
return 4;
}
std::size_t num_entity_dofs(std::size_t d) const final override
{
switch (d)
{
case 0:
{
return 2;
break;
}
case 1:
{
return 0;
break;
}
case 2:
{
return 0;
break;
}
}
return 0;
}
std::size_t num_entity_closure_dofs(std::size_t d) const final override
{
switch (d)
{
case 0:
{
return 2;
break;
}
case 1:
{
return 4;
break;
}
case 2:
{
return 6;
break;
}
}
return 0;
}
void tabulate_dofs(std::size_t * dofs,
const std::vector<std::size_t>& num_global_entities,
const std::vector<std::vector<std::size_t>>& entity_indices) const final override
{
unsigned int offset = 0;
dofs[0] = offset + entity_indices[0][0];
dofs[1] = offset + entity_indices[0][1];
dofs[2] = offset + entity_indices[0][2];
offset += num_global_entities[0];
dofs[3] = offset + entity_indices[0][0];
dofs[4] = offset + entity_indices[0][1];
dofs[5] = offset + entity_indices[0][2];
offset += num_global_entities[0];
}
void tabulate_facet_dofs(std::size_t * dofs,
std::size_t facet) const final override
{
switch (facet)
{
case 0:
{
dofs[0] = 1;
dofs[1] = 2;
dofs[2] = 4;
dofs[3] = 5;
break;
}
case 1:
{
dofs[0] = 0;
dofs[1] = 2;
dofs[2] = 3;
dofs[3] = 5;
break;
}
case 2:
{
dofs[0] = 0;
dofs[1] = 1;
dofs[2] = 3;
dofs[3] = 4;
break;
}
}
}
void tabulate_entity_dofs(std::size_t * dofs,
std::size_t d, std::size_t i) const final override
{
if (d > 2)
{
throw std::runtime_error("d is larger than dimension (2)");
}
switch (d)
{
case 0:
{
if (i > 2)
{
throw std::runtime_error("i is larger than number of entities (2)");
}
switch (i)
{
case 0:
{
dofs[0] = 0;
dofs[1] = 3;
break;
}
case 1:
{
dofs[0] = 1;
dofs[1] = 4;
break;
}
case 2:
{
dofs[0] = 2;
dofs[1] = 5;
break;
}
}
break;
}
case 1:
{
break;
}
case 2:
{
break;
}
}
}
void tabulate_entity_closure_dofs(std::size_t * dofs,
std::size_t d, std::size_t i) const final override
{
if (d > 2)
{
throw std::runtime_error("d is larger than dimension (2)");
}
switch (d)
{
case 0:
{
if (i > 2)
{
throw std::runtime_error("i is larger than number of entities (2)");
}
switch (i)
{
case 0:
{
dofs[0] = 0;
dofs[1] = 3;
break;
}
case 1:
{
dofs[0] = 1;
dofs[1] = 4;
break;
}
case 2:
{
dofs[0] = 2;
dofs[1] = 5;
break;
}
}
break;
}
case 1:
{
if (i > 2)
{
throw std::runtime_error("i is larger than number of entities (2)");
}
switch (i)
{
case 0:
{
dofs[0] = 1;
dofs[1] = 2;
dofs[2] = 4;
dofs[3] = 5;
break;
}
case 1:
{
dofs[0] = 0;
dofs[1] = 2;
dofs[2] = 3;
dofs[3] = 5;
break;
}
case 2:
{
dofs[0] = 0;
dofs[1] = 1;
dofs[2] = 3;
dofs[3] = 4;
break;
}
}
break;
}
case 2:
{
if (i > 0)
{
throw std::runtime_error("i is larger than number of entities (0)");
}
dofs[0] = 0;
dofs[1] = 1;
dofs[2] = 2;
dofs[3] = 3;
dofs[4] = 4;
dofs[5] = 5;
break;
}
}
}
std::size_t num_sub_dofmaps() const final override
{
return 2;
}
ufc::dofmap * create_sub_dofmap(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return new multimeshpoisson_dofmap_0();
break;
}
case 1:
{
return new multimeshpoisson_dofmap_0();
break;
}
}
return 0;
}
ufc::dofmap * create() const final override
{
return new multimeshpoisson_dofmap_1();
}
};
class multimeshpoisson_cell_integral_0_otherwise: public ufc::cell_integral
{
public:
multimeshpoisson_cell_integral_0_otherwise() : ufc::cell_integral()
{
}
~multimeshpoisson_cell_integral_0_otherwise() override
{
}
const std::vector<bool> & enabled_coefficients() const final override
{
static const std::vector<bool> enabled({});
return enabled;
}
void tabulate_tensor(double * A,
const double * const * w,
const double * coordinate_dofs,
int cell_orientation) const final override
{
// This function was generated using 'tensor' representation
// with the following integrals metadata:
//
// num_cells: None
// quadrature_degree: 0
// quadrature_rule: 'default'
// representation: 'tensor'
//
// and the following integral 0 metadata:
//
// estimated_polynomial_degree: 0
// quadrature_degree: 0
// quadrature_rule: 'default'
// representation: 'tensor'
// Number of operations (multiply-add pairs) for Jacobian data: 3
// Number of operations (multiply-add pairs) for geometry tensor: 8
// Number of operations (multiply-add pairs) for tensor contraction: 11
// Total number of operations (multiply-add pairs): 22
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Set scale factor
const double det = std::abs(detJ);
// Compute geometry tensor
const double G0_0_0 = det*(K[0]*K[0] + K[1]*K[1]);
const double G0_0_1 = det*(K[0]*K[2] + K[1]*K[3]);
const double G0_1_0 = det*(K[2]*K[0] + K[3]*K[1]);
const double G0_1_1 = det*(K[2]*K[2] + K[3]*K[3]);
// Compute element tensor
A[0] = 0.499999999999999*G0_0_0 + 0.5*G0_0_1 + 0.5*G0_1_0 + 0.5*G0_1_1;
A[1] = -0.499999999999999*G0_0_0 - 0.5*G0_1_0;
A[2] = -0.5*G0_0_1 - 0.5*G0_1_1;
A[3] = -0.499999999999999*G0_0_0 - 0.5*G0_0_1;
A[4] = 0.499999999999999*G0_0_0;
A[5] = 0.5*G0_0_1;
A[6] = -0.5*G0_1_0 - 0.5*G0_1_1;
A[7] = 0.5*G0_1_0;
A[8] = 0.5*G0_1_1;
}
};
class multimeshpoisson_cutcell_integral_0_otherwise: public ufc::cutcell_integral
{
public:
multimeshpoisson_cutcell_integral_0_otherwise() : ufc::cutcell_integral()
{
}
~multimeshpoisson_cutcell_integral_0_otherwise() override
{
}
const std::vector<bool> & enabled_coefficients() const final override
{
static const std::vector<bool> enabled({});
return enabled;
}
void tabulate_tensor(double * A,
const double * const * w,
const double * coordinate_dofs,
std::size_t num_quadrature_points,
const double * quadrature_points,
const double * quadrature_weights,
int cell_orientation) const final override
{
// This function was generated using 'quadrature' representation
// with the following integrals metadata:
//
// num_cells: None
// quadrature_degree: 0
// quadrature_rule: 'default'
// representation: 'quadrature'
//
// and the following integral 0 metadata:
//
// estimated_polynomial_degree: 0
// quadrature_degree: 0
// quadrature_rule: 'default'
// representation: 'quadrature'
// --- Compute geometric quantities on cell 0 ---
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Compute cell volume
// Compute circumradius of triangle in 2D
// Set quadrature weights
const double* W = quadrature_weights;
// --- Evaluation of basis function derivatives of order 1 ---
// Create table FE0_D10 for basis function derivatives on all cells
std::vector<std::vector<double> > FE0_D10(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0_D10[ip].resize(3);
// Create table FE0_D01 for basis function derivatives on all cells
std::vector<std::vector<double> > FE0_D01(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0_D01[ip].resize(3);
// Evaluate basis function derivatives on cell 0
static double FE0_dvalues_1_0[6];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis function derivatives
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 0;
multimeshpoisson_finite_element_0::_evaluate_basis_derivatives_all(1, FE0_dvalues_1_0, x, v, cell_orientation);
// Copy values to table FE0_D10
for (std::size_t i = 0; i < 3; i++)
FE0_D10[ip][0 + i] = FE0_dvalues_1_0[2*i + 0];
// Copy values to table FE0_D01
for (std::size_t i = 0; i < 3; i++)
FE0_D01[ip][0 + i] = FE0_dvalues_1_0[2*i + 1];
} // end loop over 'ip'
// Reset values in the element tensor.
for (unsigned int r = 0; r < 9; r++)
{
A[r] = 0.0;
} // end loop over 'r'
// Compute element tensor using UFL quadrature representation
// Optimisations: ('eliminate zeros', False), ('ignore ones', False), ('ignore zero tables', False), ('optimisation', False), ('remove zero terms', False)
// Loop quadrature points for integral.
// Number of operations to compute element tensor for following IP loop = unknown
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Number of operations for primary indices: 81
for (unsigned int j = 0; j < 3; j++)
{
for (unsigned int k = 0; k < 3; k++)
{
// Number of operations to compute entry: 9
A[j*3 + k] += (((0 + FE0_D01[ip][j]))*((0 + FE0_D01[ip][k])) + ((FE0_D10[ip][j] + 0))*((FE0_D10[ip][k] + 0)))*W[ip];
} // end loop over 'k'
} // end loop over 'j'
} // end loop over 'ip'
}
};
class multimeshpoisson_interface_integral_0_otherwise: public ufc::interface_integral
{
public:
multimeshpoisson_interface_integral_0_otherwise() : ufc::interface_integral()
{
}
~multimeshpoisson_interface_integral_0_otherwise() override
{
}
const std::vector<bool> & enabled_coefficients() const final override
{
static const std::vector<bool> enabled({});
return enabled;
}
void tabulate_tensor(double * A,
const double * const * w,
const double * coordinate_dofs,
std::size_t num_quadrature_points,
const double * quadrature_points,
const double * quadrature_weights,
const double * facet_normals,
int cell_orientation) const final override
{
// This function was generated using 'quadrature' representation
// with the following integrals metadata:
//
// num_cells: None
// quadrature_degree: 2
// quadrature_rule: 'default'
// representation: 'quadrature'
//
// and the following integral 0 metadata:
//
// estimated_polynomial_degree: 2
// quadrature_degree: 2
// quadrature_rule: 'default'
// representation: 'quadrature'
// --- Compute geometric quantities on cell 0 ---
// Extract vertex coordinates
const double* coordinate_dofs_0 = coordinate_dofs + 0;
// Compute Jacobian
double J_0[4];
compute_jacobian_triangle_2d(J_0, coordinate_dofs_0);
// Compute Jacobian inverse and determinant
double K_0[4];
double detJ_0;
compute_jacobian_inverse_triangle_2d(K_0, detJ_0, J_0);
// Compute cell volume
const double volume_0 = std::abs(detJ_0)/2.0;
// Compute circumradius of triangle in 2D
const double v1v2_0 = std::sqrt((coordinate_dofs_0[4] - coordinate_dofs_0[2])*(coordinate_dofs_0[4] - coordinate_dofs_0[2]) + (coordinate_dofs_0[5] - coordinate_dofs_0[3])*(coordinate_dofs_0[5] - coordinate_dofs_0[3]) );
const double v0v2_0 = std::sqrt(J_0[3]*J_0[3] + J_0[1]*J_0[1]);
const double v0v1_0 = std::sqrt(J_0[0]*J_0[0] + J_0[2]*J_0[2]);
const double circumradius_0 = 0.25*(v1v2_0*v0v2_0*v0v1_0)/(volume_0);
// --- Compute geometric quantities on cell 1 ---
// Extract vertex coordinates
const double* coordinate_dofs_1 = coordinate_dofs + 6;
// Compute Jacobian
double J_1[4];
compute_jacobian_triangle_2d(J_1, coordinate_dofs_1);
// Compute Jacobian inverse and determinant
double K_1[4];
double detJ_1;
compute_jacobian_inverse_triangle_2d(K_1, detJ_1, J_1);
// Compute cell volume
const double volume_1 = std::abs(detJ_1)/2.0;
// Compute circumradius of triangle in 2D
const double v1v2_1 = std::sqrt((coordinate_dofs_1[4] - coordinate_dofs_1[2])*(coordinate_dofs_1[4] - coordinate_dofs_1[2]) + (coordinate_dofs_1[5] - coordinate_dofs_1[3])*(coordinate_dofs_1[5] - coordinate_dofs_1[3]) );
const double v0v2_1 = std::sqrt(J_1[3]*J_1[3] + J_1[1]*J_1[1]);
const double v0v1_1 = std::sqrt(J_1[0]*J_1[0] + J_1[2]*J_1[2]);
const double circumradius_1 = 0.25*(v1v2_1*v0v2_1*v0v1_1)/(volume_1);
// Set quadrature weights
const double* W = quadrature_weights;
// --- Evaluation of basis functions ---
// Create table FE0 for basis function values on all cells
std::vector<std::vector<double> > FE0(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0[ip].resize(6);
// Evaluate basis functions on cell 0
static double FE0_values_0[3];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis functions
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 0;
multimeshpoisson_finite_element_0::_evaluate_basis_all(FE0_values_0, x, v, cell_orientation);
// Copy values to table FE0
for (std::size_t i = 0; i < 3; i++)
FE0[ip][0 + i] = FE0_values_0[1*i + 0];
} // end loop over 'ip'
// Evaluate basis functions on cell 1
static double FE0_values_1[3];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis functions
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 6;
multimeshpoisson_finite_element_0::_evaluate_basis_all(FE0_values_1, x, v, cell_orientation);
// Copy values to table FE0
for (std::size_t i = 0; i < 3; i++)
FE0[ip][3 + i] = FE0_values_1[1*i + 0];
} // end loop over 'ip'
// --- Evaluation of basis function derivatives of order 1 ---
// Create table FE0_D10 for basis function derivatives on all cells
std::vector<std::vector<double> > FE0_D10(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0_D10[ip].resize(6);
// Create table FE0_D01 for basis function derivatives on all cells
std::vector<std::vector<double> > FE0_D01(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0_D01[ip].resize(6);
// Evaluate basis function derivatives on cell 0
static double FE0_dvalues_1_0[6];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis function derivatives
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 0;
multimeshpoisson_finite_element_0::_evaluate_basis_derivatives_all(1, FE0_dvalues_1_0, x, v, cell_orientation);
// Copy values to table FE0_D10
for (std::size_t i = 0; i < 3; i++)
FE0_D10[ip][0 + i] = FE0_dvalues_1_0[2*i + 0];
// Copy values to table FE0_D01
for (std::size_t i = 0; i < 3; i++)
FE0_D01[ip][0 + i] = FE0_dvalues_1_0[2*i + 1];
} // end loop over 'ip'
// Evaluate basis function derivatives on cell 1
static double FE0_dvalues_1_1[6];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis function derivatives
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 6;
multimeshpoisson_finite_element_0::_evaluate_basis_derivatives_all(1, FE0_dvalues_1_1, x, v, cell_orientation);
// Copy values to table FE0_D10
for (std::size_t i = 0; i < 3; i++)
FE0_D10[ip][3 + i] = FE0_dvalues_1_1[2*i + 0];
// Copy values to table FE0_D01
for (std::size_t i = 0; i < 3; i++)
FE0_D01[ip][3 + i] = FE0_dvalues_1_1[2*i + 1];
} // end loop over 'ip'
// Reset values in the element tensor.
for (unsigned int r = 0; r < 36; r++)
{
A[r] = 0.0;
} // end loop over 'r'
// Compute element tensor using UFL quadrature representation
// Optimisations: ('eliminate zeros', False), ('ignore ones', False), ('ignore zero tables', False), ('optimisation', False), ('remove zero terms', False)
// Loop quadrature points for integral.
// Number of operations to compute element tensor for following IP loop = unknown
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Set facet normal components for current quadrature point
const double n_00 = facet_normals[2*ip + 0];
const double n_10 = - facet_normals[2*ip + 0];
const double n_01 = facet_normals[2*ip + 1];
const double n_11 = - facet_normals[2*ip + 1];
// Number of operations for primary indices: 1080
for (unsigned int j = 0; j < 3; j++)
{
for (unsigned int k = 0; k < 3; k++)
{
// Number of operations to compute entry: 31
A[(j + 3)*6 + (k + 3)] += ((((((((FE0_D10[ip][k + 3]) + 0))*0.5)*(((FE0[ip][j + 3]))*n_10) + (((0 + (FE0_D01[ip][k + 3])))*0.5)*(((FE0[ip][j + 3]))*n_11)))*(-1.0) + (((FE0[ip][j + 3]))*(-1.0))*((((FE0[ip][k + 3]))*(-1.0))*(4.0/((2.0*circumradius_0 + 2.0*circumradius_1)/(2.0))))) + ((((((FE0_D10[ip][j + 3]) + 0))*0.5)*(((FE0[ip][k + 3]))*n_10) + (((0 + (FE0_D01[ip][j + 3])))*0.5)*(((FE0[ip][k + 3]))*n_11)))*(-1.0))*W[ip];
// Number of operations to compute entry: 30
A[(j + 3)*6 + k] += (((((((0 + FE0_D01[ip][k]))*0.5)*(((FE0[ip][j + 3]))*n_11) + (((FE0_D10[ip][k] + 0))*0.5)*(((FE0[ip][j + 3]))*n_10)))*(-1.0) + (((FE0[ip][j + 3]))*(-1.0))*(FE0[ip][k]*(4.0/((2.0*circumradius_0 + 2.0*circumradius_1)/(2.0))))) + ((((((FE0_D10[ip][j + 3]) + 0))*0.5)*FE0[ip][k]*n_00 + (((0 + (FE0_D01[ip][j + 3])))*0.5)*FE0[ip][k]*n_01))*(-1.0))*W[ip];
// Number of operations to compute entry: 30
A[j*6 + (k + 3)] += ((((((((FE0_D10[ip][k + 3]) + 0))*0.5)*FE0[ip][j]*n_00 + (((0 + (FE0_D01[ip][k + 3])))*0.5)*FE0[ip][j]*n_01))*(-1.0) + FE0[ip][j]*((((FE0[ip][k + 3]))*(-1.0))*(4.0/((2.0*circumradius_0 + 2.0*circumradius_1)/(2.0))))) + (((((0 + FE0_D01[ip][j]))*0.5)*(((FE0[ip][k + 3]))*n_11) + (((FE0_D10[ip][j] + 0))*0.5)*(((FE0[ip][k + 3]))*n_10)))*(-1.0))*W[ip];
// Number of operations to compute entry: 29
A[j*6 + k] += (((((((0 + FE0_D01[ip][k]))*0.5)*FE0[ip][j]*n_01 + (((FE0_D10[ip][k] + 0))*0.5)*FE0[ip][j]*n_00))*(-1.0) + FE0[ip][j]*(FE0[ip][k]*(4.0/((2.0*circumradius_0 + 2.0*circumradius_1)/(2.0))))) + (((((0 + FE0_D01[ip][j]))*0.5)*FE0[ip][k]*n_01 + (((FE0_D10[ip][j] + 0))*0.5)*FE0[ip][k]*n_00))*(-1.0))*W[ip];
} // end loop over 'k'
} // end loop over 'j'
} // end loop over 'ip'
}
};
class multimeshpoisson_overlap_integral_0_otherwise: public ufc::overlap_integral
{
public:
multimeshpoisson_overlap_integral_0_otherwise() : ufc::overlap_integral()
{
}
~multimeshpoisson_overlap_integral_0_otherwise() override
{
}
const std::vector<bool> & enabled_coefficients() const final override
{
static const std::vector<bool> enabled({});
return enabled;
}
void tabulate_tensor(double * A,
const double * const * w,
const double * coordinate_dofs,
std::size_t num_quadrature_points,
const double * quadrature_points,
const double * quadrature_weights,
int cell_orientation) const final override
{
// This function was generated using 'quadrature' representation
// with the following integrals metadata:
//
// num_cells: None
// quadrature_degree: 0
// quadrature_rule: 'default'
// representation: 'quadrature'
//
// and the following integral 0 metadata:
//
// estimated_polynomial_degree: 0
// quadrature_degree: 0
// quadrature_rule: 'default'
// representation: 'quadrature'
// --- Compute geometric quantities on cell 0 ---
// Extract vertex coordinates
const double* coordinate_dofs_0 = coordinate_dofs + 0;
// Compute Jacobian
double J_0[4];
compute_jacobian_triangle_2d(J_0, coordinate_dofs_0);
// Compute Jacobian inverse and determinant
double K_0[4];
double detJ_0;
compute_jacobian_inverse_triangle_2d(K_0, detJ_0, J_0);
// Compute cell volume
// Compute circumradius of triangle in 2D
// --- Compute geometric quantities on cell 1 ---
// Extract vertex coordinates
const double* coordinate_dofs_1 = coordinate_dofs + 6;
// Compute Jacobian
double J_1[4];
compute_jacobian_triangle_2d(J_1, coordinate_dofs_1);
// Compute Jacobian inverse and determinant
double K_1[4];
double detJ_1;
compute_jacobian_inverse_triangle_2d(K_1, detJ_1, J_1);
// Compute cell volume
// Compute circumradius of triangle in 2D
// Set quadrature weights
const double* W = quadrature_weights;
// --- Evaluation of basis function derivatives of order 1 ---
// Create table FE0_D10 for basis function derivatives on all cells
std::vector<std::vector<double> > FE0_D10(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0_D10[ip].resize(6);
// Create table FE0_D01 for basis function derivatives on all cells
std::vector<std::vector<double> > FE0_D01(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0_D01[ip].resize(6);
// Evaluate basis function derivatives on cell 0
static double FE0_dvalues_1_0[6];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis function derivatives
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 0;
multimeshpoisson_finite_element_0::_evaluate_basis_derivatives_all(1, FE0_dvalues_1_0, x, v, cell_orientation);
// Copy values to table FE0_D10
for (std::size_t i = 0; i < 3; i++)
FE0_D10[ip][0 + i] = FE0_dvalues_1_0[2*i + 0];
// Copy values to table FE0_D01
for (std::size_t i = 0; i < 3; i++)
FE0_D01[ip][0 + i] = FE0_dvalues_1_0[2*i + 1];
} // end loop over 'ip'
// Evaluate basis function derivatives on cell 1
static double FE0_dvalues_1_1[6];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis function derivatives
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 6;
multimeshpoisson_finite_element_0::_evaluate_basis_derivatives_all(1, FE0_dvalues_1_1, x, v, cell_orientation);
// Copy values to table FE0_D10
for (std::size_t i = 0; i < 3; i++)
FE0_D10[ip][3 + i] = FE0_dvalues_1_1[2*i + 0];
// Copy values to table FE0_D01
for (std::size_t i = 0; i < 3; i++)
FE0_D01[ip][3 + i] = FE0_dvalues_1_1[2*i + 1];
} // end loop over 'ip'
// Reset values in the element tensor.
for (unsigned int r = 0; r < 36; r++)
{
A[r] = 0.0;
} // end loop over 'r'
// Compute element tensor using UFL quadrature representation
// Optimisations: ('eliminate zeros', False), ('ignore ones', False), ('ignore zero tables', False), ('optimisation', False), ('remove zero terms', False)
// Loop quadrature points for integral.
// Number of operations to compute element tensor for following IP loop = unknown
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Number of operations for primary indices: 432
for (unsigned int j = 0; j < 3; j++)
{
for (unsigned int k = 0; k < 3; k++)
{
// Number of operations to compute entry: 14
A[(j + 3)*6 + (k + 3)] += ((((((FE0_D10[ip][j + 3]) + 0))*(-1.0))*((((FE0_D10[ip][k + 3]) + 0))*(-1.0)) + (((0 + (FE0_D01[ip][j + 3])))*(-1.0))*(((0 + (FE0_D01[ip][k + 3])))*(-1.0))))*4.0*W[ip];
// Number of operations to compute entry: 12
A[(j + 3)*6 + k] += ((((((FE0_D10[ip][j + 3]) + 0))*(-1.0))*((FE0_D10[ip][k] + 0)) + (((0 + (FE0_D01[ip][j + 3])))*(-1.0))*((0 + FE0_D01[ip][k]))))*4.0*W[ip];
// Number of operations to compute entry: 12
A[j*6 + (k + 3)] += ((((0 + FE0_D01[ip][j]))*(((0 + (FE0_D01[ip][k + 3])))*(-1.0)) + ((FE0_D10[ip][j] + 0))*((((FE0_D10[ip][k + 3]) + 0))*(-1.0))))*4.0*W[ip];
// Number of operations to compute entry: 10
A[j*6 + k] += ((((0 + FE0_D01[ip][j]))*((0 + FE0_D01[ip][k])) + ((FE0_D10[ip][j] + 0))*((FE0_D10[ip][k] + 0))))*4.0*W[ip];
} // end loop over 'k'
} // end loop over 'j'
} // end loop over 'ip'
}
};
class multimeshpoisson_cell_integral_1_otherwise: public ufc::cell_integral
{
public:
multimeshpoisson_cell_integral_1_otherwise() : ufc::cell_integral()
{
}
~multimeshpoisson_cell_integral_1_otherwise() override
{
}
const std::vector<bool> & enabled_coefficients() const final override
{
static const std::vector<bool> enabled({true});
return enabled;
}
void tabulate_tensor(double * A,
const double * const * w,
const double * coordinate_dofs,
int cell_orientation) const final override
{
// This function was generated using 'tensor' representation
// with the following integrals metadata:
//
// num_cells: None
// quadrature_degree: 2
// quadrature_rule: 'default'
// representation: 'tensor'
//
// and the following integral 0 metadata:
//
// estimated_polynomial_degree: 2
// quadrature_degree: 2
// quadrature_rule: 'default'
// representation: 'tensor'
// Number of operations (multiply-add pairs) for Jacobian data: 3
// Number of operations (multiply-add pairs) for geometry tensor: 3
// Number of operations (multiply-add pairs) for tensor contraction: 7
// Total number of operations (multiply-add pairs): 13
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Set scale factor
const double det = std::abs(detJ);
// Compute geometry tensor
const double G0_0 = det*w[0][0]*(1.0);
const double G0_1 = det*w[0][1]*(1.0);
const double G0_2 = det*w[0][2]*(1.0);
// Compute element tensor
A[0] = 0.0833333333333334*G0_0 + 0.0416666666666667*G0_1 + 0.0416666666666667*G0_2;
A[1] = 0.0416666666666667*G0_0 + 0.0833333333333333*G0_1 + 0.0416666666666666*G0_2;
A[2] = 0.0416666666666667*G0_0 + 0.0416666666666666*G0_1 + 0.0833333333333333*G0_2;
}
};
class multimeshpoisson_cutcell_integral_1_otherwise: public ufc::cutcell_integral
{
public:
multimeshpoisson_cutcell_integral_1_otherwise() : ufc::cutcell_integral()
{
}
~multimeshpoisson_cutcell_integral_1_otherwise() override
{
}
const std::vector<bool> & enabled_coefficients() const final override
{
static const std::vector<bool> enabled({true});
return enabled;
}
void tabulate_tensor(double * A,
const double * const * w,
const double * coordinate_dofs,
std::size_t num_quadrature_points,
const double * quadrature_points,
const double * quadrature_weights,
int cell_orientation) const final override
{
// This function was generated using 'quadrature' representation
// with the following integrals metadata:
//
// num_cells: None
// quadrature_degree: 2
// quadrature_rule: 'default'
// representation: 'quadrature'
//
// and the following integral 0 metadata:
//
// estimated_polynomial_degree: 2
// quadrature_degree: 2
// quadrature_rule: 'default'
// representation: 'quadrature'
// --- Compute geometric quantities on cell 0 ---
// Compute Jacobian
double J[4];
compute_jacobian_triangle_2d(J, coordinate_dofs);
// Compute Jacobian inverse and determinant
double K[4];
double detJ;
compute_jacobian_inverse_triangle_2d(K, detJ, J);
// Compute cell volume
// Compute circumradius of triangle in 2D
// Set quadrature weights
const double* W = quadrature_weights;
// --- Evaluation of basis functions ---
// Create table FE0 for basis function values on all cells
std::vector<std::vector<double> > FE0(num_quadrature_points);
for (std::size_t ip = 0; ip < num_quadrature_points; ip++)
FE0[ip].resize(3);
// Evaluate basis functions on cell 0
static double FE0_values_0[3];
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Get current quadrature point and compute values of basis functions
const double* x = quadrature_points + ip*2;
const double* v = coordinate_dofs + 0;
multimeshpoisson_finite_element_0::_evaluate_basis_all(FE0_values_0, x, v, cell_orientation);
// Copy values to table FE0
for (std::size_t i = 0; i < 3; i++)
FE0[ip][0 + i] = FE0_values_0[1*i + 0];
} // end loop over 'ip'
// Reset values in the element tensor.
for (unsigned int r = 0; r < 3; r++)
{
A[r] = 0.0;
} // end loop over 'r'
// Compute element tensor using UFL quadrature representation
// Optimisations: ('eliminate zeros', False), ('ignore ones', False), ('ignore zero tables', False), ('optimisation', False), ('remove zero terms', False)
// Loop quadrature points for integral.
// Number of operations to compute element tensor for following IP loop = unknown
for (unsigned int ip = 0; ip < num_quadrature_points; ip++)
{
// Coefficient declarations.
double F0 = 0.0;
// Total number of operations to compute function values = 6
for (unsigned int r = 0; r < 3; r++)
{
F0 += FE0[ip][r]*w[0][r];
} // end loop over 'r'
// Number of operations for primary indices: 9
for (unsigned int j = 0; j < 3; j++)
{
// Number of operations to compute entry: 3
A[j] += FE0[ip][j]*F0*W[ip];
} // end loop over 'j'
} // end loop over 'ip'
}
};
class multimeshpoisson_form_0: public ufc::form
{
public:
multimeshpoisson_form_0() : ufc::form()
{
// Do nothing
}
~multimeshpoisson_form_0() override
{
// Do nothing
}
const char * signature() const final override
{
return "e5230f2cce2577e8ae299f6ad858716c7a551cb9b1352609899bd42ddfaf5841f7a6a1e1afdc8eda868c55f272a114dd516babb4a52cadf5a1ef795843803cbd";
}
std::size_t rank() const final override
{
return 2;
}
std::size_t num_coefficients() const final override
{
return 0;
}
std::size_t original_coefficient_position(std::size_t i) const final override
{
static const std::vector<std::size_t> position({});
return position[i];
}
ufc::finite_element * create_coordinate_finite_element() const final override
{
return new multimeshpoisson_finite_element_1();
}
ufc::dofmap * create_coordinate_dofmap() const final override
{
return new multimeshpoisson_dofmap_1();
}
ufc::coordinate_mapping * create_coordinate_mapping() const final override
{
return nullptr;
}
ufc::finite_element * create_finite_element(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return new multimeshpoisson_finite_element_0();
break;
}
case 1:
{
return new multimeshpoisson_finite_element_0();
break;
}
}
return 0;
}
ufc::dofmap * create_dofmap(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return new multimeshpoisson_dofmap_0();
break;
}
case 1:
{
return new multimeshpoisson_dofmap_0();
break;
}
}
return 0;
}
std::size_t max_cell_subdomain_id() const final override
{
return 0;
}
std::size_t max_exterior_facet_subdomain_id() const final override
{
return 0;
}
std::size_t max_interior_facet_subdomain_id() const final override
{
return 0;
}
std::size_t max_vertex_subdomain_id() const final override
{
return 0;
}
std::size_t max_custom_subdomain_id() const final override
{
return 0;
}
std::size_t max_cutcell_subdomain_id() const final override
{
return 0;
}
std::size_t max_interface_subdomain_id() const final override
{
return 0;
}
std::size_t max_overlap_subdomain_id() const final override
{
return 0;
}
bool has_cell_integrals() const final override
{
return true;
}
bool has_exterior_facet_integrals() const final override
{
return false;
}
bool has_interior_facet_integrals() const final override
{
return false;
}
bool has_vertex_integrals() const final override
{
return false;
}
bool has_custom_integrals() const final override
{
return false;
}
bool has_cutcell_integrals() const final override
{
return true;
}
bool has_interface_integrals() const final override
{
return true;
}
bool has_overlap_integrals() const final override
{
return true;
}
ufc::cell_integral * create_cell_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::exterior_facet_integral * create_exterior_facet_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::interior_facet_integral * create_interior_facet_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::vertex_integral * create_vertex_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::custom_integral * create_custom_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::cutcell_integral * create_cutcell_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::interface_integral * create_interface_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::overlap_integral * create_overlap_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::cell_integral * create_default_cell_integral() const final override
{
return new multimeshpoisson_cell_integral_0_otherwise();
}
ufc::exterior_facet_integral * create_default_exterior_facet_integral() const final override
{
return 0;
}
ufc::interior_facet_integral * create_default_interior_facet_integral() const final override
{
return 0;
}
ufc::vertex_integral * create_default_vertex_integral() const final override
{
return 0;
}
ufc::custom_integral * create_default_custom_integral() const final override
{
return 0;
}
ufc::cutcell_integral * create_default_cutcell_integral() const final override
{
return new multimeshpoisson_cutcell_integral_0_otherwise();
}
ufc::interface_integral * create_default_interface_integral() const final override
{
return new multimeshpoisson_interface_integral_0_otherwise();
}
ufc::overlap_integral * create_default_overlap_integral() const final override
{
return new multimeshpoisson_overlap_integral_0_otherwise();
}
};
class multimeshpoisson_form_1: public ufc::form
{
public:
multimeshpoisson_form_1() : ufc::form()
{
// Do nothing
}
~multimeshpoisson_form_1() override
{
// Do nothing
}
const char * signature() const final override
{
return "2789e34dafc7d1968368327a7763bf0a71f55d0fe61acbe8e654613eea64482cd9ae5938c8d6db91c7361009e9faeaf34e34f6653b456de900e336dc52f95e62";
}
std::size_t rank() const final override
{
return 1;
}
std::size_t num_coefficients() const final override
{
return 1;
}
std::size_t original_coefficient_position(std::size_t i) const final override
{
static const std::vector<std::size_t> position({0});
return position[i];
}
ufc::finite_element * create_coordinate_finite_element() const final override
{
return new multimeshpoisson_finite_element_1();
}
ufc::dofmap * create_coordinate_dofmap() const final override
{
return new multimeshpoisson_dofmap_1();
}
ufc::coordinate_mapping * create_coordinate_mapping() const final override
{
return nullptr;
}
ufc::finite_element * create_finite_element(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return new multimeshpoisson_finite_element_0();
break;
}
case 1:
{
return new multimeshpoisson_finite_element_0();
break;
}
}
return 0;
}
ufc::dofmap * create_dofmap(std::size_t i) const final override
{
switch (i)
{
case 0:
{
return new multimeshpoisson_dofmap_0();
break;
}
case 1:
{
return new multimeshpoisson_dofmap_0();
break;
}
}
return 0;
}
std::size_t max_cell_subdomain_id() const final override
{
return 0;
}
std::size_t max_exterior_facet_subdomain_id() const final override
{
return 0;
}
std::size_t max_interior_facet_subdomain_id() const final override
{
return 0;
}
std::size_t max_vertex_subdomain_id() const final override
{
return 0;
}
std::size_t max_custom_subdomain_id() const final override
{
return 0;
}
std::size_t max_cutcell_subdomain_id() const final override
{
return 0;
}
std::size_t max_interface_subdomain_id() const final override
{
return 0;
}
std::size_t max_overlap_subdomain_id() const final override
{
return 0;
}
bool has_cell_integrals() const final override
{
return true;
}
bool has_exterior_facet_integrals() const final override
{
return false;
}
bool has_interior_facet_integrals() const final override
{
return false;
}
bool has_vertex_integrals() const final override
{
return false;
}
bool has_custom_integrals() const final override
{
return false;
}
bool has_cutcell_integrals() const final override
{
return true;
}
bool has_interface_integrals() const final override
{
return false;
}
bool has_overlap_integrals() const final override
{
return false;
}
ufc::cell_integral * create_cell_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::exterior_facet_integral * create_exterior_facet_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::interior_facet_integral * create_interior_facet_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::vertex_integral * create_vertex_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::custom_integral * create_custom_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::cutcell_integral * create_cutcell_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::interface_integral * create_interface_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::overlap_integral * create_overlap_integral(std::size_t subdomain_id) const final override
{
return 0;
}
ufc::cell_integral * create_default_cell_integral() const final override
{
return new multimeshpoisson_cell_integral_1_otherwise();
}
ufc::exterior_facet_integral * create_default_exterior_facet_integral() const final override
{
return 0;
}
ufc::interior_facet_integral * create_default_interior_facet_integral() const final override
{
return 0;
}
ufc::vertex_integral * create_default_vertex_integral() const final override
{
return 0;
}
ufc::custom_integral * create_default_custom_integral() const final override
{
return 0;
}
ufc::cutcell_integral * create_default_cutcell_integral() const final override
{
return new multimeshpoisson_cutcell_integral_1_otherwise();
}
ufc::interface_integral * create_default_interface_integral() const final override
{
return 0;
}
ufc::overlap_integral * create_default_overlap_integral() const final override
{
return 0;
}
};
// DOLFIN wrappers
// Standard library includes
#include <string>
// DOLFIN includes
#include <dolfin/common/NoDeleter.h>
#include <dolfin/mesh/Mesh.h>
#include <dolfin/mesh/MultiMesh.h>
#include <dolfin/fem/FiniteElement.h>
#include <dolfin/fem/DofMap.h>
#include <dolfin/fem/Form.h>
#include <dolfin/fem/MultiMeshForm.h>
#include <dolfin/function/FunctionSpace.h>
#include <dolfin/function/MultiMeshFunctionSpace.h>
#include <dolfin/function/GenericFunction.h>
#include <dolfin/function/CoefficientAssigner.h>
#include <dolfin/function/MultiMeshCoefficientAssigner.h>
#include <dolfin/adaptivity/ErrorControl.h>
#include <dolfin/adaptivity/GoalFunctional.h>
#include <dolfin/la/GenericVector.h>
namespace MultiMeshPoisson
{
class CoefficientSpace_f: public dolfin::FunctionSpace
{
public:
// Constructor for standard function space
CoefficientSpace_f(std::shared_ptr<const dolfin::Mesh> mesh):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh))
{
// Do nothing
}
// Constructor for constrained function space
CoefficientSpace_f(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh, constrained_domain))
{
// Do nothing
}
};
class Form_a_FunctionSpace_0: public dolfin::FunctionSpace
{
public:
// Constructor for standard function space
Form_a_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh))
{
// Do nothing
}
// Constructor for constrained function space
Form_a_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh, constrained_domain))
{
// Do nothing
}
};
class Form_a_FunctionSpace_1: public dolfin::FunctionSpace
{
public:
// Constructor for standard function space
Form_a_FunctionSpace_1(std::shared_ptr<const dolfin::Mesh> mesh):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh))
{
// Do nothing
}
// Constructor for constrained function space
Form_a_FunctionSpace_1(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh, constrained_domain))
{
// Do nothing
}
};
class Form_a_MultiMeshFunctionSpace_0: public dolfin::MultiMeshFunctionSpace
{
public:
// Constructor for multimesh function space
Form_a_MultiMeshFunctionSpace_0(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh)
{
// Create and add standard function spaces
for (std::size_t part = 0; part < multimesh->num_parts(); part++)
{
std::shared_ptr<const dolfin::FunctionSpace> V(new Form_a_FunctionSpace_0(multimesh->part(part)));
add(V);
}
// Build multimesh function space
build();
}
};
class Form_a_MultiMeshFunctionSpace_1: public dolfin::MultiMeshFunctionSpace
{
public:
// Constructor for multimesh function space
Form_a_MultiMeshFunctionSpace_1(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh)
{
// Create and add standard function spaces
for (std::size_t part = 0; part < multimesh->num_parts(); part++)
{
std::shared_ptr<const dolfin::FunctionSpace> V(new Form_a_FunctionSpace_1(multimesh->part(part)));
add(V);
}
// Build multimesh function space
build();
}
};
class Form_a: public dolfin::Form
{
public:
// Constructor
Form_a(std::shared_ptr<const dolfin::FunctionSpace> V1, std::shared_ptr<const dolfin::FunctionSpace> V0):
dolfin::Form(2, 0)
{
_function_spaces[0] = V0;
_function_spaces[1] = V1;
_ufc_form = std::make_shared<const multimeshpoisson_form_0>();
}
// Destructor
~Form_a()
{}
/// Return the number of the coefficient with this name
virtual std::size_t coefficient_number(const std::string& name) const
{
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"There are no coefficients");
return 0;
}
/// Return the name of the coefficient with this number
virtual std::string coefficient_name(std::size_t i) const
{
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"There are no coefficients");
return "unnamed";
}
// Typedefs
typedef Form_a_FunctionSpace_0 TestSpace;
typedef Form_a_FunctionSpace_1 TrialSpace;
typedef Form_a_MultiMeshFunctionSpace_0 MultiMeshTestSpace;
typedef Form_a_MultiMeshFunctionSpace_1 MultiMeshTrialSpace;
// Coefficients
};
class MultiMeshForm_a: public dolfin::MultiMeshForm
{
public:
// Constructor
MultiMeshForm_a(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V1, std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0):
dolfin::MultiMeshForm(V1, V0)
{
// Create and add standard forms
std::size_t num_parts = V0->num_parts(); // assume all equal and pick first
for (std::size_t part = 0; part < num_parts; part++)
{
std::shared_ptr<dolfin::Form> a(new Form_a(V1->part(part), V0->part(part)));
add(a);
}
// Build multimesh form
build();
/// Assign coefficients
}
// Destructor
~MultiMeshForm_a()
{}
/// Return the number of the coefficient with this name
virtual std::size_t coefficient_number(const std::string& name) const
{
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"There are no coefficients");
return 0;
}
/// Return the name of the coefficient with this number
virtual std::string coefficient_name(std::size_t i) const
{
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"There are no coefficients");
return "unnamed";
}
// Typedefs
typedef Form_a_FunctionSpace_0 TestSpace;
typedef Form_a_FunctionSpace_1 TrialSpace;
typedef Form_a_MultiMeshFunctionSpace_0 MultiMeshTestSpace;
typedef Form_a_MultiMeshFunctionSpace_1 MultiMeshTrialSpace;
// Coefficients
};
class Form_L_FunctionSpace_0: public dolfin::FunctionSpace
{
public:
// Constructor for standard function space
Form_L_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh))
{
// Do nothing
}
// Constructor for constrained function space
Form_L_FunctionSpace_0(std::shared_ptr<const dolfin::Mesh> mesh, std::shared_ptr<const dolfin::SubDomain> constrained_domain):
dolfin::FunctionSpace(mesh,
std::make_shared<const dolfin::FiniteElement>(std::make_shared<multimeshpoisson_finite_element_0>()),
std::make_shared<const dolfin::DofMap>(std::make_shared<multimeshpoisson_dofmap_0>(), *mesh, constrained_domain))
{
// Do nothing
}
};
class Form_L_MultiMeshFunctionSpace_0: public dolfin::MultiMeshFunctionSpace
{
public:
// Constructor for multimesh function space
Form_L_MultiMeshFunctionSpace_0(std::shared_ptr<const dolfin::MultiMesh> multimesh): dolfin::MultiMeshFunctionSpace(multimesh)
{
// Create and add standard function spaces
for (std::size_t part = 0; part < multimesh->num_parts(); part++)
{
std::shared_ptr<const dolfin::FunctionSpace> V(new Form_L_FunctionSpace_0(multimesh->part(part)));
add(V);
}
// Build multimesh function space
build();
}
};
typedef CoefficientSpace_f Form_L_FunctionSpace_1;
class Form_L: public dolfin::Form
{
public:
// Constructor
Form_L(std::shared_ptr<const dolfin::FunctionSpace> V0):
dolfin::Form(1, 1), f(*this, 0)
{
_function_spaces[0] = V0;
_ufc_form = std::make_shared<const multimeshpoisson_form_1>();
}
// Constructor
Form_L(std::shared_ptr<const dolfin::FunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> f):
dolfin::Form(1, 1), f(*this, 0)
{
_function_spaces[0] = V0;
this->f = f;
_ufc_form = std::make_shared<const multimeshpoisson_form_1>();
}
// Destructor
~Form_L()
{}
/// Return the number of the coefficient with this name
virtual std::size_t coefficient_number(const std::string& name) const
{
if (name == "f")
return 0;
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"Invalid coefficient");
return 0;
}
/// Return the name of the coefficient with this number
virtual std::string coefficient_name(std::size_t i) const
{
switch (i)
{
case 0:
return "f";
}
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"Invalid coefficient");
return "unnamed";
}
// Typedefs
typedef Form_L_FunctionSpace_0 TestSpace;
typedef Form_L_MultiMeshFunctionSpace_0 MultiMeshTestSpace;
typedef Form_L_FunctionSpace_1 CoefficientSpace_f;
// Coefficients
dolfin::CoefficientAssigner f;
};
class MultiMeshForm_L: public dolfin::MultiMeshForm
{
public:
// Constructor
MultiMeshForm_L(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0):
dolfin::MultiMeshForm(V0), f(*this, 0)
{
// Create and add standard forms
std::size_t num_parts = V0->num_parts(); // assume all equal and pick first
for (std::size_t part = 0; part < num_parts; part++)
{
std::shared_ptr<dolfin::Form> a(new Form_L(V0->part(part)));
add(a);
}
// Build multimesh form
build();
/// Assign coefficients
}
// Constructor
MultiMeshForm_L(std::shared_ptr<const dolfin::MultiMeshFunctionSpace> V0, std::shared_ptr<const dolfin::GenericFunction> f):
dolfin::MultiMeshForm(V0), f(*this, 0)
{
// Create and add standard forms
std::size_t num_parts = V0->num_parts(); // assume all equal and pick first
for (std::size_t part = 0; part < num_parts; part++)
{
std::shared_ptr<dolfin::Form> a(new Form_L(V0->part(part)));
add(a);
}
// Build multimesh form
build();
/// Assign coefficients
this->f = f;
}
// Destructor
~MultiMeshForm_L()
{}
/// Return the number of the coefficient with this name
virtual std::size_t coefficient_number(const std::string& name) const
{
if (name == "f")
return 0;
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"Invalid coefficient");
return 0;
}
/// Return the name of the coefficient with this number
virtual std::string coefficient_name(std::size_t i) const
{
switch (i)
{
case 0:
return "f";
}
dolfin::dolfin_error("generated code for class Form",
"access coefficient data",
"Invalid coefficient");
return "unnamed";
}
// Typedefs
typedef Form_L_FunctionSpace_0 TestSpace;
typedef Form_L_MultiMeshFunctionSpace_0 MultiMeshTestSpace;
typedef Form_L_FunctionSpace_1 CoefficientSpace_f;
// Coefficients
dolfin::MultiMeshCoefficientAssigner f;
};
// Class typedefs
typedef Form_a BilinearForm;
typedef MultiMeshForm_a MultiMeshBilinearForm;
typedef Form_a JacobianForm;
typedef MultiMeshForm_a MultiMeshJacobianForm;
typedef Form_L LinearForm;
typedef MultiMeshForm_L MultiMeshLinearForm;
typedef Form_L ResidualForm;
typedef MultiMeshForm_L MultiMeshResidualForm;
typedef Form_a::TestSpace FunctionSpace;
typedef Form_a::MultiMeshTestSpace MultiMeshFunctionSpace;
}
#endif
| [
"johannr@simula.no"
] | johannr@simula.no |
f91fd4740ac8b6422306df05917247ba7224b007 | 3ff1fe3888e34cd3576d91319bf0f08ca955940f | /cwp/include/tencentcloud/cwp/v20180228/model/DescribeBaselineRuleIgnoreListRequest.h | 5020acc5d6054caca352d7bdf88dfdec47c5832b | [
"Apache-2.0"
] | permissive | TencentCloud/tencentcloud-sdk-cpp | 9f5df8220eaaf72f7eaee07b2ede94f89313651f | 42a76b812b81d1b52ec6a217fafc8faa135e06ca | refs/heads/master | 2023-08-30T03:22:45.269556 | 2023-08-30T00:45:39 | 2023-08-30T00:45:39 | 188,991,963 | 55 | 37 | Apache-2.0 | 2023-08-17T03:13:20 | 2019-05-28T08:56:08 | C++ | UTF-8 | C++ | false | false | 6,770 | h | /*
* Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENCENTCLOUD_CWP_V20180228_MODEL_DESCRIBEBASELINERULEIGNORELISTREQUEST_H_
#define TENCENTCLOUD_CWP_V20180228_MODEL_DESCRIBEBASELINERULEIGNORELISTREQUEST_H_
#include <string>
#include <vector>
#include <map>
#include <tencentcloud/core/AbstractModel.h>
#include <tencentcloud/cwp/v20180228/model/Filter.h>
namespace TencentCloud
{
namespace Cwp
{
namespace V20180228
{
namespace Model
{
/**
* DescribeBaselineRuleIgnoreList请求参数结构体
*/
class DescribeBaselineRuleIgnoreListRequest : public AbstractModel
{
public:
DescribeBaselineRuleIgnoreListRequest();
~DescribeBaselineRuleIgnoreListRequest() = default;
std::string ToJsonString() const;
/**
* 获取<li>RuleName - String - 是否必填:否 - 规则名称</li>
<li>ItemId- int - 是否必填:否 - 检测项Id</li>
* @return Filters <li>RuleName - String - 是否必填:否 - 规则名称</li>
<li>ItemId- int - 是否必填:否 - 检测项Id</li>
*
*/
std::vector<Filter> GetFilters() const;
/**
* 设置<li>RuleName - String - 是否必填:否 - 规则名称</li>
<li>ItemId- int - 是否必填:否 - 检测项Id</li>
* @param _filters <li>RuleName - String - 是否必填:否 - 规则名称</li>
<li>ItemId- int - 是否必填:否 - 检测项Id</li>
*
*/
void SetFilters(const std::vector<Filter>& _filters);
/**
* 判断参数 Filters 是否已赋值
* @return Filters 是否已赋值
*
*/
bool FiltersHasBeenSet() const;
/**
* 获取限制条数,默认10,最大100
* @return Limit 限制条数,默认10,最大100
*
*/
int64_t GetLimit() const;
/**
* 设置限制条数,默认10,最大100
* @param _limit 限制条数,默认10,最大100
*
*/
void SetLimit(const int64_t& _limit);
/**
* 判断参数 Limit 是否已赋值
* @return Limit 是否已赋值
*
*/
bool LimitHasBeenSet() const;
/**
* 获取偏移量,默认0
* @return Offset 偏移量,默认0
*
*/
int64_t GetOffset() const;
/**
* 设置偏移量,默认0
* @param _offset 偏移量,默认0
*
*/
void SetOffset(const int64_t& _offset);
/**
* 判断参数 Offset 是否已赋值
* @return Offset 是否已赋值
*
*/
bool OffsetHasBeenSet() const;
/**
* 获取排序方式: [ASC:升序|DESC:降序]
* @return Order 排序方式: [ASC:升序|DESC:降序]
*
*/
std::string GetOrder() const;
/**
* 设置排序方式: [ASC:升序|DESC:降序]
* @param _order 排序方式: [ASC:升序|DESC:降序]
*
*/
void SetOrder(const std::string& _order);
/**
* 判断参数 Order 是否已赋值
* @return Order 是否已赋值
*
*/
bool OrderHasBeenSet() const;
/**
* 获取可选排序列: [HostCount]
* @return By 可选排序列: [HostCount]
*
*/
std::string GetBy() const;
/**
* 设置可选排序列: [HostCount]
* @param _by 可选排序列: [HostCount]
*
*/
void SetBy(const std::string& _by);
/**
* 判断参数 By 是否已赋值
* @return By 是否已赋值
*
*/
bool ByHasBeenSet() const;
private:
/**
* <li>RuleName - String - 是否必填:否 - 规则名称</li>
<li>ItemId- int - 是否必填:否 - 检测项Id</li>
*/
std::vector<Filter> m_filters;
bool m_filtersHasBeenSet;
/**
* 限制条数,默认10,最大100
*/
int64_t m_limit;
bool m_limitHasBeenSet;
/**
* 偏移量,默认0
*/
int64_t m_offset;
bool m_offsetHasBeenSet;
/**
* 排序方式: [ASC:升序|DESC:降序]
*/
std::string m_order;
bool m_orderHasBeenSet;
/**
* 可选排序列: [HostCount]
*/
std::string m_by;
bool m_byHasBeenSet;
};
}
}
}
}
#endif // !TENCENTCLOUD_CWP_V20180228_MODEL_DESCRIBEBASELINERULEIGNORELISTREQUEST_H_
| [
"tencentcloudapi@tencent.com"
] | tencentcloudapi@tencent.com |
2b1e52a6cbf68b80b1207375815a8301709dfaf2 | 08d17ddeb5713d8e7a4ee01054fcce78ed7f5191 | /tensorflow/compiler/xla/service/while_loop_trip_count_annotator_test.cc | 5c19cbc015dab7721dc60e015ca7125cc628fc0a | [
"Apache-2.0"
] | permissive | Godsinred/tensorflow | 9cd67e1088ad8893265651ad4a5c45a6640b6c96 | 45100d5f55d7cba15bffcd91bf521ed37daf7bca | refs/heads/master | 2020-04-25T19:44:53.669366 | 2019-02-28T01:54:55 | 2019-02-28T02:59:15 | 173,030,955 | 2 | 0 | Apache-2.0 | 2019-02-28T03:03:41 | 2019-02-28T03:03:41 | null | UTF-8 | C++ | false | false | 6,970 | cc | /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/compiler/xla/service/while_loop_trip_count_annotator.h"
#include "tensorflow/compiler/xla/service/pattern_matcher.h"
#include "tensorflow/compiler/xla/service/while_loop_simplifier.h"
#include "tensorflow/compiler/xla/status_macros.h"
#include "tensorflow/compiler/xla/test.h"
#include "tensorflow/compiler/xla/tests/hlo_test_base.h"
#include "tensorflow/core/lib/core/status_test_util.h"
namespace xla {
namespace {
class TripCountAnnotatorTest : public HloTestBase {};
TEST_F(TripCountAnnotatorTest, KnownSmallTripCount) {
const char* kModuleStr = R"(
HloModule test
Body {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
one = s32[] constant(1)
i_plus_one = s32[] add(i, one)
ROOT tuple = (s32[]) tuple(i_plus_one)
}
Cond {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
trip_count = s32[] constant(10)
ROOT done = pred[] less-than(i, trip_count)
}
ENTRY test {
i_start = s32[] constant(0)
initial_tuple = (s32[]) tuple(i_start)
ROOT while = (s32[]) while(initial_tuple), condition=Cond, body=Body
})";
TF_ASSERT_OK_AND_ASSIGN(auto m, ParseAndReturnVerifiedModule(kModuleStr));
WhileLoopTripCountAnnotator pass;
TF_ASSERT_OK_AND_ASSIGN(bool changed, RunHloPass(&pass, m.get()));
ASSERT_TRUE(changed);
TF_ASSERT_OK_AND_ASSIGN(auto config,
m->entry_computation()
->root_instruction()
->backend_config<WhileLoopBackendConfig>());
EXPECT_EQ(10, config.known_trip_count().n());
}
TEST_F(TripCountAnnotatorTest, KnownLargeTripCount) {
const char* kModuleStr = R"(
HloModule test
Body {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
one = s32[] constant(1)
i_plus_one = s32[] add(i, one)
ROOT tuple = (s32[]) tuple(i_plus_one)
}
Cond {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
trip_count = s32[] constant(1000000)
ROOT done = pred[] less-than(i, trip_count)
}
ENTRY test {
i_start = s32[] constant(0)
initial_tuple = (s32[]) tuple(i_start)
ROOT while = (s32[]) while(initial_tuple), condition=Cond, body=Body
})";
TF_ASSERT_OK_AND_ASSIGN(auto m, ParseAndReturnVerifiedModule(kModuleStr));
WhileLoopTripCountAnnotator pass;
TF_ASSERT_OK_AND_ASSIGN(bool changed, RunHloPass(&pass, m.get()));
ASSERT_TRUE(changed);
TF_ASSERT_OK_AND_ASSIGN(auto config,
m->entry_computation()
->root_instruction()
->backend_config<WhileLoopBackendConfig>());
EXPECT_EQ(1000000, config.known_trip_count().n());
}
TEST_F(TripCountAnnotatorTest, NonzeroStart) {
const char* kModuleStr = R"(
HloModule test
Body {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
one = s32[] constant(1)
i_plus_one = s32[] add(i, one)
ROOT tuple = (s32[]) tuple(i_plus_one)
}
Cond {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
trip_count = s32[] constant(1000000)
ROOT done = pred[] less-than(i, trip_count)
}
ENTRY test {
i_start = s32[] constant(10)
initial_tuple = (s32[]) tuple(i_start)
ROOT while = (s32[]) while(initial_tuple), condition=Cond, body=Body
})";
TF_ASSERT_OK_AND_ASSIGN(auto m, ParseAndReturnVerifiedModule(kModuleStr));
WhileLoopTripCountAnnotator pass;
TF_ASSERT_OK_AND_ASSIGN(bool changed, RunHloPass(&pass, m.get()));
ASSERT_TRUE(changed);
TF_ASSERT_OK_AND_ASSIGN(auto config,
m->entry_computation()
->root_instruction()
->backend_config<WhileLoopBackendConfig>());
EXPECT_EQ(999990, config.known_trip_count().n());
}
TEST_F(TripCountAnnotatorTest, LessThanOrEqualTo) {
const char* kModuleStr = R"(
HloModule test
Body {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
one = s32[] constant(1)
i_plus_one = s32[] add(i, one)
ROOT tuple = (s32[]) tuple(i_plus_one)
}
Cond {
param = (s32[]) parameter(0)
i = s32[] get-tuple-element(param), index=0
trip_count = s32[] constant(1000000)
ROOT done = pred[] less-than-or-equal-to(i, trip_count)
}
ENTRY test {
i_start = s32[] constant(10)
initial_tuple = (s32[]) tuple(i_start)
ROOT while = (s32[]) while(initial_tuple), condition=Cond, body=Body
})";
TF_ASSERT_OK_AND_ASSIGN(auto m, ParseAndReturnVerifiedModule(kModuleStr));
WhileLoopTripCountAnnotator pass;
TF_ASSERT_OK_AND_ASSIGN(bool changed, RunHloPass(&pass, m.get()));
ASSERT_TRUE(changed);
TF_ASSERT_OK_AND_ASSIGN(auto config,
m->entry_computation()
->root_instruction()
->backend_config<WhileLoopBackendConfig>());
EXPECT_EQ(999991, config.known_trip_count().n());
}
TEST_F(TripCountAnnotatorTest, Int64Overflow) {
// for(i = INT64_MIN; i < INT64_MAX; ++i)
//
// We store the trip count as an int64, so this loop is unanalyzable.
const char* kModuleStr = R"(
HloModule test
Body {
param = (s64[]) parameter(0)
i = s64[] get-tuple-element(param), index=0
one = s64[] constant(1)
i_plus_one = s64[] add(i, one)
ROOT tuple = (s64[]) tuple(i_plus_one)
}
Cond {
param = (s64[]) parameter(0)
i = s64[] get-tuple-element(param), index=0
trip_count = s64[] constant(9223372036854775807) // 2^63-1
ROOT done = pred[] less-than-or-equal-to(i, trip_count)
}
ENTRY test {
i_start = s64[] constant(-9223372036854775808) // -2^63
initial_tuple = (s64[]) tuple(i_start)
ROOT while = (s64[]) while(initial_tuple), condition=Cond, body=Body
})";
TF_ASSERT_OK_AND_ASSIGN(auto m, ParseAndReturnVerifiedModule(kModuleStr));
WhileLoopTripCountAnnotator pass;
TF_ASSERT_OK_AND_ASSIGN(bool changed, RunHloPass(&pass, m.get()));
EXPECT_FALSE(changed);
}
} // namespace
} // namespace xla
| [
"gardener@tensorflow.org"
] | gardener@tensorflow.org |
b0521eec49ecb754b839019b8915a0c7e47d9a41 | d8ea5358838f3624b0ac11ef2f4d96caa4e2e356 | /C_BA_String.cpp | d20e214c69a15c17b2edd752bb8971247b5c7869 | [] | no_license | md-omar-f/codeforces-problem-solutions | b81794ce6b601347a6857ce084d5cc7c3d00e4d9 | db2939c437bf5901c9f5c953d9006ed822ecf312 | refs/heads/master | 2023-05-12T05:19:38.597484 | 2023-04-29T19:46:24 | 2023-04-29T19:46:24 | 283,279,144 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 977 | cpp | #include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define forn(i,n) for(int i=0;i<int(n);++i)
#define vet(a) for(auto&i:a)cout<<i<<" "
#define out(a) cout<<a<<endl
#define lli long long int
void solve(){
lli n,k,x;cin>>n>>k>>x;
--x;
string s;cin>>s;
reverse(s.begin(),s.end());
string ans="";
lli i=0;
while(i<n){
if(s[i]=='a'){
ans+='a';++i;continue;
}
lli cnt=0;
while(i<n&&s[i]=='*'){
cnt+=k;++i;
}
for(lli j=0;j<(x%(cnt+1));++j){
ans+='b';
}
x/=cnt+1;
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
}
int32_t main(){
IOS;
/*
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
*/
int t=1;
cin>>t;
while(t--){
solve();
}
return 0;
} | [
"faruqmdomar07@gmail.com"
] | faruqmdomar07@gmail.com |
8b936673d19f742c05781ddc699e4dc2000432b3 | 05b166f163992e1aa67f089c0c86d27a9c3af786 | /~2022/Graph_traversal/2251.cpp | ef63c89dac290b18ba5b6a671f639edb8764aef3 | [] | no_license | gyeolse/algorithm_study | 52417554c9ab7ffc761c3b78e143683a9c18abaa | bdfd3f0ae0661a0163f5575f40a6984a6f453104 | refs/heads/master | 2022-08-31T11:32:27.502032 | 2022-08-06T12:18:50 | 2022-08-06T12:18:50 | 246,004,136 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 247 | cpp | #include <bits/stdc++.h>
using namespace std;
int a, b, c;
int tong[3] = {0,0,0};
int main() {
cin>>a>>b>>c;
while(1) {
if(tong[0] == 0 && tong[2] !=0) {
cout<<tong[2]<<" ";
}
}
return 0;
} | [
"threewave@kakao.com"
] | threewave@kakao.com |
8a8d09b3796b317b81039c7d94e60db0d4bb6f24 | 87960daf16cca9bc7f46fe26571333b619f2bafc | /test/cpp/jit/test_misc.h | 36c22dcb5934d537c8d090165b0bad64a45273cd | [
"BSD-3-Clause",
"LicenseRef-scancode-generic-cla",
"Apache-2.0",
"BSD-2-Clause"
] | permissive | Roulbac/pytorch | d754e7d464a62c25f6c6b9c3bba77eb76363efec | 6c52a5f60321bb9fbd6cec31cbfb79811f3201ea | refs/heads/master | 2020-04-26T06:55:18.194409 | 2019-03-02T18:20:27 | 2019-03-02T18:20:27 | 173,379,856 | 0 | 0 | NOASSERTION | 2019-03-01T23:10:05 | 2019-03-01T23:10:05 | null | UTF-8 | C++ | false | false | 60,238 | h | #pragma once
#include "test/cpp/jit/test_base.h"
#include "ATen/core/interned_strings.h"
#include "torch/csrc/autograd/generated/variable_factories.h"
#include "torch/csrc/autograd/variable.h"
#include "torch/csrc/jit/argument_spec.h"
#include "torch/csrc/jit/attributes.h"
#include "torch/csrc/jit/autodiff.h"
#include "torch/csrc/jit/code_template.h"
#include "torch/csrc/jit/custom_operator.h"
#include "torch/csrc/jit/dynamic_dag.h"
#include "torch/csrc/jit/fuser/interface.h"
#include "torch/csrc/jit/import.h"
#include "torch/csrc/jit/interpreter.h"
#include "torch/csrc/jit/passes/alias_analysis.h"
#include "torch/csrc/jit/passes/common_subexpression_elimination.h"
#include "torch/csrc/jit/passes/constant_propagation.h"
#include "torch/csrc/jit/passes/create_autodiff_subgraphs.h"
#include "torch/csrc/jit/passes/dead_code_elimination.h"
#include "torch/csrc/jit/passes/graph_fuser.h"
#include "torch/csrc/jit/passes/lower_grad_of.h"
#include "torch/csrc/jit/passes/lower_tuples.h"
#include "torch/csrc/jit/passes/requires_grad_analysis.h"
#include "torch/csrc/jit/passes/shape_analysis.h"
#include "torch/csrc/jit/passes/utils/subgraph_utils.h"
#include "torch/csrc/jit/symbolic_script.h"
#include "torch/csrc/jit/symbolic_variable.h"
#include "torch/csrc/jit/tracer.h"
#include "torch/csrc/utils/hash.h"
#include "torch/csrc/utils/memory.h"
#include "torch/csrc/autograd/engine.h"
#include "torch/csrc/autograd/variable.h"
#include "ATen/core/ivalue.h"
#include "torch/csrc/jit/graph_executor.h"
#include "torch/csrc/jit/script/compiler.h"
#include "torch/csrc/jit/script/module.h"
#include "onnx/onnx_pb.h"
#include <ATen/ATen.h>
#include <c10/util/Exception.h>
#include <algorithm>
#include <cstddef>
#include <functional>
#include <iostream>
#include <memory>
#include <stdexcept>
#include <string>
#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>
namespace torch {
namespace jit {
namespace {
using Var = SymbolicVariable;
using namespace torch::autograd;
template <typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& list) {
size_t i = 0;
out << "{";
for (auto&& e : list) {
if (i++ > 0)
out << ", ";
out << e;
}
out << "}";
return out;
}
auto ct = CodeTemplate(R"(
int foo($args) {
$bar
$bar
$a+$b
}
int commatest(int a${,stuff})
int notest(int a${,empty,})
)");
auto ct_expect = R"(
int foo(hi, 8) {
what
on many
lines...
7
what
on many
lines...
7
3+4
}
int commatest(int a, things..., others)
int notest(int a)
)";
void testCodeTemplate() {
{
TemplateEnv e;
e.s("hi", "foo");
e.v("what", {"is", "this"});
TemplateEnv c(e);
c.s("hi", "foo2");
ASSERT_EQ(e.s("hi"), "foo");
ASSERT_EQ(c.s("hi"), "foo2");
ASSERT_EQ(e.v("what")[0], "is");
}
{
TemplateEnv e;
e.v("args", {"hi", "8"});
e.v("bar", {"what\non many\nlines...", "7"});
e.s("a", "3");
e.s("b", "4");
e.v("stuff", {"things...", "others"});
e.v("empty", {});
auto s = ct.format(e);
// std::cout << "'" << s << "'\n";
// std::cout << "'" << ct_expect << "'\n";
ASSERT_EQ(s, ct_expect);
}
}
void testFusion() {
auto testSimple = [&] {
Graph graph;
Var i0 = Var::asNewInput(graph);
Var i1 = Var::asNewInput(graph);
auto o0 = i0 * i1;
o0.addAsOutput();
auto a = at::rand({3, 4}, at::kCUDA);
auto b = at::rand({4, 3}, at::kCUDA).transpose(0, 1);
auto o = at::zeros({3, 4}, at::kCUDA);
auto outputs = debugLaunchGraph(graph, {a, b});
ASSERT_EQ(outputs.size(), 1);
auto o2 = a * b;
float max_diff = (o2 - outputs[0]).abs().max().item<double>();
// std::cout << "max diff: " << max_diff << "\n";
ASSERT_EQ(max_diff, 0);
};
testSimple();
auto testOne = [&](int ti, int tj, int toi, int toj) {
Graph graph;
Var i0 = Var::asNewInput(graph);
Var i1 = Var::asNewInput(graph);
Var i2 = Var::asNewInput(graph);
Var i3 = Var::asNewInput(graph);
Var i4 = Var::asNewInput(graph);
auto p22 = i4.sigmoid();
auto p20 = i3.sigmoid();
auto p18 = i2.tanh();
auto p16 = i1.sigmoid();
auto p14 = p20 * i0;
auto p11 = p22 * p18;
auto o1 = p14 + p11;
auto p5 = o1.tanh();
auto o0 = p16 * p5;
o0.addAsOutput();
o1.addAsOutput();
graph.lint();
std::vector<at::Tensor> inputs;
// We want to generate input/output tensors with dimension 128x128x32, but
// with different internal strides. To do this, we generate a tensor
// with the "wrong" dimensions, and then use transpose to get an
// appropriately sized view.
for (size_t i = 0; i < graph.inputs().size(); i++) {
std::vector<int64_t> dims = {128, 128, 32};
std::swap(dims[ti], dims[tj]);
inputs.push_back(at::rand(dims, at::kCUDA).transpose(ti, tj));
}
auto t22 = inputs[4].sigmoid();
auto t20 = inputs[3].sigmoid();
auto t18 = inputs[2].tanh();
auto t16 = inputs[1].sigmoid();
auto t14 = t20 * inputs[0];
auto t11 = t22 * t18;
auto out1 = t14 + t11;
auto t5 = out1.tanh();
auto out0 = t16 * t5;
auto outputs = debugLaunchGraph(graph, inputs);
ASSERT_EQ(outputs.size(), graph.outputs().size());
ASSERT_TRUE(out0.is_same_size(outputs.front()));
float max_diff = (outputs.front() - out0).abs().max().item<double>();
ASSERT_TRUE(max_diff < 1e-6);
};
testOne(0, 0, 0, 0);
testOne(0, 1, 0, 0);
testOne(1, 2, 0, 0);
testOne(0, 2, 0, 0);
testOne(0, 0, 0, 1);
testOne(0, 1, 1, 2);
testOne(1, 2, 0, 2);
auto createFusedConcat =
[](Graph& graph, at::ArrayRef<Value*> inputs, int64_t dim) -> Value* {
return graph
.insertNode(graph.create(prim::FusedConcat, inputs)->i_(attr::dim, dim))
->output();
};
auto testConcat = [&](int dim) {
Graph graph;
Var i0 = Var::asNewInput(graph);
Var i1 = Var::asNewInput(graph);
auto o0 = i0 * i1;
o0.addAsOutput();
Var(createFusedConcat(graph, {i0, o0}, dim)).addAsOutput();
auto a = at::rand({3, 4, 5}, at::kCUDA);
auto b = at::rand({4, 3, 5}, at::kCUDA).transpose(0, 1);
auto o_r = a * b;
auto o2_r = at::cat({a, o_r}, dim);
auto outputs = debugLaunchGraph(graph, {a, b});
ASSERT_EQ(outputs.size(), 2);
float max_diff = (o_r - outputs[0]).abs().max().item<double>();
ASSERT_EQ(max_diff, 0);
float max_diff2 = (o2_r - outputs[1]).abs().max().item<double>();
ASSERT_EQ(max_diff2, 0);
};
testConcat(0);
testConcat(1);
testConcat(2);
}
void testAttributes() {
Graph g;
auto one = attr::alpha;
auto two = attr::device;
auto three = attr::end;
auto four = attr::perm;
Node* n = g.create(Symbol::fromQualString("foo::bar"));
Node& attr = *n;
attr.f_(one, 3.4)->i_(two, 5)->s_(three, "what");
ASSERT_EQ(attr.f(one), 3.4);
ASSERT_EQ(attr.s(three), "what");
ASSERT_EQ(attr.i(two), 5);
attr.s_(one, "no");
ASSERT_EQ(attr.s(one), "no");
ASSERT_TRUE(attr.hasAttribute(three));
ASSERT_TRUE(!attr.hasAttribute(four));
attr.ss_(two, {"hi", "now"});
ASSERT_EQ(attr.ss(two).at(1), "now");
Node* n2 = g.create(Symbol::fromQualString("foo::baz"));
Node& attr2 = *n2;
attr2.copyAttributes(attr);
ASSERT_EQ(attr2.s(one), "no");
attr2.f_(one, 5);
ASSERT_EQ(attr.s(one), "no");
ASSERT_EQ(attr2.f(one), 5);
}
void testInternedStrings() {
ASSERT_EQ(prim::Param, Symbol::prim("Param"));
ASSERT_EQ(prim::Return, Symbol::prim("Return"));
ASSERT_EQ(prim::Return.toUnqualString(), std::string("Return"));
ASSERT_EQ(prim::Return.toQualString(), std::string("prim::Return"));
Symbol newsym = Symbol::aten("__NEW_SYMBOL");
size_t symstart = newsym;
ASSERT_EQ(newsym.toQualString(), std::string("aten::__NEW_SYMBOL"));
// TODO: This test is a bit too close to the implementation details.
ASSERT_EQ(Symbol::aten("What"), symstart + 1);
ASSERT_EQ(Symbol::aten("What2"), symstart + 2);
ASSERT_EQ(Symbol::aten("What"), symstart + 1);
ASSERT_EQ(Symbol::aten("What2"), symstart + 2);
ASSERT_EQ(Symbol(symstart + 2).toUnqualString(), std::string("What2"));
}
void testFromQualString() {
ASSERT_EQ(Symbol::fromQualString("prim::Param"), Symbol::prim("Param"));
ASSERT_EQ(Symbol::fromQualString("aten::mm"), Symbol::aten("mm"));
ASSERT_EQ(Symbol::fromQualString("onnx::LSTM"), Symbol::onnx("LSTM"));
ASSERT_EQ(Symbol::fromQualString("attr::value"), Symbol::attr("value"));
ASSERT_EQ(Symbol::fromQualString("scope::"), Symbol::scope(""));
ASSERT_EQ(Symbol::fromQualString("::").toUnqualString(), std::string(""));
ASSERT_EQ(
Symbol::fromQualString("::").ns().toQualString(),
std::string("namespaces::"));
ASSERT_EQ(
Symbol::fromQualString("new_ns::param").toUnqualString(),
std::string("param"));
ASSERT_EQ(
Symbol::fromQualString("new_ns::param").ns().toUnqualString(),
std::string("new_ns"));
ASSERT_EQ(
Symbol::fromQualString("new_ns::param").ns(),
Symbol::fromQualString("namespaces::new_ns"));
auto bad_inputs = {"scope", ":", ""};
for (auto input : bad_inputs) {
try {
Symbol::fromQualString(input);
ASSERT_TRUE(0);
} catch (const std::exception& c) {
}
}
}
at::Tensor t_use(at::Tensor x) {
return x;
}
at::Tensor t_def(at::Tensor x) {
return x.t();
}
// given the difference of output vs expected tensor, check whether the
// difference is within a relative tolerance range. This is a standard way of
// matching tensor values upto certain precision
bool checkRtol(const at::Tensor& diff, const std::vector<at::Tensor> inputs) {
double maxValue = 0.0;
for (auto& tensor : inputs) {
maxValue = fmax(tensor.abs().max().item<float>(), maxValue);
}
return diff.abs().max().item<float>() < 2e-6 * maxValue;
}
bool almostEqual(const at::Tensor& a, const at::Tensor& b) {
return checkRtol(a - b, {a, b});
}
bool exactlyEqual(const at::Tensor& a, const at::Tensor& b) {
return (a - b).abs().max().item<float>() == 0.f;
}
std::pair<at::Tensor, at::Tensor> lstm(
at::Tensor input,
at::Tensor hx,
at::Tensor cx,
at::Tensor w_ih,
at::Tensor w_hh) {
auto gates = input.mm(t_use(w_ih)) + hx.mm(t_use(w_hh));
auto chunked_gates = gates.chunk(4, 1);
auto ingate = chunked_gates[0];
auto forgetgate = chunked_gates[1];
auto cellgate = chunked_gates[2];
auto outgate = chunked_gates[3];
ingate = ingate.sigmoid();
outgate = outgate.sigmoid();
cellgate = cellgate.tanh();
forgetgate = forgetgate.sigmoid();
auto cy = (forgetgate * cx) + (ingate * cellgate);
auto hy = outgate * cy.tanh();
return {hy, cy};
}
std::tuple<Var, Var> build_lstm_body(
Graph& g,
Var input,
Var hx,
Var cx,
Var w_ih,
Var w_hh) {
auto gates = input.mm(w_ih);
gates = gates + hx.mm(w_hh);
auto outputs = gates.chunk(4, 1);
auto ingate = outputs[0];
auto forgetgate = outputs[1];
auto cellgate = outputs[2];
auto outgate = outputs[3];
ingate = ingate.sigmoid();
outgate = outgate.sigmoid();
cellgate = cellgate.tanh();
forgetgate = forgetgate.sigmoid();
auto cy = forgetgate * cx;
cy = cy + ingate * cellgate;
auto hy = outgate * cy.tanh();
return std::make_tuple(hy, cy);
}
std::shared_ptr<Graph> build_lstm() {
auto r = std::make_shared<Graph>();
auto& g = *r;
Value* input = g.addInput();
Value* hx = g.addInput();
Value* cx = g.addInput();
Value* w_ih = g.addInput();
Value* w_hh = g.addInput();
Var hy;
Var cy;
std::tie(hy, cy) = build_lstm_body(g, input, hx, cx, w_ih, w_hh);
hy.addAsOutput();
cy.addAsOutput();
g.lint();
return r;
}
std::vector<at::Tensor> run(
InterpreterState& interp,
const std::vector<at::Tensor>& inputs) {
std::vector<IValue> stack(inputs.begin(), inputs.end());
interp.run(stack);
return fmap(stack, [](const IValue& i) { return i.toTensor(); });
}
std::pair<tensor_list, tensor_list> runGradient(
Gradient& grad_spec,
tensor_list& tensors_in,
tensor_list& tensor_grads_in) {
static const auto as_tensorlist = [](const Stack& stack) {
return fmap(stack, [](const IValue& i) { return i.toTensor(); });
};
Code f_code{grad_spec.f}, df_code{grad_spec.df};
InterpreterState f_interpreter{f_code}, df_interpreter{df_code};
auto f_stack = fmap<IValue>(tensors_in);
f_interpreter.run(f_stack);
Stack df_stack;
df_stack.insert(
df_stack.end(), tensor_grads_in.begin(), tensor_grads_in.end());
for (auto offset : grad_spec.df_input_captured_inputs)
df_stack.push_back(tensors_in[offset]);
for (auto offset : grad_spec.df_input_captured_outputs)
df_stack.push_back(f_stack[offset]);
df_interpreter.run(df_stack);
// Outputs of f needs to be sliced
f_stack.erase(f_stack.begin() + grad_spec.f_real_outputs, f_stack.end());
return std::make_pair(as_tensorlist(f_stack), as_tensorlist(df_stack));
}
void assertAllClose(const tensor_list& a, const tensor_list& b) {
ASSERT_EQ(a.size(), b.size());
for (size_t i = 0; i < a.size(); ++i) {
ASSERT_TRUE(a[i].is_same_size(b[i]));
ASSERT_TRUE(a[i].allclose(b[i]));
}
}
void testInterp() {
constexpr int batch_size = 4;
constexpr int input_size = 256;
constexpr int seq_len = 32;
int hidden_size = 2 * input_size;
auto input = at::randn({seq_len, batch_size, input_size}, at::kCUDA);
auto hx = at::randn({batch_size, hidden_size}, at::kCUDA);
auto cx = at::randn({batch_size, hidden_size}, at::kCUDA);
auto w_ih = t_def(at::randn({4 * hidden_size, input_size}, at::kCUDA));
auto w_hh = t_def(at::randn({4 * hidden_size, hidden_size}, at::kCUDA));
auto lstm_g = build_lstm();
Code lstm_function(lstm_g);
InterpreterState lstm_interp(lstm_function);
auto outputs = run(lstm_interp, {input[0], hx, cx, w_ih, w_hh});
std::tie(hx, cx) = lstm(input[0], hx, cx, w_ih, w_hh);
// std::cout << almostEqual(outputs[0],hx) << "\n";
ASSERT_TRUE(exactlyEqual(outputs[0], hx));
ASSERT_TRUE(exactlyEqual(outputs[1], cx));
}
void testTHNNConv() {
std::vector<int64_t> input_size = {4, 3, 15, 17}; // B x C x H x W
std::vector<int64_t> kernel_size = {3, 5};
std::vector<int64_t> stride = {1, 2};
std::vector<int64_t> padding = {2, 1};
constexpr int out_channels = 5;
// make inputs
at::Tensor input = torch::randn(input_size);
at::Tensor weight = torch::randn(
{out_channels, input_size[1], kernel_size[0], kernel_size[1]});
at::Tensor bias = torch::randn({out_channels});
// run forward eagerly
at::Tensor output, finput, fgradinput;
std::tie(output, finput, fgradinput) = at::thnn_conv2d_forward(
input, weight, kernel_size, bias, stride, padding);
// make grad_outputs
at::Tensor grad_output = torch::randn_like(output);
at::Tensor grad_finput = torch::zeros_like(finput);
at::Tensor grad_fgradinput = torch::zeros_like(fgradinput);
// run backward eagerly
at::Tensor grad_input, grad_weight, grad_bias;
std::tie(grad_input, grad_weight, grad_bias) = at::thnn_conv2d_backward(
grad_output,
input,
weight,
kernel_size,
stride,
padding,
finput,
fgradinput,
{true, true, true});
// make JIT graph
auto graph = std::make_shared<Graph>();
auto ksz_val = graph->insertConstant(IValue(kernel_size));
auto kst_val = graph->insertConstant(IValue(stride));
auto pad_val = graph->insertConstant(IValue(padding));
auto inputg = graph->addInput("self");
auto weightg = graph->addInput("weight");
auto biasg = graph->addInput("bias");
Value* conv = graph->insert(
aten::thnn_conv2d_forward,
{inputg, weightg, ksz_val, biasg, kst_val, pad_val});
auto outputs = conv->node()->outputs();
for (auto output : outputs) {
graph->registerOutput(output);
}
LowerAllTuples(graph);
graph->lint();
// differentiate JIT graph
EliminateDeadCode(graph); // Tracing of some ops depends on the DCE trick
ConstantPropagation(graph);
auto grad_spec = differentiate(graph);
LowerGradOf(*grad_spec.df);
// prepare JIT inputs / gradients
tensor_list tensors_in;
tensors_in.push_back(input);
tensors_in.push_back(weight);
tensors_in.push_back(bias);
tensor_list tensor_grads_in;
tensor_grads_in.push_back(grad_output);
tensor_grads_in.push_back(grad_finput);
tensor_grads_in.push_back(grad_fgradinput);
// Get outputs from the interpreter
tensor_list tensors_out, tensor_grads_out;
std::tie(tensors_out, tensor_grads_out) =
runGradient(grad_spec, tensors_in, tensor_grads_in);
// prepare expected structs
tensor_list expected_tensors_out, expected_tensor_grads_out;
expected_tensors_out.push_back(output);
expected_tensors_out.push_back(finput);
expected_tensors_out.push_back(fgradinput);
expected_tensor_grads_out.push_back(grad_input);
expected_tensor_grads_out.push_back(grad_weight);
expected_tensor_grads_out.push_back(grad_bias);
// Compare results
assertAllClose(tensors_out, expected_tensors_out);
assertAllClose(tensor_grads_out, expected_tensor_grads_out);
}
void testATenNativeBatchNorm() {
// aten::native_batch_norm(Tensor input, Tensor weight, Tensor bias, Tensor
// running_mean, Tensor running_var, bool training, float momentum, float eps)
// -> (Tensor, Tensor, Tensor)
std::vector<int64_t> input_size = {4, 3, 15, 17}; // B x C x H x W
bool training = true;
float momentum = 0.9;
float eps = 1e-5;
// make inputs
at::Tensor input = torch::randn(input_size);
at::Tensor weight = torch::randn({input_size[1]});
at::Tensor bias = torch::randn({input_size[1]});
at::Tensor running_mean = torch::randn({input_size[1]});
at::Tensor running_var = torch::randn({input_size[1]});
// running_mean and running_var are changed in-place, so clone and send them
at::Tensor running_mean_eager = running_mean.clone();
at::Tensor running_var_eager = running_var.clone();
at::Tensor running_mean_jit = running_mean.clone();
at::Tensor running_var_jit = running_var.clone();
// run forward eagerly
at::Tensor output, savemean, saveinvstd;
std::tie(output, savemean, saveinvstd) = at::native_batch_norm(
input,
weight,
bias,
running_mean_eager,
running_var_eager,
training,
momentum,
eps);
// make grad_outputs
at::Tensor grad_output = torch::randn_like(output);
at::Tensor grad_savemean = torch::zeros_like(savemean);
at::Tensor grad_saveinvstd = torch::zeros_like(saveinvstd);
// run backward eagerly
at::Tensor grad_input, grad_weight, grad_bias;
// aten::native_batch_norm_backward(Tensor grad_out, Tensor input, Tensor
// weight, Tensor running_mean, Tensor running_var, Tensor save_mean, Tensor
// save_invstd, bool train, float eps, bool[3] output_mask) -> (Tensor,
// Tensor, Tensor)
std::tie(grad_input, grad_weight, grad_bias) = at::native_batch_norm_backward(
grad_output,
input,
weight,
running_mean_eager,
running_var_eager,
savemean,
saveinvstd,
training,
eps,
{true, true, true});
// make JIT graph
auto graph = std::make_shared<Graph>();
auto training_val = graph->insertConstant(IValue(training));
auto momentum_val = graph->insertConstant(IValue(momentum));
auto eps_val = graph->insertConstant(IValue(eps));
auto inputg = graph->addInput("self");
auto weightg = graph->addInput("weight");
auto biasg = graph->addInput("bias");
auto running_meang = graph->addInput("running_mean");
auto running_varg = graph->addInput("running_var");
Value* bn = graph->insert(
aten::native_batch_norm,
{inputg,
weightg,
biasg,
running_meang,
running_varg,
training_val,
momentum_val,
eps_val});
auto outputs = bn->node()->outputs();
for (auto output : outputs) {
graph->registerOutput(output);
}
LowerAllTuples(graph);
graph->lint();
// differentiate JIT graph
EliminateDeadCode(graph); // Tracing of some ops depends on the DCE trick
ConstantPropagation(graph);
auto grad_spec = differentiate(graph);
LowerGradOf(*grad_spec.df);
// prepare JIT inputs / gradients
tensor_list tensors_in;
tensors_in.push_back(input);
tensors_in.push_back(weight);
tensors_in.push_back(bias);
tensors_in.push_back(running_mean_jit);
tensors_in.push_back(running_var_jit);
tensor_list tensor_grads_in;
tensor_grads_in.push_back(grad_output);
tensor_grads_in.push_back(grad_savemean);
tensor_grads_in.push_back(grad_saveinvstd);
// Get outputs from the interpreter
tensor_list tensors_out, tensor_grads_out;
std::tie(tensors_out, tensor_grads_out) =
runGradient(grad_spec, tensors_in, tensor_grads_in);
// prepare expected structs
tensor_list expected_tensors_out, expected_tensor_grads_out;
expected_tensors_out.push_back(output);
expected_tensors_out.push_back(savemean);
expected_tensors_out.push_back(saveinvstd);
expected_tensors_out.push_back(running_mean_eager);
expected_tensors_out.push_back(running_var_eager);
expected_tensor_grads_out.push_back(grad_input);
expected_tensor_grads_out.push_back(grad_weight);
expected_tensor_grads_out.push_back(grad_bias);
tensors_out.push_back(running_mean_jit);
tensors_out.push_back(running_var_jit);
// Compare results
assertAllClose(tensors_out, expected_tensors_out);
assertAllClose(tensor_grads_out, expected_tensor_grads_out);
}
using var_meta_type = std::vector<int64_t>;
using var_meta_list = std::vector<var_meta_type>;
using test_fn_type = std::function<variable_list(const variable_list&)>;
struct ADTestSpec {
ADTestSpec(const char* name, var_meta_list input_meta, test_fn_type test_fn)
: name(name), input_meta(input_meta), test_fn(test_fn) {}
variable_list operator()(const variable_list& inputs) const {
return test_fn(inputs);
};
std::vector<Variable> make_vars() const {
std::vector<Variable> out;
for (const auto& m : input_meta) {
out.push_back(torch::randn(m, at::requires_grad(true)));
}
return out;
}
const char* name;
var_meta_list input_meta;
test_fn_type test_fn;
};
variable_list get_grad_outputs(const variable_list& vars) {
return fmap(vars, [](const Variable& v) -> Variable {
return at::randn(v.sizes(), v.options());
});
}
std::shared_ptr<Graph> trace(
const ADTestSpec& test,
const variable_list& vars_in) {
std::shared_ptr<tracer::TracingState> state;
Stack trace_stack_in;
std::tie(state, trace_stack_in) = tracer::enter(fmap<IValue>(vars_in));
variable_list trace_vars_in = fmap(
trace_stack_in, [](const IValue& v) { return Variable(v.toTensor()); });
auto trace_vars_out = test(trace_vars_in);
tracer::exit(fmap<IValue>(trace_vars_out));
return state->graph;
}
variable_list grad(
const variable_list& outputs,
const variable_list& inputs,
const variable_list& grad_outputs) {
const auto get_edge = [](const Variable& v) { return v.gradient_edge(); };
auto& engine = torch::autograd::Engine::get_default_engine();
return engine.execute(
fmap(outputs, get_edge),
grad_outputs,
true,
false,
fmap(inputs, get_edge));
}
void testADFormulas() {
const auto unwrap = [](const Variable& v) { return v.data(); };
using VL = variable_list;
const var_meta_list binary_pointwise = {{2, 3, 4, 5}, {2, 3, 4, 5}};
const var_meta_list unary_pointwise = {{2, 3, 4, 5}};
const var_meta_list unary_pointwise_2d = {{2, 3}};
const std::vector<ADTestSpec> ad_tests = {
{"add",
binary_pointwise,
[](const VL& v) -> VL { return {v[0] + v[1]}; }},
{"sub",
binary_pointwise,
[](const VL& v) -> VL { return {v[0] - v[1]}; }},
{"mul",
binary_pointwise,
[](const VL& v) -> VL { return {v[0] * v[1]}; }},
{"sigmoid",
unary_pointwise,
[](const VL& v) -> VL { return {v[0].sigmoid()}; }},
{"tanh",
unary_pointwise,
[](const VL& v) -> VL { return {v[0].tanh()}; }},
{"t", unary_pointwise_2d, [](const VL& v) -> VL { return {v[0].t()}; }},
{"view",
unary_pointwise_2d,
[](const VL& v) -> VL {
return {v[0].view({3, 2})};
}},
{"expand",
{{2, 1}},
[](const VL& v) -> VL {
return {v[0].expand({2, 3})};
}},
{"mm",
{{10, 12}, {12, 15}},
[](const VL& v) -> VL { return {v[0].mm(v[1])}; }},
// TODO: enable once we'll be able to capture lists across
// forward-backward
//{"chunk", {{10, 12, 15}}, [](const VL& v) -> VL { return
// fmap<Variable>(v[0].chunk(4, 1)); }},
//{"chunk", {{10, 12, 15}}, [](const VL& v) -> VL { return
// fmap<Variable>(v[0].chunk(3, 2)); }},
//{"split", {{10, 12, 15}}, [](const VL& v) -> VL { return
// fmap<Variable>(v[0].split(4, 1)); }},
//{"split", {{10, 12, 15}}, [](const VL& v) -> VL { return
// fmap<Variable>(v[0].split(3, 2)); }},
};
for (const auto& test : ad_tests) {
// Get reference values form autograd
auto vars_in = test.make_vars();
auto vars_out = test(vars_in);
auto var_grads_in = get_grad_outputs(vars_out);
auto var_grads_out = grad(vars_out, vars_in, var_grads_in);
// Trace and differentiate the op
auto graph = trace(test, vars_in);
EliminateDeadCode(graph); // Tracing of some ops depends on the DCE trick
ConstantPropagation(graph);
auto grad_spec = differentiate(graph);
LowerGradOf(*grad_spec.df);
// Get outputs from the interpreter
auto tensors_in = fmap(vars_in, unwrap);
auto tensor_grads_in = fmap(var_grads_in, unwrap);
tensor_list tensors_out, tensor_grads_out;
std::tie(tensors_out, tensor_grads_out) =
runGradient(grad_spec, tensors_in, tensor_grads_in);
// Compare results
auto expected_tensors_out = fmap(vars_out, unwrap);
auto expected_tensor_grads_out = fmap(var_grads_out, unwrap);
assertAllClose(tensors_out, expected_tensors_out);
assertAllClose(tensor_grads_out, expected_tensor_grads_out);
}
}
void testDifferentiate(std::ostream& out = std::cout) {
auto graph = std::make_shared<Graph>();
at::ScalarType s = at::ScalarType::Float;
auto type = CompleteTensorType::create(s, at::kCPU, {2, 3, 4}, {12, 4, 1});
// Build up a fake graph
auto a = SymbolicVariable::asNewInput(*graph, type);
auto b = SymbolicVariable::asNewInput(*graph, type);
auto c = a * b * a + b;
graph->registerOutput(c.value());
auto grad_spec = differentiate(graph);
std::vector<size_t> expected_captured_inputs = {0, 1};
std::vector<size_t> expected_captured_outputs = {1, 2};
std::vector<size_t> expected_input_vjps = {0, 1};
std::vector<size_t> expected_output_vjps = {0, 1};
ASSERT_EQ(grad_spec.f_real_outputs, 1);
ASSERT_EQ(grad_spec.df_input_captured_inputs, expected_captured_inputs);
ASSERT_EQ(grad_spec.df_input_captured_outputs, expected_captured_outputs);
ASSERT_EQ(grad_spec.df_input_vjps, expected_input_vjps);
ASSERT_EQ(grad_spec.df_output_vjps, expected_output_vjps);
out << "testDifferentiate\n";
out << *grad_spec.f;
out << *grad_spec.df;
out << "\n";
}
void testDifferentiateWithRequiresGrad(std::ostream& out = std::cout) {
// Build up a fake graph
auto graph = std::make_shared<Graph>();
auto a = SymbolicVariable::asNewInput(*graph);
auto b = SymbolicVariable::asNewInput(*graph);
auto d = b * b + b;
auto e = (d + a) * a + b;
graph->registerOutput(d.value());
graph->registerOutput(e.value());
auto a_var = autograd::make_variable(
at::empty_strided(2, 2, at::CPU(at::kFloat).options()), true);
auto b_var = autograd::make_variable(
at::empty_strided(2, 2, at::CPU(at::kFloat).options()), false);
setInputTypes(*graph, ArgumentSpec(true, {a_var, b_var}, 2));
PropagateInputShapes(graph);
PropagateRequiresGrad(graph);
auto grad_spec = differentiate(graph);
std::vector<size_t> expected_input_vjps = {1, 2}; // for e and %4 = (d + a)
std::vector<size_t> expected_output_vjps = {0}; // only a requires grad
ASSERT_EQ(grad_spec.f_real_outputs, 2);
ASSERT_EQ(grad_spec.df_input_captured_inputs, std::vector<size_t>({0}));
ASSERT_EQ(grad_spec.df_input_captured_outputs, std::vector<size_t>({2, 3}));
ASSERT_EQ(grad_spec.df_input_vjps, expected_input_vjps);
ASSERT_EQ(grad_spec.df_output_vjps, expected_output_vjps);
out << "testDifferentiateWithRequiresGrad\n";
out << *grad_spec.f;
out << *grad_spec.df;
out << "\n";
}
void testRegisterFusionCachesKernel(std::ostream& out = std::cout) {
// Build up a fake graph with a FusionGroup
auto createGraphWithNames = [](std::string cname, std::string dname) {
auto graph = std::make_shared<Graph>();
at::ScalarType s = at::ScalarType::Float;
auto type = CompleteTensorType::create(s, at::kCPU, {2, 3, 4}, {12, 4, 1});
auto a = SymbolicVariable::asNewInput(*graph, type);
auto b = SymbolicVariable::asNewInput(*graph, type);
auto c = a * b;
auto d = c * a;
c.value()->setUniqueName(cname);
d.value()->setUniqueName(dname);
graph->registerOutput(d.value());
torch::jit::overrideCanFuseOnCPU(true);
FuseGraph(graph);
torch::jit::overrideCanFuseOnCPU(false);
return graph;
};
auto getFusionGroup = [](const std::shared_ptr<Graph>& graph) {
const auto& nodes = graph->nodes();
auto maybe_fusion_group =
std::find_if(nodes.begin(), nodes.end(), [](const Node* node) {
return node->kind() == prim::FusionGroup;
});
AT_CHECK(
maybe_fusion_group != nodes.end(),
"testRegisterFusionCachesKernel: could not create FusionGroup");
return *maybe_fusion_group;
};
// Create two alpha-equivalent fusion groups
auto graph1 = createGraphWithNames("c1", "d1");
auto fg1 = getFusionGroup(graph1);
auto graph2 = createGraphWithNames("c2", "d2");
auto fg2 = getFusionGroup(graph2);
// Register both with the fusion compiler.
auto expected_key = registerFusion(fg1);
auto second_key = registerFusion(fg2);
// Because the graphs are alpha-equivalent, they should return the same key
// and therefore share a KernelSpec to share kernels for specializations
ASSERT_EQ(second_key, expected_key);
}
void testCreateAutodiffSubgraphs(std::ostream& out = std::cout) {
auto graph = build_lstm();
CreateAutodiffSubgraphs(graph, /*threshold=*/2);
out << "testCreateAutodiffSubgraphs\n";
out << *graph << "\n";
}
void testSubgraphUtils() {
auto graph = build_lstm();
EliminateCommonSubexpression(graph);
std::vector<Node*> originalNodes(
graph->nodes().begin(), graph->nodes().end());
// Merge everything into a single subgraph
bool first = true;
Node* subgraph;
for (auto it = graph->nodes().rbegin(); it != graph->nodes().rend();) {
if (first) {
subgraph = SubgraphUtils::createSingletonSubgraph(
*it, prim::DifferentiableGraph);
it = ++subgraph->reverseIterator();
first = false;
}
SubgraphUtils::mergeNodeIntoSubgraph(*it, subgraph);
it = ++subgraph->reverseIterator();
}
// Unmerge and compare with original node listing
SubgraphUtils::unmergeSubgraph(subgraph);
EliminateCommonSubexpression(graph);
std::vector<Node*> newNodes(graph->nodes().begin(), graph->nodes().end());
ASSERT_EQ(originalNodes.size(), newNodes.size());
}
autograd::Variable var(at::Type& t, at::IntArrayRef sizes, bool requires_grad) {
return autograd::make_variable(at::rand(sizes, t.options()), requires_grad);
}
autograd::Variable undef() {
return autograd::Variable();
}
int device(const autograd::Variable& v) {
return v.type().is_cuda() ? v.get_device() : -1;
}
bool isEqual(at::IntArrayRef lhs, at::IntArrayRef rhs) {
return lhs.size() == rhs.size() &&
std::equal(lhs.begin(), lhs.end(), rhs.begin());
}
bool isEqual(const CompleteArgumentInfo& ti, const autograd::Variable& v) {
if (!ti.defined())
return ti.defined() == v.defined();
return ti.device() == device(v) && ti.requires_grad() == v.requires_grad() &&
ti.type() == v.type().scalarType() && isEqual(ti.sizes(), v.sizes()) &&
isEqual(ti.strides(), v.strides());
}
// work around the fact that variable_tensor_list doesn't duplicate all
// of std::vector's constructors.
// most constructors are never used in the implementation, just in our tests.
Stack createStack(std::vector<at::Tensor>&& list) {
return Stack(
std::make_move_iterator(list.begin()),
std::make_move_iterator(list.end()));
}
void testArgumentSpec() {
auto& CF = at::CPU(at::kFloat);
auto& CD = at::CPU(at::kDouble);
auto& GF = at::CUDA(at::kFloat);
auto& GD = at::CUDA(at::kDouble);
auto list = createStack({var(CF, {1}, true),
var(CD, {1, 2}, false),
var(GF, {}, true),
var(GD, {4, 5, 6}, false),
undef()});
// make sure we have some non-standard strides
list[1].toTensor().transpose_(0, 1);
// same list but different backing values
auto list2 = createStack({var(CF, {1}, true),
var(CD, {1, 2}, false),
var(GF, {}, true),
var(GD, {4, 5, 6}, false),
undef()});
list2[1].toTensor().transpose_(0, 1);
CompleteArgumentSpec a(true, list);
CompleteArgumentSpec b(true, list);
ASSERT_EQ(a.hashCode(), b.hashCode());
ASSERT_EQ(a, b);
CompleteArgumentSpec d(true, list2);
ASSERT_EQ(d, a);
ASSERT_EQ(d.hashCode(), a.hashCode());
for (size_t i = 0; i < list.size(); ++i) {
ASSERT_TRUE(isEqual(a.at(i), list[i].toTensor()));
}
CompleteArgumentSpec no_grad(/*with_grad=*/false, list);
ASSERT_TRUE(no_grad != a);
std::unordered_set<CompleteArgumentSpec> spec;
spec.insert(std::move(a));
ASSERT_TRUE(spec.count(b) > 0);
ASSERT_EQ(spec.count(no_grad), 0);
spec.insert(std::move(no_grad));
ASSERT_EQ(spec.count(CompleteArgumentSpec(true, list)), 1);
list2[1].toTensor().transpose_(0, 1);
CompleteArgumentSpec c(true, list2); // same as list, except for one stride
ASSERT_FALSE(c == a);
ASSERT_EQ(spec.count(c), 0);
Stack stack = {var(CF, {1, 2}, true), 3, var(CF, {1, 2}, true)};
CompleteArgumentSpec with_const(true, stack);
ASSERT_EQ(with_const.at(2).sizes().size(), 2);
}
void testGraphExecutor() {
constexpr int batch_size = 4;
constexpr int input_size = 256;
int hidden_size = 2 * input_size;
auto v = [](at::Tensor t) { return autograd::make_variable(t, false); };
auto input = at::randn({batch_size, input_size}, at::kCUDA);
auto hx = at::randn({batch_size, hidden_size}, at::kCUDA);
auto cx = at::randn({batch_size, hidden_size}, at::kCUDA);
auto w_ih = t_def(at::randn({4 * hidden_size, input_size}, at::kCUDA));
auto w_hh = t_def(at::randn({4 * hidden_size, hidden_size}, at::kCUDA));
auto g = build_lstm();
GraphExecutor executor(g);
auto stack = createStack({v(input), v(hx), v(cx), v(w_ih), v(w_hh)});
executor.run(stack);
ASSERT_EQ(stack.size(), 2);
at::Tensor r0, r1;
std::tie(r0, r1) = lstm(input, hx, cx, w_ih, w_hh);
ASSERT_TRUE(almostEqual(Variable(stack[0].toTensor()).data(), r0));
ASSERT_TRUE(almostEqual(Variable(stack[1].toTensor()).data(), r1));
}
void testBlocks(std::ostream& out = std::cout) {
Graph g;
auto a = Var::asNewInput(g, "a");
auto b = Var::asNewInput(g, "b");
auto c = a + b;
auto r = g.appendNode(g.create(prim::If, {Var::asNewInput(g, "c").value()}));
auto then_block = r->addBlock();
auto else_block = r->addBlock();
{
WithInsertPoint guard(then_block);
auto t = c + c;
then_block->registerOutput(t.value());
}
{
WithInsertPoint guard(else_block);
auto d = b + c;
auto e = d + c;
else_block->registerOutput(e.value());
}
g.registerOutput((Var(r->output()) + c).value());
g.lint();
out << "testBlocks\n" << g << "\n";
r->eraseBlock(0);
out << g << "\n";
g.lint();
// test recursive copy of blocks works
auto g2 = g.copy();
out << *g2 << "\n";
}
const auto cf_examples = R"JIT(
def if_test(a, b):
# FIXME: use 0 instead of a.
# c = 0
c = a
if bool(a < b):
c = b
else:
c = a
return c
def if_one(a, b):
c = b
if bool(a < b):
c = a
return c
def while_test(a, i):
while bool(i < 3):
a *= a
i += 1
return a
)JIT";
void testControlFlow() {
auto cu = std::make_shared<script::Module>();
script::defineMethodsInModule(
cu, cf_examples, script::nativeResolver, nullptr);
auto run = [&](const std::string& name, std::vector<IValue> stack) {
auto graph = cu->get_method(name).graph();
Code code(graph);
InterpreterState interp(code);
interp.run(stack);
return stack;
};
auto L = [](int64_t l) {
return IValue(autograd::make_variable(scalar_to_tensor(at::Scalar(l))));
};
auto V = [](IValue t) { return std::move(t).toTensor().item<int64_t>(); };
auto run_binary = [&](const std::string& name, int64_t a, int64_t b) {
return V(run(name, {L(a), L(b)})[0]);
};
ASSERT_EQ(2, run_binary("if_test", 1, 2));
ASSERT_EQ(3, run_binary("if_test", 3, 2));
ASSERT_EQ(2, run_binary("if_one", 2, 3));
ASSERT_EQ(2, run_binary("if_one", 3, 2));
ASSERT_EQ(256, run_binary("while_test", 2, 0));
}
void testIValue() {
Shared<IntList> foo = IntList::create({3, 4, 5});
ASSERT_EQ(foo.use_count(), 1);
IValue bar{foo};
ASSERT_EQ(foo.use_count(), 2);
auto baz = bar;
ASSERT_EQ(foo.use_count(), 3);
auto foo2 = std::move(bar);
ASSERT_EQ(foo.use_count(), 3);
ASSERT_TRUE(foo2.isIntList());
ASSERT_TRUE(bar.isNone());
foo2 = IValue(4.0);
ASSERT_TRUE(foo2.isDouble());
ASSERT_EQ(foo2.toDouble(), 4.0);
ASSERT_EQ(foo.use_count(), 2);
ASSERT_TRUE(ArrayRef<int64_t>(baz.toIntList()->elements()).equals({3, 4, 5}));
auto move_it = std::move(baz).toIntList();
ASSERT_EQ(foo.use_count(), 2);
ASSERT_TRUE(baz.isNone());
IValue i(4);
ASSERT_TRUE(i.isInt());
ASSERT_EQ(i.toInt(), 4);
IValue dlist(DoubleList::create({3.5}));
ASSERT_TRUE(dlist.isDoubleList());
ASSERT_TRUE(ArrayRef<double>(std::move(dlist).toDoubleList()->elements())
.equals({3.5}));
ASSERT_TRUE(dlist.isNone());
dlist = IValue(DoubleList::create({3.4}));
ASSERT_TRUE(ArrayRef<double>(dlist.toDoubleList()->elements()).equals({3.4}));
IValue the_list(Tuple::create({IValue(3.4), IValue(4), IValue(foo)}));
ASSERT_EQ(foo.use_count(), 3);
ASSERT_TRUE(the_list.isTuple());
auto first = std::move(the_list).toTuple()->elements().at(1);
ASSERT_EQ(first.toInt(), 4);
at::Tensor tv = at::rand({3, 4});
IValue ten(tv);
ASSERT_EQ(tv.use_count(), 2);
auto ten2 = ten;
ASSERT_EQ(tv.use_count(), 3);
ASSERT_TRUE(ten2.toTensor().equal(ten.toTensor()));
std::move(ten2).toTensor();
ASSERT_EQ(tv.use_count(), 2);
}
void testProto() {
::ONNX_NAMESPACE::ModelProto proto;
proto.set_producer_name("foo");
}
void testCustomOperators() {
{
RegisterOperators reg({createOperator(
"foo::bar", [](double a, at::Tensor b) { return a + b; })});
auto& ops = getAllOperatorsFor(Symbol::fromQualString("foo::bar"));
ASSERT_EQ(ops.size(), 1);
auto& op = ops.front();
ASSERT_EQ(op->schema().name(), "foo::bar");
ASSERT_EQ(op->schema().arguments().size(), 2);
ASSERT_EQ(op->schema().arguments()[0].name(), "_0");
ASSERT_EQ(op->schema().arguments()[0].type()->kind(), TypeKind::FloatType);
ASSERT_EQ(op->schema().arguments()[1].name(), "_1");
ASSERT_EQ(op->schema().arguments()[1].type()->kind(), TypeKind::TensorType);
ASSERT_EQ(op->schema().returns()[0].type()->kind(), TypeKind::TensorType);
Stack stack;
push(stack, 2.0f, autograd::make_variable(at::ones(5)));
op->getOperation()(stack);
at::Tensor output;
pop(stack, output);
ASSERT_TRUE(output.allclose(autograd::make_variable(at::full(5, 3.0f))));
}
{
RegisterOperators reg({createOperator(
"foo::bar_with_schema(float a, Tensor b) -> Tensor",
[](double a, at::Tensor b) { return a + b; })});
auto& ops =
getAllOperatorsFor(Symbol::fromQualString("foo::bar_with_schema"));
ASSERT_EQ(ops.size(), 1);
auto& op = ops.front();
ASSERT_EQ(op->schema().name(), "foo::bar_with_schema");
ASSERT_EQ(op->schema().arguments().size(), 2);
ASSERT_EQ(op->schema().arguments()[0].name(), "a");
ASSERT_EQ(op->schema().arguments()[0].type()->kind(), TypeKind::FloatType);
ASSERT_EQ(op->schema().arguments()[1].name(), "b");
ASSERT_EQ(op->schema().arguments()[1].type()->kind(), TypeKind::TensorType);
ASSERT_EQ(op->schema().returns().size(), 1);
ASSERT_EQ(op->schema().returns()[0].type()->kind(), TypeKind::TensorType);
Stack stack;
push(stack, 2.0f, autograd::make_variable(at::ones(5)));
op->getOperation()(stack);
at::Tensor output;
pop(stack, output);
ASSERT_TRUE(output.allclose(autograd::make_variable(at::full(5, 3.0f))));
}
{
// Check that lists work well.
RegisterOperators reg({createOperator(
"foo::lists(int[] ints, float[] floats, Tensor[] tensors) -> float[]",
[](const std::vector<int64_t>& ints,
const std::vector<double>& floats,
std::vector<at::Tensor> tensors) { return floats; })});
auto& ops = getAllOperatorsFor(Symbol::fromQualString("foo::lists"));
ASSERT_EQ(ops.size(), 1);
auto& op = ops.front();
ASSERT_EQ(op->schema().name(), "foo::lists");
ASSERT_EQ(op->schema().arguments().size(), 3);
ASSERT_EQ(op->schema().arguments()[0].name(), "ints");
ASSERT_TRUE(
op->schema().arguments()[0].type()->isSubtypeOf(ListType::ofInts()));
ASSERT_EQ(op->schema().arguments()[1].name(), "floats");
ASSERT_TRUE(
op->schema().arguments()[1].type()->isSubtypeOf(ListType::ofFloats()));
ASSERT_EQ(op->schema().arguments()[2].name(), "tensors");
ASSERT_TRUE(
op->schema().arguments()[2].type()->isSubtypeOf(ListType::ofTensors()));
ASSERT_EQ(op->schema().returns().size(), 1);
ASSERT_TRUE(
op->schema().returns()[0].type()->isSubtypeOf(ListType::ofFloats()));
Stack stack;
push(stack, std::vector<int64_t>{1, 2});
push(stack, std::vector<double>{1.0, 2.0});
push(stack, std::vector<at::Tensor>{autograd::make_variable(at::ones(5))});
op->getOperation()(stack);
std::vector<double> output;
pop(stack, output);
ASSERT_EQ(output.size(), 2);
ASSERT_EQ(output[0], 1.0);
ASSERT_EQ(output[1], 2.0);
}
{
RegisterOperators reg(
"foo::lists2(Tensor[] tensors) -> Tensor[]",
[](std::vector<at::Tensor> tensors) { return tensors; });
auto& ops = getAllOperatorsFor(Symbol::fromQualString("foo::lists2"));
ASSERT_EQ(ops.size(), 1);
auto& op = ops.front();
ASSERT_EQ(op->schema().name(), "foo::lists2");
ASSERT_EQ(op->schema().arguments().size(), 1);
ASSERT_EQ(op->schema().arguments()[0].name(), "tensors");
ASSERT_TRUE(
op->schema().arguments()[0].type()->isSubtypeOf(ListType::ofTensors()));
ASSERT_EQ(op->schema().returns().size(), 1);
ASSERT_TRUE(
op->schema().returns()[0].type()->isSubtypeOf(ListType::ofTensors()));
Stack stack;
push(stack, std::vector<at::Tensor>{autograd::make_variable(at::ones(5))});
op->getOperation()(stack);
std::vector<at::Tensor> output;
pop(stack, output);
ASSERT_EQ(output.size(), 1);
ASSERT_TRUE(output[0].allclose(autograd::make_variable(at::ones(5))));
}
{
auto op = createOperator(
"traced::op(float a, Tensor b) -> Tensor",
[](double a, at::Tensor b) { return a + b; });
std::shared_ptr<tracer::TracingState> state;
std::tie(state, std::ignore) = tracer::enter({});
Stack stack;
push(stack, 2.0f, autograd::make_variable(at::ones(5)));
op.getOperation()(stack);
at::Tensor output = autograd::make_variable(at::empty({}));
pop(stack, output);
tracer::exit({IValue(output)});
std::string op_name("traced::op");
bool contains_traced_op = false;
for (const auto& node : state->graph->nodes()) {
if (std::string(node->kind().toQualString()) == op_name) {
contains_traced_op = true;
break;
}
}
ASSERT_TRUE(contains_traced_op);
}
{
ASSERT_THROWS_WITH(
createOperator(
"foo::bar_with_bad_schema(Tensor a) -> Tensor",
[](double a, at::Tensor b) { return a + b; }),
"Inferred 2 argument(s) for operator implementation, "
"but the provided schema specified 1 argument(s).");
ASSERT_THROWS_WITH(
createOperator(
"foo::bar_with_bad_schema(Tensor a) -> Tensor",
[](double a) { return a; }),
"Inferred type for argument #0 was float, "
"but the provided schema specified type Tensor "
"for the argument in that position");
ASSERT_THROWS_WITH(
createOperator(
"foo::bar_with_bad_schema(float a) -> (float, float)",
[](double a) { return a; }),
"Inferred 1 return value(s) for operator implementation, "
"but the provided schema specified 2 return value(s).");
ASSERT_THROWS_WITH(
createOperator(
"foo::bar_with_bad_schema(float a) -> Tensor",
[](double a) { return a; }),
"Inferred type for return value #0 was float, "
"but the provided schema specified type Tensor "
"for the return value in that position");
}
{
// vector<double> is not supported yet.
auto op = createOperator(
"traced::op(float[] f) -> int",
[](const std::vector<double>& f) -> int64_t { return f.size(); });
std::shared_ptr<tracer::TracingState> state;
std::tie(state, std::ignore) = tracer::enter({});
Stack stack;
push(stack, std::vector<double>{1.0});
ASSERT_THROWS_WITH(
op.getOperation()(stack),
"Tracing float lists currently not supported!");
tracer::abandon();
}
}
void testEvalModeForLoadedModule() {
if (isSandcastle())
return; // The module file to load is not generated in Sandcastle
std::string module_path = "dropout_model.pt";
std::shared_ptr<torch::jit::script::Module> module =
torch::jit::load(module_path);
AT_ASSERT(module->get_module("dropout")->is_training());
module->eval();
AT_ASSERT(!module->get_module("dropout")->is_training());
module->train();
AT_ASSERT(module->get_module("dropout")->is_training());
}
// test a few features that are not directly used in schemas yet
void testSchemaParser() {
// nested arrays
auto s = parseSchema("at::what(int[][4] foo) -> ()");
ASSERT_TRUE(s.arguments().at(0).N() == 4);
ASSERT_TRUE(IntType::get()->isSubtypeOf(s.arguments()
.at(0)
.type()
->expect<ListType>()
->getElementType()
->expect<ListType>()
->getElementType()));
auto s2 = parseSchema("at::what(int[][] foo) -> ()");
ASSERT_TRUE(IntType::get()->isSubtypeOf(s2.arguments()
.at(0)
.type()
->expect<ListType>()
->getElementType()
->expect<ListType>()
->getElementType()));
// named returns
parseSchema("at::what(Tensor! i_will_be_written_to) -> ()");
auto s3 =
parseSchema("at::what() -> (Tensor the_return, Tensor the_return2)");
ASSERT_TRUE(s3.returns().at(0).name() == "the_return");
ASSERT_TRUE(s3.returns().at(1).name() == "the_return2");
// futures
auto s4 = parseSchema("at::what(Future(int) foo) -> ()");
ASSERT_TRUE(IntType::get()->isSubtypeOf(
s4.arguments().at(0).type()->expect<FutureType>()->getElementType()));
// test tensor with annotated alias sets
parseSchema("at::what(Tensor(a) foo) -> (Tensor(a))");
{
const auto s = parseSchema(
"at::what(Tensor(b|c)[](a!) list, Tensor(c) element)"
" -> (Tensor(b|c)[](a!))");
// The list itself is annotated with `a`
const auto& aliasInfo = *s.arguments().at(0).alias_info();
ASSERT_TRUE(
aliasInfo.beforeSets() ==
std::unordered_set<Symbol>{Symbol::fromQualString("alias::a")});
ASSERT_TRUE(aliasInfo.isWrite());
// Check the contained types
ASSERT_TRUE(!aliasInfo.containedTypes().empty());
const auto& containedAliasInfo = aliasInfo.containedTypes()[0];
const auto expected = std::unordered_set<Symbol>{
Symbol::fromQualString("alias::b"),
Symbol::fromQualString("alias::c"),
};
ASSERT_TRUE(containedAliasInfo.beforeSets() == expected);
ASSERT_TRUE(containedAliasInfo.afterSets() == expected);
ASSERT_FALSE(containedAliasInfo.isWrite());
}
{
const auto s = parseSchema(
"at::what(Tensor(b -> b|c)[](a!) list, Tensor(c) element)"
" -> (Tensor(b|c)[](a!))");
// The list itself is annotated with `a`
const auto& aliasInfo = *s.arguments().at(0).alias_info();
ASSERT_EQ(
aliasInfo.beforeSets(),
std::unordered_set<Symbol>{Symbol::fromQualString("alias::a")});
ASSERT_EQ(
aliasInfo.afterSets(),
std::unordered_set<Symbol>{Symbol::fromQualString("alias::a")});
ASSERT_TRUE(aliasInfo.isWrite());
ASSERT_EQ(aliasInfo.containedTypes().size(), 1);
// Check the contained types
ASSERT_TRUE(!aliasInfo.containedTypes().empty());
const auto& containedAliasInfo = aliasInfo.containedTypes()[0];
const auto expectedBefore = std::unordered_set<Symbol>{
Symbol::fromQualString("alias::b"),
};
const auto expectedAfter = std::unordered_set<Symbol>{
Symbol::fromQualString("alias::b"),
Symbol::fromQualString("alias::c")
};
ASSERT_TRUE(containedAliasInfo.beforeSets() == expectedBefore);
ASSERT_TRUE(containedAliasInfo.afterSets() == expectedAfter);
ASSERT_FALSE(containedAliasInfo.isWrite());
}
}
void testTopologicalIndex() {
{
Graph graph;
auto node1 = graph.create(prim::Undefined);
auto node2 = graph.create(prim::Undefined);
auto node3 = graph.create(prim::Undefined);
auto node4 = graph.create(prim::Undefined);
graph.appendNode(node4);
graph.prependNode(node1);
node2->insertAfter(node1);
node3->insertBefore(node4);
// nodes should be in numerical order
ASSERT_TRUE(node1->isBefore(node2));
ASSERT_TRUE(node1->isBefore(node3));
ASSERT_TRUE(node1->isBefore(node4));
ASSERT_TRUE(node2->isAfter(node1));
ASSERT_TRUE(node2->isBefore(node3));
ASSERT_TRUE(node2->isBefore(node4));
ASSERT_FALSE(node3->isBefore(node1));
ASSERT_FALSE(node3->isBefore(node2));
ASSERT_FALSE(node3->isAfter(node4));
// Built up a block structure
// node3
// /\ ...
// A B block1
// \ ...
// C block2
auto block1 = node3->addBlock();
auto A = graph.create(prim::Undefined);
block1->appendNode(A);
auto B = graph.create(prim::Undefined);
block1->appendNode(B);
auto block2 = B->addBlock();
auto C = graph.create(prim::Undefined);
block2->appendNode(C);
// Check isAfter on different block levels
ASSERT_TRUE(node1->isBefore(A));
ASSERT_TRUE(A->isBefore(B));
ASSERT_TRUE(A->isBefore(C));
// make sure things don't blow up on deletions
node2->destroy();
auto node2p = graph.create(prim::Undefined);
node2p->insertAfter(node1);
ASSERT_TRUE(node1->isBefore(node2p));
ASSERT_TRUE(node2p->isBefore(node3));
}
{
// Induce reindexing to test that path
Graph graph;
std::map<size_t, Node*> nodes;
auto anchor = graph.create(prim::Undefined);
graph.appendNode(anchor);
// Inserting to the same place a lot will trigger reindexing
for (auto i = 0; i < 100; ++i) {
auto n = graph.create(prim::Undefined);
n->insertAfter(anchor);
nodes[i] = n;
}
// Nodes should be in reverse order
for (auto i = 0; i < 100; ++i) {
for (auto j = i + 1; j < 100; ++j) {
ASSERT_TRUE(nodes[i]->isAfter(nodes[j]));
}
}
}
}
std::unique_ptr<detail::DynamicDAG<std::string>> newDynamicDAG() {
return std::unique_ptr<detail::DynamicDAG<std::string>>(
new detail::DynamicDAG<std::string>());
}
void testNewVertex() {
auto graph = newDynamicDAG();
AT_ASSERT(graph->debugNumVertices() == 0);
auto a = graph->newVertex("a");
AT_ASSERT(graph->debugNumVertices() == 1);
AT_ASSERT(a->ord == 0);
AT_ASSERT(a->data.size() == 1);
AT_ASSERT(a->data[0] == "a");
AT_ASSERT(a->in_edges().size() == 0);
AT_ASSERT(a->out_edges().size() == 0);
auto b = graph->newVertex("b");
auto c = graph->newVertex("c");
AT_ASSERT(graph->debugNumVertices() == 3);
AT_ASSERT(b->ord == 1);
AT_ASSERT(c->ord == 2);
}
void testAddEdgeBasic() {
// a -> b -> c
// \---------^
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
auto c = graph->newVertex("c");
graph->addEdge(a, b);
graph->addEdge(b, c);
graph->addEdge(a, c);
AT_ASSERT(a->in_edges().size() == 0);
AT_ASSERT(a->out_edges().size() == 2);
AT_ASSERT(a->out_edges().contains(b));
AT_ASSERT(a->out_edges().contains(c));
AT_ASSERT(b->in_edges().size() == 1);
AT_ASSERT(b->out_edges().size() == 1);
AT_ASSERT(b->in_edges().contains(a));
AT_ASSERT(b->out_edges().contains(c));
AT_ASSERT(c->in_edges().size() == 2);
AT_ASSERT(c->out_edges().size() == 0);
AT_ASSERT(c->in_edges().contains(a));
AT_ASSERT(c->in_edges().contains(b));
}
void testAddEdgeCycleDetection() {
// a -> b -> c
// ^---------/
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
auto c = graph->newVertex("c");
graph->addEdge(a, b);
graph->addEdge(b, c);
bool erred = false;
try {
graph->addEdge(c, a);
} catch (c10::Error& err) {
erred = true;
}
AT_ASSERT(erred);
}
void testAddEdgeReordersBasic() {
// a, b => b -> a
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
AT_ASSERT(a->ord == 0);
AT_ASSERT(b->ord == 1);
graph->addEdge(b, a);
AT_ASSERT(a->ord == 1);
AT_ASSERT(b->ord == 0);
}
void testAddEdgeReordersComplicated() {
// a -> b c -> d with addEdge(d, b) ==>
// c -> d -> a -> b
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
auto c = graph->newVertex("c");
auto d = graph->newVertex("d");
graph->addEdge(a, b);
graph->addEdge(c, d);
AT_ASSERT(a->ord == 0);
AT_ASSERT(b->ord == 1);
AT_ASSERT(c->ord == 2);
AT_ASSERT(d->ord == 3);
graph->addEdge(d, a);
AT_ASSERT(c->ord == 0);
AT_ASSERT(d->ord == 1);
AT_ASSERT(a->ord == 2);
AT_ASSERT(b->ord == 3);
AT_ASSERT(c->in_edges().size() == 0);
AT_ASSERT(c->out_edges().size() == 1);
AT_ASSERT(c->out_edges().contains(d));
AT_ASSERT(d->in_edges().size() == 1);
AT_ASSERT(d->out_edges().size() == 1);
AT_ASSERT(d->in_edges().contains(c));
AT_ASSERT(d->out_edges().contains(a));
AT_ASSERT(a->in_edges().size() == 1);
AT_ASSERT(a->out_edges().size() == 1);
AT_ASSERT(a->in_edges().contains(d));
AT_ASSERT(a->out_edges().contains(b));
AT_ASSERT(b->in_edges().size() == 1);
AT_ASSERT(b->out_edges().size() == 0);
AT_ASSERT(b->in_edges().contains(a));
}
void testRemoveEdgeBasic() {
// a -> b
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
graph->addEdge(a, b);
AT_ASSERT(graph->debugNumVertices() == 2);
graph->removeEdge(a, b);
AT_ASSERT(graph->debugNumVertices() == 2);
AT_ASSERT(a->out_edges().size() == 0);
AT_ASSERT(b->in_edges().size() == 0);
}
void testRemoveVertexBasic() {
// a -> b
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
auto c = graph->newVertex("c");
graph->addEdge(a, b);
graph->addEdge(b, c);
AT_ASSERT(graph->debugNumVertices() == 3);
graph->removeVertex(b);
AT_ASSERT(graph->debugNumVertices() == 2);
AT_ASSERT(a->out_edges().size() == 0);
AT_ASSERT(c->in_edges().size() == 0);
}
void testContractEdgeBasic() {
// a -> b -> c -> d
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
auto c = graph->newVertex("c");
auto d = graph->newVertex("d");
graph->addEdge(a, b);
graph->addEdge(b, c);
graph->addEdge(c, d);
graph->contractEdge(b, c);
AT_ASSERT(graph->debugNumVertices() == 3);
AT_ASSERT(a->out_edges().size() == 1);
AT_ASSERT(d->in_edges().size() == 1);
AT_ASSERT(*a->out_edges().begin() == *d->in_edges().begin());
auto* contracted = *a->out_edges().begin();
AT_ASSERT(contracted->data.size() == 2);
AT_ASSERT(contracted->data[0] == "b");
AT_ASSERT(contracted->data[1] == "c");
AT_ASSERT(contracted->out_edges().size() == 1);
AT_ASSERT(contracted->in_edges().size() == 1);
AT_ASSERT(contracted->in_edges().contains(a));
AT_ASSERT(contracted->out_edges().contains(d));
}
void testContractEdgeCycleDetection() {
// a -> b -> c
// `---------^
// contractEdge(a, c) will cause a cycle
auto graph = newDynamicDAG();
auto a = graph->newVertex("a");
auto b = graph->newVertex("b");
auto c = graph->newVertex("c");
graph->addEdge(a, b);
graph->addEdge(b, c);
graph->addEdge(a, c);
AT_ASSERT(!graph->contractEdge(a, c));
}
void testDynamicDAG() {
testNewVertex();
testAddEdgeBasic();
testAddEdgeCycleDetection();
testAddEdgeReordersBasic();
testAddEdgeReordersComplicated();
testRemoveEdgeBasic();
testRemoveVertexBasic();
testContractEdgeBasic();
testContractEdgeCycleDetection();
}
void testAutogradProfiler() {
constexpr int batch_size = 4;
constexpr int input_size = 256;
constexpr int seq_len = 32;
int hidden_size = 2 * input_size;
auto input = torch::randn({seq_len, batch_size, input_size}, at::kCPU);
auto hx = torch::randn({batch_size, hidden_size}, at::kCPU);
auto cx = torch::randn({batch_size, hidden_size}, at::kCPU);
auto w_ih = t_def(torch::randn({4 * hidden_size, input_size}, at::kCPU));
auto w_hh = t_def(torch::randn({4 * hidden_size, hidden_size}, at::kCPU));
std::stringstream ss;
{
autograd::profiler::RecordProfile guard(ss);
for (size_t i = 0; i < 100; ++i) {
std::tie(hx, cx) = lstm(input[0], hx, cx, w_ih, w_hh);
}
}
std::string result = ss.str();
size_t count = 0;
for (size_t pos = 0; (pos = result.find("tanh", pos)) != std::string::npos;
count++, pos++) {
}
AT_CHECK(count == 200);
}
void testNoneSchemaMatch() {
RegisterOperators reg({
Operator(
"test::test_none() -> int?",
[](const Node* node) {
return [](Stack& stack) {
push(stack, IValue());
return 0;
};
}),
Operator(
"test::is_none(int? a) -> bool",
[](const Node* node) {
return [](Stack& stack) {
IValue a = pop(stack);
if (a.isNone()) {
push(stack, true);
} else {
push(stack, false);
}
return 0;
};
}),
});
// Constant propagation will run test_none and produce a None,
// testing that its type is set appropriately and schema matching doesn't
// fail when running is_none
auto r = std::make_shared<Graph>();
auto& g = *r;
auto opt_int = g.insert(Symbol::fromQualString("test::test_none"), {});
auto out_bool = g.insert(Symbol::fromQualString("test::is_none"), {opt_int});
g.registerOutput(out_bool);
ConstantPropagation(r);
auto nodes = r->block()->nodes();
// checking that constant propagation ran wo/failure
AT_ASSERT(std::distance(nodes.begin(), nodes.end()) == 1);
}
} // namespace
} // namespace jit
} // namespace torch
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
a378ed72f41d87b8240403880c4c548aafebc9a1 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5648941810974720_0/C++/stalker506/main.cpp | 6bf97dabfa10e0a1938201e31b1e1171844e8c3c | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 2,235 | cpp | //#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef double ld;
typedef long long ll;
const ld EPS = 1e-2;
const int INF = (int) 1e9;
const int N = (int) 2e3 + 5;
const ll M = (long long) 1e9 + 7;
vector <int> solve(string &s) {
map <char, int> cnt;
vector <int> res;
int n = s.length();
for (int i = 0; i < n; i++)
cnt[s[i]]++;
while (cnt['Z']) {
res.push_back(0);
cnt['Z']--, cnt['E']--, cnt['R']--, cnt['O']--;
}
while (cnt['W']) {
res.push_back(2);
cnt['W']--, cnt['T']--, cnt['O']--;
}
while (cnt['U']) {
res.push_back(4);
cnt['F']--, cnt['U']--, cnt['R']--, cnt['O']--;
}
while (cnt['X']) {
res.push_back(6);
cnt['S']--, cnt['I']--, cnt['X']--;
}
while (cnt['G']) {
res.push_back(8);
cnt['I']--, cnt['E']--, cnt['G']--, cnt['H']--, cnt['T']--;
}
while (cnt['F']) {
res.push_back(5);
cnt['F']--, cnt['E']--, cnt['I']--, cnt['V']--;
}
while (cnt['R']) {
res.push_back(3);
cnt['T']--, cnt['H']--, cnt['R']--, cnt['E'] -= 2;
}
while (cnt['O']) {
res.push_back(1);
cnt['N']--, cnt['E']--; cnt['O']--;
}
while (cnt['S']) {
res.push_back(7);
cnt['S']--, cnt['E'] -= 2, cnt['V']--, cnt['N']--;
}
while (cnt['N']) {
res.push_back(9);
cnt['N'] -= 2, cnt['E']--, cnt['I']--;
}
sort(res.begin(), res.end());
return res;
}
int main() {
freopen("A-small-attempt1.in", "r", stdin);
freopen("output.txt", "w", stdout);
int T;
cin >> T;
for (int t = 0; t < T; t++) {
string s;
cin >> s;
cout << "Case #" << t + 1 << ": ";
vector <int> ans = solve(s);
for (int i = 0; i < (int)ans.size(); i++)
cout << ans[i];
cout << endl;
}
return 0;
}
| [
"alexandra1.back@gmail.com"
] | alexandra1.back@gmail.com |
0cc3cd60f752345e555b7706da5697cee681c0ba | f9ae1ba26d3d93d9013197cbd28b08d14f8889f3 | /src/nodes/pardata_nodes/parallel_data_sync_node.cpp | b82f8cc51d87e5cce5c048067d5d97ecf249eef1 | [] | no_license | RDowse/Asynchronous-Deep-Learning | 3242bf2d87728518a13e182471aae070698baa06 | d6ae52f4f6647688486d9a47b474d5c6a991c712 | refs/heads/master | 2021-03-24T12:22:04.921517 | 2017-06-24T17:39:54 | 2017-06-24T17:39:54 | 71,652,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,309 | cpp |
#include "nodes/pardata_nodes/parallel_data_sync_node.h"
#include "messages/forward_propagation_message.h"
#include "messages/backward_propagation_message.h"
#include "tools/math.h"
#include "states/backward_train_state.h"
#include "states/forward_train_state.h"
std::string ParallelDataNeuralNode::SyncNode::m_type = "Sync";
void ParallelDataNeuralNode::SyncNode::addEdge(Edge* e) {
Node::addEdge(e);
if(e->src->getId() == id){
if(e->dst->getType() == "Output"){
outgoingBackwardEdges.push_back(e);
dstOutputIndex[e->dst->getId()] = map_index++;
} else if(e->dst->getType() == "Input" ||
e->dst->getType() == "Bias"){
outgoingForwardEdges.push_back(e);
} else {
cout << "Unknown type " << e->dst->getType() << "\n";
assert(0);
}
} else if(e->dst->getId() == id){
if(e->src->getType() == "Output"){
incomingForwardEdges.push_back(e);
} else if(e->src->getType() == "Input"
|| e->src->getType() == "Bias"){
incomingBackwardEdges.push_back(e);
} else {
cout << "Unknown type " << e->src->getType() << "\n";
assert(0);
}
}
}
bool ParallelDataNeuralNode::SyncNode::sendForwardMsgs(vector<Message*>& msgs, int stateIndex){
assert(readyToSendForward(stateIndex));
assert(dataset!=NULL);
// time step
batchNum++;
auto& images = validating ?
dataset->validation_images : dataset->training_images;
// if(validating){
// batchSize = dataset->validation_labels.size();
// }else{
// // for batch remainder
// if( sampleIndex + context->batchSize > dataset->training_labels.size() )
// batchSize = dataset->training_labels.size() - sampleIndex;
// else
// batchSize = context->batchSize;
// }
// simplified
batchSize = validating ? dataset->validation_labels.size() : context->batchSize;
Logging::log(3, "Sending sample %d", sampleIndex);
// send out data samples to input nodes
msgs.reserve(outgoingForwardEdges.size());
for(unsigned i = 0, j = 0; i < outgoingForwardEdges.size(); i++){
assert( 0 == outgoingForwardEdges[i]->msgStatus );
auto msg = forwardMessagePool->getMessage();
msg->src = id;
msg->dst = outgoingForwardEdges[i]->dst->getId();
msg->batchNum = batchNum;
msg->dataSetType = validating ? DataSetType::validating : DataSetType::training;
msg->batchIndex = stateIndex;
// sampling strategy
if(outgoingForwardEdges[i]->dst->getType() == "Input"
&& j < images.cols()){
msg->activation = images.block(sampleIndex,j++,batchSize,1);
} else if(outgoingForwardEdges[i]->dst->getType() == "Bias"){
msg->activation = Eigen::VectorXf::Ones(batchSize);
} else {
assert(0); // shouldn't occur
}
msgs.push_back(msg);
}
assert((batchCount % context->numModels) == stateIndex);
// move to next batch
activeBatchCount++;
batchCount++;
assert(activeBatchCount <= context->numModels);
sampleIndex += batchSize;
// reset
tick = false;
backwardSeenCount[stateIndex] = 0;
}
bool ParallelDataNeuralNode::SyncNode::sendBackwardMsgs(vector<Message*>& msgs, int stateIndex){
assert(readyToSendBackward(stateIndex));
Logging::log(3, "Sending sample %d backward", sampleIndex-(activeBatchCount*batchSize));
auto batchLabels = dataset->training_labels.block(sampleIndex-(activeBatchCount*batchSize),0,batchSize,1);
msgs.reserve(outgoingBackwardEdges.size());
for(int i = 0; i < outgoingBackwardEdges.size(); ++i){
auto msg = backwardMessagePool->getMessage();
msg->src = id;
msg->dst = outgoingBackwardEdges[i]->dst->getId();
msg->batchNum = batchNum;
msg->batchIndex = stateIndex;
Eigen::VectorXf target(batchSize);
for(int j = 0; j < batchSize; ++j)
target(j) = (batchLabels(j) == i ? context->actMax : context->actMin);
assert(outgoingBackwardEdges[i]->dst->getType() == "Output");
msg->target = target;
msgs.push_back(msg);
}
// reset
forwardSeenCount[stateIndex] = 0;
}
bool ParallelDataNeuralNode::SyncNode::readyToSendForward(int i){
return (backwardSeenCount[i] == incomingBackwardEdges.size()
|| activeBatchCount < context->numModels
|| tick)
&& (batchCount % context->numModels) == i
&& context->epoch < context->maxEpoch
&& sampleIndex < dataset->training_labels.size()
&& activeBatchCount < context->numModels;
}
bool ParallelDataNeuralNode::SyncNode::readyToSendBackward(int i){
return (forwardSeenCount[i] == incomingForwardEdges.size());
}
void ParallelDataNeuralNode::SyncNode::onRecv(BackwardPropagationMessage* msg){
backwardSeenCount[msg->batchIndex]++;
backwardMessagePool->returnMessage(msg);
int batchIndex = msg->batchIndex;
assert(backwardSeenCount[batchIndex] <= incomingBackwardEdges.size());
if(backwardSeenCount[batchIndex] == incomingBackwardEdges.size())
{ // state update
// free up active batch count
activeBatchCount--;
assert(activeBatchCount >= 0);
int nTrainingSamples = dataset->training_labels.size();
// end of epoch, all samples in the training set have been passed
if(sampleIndex==nTrainingSamples && activeBatchCount == 0){
dataset->shuffle();
// next epoch
context->epoch++;
context->accuracy = accuracy/nTrainingSamples;
context->training_error = training_error/nTrainingSamples;
context->accuracy_train(context->epoch-1) = accuracy/nTrainingSamples;
Logging::log(0,"ACCURACY: %f\n",context->accuracy);
Logging::log(0,"AVERAGE ERROR: %f\n",context->training_error);
Logging::log(0,"EPOCH: %d\n",context->epoch);
// reset
sampleIndex = 0;
training_error = 0;
accuracy = 0;
}
delete state[batchIndex];
state[batchIndex] = new ForwardTrainState<ParallelDataNeuralNode>();
}
}
void ParallelDataNeuralNode::SyncNode::onRecv(ForwardPropagationMessage* msg){
forwardSeenCount[msg->batchIndex]++;
if(!receivedOutput[msg->batchIndex].size() || batchSize != receivedOutput[msg->batchIndex].rows())
receivedOutput[msg->batchIndex] = Eigen::MatrixXf(batchSize,outgoingBackwardEdges.size());
int index = dstOutputIndex[msg->src];
// network output
receivedOutput[msg->batchIndex].col(index) = msg->activation;
forwardMessagePool->returnMessage(msg);
int batchIndex = msg->batchIndex;
if(readyToSendBackward(batchIndex)){
// training error
if(outgoingBackwardEdges.size() == 1){ assert(0); }// todo implement binary version
int batchSampleIndex = sampleIndex - batchSize*activeBatchCount;
auto batchLabels = !validating ? dataset->training_labels.block(batchSampleIndex,0,batchSize,1):
dataset->validation_labels;
Eigen::MatrixXf target = Eigen::MatrixXf::Constant(batchSize,outgoingBackwardEdges.size(),context->actMin);
for(int i = 0; i < batchSize; ++i)
target( i, (int)batchLabels(i) ) = context->actMax;
training_error += math::mse(target,receivedOutput[msg->batchIndex]);
// TODO: separate accuracy predicition for the training set into a separate forward pass
MatrixXf::Index maxIndex[batchSize];
VectorXf maxVal(batchSize);
for(int i = 0; i < batchSize; ++i){ // multi-classification only
maxVal(i) = receivedOutput[msg->batchIndex].row(i).maxCoeff( &maxIndex[i] );
if(maxIndex[i]==batchLabels(i)) accuracy++;
}
delete state[msg->batchIndex];
state[msg->batchIndex] = new BackwardTrainState<ParallelDataNeuralNode>();
}
} | [
"rd613@imperial.ac.uk"
] | rd613@imperial.ac.uk |
ea6693530894b315a7c44282ed1a581bf698cda9 | 24ce061d37343fb1c3129596546577a6622c85d4 | /CS_048-04812030-0006172461-2/2018-1-E.cpp | c75219c1428b3ddc92c379d55a7823ff0afa3bbb | [] | no_license | Tenant/Algorithm-Repo | d61026c835ffe9a9a03ae705702e495adcd45d36 | 96c5f6c44145bfa488811756aa2ce5269e577471 | refs/heads/master | 2021-04-09T17:21:59.418228 | 2019-01-13T19:36:05 | 2019-01-13T19:36:05 | 125,698,364 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 824 | cpp | #include <iostream>
#define N_MAX 65536
int pre[N_MAX],cnt;
void process(int* mid, int* post, int length)
{
int pos=0;
for(;pos<length && mid[pos]!=post[length-1];pos++);
pre[cnt++]=mid[pos];
if(pos>0)
{
process(mid,post,pos);
}
if(pos<length-1)
{
process(mid+pos+1,post+pos,length-pos-1);
}
}
int main(int argc, char* argv[])
{
int mid[N_MAX], post[N_MAX];
int N;
for(N=0;;N++)
{
scanf("%d",&mid[N]);
if(getchar()!=' ') break;
}
for(N=0;;N++)
{
scanf("%d",&post[N]);
if(getchar()!=' ') break;
}
cnt=0;
process(mid,post,++N);
std::cout<<pre[0];
for(int idx=1;idx<cnt;idx++) std::cout<<" "<<pre[idx];
std::cout<<std::endl;
return 0;
}
| [
"gaoshuqi@pku.edu.cn"
] | gaoshuqi@pku.edu.cn |
663e562acb468e1d2124231f740e3d454d53f3dd | 6f4883cec42366e1ed7dc4ddf25b56e7702b0c69 | /2387/5196830_AC_79MS_4528K.cpp | 8438660a6c0259d99845da9267e7aed14c4abd54 | [] | no_license | 15800688908/poj-codes | 89e3739df0db4bd4fe22db3e0bf839fc7abe35d1 | 913331dd1cfb6a422fb90175dcddb54b577d1059 | refs/heads/master | 2022-01-25T07:55:15.590648 | 2016-09-30T13:08:24 | 2016-09-30T13:08:24 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 948 | cpp | #include<stdio.h>
#include<string.h>
const int maxn=1100;
const int INF=100000000;
int map[maxn][maxn],d[maxn];
bool flag[maxn];
int m,n;
void dijkstra()
{
int i,j,minv,s;
memset(flag,false,sizeof(flag));
for(i=1;i<=n;++i)
d[i]=INF;
d[1]=0;
for(i=1;i<=n;i++)
{
minv=INF;s=-1;
for(j=1;j<=n;j++)
if(!flag[j]&&d[j]<minv)
{
s=j;
minv=d[j];
}
if(s==-1)
break;
flag[s]=true;
if(flag[n])
break;
for(j=1;j<=n;j++)
if(!flag[j]&&d[s]+map[s][j]<d[j])
d[j]=d[s]+map[s][j];
}
}
int main()
{
int cnt,value,i,j;
while(EOF!=scanf("%d %d",&m,&n))
{
for(i=1;i<=n;++i)
{
for(j=1;j<=n;++j)
map[i][j]=INF;
map[i][i]=0;
}
while(m--)
{
scanf("%d%d%d",&i,&j,&value);
if(value<map[i][j])
map[i][j]=map[j][i]=value;
}
dijkstra();
printf("%d\n",d[n]);
}
return 0;
}
| [
"dilin.life@gmail.com"
] | dilin.life@gmail.com |
cb636483037705b3de8f0c1eee7249390666d6c5 | 3ed4316561e9450e92dc334b1442a3500554f57f | /ExOpenGL3/OpenGL/03-uniforms/03-uniforms/ShaderProgram.h | 3a9200304a68e852f9a3d0d4dca6aad2860c7edb | [] | no_license | TheSoraHD/Rambo2D | 91de55f6bc258edf3ccd78e0ace6c108f00ee863 | c4f68348910adf025893f3f96de939c6790b406d | refs/heads/master | 2022-03-27T17:38:18.705431 | 2020-01-01T19:19:05 | 2020-01-01T19:19:05 | 212,827,341 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,044 | h | #ifndef _SHADER_PROGRAM_INCLUDE
#define _SHADER_PROGRAM_INCLUDE
#include <GL/glew.h>
#include <GL/gl.h>
#include "Shader.h"
// Using the Shader class ShaderProgram can link a vertex and a fragment shader
// together, bind input attributes to their corresponding vertex shader names,
// and bind the fragment output to a name from the fragment shader
class ShaderProgram
{
public:
ShaderProgram();
void init();
void addShader(const Shader &shader);
void bindFragmentOutput(const string &outputName);
GLint bindVertexAttribute(const string &attribName, GLint size);
void link();
void free();
void use();
// Pass uniforms to the associated shaders
void setUniform2f(const string &uniformName, float v0, float v1);
void setUniform3f(const string &uniformName, float v0, float v1, float v2);
void setUniform4f(const string &uniformName, float v0, float v1, float v2, float v3);
bool isLinked();
const string &log() const;
private:
GLuint programId;
bool linked;
string errorLog;
};
#endif // _SHADER_PROGRAM_INCLUDE
| [
"sven.wallin@est.fib.upc.edu"
] | sven.wallin@est.fib.upc.edu |
0a4c53c9e0b72b7600ab4cb758b8d9312b85071e | 30cf11a1ce961e3eef4332e0743120de55f06871 | /WJets/8TeV/LeptoQuarks/NTupleMaker/interface/RootTupleMakerV2_GenJets.h | 60ef63d994de967b671167e3a8e7c4b43c852464 | [] | no_license | bhawan/usercode | 1bde88a39fcb5ac466ffd547f1662cee91f695bd | b8c9042dc7cc4ee1907dc6c6dc3b25305ad31935 | refs/heads/master | 2020-05-18T00:07:39.498631 | 2013-08-23T15:16:12 | 2013-08-23T15:16:12 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 573 | h | #ifndef RootTupleMakerV2GenJets
#define RootTupleMakerV2GenJets
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
class RootTupleMakerV2_GenJets : public edm::EDProducer {
public:
explicit RootTupleMakerV2_GenJets(const edm::ParameterSet&);
private:
void produce( edm::Event &, const edm::EventSetup & );
const edm::InputTag inputTag;
const edm::InputTag inputTagP;
const std::string prefix,suffix;
const unsigned int maxSize;
};
#endif
| [
""
] | |
dee05680523547303c3d5bbf429efce7b63031a9 | 5c5033209087c5d2c72415ae45efab42e5658d08 | /蓝桥/2013年第四届蓝桥C++B组/2013.07错误票据.cpp | 9c6e8bff0334f5d3fec427d7c2e32d7d2fe69532 | [] | no_license | mqaaa/algorithmmic | 1b6f4bd8381d76625f726bad662783b28080de9d | 811b6ae7c1ff021149c79e54ce9366e95fcb8c8b | refs/heads/master | 2021-03-30T17:26:00.934151 | 2018-04-18T14:00:27 | 2018-04-18T14:00:27 | 123,786,066 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,230 | cpp |
/*************************************************************
Author : qmeng
MailTo : qmeng1128@163.com
QQ : 1163306125
Blog : http://blog.csdn.net/Mq_Go/
Create : 2018-03-23 16:41:43
Version: 1.0
**************************************************************/
#include <cstdio>
#include <iostream>
#include<algorithm>
#include <string>
const int maxn=100005;
using namespace std;
int main(){
int n;
int hashtable[maxn];
fill(hashtable,hashtable+maxn,0);
int num;
int u=0;
scanf("%d",&n);
getchar();
string str;
for(int i=0;i<n;i++)
{
/*while(scanf("%d",&num)!=EOF)
{
hashtable[u++]=num;
}*/
getline(cin,str);
cout << str << endl;
int temp = 0;
for(int j = 0 ; j < str.length() ; j++){
if(str[j]<'9'&&str[j]>'0'){
temp = temp*10 + str[j]-'0';
//cout << temp << endl;
}else{
hashtable[temp]++;
temp = 0;
}
}
hashtable[temp]++;
}
//cout << "1311315365"<<endl;
//sort(hashtable,hashtable+u);
int l,m,k;
for(int i=0;i<10;i++)
{
cout<<i<<" "<<hashtable[i]<<endl;
if(hashtable[i]==2)
{
l=i;
}else if(hashtable[i]==0)
{
m=i;
}
if(hashtable[i]==1){
k = m;
}
}
printf("%d %d",l,k);
return 0;
}
| [
"qmeng1128@163.com"
] | qmeng1128@163.com |
708d4db49841340a0817964cd6e8bc8fade7ba13 | 48d716be7c6ee6c227c51998f30621e4e80ae690 | /util.cpp | 184268edf27e963128752c1827fb114b1fd7bb04 | [] | no_license | aceiii/sfml-game-dev | 329296f905f20604c248e0b96dc1d4bdc1d2c460 | aeb09541ffe4e13f3f94952c6171dd31d38be17b | refs/heads/master | 2021-01-12T13:00:59.407055 | 2016-10-24T16:25:44 | 2016-10-24T16:25:44 | 70,112,358 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 6,164 | cpp | #include <sstream>
#include <complex>
#include "util.h"
std::string keyToString(const sf::Keyboard::Key& key) {
switch (key) {
case sf::Keyboard::Unknown: return "Unknown";
case sf::Keyboard::A: return "A";
case sf::Keyboard::B: return "B";
case sf::Keyboard::C: return "C";
case sf::Keyboard::D: return "D";
case sf::Keyboard::E: return "E";
case sf::Keyboard::F: return "F";
case sf::Keyboard::G: return "G";
case sf::Keyboard::H: return "H";
case sf::Keyboard::I: return "I";
case sf::Keyboard::J: return "J";
case sf::Keyboard::K: return "K";
case sf::Keyboard::L: return "L";
case sf::Keyboard::M: return "M";
case sf::Keyboard::N: return "N";
case sf::Keyboard::O: return "O";
case sf::Keyboard::P: return "P";
case sf::Keyboard::Q: return "Q";
case sf::Keyboard::R: return "R";
case sf::Keyboard::S: return "S";
case sf::Keyboard::T: return "T";
case sf::Keyboard::U: return "U";
case sf::Keyboard::V: return "V";
case sf::Keyboard::W: return "W";
case sf::Keyboard::X: return "X";
case sf::Keyboard::Y: return "Y";
case sf::Keyboard::Z: return "Z";
case sf::Keyboard::Num0: return "0";
case sf::Keyboard::Num1: return "1";
case sf::Keyboard::Num2: return "2";
case sf::Keyboard::Num3: return "3";
case sf::Keyboard::Num4: return "4";
case sf::Keyboard::Num5: return "5";
case sf::Keyboard::Num6: return "6";
case sf::Keyboard::Num7: return "7";
case sf::Keyboard::Num8: return "8";
case sf::Keyboard::Num9: return "9";
case sf::Keyboard::Escape: return "ESC";
case sf::Keyboard::LControl: return "L-CTRL";
case sf::Keyboard::LShift: return "L-SHIFT";
case sf::Keyboard::LAlt: return "L-ALT";
case sf::Keyboard::LSystem: return "L-SYS";
case sf::Keyboard::RControl: return "R-CTRL";
case sf::Keyboard::RShift: return "R-SHIFT";
case sf::Keyboard::RAlt: return "R-ALT";
case sf::Keyboard::RSystem: return "R-SYS";
case sf::Keyboard::Menu: return "MENU";
case sf::Keyboard::LBracket: return "[";
case sf::Keyboard::RBracket: return "]";
case sf::Keyboard::SemiColon: return ";";
case sf::Keyboard::Comma: return ",";
case sf::Keyboard::Period: return ".";
case sf::Keyboard::Quote: return "'";
case sf::Keyboard::Slash: return "/";
case sf::Keyboard::BackSlash: return "\\";
case sf::Keyboard::Tilde: return "~";
case sf::Keyboard::Equal: return "=";
case sf::Keyboard::Dash: return "-";
case sf::Keyboard::Space: return "SPACE";
case sf::Keyboard::Return: return "RETURN";
case sf::Keyboard::BackSpace: return "BACK";
case sf::Keyboard::Tab: return "TAB";
case sf::Keyboard::PageUp: return "PGUP";
case sf::Keyboard::PageDown: return "PGDN";
case sf::Keyboard::End: return "END";
case sf::Keyboard::Home: return "HOME";
case sf::Keyboard::Insert: return "INS";
case sf::Keyboard::Delete: return "DEL";
case sf::Keyboard::Add: return "ADD";
case sf::Keyboard::Subtract: return "SUB";
case sf::Keyboard::Multiply: return "MUL";
case sf::Keyboard::Divide: return "DIV";
case sf::Keyboard::Left: return "LEFT";
case sf::Keyboard::Right: return "RIGHT";
case sf::Keyboard::Up: return "UP";
case sf::Keyboard::Down: return "DOWN";
case sf::Keyboard::Numpad0: return "NUM0";
case sf::Keyboard::Numpad1: return "NUM1";
case sf::Keyboard::Numpad2: return "NUM2";
case sf::Keyboard::Numpad3: return "NUM3";
case sf::Keyboard::Numpad4: return "NUM4";
case sf::Keyboard::Numpad5: return "NUM5";
case sf::Keyboard::Numpad6: return "NUM6";
case sf::Keyboard::Numpad7: return "NUM7";
case sf::Keyboard::Numpad8: return "NUM8";
case sf::Keyboard::Numpad9: return "NUM9";
case sf::Keyboard::F1: return "F1";
case sf::Keyboard::F2: return "F2";
case sf::Keyboard::F3: return "F3";
case sf::Keyboard::F4: return "F4";
case sf::Keyboard::F5: return "F5";
case sf::Keyboard::F6: return "F6";
case sf::Keyboard::F7: return "F7";
case sf::Keyboard::F8: return "F8";
case sf::Keyboard::F9: return "F9";
case sf::Keyboard::F10: return "F10";
case sf::Keyboard::F11: return "F11";
case sf::Keyboard::F12: return "F12";
case sf::Keyboard::F13: return "F13";
case sf::Keyboard::F14: return "F14";
case sf::Keyboard::F15: return "F15";
case sf::Keyboard::Pause: return "Pause";
default: return "Unknown";
}
}
float toRadians(float deg) {
return static_cast<float>(M_PI / 180.0 * deg);
}
double toRadians(double deg) {
return M_PI / 180 * deg;
}
float toDegrees(float rads) {
return static_cast<float>(rads * 180.0 * M_PI);
}
double toDegrees(double rads) {
return rads * 180.0 * M_PI;
}
sf::Vector2f unitVector(sf::Vector2f pos) {
float dist = std::sqrt(pos.x * pos.x + pos.y * pos.y);
pos.x /= dist;
pos.y /= dist;
return pos;
}
float distance(const SceneNode &node1, const SceneNode &node2) {
sf::Vector2f vec = node1.getWorldPosition() - node2.getWorldPosition();
return std::sqrt(vec.x * vec.x + vec.y * vec.y);
}
bool collision(const SceneNode &lhs, const SceneNode &rhs) {
return lhs.getBoundingRect().intersects(rhs.getBoundingRect());
}
bool matchesCategories(SceneNode::pair_type &colliders, Category::Type type1, Category::Type type2) {
unsigned int category1 = colliders.first->getCategory();
unsigned int category2 = colliders.second->getCategory();
if (type1 & category1 && type2 & category2) {
return true;
} else if (type1 & category2 && type2 & category1) {
std::swap(colliders.first, colliders.second);
return true;
}
return false;
}
| [
"borin.ouch@gmail.com"
] | borin.ouch@gmail.com |
c296471aec402aaa608b0b3709e5e956d80cc2a1 | dbc2f341a9e9e0200f9a59e8b05a5cad0301e3ec | /uint256.cpp | bf95b8fed158b6cdac7b619cd87b27916d913ee2 | [] | no_license | JonSalazar/serialization | 3523e20abd521f2d7f36c0b88befbb76e9657db9 | e91f41505598ee37cec3cdbaa771f2f68fcd4368 | refs/heads/master | 2020-04-24T18:00:48.528153 | 2019-03-07T03:47:35 | 2019-03-07T03:47:35 | 172,166,665 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,286 | cpp | // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2017 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "uint256.h"
#include "utilstrencodings.h"
#include <stdio.h>
#include <string.h>
#include <vector>
template <unsigned int BITS>
base_blob<BITS>::base_blob(const std::vector<unsigned char>& vch)
{
assert(vch.size() == sizeof(data));
memcpy(data, vch.data(), sizeof(data));
}
template <unsigned int BITS>
std::string base_blob<BITS>::GetHex() const
{
return HexStr(std::reverse_iterator<const uint8_t*>(data + sizeof(data)), std::reverse_iterator<const uint8_t*>(data));
}
template <unsigned int BITS>
void base_blob<BITS>::SetHex(const char* psz)
{
memset(data, 0, sizeof(data));
// skip leading spaces
while (isspace(*psz))
psz++;
// skip 0x
if (psz[0] == '0' && tolower(psz[1]) == 'x')
psz += 2;
// hex string to uint
const char* pbegin = psz;
while (HexDigit(*psz) != -1)
psz++;
psz--;
unsigned char* p1 = (unsigned char*)data;
unsigned char* pend = p1 + WIDTH;
while (psz >= pbegin && p1 < pend) {
*p1 = ::HexDigit(*psz--);
if (psz >= pbegin) {
*p1 |= ((unsigned char)::HexDigit(*psz--) << 4);
p1++;
}
}
}
template <unsigned int BITS>
void base_blob<BITS>::SetHex(const std::string& str)
{
SetHex(str.c_str());
}
template <unsigned int BITS>
std::string base_blob<BITS>::ToString() const
{
return (GetHex());
}
// Explicit instantiations for base_blob<160>
template base_blob<160>::base_blob(const std::vector<unsigned char>&);
template std::string base_blob<160>::GetHex() const;
template std::string base_blob<160>::ToString() const;
template void base_blob<160>::SetHex(const char*);
template void base_blob<160>::SetHex(const std::string&);
// Explicit instantiations for base_blob<256>
template base_blob<256>::base_blob(const std::vector<unsigned char>&);
template std::string base_blob<256>::GetHex() const;
template std::string base_blob<256>::ToString() const;
template void base_blob<256>::SetHex(const char*);
template void base_blob<256>::SetHex(const std::string&);
| [
"jonsalazar99@hotmail.com"
] | jonsalazar99@hotmail.com |
97fc51e9407bfb562359245bb2c5806a2646bce9 | 258b8cd33ce666d1a2a16114af1996a5f36113a4 | /src/Wordlist.hpp | 9f3469c59dc1a0f005ea8f237b97fe56311853c4 | [] | no_license | Emma-Rabbit/hangman | 1099a010985f3e77bcd31933bbfcf0c85a14ed3b | 87bb7c4c4e5bfc01f5f3e2a2288cc9cdb3b3ac09 | refs/heads/main | 2023-05-05T03:11:06.772490 | 2021-05-15T11:11:41 | 2021-05-15T11:11:41 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 339 | hpp | #include "FileManager.hpp"
#include <vector>
#include <string>
class Wordlist{
FileManager *fm;
std::vector<std::string> wordlist;
public:
int addWord(std::string word);
int deleteWord(std::string word);
void listWords();
std::vector<std::string> getWordVector();
std::string pickWord();
Wordlist(std::string filename);
}; | [
"tiranmelia@gmail.com"
] | tiranmelia@gmail.com |
73871068d5f469a92f87b79981c11381a6cdf788 | a05e148a60a5901c1b8faa4aba964e8788fbe1e7 | /cpp/mat_gen2/main.cpp | 71697e08c671e2c83e09533a6a92ea7c57895e71 | [] | no_license | u1234x1234/kaggle-truly-native | 8dd08592e5847be7373c49434f59910dce70b6c7 | 22500be88dc36025ebbec6c354a55bb96b5480cb | refs/heads/master | 2021-01-10T02:03:22.762598 | 2017-04-30T15:16:35 | 2017-04-30T15:16:35 | 47,903,273 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,602 | cpp | #include <iostream>
#include <fstream>
#include <string>
#include <future>
#include <cstdlib>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <cctype>
#include <functional>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include "../xgboost/wrapper/xgboost_wrapper.h"
using namespace std;
int main(int argc, char *argv[])
{
string root_path = "/root/native/";
string mode(argv[1]);
vector<unsigned long> indptr;
vector<unsigned int> indices;
vector<float> data;
int tmp_i;
float tmp_f;
ifstream in1(root_path + "/" + mode + ".indptr");
while(in1.read(reinterpret_cast<char*>(&tmp_i), sizeof(unsigned int)))
indptr.push_back(tmp_i);
cout << "indptr loaded: " << indptr.size() << endl;
cout << "indptr " << indptr[0] << " " << indptr[indptr.size() - 1] << endl;
ifstream in2(root_path + "/" + mode + ".indices");
while(in2.read(reinterpret_cast<char*>(&tmp_i), sizeof(int)))
indices.push_back(tmp_i);
cout << "indices loaded " << indices.size() << endl;
cout << "ind: " << indices[0] << endl;
ifstream in3(root_path + "/" + mode + ".data");
while(in3.read(reinterpret_cast<char*>(&tmp_f), sizeof(float)))
data.push_back(tmp_f);
cout << "data loaded: " << data.size() << endl;
cout << "data: " << data[0] << endl;
DMatrixHandle *out = new DMatrixHandle();
XGDMatrixCreateFromCSR(indptr.data(), indices.data(), data.data(), indptr.size(), data.size(), out);
cout << "dmat created" << endl;
XGDMatrixSaveBinary(*out, (root_path + "/" + mode + ".dmat").c_str(), 0);
cout << "saved" << endl;
return 0;
}
| [
"u1234x1234@gmail.com"
] | u1234x1234@gmail.com |
9a36442ac1ebe20ae6bfb33f1f9d2e03dd4a19eb | e87e60c2a2836ca34c5abf9661230e65dfd565d2 | /src/Json/JsonDiagnostics.cpp | 152799b4912c0020d7835a1872bfb29b6dccc562 | [
"Zlib",
"MIT"
] | permissive | lriki/Lumino.Core | 862234b2022388463d9e18f81aea8f95f9c1c55b | e67084fb8f0c2962b2b36916c747672540902d63 | refs/heads/master | 2021-01-25T15:19:35.856882 | 2017-01-23T13:13:37 | 2017-01-23T13:13:37 | 29,088,000 | 2 | 1 | null | null | null | null | SHIFT_JIS | C++ | false | false | 1,708 | cpp |
#pragma once
//#include "../Base/EnumExtension.h"
//#include "../Base/String.h"
//
//LN_NAMESPACE_BEGIN
//
///** JSON 解析のエラーコード */
//LN_ENUM(JsonParseError)
//{
// NoError = 0, ///< エラーは発生していない
// DocumentEmpty, ///< 入力文字列が空だった
// DocumentRootNotSingular, ///< 複数のルート要素が見つかった
// ValueInvalid, ///< 無効な値
// StringEscapeInvalid, ///< 無効なエスケープシーケンス
// StringMissQuotationMark, ///< 文字列の開始と終端が一致しなかった (" が少ない)
// StringInvalidEncoding, ///< 変換できない文字が存在した
// ArrayMissCommaOrSquareBracket, ///< 配列の要素の後に , か ] が無かった
// ObjectMissKeyStart, ///< オブジェクトメンバの名前の開始 " が見つからなかった
// ObjectMissColon, ///< オブジェクトメンバの : が見つからなかった
// ObjectMissCommaOrCurlyBracket, ///< オブジェクトメンバの後に , か } が見つからなかった
//
// NumberInvalid, ///< 無効な数値
// NumberOverflow, ///< 数値の変換でオーバーフローが発生した
//
// Termination, ///< Hander で中断された
//};
//LN_ENUM_DECLARE(JsonParseError);
//
///**
// @brief JSON 解析中のエラーを表します。
//*/
//class JsonError
//{
//public:
// JsonError()
// : ErrorCode(JsonParseError::NoError)
// , Offset(0)
// , Message()
// {}
//
//public:
// void SetError(JsonParseError errorCode, int offset) { ErrorCode = errorCode; Offset = offset; }
//
//public:
// JsonParseError ErrorCode;
// int Offset;
// String Message;
//};
//
//LN_NAMESPACE_END
| [
"lriki.net@gmail.com"
] | lriki.net@gmail.com |
215a8e7f38f52bdee15d49a6fc3a4d53d3771f00 | 2f874d5907ad0e95a2285ffc3592b8f75ecca7cd | /src/beast/beast/module/core/files/DirectoryIterator.cpp | 5b754a5e84aacd701fe9238fc3cc925cd4cc70de | [
"MIT-Wu",
"MIT",
"ISC",
"BSL-1.0"
] | permissive | dzcoin/DzCoinService | fb93809a37fad0a26bf26189266b44cf4c797865 | b0056717d6bcc1741f4fb3f3f166cd8ce78393f9 | refs/heads/master | 2021-01-20T20:28:41.639585 | 2016-08-15T06:21:51 | 2016-08-15T06:21:51 | 65,678,478 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,569 | cpp | //------------------------------------------------------------------------------
/*
this file is part of beast: https://github.com/vinniefalco/beast
copyright 2013, vinnie falco <vinnie.falco@gmail.com>
portions of this file are from juce.
copyright (c) 2013 - raw material software ltd.
please visit http://www.juce.com
permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
the software is provided "as is" and the author disclaims all warranties
with regard to this software including all implied warranties of
merchantability and fitness. in no event shall the author be liable for
any special , direct, indirect, or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether in an
action of contract, negligence or other tortious action, arising out of
or in connection with the use or performance of this software.
*/
//==============================================================================
#include <beast/cxx14/memory.h> // <memory>
namespace beast {
static stringarray parsewildcards (const string& pattern)
{
stringarray s;
s.addtokens (pattern, ";,", "\"'");
s.trim();
s.removeemptystrings();
return s;
}
static bool filematches (const stringarray& wildcards, const string& filename)
{
for (int i = 0; i < wildcards.size(); ++i)
if (filename.matcheswildcard (wildcards[i], ! file::arefilenamescasesensitive()))
return true;
return false;
}
directoryiterator::directoryiterator (const file& directory, bool recursive,
const string& pattern, const int type)
: wildcards (parsewildcards (pattern)),
filefinder (directory, (recursive || wildcards.size() > 1) ? "*" : pattern),
wildcard (pattern),
path (file::addtrailingseparator (directory.getfullpathname())),
index (-1),
totalnumfiles (-1),
whattolookfor (type),
isrecursive (recursive),
hasbeenadvanced (false)
{
// you have to specify the type of files you're looking for!
bassert ((type & (file::findfiles | file::finddirectories)) != 0);
bassert (type > 0 && type <= 7);
}
directoryiterator::~directoryiterator()
{
}
bool directoryiterator::next()
{
return next (nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
}
bool directoryiterator::next (bool* const isdirresult, bool* const ishiddenresult, std::int64_t* const filesize,
time* const modtime, time* const creationtime, bool* const isreadonly)
{
hasbeenadvanced = true;
if (subiterator != nullptr)
{
if (subiterator->next (isdirresult, ishiddenresult, filesize, modtime, creationtime, isreadonly))
return true;
subiterator = nullptr;
}
string filename;
bool isdirectory, ishidden = false;
while (filefinder.next (filename, &isdirectory,
(ishiddenresult != nullptr || (whattolookfor & file::ignorehiddenfiles) != 0) ? &ishidden : nullptr,
filesize, modtime, creationtime, isreadonly))
{
++index;
if (! filename.containsonly ("."))
{
bool matches = false;
if (isdirectory)
{
if (isrecursive && ((whattolookfor & file::ignorehiddenfiles) == 0 || ! ishidden))
subiterator = std::make_unique <directoryiterator> (
file::createfilewithoutcheckingpath (path + filename),
true, wildcard, whattolookfor);
matches = (whattolookfor & file::finddirectories) != 0;
}
else
{
matches = (whattolookfor & file::findfiles) != 0;
}
// if we're not relying on the os iterator to do the wildcard match, do it now..
if (matches && (isrecursive || wildcards.size() > 1))
matches = filematches (wildcards, filename);
if (matches && (whattolookfor & file::ignorehiddenfiles) != 0)
matches = ! ishidden;
if (matches)
{
currentfile = file::createfilewithoutcheckingpath (path + filename);
if (ishiddenresult != nullptr) *ishiddenresult = ishidden;
if (isdirresult != nullptr) *isdirresult = isdirectory;
return true;
}
if (subiterator != nullptr)
return next (isdirresult, ishiddenresult, filesize, modtime, creationtime, isreadonly);
}
}
return false;
}
const file& directoryiterator::getfile() const
{
if (subiterator != nullptr && subiterator->hasbeenadvanced)
return subiterator->getfile();
// you need to call directoryiterator::next() before asking it for the file that it found!
bassert (hasbeenadvanced);
return currentfile;
}
float directoryiterator::getestimatedprogress() const
{
if (totalnumfiles < 0)
totalnumfiles = file (path).getnumberofchildfiles (file::findfilesanddirectories);
if (totalnumfiles <= 0)
return 0.0f;
const float detailedindex = (subiterator != nullptr) ? index + subiterator->getestimatedprogress()
: (float) index;
return detailedindex / totalnumfiles;
}
} // beast
| [
"dzgrouphelp@foxmail.com"
] | dzgrouphelp@foxmail.com |
4fa3a54aae386cca811170d5456c04f5ba6c6afd | 5137b0cc9b3f7d90425d584f06bda9e4df0f76f8 | /OOP345/MS3/CustomerOrder.h | 9fe50f1de43eebd0ec3b07d7f76ec17a4c02329d | [] | no_license | zzhao58/Zoey_Repos | 2136a19292899bdd3c90ff58b898345096134fa6 | 43519036c087107ca035acf695d127519ead4800 | refs/heads/master | 2023-01-04T17:12:15.152868 | 2019-12-05T02:52:30 | 2019-12-05T02:52:30 | 149,228,810 | 1 | 0 | null | 2023-01-03T16:14:17 | 2018-09-18T04:26:06 | C++ | UTF-8 | C++ | false | false | 817 | h | //CustomerOrder.h
//Zhi Zhao (109079178)
#ifndef CUSTOMERORDER_SICT_H
#define CUSTOMERORDER_SICT_H
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include "ItemInfo.h"
#include "ItemSet.h"
const int MAX = 5;
namespace sict{
class CustomerOrder {
std::string CustomerName;
std::string ProductName;
std::vector<ItemInfo> Items;
static size_t field_width;
public:
CustomerOrder();
CustomerOrder(const std::string&);
~CustomerOrder();
void fillItem(ItemSet&, std::ostream&); //check inventor full?
bool isFilled() const;
bool isItemFilled(const std::string& ) const;
std::string getNameProduct() const;
void display(std::ostream&, bool = false) const; // argument default value should appear in declaration.
static size_t getfieldWidth();
};
}
#endif
| [
"zoeyzhao100@gmail.com"
] | zoeyzhao100@gmail.com |
aac525f7c030ef2b5c5fa778e7f6df37c7f9c39d | 108c2b4b662962786d1f727831251790d8d38162 | /src/somadicom/Dicom/Bruker/BrukerEnhancedMRReader.cc | 64a1e5b5313ab7dd2b4a99a188fd5e2c1e391cd9 | [
"LicenseRef-scancode-cecill-b-en"
] | permissive | brainvisa/soma-io | 105adbaccc5f06d6773ee894f30baec35c48a403 | d22e9d27f6e0696e234a6e33f7fbd9fa4620adc1 | refs/heads/master | 2023-08-04T18:46:57.728163 | 2023-07-28T16:53:08 | 2023-07-28T16:53:08 | 155,413,952 | 3 | 4 | NOASSERTION | 2023-07-28T16:53:09 | 2018-10-30T15:55:17 | C++ | UTF-8 | C++ | false | false | 1,500 | cc | #ifdef SOMA_IO_DICOM
#include <soma-io/Dicom/Bruker/BrukerEnhancedMRReader.h>
#include <soma-io/Dicom/Bruker/BrukerEnhancedIndexModule.h>
#include <soma-io/Dicom/DicomDatasetHeader.h>
#include <soma-io/Dicom/DicomIO.h>
#include <soma-io/Object/HeaderProxy.h>
#include <soma-io/Utils/StdInt.h>
#else
#include <Dicom/Bruker/BrukerEnhancedMRReader.h>
#include <Dicom/Bruker/BrukerEnhancedIndexModule.h>
#include <Dicom/DicomDatasetHeader.h>
#include <Dicom/DicomIO.h>
#include <Object/HeaderProxy.h>
#include <Utils/StdInt.h>
#endif
#include <dcmtk/config/osconfig.h>
#include <dcmtk/dcmdata/dcdatset.h>
#include <dcmtk/dcmdata/dcdeftag.h>
#include <dcmtk/dcmdata/dcsequen.h>
dcm::BrukerEnhancedMRReader::BrukerEnhancedMRReader()
: dcm::EnhancedMRImageStorageReader(),
dcm::Singleton< dcm::BrukerEnhancedMRReader >()
{
}
dcm::BrukerEnhancedMRReader::~BrukerEnhancedMRReader()
{
}
std::string dcm::BrukerEnhancedMRReader::getManufacturerName()
{
return "Bruker BioSpin MRI GmbH";
}
bool dcm::BrukerEnhancedMRReader::buildIndexLut( DcmDataset* dataset )
{
if ( dataset )
{
dcm::BrukerEnhancedIndexModule indexModule;
if ( indexModule.parseItem( dataset ) )
{
_dataInfo->_slices = indexModule.getZCount();
_dataInfo->_frames = indexModule.getTCount();
_indexLut = indexModule.getIndices();
return true;
}
}
return false;
}
RegisterDicomReaderFunction( BrukerEnhancedMRReader );
| [
"FPoupon@users.noreply.github.com"
] | FPoupon@users.noreply.github.com |
e11393522975325d140b2400b45eab816d428a7a | d93b93310b0d35df76331869aba39556bbf2a1e1 | /Parcial 1 y 2/ThreadsConv/10Conveniencia/RAM.cpp | 7e8c024475ebb6d4922a39777d967539c64afca0 | [] | no_license | ErickMimin/Ukranio | 5093d3919c41905339902e878f39e23fd0c26ed2 | 17d8f4f9860c0366c91299a80cd1d56cbe45e085 | refs/heads/master | 2021-01-02T10:32:53.147488 | 2020-05-23T05:23:43 | 2020-05-23T05:23:43 | 239,578,836 | 0 | 0 | null | 2020-05-20T22:26:23 | 2020-02-10T18:07:44 | C | UTF-8 | C++ | false | false | 325 | cpp | #include <iostream>
#include <cstdlib>
using namespace std;
#define numeroElementos 999000000
int main() {
unsigned long *arreglo, i;
arreglo = new unsigned long[numeroElementos];
for(i = 0; i < numeroElementos; i++)
arreglo[i] = 0;
for(i = 0; i < 1000010000; i++){
arreglo[rand() % numeroElementos] = rand();
}
} | [
"Eri_mimo@hotmail.com"
] | Eri_mimo@hotmail.com |
869c819af31f714c119d9009d6ff415d7809a159 | 5456502f97627278cbd6e16d002d50f1de3da7bb | /ui/views/widget/native_widget_private.h | 740880cf19a2e49c0e208c18ba80161620648397 | [
"BSD-3-Clause"
] | permissive | TrellixVulnTeam/Chromium_7C66 | 72d108a413909eb3bd36c73a6c2f98de1573b6e5 | c8649ab2a0f5a747369ed50351209a42f59672ee | refs/heads/master | 2023-03-16T12:51:40.231959 | 2017-12-20T10:38:26 | 2017-12-20T10:38:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 10,285 | h | // 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.
#ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_
#define UI_VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_
#include <memory>
#include <string>
#include "base/strings/string16.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/native_widget.h"
namespace gfx {
class FontList;
class ImageSkia;
class Rect;
}
namespace ui {
class InputMethod;
class NativeTheme;
class OSExchangeData;
}
namespace views {
class TooltipManager;
namespace internal {
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetPrivate interface
//
// A NativeWidget subclass internal to views that provides Widget a conduit for
// communication with a backend-specific native widget implementation.
//
// Many of the methods here are pass-thrus for Widget, and as such there is no
// documentation for them here. In that case, see methods of the same name in
// widget.h.
//
// IMPORTANT: This type is intended for use only by the views system and for
// NativeWidget implementations. This file should not be included
// in code that does not fall into one of these use cases.
//
class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget {
public:
~NativeWidgetPrivate() override {}
// Creates an appropriate default NativeWidgetPrivate implementation for the
// current OS/circumstance.
static NativeWidgetPrivate* CreateNativeWidget(
internal::NativeWidgetDelegate* delegate);
static NativeWidgetPrivate* GetNativeWidgetForNativeView(
gfx::NativeView native_view);
static NativeWidgetPrivate* GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window);
// Retrieves the top NativeWidgetPrivate in the hierarchy containing the given
// NativeView, or NULL if there is no NativeWidgetPrivate that contains it.
static NativeWidgetPrivate* GetTopLevelNativeWidget(
gfx::NativeView native_view);
static void GetAllChildWidgets(gfx::NativeView native_view,
Widget::Widgets* children);
static void GetAllOwnedWidgets(gfx::NativeView native_view,
Widget::Widgets* owned);
static void ReparentNativeView(gfx::NativeView native_view,
gfx::NativeView new_parent);
// Returns true if any mouse button is currently down.
static bool IsMouseButtonDown();
static gfx::FontList GetWindowTitleFontList();
// Returns the NativeView with capture, otherwise NULL if there is no current
// capture set, or if |native_view| has no root.
static gfx::NativeView GetGlobalCapture(gfx::NativeView native_view);
// Initializes the NativeWidget.
virtual void InitNativeWidget(const Widget::InitParams& params) = 0;
// Called at the end of Widget::Init(), after Widget has completed
// initialization.
virtual void OnWidgetInitDone() = 0;
// Returns a NonClientFrameView for the widget's NonClientView, or NULL if
// the NativeWidget wants no special NonClientFrameView.
virtual NonClientFrameView* CreateNonClientFrameView() = 0;
virtual bool ShouldUseNativeFrame() const = 0;
virtual bool ShouldWindowContentsBeTransparent() const = 0;
virtual void FrameTypeChanged() = 0;
// Returns the Widget associated with this NativeWidget. This function is
// guaranteed to return non-NULL for the lifetime of the NativeWidget.
virtual Widget* GetWidget() = 0;
virtual const Widget* GetWidget() const = 0;
// Returns the NativeView/Window associated with this NativeWidget.
virtual gfx::NativeView GetNativeView() const = 0;
virtual gfx::NativeWindow GetNativeWindow() const = 0;
// Returns the topmost Widget in a hierarchy.
virtual Widget* GetTopLevelWidget() = 0;
// Returns the Compositor, or NULL if there isn't one associated with this
// NativeWidget.
virtual const ui::Compositor* GetCompositor() const = 0;
// Returns the NativeWidget's layer, if any.
virtual const ui::Layer* GetLayer() const = 0;
// Reorders the widget's child NativeViews which are associated to the view
// tree (eg via a NativeViewHost) to match the z-order of the views in the
// view tree. The z-order of views with layers relative to views with
// associated NativeViews is used to reorder the NativeView layers. This
// method assumes that the widget's child layers which are owned by a view are
// already in the correct z-order relative to each other and does no
// reordering if there are no views with an associated NativeView.
virtual void ReorderNativeViews() = 0;
// Notifies the NativeWidget that a view was removed from the Widget's view
// hierarchy.
virtual void ViewRemoved(View* view) = 0;
// Sets/Gets a native window property on the underlying native window object.
// Returns NULL if the property does not exist. Setting the property value to
// NULL removes the property.
virtual void SetNativeWindowProperty(const char* name, void* value) = 0;
virtual void* GetNativeWindowProperty(const char* name) const = 0;
// Returns the native widget's tooltip manager. Called from the View hierarchy
// to update tooltips.
virtual TooltipManager* GetTooltipManager() const = 0;
// Sets or releases event capturing for this native widget.
virtual void SetCapture() = 0;
virtual void ReleaseCapture() = 0;
// Returns true if this native widget is capturing events.
virtual bool HasCapture() const = 0;
// Returns the ui::InputMethod for this native widget.
virtual ui::InputMethod* GetInputMethod() = 0;
// Centers the window and sizes it to the specified size.
virtual void CenterWindow(const gfx::Size& size) = 0;
// Retrieves the window's current restored bounds and "show" state, for
// persisting.
virtual void GetWindowPlacement(
gfx::Rect* bounds,
ui::WindowShowState* show_state) const = 0;
// Sets the NativeWindow title. Returns true if the title changed.
virtual bool SetWindowTitle(const base::string16& title) = 0;
// Sets the Window icons. |window_icon| is a 16x16 icon suitable for use in
// a title bar. |app_icon| is a larger size for use in the host environment
// app switching UI.
virtual void SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) = 0;
// Initializes the modal type of the window to |modal_type|. Called from
// NativeWidgetDelegate::OnNativeWidgetCreated() before the widget is
// initially parented.
virtual void InitModalType(ui::ModalType modal_type) = 0;
// See method documentation in Widget.
virtual gfx::Rect GetWindowBoundsInScreen() const = 0;
virtual gfx::Rect GetClientAreaBoundsInScreen() const = 0;
virtual gfx::Rect GetRestoredBounds() const = 0;
virtual std::string GetWorkspace() const = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0;
virtual void SetSize(const gfx::Size& size) = 0;
virtual void StackAbove(gfx::NativeView native_view) = 0;
virtual void StackAtTop() = 0;
virtual void SetShape(std::unique_ptr<SkRegion> shape) = 0;
virtual void Close() = 0;
virtual void CloseNow() = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
// Invoked if the initial show should maximize the window. |restored_bounds|
// is the bounds of the window when not maximized.
virtual void ShowMaximizedWithBounds(const gfx::Rect& restored_bounds) = 0;
virtual void ShowWithWindowState(ui::WindowShowState show_state) = 0;
virtual bool IsVisible() const = 0;
virtual void Activate() = 0;
virtual void Deactivate() = 0;
virtual bool IsActive() const = 0;
virtual void SetAlwaysOnTop(bool always_on_top) = 0;
virtual bool IsAlwaysOnTop() const = 0;
virtual void SetVisibleOnAllWorkspaces(bool always_visible) = 0;
virtual bool IsVisibleOnAllWorkspaces() const = 0;
virtual void Maximize() = 0;
virtual void Minimize() = 0;
virtual bool IsMaximized() const = 0;
virtual bool IsMinimized() const = 0;
virtual void Restore() = 0;
virtual void SetFullscreen(bool fullscreen) = 0;
virtual bool IsFullscreen() const = 0;
virtual void SetOpacity(float opacity) = 0;
virtual void FlashFrame(bool flash) = 0;
virtual void RunShellDrag(View* view,
const ui::OSExchangeData& data,
const gfx::Point& location,
int operation,
ui::DragDropTypes::DragEventSource source) = 0;
virtual void SchedulePaintInRect(const gfx::Rect& rect) = 0;
virtual void SetCursor(gfx::NativeCursor cursor) = 0;
virtual bool IsMouseEventsEnabled() const = 0;
virtual void ClearNativeFocus() = 0;
virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0;
virtual Widget::MoveLoopResult RunMoveLoop(
const gfx::Vector2d& drag_offset,
Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) = 0;
virtual void EndMoveLoop() = 0;
virtual void SetVisibilityChangedAnimationsEnabled(bool value) = 0;
virtual void SetVisibilityAnimationDuration(
const base::TimeDelta& duration) = 0;
virtual void SetVisibilityAnimationTransition(
Widget::VisibilityTransition transition) = 0;
virtual ui::NativeTheme* GetNativeTheme() const = 0;
virtual void OnRootViewLayout() = 0;
virtual bool IsTranslucentWindowOpacitySupported() const = 0;
virtual void OnSizeConstraintsChanged() = 0;
// Repost an unhandled event to the native widget for default OS processing.
virtual void RepostNativeEvent(gfx::NativeEvent native_event) = 0;
// Returns an internal name that matches the name of the associated Widget.
virtual std::string GetName() const = 0;
// Overridden from NativeWidget:
internal::NativeWidgetPrivate* AsNativeWidgetPrivate() override;
};
} // namespace internal
} // namespace views
#endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_PRIVATE_H_
| [
"lixiaodonglove7@aliyun.com"
] | lixiaodonglove7@aliyun.com |
ac15be14855e7923430d97241c783751272e3d8f | 8afb5afd38548c631f6f9536846039ef6cb297b9 | /_REPO/MICROSOFT/react-native-windows/vnext/Microsoft.ReactNative.Cxx/UI.Xaml.Controls.h | 1040f9786a35e27950bab817564588595f442e1c | [
"MIT"
] | permissive | bgoonz/UsefulResourceRepo2.0 | d87588ffd668bb498f7787b896cc7b20d83ce0ad | 2cb4b45dd14a230aa0e800042e893f8dfb23beda | refs/heads/master | 2023-03-17T01:22:05.254751 | 2022-08-11T03:18:22 | 2022-08-11T03:18:22 | 382,628,698 | 10 | 12 | MIT | 2022-10-10T14:13:54 | 2021-07-03T13:58:52 | null | UTF-8 | C++ | false | false | 354 | h | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#ifdef USE_WINUI3
#include <winrt/Microsoft.UI.Xaml.Controls.h>
namespace winrt::Microsoft::UI::Xaml::Controls {
using IControl7 = Control;
} // namespace winrt::Microsoft::UI::Xaml::Controls
#else
#include <winrt/Windows.UI.Xaml.Controls.h>
#endif // USE_WINUI3
| [
"bryan.guner@gmail.com"
] | bryan.guner@gmail.com |
dcaaddfb8548c2b48ebeca6b0691f519b8d46cf6 | fc61880f0895ef0e41c6e0225534c5683313247a | /modules/sort/test/merge_sort_test_suite.cpp | 29b006f064254e6d52dc45ab3a0f5364075fd3d5 | [] | no_license | nkornelsen/computer-vision-bootcamp | ba3cb556deae23c2bc58d6f289b8d70beea6fc49 | e0c00985a9526aa6c196df79e3d66839b47f13fc | refs/heads/master | 2022-11-23T06:04:45.547940 | 2020-08-01T19:45:03 | 2020-08-01T19:45:03 | 284,184,831 | 0 | 0 | null | 2020-08-01T04:19:48 | 2020-08-01T04:19:47 | null | UTF-8 | C++ | false | false | 1,293 | cpp | /**
* @file merge_sort_test_suite.h
* @author Nolan Kornelsen
*
* @section LICENSE
*
* Copyright (c) 2015, Waterloo Aerial Robotics Group (WARG)
* All rights reserved.
*
* This software is licensed under a modified version of the BSD 3 clause license
* that should have been included with this software in a file called COPYING.txt
* Otherwise it is available at:
* https://raw.githubusercontent.com/UWARG/computer-vision/master/COPYING.txt
*/
#define BOOST_TEST_MODULE SortModule
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <cstdlib>
#include "merge_sort.h"
BOOST_AUTO_TEST_SUITE(MergeSortTestSuite);
BOOST_AUTO_TEST_CASE(MergeSortTest) {
int n = rand() % 100 + 1;
std::vector<int> testVector;
for (int i = 0; i < n; i++) {
testVector.push_back(rand() % 1000 + 1);
}
std::cout << "Sorting list: ";
for (int i : testVector) {
std::cout << i << ' ';
}
std::cout << std::endl;
merge_sort(&testVector);
std::cout << "Sorted list: ";
for (int i : testVector) {
std::cout << i << ' ';
}
std::cout << std::endl;
// test if sorted
for (int i = 0; i < testVector.size() - 1; i++) {
BOOST_CHECK(testVector[i] <= testVector[i+1]);
}
}
BOOST_AUTO_TEST_SUITE_END(); | [
"perpetualcolor@gmail.com"
] | perpetualcolor@gmail.com |
403a9f86e53a9d80bc3ad00e87d72ca64919e4d4 | ae3dd93d22fbe363d88f454587b3a08f1f2e7952 | /src/slg/engines/oclrenderengine.cpp | fee7240b900d3aed8a44bdb347e02d51ecdf6519 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | tschw/LuxCore | 1efcfc679856745d33f93d25eb3e9056576d3c4d | 111009811c31a74595e25c290bfaa7d715db4192 | refs/heads/master | 2021-04-12T08:09:14.760438 | 2018-03-20T10:27:15 | 2018-03-20T10:27:15 | 126,042,938 | 0 | 0 | Apache-2.0 | 2018-03-20T15:48:42 | 2018-03-20T15:48:37 | null | UTF-8 | C++ | false | false | 6,164 | cpp | /***************************************************************************
* Copyright 1998-2018 by authors (see AUTHORS.txt) *
* *
* This file is part of LuxCoreRender. *
* *
* Licensed under the Apache License, Version 2.0 (the "License"); *
* you may not use this file except in compliance with the License. *
* You may obtain a copy of the License at *
* *
* http://www.apache.org/licenses/LICENSE-2.0 *
* *
* Unless required by applicable law or agreed to in writing, software *
* distributed under the License is distributed on an "AS IS" BASIS, *
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.*
* See the License for the specific language governing permissions and *
* limitations under the License. *
***************************************************************************/
#include "slg/engines/oclrenderengine.h"
#include "luxrays/core/intersectiondevice.h"
#if !defined(LUXRAYS_DISABLE_OPENCL)
#include "luxrays/core/ocldevice.h"
#endif
using namespace std;
using namespace luxrays;
using namespace slg;
//------------------------------------------------------------------------------
// OCLRenderEngine
//------------------------------------------------------------------------------
OCLRenderEngine::OCLRenderEngine(const RenderConfig *rcfg, Film *flm,
boost::mutex *flmMutex, const bool supportsNativeThreads) : RenderEngine(rcfg, flm, flmMutex) {
#if !defined(LUXRAYS_DISABLE_OPENCL)
const Properties &cfg = renderConfig->cfg;
const bool useCPUs = cfg.Get(GetDefaultProps().Get("opencl.cpu.use")).Get<bool>();
const bool useGPUs = cfg.Get(GetDefaultProps().Get("opencl.gpu.use")).Get<bool>();
// 0 means use the value suggested by the OpenCL driver
const u_int forceCPUWorkSize = cfg.Get(GetDefaultProps().Get("opencl.cpu.workgroup.size")).Get<u_int>();
// 0 means use the value suggested by the OpenCL driver
// Note: I'm using 64 because some driver (i.e. NVIDIA) suggests a value and than
// throws a clEnqueueNDRangeKernel(CL_OUT_OF_RESOURCES)
const u_int forceGPUWorkSize = cfg.Get(GetDefaultProps().Get("opencl.gpu.workgroup.size")).Get<u_int>();
const string oclDeviceConfig = cfg.Get(GetDefaultProps().Get("opencl.devices.select")).Get<string>();
//--------------------------------------------------------------------------
// Get OpenCL device descriptions
//--------------------------------------------------------------------------
vector<DeviceDescription *> oclDescs = ctx->GetAvailableDeviceDescriptions();
DeviceDescription::Filter(DEVICE_TYPE_OPENCL_ALL, oclDescs);
// Device info
bool haveSelectionString = (oclDeviceConfig.length() > 0);
if (haveSelectionString && (oclDeviceConfig.length() != oclDescs.size())) {
stringstream ss;
ss << "OpenCL device selection string has the wrong length, must be " <<
oclDescs.size() << " instead of " << oclDeviceConfig.length();
throw runtime_error(ss.str().c_str());
}
for (size_t i = 0; i < oclDescs.size(); ++i) {
OpenCLDeviceDescription *desc = static_cast<OpenCLDeviceDescription *>(oclDescs[i]);
if (haveSelectionString) {
if (oclDeviceConfig.at(i) == '1') {
if (desc->GetType() & DEVICE_TYPE_OPENCL_GPU)
desc->SetForceWorkGroupSize(forceGPUWorkSize);
else if (desc->GetType() & DEVICE_TYPE_OPENCL_CPU)
desc->SetForceWorkGroupSize(forceCPUWorkSize);
selectedDeviceDescs.push_back(desc);
}
} else {
if ((useCPUs && desc->GetType() & DEVICE_TYPE_OPENCL_CPU) ||
(useGPUs && desc->GetType() & DEVICE_TYPE_OPENCL_GPU)) {
if (desc->GetType() & DEVICE_TYPE_OPENCL_GPU)
desc->SetForceWorkGroupSize(forceGPUWorkSize);
else if (desc->GetType() & DEVICE_TYPE_OPENCL_CPU)
desc->SetForceWorkGroupSize(forceCPUWorkSize);
selectedDeviceDescs.push_back(oclDescs[i]);
}
}
}
oclRenderThreadCount = selectedDeviceDescs.size();
#endif
if (selectedDeviceDescs.size() == 0)
throw runtime_error("No OpenCL device selected or available");
#if !defined(LUXRAYS_DISABLE_OPENCL)
if (supportsNativeThreads) {
//----------------------------------------------------------------------
// Get native device descriptions
//----------------------------------------------------------------------
vector<DeviceDescription *> nativeDescs = ctx->GetAvailableDeviceDescriptions();
DeviceDescription::Filter(DEVICE_TYPE_NATIVE_THREAD, nativeDescs);
nativeDescs.resize(1);
nativeRenderThreadCount = cfg.Get(GetDefaultProps().Get("opencl.native.threads.count")).Get<u_int>();
if (nativeRenderThreadCount > 0)
selectedDeviceDescs.resize(selectedDeviceDescs.size() + nativeRenderThreadCount, nativeDescs[0]);
} else
nativeRenderThreadCount = 0;
#endif
}
Properties OCLRenderEngine::ToProperties(const Properties &cfg) {
return Properties() <<
cfg.Get(GetDefaultProps().Get("opencl.cpu.use")) <<
cfg.Get(GetDefaultProps().Get("opencl.gpu.use")) <<
cfg.Get(GetDefaultProps().Get("opencl.cpu.workgroup.size")) <<
cfg.Get(GetDefaultProps().Get("opencl.gpu.workgroup.size")) <<
cfg.Get(GetDefaultProps().Get("opencl.devices.select")) <<
cfg.Get(GetDefaultProps().Get("opencl.native.threads.count"));
}
const Properties &OCLRenderEngine::GetDefaultProps() {
static Properties props = Properties() <<
RenderEngine::GetDefaultProps() <<
Property("opencl.cpu.use")(false) <<
Property("opencl.gpu.use")(true) <<
#if defined(__APPLE__)
Property("opencl.cpu.workgroup.size")(1) <<
#else
Property("opencl.cpu.workgroup.size")(0) <<
#endif
Property("opencl.gpu.workgroup.size")(64) <<
Property("opencl.devices.select")("") <<
Property("opencl.native.threads.count")(boost::thread::hardware_concurrency());
return props;
}
| [
"dade916@gmail.com"
] | dade916@gmail.com |
d1adcdfac87ee4323213d26d35da44c81b9a6ab1 | 1464919791f6d1932f18f0a2c4a471d4ffcab740 | /DirectionalLight/main.cpp | ea485ece25e51c5aa503447602b841c27ec971a7 | [] | no_license | firearasi/mylearnopengl | bb5f464ba333b075f1d5ab4293c25264c6f15372 | a274b3ec15d5f54ae1bc72cde1aa01739fb756cd | refs/heads/master | 2020-03-22T23:22:20.360790 | 2018-07-13T06:23:17 | 2018-07-13T06:23:17 | 140,806,068 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 16,439 | cpp | #include <glad/glad.h>
#include <GLFW/glfw3.h>
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <shader/shader.h>
#include <utils/camera.h>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void mouse_callback(GLFWwindow* window, double xpos, double ypos);
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset);
void processInput(GLFWwindow *window);
unsigned int loadTexture(char const * path);
// settings
const unsigned int SCR_WIDTH = 1920;
const unsigned int SCR_HEIGHT = 1080;
// camera
Camera camera(glm::vec3(0.0f, 0.0f, 8.0f));
float lastX = SCR_WIDTH / 2.0f;
float lastY = SCR_HEIGHT / 2.0f;
bool firstMouse = true;
// timing
float deltaTime = 0.0f; // time between current frame and last frame
float lastFrame = 0.0f;
int main()
{
// glfw: initialize and configure
// ------------------------------
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // uncomment this statement to fix compilation on OS X
#endif
// glfw window creation
// --------------------
GLFWwindow* window = glfwCreateWindow(SCR_WIDTH, SCR_HEIGHT, "LearnOpenGL", NULL, NULL);
if (window == NULL)
{
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
return -1;
}
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
glfwSetCursorPosCallback(window, mouse_callback);
glfwSetScrollCallback(window, scroll_callback);
glfwMakeContextCurrent(window);
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
// glad: load all OpenGL function pointers
// ---------------------------------------
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
{
std::cout << "Failed to initialize GLAD" << std::endl;
return -1;
}
// configure global opengl state
// -----------------------------
glEnable(GL_DEPTH_TEST);
// build and compile our shader zprogram
// ------------------------------------
Shader cubeShader("shader.vert", "cubeshader.frag");
Shader lightShader("shader.vert", "lightshader.frag");
// set up vertex data (and buffer(s)) and configure vertex attributes
// ------------------------------------------------------------------
float vertices[] = {
// positions // normals // texture coords
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f,
0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
-0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
-0.5f, -0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
-0.5f, 0.5f, 0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f,
0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f,
0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 1.0f,
0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, -0.5f, 0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f,
-0.5f, -0.5f, -0.5f, 0.0f, -1.0f, 0.0f, 0.0f, 1.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f
};
glm::vec3 cubePositions[] = {
glm::vec3( 0.0f, 0.0f, 0.0f),
glm::vec3( 2.0f, 5.0f, -15.0f),
glm::vec3(-1.5f, -2.2f, -2.5f),
glm::vec3(-3.8f, -2.0f, -12.3f),
glm::vec3( 2.4f, -0.4f, -3.5f),
glm::vec3(-1.7f, 3.0f, -7.5f),
glm::vec3( 1.3f, -2.0f, -2.5f),
glm::vec3( 1.5f, 2.0f, -2.5f),
glm::vec3( 1.5f, 0.2f, -1.5f),
glm::vec3(-1.3f, 1.0f, -1.5f)
};
/*
float vertices[] = {
-1, 1, -1, 0.25, 0,
1, 1, -1, 0.5, 0,
-1, 1, -1, 0, 0.25,
-1, 1, 1, 0.25,0.25,
1,1,1,0.5,0.25,
1,1,-1,0.75,0.25,
-1,1,-1,1,0.25,
-1,-1,-1,0,0.5,
-1,-1,1,0.25,0.5,
1,-1,1,0.5,0.5,
1,-1,-1,0.75,0.5,
-1,-1,-1,1,0.5,
-1,-1,-1,0.25,0.75,
1,-1,-1,0.5,0.75
};
int indices[] = {
0,1,4,
0,4,3,
2,3,8,
2,8,7,
3,4,9,
3,9,8,
4,5,10,
4,10,9,
5,6,11,
5,11,10,
8,9,13,
8,13,12
};
*/
// Cube VBO,VAO,EBO
unsigned int VBO, VAO;
glGenVertexArrays(1, &VAO);
glGenBuffers(1, &VBO);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// position attribute
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
// normal vec attribute
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3 * sizeof(float)));
glEnableVertexAttribArray(1);
// texture coords
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));
glEnableVertexAttribArray(2);
// Light Source
unsigned int lightVAO, lightVBO;
glGenVertexArrays(1, &lightVAO);
glGenBuffers(1, &lightVBO);
glBindVertexArray(lightVAO);
glBindBuffer(GL_ARRAY_BUFFER, lightVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
// position attribute
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);
glEnableVertexAttribArray(0);
// normal vec attribute
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*) (3 * sizeof(float)));
glEnableVertexAttribArray(1);
// load and create a texture
// -------------------------
unsigned int diffuseMap = loadTexture("../textures/container2.png");
unsigned int specularMap = loadTexture("../textures/container2_specular.png");
unsigned int emissiveMap = loadTexture("../textures/matrix.jpg");
// render loop
// -----------
while (!glfwWindowShouldClose(window))
{
// per-frame time logic
// --------------------
//std::cout<< "Camera pos: (" << camera.Position.x<<", "<<camera.Position.y<<", "<<camera.Position.z<<")."<<std::endl;
float currentFrame = glfwGetTime();
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
// input
// -----
processInput(window);
// render
// ------
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // also clear the depth buffer now!
// create transformations
glm::mat4 model;
glm::mat4 view;
glm::mat4 projection;
glm::mat4 translation;
unsigned int modelLoc;
unsigned int viewLoc;
// Set colors
glm::vec4 lightColor = glm::vec4(1.f, 1.0f, 1.0f, 1.0f);
glm::vec3 lightPos = glm::vec3(3.0, 2.0, 2.5);
// Draw light source
/*
lightShader.use();
glBindVertexArray(lightVAO);
model = glm::scale(glm::mat4(1.0f), glm::vec3(0.2));
view = camera.GetViewMatrix();
translation = glm::translate(glm::mat4(1.0),lightPos);
projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
lightShader.set4fv("lightColor", lightColor);
lightShader.setMat4("model", model);
lightShader.setMat4("view", view);
// note: currently we set the projection matrix each frame, but since the projection matrix rarely changes it's often best practice to set it outside the main loop only once.
lightShader.setMat4("projection", projection);
lightShader.setMat4("translation", translation);
glDrawArrays(GL_TRIANGLES, 0, 36);
//glDrawElements(GL_TRIANGLES, sizeof(indices) / sizeof(int), GL_UNSIGNED_INT, 0);
*/
// Draw cube
// activate shader
cubeShader.use();
// Load lightingmaps
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, diffuseMap);
glActiveTexture(GL_TEXTURE0 + 1);
glBindTexture(GL_TEXTURE_2D, specularMap);
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, emissiveMap);
cubeShader.setInt("material.diffuse", 0);
cubeShader.setInt("material.specular", 1);
cubeShader.setInt("material.emissive", 2);
cubeShader.setFloat("material.shininess", 32);
// light properties
cubeShader.set4fv("light.direction", glm::vec4(-0.2f, -1.0f, -0.3f, 0.0f));
cubeShader.set4fv("light.ambient", glm::vec4(0.4f, 0.4f, 0.4f, 1.0f));
cubeShader.set4fv("light.diffuse", glm::vec4(0.7f, 0.7f, 0.7f, 1.0f));
cubeShader.set4fv("light.specular", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
// retrieve the matrix uniform locations
cubeShader.setFloat("u_time", glfwGetTime());
// set normal matrix
glm::mat3 normalMatrix = glm::mat3(glm::transpose(glm::inverse(model)));
cubeShader.setMat3("normalMatrix", normalMatrix);
// render box
// set viewPos
cubeShader.set3fv("viewPos", camera.Position);
// note: currently we set the projection matrix each frame, but since the projection matrix rarely changes it's often best practice to set it outside the main loop only once.
cubeShader.setMat4("projection", projection);
glBindVertexArray(VAO);
view = camera.GetViewMatrix();
translation = glm::mat4(1.0);
for (int i = 0; i< 10; i++)
{
//model = glm::rotate(glm::mat4(1.0), (float)glfwGetTime() * glm::radians(10.0f), glm::vec3(0.5f, 1.0f, 0.0f));
model = glm::rotate(glm::mat4(1.0), glm::radians(23.0f * i), glm::vec3(0.5f, 1.0f, 0.1f));
model = glm::translate(model, cubePositions[i]);
projection = glm::perspective(glm::radians(45.0f), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 100.0f);
// note: currently we set the projection matrix each frame, but since the projection matrix rarely changes it's often best practice to set it outside the main loop only once.
cubeShader.setMat4("model", model);
cubeShader.setMat4("view", view);
cubeShader.setMat4("projection", projection);
cubeShader.setMat4("translation", translation);
glDrawArrays(GL_TRIANGLES, 0, 36);
}
//glDrawElements(GL_TRIANGLES, sizeof(indices) / sizeof(int), GL_UNSIGNED_INT, 0);
//translation = glm::translate(glm::mat4(1.0), glm::vec3(2.0,2.0,2.0));
//cubeShader.setMat4("translation", translation);
//glDrawArrays(GL_TRIANGLES, 0, 36);
// glfw: swap buffers and poll IO events (keys pressed/released, mouse moved etc.)
// -------------------------------------------------------------------------------
glfwSwapBuffers(window);
glfwPollEvents();
}
// optional: de-allocate all resources once they've outlived their purpose:
// ------------------------------------------------------------------------
glDeleteVertexArrays(1, &VAO);
glDeleteBuffers(1, &VBO);
// glfw: terminate, clearing all previously allocated GLFW resources.
// ------------------------------------------------------------------
glfwTerminate();
return 0;
}
// process all input: query GLFW whether relevant keys are pressed/released this frame and react accordingly
// ---------------------------------------------------------------------------------------------------------
void processInput(GLFWwindow *window)
{
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
if (glfwGetKey(window, GLFW_KEY_W) == GLFW_PRESS)
camera.ProcessKeyboard(FORWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_S) == GLFW_PRESS)
camera.ProcessKeyboard(BACKWARD, deltaTime);
if (glfwGetKey(window, GLFW_KEY_A) == GLFW_PRESS)
camera.ProcessKeyboard(LEFT, deltaTime);
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
camera.ProcessKeyboard(RIGHT, deltaTime);
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS)
camera.ProcessKeyboard(DOWN, deltaTime);
if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS)
camera.ProcessKeyboard(UP, deltaTime);
}
// glfw: whenever the window size changed (by OS or user resize) this callback function executes
// ---------------------------------------------------------------------------------------------
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
// make sure the viewport matches the new window dimensions; note that width and
// height will be significantly larger than specified on retina displays.
glViewport(0, 0, width, height);
}
void mouse_callback(GLFWwindow* window, double xpos, double ypos)
{
if (firstMouse)
{
lastX = xpos;
lastY = ypos;
firstMouse = false;
}
float xoffset = xpos - lastX;
float yoffset = lastY - ypos; // reversed since y-coordinates go from bottom to top
lastX = xpos;
lastY = ypos;
camera.ProcessMouseMovement(xoffset, yoffset);
}
// glfw: whenever the mouse scroll wheel scrolls, this callback is called
// ----------------------------------------------------------------------
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{
if (glfwGetKey(window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS)
camera.ProcessMouseScroll(yoffset);
}
// utility function for loading a 2D texture from file
// ---------------------------------------------------
unsigned int loadTexture(char const * path)
{
unsigned int textureID;
glGenTextures(1, &textureID);
int width, height, nrComponents;
unsigned char *data = stbi_load(path, &width, &height, &nrComponents, 0);
if (data)
{
GLenum format;
if (nrComponents == 1)
format = GL_RED;
else if (nrComponents == 3)
format = GL_RGB;
else if (nrComponents == 4)
format = GL_RGBA;
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
stbi_image_free(data);
}
else
{
std::cout << "Texture failed to load at path: " << path << std::endl;
stbi_image_free(data);
}
return textureID;
}
| [
"firearasi@qq.com"
] | firearasi@qq.com |
e5dfafe041a81815be98368a96047f9f5630ce9e | c5cf8346c93728e98d086277ebf1d513481c9216 | /ShinobiEngine/Engine/GameObjectx/Components/Transform2D.cpp | 683ac36f00c3eb8378af03432795d16831ca498a | [
"Apache-2.0"
] | permissive | denevcoding/ShinobiEngine2D | 46834bb59317a81809cb46719d9061a46beed4e1 | 3d29adc18cd4ccbb975969d1ccf348401c715fa4 | refs/heads/master | 2022-11-18T05:32:03.189537 | 2020-07-22T13:05:54 | 2020-07-22T13:05:54 | 281,673,477 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 356 | cpp | #include "stdafx.h"
#include "Transform2D.h"
Transform2D::~Transform2D()
{
std::cerr << "Se destruido un Tansform 2D" << std::endl;
}
void Transform2D::Update(double ftimeDiff)
{
}
void Transform2D::ReceiveMsg(const Message& message)
{
}
void Transform2D::Activate()
{
m_isEnabled = true;
}
void Transform2D::Deactivate()
{
m_isEnabled = false;
}
| [
"kevin.velez@live.u-tad.com"
] | kevin.velez@live.u-tad.com |
aa048bc158652efd02027505144a2ad168e0be05 | 9853d6bd0920bdb895a3e795f6e06079823ef4c6 | /AladinGame/Aladin/Viewport.cpp | e1f1a7a9213c062c3cfeeb75041fa9fd97d38210 | [] | no_license | vantranguit920/Aladin | db921c8549349a927642172c1f598c96dffc6dfe | fc4e822f0b0e733b2a2daf1e4b8e12cd7734cbf2 | refs/heads/master | 2022-02-28T06:35:37.950865 | 2019-11-12T17:20:13 | 2019-11-12T17:20:13 | 217,807,415 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,976 | cpp | #include "Viewport.h"
#include "Object.h"
Viewport::Viewport()
{
}
Viewport::Viewport(float x, float y)
{
this->positionWorld.x = x;
this->positionWorld.y = y;
//Mặc định là kích thước game
this->width = 500.0f;
this->height = 500.0f;
}
Viewport::Viewport(float x, float y, float width, float height)
{
this->positionWorld.x = x;
this->positionWorld.y = y;
this->width = width;
this->height = height;
}
Viewport::~Viewport()
{
}
//Get set vị trí Viewport
D3DXVECTOR2 Viewport::GetPosition()
{
return positionWorld;
}
void Viewport::SetPosition(D3DXVECTOR2 position)
{
positionWorld = position;
}
void Viewport::SetPositionX(float x)
{
positionWorld.x = x;
}
void Viewport::SetPositionY(float y)
{
positionWorld.y = y;
}
//Lấy chiều dài rộng của Viewport
float Viewport::GetWidth()
{
return this->width;
}
float Viewport::GetHeight()
{
return this->height;
}
int Viewport::GetStart()
{
return this->start;
}
bool Viewport::GetInStageBoos()
{
return inStageBoss;
}
void Viewport::SetInStageBoss(bool b)
{
inStageBoss = b;
}
D3DXVECTOR2 Viewport::TransformPosition(D3DXVECTOR2 position)
{
D3DXVECTOR3* position3 = &D3DXVECTOR3(position.x, position.y, 0);
D3DXMATRIX mt;
D3DXVECTOR4 posInViewport;
//đổi ma trận chuẩn bị nhân lấy tọa độ mới
D3DXMatrixIdentity(&mt);
mt._22 = -1.0f;
mt._41 = -positionWorld.x;
mt._42 = positionWorld.y;
D3DXVec3Transform(&posInViewport, position3, &mt);
return D3DXVECTOR2(posInViewport.x, posInViewport.y);
}
//Kiểm tra 1 rect có ở trong màn hình không
bool Viewport::isContains(RECT rect)
{
if (rect.right < positionWorld.x)
return false;
if (rect.bottom > positionWorld.y)
return false;
if (rect.left > positionWorld.x + width)
return false;
if (rect.top < positionWorld.y - height)
return false;
return true;
}
//Kích thước RECT màn hình tính trong World
RECT Viewport::GetBound()
{
RECT rect;
rect.left = this->positionWorld.x;
rect.top = this->positionWorld.y;
rect.bottom = rect.top - height;
rect.right = rect.left + width;
return rect;
}
//Update theo 1 đối tượng
void Viewport::Update(float dt, Keyboard* key, D3DXVECTOR2 &posobject, D3DXVECTOR2 velocityMan, std::vector <Stage*> listStage)
{
//trục X
if (posobject.x - positionWorld.x <= width/2 )
positionWorld.x = posobject.x - width/2 ;
else if (posobject.x - positionWorld.x >= width/2)
positionWorld.x = posobject.x - width/2 ;
//trục Y
if (positionWorld.y - posobject.y <= width/2 )
positionWorld.y = posobject.y + width/2 ;
else if (positionWorld.y - posobject.y >= width/2 )
positionWorld.y = posobject.y + width/2 ;
/*if (positionWorld.x < start)
positionWorld.x = start;
else if (positionWorld.x > end - width)
positionWorld.x = end - width;
if (positionWorld.y < height + bottom)
positionWorld.y = height + bottom;
else if (positionWorld.y > top)
positionWorld.y = top;*/
} | [
"="
] | = |
76b2700d4c5d8f2d7e86078a77409ab606d453e9 | 1a8f5d5fb51498859bb06d0287ad6c38e9bb8f70 | /sparta/test/PatriciaTreeSetAbstractDomainTest.cpp | 198d8ac22d4a2e7b919b3c48c23d5e5ee21526bc | [
"MIT"
] | permissive | willpyshan13/redex | a5c3109734626bb647e2dfcd49c7d38075ab3553 | 0bb6a6ca434c4f57e825f0c3e0d47d7f1388529f | refs/heads/master | 2022-04-15T07:19:18.825412 | 2020-04-15T01:25:03 | 2020-04-15T01:27:58 | 255,777,262 | 1 | 0 | MIT | 2020-04-15T01:57:46 | 2020-04-15T01:57:45 | null | UTF-8 | C++ | false | false | 5,849 | cpp | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "PatriciaTreeSetAbstractDomain.h"
#include <algorithm>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <memory>
#include <string>
#include <vector>
#include "PatriciaTreeSet.h"
using namespace sparta;
using Domain = PatriciaTreeSetAbstractDomain<std::string*>;
class PatriciaTreeSetAbstractDomainTest : public ::testing::Test {
protected:
PatriciaTreeSetAbstractDomainTest()
: m_a(new std::string("a")),
m_b(new std::string("b")),
m_c(new std::string("c")),
m_d(new std::string("d")) {}
std::string* a() { return m_a.get(); }
std::string* b() { return m_b.get(); }
std::string* c() { return m_c.get(); }
std::string* d() { return m_d.get(); }
std::string* e() { return m_e.get(); }
std::vector<std::string> to_string(const PatriciaTreeSet<std::string*>& s) {
std::vector<std::string> result;
std::transform(s.begin(),
s.end(),
std::back_inserter(result),
[](std::string* p) { return *p; });
return result;
}
std::unique_ptr<std::string> m_a;
std::unique_ptr<std::string> m_b;
std::unique_ptr<std::string> m_c;
std::unique_ptr<std::string> m_d;
std::unique_ptr<std::string> m_e;
};
TEST_F(PatriciaTreeSetAbstractDomainTest, latticeOperations) {
Domain e1(this->a());
Domain e2({this->a(), this->b(), this->c()});
Domain e3({this->b(), this->c(), this->d()});
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("a"));
EXPECT_THAT(this->to_string(e2.elements()),
::testing::UnorderedElementsAre("a", "b", "c"));
EXPECT_THAT(this->to_string(e3.elements()),
::testing::UnorderedElementsAre("b", "c", "d"));
EXPECT_TRUE(Domain::bottom().leq(Domain::top()));
EXPECT_FALSE(Domain::top().leq(Domain::bottom()));
EXPECT_FALSE(e2.is_top());
EXPECT_FALSE(e2.is_bottom());
EXPECT_TRUE(e1.leq(e2));
EXPECT_FALSE(e1.leq(e3));
EXPECT_TRUE(e2.equals(Domain({this->b(), this->c(), this->a()})));
EXPECT_FALSE(e2.equals(e3));
EXPECT_THAT(this->to_string(e2.join(e3).elements()),
::testing::UnorderedElementsAre("a", "b", "c", "d"));
EXPECT_TRUE(e1.join(e2).equals(e2));
EXPECT_TRUE(e2.join(Domain::bottom()).equals(e2));
EXPECT_TRUE(e2.join(Domain::top()).is_top());
EXPECT_TRUE(e1.widening(e2).equals(e2));
EXPECT_THAT(this->to_string(e2.meet(e3).elements()),
::testing::UnorderedElementsAre("b", "c"));
EXPECT_TRUE(e1.meet(e2).equals(e1));
EXPECT_TRUE(e2.meet(Domain::bottom()).is_bottom());
EXPECT_TRUE(e2.meet(Domain::top()).equals(e2));
EXPECT_FALSE(e1.meet(e3).is_bottom());
EXPECT_TRUE(e1.meet(e3).elements().empty());
EXPECT_TRUE(e1.narrowing(e2).equals(e1));
EXPECT_TRUE(e2.contains(this->a()));
EXPECT_FALSE(e3.contains(this->a()));
// Making sure no side effect took place.
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("a"));
EXPECT_THAT(this->to_string(e2.elements()),
::testing::UnorderedElementsAre("a", "b", "c"));
EXPECT_THAT(this->to_string(e3.elements()),
::testing::UnorderedElementsAre("b", "c", "d"));
}
TEST_F(PatriciaTreeSetAbstractDomainTest, destructiveOperations) {
Domain e1(this->a());
Domain e2({this->a(), this->b(), this->c()});
Domain e3({this->b(), this->c(), this->d()});
e1.add(this->b());
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("a", "b"));
e1.add({this->a(), this->c()});
EXPECT_TRUE(e1.equals(e2));
std::vector<std::string*> v1 = {this->a(), this->b()};
e1.add(v1.begin(), v1.end());
EXPECT_TRUE(e1.equals(e2));
e1.remove(this->b());
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("a", "c"));
e1.remove(this->d());
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("a", "c"));
std::vector<std::string*> v2 = {this->a(), this->e()};
e1.remove(v2.begin(), v2.end());
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("c"));
e1.remove({this->a(), this->c()});
EXPECT_TRUE(e1.elements().empty());
e1.join_with(e2);
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("a", "b", "c"));
e1.join_with(Domain::bottom());
EXPECT_TRUE(e1.equals(e2));
e1.join_with(Domain::top());
EXPECT_TRUE(e1.is_top());
e1 = Domain(this->a());
e1.widen_with(Domain({this->b(), this->c()}));
EXPECT_TRUE(e1.equals(e2));
e1 = Domain(this->a());
e2.meet_with(e3);
EXPECT_THAT(this->to_string(e2.elements()),
::testing::UnorderedElementsAre("b", "c"));
e1.meet_with(e2);
EXPECT_TRUE(e1.elements().empty());
e1.meet_with(Domain::top());
EXPECT_THAT(this->to_string(e2.elements()),
::testing::UnorderedElementsAre("b", "c"));
e1.meet_with(Domain::bottom());
EXPECT_TRUE(e1.is_bottom());
e1 = Domain(this->a());
e1.narrow_with(Domain({this->a(), this->b()}));
EXPECT_THAT(this->to_string(e1.elements()),
::testing::UnorderedElementsAre("a"));
EXPECT_FALSE(e2.is_top());
e1.set_to_top();
EXPECT_TRUE(e1.is_top());
e1.set_to_bottom();
EXPECT_TRUE(e1.is_bottom());
EXPECT_FALSE(e2.is_bottom());
e2.set_to_bottom();
EXPECT_TRUE(e2.is_bottom());
e1 = Domain({this->a(), this->b(), this->c(), this->d()});
e2 = e1;
EXPECT_TRUE(e1.equals(e2));
EXPECT_TRUE(e2.equals(e1));
EXPECT_FALSE(e2.is_bottom());
EXPECT_THAT(this->to_string(e2.elements()),
::testing::UnorderedElementsAre("a", "b", "c", "d"));
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
b566a8ff631c0f09aeddaa188626d1957b732a59 | ea401c3e792a50364fe11f7cea0f35f99e8f4bde | /hackathon/wpkenan/resample_swc/resampling.h | 4709d789b7025d003f5eb45c652f5f312604793f | [
"MIT"
] | permissive | Vaa3D/vaa3d_tools | edb696aa3b9b59acaf83d6d27c6ae0a14bf75fe9 | e6974d5223ae70474efaa85e1253f5df1814fae8 | refs/heads/master | 2023-08-03T06:12:01.013752 | 2023-08-02T07:26:01 | 2023-08-02T07:26:01 | 50,527,925 | 107 | 86 | MIT | 2023-05-22T23:43:48 | 2016-01-27T18:19:17 | C++ | UTF-8 | C++ | false | false | 4,256 | h | //resample neuronTree subject to a step length
//2012-02-29 by Yinan Wan
//2012-03-05 Yinan Wan: interpolate radius
#ifndef __RESAMPLING_H__
#define __RESAMPLING_H__
#include "basic_surf_objs.h"
#include <vector>
using namespace std;
#define DISTP(a,b) sqrt(((a)->x-(b)->x)*((a)->x-(b)->x)+((a)->y-(b)->y)*((a)->y-(b)->y)+((a)->z-(b)->z)*((a)->z-(b)->z))
struct Point;
struct Point
{
double x,y,z,r;
V3DLONG type;
Point* p;
V3DLONG childNum;
V3DLONG level,seg_id;
QList<float> fea_val;
};
typedef vector<Point*> Segment;
typedef vector<Point*> Tree;
void resample_path(Segment * seg, double step)
{
char c;
Segment seg_r;
double path_length = 0;
Point* start = seg->at(0);
Point* seg_par = seg->back()->p;
V3DLONG iter_old = 0;
seg_r.push_back(start);
while (iter_old < seg->size() && start && start->p)
{
path_length += DISTP(start,start->p);
if (path_length<=seg_r.size()*step)
{
start = start->p;
iter_old++;
}
else//a new point should be created
{
path_length -= DISTP(start,start->p);
Point* pt = new Point;
double rate = (seg_r.size()*step-path_length)/(DISTP(start,start->p));
pt->x = start->x + rate*(start->p->x-start->x);
pt->y = start->y + rate*(start->p->y-start->y);
pt->z = start->z + rate*(start->p->z-start->z);
pt->r = start->r*(1-rate) + start->p->r*rate;//intepolate the radius
pt->p = start->p;
if (rate<0.5)
{
pt->type = start->type;
pt->seg_id = start->seg_id;
pt->level = start->level;
pt->fea_val = start->fea_val;
}
else
{
pt->type = start->p->type;
pt->seg_id = start->p->seg_id;
pt->level = start->p->level;
pt->fea_val = start->p->fea_val;
}
seg_r.back()->p = pt;
seg_r.push_back(pt);
path_length += DISTP(start,pt);
start = pt;
}
}
seg_r.back()->p = seg_par;
for (V3DLONG i=0;i<seg->size();i++)
if (!seg->at(i)) {delete seg->at(i); seg->at(i) = NULL;}
*seg = seg_r;
};
NeuronTree resample(NeuronTree input, double step)
{
NeuronTree result;
V3DLONG siz = input.listNeuron.size();
Tree tree;
for (V3DLONG i=0;i<siz;i++)
{
NeuronSWC s = input.listNeuron[i];
Point* pt = new Point;
pt->x = s.x;
pt->y = s.y;
pt->z = s.z;
pt->r = s.r;
pt ->type = s.type;
pt->seg_id = s.seg_id;
pt->level = s.level;
pt->fea_val = s.fea_val;
pt->p = NULL;
pt->childNum = 0;
tree.push_back(pt);
}
for (V3DLONG i=0;i<siz;i++)
{
if (input.listNeuron[i].pn<0) continue;
V3DLONG pid = input.hashNeuron.value(input.listNeuron[i].pn);
tree[i]->p = tree[pid];
tree[pid]->childNum++;
}
// printf("tree constructed.\n");
vector<Segment*> seg_list;
for (V3DLONG i=0;i<siz;i++)
{
if (tree[i]->childNum!=1)//tip or branch point
{
Segment* seg = new Segment;
Point* cur = tree[i];
do
{
seg->push_back(cur);
cur = cur->p;
}
while(cur && cur->childNum==1);
seg_list.push_back(seg);
}
}
// printf("segment list constructed.\n");
for (V3DLONG i=0;i<seg_list.size();i++)
{
resample_path(seg_list[i], step);
}
// printf("resample done.\n");
tree.clear();
map<Point*, V3DLONG> index_map;
for (V3DLONG i=0;i<seg_list.size();i++)
for (V3DLONG j=0;j<seg_list[i]->size();j++)
{
tree.push_back(seg_list[i]->at(j));
index_map.insert(pair<Point*, V3DLONG>(seg_list[i]->at(j), tree.size()-1));
}
for (V3DLONG i=0;i<tree.size();i++)
{
NeuronSWC S;
Point* p = tree[i];
S.n = i+1;
if (p->p==NULL) S.pn = -1;
else
S.pn = index_map[p->p]+1;
if (p->p==p) printf("There is loop in the tree!\n");
S.x = p->x;
S.y = p->y;
S.z = p->z;
S.r = p->r;
S.type = p->type;
S.seg_id = p->seg_id;
S.level = p->level;
S.fea_val = p->fea_val;
result.listNeuron.push_back(S);
}
for (V3DLONG i=0;i<tree.size();i++)
{
if (tree[i]) {delete tree[i]; tree[i]=NULL;}
}
for (V3DLONG j=0;j<seg_list.size();j++)
if (seg_list[j]) {delete seg_list[j]; seg_list[j] = NULL;}
for (V3DLONG i=0;i<result.listNeuron.size();i++)
result.hashNeuron.insert(result.listNeuron[i].n, i);
return result;
}
#endif
| [
"llfwyyx@163.com"
] | llfwyyx@163.com |
3c89e47dd3381b4dfa1a4340129f79effcc80b24 | 5fd336b1e29a2a439ec16f81b0ed6fd38a9538de | /REM.cpp | d9c41b3e0d4a44f06294672395f5a36d0c19507b | [] | no_license | itsmekate/ft_gkrellm | 58a7924cf0f5d77cf6f8e0fcf26a43942bec34c8 | 698101198a89cb759619e579807a5b935c44a295 | refs/heads/master | 2020-04-01T04:22:00.289774 | 2018-10-14T14:14:27 | 2018-10-14T14:14:27 | 152,860,364 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,550 | cpp | //
// Created by Kateryna PRASOL on 13.10.2018.
//
#include "REM.h"
REM::REM()
{
char line[80];
FILE *top = popen("top -l 1| grep PhysMem", "r");
fgets(line, sizeof(line), top);
pclose(top);
_REM = line;
}
REM::REM(REM const &rhs)
{
*this = rhs;
}
REM const & REM::operator=(REM const &rhs)
{
if (this != &rhs)
{
_REM = rhs._REM;
}
return (*this);
}
REM::~REM()
{
}
std::string REM::getREM()
{
char line[80];
FILE *top = popen("top -l 1| grep PhysMem", "r");
fgets(line, sizeof(line), top);
pclose(top);
_REM = line;
return _REM;
}
void REM::outputREM(WINDOW *_winREM)
{
std::string s = getREM();
int d = stoi(s.substr(9, 11)) / 400;
std::string progress (d, ' ');
wattron(_winREM, COLOR_PAIR(7));
mvwprintw(_winREM, 3, 2, "..............................................");
wattron(_winREM, COLOR_PAIR(7));
wattron(_winREM, A_BOLD);
wattron(_winREM, COLOR_PAIR(6));
mvwprintw(_winREM, 1, 2, "%s", getREM().c_str());
wattroff(_winREM, COLOR_PAIR(6));
wattron(_winREM, COLOR_PAIR(10));
mvwprintw(_winREM, 3, 2, "%s", progress.c_str());
wattroff(_winREM, COLOR_PAIR(10));
wattroff(_winREM, A_BOLD);
wattron(_winREM, COLOR_PAIR(1));
box(_winREM, 0, 0);
wattroff(_winREM, COLOR_PAIR(1));
wrefresh(_winREM);
}
void REM::outputCPU(WINDOW *_winCPU){(void)_winCPU;}
void REM::outputNetwork(WINDOW *_winNetwork){(void) _winNetwork;}
void REM::outputOSInfoWindow(WINDOW *_winOSInfo){(void) _winOSInfo;} | [
"prasolkaterina@knu.ua"
] | prasolkaterina@knu.ua |
783d53a1eecd42da6b844c22b876f2250aadc3ec | 4368f3b127b9330885c7a1789446c8af56189cdb | /Qt/QtCore/qlocale_blackberry.h | c80b6c1c3631b56e9fdf79c83227d6a8465929e0 | [
"MIT"
] | permissive | Yangff/mvuccu | 4cb57a8fb855a60c44e40f30b9c23bc66e175781 | d0dc7c84fdeea4ee3b70ba758942a3499bd7a53a | refs/heads/master | 2021-01-17T06:52:24.207080 | 2017-11-24T17:08:24 | 2017-11-24T17:08:24 | 52,864,715 | 5 | 5 | null | 2017-11-24T17:08:24 | 2016-03-01T09:30:02 | C++ | UTF-8 | C++ | false | false | 2,994 | h | /****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL21$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QLOCALE_BLACKBERRY_H
#define QLOCALE_BLACKBERRY_H
#include <QtCore/qsocketnotifier.h>
#include <QtCore/qreadwritelock.h>
#include <QtCore/qlocale.h>
QT_BEGIN_NAMESPACE
#ifndef QT_NO_SYSTEMLOCALE
class QBBSystemLocaleData : public QObject
{
Q_OBJECT
public:
QBBSystemLocaleData();
virtual ~QBBSystemLocaleData();
uint measurementSystem();
QVariant timeFormat(QLocale::FormatType);
QVariant dateTimeFormat(QLocale::FormatType);
QLocale languageLocale();
QLocale regionLocale();
QReadWriteLock lock;
public Q_SLOTS:
void installSocketNotifiers();
void readLanguageLocale();
void readRegionLocale();
void readMeasurementSystem();
void readHourFormat();
private:
QByteArray readPpsValue(const char *ppsObject, int ppsFd);
QString getCorrectFormat(const QString &baseFormat, QLocale::FormatType typeFormat);
QByteArray lc_language;
QByteArray lc_region;
uint m_measurementSystem;
bool is24HourFormat;
QSocketNotifier *languageNotifier;
QSocketNotifier *regionNotifier;
QSocketNotifier *measurementNotifier;
QSocketNotifier *hourNotifier;
int languageFd;
int regionFd;
int measurementFd;
int hourFd;
};
#endif // QT_NO_SYSTEMLOCALE
QT_END_NAMESPACE
#endif // QLOCALE_BLACKBERRY_H
| [
"yangff1@gmail.com"
] | yangff1@gmail.com |
354160b2291c0a49ff87a323022a9e5bf01bdb73 | fac52aacf1a7145d46f420bb2991528676e3be3f | /SDK/AnimBP_Hunter_86_classes.h | a75ac65b3d76e82fdf9b4be2b36736df3a54f1be | [] | no_license | zH4x-SDK/zSCUM-SDK | 2342afd6ee54f4f0b14b0a0e9e3920d75bdb4fed | 711376eb272b220521fec36d84ca78fc11d4802a | refs/heads/main | 2023-07-15T16:02:22.649492 | 2021-08-27T13:44:21 | 2021-08-27T13:44:21 | 400,522,163 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,738 | h | #pragma once
// Name: SCUM, Version: 4.20.3
#ifdef _MSC_VER
#pragma pack(push, 0x8)
#endif
namespace SDK
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// AnimBlueprintGeneratedClass AnimBP_Hunter_86.AnimBP_Hunter_85_C
// 0x0960 (0x0CE0 - 0x0380)
class UAnimBP_Hunter_85_C : public UWeaponAnimInstance
{
public:
struct FPointerToUberGraphFrame UberGraphFrame; // 0x0380(0x0008) (Transient, DuplicateTransient)
struct FAnimNode_Root AnimGraphNode_Root_31F1701D46E0E3F3EE3D98933FB192E6; // 0x0388(0x0048)
struct FAnimNode_Slot AnimGraphNode_Slot_A95CEACC47CD6D3C6CB3E597B76A7F4E; // 0x03D0(0x0070)
struct FAnimNode_SaveCachedPose AnimGraphNode_SaveCachedPose_91AB8849488134DD83BB2C9FD1EF07D4;// 0x0440(0x00E0)
struct FAnimNode_SequencePlayer AnimGraphNode_SequencePlayer_FC7BB48E4BF0507D600784A9234ACCF2;// 0x0520(0x00B0)
struct FAnimNode_Slot AnimGraphNode_Slot_040F231F4BF8E5E8138357B85F85B095; // 0x05D0(0x0070)
struct FAnimNode_Slot AnimGraphNode_Slot_6422098D46CACA858568388AC0611EE8; // 0x0640(0x0070)
struct FAnimNode_Slot AnimGraphNode_Slot_21AE88CC4FDD19B683373A9C8C500CA3; // 0x06B0(0x0070)
struct FAnimNode_BlendListByEnum AnimGraphNode_BlendListByEnum_AE289265453B18CD7EAACC99513F65A1;// 0x0720(0x00E0)
struct FAnimNode_UseCachedPose AnimGraphNode_UseCachedPose_9549960F46483C1EFF7E22AAFF4922CB;// 0x0800(0x0050)
struct FAnimNode_UseCachedPose AnimGraphNode_UseCachedPose_6816706448163841CB1F009AA84A99CC;// 0x0850(0x0050)
struct FAnimNode_UseCachedPose AnimGraphNode_UseCachedPose_FF7C045C4F38C122888DAC8385444F53;// 0x08A0(0x0050)
struct FAnimNode_BlendListByBool AnimGraphNode_BlendListByBool_6B95305F4AC89071766ECC8F395DB36B;// 0x08F0(0x00D0)
struct FAnimNode_BlendListByEnum AnimGraphNode_BlendListByEnum_4385E0354D48EE81EA3774970BD73608;// 0x09C0(0x00E0)
struct FAnimNode_Slot AnimGraphNode_Slot_305D5F6D49637286B61D34A10712281A; // 0x0AA0(0x0070)
struct FAnimNode_Slot AnimGraphNode_Slot_8D4375384E47A0829679EB9D447B6EBC; // 0x0B10(0x0070)
struct FAnimNode_Slot AnimGraphNode_Slot_DBDC0BE542597F8F5FAAD3B4AE097A4F; // 0x0B80(0x0070)
struct FAnimNode_UseCachedPose AnimGraphNode_UseCachedPose_A34D31C8476F46EEFC599990B265CF77;// 0x0BF0(0x0050)
struct FAnimNode_UseCachedPose AnimGraphNode_UseCachedPose_D0931CDA4750E7BB480F8DA51E70C0F2;// 0x0C40(0x0050)
struct FAnimNode_UseCachedPose AnimGraphNode_UseCachedPose_C716CD394DF1D93D8C62F0B1D42BFD8F;// 0x0C90(0x0050)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("AnimBlueprintGeneratedClass AnimBP_Hunter_86.AnimBP_Hunter_85_C");
return ptr;
}
void EvaluateGraphExposedInputs_ExecuteUbergraph_AnimBP_Hunter_85_AnimGraphNode_BlendListByEnum_4385E0354D48EE81EA3774970BD73608();
void EvaluateGraphExposedInputs_ExecuteUbergraph_AnimBP_Hunter_85_AnimGraphNode_BlendListByBool_6B95305F4AC89071766ECC8F395DB36B();
void EvaluateGraphExposedInputs_ExecuteUbergraph_AnimBP_Hunter_85_AnimGraphNode_BlendListByEnum_AE289265453B18CD7EAACC99513F65A1();
void ExecuteUbergraph_AnimBP_Hunter_86(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| [
"zp2kshield@gmail.com"
] | zp2kshield@gmail.com |
1ee76481047b86c14d9dd8a1fd18b22a5379a96c | c897e90a03799e50250a8304a4f8f74c63fa2b92 | /include/Color.h | e7c4a8062c8f351065c32fd5c507b1ae9463e1fe | [] | no_license | GHF/trayrace | 5e6d7e188ea95c8f41bf5808a9e4f6a70c0ff352 | d6cf02aef3c511c8b9816b5edc84ba803638f811 | refs/heads/master | 2016-09-10T10:09:31.562165 | 2012-12-14T16:35:43 | 2012-12-14T16:35:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,815 | h | /*
* Copyright (C) 2012 Xo Wang
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL XO
* WANG 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.
*
* Except as contained in this notice, the name of Xo Wang shall not be
* used in advertising or otherwise to promote the sale, use or other dealings
* in this Software without prior written authorization from Xo Wang.
*/
#ifndef COLOR_H_
#define COLOR_H_
#include "Trayrace.h"
#include "PixelToaster/PixelToaster.h"
#include <ostream>
namespace Trayrace {
class Color: public Vector4f {
public:
Color() {
}
Color(float r, float g, float b, float a = 1.f) {
*this << r, g, b, a;
}
Color(const Vector4f &v) :
Vector4f(v) {
}
// friend std::ostream &operator<<(std::ostream &os, const Color &c) {
// return os <<
// }
};
}
#endif /* COLOR_H_ */
| [
"xo@geekshavefeelings.com"
] | xo@geekshavefeelings.com |
e299a14e2ea320ff49641b683239934d23303490 | ac1c9fbc1f1019efb19d0a8f3a088e8889f1e83c | /out/release/gen/services/audio/public/mojom/system_info.mojom-shared.h | 8f70decb2b2a452d0394c046ddcee7c3f4a1064b | [
"BSD-3-Clause"
] | permissive | xueqiya/chromium_src | 5d20b4d3a2a0251c063a7fb9952195cda6d29e34 | d4aa7a8f0e07cfaa448fcad8c12b29242a615103 | refs/heads/main | 2022-07-30T03:15:14.818330 | 2021-01-16T16:47:22 | 2021-01-16T16:47:22 | 330,115,551 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,258 | h | // services/audio/public/mojom/system_info.mojom-shared.h is auto generated by mojom_bindings_generator.py, do not edit
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_AUDIO_PUBLIC_MOJOM_SYSTEM_INFO_MOJOM_SHARED_H_
#define SERVICES_AUDIO_PUBLIC_MOJOM_SYSTEM_INFO_MOJOM_SHARED_H_
#include <stdint.h>
#include <functional>
#include <ostream>
#include <type_traits>
#include <utility>
#include "base/compiler_specific.h"
#include "base/containers/flat_map.h"
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/enum_traits.h"
#include "mojo/public/cpp/bindings/interface_data_view.h"
#include "mojo/public/cpp/bindings/lib/bindings_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "services/audio/public/mojom/system_info.mojom-shared-internal.h"
#include "media/mojo/mojom/audio_parameters.mojom-shared.h"
#include "services/audio/public/mojom/audio_device_description.mojom-shared.h"
#include "mojo/public/cpp/bindings/lib/interface_serialization.h"
namespace audio {
namespace mojom {
} // namespace mojom
} // namespace audio
namespace mojo {
namespace internal {
} // namespace internal
} // namespace mojo
namespace audio {
namespace mojom {
// Interface base classes. They are used for type safety check.
class SystemInfoInterfaceBase {};
using SystemInfoPtrDataView =
mojo::InterfacePtrDataView<SystemInfoInterfaceBase>;
using SystemInfoRequestDataView =
mojo::InterfaceRequestDataView<SystemInfoInterfaceBase>;
using SystemInfoAssociatedPtrInfoDataView =
mojo::AssociatedInterfacePtrInfoDataView<SystemInfoInterfaceBase>;
using SystemInfoAssociatedRequestDataView =
mojo::AssociatedInterfaceRequestDataView<SystemInfoInterfaceBase>;
} // namespace mojom
} // namespace audio
namespace std {
} // namespace std
namespace mojo {
} // namespace mojo
namespace audio {
namespace mojom {
} // namespace mojom
} // namespace audio
#endif // SERVICES_AUDIO_PUBLIC_MOJOM_SYSTEM_INFO_MOJOM_SHARED_H_ | [
"xueqi@zjmedia.net"
] | xueqi@zjmedia.net |
a5f63f9af817eb7db25947d23a0b9257bc3f1ae1 | 5380c586f6129eebdc2c23c47377e1637a18ac7f | /velox/type/tests/FilterBuilder.h | f07c6e6ffa64cb3ea4179249b95b2881b6752c77 | [
"Apache-2.0"
] | permissive | amaliujia/velox | 1bd9ecd83d1c42935ed463dd6de9c8fc0b0d6357 | 648f88dae970858c870acbbb68dbc4c35207042d | refs/heads/main | 2023-08-11T02:40:28.410788 | 2021-10-01T18:16:15 | 2021-10-01T18:16:15 | 409,347,480 | 0 | 0 | Apache-2.0 | 2021-09-22T20:31:04 | 2021-09-22T20:31:04 | null | UTF-8 | C++ | false | false | 7,705 | h | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "velox/type/Filter.h"
namespace facebook::velox::common::test {
inline std::unique_ptr<common::BigintRange> lessThan(
int64_t max,
bool nullAllowed = false) {
return std::make_unique<common::BigintRange>(
std::numeric_limits<int64_t>::min(), max - 1, nullAllowed);
}
inline std::unique_ptr<common::BigintRange> lessThanOrEqual(
int64_t max,
bool nullAllowed = false) {
return std::make_unique<common::BigintRange>(
std::numeric_limits<int64_t>::min(), max, nullAllowed);
}
inline std::unique_ptr<common::BigintRange> greaterThan(
int64_t min,
bool nullAllowed = false) {
return std::make_unique<common::BigintRange>(
min + 1, std::numeric_limits<int64_t>::max(), nullAllowed);
}
inline std::unique_ptr<common::BigintRange> greaterThanOrEqual(
int64_t min,
bool nullAllowed = false) {
return std::make_unique<common::BigintRange>(
min, std::numeric_limits<int64_t>::max(), nullAllowed);
}
inline std::unique_ptr<common::DoubleRange> lessThanDouble(
double max,
bool nullAllowed = false) {
return std::make_unique<common::DoubleRange>(
std::numeric_limits<double>::lowest(),
true,
true,
max,
false,
true,
nullAllowed);
}
inline std::unique_ptr<common::DoubleRange> lessThanOrEqualDouble(
double max,
bool nullAllowed = false) {
return std::make_unique<common::DoubleRange>(
std::numeric_limits<double>::lowest(),
true,
true,
max,
false,
false,
nullAllowed);
}
inline std::unique_ptr<common::DoubleRange> greaterThanDouble(
double min,
bool nullAllowed = false) {
return std::make_unique<common::DoubleRange>(
min,
false,
true,
std::numeric_limits<double>::max(),
true,
true,
nullAllowed);
}
inline std::unique_ptr<common::DoubleRange> greaterThanOrEqualDouble(
double min,
bool nullAllowed = false) {
return std::make_unique<common::DoubleRange>(
min,
false,
false,
std::numeric_limits<double>::max(),
true,
true,
nullAllowed);
}
inline std::unique_ptr<common::DoubleRange>
betweenDouble(double min, double max, bool nullAllowed = false) {
return std::make_unique<common::DoubleRange>(
min, false, false, max, false, false, nullAllowed);
}
inline std::unique_ptr<common::FloatRange> lessThanFloat(
float max,
bool nullAllowed = false) {
return std::make_unique<common::FloatRange>(
std::numeric_limits<float>::lowest(),
true,
true,
max,
false,
true,
nullAllowed);
}
inline std::unique_ptr<common::FloatRange> lessThanOrEqualFloat(
float max,
bool nullAllowed = false) {
return std::make_unique<common::FloatRange>(
std::numeric_limits<float>::lowest(),
true,
true,
max,
false,
false,
nullAllowed);
}
inline std::unique_ptr<common::FloatRange> greaterThanFloat(
float min,
bool nullAllowed = false) {
return std::make_unique<common::FloatRange>(
min,
false,
true,
std::numeric_limits<float>::max(),
true,
true,
nullAllowed);
}
inline std::unique_ptr<common::FloatRange> greaterThanOrEqualFloat(
float min,
bool nullAllowed = false) {
return std::make_unique<common::FloatRange>(
min,
false,
false,
std::numeric_limits<float>::max(),
true,
true,
nullAllowed);
}
inline std::unique_ptr<common::FloatRange>
betweenFloat(float min, float max, bool nullAllowed = false) {
return std::make_unique<common::FloatRange>(
min, false, false, max, false, false, nullAllowed);
}
inline std::unique_ptr<common::BigintRange>
between(int64_t min, int64_t max, bool nullAllowed = false) {
return std::make_unique<common::BigintRange>(min, max, nullAllowed);
}
inline std::unique_ptr<common::BigintMultiRange> bigintOr(
std::unique_ptr<common::BigintRange> a,
std::unique_ptr<common::BigintRange> b,
bool nullAllowed = false) {
std::vector<std::unique_ptr<common::BigintRange>> filters;
filters.emplace_back(std::move(a));
filters.emplace_back(std::move(b));
return std::make_unique<common::BigintMultiRange>(
std::move(filters), nullAllowed);
}
inline std::unique_ptr<common::BigintMultiRange> bigintOr(
std::unique_ptr<common::BigintRange> a,
std::unique_ptr<common::BigintRange> b,
std::unique_ptr<common::BigintRange> c,
bool nullAllowed = false) {
std::vector<std::unique_ptr<common::BigintRange>> filters;
filters.emplace_back(std::move(a));
filters.emplace_back(std::move(b));
filters.emplace_back(std::move(c));
return std::make_unique<common::BigintMultiRange>(
std::move(filters), nullAllowed);
}
inline std::unique_ptr<common::BytesValues> equal(
const std::string& value,
bool nullAllowed = false) {
return std::make_unique<common::BytesValues>(
std::vector<std::string>{value}, nullAllowed);
}
inline std::unique_ptr<common::BigintRange> equal(
int64_t value,
bool nullAllowed = false) {
return std::make_unique<common::BigintRange>(value, value, nullAllowed);
}
inline std::unique_ptr<common::BytesRange> between(
const std::string& min,
const std::string& max,
bool nullAllowed = false) {
return std::make_unique<common::BytesRange>(
min, false, false, max, false, false, nullAllowed);
}
inline std::unique_ptr<common::BytesRange> lessThanOrEqual(
const std::string& max,
bool nullAllowed = false) {
return std::make_unique<common::BytesRange>(
"", true, true, max, false, false, nullAllowed);
}
inline std::unique_ptr<common::BytesRange> greaterThanOrEqual(
const std::string& min,
bool nullAllowed = false) {
return std::make_unique<common::BytesRange>(
min, false, false, "", true, true, nullAllowed);
}
inline std::unique_ptr<common::Filter> in(
const std::vector<int64_t>& values,
bool nullAllowed = false) {
return common::createBigintValues(values, nullAllowed);
}
inline std::unique_ptr<common::BytesValues> in(
const std::vector<std::string>& values,
bool nullAllowed = false) {
return std::make_unique<common::BytesValues>(values, nullAllowed);
}
inline std::unique_ptr<common::BoolValue> boolEqual(
bool value,
bool nullAllowed = false) {
return std::make_unique<common::BoolValue>(value, nullAllowed);
}
inline std::unique_ptr<common::IsNull> isNull() {
return std::make_unique<common::IsNull>();
}
inline std::unique_ptr<common::IsNotNull> isNotNull() {
return std::make_unique<common::IsNotNull>();
}
template <typename T>
std::unique_ptr<common::MultiRange> orFilter(
std::unique_ptr<T> a,
std::unique_ptr<T> b,
bool nullAllowed = false,
bool nanAllowed = false) {
std::vector<std::unique_ptr<common::Filter>> filters;
filters.emplace_back(std::move(a));
filters.emplace_back(std::move(b));
return std::make_unique<common::MultiRange>(
std::move(filters), nullAllowed, nanAllowed);
}
} // namespace facebook::velox::common::test
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
b134c2e4af39cab20b002db5b202d2ea917a46c4 | 22aee427f75c8411a6910567f0421f722619db27 | /Math/source/Math/cdm_radian.cpp | 70ed7dd63c8e8f3a53cdf482a6122f3e0b0d748f | [] | no_license | XxGTSCxX/Chilldew | 7ffc747d50ecfa1b5f3171e9b582de91c12c4c0d | 3de3ba2f75170729242b8d62c4e47b94ad98870f | refs/heads/master | 2023-01-07T02:29:24.162286 | 2020-10-23T14:58:20 | 2020-10-23T14:58:20 | 254,054,388 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,296 | cpp | /******************************************************************************/
/*!
\project Chilldew-Math
\file cdm_radian.cpp
\author Gabrielle Tan Suan Choo
\brief
Angles in radians.
all content (C) 2020 DigiPen (SINGAPORE) Corporation, all rights reserved.
Reproduction or disclosure of this file or its contents without the prior
written consent of DigiPen Institute of Technology is prohibited.
*/
/******************************************************************************/
#include "cdm_radian.h"
#include "cdm_degree.h"
namespace chilldew::math
{
radian::radian(degree deg_angle) noexcept
: _angle{ deg_angle._angle * math::deg_to_rad }
{}
radian& radian::operator+=(radian angle) noexcept
{
_angle += angle._angle;
return *this;
}
radian& radian::operator-=(radian angle) noexcept
{
_angle -= angle._angle;
return *this;
}
radian& radian::operator*=(real scale) noexcept
{
_angle *= scale;
return *this;
}
radian& radian::operator/=(real scale) noexcept
{
_angle /= scale;
return *this;
}
radian operator+(radian lhs, radian rhs)
{
return radian{ lhs } += rhs;
}
radian operator-(radian lhs, radian rhs)
{
return radian{ lhs } -= rhs;
}
radian operator*(radian angle, real scale)
{
return radian{ angle } *= scale;
}
radian operator*(real scale, radian angle)
{
return radian{ angle } *= scale;
}
radian operator/(radian angle, real scale)
{
return radian{ angle } /= scale;
}
radian operator-(radian angle)
{
return radian{ -angle._angle };
}
bool operator==(radian lhs, radian rhs)
{
return lhs._angle == rhs._angle;
}
bool operator<(radian lhs, radian rhs)
{
return lhs._angle < rhs._angle;
}
bool operator>(radian lhs, radian rhs)
{
return lhs._angle > rhs._angle;
}
bool operator!=(radian lhs, radian rhs)
{
return !(lhs == rhs);
}
bool operator<=(radian lhs, radian rhs)
{
return !(lhs > rhs);
}
bool operator>=(radian lhs, radian rhs)
{
return !(lhs < rhs);
}
}
| [
"g.tan@digipen.edu"
] | g.tan@digipen.edu |
6cbbeffbb498cb7ffd5a6b85a227e317959fc99b | 965b150758d50addcff149bfae7f37db48d62453 | /src/net/socket.cpp | a8c6415e5a91fa16d72d0926c3aac24e907e72ea | [] | no_license | C3-502/luna | 4711f4cda11a112b66fac5dcf414055731d87288 | 5d13683f038b1061054393a6e2289cee2963cb4e | refs/heads/master | 2020-12-30T18:03:13.365240 | 2017-06-10T19:55:39 | 2017-06-10T19:55:39 | 90,948,593 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,113 | cpp | #include "socket.h"
#include "../util/common_inc.h"
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
namespace luna {
namespace socket {
int tcp_socket()
{
return socket(AF_INET, SOCK_STREAM, 0);
}
int bind(int fd, const IPv4Addr &addr)
{
struct sockaddr_in sock_addr = addr.transformToSocketAddr();
return ::bind(fd, (sockaddr*) &sock_addr, sizeof(sock_addr));
}
int listen(int fd, int backlog)
{
return ::listen(fd, backlog);
}
int recv(int fd, char *buf, uint32_t count)
{
return ::read(fd, buf, count);
}
int send(int fd, const char *msg, uint32_t count)
{
return ::write(fd, msg, count);
}
int set_nonblock(int fd)
{
int flags = fcntl(fd, F_GETFL, 0);
int ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
if (ret < 0)
{
ERROR_LOG("fcntl");
return LUNA_RUNTIME_ERROR;
}
return LUNA_RUNTIME_OK;
}
int set_reuse_addr(int fd)
{
int optval = 1;
return ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
&optval, static_cast<socklen_t>(sizeof optval));
}
}
}
| [
"895605504@qq.com"
] | 895605504@qq.com |
55991a794666dae6b4966fe2a8e7f7bda0446cec | 2c93c789e2c7d4ad9e5104b98b0fb80ad69a2307 | /tools/Revitalize/seance/test/imports/funcs/sub_45F510.cpp | 56b5ea843548de73c272fd4e09c823c6b538db19 | [] | no_license | jkoppel/project-ironfist | 4faeaf8616084abe76696f4085776f26ff6ce212 | 0f8651d4305a4f982af8e43269dd6a8d7f86464d | refs/heads/master | 2023-05-26T09:14:29.594446 | 2023-05-11T07:11:28 | 2023-05-11T07:11:28 | 24,222,392 | 35 | 19 | null | 2023-05-11T04:52:17 | 2014-09-19T08:34:00 | Assembly | UTF-8 | C++ | false | false | 484 | cpp | {
if ( connectionSocket != -1 )
closesocket(connectionSocket);
if ( dword_4ED2E8 )
KBFree(dword_4ED2E8, (int)"F:\\h2xsrc\\Source\\Wsnetwin.cpp", word_511BEC + 7);
dword_4ED2E8 = 0;
if ( dword_4ED2EC )
KBFree(dword_4ED2EC, (int)"F:\\h2xsrc\\Source\\Wsnetwin.cpp", word_511BEC + 11);
dword_4ED2EC = 0;
WSACleanup();
dword_511780 = 0;
connectionSocket = -1;
dword_511788 = 1;
dword_51178C = 0;
dword_511790 = 0;
dword_511794 = 0;
_cfltcvt_init();
}
| [
"kertwaii@gmail.com"
] | kertwaii@gmail.com |
7a12e755db6bd08e0ed5ff5eabc528c84540c4e4 | ad244dfe15d721c1b5f5fd6ff5d49a6affdbaa51 | /Source/TimeSink/TrackableGameplayAbility.h | 9b140acf71070a5aff11a7e6a0b36b26d1ec23fc | [] | no_license | Zazow/TimSink | e72af484534ebd028257c124293d3a7183f348b4 | 394a6afa9c3a2e677fc5f3ec61cbd4c0a4d643ed | refs/heads/master | 2022-10-04T03:21:08.192534 | 2020-06-04T02:36:22 | 2020-06-04T02:36:22 | 267,163,108 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,001 | h | // Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Abilities/GameplayAbility.h"
#include "TrackableGameplayAbility.generated.h"
// custom delegate that gets called when this ability ended execution
DECLARE_DYNAMIC_MULTICAST_SPARSE_DELEGATE_OneParam(FAbilityEndedSignature, UTrackableGameplayAbility, OnAbilityEnded, bool, Cancelled);
/**
*
*/
UCLASS()
class TIMESINK_API UTrackableGameplayAbility : public UGameplayAbility
{
GENERATED_BODY()
/** Native function, called if an ability ends normally or abnormally. If bReplicate is set to true, try to replicate the ending to the client/server */
virtual void EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility, bool bWasCancelled) override;
public:
UPROPERTY(BlueprintAssignable)
FAbilityEndedSignature OnAbilityEnded;
};
| [
"ZiyadKAG@gmail.com"
] | ZiyadKAG@gmail.com |
749b85cb162ee0c27f572a70c9d5641cb219804d | a4870cf80e48ced67e63aead9c5ca904ce86a43e | /HDU/2579/2579.cpp | 91849be414f426b9a875b3caccf889afd07b4c29 | [] | no_license | axyst/competitive-programming | 2d2072a906b0ef4bbf1cab4523293412db002b25 | f3c05ebc9b09cba0af30b977222ae2b246ecc041 | refs/heads/master | 2023-07-24T12:45:15.977496 | 2021-08-20T02:27:46 | 2021-08-20T02:27:46 | 123,937,122 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,494 | cpp | #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#define X next.x
#define Y next.y
#define T next.time
using namespace std;
int t,r,c,k;
int vis[125][125][125];
char maze[125][125];
struct node
{
int x,y,time;
};
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
node in,out;
int yes(int a,int b,int c)
{
if(maze[a][b]=='#'&&c%k!=0) return 0;
else return 1;
}
int bfs()
{
queue<node>q;
in.time=0;
vis[in.x][in.y][0]=1;
q.push(in);
while(!q.empty())
{
node u=q.front();
q.pop();
for(int i=0;i<4;i++)
{
node next;
X=u.x+dir[i][0];
Y=u.y+dir[i][1];
T=u.time+1;
//printf("%d %d\n",X,Y);
if(X<0||X>=r||Y<0||Y>=c||!yes(X,Y,T)||vis[X][Y][T%k]) continue;
if(X==out.x&&Y==out.y) return T;
q.push(next);
vis[X][Y][T%k]=1;
}
}
return -1;
}
int main()
{
scanf("%d",&t);
while(t--)
{
memset(vis,0,sizeof(vis));
scanf("%d%d%d",&r,&c,&k);
for(int i=0;i<r;i++) scanf("%s",&maze[i]);
for(int i=0;i<r;i++)
for(int j=0;j<c;j++)
{
if(maze[i][j]=='Y') in.x=i,in.y=j;
if(maze[i][j]=='G') out.x=i,out.y=j;
}
//printf("%d %d \n%d %d\n",in.x,in.y,out.x,out.y);
int ans=bfs();
if(ans!=-1) printf("%d\n",ans);
else printf("Please give me another chance!\n");
}
return 0;
} | [
"axysta@gmail.com"
] | axysta@gmail.com |
62186e275eeeb19a623e7c4b07c026e5f048634f | da11e788e890a449ce799bea3a98b7b450df7f55 | /src/mbgl/style/layers/background_layer_impl.cpp | 4a8fe39c9a186fa19075285d3c277faad48df9b4 | [
"LicenseRef-scancode-warranty-disclaimer",
"IJG",
"Zlib",
"NCSA",
"LicenseRef-scancode-unknown-license-reference",
"blessing",
"BSD-3-Clause",
"ISC",
"Libpng",
"BSL-1.0",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"JSON",
"curl",
... | permissive | TanJay/mapbox-gl-native | b9125cc5931a4950dfc54434119e948abe5ba709 | 6348fe9f4acccce65d1396aa9eab79e6c44bcfc2 | refs/heads/master | 2021-01-19T20:17:30.045126 | 2017-01-31T10:24:52 | 2017-01-31T10:24:52 | 80,513,442 | 0 | 0 | NOASSERTION | 2020-05-26T19:49:27 | 2017-01-31T11:10:41 | C++ | UTF-8 | C++ | false | false | 676 | cpp | #include <mbgl/style/layers/background_layer_impl.hpp>
#include <mbgl/renderer/bucket.hpp>
namespace mbgl {
namespace style {
void BackgroundLayer::Impl::cascade(const CascadeParameters& parameters) {
paint.cascade(parameters);
}
bool BackgroundLayer::Impl::evaluate(const PropertyEvaluationParameters& parameters) {
paint.evaluate(parameters);
passes = paint.evaluated.get<BackgroundOpacity>() > 0 ? RenderPass::Translucent : RenderPass::None;
return paint.hasTransition();
}
std::unique_ptr<Bucket> BackgroundLayer::Impl::createBucket(BucketParameters&, const GeometryTileLayer&) const {
return nullptr;
}
} // namespace style
} // namespace mbgl
| [
"john.firebaugh@gmail.com"
] | john.firebaugh@gmail.com |
4b0a0373e7f2712c511f869a260768d4de5c667c | 6d2b6527f0ee6c5c9560897a44276a43b98662ed | /src/resources/Image.cpp | 9aac2f16ce9fc4386f61883d719a5168d5c1d7cb | [] | no_license | Murloc992/TheEngine | f668f68d2321c0c1976c2c859d032a764ee44282 | d70d25c59138fbb85c74ea2f4aba9ab725956d90 | refs/heads/master | 2023-03-16T08:23:49.976323 | 2023-03-14T11:45:29 | 2023-03-14T12:07:53 | 218,316,094 | 0 | 0 | null | 2019-11-01T16:41:39 | 2019-10-29T15:10:19 | C | UTF-8 | C++ | false | false | 41 | cpp | //#include "Precomp.h"
#include "Image.h" | [
"murloc992@gmail.com"
] | murloc992@gmail.com |
af62e5e7f073b69f3a3928344514fc834eefbc8a | ba4db75b9d1f08c6334bf7b621783759cd3209c7 | /src_main/common/xsi/5.1/xsi_port.h | ac90cf88e28d514c7fb70b4145851ba82a12f5ec | [] | no_license | equalent/source-2007 | a27326c6eb1e63899e3b77da57f23b79637060c0 | d07be8d02519ff5c902e1eb6430e028e1b302c8b | refs/heads/master | 2020-03-28T22:46:44.606988 | 2017-03-27T18:05:57 | 2017-03-27T18:05:57 | 149,257,460 | 2 | 0 | null | 2018-09-18T08:52:10 | 2018-09-18T08:52:09 | null | WINDOWS-1252 | C++ | false | false | 5,240 | h | //*****************************************************************************
/*!
\file xsi_port.h
\brief Port class declaration.
© Copyright 1998-2002 Avid Technology, Inc. and its licensors. All rights
reserved. This file contains confidential and proprietary information of
Avid Technology, Inc., and is subject to the terms of the SOFTIMAGE|XSI
end user license agreement (or EULA).
*/
//*****************************************************************************
#if (_MSC_VER > 1000) || defined(SGI_COMPILER)
#pragma once
#endif
#ifndef __XSIPORT_H__
#define __XSIPORT_H__
#include <xsi_siobject.h>
namespace XSI {
class ProjectItem;
//*****************************************************************************
/*! \class Port xsi_port.h
\brief A port is an input or output connection to another object.
Actually, a port is more like a connection point on an operator, which may or may not be actually
connected to something (some operator ports are optional).
Use SIObject::GetName to get the name of this port.
\sa Operator, OperatorContext, UpdateContext, SIObject, InputPort, OutputPort
*/
//*****************************************************************************
class SICPPSDKDECL Port : public SIObject
{
public:
/*! Default constructor. */
Port();
/*! Default destructor. */
~Port();
/*! Constructor.
\param in_ref constant reference object.
*/
Port(const CRef& in_ref);
/*! Copy constructor.
\param in_obj constant class object.
*/
Port(const Port& in_obj);
/*! Returns true if a given class type is compatible with this API class.
\param in_ClassID class type.
\return true if the class is compatible, false otherwise.
*/
bool IsA( siClassID in_ClassID) const;
/*! Returns the type of the API class.
\return The class type.
*/
siClassID GetClassID() const;
/*! Creates an object from another object. The newly created object is set to
empty if the input object is not compatible.
\param in_obj constant class object.
\return The new Port object.
*/
Port& operator=(const Port& in_obj);
/*! Creates an object from a reference object. The newly created object is
set to empty if the input reference object is not compatible.
\param in_ref constant class object.
\return The new Port object.
*/
Port& operator=(const CRef& in_ref);
/*! Returns true if the port is connected, false otherwise
\return true if connected; false otherwise.
*/
bool IsConnected() const;
/*! Returns the port index of this port as a <link idref="Long"/> within its port group or -1 if
there is a failure.
\note This index refers to the index of the port within the port group and is different from
the index used to access the CRefArrays of InputPort or OutputPort references (available
through Operator::GetInputPorts and Operator::GetOutputPorts).
\note This index is rarely a concern when implementing Self-Installed Custom Operators, because
OperatorContext::GetInputValue is based on the CRefArray index for the InputPort and normally
there is only a single output port (see OperatorContext::GetOutputPort).
\note When the Port is an output port, returned from a call to CustomProperty::AddOutputPort, this
index may change if any input ports are added afterwards.
\return LONG > 0 success
\return -1 failure
*/
LONG GetIndex() const;
/*! Returns the type of the port, input or output.
\return The Port type.
*/
siPortType GetPortType() const;
/*! Returns a reference object for the object connected to the port.
If this function is called from the Update() context of a custom operator
it will return an empty CRef.
\retval out_pTarget the object to which the port is connected.
\return A reference to the object connected to the port.
\sa \xl Port_Target2
*/
CRef GetTarget(void) const;
/*! Returns the index of the port group to which the port belongs.
\return LONG > 0 success
\return -1 means failure
*/
LONG GetGroupIndex(void) const;
/*! Returns the name of the port group to which the port belongs.
\return The name of the port group (empty string means failure)
*/
CString GetGroupName(void) const;
/*! Returns the port group instance index for the port. There may be many
objects of the same type connected to the same port group. Each object is
connected to a port group instance, and within the port group instance there
may be many ports.
\return LONG > 0 success
\return -1 means failure
*/
LONG GetGroupInstance(void) const;
/*! Returns the mask of port flags described in ::siPortFlags.
\return The mask containing port flags
\since 4.0
*/
siPortFlags GetFlags(void) const;
/*! Returns true if the port supports branch and group connections.
\return true if the port supports branch and group connections.
\since 4.0
*/
bool GetBranchGroup() const;
/*! Returns a string containing the path to the target object.
\return The path to the target object.
\since 4.0
*/
CString GetTargetPath() const;
private:
Port * operator&() const;
Port * operator&();
};
};
#endif // __XSIPORT_H__
| [
"sean@csnxs.uk"
] | sean@csnxs.uk |
e86875f7a17ac1f1255aa0dfdb35d57adfa620cc | 1f63dde39fcc5f8be29f2acb947c41f1b6f1683e | /Boss2D/addon/webrtc-jumpingyang001_for_boss/modules/rtp_rtcp/source/rtcp_packet/app_unittest.cc | 5121bcf1b7d661cd999b0a5315da1d00b7ab7f5a | [
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-google-patent-license-webm",
"LicenseRef-scancode-google-patent-license-webrtc",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | koobonil/Boss2D | 09ca948823e0df5a5a53b64a10033c4f3665483a | e5eb355b57228a701495f2660f137bd05628c202 | refs/heads/master | 2022-10-20T09:02:51.341143 | 2019-07-18T02:13:44 | 2019-07-18T02:13:44 | 105,999,368 | 7 | 2 | MIT | 2022-10-04T23:31:12 | 2017-10-06T11:57:07 | C++ | UTF-8 | C++ | false | false | 3,454 | cc | /*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include BOSS_WEBRTC_U_modules__rtp_rtcp__source__rtcp_packet__app_h //original-code:"modules/rtp_rtcp/source/rtcp_packet/app.h"
#include "test/gmock.h"
#include "test/gtest.h"
#include "test/rtcp_packet_parser.h"
namespace webrtc {
namespace {
using ::testing::ElementsAreArray;
using ::testing::make_tuple;
using ::webrtc::rtcp::App;
constexpr uint32_t kName = ((uint32_t)'n' << 24) | ((uint32_t)'a' << 16) |
((uint32_t)'m' << 8) | (uint32_t)'e';
constexpr uint8_t kSubtype = 0x1e;
constexpr uint32_t kSenderSsrc = 0x12345678;
constexpr uint8_t kData[] = {'t', 'e', 's', 't', 'd', 'a', 't', 'a'};
constexpr uint8_t kVersionBits = 2 << 6;
constexpr uint8_t kPaddingBit = 1 << 5;
// clang-format off
constexpr uint8_t kPacketWithoutData[] = {
kVersionBits | kSubtype, App::kPacketType, 0x00, 0x02,
0x12, 0x34, 0x56, 0x78,
'n', 'a', 'm', 'e'};
constexpr uint8_t kPacketWithData[] = {
kVersionBits | kSubtype, App::kPacketType, 0x00, 0x04,
0x12, 0x34, 0x56, 0x78,
'n', 'a', 'm', 'e',
't', 'e', 's', 't',
'd', 'a', 't', 'a'};
constexpr uint8_t kTooSmallPacket[] = {
kVersionBits | kSubtype, App::kPacketType, 0x00, 0x01,
0x12, 0x34, 0x56, 0x78};
constexpr uint8_t kPaddingSize = 1;
constexpr uint8_t kPacketWithUnalignedPayload[] = {
kVersionBits | kPaddingBit | kSubtype, App::kPacketType, 0x00, 0x03,
0x12, 0x34, 0x56, 0x78,
'n', 'a', 'm', 'e',
'd', 'a', 't', kPaddingSize};
// clang-format on
} // namespace
TEST(RtcpPacketAppTest, CreateWithoutData) {
App app;
app.SetSsrc(kSenderSsrc);
app.SetSubType(kSubtype);
app.SetName(kName);
rtc::Buffer raw = app.Build();
EXPECT_THAT(make_tuple(raw.data(), raw.size()),
ElementsAreArray(kPacketWithoutData));
}
TEST(RtcpPacketAppTest, ParseWithoutData) {
App parsed;
EXPECT_TRUE(test::ParseSinglePacket(kPacketWithoutData, &parsed));
EXPECT_EQ(kSenderSsrc, parsed.ssrc());
EXPECT_EQ(kSubtype, parsed.sub_type());
EXPECT_EQ(kName, parsed.name());
EXPECT_EQ(0u, parsed.data_size());
}
TEST(RtcpPacketAppTest, CreateWithData) {
App app;
app.SetSsrc(kSenderSsrc);
app.SetSubType(kSubtype);
app.SetName(kName);
app.SetData(kData, sizeof(kData));
rtc::Buffer raw = app.Build();
EXPECT_THAT(make_tuple(raw.data(), raw.size()),
ElementsAreArray(kPacketWithData));
}
TEST(RtcpPacketAppTest, ParseWithData) {
App parsed;
EXPECT_TRUE(test::ParseSinglePacket(kPacketWithData, &parsed));
EXPECT_EQ(kSenderSsrc, parsed.ssrc());
EXPECT_EQ(kSubtype, parsed.sub_type());
EXPECT_EQ(kName, parsed.name());
EXPECT_THAT(make_tuple(parsed.data(), parsed.data_size()),
ElementsAreArray(kData));
}
TEST(RtcpPacketAppTest, ParseFailsOnTooSmallPacket) {
App parsed;
EXPECT_FALSE(test::ParseSinglePacket(kTooSmallPacket, &parsed));
}
TEST(RtcpPacketAppTest, ParseFailsOnUnalignedPayload) {
App parsed;
EXPECT_FALSE(test::ParseSinglePacket(kPacketWithUnalignedPayload, &parsed));
}
} // namespace webrtc
| [
"slacealic@nate.com"
] | slacealic@nate.com |
c9bdb9883e37970cf7191ea19a40bd90347fcc7f | da1500e0d3040497614d5327d2461a22e934b4d8 | /third_party/boringssl/src/third_party/googletest/src/gtest.cc | 42f048445ee6112e46773c47489d0cf4a4bb30f2 | [
"BSD-3-Clause",
"ISC",
"OpenSSL",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"MIT",
"GPL-1.0-or-later",
"LGPL-2.0-or-later",
"Apache-2.0"
] | permissive | youtube/cobalt | 34085fc93972ebe05b988b15410e99845efd1968 | acefdaaadd3ef46f10f63d1acae2259e4024d383 | refs/heads/main | 2023-09-01T13:09:47.225174 | 2023-09-01T08:54:54 | 2023-09-01T08:54:54 | 50,049,789 | 169 | 80 | BSD-3-Clause | 2023-09-14T21:50:50 | 2016-01-20T18:11:34 | null | UTF-8 | C++ | false | false | 197,236 | cc | // Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
//
// The Google C++ Testing Framework (Google Test)
#include "gtest/gtest.h"
#include "gtest/internal/custom/gtest.h"
#include "gtest/gtest-spi.h"
#include <ctype.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <ostream> // NOLINT
#include <sstream>
#include <vector>
#if GTEST_OS_LINUX
// TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday().
# define GTEST_HAS_GETTIMEOFDAY_ 1
# include <fcntl.h> // NOLINT
# include <limits.h> // NOLINT
# include <sched.h> // NOLINT
// Declares vsnprintf(). This header is not available on Windows.
# include <strings.h> // NOLINT
# include <sys/mman.h> // NOLINT
# include <sys/time.h> // NOLINT
# include <unistd.h> // NOLINT
# include <string>
#elif GTEST_OS_SYMBIAN
# define GTEST_HAS_GETTIMEOFDAY_ 1
# include <sys/time.h> // NOLINT
#elif GTEST_OS_ZOS
# define GTEST_HAS_GETTIMEOFDAY_ 1
# include <sys/time.h> // NOLINT
// On z/OS we additionally need strings.h for strcasecmp.
# include <strings.h> // NOLINT
#elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE.
# include <windows.h> // NOLINT
# undef min
#elif GTEST_OS_WINDOWS // We are on Windows proper.
# include <io.h> // NOLINT
# include <sys/timeb.h> // NOLINT
# include <sys/types.h> // NOLINT
# include <sys/stat.h> // NOLINT
# if GTEST_OS_WINDOWS_MINGW
// MinGW has gettimeofday() but not _ftime64().
// TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday().
// TODO(kenton@google.com): There are other ways to get the time on
// Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW
// supports these. consider using them instead.
# define GTEST_HAS_GETTIMEOFDAY_ 1
# include <sys/time.h> // NOLINT
# endif // GTEST_OS_WINDOWS_MINGW
// cpplint thinks that the header is already included, so we want to
// silence it.
# include <windows.h> // NOLINT
# undef min
#else
// Assume other platforms have gettimeofday().
// TODO(kenton@google.com): Use autoconf to detect availability of
// gettimeofday().
# define GTEST_HAS_GETTIMEOFDAY_ 1
// cpplint thinks that the header is already included, so we want to
// silence it.
# include <sys/time.h> // NOLINT
# include <unistd.h> // NOLINT
#endif // GTEST_OS_LINUX
#if GTEST_HAS_EXCEPTIONS
# include <stdexcept>
#endif
#if GTEST_CAN_STREAM_RESULTS_
# include <arpa/inet.h> // NOLINT
# include <netdb.h> // NOLINT
# include <sys/socket.h> // NOLINT
# include <sys/types.h> // NOLINT
#endif
#include "src/gtest-internal-inl.h"
#if GTEST_OS_WINDOWS
# define vsnprintf _vsnprintf
#endif // GTEST_OS_WINDOWS
namespace testing {
using internal::CountIf;
using internal::ForEach;
using internal::GetElementOr;
using internal::Shuffle;
// Constants.
// A test whose test case name or test name matches this filter is
// disabled and not run.
static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*";
// A test case whose name matches this filter is considered a death
// test case and will be run before test cases whose name doesn't
// match this filter.
static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*";
// A test filter that matches everything.
static const char kUniversalFilter[] = "*";
// The default output file for XML output.
static const char kDefaultOutputFile[] = "test_detail.xml";
// The environment variable name for the test shard index.
static const char kTestShardIndex[] = "GTEST_SHARD_INDEX";
// The environment variable name for the total number of test shards.
static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS";
// The environment variable name for the test shard status file.
static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE";
namespace internal {
// The text used in failure messages to indicate the start of the
// stack trace.
const char kStackTraceMarker[] = "\nStack trace:\n";
// g_help_flag is true iff the --help flag or an equivalent form is
// specified on the command line.
bool g_help_flag = false;
} // namespace internal
static const char* GetDefaultFilter() {
#ifdef GTEST_TEST_FILTER_ENV_VAR_
const char* const testbridge_test_only = getenv(GTEST_TEST_FILTER_ENV_VAR_);
if (testbridge_test_only != NULL) {
return testbridge_test_only;
}
#endif // GTEST_TEST_FILTER_ENV_VAR_
return kUniversalFilter;
}
GTEST_DEFINE_bool_(
also_run_disabled_tests,
internal::BoolFromGTestEnv("also_run_disabled_tests", false),
"Run disabled tests too, in addition to the tests normally being run.");
GTEST_DEFINE_bool_(
break_on_failure,
internal::BoolFromGTestEnv("break_on_failure", false),
"True iff a failed assertion should be a debugger break-point.");
GTEST_DEFINE_bool_(
catch_exceptions,
internal::BoolFromGTestEnv("catch_exceptions", true),
"True iff " GTEST_NAME_
" should catch exceptions and treat them as test failures.");
GTEST_DEFINE_string_(
color,
internal::StringFromGTestEnv("color", "auto"),
"Whether to use colors in the output. Valid values: yes, no, "
"and auto. 'auto' means to use colors if the output is "
"being sent to a terminal and the TERM environment variable "
"is set to a terminal type that supports colors.");
GTEST_DEFINE_string_(
filter,
internal::StringFromGTestEnv("filter", GetDefaultFilter()),
"A colon-separated list of glob (not regex) patterns "
"for filtering the tests to run, optionally followed by a "
"'-' and a : separated list of negative patterns (tests to "
"exclude). A test is run if it matches one of the positive "
"patterns and does not match any of the negative patterns.");
GTEST_DEFINE_bool_(list_tests, false,
"List all tests without running them.");
GTEST_DEFINE_string_(
output,
internal::StringFromGTestEnv("output", ""),
"A format (currently must be \"xml\"), optionally followed "
"by a colon and an output file name or directory. A directory "
"is indicated by a trailing pathname separator. "
"Examples: \"xml:filename.xml\", \"xml::directoryname/\". "
"If a directory is specified, output files will be created "
"within that directory, with file-names based on the test "
"executable's name and, if necessary, made unique by adding "
"digits.");
GTEST_DEFINE_bool_(
print_time,
internal::BoolFromGTestEnv("print_time", true),
"True iff " GTEST_NAME_
" should display elapsed time in text output.");
GTEST_DEFINE_int32_(
random_seed,
internal::Int32FromGTestEnv("random_seed", 0),
"Random number seed to use when shuffling test orders. Must be in range "
"[1, 99999], or 0 to use a seed based on the current time.");
GTEST_DEFINE_int32_(
repeat,
internal::Int32FromGTestEnv("repeat", 1),
"How many times to repeat each test. Specify a negative number "
"for repeating forever. Useful for shaking out flaky tests.");
GTEST_DEFINE_bool_(
show_internal_stack_frames, false,
"True iff " GTEST_NAME_ " should include internal stack frames when "
"printing test failure stack traces.");
GTEST_DEFINE_bool_(
shuffle,
internal::BoolFromGTestEnv("shuffle", false),
"True iff " GTEST_NAME_
" should randomize tests' order on every run.");
GTEST_DEFINE_int32_(
stack_trace_depth,
internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth),
"The maximum number of stack frames to print when an "
"assertion fails. The valid range is 0 through 100, inclusive.");
GTEST_DEFINE_string_(
stream_result_to,
internal::StringFromGTestEnv("stream_result_to", ""),
"This flag specifies the host name and the port number on which to stream "
"test results. Example: \"localhost:555\". The flag is effective only on "
"Linux.");
GTEST_DEFINE_bool_(
throw_on_failure,
internal::BoolFromGTestEnv("throw_on_failure", false),
"When this flag is specified, a failed assertion will throw an exception "
"if exceptions are enabled or exit the program with a non-zero code "
"otherwise.");
#if GTEST_USE_OWN_FLAGFILE_FLAG_
GTEST_DEFINE_string_(
flagfile,
internal::StringFromGTestEnv("flagfile", ""),
"This flag specifies the flagfile to read command-line flags from.");
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
namespace internal {
// Generates a random number from [0, range), using a Linear
// Congruential Generator (LCG). Crashes if 'range' is 0 or greater
// than kMaxRange.
UInt32 Random::Generate(UInt32 range) {
// These constants are the same as are used in glibc's rand(3).
// Use wider types than necessary to prevent unsigned overflow diagnostics.
state_ = static_cast<UInt32>(1103515245ULL*state_ + 12345U) % kMaxRange;
GTEST_CHECK_(range > 0)
<< "Cannot generate a number in the range [0, 0).";
GTEST_CHECK_(range <= kMaxRange)
<< "Generation of a number in [0, " << range << ") was requested, "
<< "but this can only generate numbers in [0, " << kMaxRange << ").";
// Converting via modulus introduces a bit of downward bias, but
// it's simple, and a linear congruential generator isn't too good
// to begin with.
return state_ % range;
}
// GTestIsInitialized() returns true iff the user has initialized
// Google Test. Useful for catching the user mistake of not initializing
// Google Test before calling RUN_ALL_TESTS().
static bool GTestIsInitialized() { return GetArgvs().size() > 0; }
// Iterates over a vector of TestCases, keeping a running sum of the
// results of calling a given int-returning method on each.
// Returns the sum.
static int SumOverTestCaseList(const std::vector<TestCase*>& case_list,
int (TestCase::*method)() const) {
int sum = 0;
for (size_t i = 0; i < case_list.size(); i++) {
sum += (case_list[i]->*method)();
}
return sum;
}
// Returns true iff the test case passed.
static bool TestCasePassed(const TestCase* test_case) {
return test_case->should_run() && test_case->Passed();
}
// Returns true iff the test case failed.
static bool TestCaseFailed(const TestCase* test_case) {
return test_case->should_run() && test_case->Failed();
}
// Returns true iff test_case contains at least one test that should
// run.
static bool ShouldRunTestCase(const TestCase* test_case) {
return test_case->should_run();
}
// AssertHelper constructor.
AssertHelper::AssertHelper(TestPartResult::Type type,
const char* file,
int line,
const char* message)
: data_(new AssertHelperData(type, file, line, message)) {
}
AssertHelper::~AssertHelper() {
delete data_;
}
// Message assignment, for assertion streaming support.
void AssertHelper::operator=(const Message& message) const {
UnitTest::GetInstance()->
AddTestPartResult(data_->type, data_->file, data_->line,
AppendUserMessage(data_->message, message),
UnitTest::GetInstance()->impl()
->CurrentOsStackTraceExceptTop(1)
// Skips the stack frame for this function itself.
); // NOLINT
}
// Mutex for linked pointers.
GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);
// A copy of all command line arguments. Set by InitGoogleTest().
::std::vector<testing::internal::string> g_argvs;
const ::std::vector<testing::internal::string>& GetArgvs() {
#if defined(GTEST_CUSTOM_GET_ARGVS_)
return GTEST_CUSTOM_GET_ARGVS_();
#else // defined(GTEST_CUSTOM_GET_ARGVS_)
return g_argvs;
#endif // defined(GTEST_CUSTOM_GET_ARGVS_)
}
// Returns the current application's name, removing directory path if that
// is present.
FilePath GetCurrentExecutableName() {
FilePath result;
#if GTEST_OS_WINDOWS
result.Set(FilePath(GetArgvs()[0]).RemoveExtension("exe"));
#else
result.Set(FilePath(GetArgvs()[0]));
#endif // GTEST_OS_WINDOWS
return result.RemoveDirectoryName();
}
// Functions for processing the gtest_output flag.
// Returns the output format, or "" for normal printed output.
std::string UnitTestOptions::GetOutputFormat() {
const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
if (gtest_output_flag == NULL) return std::string("");
const char* const colon = strchr(gtest_output_flag, ':');
return (colon == NULL) ?
std::string(gtest_output_flag) :
std::string(gtest_output_flag, colon - gtest_output_flag);
}
// Returns the name of the requested output file, or the default if none
// was explicitly specified.
std::string UnitTestOptions::GetAbsolutePathToOutputFile() {
const char* const gtest_output_flag = GTEST_FLAG(output).c_str();
if (gtest_output_flag == NULL)
return "";
const char* const colon = strchr(gtest_output_flag, ':');
if (colon == NULL)
return internal::FilePath::ConcatPaths(
internal::FilePath(
UnitTest::GetInstance()->original_working_dir()),
internal::FilePath(kDefaultOutputFile)).string();
internal::FilePath output_name(colon + 1);
if (!output_name.IsAbsolutePath())
// TODO(wan@google.com): on Windows \some\path is not an absolute
// path (as its meaning depends on the current drive), yet the
// following logic for turning it into an absolute path is wrong.
// Fix it.
output_name = internal::FilePath::ConcatPaths(
internal::FilePath(UnitTest::GetInstance()->original_working_dir()),
internal::FilePath(colon + 1));
if (!output_name.IsDirectory())
return output_name.string();
internal::FilePath result(internal::FilePath::GenerateUniqueFileName(
output_name, internal::GetCurrentExecutableName(),
GetOutputFormat().c_str()));
return result.string();
}
// Returns true iff the wildcard pattern matches the string. The
// first ':' or '\0' character in pattern marks the end of it.
//
// This recursive algorithm isn't very efficient, but is clear and
// works well enough for matching test names, which are short.
bool UnitTestOptions::PatternMatchesString(const char *pattern,
const char *str) {
switch (*pattern) {
case '\0':
case ':': // Either ':' or '\0' marks the end of the pattern.
return *str == '\0';
case '?': // Matches any single character.
return *str != '\0' && PatternMatchesString(pattern + 1, str + 1);
case '*': // Matches any string (possibly empty) of characters.
return (*str != '\0' && PatternMatchesString(pattern, str + 1)) ||
PatternMatchesString(pattern + 1, str);
default: // Non-special character. Matches itself.
return *pattern == *str &&
PatternMatchesString(pattern + 1, str + 1);
}
}
bool UnitTestOptions::MatchesFilter(
const std::string& name, const char* filter) {
const char *cur_pattern = filter;
for (;;) {
if (PatternMatchesString(cur_pattern, name.c_str())) {
return true;
}
// Finds the next pattern in the filter.
cur_pattern = strchr(cur_pattern, ':');
// Returns if no more pattern can be found.
if (cur_pattern == NULL) {
return false;
}
// Skips the pattern separater (the ':' character).
cur_pattern++;
}
}
// Returns true iff the user-specified filter matches the test case
// name and the test name.
bool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name,
const std::string &test_name) {
const std::string& full_name = test_case_name + "." + test_name.c_str();
// Split --gtest_filter at '-', if there is one, to separate into
// positive filter and negative filter portions
const char* const p = GTEST_FLAG(filter).c_str();
const char* const dash = strchr(p, '-');
std::string positive;
std::string negative;
if (dash == NULL) {
positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter
negative = "";
} else {
positive = std::string(p, dash); // Everything up to the dash
negative = std::string(dash + 1); // Everything after the dash
if (positive.empty()) {
// Treat '-test1' as the same as '*-test1'
positive = kUniversalFilter;
}
}
// A filter is a colon-separated list of patterns. It matches a
// test if any pattern in it matches the test.
return (MatchesFilter(full_name, positive.c_str()) &&
!MatchesFilter(full_name, negative.c_str()));
}
#if GTEST_HAS_SEH
// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
// This function is useful as an __except condition.
int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
// Google Test should handle a SEH exception if:
// 1. the user wants it to, AND
// 2. this is not a breakpoint exception, AND
// 3. this is not a C++ exception (VC++ implements them via SEH,
// apparently).
//
// SEH exception code for C++ exceptions.
// (see http://support.microsoft.com/kb/185294 for more information).
const DWORD kCxxExceptionCode = 0xe06d7363;
bool should_handle = true;
if (!GTEST_FLAG(catch_exceptions))
should_handle = false;
else if (exception_code == EXCEPTION_BREAKPOINT)
should_handle = false;
else if (exception_code == kCxxExceptionCode)
should_handle = false;
return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
}
#endif // GTEST_HAS_SEH
} // namespace internal
// The c'tor sets this object as the test part result reporter used by
// Google Test. The 'result' parameter specifies where to report the
// results. Intercepts only failures from the current thread.
ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
TestPartResultArray* result)
: intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),
result_(result) {
Init();
}
// The c'tor sets this object as the test part result reporter used by
// Google Test. The 'result' parameter specifies where to report the
// results.
ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(
InterceptMode intercept_mode, TestPartResultArray* result)
: intercept_mode_(intercept_mode),
result_(result) {
Init();
}
void ScopedFakeTestPartResultReporter::Init() {
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
old_reporter_ = impl->GetGlobalTestPartResultReporter();
impl->SetGlobalTestPartResultReporter(this);
} else {
old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();
impl->SetTestPartResultReporterForCurrentThread(this);
}
}
// The d'tor restores the test part result reporter used by Google Test
// before.
ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
if (intercept_mode_ == INTERCEPT_ALL_THREADS) {
impl->SetGlobalTestPartResultReporter(old_reporter_);
} else {
impl->SetTestPartResultReporterForCurrentThread(old_reporter_);
}
}
// Increments the test part result count and remembers the result.
// This method is from the TestPartResultReporterInterface interface.
void ScopedFakeTestPartResultReporter::ReportTestPartResult(
const TestPartResult& result) {
result_->Append(result);
}
namespace internal {
// Returns the type ID of ::testing::Test. We should always call this
// instead of GetTypeId< ::testing::Test>() to get the type ID of
// testing::Test. This is to work around a suspected linker bug when
// using Google Test as a framework on Mac OS X. The bug causes
// GetTypeId< ::testing::Test>() to return different values depending
// on whether the call is from the Google Test framework itself or
// from user test code. GetTestTypeId() is guaranteed to always
// return the same value, as it always calls GetTypeId<>() from the
// gtest.cc, which is within the Google Test framework.
TypeId GetTestTypeId() {
return GetTypeId<Test>();
}
// The value of GetTestTypeId() as seen from within the Google Test
// library. This is solely for testing GetTestTypeId().
extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();
// This predicate-formatter checks that 'results' contains a test part
// failure of the given type and that the failure message contains the
// given substring.
static AssertionResult HasOneFailure(const char* /* results_expr */,
const char* /* type_expr */,
const char* /* substr_expr */,
const TestPartResultArray& results,
TestPartResult::Type type,
const std::string& substr) {
const std::string expected(type == TestPartResult::kFatalFailure ?
"1 fatal failure" :
"1 non-fatal failure");
Message msg;
if (results.size() != 1) {
msg << "Expected: " << expected << "\n"
<< " Actual: " << results.size() << " failures";
for (int i = 0; i < results.size(); i++) {
msg << "\n" << results.GetTestPartResult(i);
}
return AssertionFailure() << msg;
}
const TestPartResult& r = results.GetTestPartResult(0);
if (r.type() != type) {
return AssertionFailure() << "Expected: " << expected << "\n"
<< " Actual:\n"
<< r;
}
if (strstr(r.message(), substr.c_str()) == NULL) {
return AssertionFailure() << "Expected: " << expected << " containing \""
<< substr << "\"\n"
<< " Actual:\n"
<< r;
}
return AssertionSuccess();
}
// The constructor of SingleFailureChecker remembers where to look up
// test part results, what type of failure we expect, and what
// substring the failure message should contain.
SingleFailureChecker::SingleFailureChecker(const TestPartResultArray* results,
TestPartResult::Type type,
const std::string& substr)
: results_(results), type_(type), substr_(substr) {}
// The destructor of SingleFailureChecker verifies that the given
// TestPartResultArray contains exactly one failure that has the given
// type and contains the given substring. If that's not the case, a
// non-fatal failure will be generated.
SingleFailureChecker::~SingleFailureChecker() {
EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);
}
DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(
UnitTestImpl* unit_test) : unit_test_(unit_test) {}
void DefaultGlobalTestPartResultReporter::ReportTestPartResult(
const TestPartResult& result) {
unit_test_->current_test_result()->AddTestPartResult(result);
unit_test_->listeners()->repeater()->OnTestPartResult(result);
}
DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(
UnitTestImpl* unit_test) : unit_test_(unit_test) {}
void DefaultPerThreadTestPartResultReporter::ReportTestPartResult(
const TestPartResult& result) {
unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);
}
// Returns the global test part result reporter.
TestPartResultReporterInterface*
UnitTestImpl::GetGlobalTestPartResultReporter() {
internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
return global_test_part_result_repoter_;
}
// Sets the global test part result reporter.
void UnitTestImpl::SetGlobalTestPartResultReporter(
TestPartResultReporterInterface* reporter) {
internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
global_test_part_result_repoter_ = reporter;
}
// Returns the test part result reporter for the current thread.
TestPartResultReporterInterface*
UnitTestImpl::GetTestPartResultReporterForCurrentThread() {
return per_thread_test_part_result_reporter_.get();
}
// Sets the test part result reporter for the current thread.
void UnitTestImpl::SetTestPartResultReporterForCurrentThread(
TestPartResultReporterInterface* reporter) {
per_thread_test_part_result_reporter_.set(reporter);
}
// Gets the number of successful test cases.
int UnitTestImpl::successful_test_case_count() const {
return CountIf(test_cases_, TestCasePassed);
}
// Gets the number of failed test cases.
int UnitTestImpl::failed_test_case_count() const {
return CountIf(test_cases_, TestCaseFailed);
}
// Gets the number of all test cases.
int UnitTestImpl::total_test_case_count() const {
return static_cast<int>(test_cases_.size());
}
// Gets the number of all test cases that contain at least one test
// that should run.
int UnitTestImpl::test_case_to_run_count() const {
return CountIf(test_cases_, ShouldRunTestCase);
}
// Gets the number of successful tests.
int UnitTestImpl::successful_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);
}
// Gets the number of failed tests.
int UnitTestImpl::failed_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);
}
// Gets the number of disabled tests that will be reported in the XML report.
int UnitTestImpl::reportable_disabled_test_count() const {
return SumOverTestCaseList(test_cases_,
&TestCase::reportable_disabled_test_count);
}
// Gets the number of disabled tests.
int UnitTestImpl::disabled_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);
}
// Gets the number of tests to be printed in the XML report.
int UnitTestImpl::reportable_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count);
}
// Gets the number of all tests.
int UnitTestImpl::total_test_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);
}
// Gets the number of tests that should run.
int UnitTestImpl::test_to_run_count() const {
return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count);
}
// Returns the current OS stack trace as an std::string.
//
// The maximum number of stack frames to be included is specified by
// the gtest_stack_trace_depth flag. The skip_count parameter
// specifies the number of top frames to be skipped, which doesn't
// count against the number of frames to be included.
//
// For example, if Foo() calls Bar(), which in turn calls
// CurrentOsStackTraceExceptTop(1), Foo() will be included in the
// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
return os_stack_trace_getter()->CurrentStackTrace(
static_cast<int>(GTEST_FLAG(stack_trace_depth)),
skip_count + 1
// Skips the user-specified number of frames plus this function
// itself.
); // NOLINT
}
// Returns the current time in milliseconds.
TimeInMillis GetTimeInMillis() {
#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)
// Difference between 1970-01-01 and 1601-01-01 in milliseconds.
// http://analogous.blogspot.com/2005/04/epoch.html
const TimeInMillis kJavaEpochToWinFileTimeDelta =
static_cast<TimeInMillis>(116444736UL) * 100000UL;
const DWORD kTenthMicrosInMilliSecond = 10000;
SYSTEMTIME now_systime;
FILETIME now_filetime;
ULARGE_INTEGER now_int64;
// TODO(kenton@google.com): Shouldn't this just use
// GetSystemTimeAsFileTime()?
GetSystemTime(&now_systime);
if (SystemTimeToFileTime(&now_systime, &now_filetime)) {
now_int64.LowPart = now_filetime.dwLowDateTime;
now_int64.HighPart = now_filetime.dwHighDateTime;
now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -
kJavaEpochToWinFileTimeDelta;
return now_int64.QuadPart;
}
return 0;
#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_
__timeb64 now;
// MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996
// (deprecated function) there.
// TODO(kenton@google.com): Use GetTickCount()? Or use
// SystemTimeToFileTime()
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
_ftime64(&now);
GTEST_DISABLE_MSC_WARNINGS_POP_()
return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;
#elif GTEST_HAS_GETTIMEOFDAY_
struct timeval now;
gettimeofday(&now, NULL);
return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;
#else
# error "Don't know how to get the current time on your system."
#endif
}
// Utilities
// class String.
#if GTEST_OS_WINDOWS_MOBILE
// Creates a UTF-16 wide string from the given ANSI string, allocating
// memory using new. The caller is responsible for deleting the return
// value using delete[]. Returns the wide string, or NULL if the
// input is NULL.
LPCWSTR String::AnsiToUtf16(const char* ansi) {
if (!ansi) return NULL;
const int length = strlen(ansi);
const int unicode_length =
MultiByteToWideChar(CP_ACP, 0, ansi, length,
NULL, 0);
WCHAR* unicode = new WCHAR[unicode_length + 1];
MultiByteToWideChar(CP_ACP, 0, ansi, length,
unicode, unicode_length);
unicode[unicode_length] = 0;
return unicode;
}
// Creates an ANSI string from the given wide string, allocating
// memory using new. The caller is responsible for deleting the return
// value using delete[]. Returns the ANSI string, or NULL if the
// input is NULL.
const char* String::Utf16ToAnsi(LPCWSTR utf16_str) {
if (!utf16_str) return NULL;
const int ansi_length =
WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
NULL, 0, NULL, NULL);
char* ansi = new char[ansi_length + 1];
WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,
ansi, ansi_length, NULL, NULL);
ansi[ansi_length] = 0;
return ansi;
}
#endif // GTEST_OS_WINDOWS_MOBILE
// Compares two C strings. Returns true iff they have the same content.
//
// Unlike strcmp(), this function can handle NULL argument(s). A NULL
// C string is considered different to any non-NULL C string,
// including the empty string.
bool String::CStringEquals(const char * lhs, const char * rhs) {
if ( lhs == NULL ) return rhs == NULL;
if ( rhs == NULL ) return false;
return strcmp(lhs, rhs) == 0;
}
#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
// Converts an array of wide chars to a narrow string using the UTF-8
// encoding, and streams the result to the given Message object.
static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,
Message* msg) {
for (size_t i = 0; i != length; ) { // NOLINT
if (wstr[i] != L'\0') {
*msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));
while (i != length && wstr[i] != L'\0')
i++;
} else {
*msg << '\0';
i++;
}
}
}
#endif // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING
void SplitString(const ::std::string& str, char delimiter,
::std::vector< ::std::string>* dest) {
::std::vector< ::std::string> parsed;
::std::string::size_type pos = 0;
while (::testing::internal::AlwaysTrue()) {
const ::std::string::size_type colon = str.find(delimiter, pos);
if (colon == ::std::string::npos) {
parsed.push_back(str.substr(pos));
break;
} else {
parsed.push_back(str.substr(pos, colon - pos));
pos = colon + 1;
}
}
dest->swap(parsed);
}
} // namespace internal
// Constructs an empty Message.
// We allocate the stringstream separately because otherwise each use of
// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
// stack frame leading to huge stack frames in some cases; gcc does not reuse
// the stack space.
Message::Message() : ss_(new ::std::stringstream) {
// By default, we want there to be enough precision when printing
// a double to a Message.
*ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);
}
// These two overloads allow streaming a wide C string to a Message
// using the UTF-8 encoding.
Message& Message::operator <<(const wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
Message& Message::operator <<(wchar_t* wide_c_str) {
return *this << internal::String::ShowWideCString(wide_c_str);
}
#if GTEST_HAS_STD_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& Message::operator <<(const ::std::wstring& wstr) {
internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
return *this;
}
#endif // GTEST_HAS_STD_WSTRING
#if GTEST_HAS_GLOBAL_WSTRING
// Converts the given wide string to a narrow string using the UTF-8
// encoding, and streams the result to this Message object.
Message& Message::operator <<(const ::wstring& wstr) {
internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);
return *this;
}
#endif // GTEST_HAS_GLOBAL_WSTRING
// Gets the text streamed to this object so far as an std::string.
// Each '\0' character in the buffer is replaced with "\\0".
std::string Message::GetString() const {
return internal::StringStreamToString(ss_.get());
}
// AssertionResult constructors.
// Used in EXPECT_TRUE/FALSE(assertion_result).
AssertionResult::AssertionResult(const AssertionResult& other)
: success_(other.success_),
message_(other.message_.get() != NULL ?
new ::std::string(*other.message_) :
static_cast< ::std::string*>(NULL)) {
}
// Swaps two AssertionResults.
void AssertionResult::swap(AssertionResult& other) {
using std::swap;
swap(success_, other.success_);
swap(message_, other.message_);
}
// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.
AssertionResult AssertionResult::operator!() const {
AssertionResult negation(!success_);
if (message_.get() != NULL)
negation << *message_;
return negation;
}
// Makes a successful assertion result.
AssertionResult AssertionSuccess() {
return AssertionResult(true);
}
// Makes a failed assertion result.
AssertionResult AssertionFailure() {
return AssertionResult(false);
}
// Makes a failed assertion result with the given failure message.
// Deprecated; use AssertionFailure() << message.
AssertionResult AssertionFailure(const Message& message) {
return AssertionFailure() << message;
}
namespace internal {
namespace edit_distance {
std::vector<EditType> CalculateOptimalEdits(const std::vector<size_t>& left,
const std::vector<size_t>& right) {
std::vector<std::vector<double> > costs(
left.size() + 1, std::vector<double>(right.size() + 1));
std::vector<std::vector<EditType> > best_move(
left.size() + 1, std::vector<EditType>(right.size() + 1));
// Populate for empty right.
for (size_t l_i = 0; l_i < costs.size(); ++l_i) {
costs[l_i][0] = static_cast<double>(l_i);
best_move[l_i][0] = kRemove;
}
// Populate for empty left.
for (size_t r_i = 1; r_i < costs[0].size(); ++r_i) {
costs[0][r_i] = static_cast<double>(r_i);
best_move[0][r_i] = kAdd;
}
for (size_t l_i = 0; l_i < left.size(); ++l_i) {
for (size_t r_i = 0; r_i < right.size(); ++r_i) {
if (left[l_i] == right[r_i]) {
// Found a match. Consume it.
costs[l_i + 1][r_i + 1] = costs[l_i][r_i];
best_move[l_i + 1][r_i + 1] = kMatch;
continue;
}
const double add = costs[l_i + 1][r_i];
const double remove = costs[l_i][r_i + 1];
const double replace = costs[l_i][r_i];
if (add < remove && add < replace) {
costs[l_i + 1][r_i + 1] = add + 1;
best_move[l_i + 1][r_i + 1] = kAdd;
} else if (remove < add && remove < replace) {
costs[l_i + 1][r_i + 1] = remove + 1;
best_move[l_i + 1][r_i + 1] = kRemove;
} else {
// We make replace a little more expensive than add/remove to lower
// their priority.
costs[l_i + 1][r_i + 1] = replace + 1.00001;
best_move[l_i + 1][r_i + 1] = kReplace;
}
}
}
// Reconstruct the best path. We do it in reverse order.
std::vector<EditType> best_path;
for (size_t l_i = left.size(), r_i = right.size(); l_i > 0 || r_i > 0;) {
EditType move = best_move[l_i][r_i];
best_path.push_back(move);
l_i -= move != kAdd;
r_i -= move != kRemove;
}
std::reverse(best_path.begin(), best_path.end());
return best_path;
}
namespace {
// Helper class to convert string into ids with deduplication.
class InternalStrings {
public:
size_t GetId(const std::string& str) {
IdMap::iterator it = ids_.find(str);
if (it != ids_.end()) return it->second;
size_t id = ids_.size();
return ids_[str] = id;
}
private:
typedef std::map<std::string, size_t> IdMap;
IdMap ids_;
};
} // namespace
std::vector<EditType> CalculateOptimalEdits(
const std::vector<std::string>& left,
const std::vector<std::string>& right) {
std::vector<size_t> left_ids, right_ids;
{
InternalStrings intern_table;
for (size_t i = 0; i < left.size(); ++i) {
left_ids.push_back(intern_table.GetId(left[i]));
}
for (size_t i = 0; i < right.size(); ++i) {
right_ids.push_back(intern_table.GetId(right[i]));
}
}
return CalculateOptimalEdits(left_ids, right_ids);
}
namespace {
// Helper class that holds the state for one hunk and prints it out to the
// stream.
// It reorders adds/removes when possible to group all removes before all
// adds. It also adds the hunk header before printint into the stream.
class Hunk {
public:
Hunk(size_t left_start, size_t right_start)
: left_start_(left_start),
right_start_(right_start),
adds_(),
removes_(),
common_() {}
void PushLine(char edit, const char* line) {
switch (edit) {
case ' ':
++common_;
FlushEdits();
hunk_.push_back(std::make_pair(' ', line));
break;
case '-':
++removes_;
hunk_removes_.push_back(std::make_pair('-', line));
break;
case '+':
++adds_;
hunk_adds_.push_back(std::make_pair('+', line));
break;
}
}
void PrintTo(std::ostream* os) {
PrintHeader(os);
FlushEdits();
for (std::list<std::pair<char, const char*> >::const_iterator it =
hunk_.begin();
it != hunk_.end(); ++it) {
*os << it->first << it->second << "\n";
}
}
bool has_edits() const { return adds_ || removes_; }
private:
void FlushEdits() {
hunk_.splice(hunk_.end(), hunk_removes_);
hunk_.splice(hunk_.end(), hunk_adds_);
}
// Print a unified diff header for one hunk.
// The format is
// "@@ -<left_start>,<left_length> +<right_start>,<right_length> @@"
// where the left/right parts are omitted if unnecessary.
void PrintHeader(std::ostream* ss) const {
*ss << "@@ ";
if (removes_) {
*ss << "-" << left_start_ << "," << (removes_ + common_);
}
if (removes_ && adds_) {
*ss << " ";
}
if (adds_) {
*ss << "+" << right_start_ << "," << (adds_ + common_);
}
*ss << " @@\n";
}
size_t left_start_, right_start_;
size_t adds_, removes_, common_;
std::list<std::pair<char, const char*> > hunk_, hunk_adds_, hunk_removes_;
};
} // namespace
// Create a list of diff hunks in Unified diff format.
// Each hunk has a header generated by PrintHeader above plus a body with
// lines prefixed with ' ' for no change, '-' for deletion and '+' for
// addition.
// 'context' represents the desired unchanged prefix/suffix around the diff.
// If two hunks are close enough that their contexts overlap, then they are
// joined into one hunk.
std::string CreateUnifiedDiff(const std::vector<std::string>& left,
const std::vector<std::string>& right,
size_t context) {
const std::vector<EditType> edits = CalculateOptimalEdits(left, right);
size_t l_i = 0, r_i = 0, edit_i = 0;
std::stringstream ss;
while (edit_i < edits.size()) {
// Find first edit.
while (edit_i < edits.size() && edits[edit_i] == kMatch) {
++l_i;
++r_i;
++edit_i;
}
// Find the first line to include in the hunk.
const size_t prefix_context = std::min(l_i, context);
Hunk hunk(l_i - prefix_context + 1, r_i - prefix_context + 1);
for (size_t i = prefix_context; i > 0; --i) {
hunk.PushLine(' ', left[l_i - i].c_str());
}
// Iterate the edits until we found enough suffix for the hunk or the input
// is over.
size_t n_suffix = 0;
for (; edit_i < edits.size(); ++edit_i) {
if (n_suffix >= context) {
// Continue only if the next hunk is very close.
std::vector<EditType>::const_iterator it = edits.begin() + edit_i;
while (it != edits.end() && *it == kMatch) ++it;
if (it == edits.end() || (it - edits.begin()) - edit_i >= context) {
// There is no next edit or it is too far away.
break;
}
}
EditType edit = edits[edit_i];
// Reset count when a non match is found.
n_suffix = edit == kMatch ? n_suffix + 1 : 0;
if (edit == kMatch || edit == kRemove || edit == kReplace) {
hunk.PushLine(edit == kMatch ? ' ' : '-', left[l_i].c_str());
}
if (edit == kAdd || edit == kReplace) {
hunk.PushLine('+', right[r_i].c_str());
}
// Advance indices, depending on edit type.
l_i += edit != kAdd;
r_i += edit != kRemove;
}
if (!hunk.has_edits()) {
// We are done. We don't want this hunk.
break;
}
hunk.PrintTo(&ss);
}
return ss.str();
}
} // namespace edit_distance
namespace {
// The string representation of the values received in EqFailure() are already
// escaped. Split them on escaped '\n' boundaries. Leave all other escaped
// characters the same.
std::vector<std::string> SplitEscapedString(const std::string& str) {
std::vector<std::string> lines;
size_t start = 0, end = str.size();
if (end > 2 && str[0] == '"' && str[end - 1] == '"') {
++start;
--end;
}
bool escaped = false;
for (size_t i = start; i + 1 < end; ++i) {
if (escaped) {
escaped = false;
if (str[i] == 'n') {
lines.push_back(str.substr(start, i - start - 1));
start = i + 1;
}
} else {
escaped = str[i] == '\\';
}
}
lines.push_back(str.substr(start, end - start));
return lines;
}
} // namespace
// Constructs and returns the message for an equality assertion
// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.
//
// The first four parameters are the expressions used in the assertion
// and their values, as strings. For example, for ASSERT_EQ(foo, bar)
// where foo is 5 and bar is 6, we have:
//
// lhs_expression: "foo"
// rhs_expression: "bar"
// lhs_value: "5"
// rhs_value: "6"
//
// The ignoring_case parameter is true iff the assertion is a
// *_STRCASEEQ*. When it's true, the string "Ignoring case" will
// be inserted into the message.
AssertionResult EqFailure(const char* lhs_expression,
const char* rhs_expression,
const std::string& lhs_value,
const std::string& rhs_value,
bool ignoring_case) {
Message msg;
msg << "Expected equality of these values:";
msg << "\n " << lhs_expression;
if (lhs_value != lhs_expression) {
msg << "\n Which is: " << lhs_value;
}
msg << "\n " << rhs_expression;
if (rhs_value != rhs_expression) {
msg << "\n Which is: " << rhs_value;
}
if (ignoring_case) {
msg << "\nIgnoring case";
}
if (!lhs_value.empty() && !rhs_value.empty()) {
const std::vector<std::string> lhs_lines =
SplitEscapedString(lhs_value);
const std::vector<std::string> rhs_lines =
SplitEscapedString(rhs_value);
if (lhs_lines.size() > 1 || rhs_lines.size() > 1) {
msg << "\nWith diff:\n"
<< edit_distance::CreateUnifiedDiff(lhs_lines, rhs_lines);
}
}
return AssertionFailure() << msg;
}
// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.
std::string GetBoolAssertionFailureMessage(
const AssertionResult& assertion_result,
const char* expression_text,
const char* actual_predicate_value,
const char* expected_predicate_value) {
const char* actual_message = assertion_result.message();
Message msg;
msg << "Value of: " << expression_text
<< "\n Actual: " << actual_predicate_value;
if (actual_message[0] != '\0')
msg << " (" << actual_message << ")";
msg << "\nExpected: " << expected_predicate_value;
return msg.GetString();
}
// Helper function for implementing ASSERT_NEAR.
AssertionResult DoubleNearPredFormat(const char* expr1,
const char* expr2,
const char* abs_error_expr,
double val1,
double val2,
double abs_error) {
const double diff = fabs(val1 - val2);
if (diff <= abs_error) return AssertionSuccess();
// TODO(wan): do not print the value of an expression if it's
// already a literal.
return AssertionFailure()
<< "The difference between " << expr1 << " and " << expr2
<< " is " << diff << ", which exceeds " << abs_error_expr << ", where\n"
<< expr1 << " evaluates to " << val1 << ",\n"
<< expr2 << " evaluates to " << val2 << ", and\n"
<< abs_error_expr << " evaluates to " << abs_error << ".";
}
// Helper template for implementing FloatLE() and DoubleLE().
template <typename RawType>
AssertionResult FloatingPointLE(const char* expr1,
const char* expr2,
RawType val1,
RawType val2) {
// Returns success if val1 is less than val2,
if (val1 < val2) {
return AssertionSuccess();
}
// or if val1 is almost equal to val2.
const FloatingPoint<RawType> lhs(val1), rhs(val2);
if (lhs.AlmostEquals(rhs)) {
return AssertionSuccess();
}
// Note that the above two checks will both fail if either val1 or
// val2 is NaN, as the IEEE floating-point standard requires that
// any predicate involving a NaN must return false.
::std::stringstream val1_ss;
val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
<< val1;
::std::stringstream val2_ss;
val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)
<< val2;
return AssertionFailure()
<< "Expected: (" << expr1 << ") <= (" << expr2 << ")\n"
<< " Actual: " << StringStreamToString(&val1_ss) << " vs "
<< StringStreamToString(&val2_ss);
}
} // namespace internal
// Asserts that val1 is less than, or almost equal to, val2. Fails
// otherwise. In particular, it fails if either val1 or val2 is NaN.
AssertionResult FloatLE(const char* expr1, const char* expr2,
float val1, float val2) {
return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);
}
// Asserts that val1 is less than, or almost equal to, val2. Fails
// otherwise. In particular, it fails if either val1 or val2 is NaN.
AssertionResult DoubleLE(const char* expr1, const char* expr2,
double val1, double val2) {
return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);
}
namespace internal {
// The helper function for {ASSERT|EXPECT}_EQ with int or enum
// arguments.
AssertionResult CmpHelperEQ(const char* lhs_expression,
const char* rhs_expression,
BiggestInt lhs,
BiggestInt rhs) {
if (lhs == rhs) {
return AssertionSuccess();
}
return EqFailure(lhs_expression,
rhs_expression,
FormatForComparisonFailureMessage(lhs, rhs),
FormatForComparisonFailureMessage(rhs, lhs),
false);
}
// A macro for implementing the helper functions needed to implement
// ASSERT_?? and EXPECT_?? with integer or enum arguments. It is here
// just to avoid copy-and-paste of similar code.
#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
BiggestInt val1, BiggestInt val2) {\
if (val1 op val2) {\
return AssertionSuccess();\
} else {\
return AssertionFailure() \
<< "Expected: (" << expr1 << ") " #op " (" << expr2\
<< "), actual: " << FormatForComparisonFailureMessage(val1, val2)\
<< " vs " << FormatForComparisonFailureMessage(val2, val1);\
}\
}
// Implements the helper function for {ASSERT|EXPECT}_NE with int or
// enum arguments.
GTEST_IMPL_CMP_HELPER_(NE, !=)
// Implements the helper function for {ASSERT|EXPECT}_LE with int or
// enum arguments.
GTEST_IMPL_CMP_HELPER_(LE, <=)
// Implements the helper function for {ASSERT|EXPECT}_LT with int or
// enum arguments.
GTEST_IMPL_CMP_HELPER_(LT, < )
// Implements the helper function for {ASSERT|EXPECT}_GE with int or
// enum arguments.
GTEST_IMPL_CMP_HELPER_(GE, >=)
// Implements the helper function for {ASSERT|EXPECT}_GT with int or
// enum arguments.
GTEST_IMPL_CMP_HELPER_(GT, > )
#undef GTEST_IMPL_CMP_HELPER_
// The helper function for {ASSERT|EXPECT}_STREQ.
AssertionResult CmpHelperSTREQ(const char* lhs_expression,
const char* rhs_expression,
const char* lhs,
const char* rhs) {
if (String::CStringEquals(lhs, rhs)) {
return AssertionSuccess();
}
return EqFailure(lhs_expression,
rhs_expression,
PrintToString(lhs),
PrintToString(rhs),
false);
}
// The helper function for {ASSERT|EXPECT}_STRCASEEQ.
AssertionResult CmpHelperSTRCASEEQ(const char* lhs_expression,
const char* rhs_expression,
const char* lhs,
const char* rhs) {
if (String::CaseInsensitiveCStringEquals(lhs, rhs)) {
return AssertionSuccess();
}
return EqFailure(lhs_expression,
rhs_expression,
PrintToString(lhs),
PrintToString(rhs),
true);
}
// The helper function for {ASSERT|EXPECT}_STRNE.
AssertionResult CmpHelperSTRNE(const char* s1_expression,
const char* s2_expression,
const char* s1,
const char* s2) {
if (!String::CStringEquals(s1, s2)) {
return AssertionSuccess();
} else {
return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
<< s2_expression << "), actual: \""
<< s1 << "\" vs \"" << s2 << "\"";
}
}
// The helper function for {ASSERT|EXPECT}_STRCASENE.
AssertionResult CmpHelperSTRCASENE(const char* s1_expression,
const char* s2_expression,
const char* s1,
const char* s2) {
if (!String::CaseInsensitiveCStringEquals(s1, s2)) {
return AssertionSuccess();
} else {
return AssertionFailure()
<< "Expected: (" << s1_expression << ") != ("
<< s2_expression << ") (ignoring case), actual: \""
<< s1 << "\" vs \"" << s2 << "\"";
}
}
} // namespace internal
namespace {
// Helper functions for implementing IsSubString() and IsNotSubstring().
// This group of overloaded functions return true iff needle is a
// substring of haystack. NULL is considered a substring of itself
// only.
bool IsSubstringPred(const char* needle, const char* haystack) {
if (needle == NULL || haystack == NULL)
return needle == haystack;
return strstr(haystack, needle) != NULL;
}
bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {
if (needle == NULL || haystack == NULL)
return needle == haystack;
return wcsstr(haystack, needle) != NULL;
}
// StringType here can be either ::std::string or ::std::wstring.
template <typename StringType>
bool IsSubstringPred(const StringType& needle,
const StringType& haystack) {
return haystack.find(needle) != StringType::npos;
}
// This function implements either IsSubstring() or IsNotSubstring(),
// depending on the value of the expected_to_be_substring parameter.
// StringType here can be const char*, const wchar_t*, ::std::string,
// or ::std::wstring.
template <typename StringType>
AssertionResult IsSubstringImpl(
bool expected_to_be_substring,
const char* needle_expr, const char* haystack_expr,
const StringType& needle, const StringType& haystack) {
if (IsSubstringPred(needle, haystack) == expected_to_be_substring)
return AssertionSuccess();
const bool is_wide_string = sizeof(needle[0]) > 1;
const char* const begin_string_quote = is_wide_string ? "L\"" : "\"";
return AssertionFailure()
<< "Value of: " << needle_expr << "\n"
<< " Actual: " << begin_string_quote << needle << "\"\n"
<< "Expected: " << (expected_to_be_substring ? "" : "not ")
<< "a substring of " << haystack_expr << "\n"
<< "Which is: " << begin_string_quote << haystack << "\"";
}
} // namespace
// IsSubstring() and IsNotSubstring() check whether needle is a
// substring of haystack (NULL is considered a substring of itself
// only), and return an appropriate error message when they fail.
AssertionResult IsSubstring(
const char* needle_expr, const char* haystack_expr,
const char* needle, const char* haystack) {
return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
}
AssertionResult IsSubstring(
const char* needle_expr, const char* haystack_expr,
const wchar_t* needle, const wchar_t* haystack) {
return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
}
AssertionResult IsNotSubstring(
const char* needle_expr, const char* haystack_expr,
const char* needle, const char* haystack) {
return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
}
AssertionResult IsNotSubstring(
const char* needle_expr, const char* haystack_expr,
const wchar_t* needle, const wchar_t* haystack) {
return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
}
AssertionResult IsSubstring(
const char* needle_expr, const char* haystack_expr,
const ::std::string& needle, const ::std::string& haystack) {
return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
}
AssertionResult IsNotSubstring(
const char* needle_expr, const char* haystack_expr,
const ::std::string& needle, const ::std::string& haystack) {
return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
}
#if GTEST_HAS_STD_WSTRING
AssertionResult IsSubstring(
const char* needle_expr, const char* haystack_expr,
const ::std::wstring& needle, const ::std::wstring& haystack) {
return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);
}
AssertionResult IsNotSubstring(
const char* needle_expr, const char* haystack_expr,
const ::std::wstring& needle, const ::std::wstring& haystack) {
return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);
}
#endif // GTEST_HAS_STD_WSTRING
namespace internal {
#if GTEST_OS_WINDOWS
namespace {
// Helper function for IsHRESULT{SuccessFailure} predicates
AssertionResult HRESULTFailureHelper(const char* expr,
const char* expected,
long hr) { // NOLINT
# if GTEST_OS_WINDOWS_MOBILE
// Windows CE doesn't support FormatMessage.
const char error_text[] = "";
# else
// Looks up the human-readable system message for the HRESULT code
// and since we're not passing any params to FormatMessage, we don't
// want inserts expanded.
const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS;
const DWORD kBufSize = 4096;
// Gets the system's human readable message string for this HRESULT.
char error_text[kBufSize] = { '\0' };
DWORD message_length = ::FormatMessageA(kFlags,
0, // no source, we're asking system
hr, // the error
0, // no line width restrictions
error_text, // output buffer
kBufSize, // buf size
NULL); // no arguments for inserts
// Trims tailing white space (FormatMessage leaves a trailing CR-LF)
for (; message_length && IsSpace(error_text[message_length - 1]);
--message_length) {
error_text[message_length - 1] = '\0';
}
# endif // GTEST_OS_WINDOWS_MOBILE
const std::string error_hex("0x" + String::FormatHexInt(hr));
return ::testing::AssertionFailure()
<< "Expected: " << expr << " " << expected << ".\n"
<< " Actual: " << error_hex << " " << error_text << "\n";
}
} // namespace
AssertionResult IsHRESULTSuccess(const char* expr, long hr) { // NOLINT
if (SUCCEEDED(hr)) {
return AssertionSuccess();
}
return HRESULTFailureHelper(expr, "succeeds", hr);
}
AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT
if (FAILED(hr)) {
return AssertionSuccess();
}
return HRESULTFailureHelper(expr, "fails", hr);
}
#endif // GTEST_OS_WINDOWS
// Utility functions for encoding Unicode text (wide strings) in
// UTF-8.
// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8
// like this:
//
// Code-point length Encoding
// 0 - 7 bits 0xxxxxxx
// 8 - 11 bits 110xxxxx 10xxxxxx
// 12 - 16 bits 1110xxxx 10xxxxxx 10xxxxxx
// 17 - 21 bits 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// The maximum code-point a one-byte UTF-8 sequence can represent.
const UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) << 7) - 1;
// The maximum code-point a two-byte UTF-8 sequence can represent.
const UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1;
// The maximum code-point a three-byte UTF-8 sequence can represent.
const UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1;
// The maximum code-point a four-byte UTF-8 sequence can represent.
const UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1;
// Chops off the n lowest bits from a bit pattern. Returns the n
// lowest bits. As a side effect, the original bit pattern will be
// shifted to the right by n bits.
inline UInt32 ChopLowBits(UInt32* bits, int n) {
const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1);
*bits >>= n;
return low_bits;
}
// Converts a Unicode code point to a narrow string in UTF-8 encoding.
// code_point parameter is of type UInt32 because wchar_t may not be
// wide enough to contain a code point.
// If the code_point is not a valid Unicode code point
// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
// to "(Invalid Unicode 0xXXXXXXXX)".
std::string CodePointToUtf8(UInt32 code_point) {
if (code_point > kMaxCodePoint4) {
return "(Invalid Unicode 0x" + String::FormatHexInt(code_point) + ")";
}
char str[5]; // Big enough for the largest valid code point.
if (code_point <= kMaxCodePoint1) {
str[1] = '\0';
str[0] = static_cast<char>(code_point); // 0xxxxxxx
} else if (code_point <= kMaxCodePoint2) {
str[2] = '\0';
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xC0 | code_point); // 110xxxxx
} else if (code_point <= kMaxCodePoint3) {
str[3] = '\0';
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xE0 | code_point); // 1110xxxx
} else { // code_point <= kMaxCodePoint4
str[4] = '\0';
str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx
str[0] = static_cast<char>(0xF0 | code_point); // 11110xxx
}
return str;
}
// The following two functions only make sense if the system
// uses UTF-16 for wide string encoding. All supported systems
// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.
// Determines if the arguments constitute UTF-16 surrogate pair
// and thus should be combined into a single Unicode code point
// using CreateCodePointFromUtf16SurrogatePair.
inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {
return sizeof(wchar_t) == 2 &&
(first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;
}
// Creates a Unicode code point from UTF16 surrogate pair.
inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,
wchar_t second) {
const UInt32 mask = (1 << 10) - 1;
return (sizeof(wchar_t) == 2) ?
(((first & mask) << 10) | (second & mask)) + 0x10000 :
// This function should not be called when the condition is
// false, but we provide a sensible default in case it is.
static_cast<UInt32>(first);
}
// Converts a wide string to a narrow string in UTF-8 encoding.
// The wide string is assumed to have the following encoding:
// UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)
// UTF-32 if sizeof(wchar_t) == 4 (on Linux)
// Parameter str points to a null-terminated wide string.
// Parameter num_chars may additionally limit the number
// of wchar_t characters processed. -1 is used when the entire string
// should be processed.
// If the string contains code points that are not valid Unicode code points
// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output
// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding
// and contains invalid UTF-16 surrogate pairs, values in those pairs
// will be encoded as individual Unicode characters from Basic Normal Plane.
std::string WideStringToUtf8(const wchar_t* str, int num_chars) {
if (num_chars == -1)
num_chars = static_cast<int>(wcslen(str));
::std::stringstream stream;
for (int i = 0; i < num_chars; ++i) {
UInt32 unicode_code_point;
if (str[i] == L'\0') {
break;
} else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {
unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],
str[i + 1]);
i++;
} else {
unicode_code_point = static_cast<UInt32>(str[i]);
}
stream << CodePointToUtf8(unicode_code_point);
}
return StringStreamToString(&stream);
}
// Converts a wide C string to an std::string using the UTF-8 encoding.
// NULL will be converted to "(null)".
std::string String::ShowWideCString(const wchar_t * wide_c_str) {
if (wide_c_str == NULL) return "(null)";
return internal::WideStringToUtf8(wide_c_str, -1);
}
// Compares two wide C strings. Returns true iff they have the same
// content.
//
// Unlike wcscmp(), this function can handle NULL argument(s). A NULL
// C string is considered different to any non-NULL C string,
// including the empty string.
bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {
if (lhs == NULL) return rhs == NULL;
if (rhs == NULL) return false;
return wcscmp(lhs, rhs) == 0;
}
// Helper function for *_STREQ on wide strings.
AssertionResult CmpHelperSTREQ(const char* lhs_expression,
const char* rhs_expression,
const wchar_t* lhs,
const wchar_t* rhs) {
if (String::WideCStringEquals(lhs, rhs)) {
return AssertionSuccess();
}
return EqFailure(lhs_expression,
rhs_expression,
PrintToString(lhs),
PrintToString(rhs),
false);
}
// Helper function for *_STRNE on wide strings.
AssertionResult CmpHelperSTRNE(const char* s1_expression,
const char* s2_expression,
const wchar_t* s1,
const wchar_t* s2) {
if (!String::WideCStringEquals(s1, s2)) {
return AssertionSuccess();
}
return AssertionFailure() << "Expected: (" << s1_expression << ") != ("
<< s2_expression << "), actual: "
<< PrintToString(s1)
<< " vs " << PrintToString(s2);
}
// Compares two C strings, ignoring case. Returns true iff they have
// the same content.
//
// Unlike strcasecmp(), this function can handle NULL argument(s). A
// NULL C string is considered different to any non-NULL C string,
// including the empty string.
bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {
if (lhs == NULL)
return rhs == NULL;
if (rhs == NULL)
return false;
return posix::StrCaseCmp(lhs, rhs) == 0;
}
// Compares two wide C strings, ignoring case. Returns true iff they
// have the same content.
//
// Unlike wcscasecmp(), this function can handle NULL argument(s).
// A NULL C string is considered different to any non-NULL wide C string,
// including the empty string.
// NB: The implementations on different platforms slightly differ.
// On windows, this method uses _wcsicmp which compares according to LC_CTYPE
// environment variable. On GNU platform this method uses wcscasecmp
// which compares according to LC_CTYPE category of the current locale.
// On MacOS X, it uses towlower, which also uses LC_CTYPE category of the
// current locale.
bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,
const wchar_t* rhs) {
if (lhs == NULL) return rhs == NULL;
if (rhs == NULL) return false;
#if GTEST_OS_WINDOWS
return _wcsicmp(lhs, rhs) == 0;
#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID
return wcscasecmp(lhs, rhs) == 0;
#else
// Android, Mac OS X and Cygwin don't define wcscasecmp.
// Other unknown OSes may not define it either.
wint_t left, right;
do {
left = towlower(*lhs++);
right = towlower(*rhs++);
} while (left && left == right);
return left == right;
#endif // OS selector
}
// Returns true iff str ends with the given suffix, ignoring case.
// Any string is considered to end with an empty suffix.
bool String::EndsWithCaseInsensitive(
const std::string& str, const std::string& suffix) {
const size_t str_len = str.length();
const size_t suffix_len = suffix.length();
return (str_len >= suffix_len) &&
CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,
suffix.c_str());
}
// Formats an int value as "%02d".
std::string String::FormatIntWidth2(int value) {
std::stringstream ss;
ss << std::setfill('0') << std::setw(2) << value;
return ss.str();
}
// Formats an int value as "%X".
std::string String::FormatHexInt(int value) {
std::stringstream ss;
ss << std::hex << std::uppercase << value;
return ss.str();
}
// Formats a byte as "%02X".
std::string String::FormatByte(unsigned char value) {
std::stringstream ss;
ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase
<< static_cast<unsigned int>(value);
return ss.str();
}
// Converts the buffer in a stringstream to an std::string, converting NUL
// bytes to "\\0" along the way.
std::string StringStreamToString(::std::stringstream* ss) {
const ::std::string& str = ss->str();
const char* const start = str.c_str();
const char* const end = start + str.length();
std::string result;
result.reserve(2 * (end - start));
for (const char* ch = start; ch != end; ++ch) {
if (*ch == '\0') {
result += "\\0"; // Replaces NUL with "\\0";
} else {
result += *ch;
}
}
return result;
}
// Appends the user-supplied message to the Google-Test-generated message.
std::string AppendUserMessage(const std::string& gtest_msg,
const Message& user_msg) {
// Appends the user message if it's non-empty.
const std::string user_msg_string = user_msg.GetString();
if (user_msg_string.empty()) {
return gtest_msg;
}
return gtest_msg + "\n" + user_msg_string;
}
} // namespace internal
// class TestResult
// Creates an empty TestResult.
TestResult::TestResult()
: death_test_count_(0),
elapsed_time_(0) {
}
// D'tor.
TestResult::~TestResult() {
}
// Returns the i-th test part result among all the results. i can
// range from 0 to total_part_count() - 1. If i is not in that range,
// aborts the program.
const TestPartResult& TestResult::GetTestPartResult(int i) const {
if (i < 0 || i >= total_part_count())
internal::posix::Abort();
return test_part_results_.at(i);
}
// Returns the i-th test property. i can range from 0 to
// test_property_count() - 1. If i is not in that range, aborts the
// program.
const TestProperty& TestResult::GetTestProperty(int i) const {
if (i < 0 || i >= test_property_count())
internal::posix::Abort();
return test_properties_.at(i);
}
// Clears the test part results.
void TestResult::ClearTestPartResults() {
test_part_results_.clear();
}
// Adds a test part result to the list.
void TestResult::AddTestPartResult(const TestPartResult& test_part_result) {
test_part_results_.push_back(test_part_result);
}
// Adds a test property to the list. If a property with the same key as the
// supplied property is already represented, the value of this test_property
// replaces the old value for that key.
void TestResult::RecordProperty(const std::string& xml_element,
const TestProperty& test_property) {
if (!ValidateTestProperty(xml_element, test_property)) {
return;
}
internal::MutexLock lock(&test_properites_mutex_);
const std::vector<TestProperty>::iterator property_with_matching_key =
std::find_if(test_properties_.begin(), test_properties_.end(),
internal::TestPropertyKeyIs(test_property.key()));
if (property_with_matching_key == test_properties_.end()) {
test_properties_.push_back(test_property);
return;
}
property_with_matching_key->SetValue(test_property.value());
}
// The list of reserved attributes used in the <testsuites> element of XML
// output.
static const char* const kReservedTestSuitesAttributes[] = {
"disabled",
"errors",
"failures",
"name",
"random_seed",
"tests",
"time",
"timestamp"
};
// The list of reserved attributes used in the <testsuite> element of XML
// output.
static const char* const kReservedTestSuiteAttributes[] = {
"disabled",
"errors",
"failures",
"name",
"tests",
"time"
};
// The list of reserved attributes used in the <testcase> element of XML output.
static const char* const kReservedTestCaseAttributes[] = {
"classname",
"name",
"status",
"time",
"type_param",
"value_param"
};
template <int kSize>
std::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) {
return std::vector<std::string>(array, array + kSize);
}
static std::vector<std::string> GetReservedAttributesForElement(
const std::string& xml_element) {
if (xml_element == "testsuites") {
return ArrayAsVector(kReservedTestSuitesAttributes);
} else if (xml_element == "testsuite") {
return ArrayAsVector(kReservedTestSuiteAttributes);
} else if (xml_element == "testcase") {
return ArrayAsVector(kReservedTestCaseAttributes);
} else {
GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element;
}
// This code is unreachable but some compilers may not realizes that.
return std::vector<std::string>();
}
static std::string FormatWordList(const std::vector<std::string>& words) {
Message word_list;
for (size_t i = 0; i < words.size(); ++i) {
if (i > 0 && words.size() > 2) {
word_list << ", ";
}
if (i == words.size() - 1) {
word_list << "and ";
}
word_list << "'" << words[i] << "'";
}
return word_list.GetString();
}
static bool ValidateTestPropertyName(
const std::string& property_name,
const std::vector<std::string>& reserved_names) {
if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=
reserved_names.end()) {
ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name
<< " (" << FormatWordList(reserved_names)
<< " are reserved by " << GTEST_NAME_ << ")";
return false;
}
return true;
}
// Adds a failure if the key is a reserved attribute of the element named
// xml_element. Returns true if the property is valid.
bool TestResult::ValidateTestProperty(const std::string& xml_element,
const TestProperty& test_property) {
return ValidateTestPropertyName(test_property.key(),
GetReservedAttributesForElement(xml_element));
}
// Clears the object.
void TestResult::Clear() {
test_part_results_.clear();
test_properties_.clear();
death_test_count_ = 0;
elapsed_time_ = 0;
}
// Returns true iff the test failed.
bool TestResult::Failed() const {
for (int i = 0; i < total_part_count(); ++i) {
if (GetTestPartResult(i).failed())
return true;
}
return false;
}
// Returns true iff the test part fatally failed.
static bool TestPartFatallyFailed(const TestPartResult& result) {
return result.fatally_failed();
}
// Returns true iff the test fatally failed.
bool TestResult::HasFatalFailure() const {
return CountIf(test_part_results_, TestPartFatallyFailed) > 0;
}
// Returns true iff the test part non-fatally failed.
static bool TestPartNonfatallyFailed(const TestPartResult& result) {
return result.nonfatally_failed();
}
// Returns true iff the test has a non-fatal failure.
bool TestResult::HasNonfatalFailure() const {
return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;
}
// Gets the number of all test parts. This is the sum of the number
// of successful test parts and the number of failed test parts.
int TestResult::total_part_count() const {
return static_cast<int>(test_part_results_.size());
}
// Returns the number of the test properties.
int TestResult::test_property_count() const {
return static_cast<int>(test_properties_.size());
}
// class Test
// Creates a Test object.
// The c'tor saves the states of all flags.
Test::Test()
: gtest_flag_saver_(new GTEST_FLAG_SAVER_) {
}
// The d'tor restores the states of all flags. The actual work is
// done by the d'tor of the gtest_flag_saver_ field, and thus not
// visible here.
Test::~Test() {
}
// Sets up the test fixture.
//
// A sub-class may override this.
void Test::SetUp() {
}
// Tears down the test fixture.
//
// A sub-class may override this.
void Test::TearDown() {
}
// Allows user supplied key value pairs to be recorded for later output.
void Test::RecordProperty(const std::string& key, const std::string& value) {
UnitTest::GetInstance()->RecordProperty(key, value);
}
// Allows user supplied key value pairs to be recorded for later output.
void Test::RecordProperty(const std::string& key, int value) {
Message value_message;
value_message << value;
RecordProperty(key, value_message.GetString().c_str());
}
namespace internal {
void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
const std::string& message) {
// This function is a friend of UnitTest and as such has access to
// AddTestPartResult.
UnitTest::GetInstance()->AddTestPartResult(
result_type,
NULL, // No info about the source file where the exception occurred.
-1, // We have no info on which line caused the exception.
message,
""); // No stack trace, either.
}
} // namespace internal
// Google Test requires all tests in the same test case to use the same test
// fixture class. This function checks if the current test has the
// same fixture class as the first test in the current test case. If
// yes, it returns true; otherwise it generates a Google Test failure and
// returns false.
bool Test::HasSameFixtureClass() {
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
const TestCase* const test_case = impl->current_test_case();
// Info about the first test in the current test case.
const TestInfo* const first_test_info = test_case->test_info_list()[0];
const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;
const char* const first_test_name = first_test_info->name();
// Info about the current test.
const TestInfo* const this_test_info = impl->current_test_info();
const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;
const char* const this_test_name = this_test_info->name();
if (this_fixture_id != first_fixture_id) {
// Is the first test defined using TEST?
const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();
// Is this test defined using TEST?
const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();
if (first_is_TEST || this_is_TEST) {
// Both TEST and TEST_F appear in same test case, which is incorrect.
// Tell the user how to fix this.
// Gets the name of the TEST and the name of the TEST_F. Note
// that first_is_TEST and this_is_TEST cannot both be true, as
// the fixture IDs are different for the two tests.
const char* const TEST_name =
first_is_TEST ? first_test_name : this_test_name;
const char* const TEST_F_name =
first_is_TEST ? this_test_name : first_test_name;
ADD_FAILURE()
<< "All tests in the same test case must use the same test fixture\n"
<< "class, so mixing TEST_F and TEST in the same test case is\n"
<< "illegal. In test case " << this_test_info->test_case_name()
<< ",\n"
<< "test " << TEST_F_name << " is defined using TEST_F but\n"
<< "test " << TEST_name << " is defined using TEST. You probably\n"
<< "want to change the TEST to TEST_F or move it to another test\n"
<< "case.";
} else {
// Two fixture classes with the same name appear in two different
// namespaces, which is not allowed. Tell the user how to fix this.
ADD_FAILURE()
<< "All tests in the same test case must use the same test fixture\n"
<< "class. However, in test case "
<< this_test_info->test_case_name() << ",\n"
<< "you defined test " << first_test_name
<< " and test " << this_test_name << "\n"
<< "using two different test fixture classes. This can happen if\n"
<< "the two classes are from different namespaces or translation\n"
<< "units and have the same name. You should probably rename one\n"
<< "of the classes to put the tests into different test cases.";
}
return false;
}
return true;
}
#if GTEST_HAS_SEH
// Adds an "exception thrown" fatal failure to the current test. This
// function returns its result via an output parameter pointer because VC++
// prohibits creation of objects with destructors on stack in functions
// using __try (see error C2712).
static std::string* FormatSehExceptionMessage(DWORD exception_code,
const char* location) {
Message message;
message << "SEH exception with code 0x" << std::setbase(16) <<
exception_code << std::setbase(10) << " thrown in " << location << ".";
return new std::string(message.GetString());
}
#endif // GTEST_HAS_SEH
namespace internal {
#if GTEST_HAS_EXCEPTIONS
// Adds an "exception thrown" fatal failure to the current test.
static std::string FormatCxxExceptionMessage(const char* description,
const char* location) {
Message message;
if (description != NULL) {
message << "C++ exception with description \"" << description << "\"";
} else {
message << "Unknown C++ exception";
}
message << " thrown in " << location << ".";
return message.GetString();
}
static std::string PrintTestPartResultToString(
const TestPartResult& test_part_result);
GoogleTestFailureException::GoogleTestFailureException(
const TestPartResult& failure)
: ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}
#endif // GTEST_HAS_EXCEPTIONS
// We put these helper functions in the internal namespace as IBM's xlC
// compiler rejects the code if they were declared static.
// Runs the given method and handles SEH exceptions it throws, when
// SEH is supported; returns the 0-value for type Result in case of an
// SEH exception. (Microsoft compilers cannot handle SEH and C++
// exceptions in the same function. Therefore, we provide a separate
// wrapper function for handling SEH exceptions.)
template <class T, typename Result>
Result HandleSehExceptionsInMethodIfSupported(
T* object, Result (T::*method)(), const char* location) {
#if GTEST_HAS_SEH
__try {
return (object->*method)();
} __except (internal::UnitTestOptions::GTestShouldProcessSEH( // NOLINT
GetExceptionCode())) {
// We create the exception message on the heap because VC++ prohibits
// creation of objects with destructors on stack in functions using __try
// (see error C2712).
std::string* exception_message = FormatSehExceptionMessage(
GetExceptionCode(), location);
internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
*exception_message);
delete exception_message;
return static_cast<Result>(0);
}
#else
(void)location;
return (object->*method)();
#endif // GTEST_HAS_SEH
}
// Runs the given method and catches and reports C++ and/or SEH-style
// exceptions, if they are supported; returns the 0-value for type
// Result in case of an SEH exception.
template <class T, typename Result>
Result HandleExceptionsInMethodIfSupported(
T* object, Result (T::*method)(), const char* location) {
// NOTE: The user code can affect the way in which Google Test handles
// exceptions by setting GTEST_FLAG(catch_exceptions), but only before
// RUN_ALL_TESTS() starts. It is technically possible to check the flag
// after the exception is caught and either report or re-throw the
// exception based on the flag's value:
//
// try {
// // Perform the test method.
// } catch (...) {
// if (GTEST_FLAG(catch_exceptions))
// // Report the exception as failure.
// else
// throw; // Re-throws the original exception.
// }
//
// However, the purpose of this flag is to allow the program to drop into
// the debugger when the exception is thrown. On most platforms, once the
// control enters the catch block, the exception origin information is
// lost and the debugger will stop the program at the point of the
// re-throw in this function -- instead of at the point of the original
// throw statement in the code under test. For this reason, we perform
// the check early, sacrificing the ability to affect Google Test's
// exception handling in the method where the exception is thrown.
if (internal::GetUnitTestImpl()->catch_exceptions()) {
#if GTEST_HAS_EXCEPTIONS
try {
return HandleSehExceptionsInMethodIfSupported(object, method, location);
} catch (const internal::GoogleTestFailureException&) { // NOLINT
// This exception type can only be thrown by a failed Google
// Test assertion with the intention of letting another testing
// framework catch it. Therefore we just re-throw it.
throw;
} catch (const std::exception& e) { // NOLINT
internal::ReportFailureInUnknownLocation(
TestPartResult::kFatalFailure,
FormatCxxExceptionMessage(e.what(), location));
} catch (...) { // NOLINT
internal::ReportFailureInUnknownLocation(
TestPartResult::kFatalFailure,
FormatCxxExceptionMessage(NULL, location));
}
return static_cast<Result>(0);
#else
return HandleSehExceptionsInMethodIfSupported(object, method, location);
#endif // GTEST_HAS_EXCEPTIONS
} else {
return (object->*method)();
}
}
} // namespace internal
// Runs the test and updates the test result.
void Test::Run() {
if (!HasSameFixtureClass()) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()");
// We will run the test only if SetUp() was successful.
if (!HasFatalFailure()) {
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &Test::TestBody, "the test body");
}
// However, we want to clean up as much as possible. Hence we will
// always call TearDown(), even if SetUp() or the test body has
// failed.
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &Test::TearDown, "TearDown()");
}
// Returns true iff the current test has a fatal failure.
bool Test::HasFatalFailure() {
return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();
}
// Returns true iff the current test has a non-fatal failure.
bool Test::HasNonfatalFailure() {
return internal::GetUnitTestImpl()->current_test_result()->
HasNonfatalFailure();
}
// class TestInfo
// Constructs a TestInfo object. It assumes ownership of the test factory
// object.
TestInfo::TestInfo(const std::string& a_test_case_name,
const std::string& a_name,
const char* a_type_param,
const char* a_value_param,
internal::CodeLocation a_code_location,
internal::TypeId fixture_class_id,
internal::TestFactoryBase* factory)
: test_case_name_(a_test_case_name),
name_(a_name),
type_param_(a_type_param ? new std::string(a_type_param) : NULL),
value_param_(a_value_param ? new std::string(a_value_param) : NULL),
location_(a_code_location),
fixture_class_id_(fixture_class_id),
should_run_(false),
is_disabled_(false),
matches_filter_(false),
factory_(factory),
result_() {}
// Destructs a TestInfo object.
TestInfo::~TestInfo() { delete factory_; }
namespace internal {
// Creates a new TestInfo object and registers it with Google Test;
// returns the created object.
//
// Arguments:
//
// test_case_name: name of the test case
// name: name of the test
// type_param: the name of the test's type parameter, or NULL if
// this is not a typed or a type-parameterized test.
// value_param: text representation of the test's value parameter,
// or NULL if this is not a value-parameterized test.
// code_location: code location where the test is defined
// fixture_class_id: ID of the test fixture class
// set_up_tc: pointer to the function that sets up the test case
// tear_down_tc: pointer to the function that tears down the test case
// factory: pointer to the factory that creates a test object.
// The newly created TestInfo instance will assume
// ownership of the factory object.
TestInfo* MakeAndRegisterTestInfo(
const char* test_case_name,
const char* name,
const char* type_param,
const char* value_param,
CodeLocation code_location,
TypeId fixture_class_id,
SetUpTestCaseFunc set_up_tc,
TearDownTestCaseFunc tear_down_tc,
TestFactoryBase* factory) {
TestInfo* const test_info =
new TestInfo(test_case_name, name, type_param, value_param,
code_location, fixture_class_id, factory);
GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);
return test_info;
}
void ReportInvalidTestCaseType(const char* test_case_name,
CodeLocation code_location) {
Message errors;
errors
<< "Attempted redefinition of test case " << test_case_name << ".\n"
<< "All tests in the same test case must use the same test fixture\n"
<< "class. However, in test case " << test_case_name << ", you tried\n"
<< "to define a test using a fixture class different from the one\n"
<< "used earlier. This can happen if the two fixture classes are\n"
<< "from different namespaces and have the same name. You should\n"
<< "probably rename one of the classes to put the tests into different\n"
<< "test cases.";
GTEST_LOG_(ERROR)
<< FormatFileLocation(code_location.file.c_str(),
code_location.line)
<< " " << errors.GetString();
}
} // namespace internal
namespace {
// A predicate that checks the test name of a TestInfo against a known
// value.
//
// This is used for implementation of the TestCase class only. We put
// it in the anonymous namespace to prevent polluting the outer
// namespace.
//
// TestNameIs is copyable.
class TestNameIs {
public:
// Constructor.
//
// TestNameIs has NO default constructor.
explicit TestNameIs(const char* name)
: name_(name) {}
// Returns true iff the test name of test_info matches name_.
bool operator()(const TestInfo * test_info) const {
return test_info && test_info->name() == name_;
}
private:
std::string name_;
};
} // namespace
namespace internal {
// This method expands all parameterized tests registered with macros TEST_P
// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.
// This will be done just once during the program runtime.
void UnitTestImpl::RegisterParameterizedTests() {
if (!parameterized_tests_registered_) {
parameterized_test_registry_.RegisterTests();
parameterized_tests_registered_ = true;
}
}
} // namespace internal
// Creates the test object, runs it, records its result, and then
// deletes it.
void TestInfo::Run() {
if (!should_run_) return;
// Tells UnitTest where to store test result.
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->set_current_test_info(this);
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
// Notifies the unit test event listeners that a test is about to start.
repeater->OnTestStart(*this);
const TimeInMillis start = internal::GetTimeInMillis();
impl->os_stack_trace_getter()->UponLeavingGTest();
// Creates the test object.
Test* const test = internal::HandleExceptionsInMethodIfSupported(
factory_, &internal::TestFactoryBase::CreateTest,
"the test fixture's constructor");
// Runs the test only if the test object was created and its
// constructor didn't generate a fatal failure.
if ((test != NULL) && !Test::HasFatalFailure()) {
// This doesn't throw as all user code that can throw are wrapped into
// exception handling code.
test->Run();
}
// Deletes the test object.
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
test, &Test::DeleteSelf_, "the test fixture's destructor");
result_.set_elapsed_time(internal::GetTimeInMillis() - start);
// Notifies the unit test event listener that a test has just finished.
repeater->OnTestEnd(*this);
// Tells UnitTest to stop associating assertion results to this
// test.
impl->set_current_test_info(NULL);
}
// class TestCase
// Gets the number of successful tests in this test case.
int TestCase::successful_test_count() const {
return CountIf(test_info_list_, TestPassed);
}
// Gets the number of failed tests in this test case.
int TestCase::failed_test_count() const {
return CountIf(test_info_list_, TestFailed);
}
// Gets the number of disabled tests that will be reported in the XML report.
int TestCase::reportable_disabled_test_count() const {
return CountIf(test_info_list_, TestReportableDisabled);
}
// Gets the number of disabled tests in this test case.
int TestCase::disabled_test_count() const {
return CountIf(test_info_list_, TestDisabled);
}
// Gets the number of tests to be printed in the XML report.
int TestCase::reportable_test_count() const {
return CountIf(test_info_list_, TestReportable);
}
// Get the number of tests in this test case that should run.
int TestCase::test_to_run_count() const {
return CountIf(test_info_list_, ShouldRunTest);
}
// Gets the number of all tests.
int TestCase::total_test_count() const {
return static_cast<int>(test_info_list_.size());
}
// Creates a TestCase with the given name.
//
// Arguments:
//
// name: name of the test case
// a_type_param: the name of the test case's type parameter, or NULL if
// this is not a typed or a type-parameterized test case.
// set_up_tc: pointer to the function that sets up the test case
// tear_down_tc: pointer to the function that tears down the test case
TestCase::TestCase(const char* a_name, const char* a_type_param,
Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc)
: name_(a_name),
type_param_(a_type_param ? new std::string(a_type_param) : NULL),
set_up_tc_(set_up_tc),
tear_down_tc_(tear_down_tc),
should_run_(false),
elapsed_time_(0) {
}
// Destructor of TestCase.
TestCase::~TestCase() {
// Deletes every Test in the collection.
ForEach(test_info_list_, internal::Delete<TestInfo>);
}
// Returns the i-th test among all the tests. i can range from 0 to
// total_test_count() - 1. If i is not in that range, returns NULL.
const TestInfo* TestCase::GetTestInfo(int i) const {
const int index = GetElementOr(test_indices_, i, -1);
return index < 0 ? NULL : test_info_list_[index];
}
// Returns the i-th test among all the tests. i can range from 0 to
// total_test_count() - 1. If i is not in that range, returns NULL.
TestInfo* TestCase::GetMutableTestInfo(int i) {
const int index = GetElementOr(test_indices_, i, -1);
return index < 0 ? NULL : test_info_list_[index];
}
// Adds a test to this test case. Will delete the test upon
// destruction of the TestCase object.
void TestCase::AddTestInfo(TestInfo * test_info) {
test_info_list_.push_back(test_info);
test_indices_.push_back(static_cast<int>(test_indices_.size()));
}
// Runs every test in this TestCase.
void TestCase::Run() {
if (!should_run_) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
impl->set_current_test_case(this);
TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();
repeater->OnTestCaseStart(*this);
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &TestCase::RunSetUpTestCase, "SetUpTestCase()");
const internal::TimeInMillis start = internal::GetTimeInMillis();
for (int i = 0; i < total_test_count(); i++) {
GetMutableTestInfo(i)->Run();
}
elapsed_time_ = internal::GetTimeInMillis() - start;
impl->os_stack_trace_getter()->UponLeavingGTest();
internal::HandleExceptionsInMethodIfSupported(
this, &TestCase::RunTearDownTestCase, "TearDownTestCase()");
repeater->OnTestCaseEnd(*this);
impl->set_current_test_case(NULL);
}
// Clears the results of all tests in this test case.
void TestCase::ClearResult() {
ad_hoc_test_result_.Clear();
ForEach(test_info_list_, TestInfo::ClearTestResult);
}
// Shuffles the tests in this test case.
void TestCase::ShuffleTests(internal::Random* random) {
Shuffle(random, &test_indices_);
}
// Restores the test order to before the first shuffle.
void TestCase::UnshuffleTests() {
for (size_t i = 0; i < test_indices_.size(); i++) {
test_indices_[i] = static_cast<int>(i);
}
}
// Formats a countable noun. Depending on its quantity, either the
// singular form or the plural form is used. e.g.
//
// FormatCountableNoun(1, "formula", "formuli") returns "1 formula".
// FormatCountableNoun(5, "book", "books") returns "5 books".
static std::string FormatCountableNoun(int count,
const char * singular_form,
const char * plural_form) {
return internal::StreamableToString(count) + " " +
(count == 1 ? singular_form : plural_form);
}
// Formats the count of tests.
static std::string FormatTestCount(int test_count) {
return FormatCountableNoun(test_count, "test", "tests");
}
// Formats the count of test cases.
static std::string FormatTestCaseCount(int test_case_count) {
return FormatCountableNoun(test_case_count, "test case", "test cases");
}
// Converts a TestPartResult::Type enum to human-friendly string
// representation. Both kNonFatalFailure and kFatalFailure are translated
// to "Failure", as the user usually doesn't care about the difference
// between the two when viewing the test result.
static const char * TestPartResultTypeToString(TestPartResult::Type type) {
switch (type) {
case TestPartResult::kSuccess:
return "Success";
case TestPartResult::kNonFatalFailure:
case TestPartResult::kFatalFailure:
#ifdef _MSC_VER
return "error: ";
#else
return "Failure\n";
#endif
default:
return "Unknown result type";
}
}
namespace internal {
// Prints a TestPartResult to an std::string.
static std::string PrintTestPartResultToString(
const TestPartResult& test_part_result) {
return (Message()
<< internal::FormatFileLocation(test_part_result.file_name(),
test_part_result.line_number())
<< " " << TestPartResultTypeToString(test_part_result.type())
<< test_part_result.message()).GetString();
}
// Prints a TestPartResult.
static void PrintTestPartResult(const TestPartResult& test_part_result) {
const std::string& result =
PrintTestPartResultToString(test_part_result);
printf("%s\n", result.c_str());
fflush(stdout);
// If the test program runs in Visual Studio or a debugger, the
// following statements add the test part result message to the Output
// window such that the user can double-click on it to jump to the
// corresponding source code location; otherwise they do nothing.
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
// We don't call OutputDebugString*() on Windows Mobile, as printing
// to stdout is done by OutputDebugString() there already - we don't
// want the same message printed twice.
::OutputDebugStringA(result.c_str());
::OutputDebugStringA("\n");
#endif
}
// class PrettyUnitTestResultPrinter
enum GTestColor {
COLOR_DEFAULT,
COLOR_RED,
COLOR_GREEN,
COLOR_YELLOW
};
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
// Returns the character attribute for the given color.
static WORD GetColorAttribute(GTestColor color) {
switch (color) {
case COLOR_RED: return FOREGROUND_RED;
case COLOR_GREEN: return FOREGROUND_GREEN;
case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;
default: return 0;
}
}
static int GetBitOffset(WORD color_mask) {
if (color_mask == 0) return 0;
int bitOffset = 0;
while((color_mask & 1) == 0) {
color_mask >>= 1;
++bitOffset;
}
return bitOffset;
}
static WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
// Let's reuse the BG
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
const WORD existing_bg = old_color_attrs & background_mask;
WORD new_color = GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
static const int bg_bitOffset = GetBitOffset(background_mask);
static const int fg_bitOffset = GetBitOffset(foreground_mask);
if (((new_color & background_mask) >> bg_bitOffset) == ((new_color & foreground_mask) >> fg_bitOffset)) {
new_color ^= FOREGROUND_INTENSITY; //invert intensity
}
return new_color;
}
#else
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
// an invalid input.
static const char* GetAnsiColorCode(GTestColor color) {
switch (color) {
case COLOR_RED: return "1";
case COLOR_GREEN: return "2";
case COLOR_YELLOW: return "3";
default: return NULL;
};
}
#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
// Returns true iff Google Test should use colors in the output.
bool ShouldUseColor(bool stdout_is_tty) {
const char* const gtest_color = GTEST_FLAG(color).c_str();
if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) {
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MINGW
// On Windows the TERM variable is usually not set, but the
// console there does support colors.
return stdout_is_tty;
#else
// On non-Windows platforms, we rely on the TERM variable.
const char* const term = posix::GetEnv("TERM");
const bool term_supports_color =
String::CStringEquals(term, "xterm") ||
String::CStringEquals(term, "xterm-color") ||
String::CStringEquals(term, "xterm-256color") ||
String::CStringEquals(term, "screen") ||
String::CStringEquals(term, "screen-256color") ||
String::CStringEquals(term, "tmux") ||
String::CStringEquals(term, "tmux-256color") ||
String::CStringEquals(term, "rxvt-unicode") ||
String::CStringEquals(term, "rxvt-unicode-256color") ||
String::CStringEquals(term, "linux") ||
String::CStringEquals(term, "cygwin");
return stdout_is_tty && term_supports_color;
#endif // GTEST_OS_WINDOWS
}
return String::CaseInsensitiveCStringEquals(gtest_color, "yes") ||
String::CaseInsensitiveCStringEquals(gtest_color, "true") ||
String::CaseInsensitiveCStringEquals(gtest_color, "t") ||
String::CStringEquals(gtest_color, "1");
// We take "yes", "true", "t", and "1" as meaning "yes". If the
// value is neither one of these nor "auto", we treat it as "no" to
// be conservative.
}
// Helpers for printing colored strings to stdout. Note that on Windows, we
// cannot simply emit special characters and have the terminal change colors.
// This routine must actually emit the characters rather than return a string
// that would be colored when printed, as can be done on Linux.
GTEST_ATTRIBUTE_PRINTF_(2, 3)
static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || \
GTEST_OS_IOS || GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT
const bool use_color = AlwaysFalse();
#else
static const bool in_color_mode =
ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
const bool use_color = in_color_mode && (color != COLOR_DEFAULT);
#endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS
// The '!= 0' comparison is necessary to satisfy MSVC 7.1.
if (!use_color) {
vprintf(fmt, args);
va_end(args);
return;
}
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE && \
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW
const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Gets the current text color.
CONSOLE_SCREEN_BUFFER_INFO buffer_info;
GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);
const WORD old_color_attrs = buffer_info.wAttributes;
const WORD new_color = GetNewColor(color, old_color_attrs);
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
fflush(stdout);
SetConsoleTextAttribute(stdout_handle, new_color);
vprintf(fmt, args);
fflush(stdout);
// Restores the text color.
SetConsoleTextAttribute(stdout_handle, old_color_attrs);
#else
printf("\033[0;3%sm", GetAnsiColorCode(color));
vprintf(fmt, args);
printf("\033[m"); // Resets the terminal to default.
#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
va_end(args);
}
// Text printed in Google Test's text output and --gunit_list_tests
// output to label the type parameter and value parameter for a test.
static const char kTypeParamLabel[] = "TypeParam";
static const char kValueParamLabel[] = "GetParam()";
static void PrintFullTestCommentIfPresent(const TestInfo& test_info) {
const char* const type_param = test_info.type_param();
const char* const value_param = test_info.value_param();
if (type_param != NULL || value_param != NULL) {
printf(", where ");
if (type_param != NULL) {
printf("%s = %s", kTypeParamLabel, type_param);
if (value_param != NULL)
printf(" and ");
}
if (value_param != NULL) {
printf("%s = %s", kValueParamLabel, value_param);
}
}
}
// This class implements the TestEventListener interface.
//
// Class PrettyUnitTestResultPrinter is copyable.
class PrettyUnitTestResultPrinter : public TestEventListener {
public:
PrettyUnitTestResultPrinter() {}
static void PrintTestName(const char * test_case, const char * test) {
printf("%s.%s", test_case, test);
}
// The following methods override what's in the TestEventListener class.
virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestCaseStart(const TestCase& test_case);
virtual void OnTestStart(const TestInfo& test_info);
virtual void OnTestPartResult(const TestPartResult& result);
virtual void OnTestEnd(const TestInfo& test_info);
virtual void OnTestCaseEnd(const TestCase& test_case);
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}
private:
static void PrintFailedTests(const UnitTest& unit_test);
};
// Fired before each iteration of tests starts.
void PrettyUnitTestResultPrinter::OnTestIterationStart(
const UnitTest& unit_test, int iteration) {
if (GTEST_FLAG(repeat) != 1)
printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
const char* const filter = GTEST_FLAG(filter).c_str();
// Prints the filter if it's not *. This reminds the user that some
// tests may be skipped.
if (!String::CStringEquals(filter, kUniversalFilter)) {
ColoredPrintf(COLOR_YELLOW,
"Note: %s filter = %s\n", GTEST_NAME_, filter);
}
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
ColoredPrintf(COLOR_YELLOW,
"Note: This is test shard %d of %s.\n",
static_cast<int>(shard_index) + 1,
internal::posix::GetEnv(kTestTotalShards));
}
if (GTEST_FLAG(shuffle)) {
ColoredPrintf(COLOR_YELLOW,
"Note: Randomizing tests' orders with a seed of %d .\n",
unit_test.random_seed());
}
ColoredPrintf(COLOR_GREEN, "[==========] ");
printf("Running %s from %s.\n",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
fflush(stdout);
}
void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(
const UnitTest& /*unit_test*/) {
ColoredPrintf(COLOR_GREEN, "[----------] ");
printf("Global test environment set-up.\n");
fflush(stdout);
}
void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {
const std::string counts =
FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
ColoredPrintf(COLOR_GREEN, "[----------] ");
printf("%s from %s", counts.c_str(), test_case.name());
if (test_case.type_param() == NULL) {
printf("\n");
} else {
printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param());
}
fflush(stdout);
}
void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {
ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
PrintTestName(test_info.test_case_name(), test_info.name());
printf("\n");
fflush(stdout);
}
// Called after an assertion failure.
void PrettyUnitTestResultPrinter::OnTestPartResult(
const TestPartResult& result) {
// If the test part succeeded, we don't need to do anything.
if (result.type() == TestPartResult::kSuccess)
return;
// Print failure message from the assertion (e.g. expected this and got that).
PrintTestPartResult(result);
fflush(stdout);
}
void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {
if (test_info.result()->Passed()) {
ColoredPrintf(COLOR_GREEN, "[ OK ] ");
} else {
ColoredPrintf(COLOR_RED, "[ FAILED ] ");
}
PrintTestName(test_info.test_case_name(), test_info.name());
if (test_info.result()->Failed())
PrintFullTestCommentIfPresent(test_info);
if (GTEST_FLAG(print_time)) {
printf(" (%s ms)\n", internal::StreamableToString(
test_info.result()->elapsed_time()).c_str());
} else {
printf("\n");
}
fflush(stdout);
}
void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {
if (!GTEST_FLAG(print_time)) return;
const std::string counts =
FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
ColoredPrintf(COLOR_GREEN, "[----------] ");
printf("%s from %s (%s ms total)\n\n",
counts.c_str(), test_case.name(),
internal::StreamableToString(test_case.elapsed_time()).c_str());
fflush(stdout);
}
void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(
const UnitTest& /*unit_test*/) {
ColoredPrintf(COLOR_GREEN, "[----------] ");
printf("Global test environment tear-down\n");
fflush(stdout);
}
// Internal helper for printing the list of failed tests.
void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {
const int failed_test_count = unit_test.failed_test_count();
if (failed_test_count == 0) {
return;
}
for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
const TestCase& test_case = *unit_test.GetTestCase(i);
if (!test_case.should_run() || (test_case.failed_test_count() == 0)) {
continue;
}
for (int j = 0; j < test_case.total_test_count(); ++j) {
const TestInfo& test_info = *test_case.GetTestInfo(j);
if (!test_info.should_run() || test_info.result()->Passed()) {
continue;
}
ColoredPrintf(COLOR_RED, "[ FAILED ] ");
printf("%s.%s", test_case.name(), test_info.name());
PrintFullTestCommentIfPresent(test_info);
printf("\n");
}
}
}
void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
int /*iteration*/) {
ColoredPrintf(COLOR_GREEN, "[==========] ");
printf("%s from %s ran.",
FormatTestCount(unit_test.test_to_run_count()).c_str(),
FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());
if (GTEST_FLAG(print_time)) {
printf(" (%s ms total)",
internal::StreamableToString(unit_test.elapsed_time()).c_str());
}
printf("\n");
ColoredPrintf(COLOR_GREEN, "[ PASSED ] ");
printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str());
int num_failures = unit_test.failed_test_count();
if (!unit_test.Passed()) {
const int failed_test_count = unit_test.failed_test_count();
ColoredPrintf(COLOR_RED, "[ FAILED ] ");
printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str());
PrintFailedTests(unit_test);
printf("\n%2d FAILED %s\n", num_failures,
num_failures == 1 ? "TEST" : "TESTS");
}
int num_disabled = unit_test.reportable_disabled_test_count();
if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {
if (!num_failures) {
printf("\n"); // Add a spacer if no FAILURE banner is displayed.
}
ColoredPrintf(COLOR_YELLOW,
" YOU HAVE %d DISABLED %s\n\n",
num_disabled,
num_disabled == 1 ? "TEST" : "TESTS");
}
// Ensure that Google Test output is printed before, e.g., heapchecker output.
fflush(stdout);
}
// End PrettyUnitTestResultPrinter
// class TestEventRepeater
//
// This class forwards events to other event listeners.
class TestEventRepeater : public TestEventListener {
public:
TestEventRepeater() : forwarding_enabled_(true) {}
virtual ~TestEventRepeater();
void Append(TestEventListener *listener);
TestEventListener* Release(TestEventListener* listener);
// Controls whether events will be forwarded to listeners_. Set to false
// in death test child processes.
bool forwarding_enabled() const { return forwarding_enabled_; }
void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }
virtual void OnTestProgramStart(const UnitTest& unit_test);
virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);
virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);
virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);
virtual void OnTestCaseStart(const TestCase& test_case);
virtual void OnTestStart(const TestInfo& test_info);
virtual void OnTestPartResult(const TestPartResult& result);
virtual void OnTestEnd(const TestInfo& test_info);
virtual void OnTestCaseEnd(const TestCase& test_case);
virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);
virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
virtual void OnTestProgramEnd(const UnitTest& unit_test);
private:
// Controls whether events will be forwarded to listeners_. Set to false
// in death test child processes.
bool forwarding_enabled_;
// The list of listeners that receive events.
std::vector<TestEventListener*> listeners_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);
};
TestEventRepeater::~TestEventRepeater() {
ForEach(listeners_, Delete<TestEventListener>);
}
void TestEventRepeater::Append(TestEventListener *listener) {
listeners_.push_back(listener);
}
// TODO(vladl@google.com): Factor the search functionality into Vector::Find.
TestEventListener* TestEventRepeater::Release(TestEventListener *listener) {
for (size_t i = 0; i < listeners_.size(); ++i) {
if (listeners_[i] == listener) {
listeners_.erase(listeners_.begin() + i);
return listener;
}
}
return NULL;
}
// Since most methods are very similar, use macros to reduce boilerplate.
// This defines a member that forwards the call to all listeners.
#define GTEST_REPEATER_METHOD_(Name, Type) \
void TestEventRepeater::Name(const Type& parameter) { \
if (forwarding_enabled_) { \
for (size_t i = 0; i < listeners_.size(); i++) { \
listeners_[i]->Name(parameter); \
} \
} \
}
// This defines a member that forwards the call to all listeners in reverse
// order.
#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \
void TestEventRepeater::Name(const Type& parameter) { \
if (forwarding_enabled_) { \
for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \
listeners_[i]->Name(parameter); \
} \
} \
}
GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)
GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)
GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase)
GTEST_REPEATER_METHOD_(OnTestStart, TestInfo)
GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)
GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)
GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)
GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)
GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)
GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase)
GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)
#undef GTEST_REPEATER_METHOD_
#undef GTEST_REVERSE_REPEATER_METHOD_
void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,
int iteration) {
if (forwarding_enabled_) {
for (size_t i = 0; i < listeners_.size(); i++) {
listeners_[i]->OnTestIterationStart(unit_test, iteration);
}
}
}
void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,
int iteration) {
if (forwarding_enabled_) {
for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) {
listeners_[i]->OnTestIterationEnd(unit_test, iteration);
}
}
}
// End TestEventRepeater
// This class generates an XML output file.
class XmlUnitTestResultPrinter : public EmptyTestEventListener {
public:
explicit XmlUnitTestResultPrinter(const char* output_file);
virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);
private:
// Is c a whitespace character that is normalized to a space character
// when it appears in an XML attribute value?
static bool IsNormalizableWhitespace(char c) {
return c == 0x9 || c == 0xA || c == 0xD;
}
// May c appear in a well-formed XML document?
static bool IsValidXmlCharacter(char c) {
return IsNormalizableWhitespace(c) || c >= 0x20;
}
// Returns an XML-escaped copy of the input string str. If
// is_attribute is true, the text is meant to appear as an attribute
// value, and normalizable whitespace is preserved by replacing it
// with character references.
static std::string EscapeXml(const std::string& str, bool is_attribute);
// Returns the given string with all characters invalid in XML removed.
static std::string RemoveInvalidXmlCharacters(const std::string& str);
// Convenience wrapper around EscapeXml when str is an attribute value.
static std::string EscapeXmlAttribute(const std::string& str) {
return EscapeXml(str, true);
}
// Convenience wrapper around EscapeXml when str is not an attribute value.
static std::string EscapeXmlText(const char* str) {
return EscapeXml(str, false);
}
// Verifies that the given attribute belongs to the given element and
// streams the attribute as XML.
static void OutputXmlAttribute(std::ostream* stream,
const std::string& element_name,
const std::string& name,
const std::string& value);
// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
static void OutputXmlCDataSection(::std::ostream* stream, const char* data);
// Streams an XML representation of a TestInfo object.
static void OutputXmlTestInfo(::std::ostream* stream,
const char* test_case_name,
const TestInfo& test_info);
// Prints an XML representation of a TestCase object
static void PrintXmlTestCase(::std::ostream* stream,
const TestCase& test_case);
// Prints an XML summary of unit_test to output stream out.
static void PrintXmlUnitTest(::std::ostream* stream,
const UnitTest& unit_test);
// Produces a string representing the test properties in a result as space
// delimited XML attributes based on the property key="value" pairs.
// When the std::string is not empty, it includes a space at the beginning,
// to delimit this attribute from prior attributes.
static std::string TestPropertiesAsXmlAttributes(const TestResult& result);
// The output file.
const std::string output_file_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);
};
// Creates a new XmlUnitTestResultPrinter.
XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)
: output_file_(output_file) {
if (output_file_.c_str() == NULL || output_file_.empty()) {
GTEST_LOG_(FATAL) << "XML output file may not be null";
}
}
// Called after the unit test ends.
void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,
int /*iteration*/) {
FILE* xmlout = NULL;
FilePath output_file(output_file_);
FilePath output_dir(output_file.RemoveFileName());
if (output_dir.CreateDirectoriesRecursively()) {
xmlout = posix::FOpen(output_file_.c_str(), "w");
}
if (xmlout == NULL) {
// TODO(wan): report the reason of the failure.
//
// We don't do it for now as:
//
// 1. There is no urgent need for it.
// 2. It's a bit involved to make the errno variable thread-safe on
// all three operating systems (Linux, Windows, and Mac OS).
// 3. To interpret the meaning of errno in a thread-safe way,
// we need the strerror_r() function, which is not available on
// Windows.
GTEST_LOG_(FATAL) << "Unable to open file \""
<< output_file_ << "\"";
}
std::stringstream stream;
PrintXmlUnitTest(&stream, unit_test);
fprintf(xmlout, "%s", StringStreamToString(&stream).c_str());
fclose(xmlout);
}
// Returns an XML-escaped copy of the input string str. If is_attribute
// is true, the text is meant to appear as an attribute value, and
// normalizable whitespace is preserved by replacing it with character
// references.
//
// Invalid XML characters in str, if any, are stripped from the output.
// It is expected that most, if not all, of the text processed by this
// module will consist of ordinary English text.
// If this module is ever modified to produce version 1.1 XML output,
// most invalid characters can be retained using character references.
// TODO(wan): It might be nice to have a minimally invasive, human-readable
// escaping scheme for invalid characters, rather than dropping them.
std::string XmlUnitTestResultPrinter::EscapeXml(
const std::string& str, bool is_attribute) {
Message m;
for (size_t i = 0; i < str.size(); ++i) {
const char ch = str[i];
switch (ch) {
case '<':
m << "<";
break;
case '>':
m << ">";
break;
case '&':
m << "&";
break;
case '\'':
if (is_attribute)
m << "'";
else
m << '\'';
break;
case '"':
if (is_attribute)
m << """;
else
m << '"';
break;
default:
if (IsValidXmlCharacter(ch)) {
if (is_attribute && IsNormalizableWhitespace(ch))
m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch))
<< ";";
else
m << ch;
}
break;
}
}
return m.GetString();
}
// Returns the given string with all characters invalid in XML removed.
// Currently invalid characters are dropped from the string. An
// alternative is to replace them with certain characters such as . or ?.
std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(
const std::string& str) {
std::string output;
output.reserve(str.size());
for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
if (IsValidXmlCharacter(*it))
output.push_back(*it);
return output;
}
// The following routines generate an XML representation of a UnitTest
// object.
//
// This is how Google Test concepts map to the DTD:
//
// <testsuites name="AllTests"> <-- corresponds to a UnitTest object
// <testsuite name="testcase-name"> <-- corresponds to a TestCase object
// <testcase name="test-name"> <-- corresponds to a TestInfo object
// <failure message="...">...</failure>
// <failure message="...">...</failure>
// <failure message="...">...</failure>
// <-- individual assertion failures
// </testcase>
// </testsuite>
// </testsuites>
// Formats the given time in milliseconds as seconds.
std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {
::std::stringstream ss;
ss << (static_cast<double>(ms) * 1e-3);
return ss.str();
}
static bool PortableLocaltime(time_t seconds, struct tm* out) {
#if defined(_MSC_VER)
return localtime_s(out, &seconds) == 0;
#elif defined(__MINGW32__) || defined(__MINGW64__)
// MINGW <time.h> provides neither localtime_r nor localtime_s, but uses
// Windows' localtime(), which has a thread-local tm buffer.
struct tm* tm_ptr = localtime(&seconds); // NOLINT
if (tm_ptr == NULL)
return false;
*out = *tm_ptr;
return true;
#else
return localtime_r(&seconds, out) != NULL;
#endif
}
// Converts the given epoch time in milliseconds to a date string in the ISO
// 8601 format, without the timezone information.
std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) {
struct tm time_struct;
if (!PortableLocaltime(static_cast<time_t>(ms / 1000), &time_struct))
return "";
// YYYY-MM-DDThh:mm:ss
return StreamableToString(time_struct.tm_year + 1900) + "-" +
String::FormatIntWidth2(time_struct.tm_mon + 1) + "-" +
String::FormatIntWidth2(time_struct.tm_mday) + "T" +
String::FormatIntWidth2(time_struct.tm_hour) + ":" +
String::FormatIntWidth2(time_struct.tm_min) + ":" +
String::FormatIntWidth2(time_struct.tm_sec);
}
// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.
void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
const char* data) {
const char* segment = data;
*stream << "<![CDATA[";
for (;;) {
const char* const next_segment = strstr(segment, "]]>");
if (next_segment != NULL) {
stream->write(
segment, static_cast<std::streamsize>(next_segment - segment));
*stream << "]]>]]><![CDATA[";
segment = next_segment + strlen("]]>");
} else {
*stream << segment;
break;
}
}
*stream << "]]>";
}
void XmlUnitTestResultPrinter::OutputXmlAttribute(
std::ostream* stream,
const std::string& element_name,
const std::string& name,
const std::string& value) {
const std::vector<std::string>& allowed_names =
GetReservedAttributesForElement(element_name);
GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=
allowed_names.end())
<< "Attribute " << name << " is not allowed for element <" << element_name
<< ">.";
*stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\"";
}
// Prints an XML representation of a TestInfo object.
// TODO(wan): There is also value in printing properties with the plain printer.
void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,
const char* test_case_name,
const TestInfo& test_info) {
const TestResult& result = *test_info.result();
const std::string kTestcase = "testcase";
*stream << " <testcase";
OutputXmlAttribute(stream, kTestcase, "name", test_info.name());
if (test_info.value_param() != NULL) {
OutputXmlAttribute(stream, kTestcase, "value_param",
test_info.value_param());
}
if (test_info.type_param() != NULL) {
OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param());
}
OutputXmlAttribute(stream, kTestcase, "status",
test_info.should_run() ? "run" : "notrun");
OutputXmlAttribute(stream, kTestcase, "time",
FormatTimeInMillisAsSeconds(result.elapsed_time()));
OutputXmlAttribute(stream, kTestcase, "classname", test_case_name);
*stream << TestPropertiesAsXmlAttributes(result);
int failures = 0;
for (int i = 0; i < result.total_part_count(); ++i) {
const TestPartResult& part = result.GetTestPartResult(i);
if (part.failed()) {
if (++failures == 1) {
*stream << ">\n";
}
const std::string location =
internal::FormatCompilerIndependentFileLocation(part.file_name(),
part.line_number());
const std::string summary = location + "\n" + part.summary();
*stream << " <failure message=\""
<< EscapeXmlAttribute(summary.c_str())
<< "\" type=\"\">";
const std::string detail = location + "\n" + part.message();
OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());
*stream << "</failure>\n";
}
}
if (failures == 0)
*stream << " />\n";
else
*stream << " </testcase>\n";
}
// Prints an XML representation of a TestCase object
void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,
const TestCase& test_case) {
const std::string kTestsuite = "testsuite";
*stream << " <" << kTestsuite;
OutputXmlAttribute(stream, kTestsuite, "name", test_case.name());
OutputXmlAttribute(stream, kTestsuite, "tests",
StreamableToString(test_case.reportable_test_count()));
OutputXmlAttribute(stream, kTestsuite, "failures",
StreamableToString(test_case.failed_test_count()));
OutputXmlAttribute(
stream, kTestsuite, "disabled",
StreamableToString(test_case.reportable_disabled_test_count()));
OutputXmlAttribute(stream, kTestsuite, "errors", "0");
OutputXmlAttribute(stream, kTestsuite, "time",
FormatTimeInMillisAsSeconds(test_case.elapsed_time()));
*stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result())
<< ">\n";
for (int i = 0; i < test_case.total_test_count(); ++i) {
if (test_case.GetTestInfo(i)->is_reportable())
OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i));
}
*stream << " </" << kTestsuite << ">\n";
}
// Prints an XML summary of unit_test to output stream out.
void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,
const UnitTest& unit_test) {
const std::string kTestsuites = "testsuites";
*stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
*stream << "<" << kTestsuites;
OutputXmlAttribute(stream, kTestsuites, "tests",
StreamableToString(unit_test.reportable_test_count()));
OutputXmlAttribute(stream, kTestsuites, "failures",
StreamableToString(unit_test.failed_test_count()));
OutputXmlAttribute(
stream, kTestsuites, "disabled",
StreamableToString(unit_test.reportable_disabled_test_count()));
OutputXmlAttribute(stream, kTestsuites, "errors", "0");
OutputXmlAttribute(
stream, kTestsuites, "timestamp",
FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));
OutputXmlAttribute(stream, kTestsuites, "time",
FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));
if (GTEST_FLAG(shuffle)) {
OutputXmlAttribute(stream, kTestsuites, "random_seed",
StreamableToString(unit_test.random_seed()));
}
*stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());
OutputXmlAttribute(stream, kTestsuites, "name", "AllTests");
*stream << ">\n";
for (int i = 0; i < unit_test.total_test_case_count(); ++i) {
if (unit_test.GetTestCase(i)->reportable_test_count() > 0)
PrintXmlTestCase(stream, *unit_test.GetTestCase(i));
}
*stream << "</" << kTestsuites << ">\n";
}
// Produces a string representing the test properties in a result as space
// delimited XML attributes based on the property key="value" pairs.
std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(
const TestResult& result) {
Message attributes;
for (int i = 0; i < result.test_property_count(); ++i) {
const TestProperty& property = result.GetTestProperty(i);
attributes << " " << property.key() << "="
<< "\"" << EscapeXmlAttribute(property.value()) << "\"";
}
return attributes.GetString();
}
// End XmlUnitTestResultPrinter
#if GTEST_CAN_STREAM_RESULTS_
// Checks if str contains '=', '&', '%' or '\n' characters. If yes,
// replaces them by "%xx" where xx is their hexadecimal value. For
// example, replaces "=" with "%3D". This algorithm is O(strlen(str))
// in both time and space -- important as the input str may contain an
// arbitrarily long test failure message and stack trace.
std::string StreamingListener::UrlEncode(const char* str) {
std::string result;
result.reserve(strlen(str) + 1);
for (char ch = *str; ch != '\0'; ch = *++str) {
switch (ch) {
case '%':
case '=':
case '&':
case '\n':
result.append("%" + String::FormatByte(static_cast<unsigned char>(ch)));
break;
default:
result.push_back(ch);
break;
}
}
return result;
}
void StreamingListener::SocketWriter::MakeConnection() {
GTEST_CHECK_(sockfd_ == -1)
<< "MakeConnection() can't be called when there is already a connection.";
addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses.
hints.ai_socktype = SOCK_STREAM;
addrinfo* servinfo = NULL;
// Use the getaddrinfo() to get a linked list of IP addresses for
// the given host name.
const int error_num = getaddrinfo(
host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);
if (error_num != 0) {
GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: "
<< gai_strerror(error_num);
}
// Loop through all the results and connect to the first we can.
for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL;
cur_addr = cur_addr->ai_next) {
sockfd_ = socket(
cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);
if (sockfd_ != -1) {
// Connect the client socket to the server socket.
if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {
close(sockfd_);
sockfd_ = -1;
}
}
}
freeaddrinfo(servinfo); // all done with this structure
if (sockfd_ == -1) {
GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to "
<< host_name_ << ":" << port_num_;
}
}
// End of class Streaming Listener
#endif // GTEST_CAN_STREAM_RESULTS__
// Class ScopedTrace
// Pushes the given source file location and message onto a per-thread
// trace stack maintained by Google Test.
ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
TraceInfo trace;
trace.file = file;
trace.line = line;
trace.message = message.GetString();
UnitTest::GetInstance()->PushGTestTrace(trace);
}
// Pops the info pushed by the c'tor.
ScopedTrace::~ScopedTrace()
GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
UnitTest::GetInstance()->PopGTestTrace();
}
// class OsStackTraceGetter
const char* const OsStackTraceGetterInterface::kElidedFramesMarker =
"... " GTEST_NAME_ " internal frames ...";
std::string OsStackTraceGetter::CurrentStackTrace(int /*max_depth*/,
int /*skip_count*/) {
return "";
}
void OsStackTraceGetter::UponLeavingGTest() {}
// A helper class that creates the premature-exit file in its
// constructor and deletes the file in its destructor.
class ScopedPrematureExitFile {
public:
explicit ScopedPrematureExitFile(const char* premature_exit_filepath)
: premature_exit_filepath_(premature_exit_filepath) {
// If a path to the premature-exit file is specified...
if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') {
// create the file with a single "0" character in it. I/O
// errors are ignored as there's nothing better we can do and we
// don't want to fail the test because of this.
FILE* pfile = posix::FOpen(premature_exit_filepath, "w");
fwrite("0", 1, 1, pfile);
fclose(pfile);
}
}
~ScopedPrematureExitFile() {
if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') {
remove(premature_exit_filepath_);
}
}
private:
const char* const premature_exit_filepath_;
GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);
};
} // namespace internal
// class TestEventListeners
TestEventListeners::TestEventListeners()
: repeater_(new internal::TestEventRepeater()),
default_result_printer_(NULL),
default_xml_generator_(NULL) {
}
TestEventListeners::~TestEventListeners() { delete repeater_; }
// Returns the standard listener responsible for the default console
// output. Can be removed from the listeners list to shut down default
// console output. Note that removing this object from the listener list
// with Release transfers its ownership to the user.
void TestEventListeners::Append(TestEventListener* listener) {
repeater_->Append(listener);
}
// Removes the given event listener from the list and returns it. It then
// becomes the caller's responsibility to delete the listener. Returns
// NULL if the listener is not found in the list.
TestEventListener* TestEventListeners::Release(TestEventListener* listener) {
if (listener == default_result_printer_)
default_result_printer_ = NULL;
else if (listener == default_xml_generator_)
default_xml_generator_ = NULL;
return repeater_->Release(listener);
}
// Returns repeater that broadcasts the TestEventListener events to all
// subscribers.
TestEventListener* TestEventListeners::repeater() { return repeater_; }
// Sets the default_result_printer attribute to the provided listener.
// The listener is also added to the listener list and previous
// default_result_printer is removed from it and deleted. The listener can
// also be NULL in which case it will not be added to the list. Does
// nothing if the previous and the current listener objects are the same.
void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {
if (default_result_printer_ != listener) {
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_result_printer_);
default_result_printer_ = listener;
if (listener != NULL)
Append(listener);
}
}
// Sets the default_xml_generator attribute to the provided listener. The
// listener is also added to the listener list and previous
// default_xml_generator is removed from it and deleted. The listener can
// also be NULL in which case it will not be added to the list. Does
// nothing if the previous and the current listener objects are the same.
void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {
if (default_xml_generator_ != listener) {
// It is an error to pass this method a listener that is already in the
// list.
delete Release(default_xml_generator_);
default_xml_generator_ = listener;
if (listener != NULL)
Append(listener);
}
}
// Controls whether events will be forwarded by the repeater to the
// listeners in the list.
bool TestEventListeners::EventForwardingEnabled() const {
return repeater_->forwarding_enabled();
}
void TestEventListeners::SuppressEventForwarding() {
repeater_->set_forwarding_enabled(false);
}
// class UnitTest
// Gets the singleton UnitTest object. The first time this method is
// called, a UnitTest object is constructed and returned. Consecutive
// calls will return the same object.
//
// We don't protect this under mutex_ as a user is not supposed to
// call this before main() starts, from which point on the return
// value will never change.
UnitTest* UnitTest::GetInstance() {
// When compiled with MSVC 7.1 in optimized mode, destroying the
// UnitTest object upon exiting the program messes up the exit code,
// causing successful tests to appear failed. We have to use a
// different implementation in this case to bypass the compiler bug.
// This implementation makes the compiler happy, at the cost of
// leaking the UnitTest object.
// CodeGear C++Builder insists on a public destructor for the
// default implementation. Use this implementation to keep good OO
// design with private destructor.
#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
static UnitTest* const instance = new UnitTest;
return instance;
#else
static UnitTest instance;
return &instance;
#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)
}
// Gets the number of successful test cases.
int UnitTest::successful_test_case_count() const {
return impl()->successful_test_case_count();
}
// Gets the number of failed test cases.
int UnitTest::failed_test_case_count() const {
return impl()->failed_test_case_count();
}
// Gets the number of all test cases.
int UnitTest::total_test_case_count() const {
return impl()->total_test_case_count();
}
// Gets the number of all test cases that contain at least one test
// that should run.
int UnitTest::test_case_to_run_count() const {
return impl()->test_case_to_run_count();
}
// Gets the number of successful tests.
int UnitTest::successful_test_count() const {
return impl()->successful_test_count();
}
// Gets the number of failed tests.
int UnitTest::failed_test_count() const { return impl()->failed_test_count(); }
// Gets the number of disabled tests that will be reported in the XML report.
int UnitTest::reportable_disabled_test_count() const {
return impl()->reportable_disabled_test_count();
}
// Gets the number of disabled tests.
int UnitTest::disabled_test_count() const {
return impl()->disabled_test_count();
}
// Gets the number of tests to be printed in the XML report.
int UnitTest::reportable_test_count() const {
return impl()->reportable_test_count();
}
// Gets the number of all tests.
int UnitTest::total_test_count() const { return impl()->total_test_count(); }
// Gets the number of tests that should run.
int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }
// Gets the time of the test program start, in ms from the start of the
// UNIX epoch.
internal::TimeInMillis UnitTest::start_timestamp() const {
return impl()->start_timestamp();
}
// Gets the elapsed time, in milliseconds.
internal::TimeInMillis UnitTest::elapsed_time() const {
return impl()->elapsed_time();
}
// Returns true iff the unit test passed (i.e. all test cases passed).
bool UnitTest::Passed() const { return impl()->Passed(); }
// Returns true iff the unit test failed (i.e. some test case failed
// or something outside of all tests failed).
bool UnitTest::Failed() const { return impl()->Failed(); }
// Gets the i-th test case among all the test cases. i can range from 0 to
// total_test_case_count() - 1. If i is not in that range, returns NULL.
const TestCase* UnitTest::GetTestCase(int i) const {
return impl()->GetTestCase(i);
}
// Returns the TestResult containing information on test failures and
// properties logged outside of individual test cases.
const TestResult& UnitTest::ad_hoc_test_result() const {
return *impl()->ad_hoc_test_result();
}
// Gets the i-th test case among all the test cases. i can range from 0 to
// total_test_case_count() - 1. If i is not in that range, returns NULL.
TestCase* UnitTest::GetMutableTestCase(int i) {
return impl()->GetMutableTestCase(i);
}
// Returns the list of event listeners that can be used to track events
// inside Google Test.
TestEventListeners& UnitTest::listeners() {
return *impl()->listeners();
}
// Registers and returns a global test environment. When a test
// program is run, all global test environments will be set-up in the
// order they were registered. After all tests in the program have
// finished, all global test environments will be torn-down in the
// *reverse* order they were registered.
//
// The UnitTest object takes ownership of the given environment.
//
// We don't protect this under mutex_, as we only support calling it
// from the main thread.
Environment* UnitTest::AddEnvironment(Environment* env) {
if (env == NULL) {
return NULL;
}
impl_->environments().push_back(env);
return env;
}
// Adds a TestPartResult to the current TestResult object. All Google Test
// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call
// this to report their results. The user code should use the
// assertion macros instead of calling this directly.
void UnitTest::AddTestPartResult(
TestPartResult::Type result_type,
const char* file_name,
int line_number,
const std::string& message,
const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {
Message msg;
msg << message;
internal::MutexLock lock(&mutex_);
if (impl_->gtest_trace_stack().size() > 0) {
msg << "\n" << GTEST_NAME_ << " trace:";
for (int i = static_cast<int>(impl_->gtest_trace_stack().size());
i > 0; --i) {
const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];
msg << "\n" << internal::FormatFileLocation(trace.file, trace.line)
<< " " << trace.message;
}
}
if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) {
msg << internal::kStackTraceMarker << os_stack_trace;
}
const TestPartResult result =
TestPartResult(result_type, file_name, line_number,
msg.GetString().c_str());
impl_->GetTestPartResultReporterForCurrentThread()->
ReportTestPartResult(result);
if (result_type != TestPartResult::kSuccess) {
// gtest_break_on_failure takes precedence over
// gtest_throw_on_failure. This allows a user to set the latter
// in the code (perhaps in order to use Google Test assertions
// with another testing framework) and specify the former on the
// command line for debugging.
if (GTEST_FLAG(break_on_failure)) {
#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
// Using DebugBreak on Windows allows gtest to still break into a debugger
// when a failure happens and both the --gtest_break_on_failure and
// the --gtest_catch_exceptions flags are specified.
DebugBreak();
#else
// Dereference NULL through a volatile pointer to prevent the compiler
// from removing. We use this rather than abort() or __builtin_trap() for
// portability: Symbian doesn't implement abort() well, and some debuggers
// don't correctly trap abort().
*static_cast<volatile int*>(NULL) = 1;
#endif // GTEST_OS_WINDOWS
} else if (GTEST_FLAG(throw_on_failure)) {
#if GTEST_HAS_EXCEPTIONS
throw internal::GoogleTestFailureException(result);
#else
// We cannot call abort() as it generates a pop-up in debug mode
// that cannot be suppressed in VC 7.1 or below.
exit(1);
#endif
}
}
}
// Adds a TestProperty to the current TestResult object when invoked from
// inside a test, to current TestCase's ad_hoc_test_result_ when invoked
// from SetUpTestCase or TearDownTestCase, or to the global property set
// when invoked elsewhere. If the result already contains a property with
// the same key, the value will be updated.
void UnitTest::RecordProperty(const std::string& key,
const std::string& value) {
impl_->RecordProperty(TestProperty(key, value));
}
// Runs all tests in this UnitTest object and prints the result.
// Returns 0 if successful, or 1 otherwise.
//
// We don't protect this under mutex_, as we only support calling it
// from the main thread.
int UnitTest::Run() {
const bool in_death_test_child_process =
internal::GTEST_FLAG(internal_run_death_test).length() > 0;
// Google Test implements this protocol for catching that a test
// program exits before returning control to Google Test:
//
// 1. Upon start, Google Test creates a file whose absolute path
// is specified by the environment variable
// TEST_PREMATURE_EXIT_FILE.
// 2. When Google Test has finished its work, it deletes the file.
//
// This allows a test runner to set TEST_PREMATURE_EXIT_FILE before
// running a Google-Test-based test program and check the existence
// of the file at the end of the test execution to see if it has
// exited prematurely.
// If we are in the child process of a death test, don't
// create/delete the premature exit file, as doing so is unnecessary
// and will confuse the parent process. Otherwise, create/delete
// the file upon entering/leaving this function. If the program
// somehow exits before this function has a chance to return, the
// premature-exit file will be left undeleted, causing a test runner
// that understands the premature-exit-file protocol to report the
// test as having failed.
const internal::ScopedPrematureExitFile premature_exit_file(
in_death_test_child_process ?
NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
// used for the duration of the program.
impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));
#if GTEST_HAS_SEH
// Either the user wants Google Test to catch exceptions thrown by the
// tests or this is executing in the context of death test child
// process. In either case the user does not want to see pop-up dialogs
// about crashes - they are expected.
if (impl()->catch_exceptions() || in_death_test_child_process) {
# if !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT
// SetErrorMode doesn't exist on CE.
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
# endif // !GTEST_OS_WINDOWS_MOBILE
# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE
// Death test children can be terminated with _abort(). On Windows,
// _abort() can show a dialog with a warning message. This forces the
// abort message to go to stderr instead.
_set_error_mode(_OUT_TO_STDERR);
# endif
# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE
// In the debug version, Visual Studio pops up a separate dialog
// offering a choice to debug the aborted program. We need to suppress
// this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement
// executed. Google Test will notify the user of any unexpected
// failure via stderr.
//
// VC++ doesn't define _set_abort_behavior() prior to the version 8.0.
// Users of prior VC versions shall suffer the agony and pain of
// clicking through the countless debug dialogs.
// TODO(vladl@google.com): find a way to suppress the abort dialog() in the
// debug mode when compiled with VC 7.1 or lower.
if (!GTEST_FLAG(break_on_failure))
_set_abort_behavior(
0x0, // Clear the following flags:
_WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump.
# endif
}
#endif // GTEST_HAS_SEH
return internal::HandleExceptionsInMethodIfSupported(
impl(),
&internal::UnitTestImpl::RunAllTests,
"auxiliary test code (environments or event listeners)") ? 0 : 1;
}
// Returns the working directory when the first TEST() or TEST_F() was
// executed.
const char* UnitTest::original_working_dir() const {
return impl_->original_working_dir_.c_str();
}
// Returns the TestCase object for the test that's currently running,
// or NULL if no test is running.
const TestCase* UnitTest::current_test_case() const
GTEST_LOCK_EXCLUDED_(mutex_) {
internal::MutexLock lock(&mutex_);
return impl_->current_test_case();
}
// Returns the TestInfo object for the test that's currently running,
// or NULL if no test is running.
const TestInfo* UnitTest::current_test_info() const
GTEST_LOCK_EXCLUDED_(mutex_) {
internal::MutexLock lock(&mutex_);
return impl_->current_test_info();
}
// Returns the random seed used at the start of the current test run.
int UnitTest::random_seed() const { return impl_->random_seed(); }
// Returns ParameterizedTestCaseRegistry object used to keep track of
// value-parameterized tests and instantiate and register them.
internal::ParameterizedTestCaseRegistry&
UnitTest::parameterized_test_registry()
GTEST_LOCK_EXCLUDED_(mutex_) {
return impl_->parameterized_test_registry();
}
// Creates an empty UnitTest.
UnitTest::UnitTest() {
impl_ = new internal::UnitTestImpl(this);
}
// Destructor of UnitTest.
UnitTest::~UnitTest() {
delete impl_;
}
// Pushes a trace defined by SCOPED_TRACE() on to the per-thread
// Google Test trace stack.
void UnitTest::PushGTestTrace(const internal::TraceInfo& trace)
GTEST_LOCK_EXCLUDED_(mutex_) {
internal::MutexLock lock(&mutex_);
impl_->gtest_trace_stack().push_back(trace);
}
// Pops a trace from the per-thread Google Test trace stack.
void UnitTest::PopGTestTrace()
GTEST_LOCK_EXCLUDED_(mutex_) {
internal::MutexLock lock(&mutex_);
impl_->gtest_trace_stack().pop_back();
}
namespace internal {
UnitTestImpl::UnitTestImpl(UnitTest* parent)
: parent_(parent),
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */)
default_global_test_part_result_reporter_(this),
default_per_thread_test_part_result_reporter_(this),
GTEST_DISABLE_MSC_WARNINGS_POP_()
global_test_part_result_repoter_(
&default_global_test_part_result_reporter_),
per_thread_test_part_result_reporter_(
&default_per_thread_test_part_result_reporter_),
parameterized_test_registry_(),
parameterized_tests_registered_(false),
last_death_test_case_(-1),
current_test_case_(NULL),
current_test_info_(NULL),
ad_hoc_test_result_(),
os_stack_trace_getter_(NULL),
post_flag_parse_init_performed_(false),
random_seed_(0), // Will be overridden by the flag before first use.
random_(0), // Will be reseeded before first use.
start_timestamp_(0),
elapsed_time_(0),
#if GTEST_HAS_DEATH_TEST
death_test_factory_(new DefaultDeathTestFactory),
#endif
// Will be overridden by the flag before first use.
catch_exceptions_(false) {
listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);
}
UnitTestImpl::~UnitTestImpl() {
// Deletes every TestCase.
ForEach(test_cases_, internal::Delete<TestCase>);
// Deletes every Environment.
ForEach(environments_, internal::Delete<Environment>);
delete os_stack_trace_getter_;
}
// Adds a TestProperty to the current TestResult object when invoked in a
// context of a test, to current test case's ad_hoc_test_result when invoke
// from SetUpTestCase/TearDownTestCase, or to the global property set
// otherwise. If the result already contains a property with the same key,
// the value will be updated.
void UnitTestImpl::RecordProperty(const TestProperty& test_property) {
std::string xml_element;
TestResult* test_result; // TestResult appropriate for property recording.
if (current_test_info_ != NULL) {
xml_element = "testcase";
test_result = &(current_test_info_->result_);
} else if (current_test_case_ != NULL) {
xml_element = "testsuite";
test_result = &(current_test_case_->ad_hoc_test_result_);
} else {
xml_element = "testsuites";
test_result = &ad_hoc_test_result_;
}
test_result->RecordProperty(xml_element, test_property);
}
#if GTEST_HAS_DEATH_TEST
// Disables event forwarding if the control is currently in a death test
// subprocess. Must not be called before InitGoogleTest.
void UnitTestImpl::SuppressTestEventsIfInSubprocess() {
if (internal_run_death_test_flag_.get() != NULL)
listeners()->SuppressEventForwarding();
}
#endif // GTEST_HAS_DEATH_TEST
// Initializes event listeners performing XML output as specified by
// UnitTestOptions. Must not be called before InitGoogleTest.
void UnitTestImpl::ConfigureXmlOutput() {
const std::string& output_format = UnitTestOptions::GetOutputFormat();
if (output_format == "xml") {
listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));
} else if (output_format != "") {
GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
<< output_format
<< "\" ignored.";
}
}
#if GTEST_CAN_STREAM_RESULTS_
// Initializes event listeners for streaming test results in string form.
// Must not be called before InitGoogleTest.
void UnitTestImpl::ConfigureStreamingOutput() {
const std::string& target = GTEST_FLAG(stream_result_to);
if (!target.empty()) {
const size_t pos = target.find(':');
if (pos != std::string::npos) {
listeners()->Append(new StreamingListener(target.substr(0, pos),
target.substr(pos+1)));
} else {
GTEST_LOG_(WARNING) << "unrecognized streaming target \""
<< target
<< "\" ignored.";
}
}
}
#endif // GTEST_CAN_STREAM_RESULTS_
// Performs initialization dependent upon flag values obtained in
// ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to
// ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest
// this function is also called from RunAllTests. Since this function can be
// called more than once, it has to be idempotent.
void UnitTestImpl::PostFlagParsingInit() {
// Ensures that this function does not execute more than once.
if (!post_flag_parse_init_performed_) {
post_flag_parse_init_performed_ = true;
#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
// Register to send notifications about key process state changes.
listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());
#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
#if GTEST_HAS_DEATH_TEST
InitDeathTestSubprocessControlInfo();
SuppressTestEventsIfInSubprocess();
#endif // GTEST_HAS_DEATH_TEST
// Registers parameterized tests. This makes parameterized tests
// available to the UnitTest reflection API without running
// RUN_ALL_TESTS.
RegisterParameterizedTests();
// Configures listeners for XML output. This makes it possible for users
// to shut down the default XML output before invoking RUN_ALL_TESTS.
ConfigureXmlOutput();
#if GTEST_CAN_STREAM_RESULTS_
// Configures listeners for streaming test results to the specified server.
ConfigureStreamingOutput();
#endif // GTEST_CAN_STREAM_RESULTS_
}
}
// A predicate that checks the name of a TestCase against a known
// value.
//
// This is used for implementation of the UnitTest class only. We put
// it in the anonymous namespace to prevent polluting the outer
// namespace.
//
// TestCaseNameIs is copyable.
class TestCaseNameIs {
public:
// Constructor.
explicit TestCaseNameIs(const std::string& name)
: name_(name) {}
// Returns true iff the name of test_case matches name_.
bool operator()(const TestCase* test_case) const {
return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0;
}
private:
std::string name_;
};
// Finds and returns a TestCase with the given name. If one doesn't
// exist, creates one and returns it. It's the CALLER'S
// RESPONSIBILITY to ensure that this function is only called WHEN THE
// TESTS ARE NOT SHUFFLED.
//
// Arguments:
//
// test_case_name: name of the test case
// type_param: the name of the test case's type parameter, or NULL if
// this is not a typed or a type-parameterized test case.
// set_up_tc: pointer to the function that sets up the test case
// tear_down_tc: pointer to the function that tears down the test case
TestCase* UnitTestImpl::GetTestCase(const char* test_case_name,
const char* type_param,
Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc) {
// Can we find a TestCase with the given name?
const std::vector<TestCase*>::const_iterator test_case =
std::find_if(test_cases_.begin(), test_cases_.end(),
TestCaseNameIs(test_case_name));
if (test_case != test_cases_.end())
return *test_case;
// No. Let's create one.
TestCase* const new_test_case =
new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);
// Is this a death test case?
if (internal::UnitTestOptions::MatchesFilter(test_case_name,
kDeathTestCaseFilter)) {
// Yes. Inserts the test case after the last death test case
// defined so far. This only works when the test cases haven't
// been shuffled. Otherwise we may end up running a death test
// after a non-death test.
++last_death_test_case_;
test_cases_.insert(test_cases_.begin() + last_death_test_case_,
new_test_case);
} else {
// No. Appends to the end of the list.
test_cases_.push_back(new_test_case);
}
test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));
return new_test_case;
}
// Helpers for setting up / tearing down the given environment. They
// are for use in the ForEach() function.
static void SetUpEnvironment(Environment* env) { env->SetUp(); }
static void TearDownEnvironment(Environment* env) { env->TearDown(); }
// Runs all tests in this UnitTest object, prints the result, and
// returns true if all tests are successful. If any exception is
// thrown during a test, the test is considered to be failed, but the
// rest of the tests will still be run.
//
// When parameterized tests are enabled, it expands and registers
// parameterized tests first in RegisterParameterizedTests().
// All other functions called from RunAllTests() may safely assume that
// parameterized tests are ready to be counted and run.
bool UnitTestImpl::RunAllTests() {
// Makes sure InitGoogleTest() was called.
if (!GTestIsInitialized()) {
GTEST_LOG_(ERROR) <<
"\nThis test program did NOT call ::testing::InitGoogleTest "
"before calling RUN_ALL_TESTS(). Please fix it.";
return false;
}
// Do not run any test if the --help flag was specified.
if (g_help_flag)
return true;
// Repeats the call to the post-flag parsing initialization in case the
// user didn't call InitGoogleTest.
PostFlagParsingInit();
// Even if sharding is not on, test runners may want to use the
// GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
// protocol.
internal::WriteToShardStatusFileIfNeeded();
// True iff we are in a subprocess for running a thread-safe-style
// death test.
bool in_subprocess_for_death_test = false;
#if GTEST_HAS_DEATH_TEST
in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
if (in_subprocess_for_death_test) {
GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
}
# endif // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
#endif // GTEST_HAS_DEATH_TEST
const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
in_subprocess_for_death_test);
// Compares the full test names with the filter to decide which
// tests to run.
const bool has_tests_to_run = FilterTests(should_shard
? HONOR_SHARDING_PROTOCOL
: IGNORE_SHARDING_PROTOCOL) > 0;
// Lists the tests and exits if the --gtest_list_tests flag was specified.
if (GTEST_FLAG(list_tests)) {
// This must be called *after* FilterTests() has been called.
ListTestsMatchingFilter();
return true;
}
random_seed_ = GTEST_FLAG(shuffle) ?
GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
// True iff at least one test has failed.
bool failed = false;
TestEventListener* repeater = listeners()->repeater();
start_timestamp_ = GetTimeInMillis();
repeater->OnTestProgramStart(*parent_);
// How many times to repeat the tests? We don't want to repeat them
// when we are inside the subprocess of a death test.
const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
// Repeats forever if the repeat count is negative.
const bool forever = repeat < 0;
for (int i = 0; forever || i != repeat; i++) {
// We want to preserve failures generated by ad-hoc test
// assertions executed before RUN_ALL_TESTS().
ClearNonAdHocTestResult();
const TimeInMillis start = GetTimeInMillis();
// Shuffles test cases and tests if requested.
if (has_tests_to_run && GTEST_FLAG(shuffle)) {
random()->Reseed(random_seed_);
// This should be done before calling OnTestIterationStart(),
// such that a test event listener can see the actual test order
// in the event.
ShuffleTests();
}
// Tells the unit test event listeners that the tests are about to start.
repeater->OnTestIterationStart(*parent_, i);
// Runs each test case if there is at least one test to run.
if (has_tests_to_run) {
// Sets up all environments beforehand.
repeater->OnEnvironmentsSetUpStart(*parent_);
ForEach(environments_, SetUpEnvironment);
repeater->OnEnvironmentsSetUpEnd(*parent_);
// Runs the tests only if there was no fatal failure during global
// set-up.
if (!Test::HasFatalFailure()) {
for (int test_index = 0; test_index < total_test_case_count();
test_index++) {
GetMutableTestCase(test_index)->Run();
}
}
// Tears down all environments in reverse order afterwards.
repeater->OnEnvironmentsTearDownStart(*parent_);
std::for_each(environments_.rbegin(), environments_.rend(),
TearDownEnvironment);
repeater->OnEnvironmentsTearDownEnd(*parent_);
}
elapsed_time_ = GetTimeInMillis() - start;
// Tells the unit test event listener that the tests have just finished.
repeater->OnTestIterationEnd(*parent_, i);
// Gets the result and clears it.
if (!Passed()) {
failed = true;
}
// Restores the original test order after the iteration. This
// allows the user to quickly repro a failure that happens in the
// N-th iteration without repeating the first (N - 1) iterations.
// This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
// case the user somehow changes the value of the flag somewhere
// (it's always safe to unshuffle the tests).
UnshuffleTests();
if (GTEST_FLAG(shuffle)) {
// Picks a new random seed for each iteration.
random_seed_ = GetNextRandomSeed(random_seed_);
}
}
repeater->OnTestProgramEnd(*parent_);
return !failed;
}
// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file
// if the variable is present. If a file already exists at this location, this
// function will write over it. If the variable is present, but the file cannot
// be created, prints an error and exits.
void WriteToShardStatusFileIfNeeded() {
const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);
if (test_shard_file != NULL) {
FILE* const file = posix::FOpen(test_shard_file, "w");
if (file == NULL) {
ColoredPrintf(COLOR_RED,
"Could not write to the test shard status file \"%s\" "
"specified by the %s environment variable.\n",
test_shard_file, kTestShardStatusFile);
fflush(stdout);
exit(EXIT_FAILURE);
}
fclose(file);
}
}
// Checks whether sharding is enabled by examining the relevant
// environment variable values. If the variables are present,
// but inconsistent (i.e., shard_index >= total_shards), prints
// an error and exits. If in_subprocess_for_death_test, sharding is
// disabled because it must only be applied to the original test
// process. Otherwise, we could filter out death tests we intended to execute.
bool ShouldShard(const char* total_shards_env,
const char* shard_index_env,
bool in_subprocess_for_death_test) {
if (in_subprocess_for_death_test) {
return false;
}
const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);
const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);
if (total_shards == -1 && shard_index == -1) {
return false;
} else if (total_shards == -1 && shard_index != -1) {
const Message msg = Message()
<< "Invalid environment variables: you have "
<< kTestShardIndex << " = " << shard_index
<< ", but have left " << kTestTotalShards << " unset.\n";
ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} else if (total_shards != -1 && shard_index == -1) {
const Message msg = Message()
<< "Invalid environment variables: you have "
<< kTestTotalShards << " = " << total_shards
<< ", but have left " << kTestShardIndex << " unset.\n";
ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
} else if (shard_index < 0 || shard_index >= total_shards) {
const Message msg = Message()
<< "Invalid environment variables: we require 0 <= "
<< kTestShardIndex << " < " << kTestTotalShards
<< ", but you have " << kTestShardIndex << "=" << shard_index
<< ", " << kTestTotalShards << "=" << total_shards << ".\n";
ColoredPrintf(COLOR_RED, "%s", msg.GetString().c_str());
fflush(stdout);
exit(EXIT_FAILURE);
}
return total_shards > 1;
}
// Parses the environment variable var as an Int32. If it is unset,
// returns default_val. If it is not an Int32, prints an error
// and aborts.
Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
const char* str_val = posix::GetEnv(var);
if (str_val == NULL) {
return default_val;
}
Int32 result;
if (!ParseInt32(Message() << "The value of environment variable " << var,
str_val, &result)) {
exit(EXIT_FAILURE);
}
return result;
}
// Given the total number of shards, the shard index, and the test id,
// returns true iff the test should be run on this shard. The test id is
// some arbitrary but unique non-negative integer assigned to each test
// method. Assumes that 0 <= shard_index < total_shards.
bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
return (test_id % total_shards) == shard_index;
}
// Compares the name of each test with the user-specified filter to
// decide whether the test should be run, then records the result in
// each TestCase and TestInfo object.
// If shard_tests == true, further filters tests based on sharding
// variables in the environment - see
// https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md .
// Returns the number of tests that should run.
int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
Int32FromEnvOrDie(kTestTotalShards, -1) : -1;
const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
Int32FromEnvOrDie(kTestShardIndex, -1) : -1;
// num_runnable_tests are the number of tests that will
// run across all shards (i.e., match filter and are not disabled).
// num_selected_tests are the number of tests to be run on
// this shard.
int num_runnable_tests = 0;
int num_selected_tests = 0;
for (size_t i = 0; i < test_cases_.size(); i++) {
TestCase* const test_case = test_cases_[i];
const std::string &test_case_name = test_case->name();
test_case->set_should_run(false);
for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
TestInfo* const test_info = test_case->test_info_list()[j];
const std::string test_name(test_info->name());
// A test is disabled if test case name or test name matches
// kDisableTestFilter.
const bool is_disabled =
internal::UnitTestOptions::MatchesFilter(test_case_name,
kDisableTestFilter) ||
internal::UnitTestOptions::MatchesFilter(test_name,
kDisableTestFilter);
test_info->is_disabled_ = is_disabled;
const bool matches_filter =
internal::UnitTestOptions::FilterMatchesTest(test_case_name,
test_name);
test_info->matches_filter_ = matches_filter;
const bool is_runnable =
(GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
matches_filter;
const bool is_selected = is_runnable &&
(shard_tests == IGNORE_SHARDING_PROTOCOL ||
ShouldRunTestOnShard(total_shards, shard_index,
num_runnable_tests));
num_runnable_tests += is_runnable;
num_selected_tests += is_selected;
test_info->should_run_ = is_selected;
test_case->set_should_run(test_case->should_run() || is_selected);
}
}
return num_selected_tests;
}
// Prints the given C-string on a single line by replacing all '\n'
// characters with string "\\n". If the output takes more than
// max_length characters, only prints the first max_length characters
// and "...".
static void PrintOnOneLine(const char* str, int max_length) {
if (str != NULL) {
for (int i = 0; *str != '\0'; ++str) {
if (i >= max_length) {
printf("...");
break;
}
if (*str == '\n') {
printf("\\n");
i += 2;
} else {
printf("%c", *str);
++i;
}
}
}
}
// Prints the names of the tests matching the user-specified filter flag.
void UnitTestImpl::ListTestsMatchingFilter() {
// Print at most this many characters for each type/value parameter.
const int kMaxParamLength = 250;
for (size_t i = 0; i < test_cases_.size(); i++) {
const TestCase* const test_case = test_cases_[i];
bool printed_test_case_name = false;
for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
const TestInfo* const test_info =
test_case->test_info_list()[j];
if (test_info->matches_filter_) {
if (!printed_test_case_name) {
printed_test_case_name = true;
printf("%s.", test_case->name());
if (test_case->type_param() != NULL) {
printf(" # %s = ", kTypeParamLabel);
// We print the type parameter on a single line to make
// the output easy to parse by a program.
PrintOnOneLine(test_case->type_param(), kMaxParamLength);
}
printf("\n");
}
printf(" %s", test_info->name());
if (test_info->value_param() != NULL) {
printf(" # %s = ", kValueParamLabel);
// We print the value parameter on a single line to make the
// output easy to parse by a program.
PrintOnOneLine(test_info->value_param(), kMaxParamLength);
}
printf("\n");
}
}
}
fflush(stdout);
}
// Sets the OS stack trace getter.
//
// Does nothing if the input and the current OS stack trace getter are
// the same; otherwise, deletes the old getter and makes the input the
// current getter.
void UnitTestImpl::set_os_stack_trace_getter(
OsStackTraceGetterInterface* getter) {
if (os_stack_trace_getter_ != getter) {
delete os_stack_trace_getter_;
os_stack_trace_getter_ = getter;
}
}
// Returns the current OS stack trace getter if it is not NULL;
// otherwise, creates an OsStackTraceGetter, makes it the current
// getter, and returns it.
OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {
if (os_stack_trace_getter_ == NULL) {
#ifdef GTEST_OS_STACK_TRACE_GETTER_
os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;
#else
os_stack_trace_getter_ = new OsStackTraceGetter;
#endif // GTEST_OS_STACK_TRACE_GETTER_
}
return os_stack_trace_getter_;
}
// Returns the TestResult for the test that's currently running, or
// the TestResult for the ad hoc test if no test is running.
TestResult* UnitTestImpl::current_test_result() {
return current_test_info_ ?
&(current_test_info_->result_) : &ad_hoc_test_result_;
}
// Shuffles all test cases, and the tests within each test case,
// making sure that death tests are still run first.
void UnitTestImpl::ShuffleTests() {
// Shuffles the death test cases.
ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_);
// Shuffles the non-death test cases.
ShuffleRange(random(), last_death_test_case_ + 1,
static_cast<int>(test_cases_.size()), &test_case_indices_);
// Shuffles the tests inside each test case.
for (size_t i = 0; i < test_cases_.size(); i++) {
test_cases_[i]->ShuffleTests(random());
}
}
// Restores the test cases and tests to their order before the first shuffle.
void UnitTestImpl::UnshuffleTests() {
for (size_t i = 0; i < test_cases_.size(); i++) {
// Unshuffles the tests in each test case.
test_cases_[i]->UnshuffleTests();
// Resets the index of each test case.
test_case_indices_[i] = static_cast<int>(i);
}
}
// Returns the current OS stack trace as an std::string.
//
// The maximum number of stack frames to be included is specified by
// the gtest_stack_trace_depth flag. The skip_count parameter
// specifies the number of top frames to be skipped, which doesn't
// count against the number of frames to be included.
//
// For example, if Foo() calls Bar(), which in turn calls
// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in
// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.
std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,
int skip_count) {
// We pass skip_count + 1 to skip this wrapper function in addition
// to what the user really wants to skip.
return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);
}
// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to
// suppress unreachable code warnings.
namespace {
class ClassUniqueToAlwaysTrue {};
}
bool IsTrue(bool condition) { return condition; }
bool AlwaysTrue() {
#if GTEST_HAS_EXCEPTIONS
// This condition is always false so AlwaysTrue() never actually throws,
// but it makes the compiler think that it may throw.
if (IsTrue(false))
throw ClassUniqueToAlwaysTrue();
#endif // GTEST_HAS_EXCEPTIONS
return true;
}
// If *pstr starts with the given prefix, modifies *pstr to be right
// past the prefix and returns true; otherwise leaves *pstr unchanged
// and returns false. None of pstr, *pstr, and prefix can be NULL.
bool SkipPrefix(const char* prefix, const char** pstr) {
const size_t prefix_len = strlen(prefix);
if (strncmp(*pstr, prefix, prefix_len) == 0) {
*pstr += prefix_len;
return true;
}
return false;
}
// Parses a string as a command line flag. The string should have
// the format "--flag=value". When def_optional is true, the "=value"
// part can be omitted.
//
// Returns the value of the flag, or NULL if the parsing failed.
static const char* ParseFlagValue(const char* str,
const char* flag,
bool def_optional) {
// str and flag must not be NULL.
if (str == NULL || flag == NULL) return NULL;
// The flag must start with "--" followed by GTEST_FLAG_PREFIX_.
const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag;
const size_t flag_len = flag_str.length();
if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;
// Skips the flag name.
const char* flag_end = str + flag_len;
// When def_optional is true, it's OK to not have a "=value" part.
if (def_optional && (flag_end[0] == '\0')) {
return flag_end;
}
// If def_optional is true and there are more characters after the
// flag name, or if def_optional is false, there must be a '=' after
// the flag name.
if (flag_end[0] != '=') return NULL;
// Returns the string after "=".
return flag_end + 1;
}
// Parses a string for a bool flag, in the form of either
// "--flag=value" or "--flag".
//
// In the former case, the value is taken as true as long as it does
// not start with '0', 'f', or 'F'.
//
// In the latter case, the value is taken as true.
//
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
// Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, true);
// Aborts if the parsing failed.
if (value_str == NULL) return false;
// Converts the string value to a bool.
*value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');
return true;
}
// Parses a string for an Int32 flag, in the form of
// "--flag=value".
//
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
// Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, false);
// Aborts if the parsing failed.
if (value_str == NULL) return false;
// Sets *value to the value of the flag.
return ParseInt32(Message() << "The value of flag --" << flag,
value_str, value);
}
// Parses a string for a string flag, in the form of
// "--flag=value".
//
// On success, stores the value of the flag in *value, and returns
// true. On failure, returns false without changing *value.
static bool ParseStringFlag(const char* str,
const char* flag,
std::string* value) {
// Gets the value of the flag as a string.
const char* const value_str = ParseFlagValue(str, flag, false);
// Aborts if the parsing failed.
if (value_str == NULL) return false;
// Sets *value to the value of the flag.
*value = value_str;
return true;
}
// Determines whether a string has a prefix that Google Test uses for its
// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.
// If Google Test detects that a command line flag has its prefix but is not
// recognized, it will print its help message. Flags starting with
// GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test
// internal flags and do not trigger the help message.
static bool HasGoogleTestFlagPrefix(const char* str) {
return (SkipPrefix("--", &str) ||
SkipPrefix("-", &str) ||
SkipPrefix("/", &str)) &&
!SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) &&
(SkipPrefix(GTEST_FLAG_PREFIX_, &str) ||
SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str));
}
// Prints a string containing code-encoded text. The following escape
// sequences can be used in the string to control the text color:
//
// @@ prints a single '@' character.
// @R changes the color to red.
// @G changes the color to green.
// @Y changes the color to yellow.
// @D changes to the default terminal text color.
//
// TODO(wan@google.com): Write tests for this once we add stdout
// capturing to Google Test.
static void PrintColorEncoded(const char* str) {
GTestColor color = COLOR_DEFAULT; // The current color.
// Conceptually, we split the string into segments divided by escape
// sequences. Then we print one segment at a time. At the end of
// each iteration, the str pointer advances to the beginning of the
// next segment.
for (;;) {
const char* p = strchr(str, '@');
if (p == NULL) {
ColoredPrintf(color, "%s", str);
return;
}
ColoredPrintf(color, "%s", std::string(str, p).c_str());
const char ch = p[1];
str = p + 2;
if (ch == '@') {
ColoredPrintf(color, "@");
} else if (ch == 'D') {
color = COLOR_DEFAULT;
} else if (ch == 'R') {
color = COLOR_RED;
} else if (ch == 'G') {
color = COLOR_GREEN;
} else if (ch == 'Y') {
color = COLOR_YELLOW;
} else {
--str;
}
}
}
static const char kColorEncodedHelpMessage[] =
"This program contains tests written using " GTEST_NAME_ ". You can use the\n"
"following command line flags to control its behavior:\n"
"\n"
"Test Selection:\n"
" @G--" GTEST_FLAG_PREFIX_ "list_tests@D\n"
" List the names of all tests instead of running them. The name of\n"
" TEST(Foo, Bar) is \"Foo.Bar\".\n"
" @G--" GTEST_FLAG_PREFIX_ "filter=@YPOSTIVE_PATTERNS"
"[@G-@YNEGATIVE_PATTERNS]@D\n"
" Run only the tests whose name matches one of the positive patterns but\n"
" none of the negative patterns. '?' matches any single character; '*'\n"
" matches any substring; ':' separates two patterns.\n"
" @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n"
" Run all disabled tests too.\n"
"\n"
"Test Execution:\n"
" @G--" GTEST_FLAG_PREFIX_ "repeat=@Y[COUNT]@D\n"
" Run the tests repeatedly; use a negative count to repeat forever.\n"
" @G--" GTEST_FLAG_PREFIX_ "shuffle@D\n"
" Randomize tests' orders on every iteration.\n"
" @G--" GTEST_FLAG_PREFIX_ "random_seed=@Y[NUMBER]@D\n"
" Random number seed to use for shuffling test orders (between 1 and\n"
" 99999, or 0 to use a seed based on the current time).\n"
"\n"
"Test Output:\n"
" @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n"
" Enable/disable colored output. The default is @Gauto@D.\n"
" @G--" GTEST_FLAG_PREFIX_ "print_time=0@D\n"
" Don't print the elapsed time of each test.\n"
" @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G"
GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n"
" Generate an XML report in the given directory or with the given file\n"
" name. @YFILE_PATH@D defaults to @Gtest_detail.xml@D.\n"
#if GTEST_CAN_STREAM_RESULTS_
" @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n"
" Stream test results to the given server.\n"
#endif // GTEST_CAN_STREAM_RESULTS_
"\n"
"Assertion Behavior:\n"
#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
" @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n"
" Set the default death test style.\n"
#endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS
" @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n"
" Turn assertion failures into debugger break-points.\n"
" @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n"
" Turn assertion failures into C++ exceptions.\n"
" @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n"
" Do not report exceptions as test failures. Instead, allow them\n"
" to crash the program or throw a pop-up (on Windows).\n"
"\n"
"Except for @G--" GTEST_FLAG_PREFIX_ "list_tests@D, you can alternatively set "
"the corresponding\n"
"environment variable of a flag (all letters in upper-case). For example, to\n"
"disable colored text output, you can either specify @G--" GTEST_FLAG_PREFIX_
"color=no@D or set\n"
"the @G" GTEST_FLAG_PREFIX_UPPER_ "COLOR@D environment variable to @Gno@D.\n"
"\n"
"For more information, please read the " GTEST_NAME_ " documentation at\n"
"@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ "\n"
"(not one in your own code or tests), please report it to\n"
"@G<" GTEST_DEV_EMAIL_ ">@D.\n";
static bool ParseGoogleTestFlag(const char* const arg) {
return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,
>EST_FLAG(also_run_disabled_tests)) ||
ParseBoolFlag(arg, kBreakOnFailureFlag,
>EST_FLAG(break_on_failure)) ||
ParseBoolFlag(arg, kCatchExceptionsFlag,
>EST_FLAG(catch_exceptions)) ||
ParseStringFlag(arg, kColorFlag, >EST_FLAG(color)) ||
ParseStringFlag(arg, kDeathTestStyleFlag,
>EST_FLAG(death_test_style)) ||
ParseBoolFlag(arg, kDeathTestUseFork,
>EST_FLAG(death_test_use_fork)) ||
ParseStringFlag(arg, kFilterFlag, >EST_FLAG(filter)) ||
ParseStringFlag(arg, kInternalRunDeathTestFlag,
>EST_FLAG(internal_run_death_test)) ||
ParseBoolFlag(arg, kListTestsFlag, >EST_FLAG(list_tests)) ||
ParseStringFlag(arg, kOutputFlag, >EST_FLAG(output)) ||
ParseBoolFlag(arg, kPrintTimeFlag, >EST_FLAG(print_time)) ||
ParseInt32Flag(arg, kRandomSeedFlag, >EST_FLAG(random_seed)) ||
ParseInt32Flag(arg, kRepeatFlag, >EST_FLAG(repeat)) ||
ParseBoolFlag(arg, kShuffleFlag, >EST_FLAG(shuffle)) ||
ParseInt32Flag(arg, kStackTraceDepthFlag,
>EST_FLAG(stack_trace_depth)) ||
ParseStringFlag(arg, kStreamResultToFlag,
>EST_FLAG(stream_result_to)) ||
ParseBoolFlag(arg, kThrowOnFailureFlag,
>EST_FLAG(throw_on_failure));
}
#if GTEST_USE_OWN_FLAGFILE_FLAG_
static void LoadFlagsFromFile(const std::string& path) {
FILE* flagfile = posix::FOpen(path.c_str(), "r");
if (!flagfile) {
GTEST_LOG_(FATAL) << "Unable to open file \""
<< GTEST_FLAG(flagfile)
<< "\"";
}
std::string contents(ReadEntireFile(flagfile));
posix::FClose(flagfile);
std::vector<std::string> lines;
SplitString(contents, '\n', &lines);
for (size_t i = 0; i < lines.size(); ++i) {
if (lines[i].empty())
continue;
if (!ParseGoogleTestFlag(lines[i].c_str()))
g_help_flag = true;
}
}
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
// Parses the command line for Google Test flags, without initializing
// other parts of Google Test. The type parameter CharType can be
// instantiated to either char or wchar_t.
template <typename CharType>
void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {
for (int i = 1; i < *argc; i++) {
const std::string arg_string = StreamableToString(argv[i]);
const char* const arg = arg_string.c_str();
using internal::ParseBoolFlag;
using internal::ParseInt32Flag;
using internal::ParseStringFlag;
bool remove_flag = false;
if (ParseGoogleTestFlag(arg)) {
remove_flag = true;
#if GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (ParseStringFlag(arg, kFlagfileFlag, >EST_FLAG(flagfile))) {
LoadFlagsFromFile(GTEST_FLAG(flagfile));
remove_flag = true;
#endif // GTEST_USE_OWN_FLAGFILE_FLAG_
} else if (arg_string == "--help" || arg_string == "-h" ||
arg_string == "-?" || arg_string == "/?" ||
HasGoogleTestFlagPrefix(arg)) {
// Both help flag and unrecognized Google Test flags (excluding
// internal ones) trigger help display.
g_help_flag = true;
}
if (remove_flag) {
// Shift the remainder of the argv list left by one. Note
// that argv has (*argc + 1) elements, the last one always being
// NULL. The following loop moves the trailing NULL element as
// well.
for (int j = i; j != *argc; j++) {
argv[j] = argv[j + 1];
}
// Decrements the argument count.
(*argc)--;
// We also need to decrement the iterator as we just removed
// an element.
i--;
}
}
if (g_help_flag) {
// We print the help here instead of in RUN_ALL_TESTS(), as the
// latter may not be called at all if the user is using Google
// Test with another testing framework.
PrintColorEncoded(kColorEncodedHelpMessage);
}
}
// Parses the command line for Google Test flags, without initializing
// other parts of Google Test.
void ParseGoogleTestFlagsOnly(int* argc, char** argv) {
ParseGoogleTestFlagsOnlyImpl(argc, argv);
}
void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {
ParseGoogleTestFlagsOnlyImpl(argc, argv);
}
// The internal implementation of InitGoogleTest().
//
// The type parameter CharType can be instantiated to either char or
// wchar_t.
template <typename CharType>
void InitGoogleTestImpl(int* argc, CharType** argv) {
// We don't want to run the initialization code twice.
if (GTestIsInitialized()) return;
if (*argc <= 0) return;
g_argvs.clear();
for (int i = 0; i != *argc; i++) {
g_argvs.push_back(StreamableToString(argv[i]));
}
ParseGoogleTestFlagsOnly(argc, argv);
GetUnitTestImpl()->PostFlagParsingInit();
}
} // namespace internal
// Initializes Google Test. This must be called before calling
// RUN_ALL_TESTS(). In particular, it parses a command line for the
// flags that Google Test recognizes. Whenever a Google Test flag is
// seen, it is removed from argv, and *argc is decremented.
//
// No value is returned. Instead, the Google Test flag variables are
// updated.
//
// Calling the function for the second time has no user-visible effect.
void InitGoogleTest(int* argc, char** argv) {
#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);
#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
internal::InitGoogleTestImpl(argc, argv);
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
}
// This overloaded version can be used in Windows programs compiled in
// UNICODE mode.
void InitGoogleTest(int* argc, wchar_t** argv) {
#if defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_(argc, argv);
#else // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
internal::InitGoogleTestImpl(argc, argv);
#endif // defined(GTEST_CUSTOM_INIT_GOOGLE_TEST_FUNCTION_)
}
std::string TempDir() {
#if defined(GTEST_CUSTOM_TEMPDIR_FUNCTION_)
return GTEST_CUSTOM_TEMPDIR_FUNCTION_();
#endif
#if GTEST_OS_WINDOWS_MOBILE
return "\\temp\\";
#elif GTEST_OS_WINDOWS
const char* temp_dir = internal::posix::GetEnv("TEMP");
if (temp_dir == NULL || temp_dir[0] == '\0')
return "\\temp\\";
else if (temp_dir[strlen(temp_dir) - 1] == '\\')
return temp_dir;
else
return std::string(temp_dir) + "\\";
#elif GTEST_OS_LINUX_ANDROID
return "/sdcard/";
#else
return "/tmp/";
#endif // GTEST_OS_WINDOWS_MOBILE
}
} // namespace testing
| [
"dahlstrom@google.com"
] | dahlstrom@google.com |
fe4b5faccf96eaeaa260f69e9af34efdfe513fbe | fbce0adf0f5de7c29ada18456bf50245f980c97f | /Heap/Heap/heap_hzh.h | 5017b80dd1d5ac32b58de55942cb7690ee9c262b | [] | no_license | gaoyuanhezhihao/Some_Data_Structure | 15d4c691db68025cd0a3d86e1352a8fac1328b2b | bae01e016fa871b144dec76b9da06e3ef080c92d | refs/heads/master | 2021-01-10T11:12:09.692705 | 2018-04-22T07:05:42 | 2018-04-22T07:05:42 | 54,189,306 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,954 | h | template <typename Comparable>
class BinaryHeap
{
public:
explicit BinaryHeap(int capacity = 100);
explicit BinaryHeap(const vector<Comparable> & items);
bool isEmpty() const;
const Comparable & findMin() const;
void insert( const Comparable & x);
void insert( Comparable && x);
void deleteMin();
void deleteMin( Comparable & minItem);
void makeEmpty();
private:
int currentSize;
vector<Comparable> array;
void buildHeap();
void percolateDown( int hole );
};
template <typename Comparable>
void BinaryHeap<Comparable>::insert(const Comparable & x)
{
if(currentSize == array.size() - 1 )
array.resize( array.size() * 2);
// Percolate up
int hole = ++ currentSize;
Comparable copy = x;
array[0] = std::move( copy );
for(; x< array[hole / 2]; hole /= 2)
array[ hole ] = std::move( array[ hole / 2] );
array[ hole ] = std::move( array[ 0 ] );
}
/**
* Remove the minimum item.
* Throws UnderflowException if empty.
*/
template <typename Comparable>
void BinaryHeap<Comparable>::deleteMin()
{
if( isEmpty())
{
std::cout << "UnderflowException"<<endl;
}
minItem = sta::move( array[ 1 ] );
array[ 1 ] = std::move( array[ currentSize-- ] );
percolateDown( 1 );
}
/**
* Internal method to percolate down in the heap.
* hole is the index at which the percolate begins.
*/
template <typename Comparable>
void BinaryHeap<Comparable>::percolate(int hole)
{
int child = 0;
Comparable tmp = array[hole];
for(;hole*2 < currentSize;hole = child)
{
child = hole * 2;
if(array[child] < array[child+1])
{
child++;
}
if(array[hole] > array[child])
{
array[hole] = std::move(array[child]);
}
else
{
break;
}
}
array[hole] = std::move(tmp);
}
template <typename Comparable>
explicit BinaryHeap<Comparable>::BinaryHeap( const vector<Comparable> & items )
: array( item.size() + 10), currentSize( item.size())
{
for( int i = 0; i < items.size(); i++)
{
array[ i+1 ] = items[ i ];
}
buildHeap();
}
| [
"gaoyuanhezhihao@139.com"
] | gaoyuanhezhihao@139.com |
e148fc1457e182fe9eb8fbde8845c861772cf48f | 8e638b89dd3e7ed7f2709d72d76074acd20a5742 | /sketch_nov10a/sketch_nov10a.ino | 2e33a10d7aa90005cd2be27f6db279dfb775ecf0 | [] | no_license | indigoshakti47/Arduino | 57a0700166918c2a2c6b64a7b74664519895f47e | 0b3c88446da013b2799a2a20d5f08afcaa27fa9c | refs/heads/main | 2023-06-22T09:31:09.225854 | 2021-07-18T19:02:01 | 2021-07-18T19:02:01 | 387,249,316 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 169 | ino | void setup() {
// put your setup code here, to run once:
pinMode(2,INPUT);
Serial.begin(9600);
}
void loop() {
Serial.println(digitalRead(2));
}
| [
"indigoshakti47@unseen.is"
] | indigoshakti47@unseen.is |
c6006012ba831a0f9b32f308c83ee065a00345b0 | 3333db1df422b9751cdc540c357c31ab33e2063b | /Source/Editor.h | de7c78600639f0a9de707d009cf551fda7cd7238 | [] | no_license | haskellstudio/juceStudy | 4f14d1d3edfe4075b88bd9b38c0fc8bc13804006 | b0910693ea98f8b263798571cf4497aab74819b8 | refs/heads/master | 2021-01-21T20:52:57.634628 | 2018-01-30T09:13:42 | 2018-01-30T09:13:42 | 92,286,741 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,196 | h | /*
==============================================================================
This is an automatically generated GUI class created by the Projucer!
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 5.0.2
------------------------------------------------------------------------------
The Projucer is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright (c) 2015 - ROLI Ltd.
==============================================================================
*/
#pragma once
//[Headers] -- You can add your own extra header files here --
#include "../JuceLibraryCode/JuceHeader.h"
//[/Headers]
//==============================================================================
/**
//[Comments]
An auto-generated component, created by the Projucer.
Describe your class and how it works here!
//[/Comments]
*/
class Editor : public Component
{
public:
//==============================================================================
Editor ();
~Editor();
//==============================================================================
//[UserMethods] -- You can add your own custom methods in this section.
//[/UserMethods]
void paint (Graphics& g) override;
void resized() override;
private:
//[UserVariables] -- You can add your own custom variables in this section.
CodeDocument vertexDocument, fragmentDocument;
//CodeEditorComponent* vertexEditorComp;
//CodeEditorComponent* fragmentEditorComp;
//[/UserVariables]
//==============================================================================
ScopedPointer<TabbedComponent> tabbedComponent;
ScopedPointer<Label> label;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Editor)
};
//[EndFile] You can add extra defines here...
//[/EndFile]
| [
"haskellstudio@gmail.com"
] | haskellstudio@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.